Skip to content
Snippets Groups Projects
Commit 6178935c authored by baldwinlouie's avatar baldwinlouie Committed by Yas Naoi
Browse files

Issue #3519817 by baldwinlouie, yas: Change granularity to granularity_id in createOauthScope()

parent 6100e77b
No related branches found
No related tags found
1 merge request!2337Recompile SPA to fix redirection error. Align `Oauth2Scope::create` to...
Pipeline #480685 canceled
......@@ -107,7 +107,7 @@ ID of the account to assume.`);Drupal.t("enable");Drupal.t("enabled");Drupal.t("
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var _P=I.exports,vP=Symbol.for("react.element"),gP=Symbol.for("react.fragment"),bP=Object.prototype.hasOwnProperty,NP=_P.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,wP={key:!0,ref:!0,__self:!0,__source:!0};function Sw(e,t,n){var a,i={},l=null,s=null;n!==void 0&&(l=""+n),t.key!==void 0&&(l=""+t.key),t.ref!==void 0&&(s=t.ref);for(a in t)bP.call(t,a)&&!wP.hasOwnProperty(a)&&(i[a]=t[a]);if(e&&e.defaultProps)for(a in t=e.defaultProps,t)i[a]===void 0&&(i[a]=t[a]);return{$$typeof:vP,type:e,key:l,ref:s,props:i,_owner:NP.current}}jp.Fragment=gP;jp.jsx=Sw;jp.jsxs=Sw;(function(e){e.exports=jp})(Bp);const pe=Bp.exports.Fragment,d=Bp.exports.jsx,W=Bp.exports.jsxs;var Jm=1073741823,Lv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{};function SP(){var e="__global_unique_id__";return Lv[e]=(Lv[e]||0)+1}function DP(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function kP(e){var t=[];return{on:function(a){t.push(a)},off:function(a){t=t.filter(function(i){return i!==a})},get:function(){return e},set:function(a,i){e=a,t.forEach(function(l){return l(e,i)})}}}function xP(e){return Array.isArray(e)?e[0]:e}function CP(e,t){var n,a,i="__create-react-context-"+SP()+"__",l=function(c){dr(m,c);function m(){for(var y,_=arguments.length,g=new Array(_),b=0;b<_;b++)g[b]=arguments[b];return y=c.call.apply(c,[this].concat(g))||this,y.emitter=kP(y.props.value),y}var f=m.prototype;return f.getChildContext=function(){var _;return _={},_[i]=this.emitter,_},f.componentWillReceiveProps=function(_){if(this.props.value!==_.value){var g=this.props.value,b=_.value,S;DP(g,b)?S=0:(S=typeof t=="function"?t(g,b):Jm,S|=0,S!==0&&this.emitter.set(_.value,S))}},f.render=function(){return this.props.children},m}(Qe.Component);l.childContextTypes=(n={},n[i]=Ar.exports.object.isRequired,n);var s=function(c){dr(m,c);function m(){for(var y,_=arguments.length,g=new Array(_),b=0;b<_;b++)g[b]=arguments[b];return y=c.call.apply(c,[this].concat(g))||this,y.observedBits=void 0,y.state={value:y.getValue()},y.onUpdate=function(S,k){var T=y.observedBits|0;(T&k)!==0&&y.setState({value:y.getValue()})},y}var f=m.prototype;return f.componentWillReceiveProps=function(_){var g=_.observedBits;this.observedBits=g==null?Jm:g},f.componentDidMount=function(){this.context[i]&&this.context[i].on(this.onUpdate);var _=this.props.observedBits;this.observedBits=_==null?Jm:_},f.componentWillUnmount=function(){this.context[i]&&this.context[i].off(this.onUpdate)},f.getValue=function(){return this.context[i]?this.context[i].get():e},f.render=function(){return xP(this.props.children)(this.state.value)},m}(Qe.Component);return s.contextTypes=(a={},a[i]=Ar.exports.object,a),{Provider:l,Consumer:s}}var PP=Qe.createContext||CP,Dw=function(t){var n=PP();return n.displayName=t,n},kw=Dw("Router-History"),ki=Dw("Router"),Up=function(e){dr(t,e),t.computeRootMatch=function(i){return{path:"/",url:"/",params:{},isExact:i==="/"}};function t(a){var i;return i=e.call(this,a)||this,i.state={location:a.history.location},i._isMounted=!1,i._pendingLocation=null,a.staticContext||(i.unlisten=a.history.listen(function(l){i._pendingLocation=l})),i}var n=t.prototype;return n.componentDidMount=function(){var i=this;this._isMounted=!0,this.unlisten&&this.unlisten(),this.props.staticContext||(this.unlisten=this.props.history.listen(function(l){i._isMounted&&i.setState({location:l})})),this._pendingLocation&&this.setState({location:this._pendingLocation})},n.componentWillUnmount=function(){this.unlisten&&(this.unlisten(),this._isMounted=!1,this._pendingLocation=null)},n.render=function(){return Qe.createElement(ki.Provider,{value:{history:this.props.history,location:this.state.location,match:t.computeRootMatch(this.state.location.pathname),staticContext:this.props.staticContext}},Qe.createElement(kw.Provider,{children:this.props.children||null,value:this.props.history}))},t}(Qe.Component);Qe.Component;Qe.Component;var Iv={},TP=1e4,Ev=0;function AP(e,t){var n=""+t.end+t.strict+t.sensitive,a=Iv[n]||(Iv[n]={});if(a[e])return a[e];var i=[],l=es.exports(e,i,t),s={regexp:l,keys:i};return Ev<TP&&(a[e]=s,Ev++),s}function by(e,t){t===void 0&&(t={}),(typeof t=="string"||Array.isArray(t))&&(t={path:t});var n=t,a=n.path,i=n.exact,l=i===void 0?!1:i,s=n.strict,c=s===void 0?!1:s,m=n.sensitive,f=m===void 0?!1:m,y=[].concat(a);return y.reduce(function(_,g){if(!g&&g!=="")return null;if(_)return _;var b=AP(g,{end:l,strict:c,sensitive:f}),S=b.regexp,k=b.keys,T=S.exec(e);if(!T)return null;var x=T[0],C=T.slice(1),P=e===x;return l&&!P?null:{path:g,url:g==="/"&&x===""?"/":x,isExact:P,params:k.reduce(function(O,z,F){return O[z.name]=C[F],O},{})}},null)}function LP(e){return Qe.Children.count(e)===0}var IP=function(e){dr(t,e);function t(){return e.apply(this,arguments)||this}var n=t.prototype;return n.render=function(){var i=this;return Qe.createElement(ki.Consumer,null,function(l){l||Ml(!1);var s=i.props.location||l.location,c=i.props.computedMatch?i.props.computedMatch:i.props.path?by(s.pathname,i.props):l.match,m=Cn({},l,{location:s,match:c}),f=i.props,y=f.children,_=f.component,g=f.render;return Array.isArray(y)&&LP(y)&&(y=null),Qe.createElement(ki.Provider,{value:m},m.match?y?typeof y=="function"?y(m):y:_?Qe.createElement(_,m):g?g(m):null:typeof y=="function"?y(m):null)})},t}(Qe.Component);function Ny(e){return e.charAt(0)==="/"?e:"/"+e}function EP(e,t){return e?Cn({},t,{pathname:Ny(e)+t.pathname}):t}function RP(e,t){if(!e)return t;var n=Ny(e);return t.pathname.indexOf(n)!==0?t:Cn({},t,{pathname:t.pathname.substr(n.length)})}function Rv(e){return typeof e=="string"?e:On(e)}function Xm(e){return function(){Ml(!1)}}function Ov(){}Qe.Component;var OP=function(e){dr(t,e);function t(){return e.apply(this,arguments)||this}var n=t.prototype;return n.render=function(){var i=this;return Qe.createElement(ki.Consumer,null,function(l){l||Ml(!1);var s=i.props.location||l.location,c,m;return Qe.Children.forEach(i.props.children,function(f){if(m==null&&Qe.isValidElement(f)){c=f;var y=f.props.path||f.props.from;m=y?by(s.pathname,Cn({},f.props,{path:y})):l.match}}),m?Qe.cloneElement(c,{location:s,computedMatch:m}):null})},t}(Qe.Component),wy=Qe.useContext;function pr(){return wy(kw)}function xw(){return wy(ki).location}function ut(){var e=wy(ki).match;return e?e.params:{}}var VP=function(e){dr(t,e);function t(){for(var a,i=arguments.length,l=new Array(i),s=0;s<i;s++)l[s]=arguments[s];return a=e.call.apply(e,[this].concat(l))||this,a.history=FC(a.props),a}var n=t.prototype;return n.render=function(){return d(Up,{history:this.history,children:this.props.children})},t}(Qe.Component);Qe.Component;var $f=function(t,n){return typeof t=="function"?t(n):t},zf=function(t,n){return typeof t=="string"?ea(t,null,null,n):t},Sy=function(t){return t},Vo=Qe.forwardRef;typeof Vo>"u"&&(Vo=Sy);function MP(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var $P=Vo(function(e,t){var n=e.innerRef,a=e.navigate,i=e.onClick,l=$u(e,["innerRef","navigate","onClick"]),s=l.target,c=Cn({},l,{onClick:function(f){try{i&&i(f)}catch(y){throw f.preventDefault(),y}!f.defaultPrevented&&f.button===0&&(!s||s==="_self")&&!MP(f)&&(f.preventDefault(),a())}});return Sy!==Vo?c.ref=t||n:c.ref=n,d("a",{...c})}),Ye=Vo(function(e,t){var n=e.component,a=n===void 0?$P:n,i=e.replace,l=e.to,s=e.innerRef,c=$u(e,["component","replace","to","innerRef"]);return Qe.createElement(ki.Consumer,null,function(m){m||Ml(!1);var f=m.history,y=zf($f(l,m.location),m.location),_=y?f.createHref(y):"",g=Cn({},c,{href:_,navigate:function(){var S=$f(l,m.location),k=On(m.location)===On(zf(S)),T=i||k?f.replace:f.push;T(S)}});return Sy!==Vo?g.ref=t||s:g.innerRef=s,Qe.createElement(a,g)})}),Cw=function(t){return t},Wd=Qe.forwardRef;typeof Wd>"u"&&(Wd=Cw);function zP(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter(function(a){return a}).join(" ")}Wd(function(e,t){var n=e["aria-current"],a=n===void 0?"page":n,i=e.activeClassName,l=i===void 0?"active":i,s=e.activeStyle,c=e.className,m=e.exact,f=e.isActive,y=e.location,_=e.sensitive,g=e.strict,b=e.style,S=e.to,k=e.innerRef,T=$u(e,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","sensitive","strict","style","to","innerRef"]);return Qe.createElement(ki.Consumer,null,function(x){x||Ml(!1);var C=y||x.location,P=zf($f(S,C),C),O=P.pathname,z=O&&O.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),F=z?by(C.pathname,{path:z,exact:m,sensitive:_,strict:g}):null,j=!!(f?f(F,C):F),H=typeof c=="function"?c(j):c,ne=typeof b=="function"?b(j):b;j&&(H=zP(H,l),ne=Cn({},ne,s));var ae=Cn({"aria-current":j&&a||null,className:H,style:ne,to:P},T);return Cw!==Wd?ae.ref=t||k:ae.innerRef=k,d(Ye,{...ae})})});const gt=({action:e,designLabel:t,bundleId:n,entityData:a,text:i})=>{const l=ut(),s=document.querySelectorAll("h1.page-header");if(s.length!==1)return d(pe,{});const c=s[0],m=cr(l.entityName?l.entityName:""),f=Ti(a),y=e!==void 0?e:l.action,_=y!==void 0?y==="create"?"Add":kn(y.replace("_"," ")):void 0;let g="Cloud Dashboard";if(l.cloudServiceProvider!==void 0&&y===void 0){const k=uw(l.cloudServiceProvider).filter(T=>T.entityName===l.entityName);g=k.length>=1?k[0].labelName:`${kn(m)}s`,l.cloudContext===void 0&&(g=`All ${xl(l.cloudServiceProvider)} ${g}`)}_!==void 0&&a===void 0&&(g=_+" "+m),_!==void 0&&a!==void 0&&(g=_+" "+f),_!==void 0&&y==="delete"&&(g="Are you sure you want to delete the "+m+" "+f+"?"),_===void 0&&a!==void 0&&(g="Name: "+f),t!==void 0&&(g=kn(t)+" list"),y===void 0&&t!==void 0&&t==="store"&&n!==void 0&&(g=cr(n)),y==="console_output"?g=`Console log of ${m}`:y==="console"?g=`Console of ${m}`:y==="action_log"?g=`Action log of ${m}`:y==="launch"?g=`Are you sure you want to launch instance(s) or resource(s) from ${f}?`:y==="create_image"&&(g=`Create an image for instance ${f}${a?" ("+a.attributes.instance_id+")":""}`),i&&(g=i);const b=document.createElement("div");b.className="field field--name-name field--type-string field--label-hidden field--item",b.innerText=g,c.innerHTML="",c.appendChild(b);const S=document.querySelectorAll("#navbar > nav > div.navbar-header > div > a.name.navbar-brand");if(S.length===1){const k=S[0].textContent;document.title=g+" | "+k}return d(pe,{})},bt=({action:e,designLabel:t,entityData:n})=>{const a=ut(),i=xw().pathname,l=document.querySelectorAll("div.breadcrumb-wrapper");if(l.length===0)return d(pe,{});const s=l[0].parentNode;if(s===null)return d(pe,{});for(const k of l)k.remove();const c=s.querySelector(".contextual-region");if(c===null)return d(pe,{});const m=["Cloud service providers"],f=e!==void 0?e:a.action;if(f!==void 0){const k=xl(a.cloudServiceProvider?a.cloudServiceProvider:""),T=cr(a.entityName?a.entityName:""),x=f==="create"?"Add":f==="import"?"Import":kn(f);if(m.push(`${k} ${T}`),n!==void 0){const C=Ti(n);C!==""&&m.push(C)}m.push(`${x} ${k} ${T}`)}t!==void 0&&(m.push("Design"),m.push(`${t} list`));const y=i.split("/"),_="/clouds/dashboard";y.forEach((k,T)=>{k==="cloud_launch_template"&&(y[T]="server_template")});const g=y.map((k,T)=>{if(T===1||T===2)return null;let x=_+y.slice(0,T+1).join("/");return T===0&&(x=_+"/providers"),x}).filter(Boolean),b=document.createElement("div");b.className="breadcrumb-wrapper";const S=document.createElement("ol");return S.className="breadcrumb",m.forEach((k,T)=>{var C;const x=document.createElement("li");if(T===m.length-1&&T>0)x.className="active",x.textContent=k;else{const P=document.createElement("a");P.href=(C=g[T])!=null?C:"#",P.textContent=k,x.appendChild(P)}S.appendChild(x)}),b.appendChild(S),s.insertBefore(b,c),d(pe,{})},Pw=mt,BP=mt+"/providers",kd=e=>{window.alert(`Error: ${e}`),console.error(`Error: ${e}`)},jP=async()=>{const e=await Jt("/clouds/cloud_dashboard/config/client_id"),t=await Jt("/clouds/cloud_dashboard/config/callback_uri"),n=await Jt("/clouds/cloud_dashboard/config/scope");if(!e.ok||!t.ok||!n.ok){console.group("OAuth2 Callback URL"),e.ok||(console.error("Client ID:"),console.error(e.error)),t.ok||(console.error("Callback URI:"),console.error(t.error)),n.ok||(console.error("Scope ID:"),console.error(n.error)),console.groupEnd(),kd("Could not obtain the information required for login.");return}const a=(await e.response.json()).id,i=(await t.response.json()).uri,l=(await n.response.json()).scope,s=`/oauth/authorize?response_type=code&client_id=${a}&redirect_uri=${i}&scope=${l}`;debugger;console.log(s)},UP=async()=>{console.group("Authorization Code Grant");const e=await Jt("/clouds/cloud_dashboard/config/client_id"),t=await Jt("/clouds/cloud_dashboard/config/callback_uri");if(!e.ok||!t.ok)return console.error("Client ID : No"),console.error("Authorization failed."),console.groupEnd(),null;const n=(await e.response.json()).id,a=(await t.response.json()).uri;console.log("Client ID : Yes");const l=new URL(window.location.href).searchParams.get("code");if(l===null)return console.error("Authorization code : No"),console.error("Authorization failed."),console.groupEnd(),null;console.log("Authorization code : Yes");const s=new FormData;s.append("grant_type","authorization_code"),s.append("client_id",n),s.append("client_secret",zN),s.append("code",l),s.append("redirect_uri",a);const c=await Jt("/oauth/token",{method:"POST",body:s});if(!c.ok)return console.error("Token Request : No"),console.error("Authorization failed."),console.groupEnd(),null;console.log("Token Request : Yes");const m=await c.response.json();if(!("access_token"in m))return console.error("Access Token : No"),console.error("Authorization failed."),console.groupEnd(),null;console.log("Access Token : Yes"),console.groupEnd();const f=m.access_token,y=m.refresh_token,_=new Date().getTime()+m.expires_in*1e3;return{accessToken:f,refreshToken:y,expiresDatetime:`${_}`}},WP=async e=>{console.group("Authorization Code Grant");const t=await Jt("/clouds/cloud_dashboard/config/client_id");if(!t.ok)return console.error("Client ID : No"),console.error("Authorization failed."),null;const n=(await t.response.json()).id;console.log("Client ID : Yes");const a=new FormData;a.append("grant_type","refresh_token"),a.append("client_id",n),a.append("client_secret",zN),a.append("refresh_token",e);const i=await Jt("/oauth/token",{method:"POST",body:a});if(!i.ok)return console.error("Token Request : No"),console.error("Refresh failed."),console.groupEnd(),null;console.log("Token Request : Yes");const l=await i.response.json();if(!("access_token"in l))return console.error("Access Token : No"),console.error("Authorization failed."),console.groupEnd(),null;console.log("Access Token : Yes"),console.groupEnd();const s=l.access_token,c=l.refresh_token,m=new Date().getTime()+l.expires_in*1e3;return{accessToken:s,refreshToken:c,expiresDatetime:`${m}`}},Yc=()=>{window.localStorage.removeItem("accessToken"),window.localStorage.removeItem("refreshToken"),window.localStorage.removeItem("expiresDatetime"),window.location.href=Pw},Tw=()=>{const[e,t]=I.exports.useState(Gs("accessToken","")),[n,a]=I.exports.useState(Gs("refreshToken","")),[i,l]=I.exports.useState(Gs("expiresDatetime",""));return I.exports.useEffect(()=>{console.group("Token status"),console.log("accessToken=",e),console.log("refreshToken=",n),console.log("expiresDatetime=",i);const m=new Date(parseInt(i));console.log(`(${m.toString()})`),console.groupEnd()},[e,n,i]),{toCallbackUrl:jP,getTokenByAuthorizationCodeGrant:async()=>{const m=await UP();m!==null?(si("accessToken",m.accessToken),si("refreshToken",m.refreshToken),si("expiresDatetime",m.expiresDatetime),t(m.accessToken),a(m.refreshToken),l(m.expiresDatetime),window.location.href=BP):(kd("Could not obtain the information required for login."),window.location.href=Pw)},checkAndRefreshToken:async()=>{if(e===""||n===""||i===""){Yc();return}if(!(new Date().getTime()<=parseInt(i,10)))try{const f=await WP(n);f!==null?(si("accessToken",f.accessToken),si("refreshToken",f.refreshToken),si("expiresDatetime",f.expiresDatetime),t(f.accessToken),a(f.refreshToken),l(f.expiresDatetime)):(kd("Could not renew token expiration date."),Yc())}catch(f){kd("Could not renew token expiration date."),console.error(f),Yc()}},logout:Yc}};var Aw={exports:{}};/*!
*/var _P=I.exports,vP=Symbol.for("react.element"),gP=Symbol.for("react.fragment"),bP=Object.prototype.hasOwnProperty,NP=_P.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,wP={key:!0,ref:!0,__self:!0,__source:!0};function Sw(e,t,n){var a,i={},l=null,s=null;n!==void 0&&(l=""+n),t.key!==void 0&&(l=""+t.key),t.ref!==void 0&&(s=t.ref);for(a in t)bP.call(t,a)&&!wP.hasOwnProperty(a)&&(i[a]=t[a]);if(e&&e.defaultProps)for(a in t=e.defaultProps,t)i[a]===void 0&&(i[a]=t[a]);return{$$typeof:vP,type:e,key:l,ref:s,props:i,_owner:NP.current}}jp.Fragment=gP;jp.jsx=Sw;jp.jsxs=Sw;(function(e){e.exports=jp})(Bp);const pe=Bp.exports.Fragment,d=Bp.exports.jsx,W=Bp.exports.jsxs;var Jm=1073741823,Lv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{};function SP(){var e="__global_unique_id__";return Lv[e]=(Lv[e]||0)+1}function DP(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function kP(e){var t=[];return{on:function(a){t.push(a)},off:function(a){t=t.filter(function(i){return i!==a})},get:function(){return e},set:function(a,i){e=a,t.forEach(function(l){return l(e,i)})}}}function xP(e){return Array.isArray(e)?e[0]:e}function CP(e,t){var n,a,i="__create-react-context-"+SP()+"__",l=function(c){dr(m,c);function m(){for(var y,_=arguments.length,g=new Array(_),b=0;b<_;b++)g[b]=arguments[b];return y=c.call.apply(c,[this].concat(g))||this,y.emitter=kP(y.props.value),y}var f=m.prototype;return f.getChildContext=function(){var _;return _={},_[i]=this.emitter,_},f.componentWillReceiveProps=function(_){if(this.props.value!==_.value){var g=this.props.value,b=_.value,S;DP(g,b)?S=0:(S=typeof t=="function"?t(g,b):Jm,S|=0,S!==0&&this.emitter.set(_.value,S))}},f.render=function(){return this.props.children},m}(Qe.Component);l.childContextTypes=(n={},n[i]=Ar.exports.object.isRequired,n);var s=function(c){dr(m,c);function m(){for(var y,_=arguments.length,g=new Array(_),b=0;b<_;b++)g[b]=arguments[b];return y=c.call.apply(c,[this].concat(g))||this,y.observedBits=void 0,y.state={value:y.getValue()},y.onUpdate=function(S,k){var T=y.observedBits|0;(T&k)!==0&&y.setState({value:y.getValue()})},y}var f=m.prototype;return f.componentWillReceiveProps=function(_){var g=_.observedBits;this.observedBits=g==null?Jm:g},f.componentDidMount=function(){this.context[i]&&this.context[i].on(this.onUpdate);var _=this.props.observedBits;this.observedBits=_==null?Jm:_},f.componentWillUnmount=function(){this.context[i]&&this.context[i].off(this.onUpdate)},f.getValue=function(){return this.context[i]?this.context[i].get():e},f.render=function(){return xP(this.props.children)(this.state.value)},m}(Qe.Component);return s.contextTypes=(a={},a[i]=Ar.exports.object,a),{Provider:l,Consumer:s}}var PP=Qe.createContext||CP,Dw=function(t){var n=PP();return n.displayName=t,n},kw=Dw("Router-History"),ki=Dw("Router"),Up=function(e){dr(t,e),t.computeRootMatch=function(i){return{path:"/",url:"/",params:{},isExact:i==="/"}};function t(a){var i;return i=e.call(this,a)||this,i.state={location:a.history.location},i._isMounted=!1,i._pendingLocation=null,a.staticContext||(i.unlisten=a.history.listen(function(l){i._pendingLocation=l})),i}var n=t.prototype;return n.componentDidMount=function(){var i=this;this._isMounted=!0,this.unlisten&&this.unlisten(),this.props.staticContext||(this.unlisten=this.props.history.listen(function(l){i._isMounted&&i.setState({location:l})})),this._pendingLocation&&this.setState({location:this._pendingLocation})},n.componentWillUnmount=function(){this.unlisten&&(this.unlisten(),this._isMounted=!1,this._pendingLocation=null)},n.render=function(){return Qe.createElement(ki.Provider,{value:{history:this.props.history,location:this.state.location,match:t.computeRootMatch(this.state.location.pathname),staticContext:this.props.staticContext}},Qe.createElement(kw.Provider,{children:this.props.children||null,value:this.props.history}))},t}(Qe.Component);Qe.Component;Qe.Component;var Iv={},TP=1e4,Ev=0;function AP(e,t){var n=""+t.end+t.strict+t.sensitive,a=Iv[n]||(Iv[n]={});if(a[e])return a[e];var i=[],l=es.exports(e,i,t),s={regexp:l,keys:i};return Ev<TP&&(a[e]=s,Ev++),s}function by(e,t){t===void 0&&(t={}),(typeof t=="string"||Array.isArray(t))&&(t={path:t});var n=t,a=n.path,i=n.exact,l=i===void 0?!1:i,s=n.strict,c=s===void 0?!1:s,m=n.sensitive,f=m===void 0?!1:m,y=[].concat(a);return y.reduce(function(_,g){if(!g&&g!=="")return null;if(_)return _;var b=AP(g,{end:l,strict:c,sensitive:f}),S=b.regexp,k=b.keys,T=S.exec(e);if(!T)return null;var x=T[0],C=T.slice(1),P=e===x;return l&&!P?null:{path:g,url:g==="/"&&x===""?"/":x,isExact:P,params:k.reduce(function(O,z,F){return O[z.name]=C[F],O},{})}},null)}function LP(e){return Qe.Children.count(e)===0}var IP=function(e){dr(t,e);function t(){return e.apply(this,arguments)||this}var n=t.prototype;return n.render=function(){var i=this;return Qe.createElement(ki.Consumer,null,function(l){l||Ml(!1);var s=i.props.location||l.location,c=i.props.computedMatch?i.props.computedMatch:i.props.path?by(s.pathname,i.props):l.match,m=Cn({},l,{location:s,match:c}),f=i.props,y=f.children,_=f.component,g=f.render;return Array.isArray(y)&&LP(y)&&(y=null),Qe.createElement(ki.Provider,{value:m},m.match?y?typeof y=="function"?y(m):y:_?Qe.createElement(_,m):g?g(m):null:typeof y=="function"?y(m):null)})},t}(Qe.Component);function Ny(e){return e.charAt(0)==="/"?e:"/"+e}function EP(e,t){return e?Cn({},t,{pathname:Ny(e)+t.pathname}):t}function RP(e,t){if(!e)return t;var n=Ny(e);return t.pathname.indexOf(n)!==0?t:Cn({},t,{pathname:t.pathname.substr(n.length)})}function Rv(e){return typeof e=="string"?e:On(e)}function Xm(e){return function(){Ml(!1)}}function Ov(){}Qe.Component;var OP=function(e){dr(t,e);function t(){return e.apply(this,arguments)||this}var n=t.prototype;return n.render=function(){var i=this;return Qe.createElement(ki.Consumer,null,function(l){l||Ml(!1);var s=i.props.location||l.location,c,m;return Qe.Children.forEach(i.props.children,function(f){if(m==null&&Qe.isValidElement(f)){c=f;var y=f.props.path||f.props.from;m=y?by(s.pathname,Cn({},f.props,{path:y})):l.match}}),m?Qe.cloneElement(c,{location:s,computedMatch:m}):null})},t}(Qe.Component),wy=Qe.useContext;function pr(){return wy(kw)}function xw(){return wy(ki).location}function ut(){var e=wy(ki).match;return e?e.params:{}}var VP=function(e){dr(t,e);function t(){for(var a,i=arguments.length,l=new Array(i),s=0;s<i;s++)l[s]=arguments[s];return a=e.call.apply(e,[this].concat(l))||this,a.history=FC(a.props),a}var n=t.prototype;return n.render=function(){return d(Up,{history:this.history,children:this.props.children})},t}(Qe.Component);Qe.Component;var $f=function(t,n){return typeof t=="function"?t(n):t},zf=function(t,n){return typeof t=="string"?ea(t,null,null,n):t},Sy=function(t){return t},Vo=Qe.forwardRef;typeof Vo>"u"&&(Vo=Sy);function MP(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var $P=Vo(function(e,t){var n=e.innerRef,a=e.navigate,i=e.onClick,l=$u(e,["innerRef","navigate","onClick"]),s=l.target,c=Cn({},l,{onClick:function(f){try{i&&i(f)}catch(y){throw f.preventDefault(),y}!f.defaultPrevented&&f.button===0&&(!s||s==="_self")&&!MP(f)&&(f.preventDefault(),a())}});return Sy!==Vo?c.ref=t||n:c.ref=n,d("a",{...c})}),Ye=Vo(function(e,t){var n=e.component,a=n===void 0?$P:n,i=e.replace,l=e.to,s=e.innerRef,c=$u(e,["component","replace","to","innerRef"]);return Qe.createElement(ki.Consumer,null,function(m){m||Ml(!1);var f=m.history,y=zf($f(l,m.location),m.location),_=y?f.createHref(y):"",g=Cn({},c,{href:_,navigate:function(){var S=$f(l,m.location),k=On(m.location)===On(zf(S)),T=i||k?f.replace:f.push;T(S)}});return Sy!==Vo?g.ref=t||s:g.innerRef=s,Qe.createElement(a,g)})}),Cw=function(t){return t},Wd=Qe.forwardRef;typeof Wd>"u"&&(Wd=Cw);function zP(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter(function(a){return a}).join(" ")}Wd(function(e,t){var n=e["aria-current"],a=n===void 0?"page":n,i=e.activeClassName,l=i===void 0?"active":i,s=e.activeStyle,c=e.className,m=e.exact,f=e.isActive,y=e.location,_=e.sensitive,g=e.strict,b=e.style,S=e.to,k=e.innerRef,T=$u(e,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","sensitive","strict","style","to","innerRef"]);return Qe.createElement(ki.Consumer,null,function(x){x||Ml(!1);var C=y||x.location,P=zf($f(S,C),C),O=P.pathname,z=O&&O.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),F=z?by(C.pathname,{path:z,exact:m,sensitive:_,strict:g}):null,j=!!(f?f(F,C):F),H=typeof c=="function"?c(j):c,ne=typeof b=="function"?b(j):b;j&&(H=zP(H,l),ne=Cn({},ne,s));var ae=Cn({"aria-current":j&&a||null,className:H,style:ne,to:P},T);return Cw!==Wd?ae.ref=t||k:ae.innerRef=k,d(Ye,{...ae})})});const gt=({action:e,designLabel:t,bundleId:n,entityData:a,text:i})=>{const l=ut(),s=document.querySelectorAll("h1.page-header");if(s.length!==1)return d(pe,{});const c=s[0],m=cr(l.entityName?l.entityName:""),f=Ti(a),y=e!==void 0?e:l.action,_=y!==void 0?y==="create"?"Add":kn(y.replace("_"," ")):void 0;let g="Cloud Dashboard";if(l.cloudServiceProvider!==void 0&&y===void 0){const k=uw(l.cloudServiceProvider).filter(T=>T.entityName===l.entityName);g=k.length>=1?k[0].labelName:`${kn(m)}s`,l.cloudContext===void 0&&(g=`All ${xl(l.cloudServiceProvider)} ${g}`)}_!==void 0&&a===void 0&&(g=_+" "+m),_!==void 0&&a!==void 0&&(g=_+" "+f),_!==void 0&&y==="delete"&&(g="Are you sure you want to delete the "+m+" "+f+"?"),_===void 0&&a!==void 0&&(g="Name: "+f),t!==void 0&&(g=kn(t)+" list"),y===void 0&&t!==void 0&&t==="store"&&n!==void 0&&(g=cr(n)),y==="console_output"?g=`Console log of ${m}`:y==="console"?g=`Console of ${m}`:y==="action_log"?g=`Action log of ${m}`:y==="launch"?g=`Are you sure you want to launch instance(s) or resource(s) from ${f}?`:y==="create_image"&&(g=`Create an image for instance ${f}${a?" ("+a.attributes.instance_id+")":""}`),i&&(g=i);const b=document.createElement("div");b.className="field field--name-name field--type-string field--label-hidden field--item",b.innerText=g,c.innerHTML="",c.appendChild(b);const S=document.querySelectorAll("#navbar > nav > div.navbar-header > div > a.name.navbar-brand");if(S.length===1){const k=S[0].textContent;document.title=g+" | "+k}return d(pe,{})},bt=({action:e,designLabel:t,entityData:n})=>{const a=ut(),i=xw().pathname,l=document.querySelectorAll("div.breadcrumb-wrapper");if(l.length===0)return d(pe,{});const s=l[0].parentNode;if(s===null)return d(pe,{});for(const k of l)k.remove();const c=s.querySelector(".contextual-region");if(c===null)return d(pe,{});const m=["Cloud service providers"],f=e!==void 0?e:a.action;if(f!==void 0){const k=xl(a.cloudServiceProvider?a.cloudServiceProvider:""),T=cr(a.entityName?a.entityName:""),x=f==="create"?"Add":f==="import"?"Import":kn(f);if(m.push(`${k} ${T}`),n!==void 0){const C=Ti(n);C!==""&&m.push(C)}m.push(`${x} ${k} ${T}`)}t!==void 0&&(m.push("Design"),m.push(`${t} list`));const y=i.split("/"),_="/clouds/dashboard";y.forEach((k,T)=>{k==="cloud_launch_template"&&(y[T]="server_template")});const g=y.map((k,T)=>{if(T===1||T===2)return null;let x=_+y.slice(0,T+1).join("/");return T===0&&(x=_+"/providers"),x}).filter(Boolean),b=document.createElement("div");b.className="breadcrumb-wrapper";const S=document.createElement("ol");return S.className="breadcrumb",m.forEach((k,T)=>{var C;const x=document.createElement("li");if(T===m.length-1&&T>0)x.className="active",x.textContent=k;else{const P=document.createElement("a");P.href=(C=g[T])!=null?C:"#",P.textContent=k,x.appendChild(P)}S.appendChild(x)}),b.appendChild(S),s.insertBefore(b,c),d(pe,{})},Pw=mt,BP=mt+"/providers",kd=e=>{window.alert(`Error: ${e}`),console.error(`Error: ${e}`)},jP=async()=>{const e=await Jt("/clouds/cloud_dashboard/config/client_id"),t=await Jt("/clouds/cloud_dashboard/config/callback_uri"),n=await Jt("/clouds/cloud_dashboard/config/scope");if(!e.ok||!t.ok||!n.ok){console.group("OAuth2 Callback URL"),e.ok||(console.error("Client ID:"),console.error(e.error)),t.ok||(console.error("Callback URI:"),console.error(t.error)),n.ok||(console.error("Scope ID:"),console.error(n.error)),console.groupEnd(),kd("Could not obtain the information required for login.");return}const a=(await e.response.json()).id,i=(await t.response.json()).uri,l=(await n.response.json()).scope,s=`/oauth/authorize?response_type=code&client_id=${a}&redirect_uri=${i}&scope=${l}`;window.location.href=s},UP=async()=>{console.group("Authorization Code Grant");const e=await Jt("/clouds/cloud_dashboard/config/client_id"),t=await Jt("/clouds/cloud_dashboard/config/callback_uri");if(!e.ok||!t.ok)return console.error("Client ID : No"),console.error("Authorization failed."),console.groupEnd(),null;const n=(await e.response.json()).id,a=(await t.response.json()).uri;console.log("Client ID : Yes");const l=new URL(window.location.href).searchParams.get("code");if(l===null)return console.error("Authorization code : No"),console.error("Authorization failed."),console.groupEnd(),null;console.log("Authorization code : Yes");const s=new FormData;s.append("grant_type","authorization_code"),s.append("client_id",n),s.append("client_secret",zN),s.append("code",l),s.append("redirect_uri",a);const c=await Jt("/oauth/token",{method:"POST",body:s});if(!c.ok)return console.error("Token Request : No"),console.error("Authorization failed."),console.groupEnd(),null;console.log("Token Request : Yes");const m=await c.response.json();if(!("access_token"in m))return console.error("Access Token : No"),console.error("Authorization failed."),console.groupEnd(),null;console.log("Access Token : Yes"),console.groupEnd();const f=m.access_token,y=m.refresh_token,_=new Date().getTime()+m.expires_in*1e3;return{accessToken:f,refreshToken:y,expiresDatetime:`${_}`}},WP=async e=>{console.group("Authorization Code Grant");const t=await Jt("/clouds/cloud_dashboard/config/client_id");if(!t.ok)return console.error("Client ID : No"),console.error("Authorization failed."),null;const n=(await t.response.json()).id;console.log("Client ID : Yes");const a=new FormData;a.append("grant_type","refresh_token"),a.append("client_id",n),a.append("client_secret",zN),a.append("refresh_token",e);const i=await Jt("/oauth/token",{method:"POST",body:a});if(!i.ok)return console.error("Token Request : No"),console.error("Refresh failed."),console.groupEnd(),null;console.log("Token Request : Yes");const l=await i.response.json();if(!("access_token"in l))return console.error("Access Token : No"),console.error("Authorization failed."),console.groupEnd(),null;console.log("Access Token : Yes"),console.groupEnd();const s=l.access_token,c=l.refresh_token,m=new Date().getTime()+l.expires_in*1e3;return{accessToken:s,refreshToken:c,expiresDatetime:`${m}`}},Yc=()=>{window.localStorage.removeItem("accessToken"),window.localStorage.removeItem("refreshToken"),window.localStorage.removeItem("expiresDatetime"),window.location.href=Pw},Tw=()=>{const[e,t]=I.exports.useState(Gs("accessToken","")),[n,a]=I.exports.useState(Gs("refreshToken","")),[i,l]=I.exports.useState(Gs("expiresDatetime",""));return I.exports.useEffect(()=>{console.group("Token status"),console.log("accessToken=",e),console.log("refreshToken=",n),console.log("expiresDatetime=",i);const m=new Date(parseInt(i));console.log(`(${m.toString()})`),console.groupEnd()},[e,n,i]),{toCallbackUrl:jP,getTokenByAuthorizationCodeGrant:async()=>{const m=await UP();m!==null?(si("accessToken",m.accessToken),si("refreshToken",m.refreshToken),si("expiresDatetime",m.expiresDatetime),t(m.accessToken),a(m.refreshToken),l(m.expiresDatetime),window.location.href=BP):(kd("Could not obtain the information required for login."),window.location.href=Pw)},checkAndRefreshToken:async()=>{if(e===""||n===""||i===""){Yc();return}if(!(new Date().getTime()<=parseInt(i,10)))try{const f=await WP(n);f!==null?(si("accessToken",f.accessToken),si("refreshToken",f.refreshToken),si("expiresDatetime",f.expiresDatetime),t(f.accessToken),a(f.refreshToken),l(f.expiresDatetime)):(kd("Could not renew token expiration date."),Yc())}catch(f){kd("Could not renew token expiration date."),console.error(f),Yc()}},logout:Yc}};var Aw={exports:{}};/*!
Copyright (c) 2018 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
......
......@@ -157,9 +157,11 @@ trait CloudFormTrait {
],
'umbrella' => FALSE,
'parent' => '_none',
'granularity' => 'role',
'granularity_id' => 'role',
'permission' => '',
'granularity_configuration' => [
'role' => 'cloud_admin',
],
'langcode' => 'en',
])->save();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment