unleash-server 5.2.2 → 5.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/frontend/build/index.html +1 -1
- package/frontend/build/static/{AdvancedPlayground-0dfff43f.js → AdvancedPlayground-b8d00f81.js} +1 -1
- package/frontend/build/static/{CreateProject-b7f8de7a.js → CreateProject-fe1d0f0f.js} +1 -1
- package/frontend/build/static/{Error-71e2c977.js → Error-6550f020.js} +1 -1
- package/frontend/build/static/{FeatureArchiveDialog-4d2f3953.js → FeatureArchiveDialog-42d2cf92.js} +1 -1
- package/frontend/build/static/{FeatureMetricsChart-e1a34382.js → FeatureMetricsChart-70a6747e.js} +1 -1
- package/frontend/build/static/{FeatureViewLazyExport-3a021f35.js → FeatureViewLazyExport-60874e5e.js} +2 -2
- package/frontend/build/static/{LazyAdminExport-546d2ced.js → LazyAdminExport-c5eec10c.js} +2 -2
- package/frontend/build/static/{LazyProjectExport-6445b527.js → LazyProjectExport-7f66ff80.js} +1 -1
- package/frontend/build/static/{NetworkOverview-c0c2c8df.js → NetworkOverview-b82ebe0c.js} +2 -2
- package/frontend/build/static/{NetworkTraffic-9390e1ed.js → NetworkTraffic-51a825ea.js} +1 -1
- package/frontend/build/static/{Playground-f63ff456.js → Playground-2b482aeb.js} +1 -1
- package/frontend/build/static/{PlaygroundGuidancePopper-b56ef034.js → PlaygroundGuidancePopper-5673aca8.js} +1 -1
- package/frontend/build/static/{RoleCell-1aaafbaa.js → RoleCell-c9b26e7a.js} +1 -1
- package/frontend/build/static/{StrategyItemContainer-0c77dc4b.js → StrategyItemContainer-7b356e23.js} +1 -1
- package/frontend/build/static/{chartjs-adapter-date-fns.esm-21bf4359.js → chartjs-adapter-date-fns.esm-04fda623.js} +1 -1
- package/frontend/build/static/{flowchart-elk-definition-170a3958-a7461fc0.js → flowchart-elk-definition-170a3958-68f1625d.js} +1 -1
- package/frontend/build/static/{index-d3c3fe33.js → index-545ad556.js} +1 -1
- package/frontend/build/static/{index-7bc6399c.js → index-78d048a4.js} +79 -79
- package/frontend/build/static/{index-cd43ec71.js → index-b74e9af8.js} +1 -1
- package/frontend/build/static/{is_dark-59f2cf1b.js → is_dark-77b9ee14.js} +1 -1
- package/frontend/build/static/{mindmap-definition-44684416-4924e603.js → mindmap-definition-44684416-4cca63a5.js} +1 -1
- package/frontend/build/static/{timeline-definition-8e5a9bc6-31a3401d.js → timeline-definition-8e5a9bc6-31dad151.js} +1 -1
- package/frontend/build/static/{unknownify-e3fc74cf.js → unknownify-53fb2d5d.js} +1 -1
- package/frontend/package.json +4 -3
- package/package.json +4 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as y,r as p,aD as Bo,cA as Lo,aE as Oo,j as e,aF as In,cB as on,cC as Et,cD as Uo,cE as No,cF as $o,cG as Go,E as mt,cH as Bn,cI as Mo,cJ as Fe,cK as Nt,aS as te,aR as Pe,aT as ve,cL as Ln,cM as Te,cN as an,cO as rn,cP as ze,P as ee,o as ne,h as i,F as O,S as fe,cQ as On,cR as Un,cS as Fo,cT as jo,cU as gt,cV as zo,an as Wo,cW as Ho,m as X,a6 as W,as as Ce,bW as Nn,av as Ie,ax as $n,cX as Gt,n as Z,aA as Ae,bB as b,c1 as ye,c3 as we,ae as ft,af as Gn,ag as Mn,ah as Ee,al as Q,a8 as Ge,cY as Ve,A as K,ai as H,bb as le,T as D,aO as he,B as z,C as x,cZ as _o,ao as Mt,c_ as Fn,ac as qo,c$ as Vo,d0 as je,G as ut,d1 as Yo,f as N,s as ke,U as ce,K as Jo,M as Ko,N as Ft,O as et,Q as Zo,i as be,d2 as xe,I as _e,d3 as Xo,aU as jn,d4 as jt,d5 as Y,bK as zn,d6 as Qo,d7 as Wn,d8 as Hn,d9 as se,bL as _n,da as ea,cj as sn,db as qn,bP as ht,am as Vn,dc as ta,dd as Rt,cc as Yn,de as na,df as oa,d as Se,ch as De,dg as qe,H as pe,b4 as Ne,c0 as $e,g as tt,V as Be,c2 as nt,bU as yt,$ as aa,dh as me,di as ia,dj as Jn,dk as We,dl as Kn,dm as ra,dn as sa,bV as ln,dp as la,dq as ca,dr as da,aI as zt,ds as Wt,dt as Zn,p as Xn,bZ as Ht,c as ua,b as _t,du as Ye,dv as ha,u as Qn,e as bt,aM as Re,dw as pa,aP as ot,dx as ma,dy as qt,dz as ga,k as Je,x as eo,bz as fa,dA as ya,b8 as At,ba as Dt,dB as ba,dC as Sa,dD as va,dE as Ca,z as Vt,dF as wa,ct as Yt,cz as Jt,cr as de,bX as Kt,bY as V,dG as xa,L as Ta,dH as to,dI as ka,dJ as Ea,a0 as Ra,dK as rt,bE as Aa,bF as Da,bJ as Pa,bG as Ia,dL as Ba,dM as La,dN as Oa,dO as Ua,dP as Na,dQ as $a,c5 as Ga,dR as Ma,dS as Fa,dT as ja,dU as no,R as za,dV as Pt,dW as Wa,dX as oo,dY as pt,dZ as ao,d_ as Ha,d$ as _a,y as io,e0 as qa,e1 as cn,e2 as Va,e3 as Ya,e4 as Ja,e5 as Ka,e6 as Za,e7 as Xa,cf as Qa,bv as ei,e8 as ro,e9 as ti,ea as ni,eb as oi,ec as ai,ed as dn,a as so,b9 as ii,bM as It,ee as ri}from"./index-
|
|
1
|
+
import{t as y,r as p,aD as Bo,cA as Lo,aE as Oo,j as e,aF as In,cB as on,cC as Et,cD as Uo,cE as No,cF as $o,cG as Go,E as mt,cH as Bn,cI as Mo,cJ as Fe,cK as Nt,aS as te,aR as Pe,aT as ve,cL as Ln,cM as Te,cN as an,cO as rn,cP as ze,P as ee,o as ne,h as i,F as O,S as fe,cQ as On,cR as Un,cS as Fo,cT as jo,cU as gt,cV as zo,an as Wo,cW as Ho,m as X,a6 as W,as as Ce,bW as Nn,av as Ie,ax as $n,cX as Gt,n as Z,aA as Ae,bB as b,c1 as ye,c3 as we,ae as ft,af as Gn,ag as Mn,ah as Ee,al as Q,a8 as Ge,cY as Ve,A as K,ai as H,bb as le,T as D,aO as he,B as z,C as x,cZ as _o,ao as Mt,c_ as Fn,ac as qo,c$ as Vo,d0 as je,G as ut,d1 as Yo,f as N,s as ke,U as ce,K as Jo,M as Ko,N as Ft,O as et,Q as Zo,i as be,d2 as xe,I as _e,d3 as Xo,aU as jn,d4 as jt,d5 as Y,bK as zn,d6 as Qo,d7 as Wn,d8 as Hn,d9 as se,bL as _n,da as ea,cj as sn,db as qn,bP as ht,am as Vn,dc as ta,dd as Rt,cc as Yn,de as na,df as oa,d as Se,ch as De,dg as qe,H as pe,b4 as Ne,c0 as $e,g as tt,V as Be,c2 as nt,bU as yt,$ as aa,dh as me,di as ia,dj as Jn,dk as We,dl as Kn,dm as ra,dn as sa,bV as ln,dp as la,dq as ca,dr as da,aI as zt,ds as Wt,dt as Zn,p as Xn,bZ as Ht,c as ua,b as _t,du as Ye,dv as ha,u as Qn,e as bt,aM as Re,dw as pa,aP as ot,dx as ma,dy as qt,dz as ga,k as Je,x as eo,bz as fa,dA as ya,b8 as At,ba as Dt,dB as ba,dC as Sa,dD as va,dE as Ca,z as Vt,dF as wa,ct as Yt,cz as Jt,cr as de,bX as Kt,bY as V,dG as xa,L as Ta,dH as to,dI as ka,dJ as Ea,a0 as Ra,dK as rt,bE as Aa,bF as Da,bJ as Pa,bG as Ia,dL as Ba,dM as La,dN as Oa,dO as Ua,dP as Na,dQ as $a,c5 as Ga,dR as Ma,dS as Fa,dT as ja,dU as no,R as za,dV as Pt,dW as Wa,dX as oo,dY as pt,dZ as ao,d_ as Ha,d$ as _a,y as io,e0 as qa,e1 as cn,e2 as Va,e3 as Ya,e4 as Ja,e5 as Ka,e6 as Za,e7 as Xa,cf as Qa,bv as ei,e8 as ro,e9 as ti,ea as ni,eb as oi,ec as ai,ed as dn,a as so,b9 as ii,bM as It,ee as ri}from"./index-78d048a4.js";import{u as si,C as li,A as ci,a as di,R as ui,S as hi,T as pi,b as mi,c as gi,d as fi,e as yi,E as bi,f as Si,m as vi,g as St,B as Ci,h as lo}from"./RoleCell-c9b26e7a.js";import{a as wi}from"./index-545ad556.js";import{a as xi}from"./index-b74e9af8.js";const Ti=["component","direction","spacing","divider","children"];function ki(t,n){const a=p.Children.toArray(t).filter(Boolean);return a.reduce((o,r,s)=>(o.push(r),s<a.length-1&&o.push(p.cloneElement(n,{key:`separator-${s}`})),o),[])}const Ei=t=>({row:"Left","row-reverse":"Right",column:"Top","column-reverse":"Bottom"})[t],Ri=({ownerState:t,theme:n})=>{let a=In({display:"flex",flexDirection:"column"},on({theme:n},Et({values:t.direction,breakpoints:n.breakpoints.values}),o=>({flexDirection:o})));if(t.spacing){const o=Uo(n),r=Object.keys(n.breakpoints.values).reduce((d,l)=>((typeof t.spacing=="object"&&t.spacing[l]!=null||typeof t.direction=="object"&&t.direction[l]!=null)&&(d[l]=!0),d),{}),s=Et({values:t.direction,base:r}),c=Et({values:t.spacing,base:r});typeof s=="object"&&Object.keys(s).forEach((d,l,h)=>{if(!s[d]){const S=l>0?s[h[l-1]]:"column";s[d]=S}}),a=No(a,on({theme:n},c,(d,l)=>({"& > :not(style) + :not(style)":{margin:0,[`margin${Ei(l?s[l]:t.direction)}`]:Go(o,d)}})))}return a=$o(n.breakpoints,a),a},Ai=y("div",{name:"MuiStack",slot:"Root",overridesResolver:(t,n)=>[n.root]})(Ri),Di=p.forwardRef(function(n,a){const o=Bo({props:n,name:"MuiStack"}),r=Lo(o),{component:s="div",direction:c="column",spacing:u=0,divider:d,children:l}=r,h=Oo(r,Ti);return e(Ai,In({as:s,ownerState:{direction:c,spacing:u},ref:a},h,{children:d?ki(l,d):l}))}),Pi=Di,Ii=mt(e("path",{d:"M11.8 10.9c-2.27-.59-3-1.2-3-2.15 0-1.09 1.01-1.85 2.7-1.85 1.42 0 2.13.54 2.39 1.4.12.4.45.7.87.7h.3c.66 0 1.13-.65.9-1.27-.42-1.18-1.4-2.16-2.96-2.54V4.5c0-.83-.67-1.5-1.5-1.5S10 3.67 10 4.5v.66c-1.94.42-3.5 1.68-3.5 3.61 0 2.31 1.91 3.46 4.7 4.13 2.5.6 3 1.48 3 2.41 0 .69-.49 1.79-2.7 1.79-1.65 0-2.5-.59-2.83-1.43-.15-.39-.49-.67-.9-.67h-.28c-.67 0-1.14.68-.89 1.3.57 1.39 1.9 2.21 3.4 2.53v.67c0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5v-.65c1.95-.37 3.5-1.5 3.5-3.55 0-2.84-2.43-3.81-4.7-4.4z"}),"AttachMoneyRounded"),Bi=mt(e("path",{d:"M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5s-3 1.34-3 3 1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V18c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-1.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05.02.01.03.03.04.04 1.14.83 1.93 1.94 1.93 3.41V18c0 .35-.07.69-.18 1H22c.55 0 1-.45 1-1v-1.5c0-2.33-4.67-3.5-7-3.5z"}),"GroupRounded"),Li=mt(e("path",{d:"M11.99 2c-5.52 0-10 4.48-10 10s4.48 10 10 10 10-4.48 10-10-4.48-10-10-10zm3.61 6.34c1.07 0 1.93.86 1.93 1.93 0 1.07-.86 1.93-1.93 1.93-1.07 0-1.93-.86-1.93-1.93-.01-1.07.86-1.93 1.93-1.93zm-6-1.58c1.3 0 2.36 1.06 2.36 2.36 0 1.3-1.06 2.36-2.36 2.36s-2.36-1.06-2.36-2.36c0-1.31 1.05-2.36 2.36-2.36zm0 9.13v3.75c-2.4-.75-4.3-2.6-5.14-4.96 1.05-1.12 3.67-1.69 5.14-1.69.53 0 1.2.08 1.9.22-1.64.87-1.9 2.02-1.9 2.68zM11.99 20c-.27 0-.53-.01-.79-.04v-4.07c0-1.42 2.94-2.13 4.4-2.13 1.07 0 2.92.39 3.84 1.15-1.17 2.97-4.06 5.09-7.45 5.09z"}),"SupervisedUserCircle"),Oi=mt(e("path",{d:"M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm-6 10H6v-2h8v2zm4-4H6v-2h12v2z"}),"Topic");function dt(t,n){if(Bn(2,arguments),!n||Mo(n)!=="object")return new Date(NaN);var a=n.years?Fe(n.years):0,o=n.months?Fe(n.months):0,r=n.weeks?Fe(n.weeks):0,s=n.days?Fe(n.days):0,c=n.hours?Fe(n.hours):0,u=n.minutes?Fe(n.minutes):0,d=n.seconds?Fe(n.seconds):0,l=Nt(t),h=o||a?xi(l,o+a*12):l,m=s||r?wi(h,s+r*7):h,S=u+c*60,g=d+S*60,f=g*1e3,v=new Date(m.getTime()+f);return v}function un(t,n){Bn(2,arguments);var a=Nt(t),o=Nt(n);return a.getTime()>o.getTime()}const Zt=(t={})=>{const n=te("api/admin/api-tokens"),{data:a,error:o,mutate:r}=Pe(n,Ui,t),s=p.useMemo(()=>a??[],[a]),c=p.useCallback(()=>{r().catch(console.warn)},[r]);return{tokens:s,error:o,loading:!o&&!a,refetch:c}},Ui=async t=>(await(await fetch(t).then(ve("Api tokens"))).json()).tokens,Ni=()=>{const{tokens:t,loading:n,refetch:a}=Zt(),{deleteToken:o}=Ln(),{getTableProps:r,getTableBodyProps:s,headerGroups:c,rows:u,prepareRow:d,state:{globalFilter:l},setGlobalFilter:h,setHiddenColumns:m,columns:S}=si(t,g=>{const f=g.row.original.type==="client"?an:g.row.original.type==="frontend"?rn:ze,v=g.row.original.type==="client"?Fo:g.row.original.type==="frontend"?jo:ze;return i(gt,{children:[e(di,{token:g.row.original,permission:f}),e(ui,{token:g.row.original,permission:v,onRemove:async()=>{await o(g.row.original.secret),a()}})]})});return e(Te,{permissions:[an,rn,ze],children:e(ee,{header:e(ne,{title:`API access (${u.length})`,actions:i(O,{children:[e(fe,{initialValue:l,onChange:h}),e(ne.Divider,{}),e(li,{permission:[On,Un,ze],path:"/admin/api/create-token"})]})}),children:e(ci,{loading:n,headerGroups:c,setHiddenColumns:m,prepareRow:d,getTableBodyProps:s,getTableProps:r,rows:u,columns:S,globalFilter:l})})})},$i=({type:t,projects:n,setProjects:a,errors:o,clearErrors:r})=>{const s=zo("projectId"),{projects:c}=Wo(),u=c.map(d=>({value:d.id,label:d.name}));return s?null:i(O,{children:[e(hi,{children:"Which project do you want to give access to?"}),e(Ho,{disabled:t===pi.ADMIN,options:u,defaultValue:n,onChange:a,error:o==null?void 0:o.projects,onFocus:()=>r("projects")})]})},hn="Create API token",Gi=({modal:t=!1})=>{const{setToastApiError:n}=X(),{uiConfig:a}=W(),o=Ce(),[r,s]=p.useState(!1),[c,u]=p.useState(""),{getApiTokenPayload:d,username:l,type:h,projects:m,environment:S,setUsername:g,setTokenType:f,setProjects:v,setEnvironment:T,isValid:C,errors:w,clearErrors:k,apiTokenTypes:E}=mi(),{createToken:I,loading:P}=Ln(),{refetch:B}=Zt();Nn(hn);const L="api/admin/api-tokens";return i(Ie,{loading:P,title:hn,modal:t,description:"Unleash SDKs use API tokens to authenticate to the Unleash API. Client SDKs need a token with 'client privileges', which allows them to fetch feature toggle configurations and post usage metrics.",documentationLink:"https://docs.getunleash.io/reference/api-tokens-and-client-keys",documentationLinkLabel:"API tokens documentation",formatApiCode:()=>`curl --location --request POST '${a.unleashUrl}/${L}' \\
|
|
2
2
|
--header 'Authorization: INSERT_API_KEY' \\
|
|
3
3
|
--header 'Content-Type: application/json' \\
|
|
4
4
|
--data-raw '${JSON.stringify(d(),void 0,2)}'`,children:[i(gi,{handleSubmit:async J=>{if(J.preventDefault(),!!C())try{const R=d();await I(R).then(F=>F.json()).then(F=>{Gt(),u(F.secret),s(!0),B()})}catch(R){n(Z(R))}},handleCancel:()=>{o(Ae)},mode:"Create",actions:e($n,{name:"token",permission:[ze,Un,On]}),children:[e(fi,{username:l,setUsername:g,errors:w,clearErrors:k}),e(yi,{type:h,setType:f,apiTokenTypes:E}),e($i,{type:h,projects:m,setProjects:v,errors:w,clearErrors:k}),e(bi,{type:h,environment:S,setEnvironment:T})]}),e(Si,{open:r,closeConfirm:()=>{s(!1),o(Ae)},token:c,type:h})]})},co=({data:t={enabled:!1,autoCreate:!1},setValue:n})=>{const a=()=>{n("autoCreate",!t.autoCreate)},o=s=>{n("defaultRootRole",s.target.value)},r=s=>{n(s.target.name,s.target.value)};return i(p.Fragment,{children:[i(b,{container:!0,spacing:3,mb:2,children:[i(b,{item:!0,md:5,children:[e("strong",{children:"Auto-create users"}),e("p",{children:"Enable automatic creation of new users when signing in."})]}),e(b,{item:!0,md:6,style:{padding:"20px"},children:e(ye,{control:e(we,{onChange:a,name:"enabled",checked:t.autoCreate,disabled:!t.enabled}),label:"Auto-create users"})})]}),i(b,{container:!0,spacing:3,mb:2,children:[i(b,{item:!0,md:5,children:[e("strong",{children:"Default Root Role"}),e("p",{children:"Choose which root role the user should get when no explicit role mapping exists."})]}),e(b,{item:!0,md:6,children:i(ft,{style:{minWidth:"200px"},children:[e(Gn,{id:"defaultRootRole-label",children:"Default Role"}),i(Mn,{label:"Default Role",labelId:"defaultRootRole-label",id:"defaultRootRole",name:"defaultRootRole",disabled:!t.autoCreate||!t.enabled,value:t.defaultRootRole||"Editor",onChange:o,children:[e(Ee,{value:"Viewer",children:"Viewer"}),e(Ee,{value:"Editor",children:"Editor"}),e(Ee,{value:"Admin",children:"Admin"})]})]})})]}),i(b,{container:!0,spacing:3,mb:2,children:[i(b,{item:!0,md:5,children:[e("strong",{children:"Email domains"}),e("p",{children:"Comma separated list of email domains that should be allowed to sign in."})]}),e(b,{item:!0,md:6,children:e(Q,{onChange:r,label:"Email domains",name:"emailDomains",disabled:!t.autoCreate||!t.enabled,required:!!t.autoCreate,value:t.emailDomains||"",placeholder:"@company.com, @anotherCompany.com",style:{width:"400px"},rows:2,variant:"outlined",size:"small"})})]})]})},Mi=async(t,n)=>{if(t){if(n){const a=await n.json();throw t({message:a.message}),new Error(a.message)}throw new Error}},vt=t=>{const{makeRequest:n,createRequest:a,errors:o,loading:r}=Ge({propagateErrors:!0,handleBadRequest:Mi});return{updateSettings:async c=>{const u=`api/admin/auth/${t}/settings`,d=a(u,{method:"POST",body:JSON.stringify(c)});try{await n(d.caller,d.id)}catch(l){throw l}},errors:o,loading:r}},Xt=t=>{const a=Object.entries(t).filter(([,o])=>o!=="");return Object.fromEntries(a)},uo=({ssoType:t,data:n={enabled:!1,enableGroupSyncing:!1,groupJsonPath:""},setValue:a})=>{const o=()=>{a("enableGroupSyncing",!n.enableGroupSyncing)},r=s=>{a(s.target.name,s.target.value)};return i(O,{children:[i(b,{container:!0,spacing:3,mb:2,children:[i(b,{item:!0,md:5,children:[e("strong",{children:"Enable Group Syncing"}),i("p",{children:["Enables automatically syncing of users from the"," ",t,"provider when a user logs in."]})]}),e(b,{item:!0,md:6,style:{padding:"20px"},children:e(ye,{control:e(we,{onChange:o,value:n.enableGroupSyncing,name:"enableGroupSyncing",checked:n.enableGroupSyncing,disabled:!n.enabled}),label:n.enableGroupSyncing?"Enabled":"Disabled"})})]}),i(b,{container:!0,spacing:3,mb:2,children:[i(b,{item:!0,md:5,children:[e("strong",{children:"Group Field JSON Path"}),i("p",{children:["Specifies the path in the ",t," token response from which to read the groups the user belongs to."]})]}),e(b,{item:!0,md:6,children:e(Q,{onChange:r,label:"Group JSON Path",name:"groupJsonPath",value:n.groupJsonPath,disabled:!n.enableGroupSyncing,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]})]})},Fi={enabled:!1,enableSingleSignOut:!1,enableGroupSyncing:!1,autoCreate:!1,unleashHostname:location.hostname,groupJsonPath:"",clientId:"",discoverUrl:"",secret:"",acrValues:"",idTokenSigningAlgorithm:"RS256"},ji=()=>{const{setToastData:t,setToastApiError:n}=X(),{uiConfig:a}=W(),[o,r]=p.useState(Fi),{config:s}=Ve("oidc"),{updateSettings:c,errors:u,loading:d}=vt("oidc");p.useEffect(()=>{s.discoverUrl&&r(s)},[s]);const l=f=>{S(f.target.name,f.target.value)},h=()=>{r({...o,enabled:!o.enabled})},m=()=>{r({...o,enableSingleSignOut:!o.enableSingleSignOut})},S=(f,v)=>{r({...o,[f]:v})},g=async f=>{f.preventDefault();try{await c(Xt(o)),t({title:"Settings stored",type:"success"})}catch(v){n(Z(v))}};return i(ee,{children:[e(b,{container:!0,sx:{mb:3},children:e(b,{item:!0,md:12,children:i(K,{severity:"info",children:["Please read the"," ",e("a",{href:"https://www.unleash-hosted.com/docs/enterprise-authentication",target:"_blank",rel:"noreferrer",children:"documentation"})," ","to learn how to integrate with specific Open Id Connect providers (Okta, Keycloak, Google, etc). ",e("br",{}),"Callback URL:"," ",i("code",{children:[a.unleashUrl,"/auth/oidc/callback"]})]})})}),i("form",{onSubmit:g,children:[i(b,{container:!0,spacing:3,mb:2,children:[i(b,{item:!0,md:5,children:[e("strong",{children:"Enable"}),e("p",{children:"Enable Open Id Connect Authentication."})]}),e(b,{item:!0,md:6,style:{padding:"20px"},children:e(ye,{control:e(we,{onChange:h,value:o.enabled,name:"enabled",checked:o.enabled}),label:o.enabled?"Enabled":"Disabled"})})]}),i(b,{container:!0,spacing:3,mb:2,children:[i(b,{item:!0,md:5,children:[e("strong",{children:"Discover URL"}),e("p",{children:"(Required) Issuer discover metadata URL"})]}),e(b,{item:!0,md:6,children:e(Q,{onChange:l,label:"Discover URL",name:"discoverUrl",value:o.discoverUrl,disabled:!o.enabled,style:{width:"400px"},variant:"outlined",size:"small"})})]}),i(b,{container:!0,spacing:3,mb:2,children:[i(b,{item:!0,md:5,children:[e("strong",{children:"Client ID"}),e("p",{children:"(Required) Client ID of your OpenID application"})]}),e(b,{item:!0,md:6,children:e(Q,{onChange:l,label:"Client ID",name:"clientId",value:o.clientId,disabled:!o.enabled,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),i(b,{container:!0,spacing:3,mb:4,children:[i(b,{item:!0,md:5,children:[e("strong",{children:"Client secret"}),i("p",{children:["(Required) Client secret of your OpenID application."," "]})]}),e(b,{item:!0,md:6,children:e(Q,{onChange:l,label:"Client Secret",name:"secret",value:o.secret,disabled:!o.enabled,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),e("h3",{children:"Optional Configuration"}),i(b,{container:!0,spacing:3,mb:2,children:[i(b,{item:!0,md:5,children:[e("strong",{children:"Enable Single Sign-Out"}),e("p",{children:"If you enable Single Sign-Out Unleash will redirect the user to the IDP as part of the Sign-out process."})]}),e(b,{item:!0,md:6,style:{padding:"20px"},children:e(ye,{control:e(we,{onChange:m,value:o.enableSingleSignOut,disabled:!o.enabled,name:"enableSingleSignOut",checked:o.enableSingleSignOut}),label:o.enableSingleSignOut?"Enabled":"Disabled"})})]}),i(b,{container:!0,spacing:3,mb:2,children:[i(b,{item:!0,md:5,children:[e("strong",{children:"ACR Values"}),e("p",{children:'Requested Authentication Context Class Reference values. If multiple values are specified they should be "space" separated. Will be sent as "acr_values" as part of the authentication request. Unleash will validate the acr value in the id token claims against the list of acr values.'})]}),e(b,{item:!0,md:6,children:e(Q,{onChange:l,label:"ACR Values",name:"acrValues",value:o.acrValues,disabled:!o.enabled,style:{width:"400px"},variant:"outlined",size:"small"})})]}),e(uo,{ssoType:"OIDC",data:o,setValue:S}),e(co,{data:o,setValue:S}),i(b,{container:!0,spacing:3,mb:2,children:[i(b,{item:!0,md:5,children:[e("strong",{children:"ID Signing algorithm"}),i("p",{children:["Which signing algorithm to use. ",e("br",{}),' Leave this alone unless you see errors that look like "unexpected JWT alg received, expected RS256, got: RS512" in your logs.']})]}),e(b,{item:!0,md:6,children:i(ft,{style:{minWidth:"200px"},children:[e(Gn,{id:"defaultRootRole-label",children:"Signing algorithm"}),i(Mn,{label:"Signing algorithm",labelId:"idTokenSigningAlgorithm-label",id:"idTokenSigningAlgorithm",name:"idTokenSigningAlgorithm",value:o.idTokenSigningAlgorithm||"RS256",onChange:f=>S("idTokenSigningAlgorithm",f.target.value),children:[e(Ee,{value:"RS256",children:"RS256"}),e(Ee,{value:"RS384",children:"RS384"}),e(Ee,{value:"RS512",children:"RS512"})]})]})})]}),e(b,{container:!0,spacing:3,children:i(b,{item:!0,md:12,children:[e(H,{variant:"contained",color:"primary",type:"submit",disabled:d,children:"Save"})," ",e("p",{children:e("small",{style:{color:"red"},children:u==null?void 0:u.message})})]})})]})]})},zi={enabled:!1,autoCreate:!1,enableGroupSyncing:!1,unleashHostname:location.hostname,entityId:"",signOnUrl:"",certificate:"",signOutUrl:"",spCertificate:"",groupJsonPath:""},Wi=()=>{const{setToastData:t,setToastApiError:n}=X(),{uiConfig:a}=W(),[o,r]=p.useState(zi),{config:s}=Ve("saml"),{updateSettings:c,errors:u,loading:d}=vt("saml");p.useEffect(()=>{s.entityId&&r(s)},[s]);const l=g=>{m(g.target.name,g.target.value)},h=()=>{r({...o,enabled:!o.enabled})},m=(g,f)=>{r({...o,[g]:f})},S=async g=>{g.preventDefault();try{await c(Xt(o)),t({title:"Settings stored",type:"success"})}catch(f){n(Z(f))}};return i(ee,{children:[e(b,{container:!0,sx:{mb:3},children:e(b,{item:!0,md:12,children:i(K,{severity:"info",children:["Please read the"," ",e("a",{href:"https://www.unleash-hosted.com/docs/enterprise-authentication",target:"_blank",rel:"noreferrer",children:"documentation"})," ","to learn how to integrate with specific SAML 2.0 providers (Okta, Keycloak, etc). ",e("br",{}),"Callback URL:"," ",i("code",{children:[a.unleashUrl,"/auth/saml/callback"]})]})})}),i("form",{onSubmit:S,children:[i(b,{container:!0,spacing:3,children:[i(b,{item:!0,md:5,mb:2,children:[e("strong",{children:"Enable"}),e("p",{children:"Enable SAML 2.0 Authentication."})]}),e(b,{item:!0,md:6,children:e(ye,{control:e(we,{onChange:h,value:o.enabled,name:"enabled",checked:o.enabled}),label:o.enabled?"Enabled":"Disabled"})})]}),i(b,{container:!0,spacing:3,mb:2,children:[i(b,{item:!0,md:5,children:[e("strong",{children:"Entity ID"}),e("p",{children:"(Required) The Entity Identity provider issuer."})]}),e(b,{item:!0,md:6,children:e(Q,{onChange:l,label:"Entity ID",name:"entityId",value:o.entityId,disabled:!o.enabled,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),i(b,{container:!0,spacing:3,mb:2,children:[i(b,{item:!0,md:5,children:[e("strong",{children:"Single Sign-On URL"}),e("p",{children:"(Required) The url to redirect the user to for signing in."})]}),e(b,{item:!0,md:6,children:e(Q,{onChange:l,label:"Single Sign-On URL",name:"signOnUrl",value:o.signOnUrl,disabled:!o.enabled,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),i(b,{container:!0,spacing:3,mb:4,children:[i(b,{item:!0,md:5,children:[e("strong",{children:"X.509 Certificate"}),e("p",{children:"(Required) The certificate used to sign the SAML 2.0 request."})]}),e(b,{item:!0,md:7,children:e(Q,{onChange:l,label:"X.509 Certificate",name:"certificate",value:o.certificate,disabled:!o.enabled,style:{width:"100%"},InputProps:{style:{fontSize:"0.6em",fontFamily:"monospace"}},multiline:!0,rows:14,maxRows:14,variant:"outlined",size:"small",required:!0})})]}),e("h3",{children:"Optional Configuration"}),i(b,{container:!0,spacing:3,mb:2,children:[i(b,{item:!0,md:5,children:[e("strong",{children:"Single Sign-out URL"}),e("p",{children:"(Optional) The url to redirect the user to for signing out of the IDP."})]}),e(b,{item:!0,md:6,children:e(Q,{onChange:l,label:"Single Sign-out URL",name:"signOutUrl",value:o.signOutUrl,disabled:!o.enabled,style:{width:"400px"},variant:"outlined",size:"small"})})]}),i(b,{container:!0,spacing:3,mb:2,children:[i(b,{item:!0,md:5,children:[e("strong",{children:"Service Provider X.509 Certificate"}),e("p",{children:"(Optional) The private certificate used by the Service Provider used to sign the SAML 2.0 request towards the IDP. E.g. used to sign single logout requests (SLO)."})]}),e(b,{item:!0,md:7,children:e(Q,{onChange:l,label:"X.509 Certificate",name:"spCertificate",value:o.spCertificate,disabled:!o.enabled,style:{width:"100%"},InputProps:{style:{fontSize:"0.6em",fontFamily:"monospace"}},multiline:!0,rows:14,maxRows:14,variant:"outlined",size:"small"})})]}),e(uo,{ssoType:"SAML",data:o,setValue:m}),e(co,{data:o,setValue:m}),e(b,{container:!0,spacing:3,children:i(b,{item:!0,md:5,children:[e(H,{variant:"contained",color:"primary",type:"submit",disabled:d,children:"Save"})," ",e("p",{children:e("small",{style:{color:"red"},children:u==null?void 0:u.message})})]})})]})]})},Hi=()=>{const{data:t,error:n,mutate:a}=Pe(te("api/admin/user-admin/admin-count"),_i);return{data:t,loading:!n&&!t,refetch:()=>a(),error:n}},_i=t=>fetch(t).then(ve("Admin count")).then(n=>n.json()),qi=({open:t,setOpen:n,onClick:a,adminCount:o,tokens:r})=>i(le,{open:t,onClose:()=>{n(!1)},onClick:a,title:"Disable password based login?",primaryButtonText:"Disable password based login",secondaryButtonText:"Cancel",children:[i(K,{severity:"warning",children:[e("strong",{children:"Warning!"})," Disabling password based login may lock you out of the system permanently if you do not have any alternative admin credentials (such as an admin SSO account or admin API token) secured beforehand.",e("br",{}),e("br",{}),e("strong",{children:"Password based administrators: "})," ",o==null?void 0:o.password,e("br",{}),e("strong",{children:"Other administrators: "})," ",o==null?void 0:o.noPassword,e("br",{}),e("strong",{children:"Admin service accounts: "})," ",o==null?void 0:o.service,e("br",{}),e("strong",{children:"Admin API tokens: "})," ",r.filter(({type:s})=>s==="admin").length]}),e(D,{sx:{mt:3},children:"You are about to disable password based login. Are you sure you want to proceed?"})]}),Vi=()=>{const{setToastData:t,setToastApiError:n}=X(),{config:a,refetch:o}=Ve("simple"),[r,s]=p.useState(!1),{updateSettings:c,errors:u,loading:d}=vt("simple"),[l,h]=p.useState(!1),{data:m}=Hi(),{tokens:S}=Zt();p.useEffect(()=>{s(!!a.disabled)},[a.disabled]);const g=()=>{s(!r)},f=async T=>{T.preventDefault(),!a.disabled&&r?h(!0):v()},v=async()=>{try{await c({disabled:r}),o(),t({title:"Successfully saved",text:"Password authentication settings stored.",autoHideDuration:4e3,type:"success",show:!0})}catch(T){n(Z(T)),s(a.disabled)}};return e(ee,{children:i("form",{onSubmit:f,children:[i(K,{severity:"info",sx:{mb:3},children:["Overview of administrators on your Unleash instance:",e("br",{}),e("br",{}),e("strong",{children:"Password based administrators: "})," ",e(he,{to:"/admin/users",children:m==null?void 0:m.password}),e("br",{}),e("strong",{children:"Other administrators: "})," ",e(he,{to:"/admin/users",children:m==null?void 0:m.noPassword}),e("br",{}),e("strong",{children:"Admin service accounts: "})," ",e(he,{to:"/admin/service-accounts",children:m==null?void 0:m.service}),e("br",{}),e("strong",{children:"Admin API tokens: "})," ",e(he,{to:"/admin/api",children:S.filter(({type:T})=>T==="admin").length})]}),i(b,{container:!0,spacing:3,mb:2,children:[i(b,{item:!0,md:5,children:[e("strong",{children:"Password based login"}),e("p",{children:"Allow users to login with username & password"})]}),e(b,{item:!0,md:6,style:{padding:"20px"},children:e(ye,{control:e(we,{onChange:g,value:!r,name:"disabled",checked:!r}),label:r?"Disabled":"Enabled"})})]}),e(b,{container:!0,spacing:3,children:i(b,{item:!0,md:12,children:[e(H,{variant:"contained",color:"primary",type:"submit",disabled:d,children:"Save"})," ",e("p",{children:e("small",{style:{color:"red"},children:u==null?void 0:u.message})})]})}),e(qi,{open:l,setOpen:h,onClick:()=>{h(!1),v()},adminCount:m,tokens:S})]})})},Yi={enabled:!1,autoCreate:!1,unleashHostname:location.hostname,clientId:"",clientSecret:"",emailDomains:""},Ji=()=>{const{setToastData:t,setToastApiError:n}=X(),{uiConfig:a}=W(),[o,r]=p.useState(Yi),{config:s}=Ve("google"),{updateSettings:c,errors:u,loading:d}=vt("google");p.useEffect(()=>{s.clientId&&r(s)},[s]);const l=g=>{r({...o,[g.target.name]:g.target.value})},h=()=>{r({...o,enabled:!o.enabled})},m=()=>{r({...o,autoCreate:!o.autoCreate})},S=async g=>{g.preventDefault();try{await c(Xt(o)),t({title:"Settings stored",type:"success"})}catch(f){n(Z(f))}};return i(ee,{children:[i(z,{children:[i(K,{severity:"error",sx:{mb:2},children:["This integration is deprecated and will be removed in next major version. Please use ",e("strong",{children:"OpenID Connect"})," to enable Google SSO."]}),i(K,{severity:"info",sx:{mb:3},children:["Read the"," ",e("a",{href:"https://www.unleash-hosted.com/docs/enterprise-authentication/google",target:"_blank",rel:"noreferrer",children:"documentation"})," ","to learn how to integrate with Google OAuth 2.0. ",e("br",{}),"Callback URL:"," ",i("code",{children:[a.unleashUrl,"/auth/google/callback"]})]})]}),i("form",{onSubmit:S,children:[i(b,{container:!0,spacing:3,mb:2,children:[i(b,{item:!0,xs:5,children:[e("strong",{children:"Enable"}),e("p",{children:"Enable Google users to login. Value is ignored if Client ID and Client Secret are not defined."})]}),e(b,{item:!0,xs:6,style:{padding:"20px"},children:e(ye,{control:e(we,{onChange:h,value:o.enabled,name:"enabled",checked:o.enabled}),label:o.enabled?"Enabled":"Disabled"})})]}),i(b,{container:!0,spacing:3,mb:2,children:[i(b,{item:!0,xs:5,children:[e("strong",{children:"Client ID"}),e("p",{children:"(Required) The Client ID provided by Google when registering the application."})]}),e(b,{item:!0,xs:6,children:e(Q,{onChange:l,label:"Client ID",name:"clientId",placeholder:"",value:o.clientId,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),i(b,{container:!0,spacing:3,mb:2,children:[i(b,{item:!0,md:5,children:[e("strong",{children:"Client Secret"}),e("p",{children:"(Required) Client Secret provided by Google when registering the application."})]}),e(b,{item:!0,md:6,children:e(Q,{onChange:l,label:"Client Secret",name:"clientSecret",value:o.clientSecret,placeholder:"",style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),i(b,{container:!0,spacing:3,mb:2,children:[i(b,{item:!0,md:5,children:[e("strong",{children:"Unleash hostname"}),i("p",{children:["(Required) The hostname you are running Unleash on that Google should send the user back to. The final callback URL will be"," ",e("small",{children:e("code",{children:"https://[unleash.hostname.com]/auth/google/callback"})})]})]}),e(b,{item:!0,md:6,children:e(Q,{onChange:l,label:"Unleash Hostname",name:"unleashHostname",placeholder:"",value:o.unleashHostname||"",style:{width:"400px"},variant:"outlined",size:"small"})})]}),i(b,{container:!0,spacing:3,mb:2,children:[i(b,{item:!0,md:5,children:[e("strong",{children:"Auto-create users"}),e("p",{children:"Enable automatic creation of new users when signing in with Google."})]}),e(b,{item:!0,md:6,style:{padding:"20px"},children:e(we,{onChange:m,name:"enabled",checked:o.autoCreate})})]}),i(b,{container:!0,spacing:3,mb:2,children:[i(b,{item:!0,md:5,children:[e("strong",{children:"Email domains"}),e("p",{children:"(Optional) Comma separated list of email domains that should be allowed to sign in."})]}),e(b,{item:!0,md:6,children:e(Q,{onChange:l,label:"Email domains",name:"emailDomains",value:o.emailDomains,placeholder:"@company.com, @anotherCompany.com",style:{width:"400px"},rows:2,multiline:!0,variant:"outlined",size:"small"})})]}),e(b,{container:!0,spacing:3,children:i(b,{item:!0,md:5,children:[e(H,{variant:"contained",color:"primary",type:"submit",disabled:d,children:"Save"})," ",e("p",{children:e("small",{style:{color:"error.dark"},children:u==null?void 0:u.message})})]})})]})]})},Ki=()=>{const{authenticationType:t}=W().uiConfig,{uiConfig:n}=W(),a=[{label:"OpenID Connect",component:e(ji,{})},{label:"SAML 2.0",component:e(Wi,{})},{label:"Password",component:e(Vi,{})},{label:"Google",component:e(Ji,{})}].filter(o=>{var r;return((r=n.flags)==null?void 0:r.googleAuthEnabled)||o.label!=="Google"});return e("div",{children:e(Te,{permissions:ze,children:i(ee,{header:"Single Sign-On",children:[e(x,{condition:t==="enterprise",show:e(_o,{tabData:a})}),e(x,{condition:t==="open-source",show:e(K,{severity:"warning",children:"You are running the open-source version of Unleash. You have to use the Enterprise edition in order configure Single Sign-on."})}),e(x,{condition:t==="demo",show:e(K,{severity:"warning",children:"You are running Unleash in demo mode. You have to use the Enterprise edition in order configure Single Sign-on."})}),e(x,{condition:t==="custom",show:e(K,{severity:"warning",children:"You have decided to use custom authentication type. You have to use the Enterprise edition in order configure Single Sign-on from the user interface."})}),e(x,{condition:t==="hosted",show:e(K,{severity:"info",children:"Your Unleash instance is managed by the Unleash team."})})]})})})},Zi=te("api/admin/invoices"),Xi=y(H)(({theme:t})=>({width:"100%",marginBottom:t.spacing(1.5)})),Qi=({update:t})=>e(Xi,{href:`${Zi}/${t?"portal":"checkout"}`,variant:t?"outlined":"contained",children:t?"Update billing information":"Add billing information"}),er=y("aside")(({theme:t})=>({padding:t.spacing(4),height:"100%",borderRadius:t.shape.borderRadiusLarge,backgroundColor:t.palette.background.elevation2})),tr=y(D)(({theme:t})=>({marginBottom:t.spacing(4)})),nr=y(K)(({theme:t})=>({marginBottom:t.spacing(4)})),pn=y(D)(({theme:t})=>({fontSize:t.fontSizes.smallBody,color:t.palette.text.secondary})),or=y(Mt)(({theme:t})=>({margin:`${t.spacing(2.5)} 0`,borderColor:t.palette.divider})),ar=({instanceStatus:t})=>{const n=t.state!==Fn.ACTIVE;return e(b,{item:!0,xs:12,md:5,children:i(er,{children:[e(tr,{variant:"body1",children:"Billing information"}),e(x,{condition:n,show:i(nr,{severity:"warning",children:["In order to ",e("strong",{children:"Upgrade trial"})," you need to provide us your billing information."]})}),e(Qi,{update:!n}),e(pn,{children:n?"Once we have received your billing information we will upgrade your trial within 1 business day":"Update your credit card and business information and change which email address we send invoices to"}),e(or,{}),i(pn,{children:[e("a",{href:"mailto:elise@getunleash.ai?subject=PRO plan clarifications",children:"Get in touch with us"})," ","for any clarification"]})]})})},Le=()=>{const{data:t,error:n,mutate:a}=Pe(te("api/admin/user-admin"),ir);return p.useMemo(()=>({users:(t==null?void 0:t.users)??[],roles:(t==null?void 0:t.rootRoles)??[],loading:!n&&!t,refetch:()=>a(),error:n}),[t,n,a])},ir=t=>fetch(t).then(ve("Users")).then(n=>n.json()),rr=y(b)(({theme:t})=>({flexWrap:"nowrap",gap:t.spacing(1)})),st=({sx:t,children:n})=>e(rr,{container:!0,item:!0,justifyContent:"space-between",alignItems:"center",sx:t,children:n}),Ue=({children:t,vertical:n=!1})=>e(b,{container:n,item:!0,display:"flex",alignItems:n?"start":"center",direction:n?"column":void 0,children:t}),sr=y("span")(({theme:t})=>({fontSize:t.fontSizes.smallBody,marginLeft:t.spacing(1)})),mn=({children:t})=>i(sr,{children:["(",t,")"]}),lr=y("aside")(({theme:t})=>({padding:t.spacing(2.5),height:"100%",borderRadius:t.shape.borderRadiusLarge,boxShadow:t.boxShadows.elevated,[t.breakpoints.up("md")]:{padding:t.spacing(6.5)}})),gn=y(D)(({theme:t})=>({fontSize:t.fontSizes.smallBody,color:t.palette.text.secondary})),cr=y("span")(({theme:t})=>({fontSize:"3.25rem",lineHeight:1,color:t.palette.primary.main,fontWeight:800})),dr=y("span")(({theme:t})=>({marginLeft:t.spacing(1.5),fontWeight:t.fontWeight.bold})),ur=y("span")(({theme:t})=>({color:t.palette.primary.main,fontSize:t.fontSizes.mainHeader,fontWeight:t.fontWeight.bold})),hr=y(K)(({theme:t})=>({fontSize:t.fontSizes.smallerBody,marginBottom:t.spacing(3),marginTop:t.spacing(-1.5),[t.breakpoints.up("md")]:{marginTop:t.spacing(-4.5)}})),pr=y(qo)(({theme:t})=>({fontSize:"1rem",marginRight:t.spacing(1)})),mr=y(Mt)(({theme:t})=>({margin:`${t.spacing(3)} 0`})),gr=({instanceStatus:t})=>{var g;const{users:n}=Le(),a=Vo(t),{uiConfig:o}=W(),r=n.filter(f=>f.email),s={[je.PRO]:80,[je.COMPANY]:0,[je.TEAM]:0,[je.ENTERPRISE]:0,[je.UNKNOWN]:0,user:15},c=s[t.plan],u=t.seats??5,d=Math.min(r.length,u),l=r.length-d,h=s.user*l,m=c+h,S=t.state!==Fn.ACTIVE;return e(b,{item:!0,xs:12,md:7,children:i(lr,{children:[e(x,{condition:S,show:i(hr,{severity:"info",children:["After you have sent your billing information, your instance will be upgraded - you don't have to do anything."," ",e("a",{href:"mailto:elise@getunleash.ai?subject=PRO plan clarifications",children:"Get in touch with us"})," ","for any clarification"]})}),e(ut,{color:"success",children:"Current plan"}),e(b,{container:!0,children:i(st,{sx:f=>({marginBottom:f.spacing(3)}),children:[i(Ue,{children:[e(cr,{children:t.plan}),e(x,{condition:Yo(t),show:e(dr,{sx:f=>({color:a?f.palette.error.dark:f.palette.warning.dark}),children:a?"Trial expired":t.trialExtended?"Extended Trial":"Trial"})})]}),e(Ue,{children:e(x,{condition:c>0,show:i(ur,{children:["$",c.toFixed(2)]})})})]})}),e(x,{condition:!!((g=o==null?void 0:o.flags)!=null&&g.proPlanAutoCharge&&t.plan===je.PRO),show:i(O,{children:[i(b,{container:!0,children:[i(st,{sx:f=>({marginBottom:f.spacing(1.5)}),children:[i(Ue,{vertical:!0,children:[i(D,{children:[e("strong",{children:"Included members"}),e(mn,{children:i(he,{to:"/admin/users",children:[d," of 5 assigned"]})})]}),e(gn,{children:"You have 5 team members included in your PRO plan"})]}),i(Ue,{children:[e(pr,{}),e(D,{variant:"body2",children:"included"})]})]}),i(st,{children:[i(Ue,{vertical:!0,children:[i(D,{children:[e("strong",{children:"Paid members"}),e(mn,{children:i(he,{to:"/admin/users",children:[l," assigned"]})})]}),e(gn,{children:"$15/month per paid member"})]}),e(Ue,{children:i(D,{sx:f=>({fontSize:f.fontSizes.mainHeader}),children:["$",h.toFixed(2)]})})]})]}),e(mr,{}),e(b,{container:!0,children:i(st,{children:[e(Ue,{children:e(D,{sx:f=>({fontWeight:f.fontWeight.bold,fontSize:f.fontSizes.mainHeader}),children:"Total per month"})}),e(Ue,{children:i(D,{sx:f=>({fontWeight:f.fontWeight.bold,fontSize:"2rem"}),children:["$",m.toFixed(2)]})})]})})]})})]})})},fr=({instanceStatus:t})=>i(b,{container:!0,spacing:4,children:[e(ar,{instanceStatus:t}),e(gr,{instanceStatus:t})]}),yr=y(D)(({theme:t})=>({marginTop:t.spacing(6),marginBottom:t.spacing(2.5),fontSize:t.fontSizes.mainHeader})),br=[{Header:"Amount",accessor:"amountFormatted"},{Header:"Status",accessor:"status",disableGlobalFilter:!0},{Header:"Created date",accessor:"created",Cell:xe,sortType:"date",disableGlobalFilter:!0},{Header:"Due date",accessor:"dueDate",Cell:xe,sortType:"date",disableGlobalFilter:!0},{Header:"Download",accessor:"invoicePDF",align:"center",Cell:({value:t})=>e(z,{sx:{display:"flex",justifyContent:"center"},"data-loading":!0,children:e(_e,{href:t,children:e(Xo,{})})}),width:100,disableGlobalFilter:!0,disableSortBy:!0}],Sr=({data:t,isLoading:n=!1})=>{const a=p.useMemo(()=>({sortBy:[{id:"created"}]}),[]),{getTableProps:o,getTableBodyProps:r,headerGroups:s,rows:c,prepareRow:u}=N.useTable({columns:br,data:t,initialState:a,sortTypes:ke,autoResetGlobalFilter:!1,disableSortRemove:!0,defaultColumn:{Cell:ce}},N.useGlobalFilter,N.useSortBy);return i(ee,{isLoading:n,disablePadding:!0,children:[e(yr,{children:"Payment history"}),i(Jo,{...o(),children:[e(Ko,{headerGroups:s}),e(Ft,{...r(),children:c.map(d=>(u(d),e(et,{hover:!0,...d.getRowProps(),children:d.cells.map(l=>e(Zo,{...l.getCellProps(),children:l.render("Cell")}))})))})]}),e(x,{condition:c.length===0,show:e(be,{children:"No invoices to show."})})]})},$t="api/admin/invoices",vr=te($t),ho=(t={})=>{const n=()=>fetch(vr,{method:"GET"}).then(ve("Invoices")).then(u=>u.json()),{data:a,error:o}=Pe($t,n,t),[r,s]=p.useState(!o&&!a),c=()=>{jn($t)};return p.useEffect(()=>{s(!o&&!a)},[a,o]),{invoices:(a==null?void 0:a.invoices)||[],error:o,loading:r,refetchInvoices:c}},Cr=()=>{const{instanceStatus:t,isBilling:n,refetchInstanceStatus:a,refresh:o,loading:r}=jt(),{invoices:s}=ho();return p.useEffect(()=>{(async()=>{await o(),a()})()},[a,o]),e("div",{children:e(ee,{header:"Billing",isLoading:r,children:e(x,{condition:n,show:e(Te,{permissions:Y,children:i(O,{children:[e(fr,{instanceStatus:t}),e(Sr,{data:s})]})}),elseShow:e(K,{severity:"error",children:"Billing is not enabled for this instance."})})})})},wr=te("api/admin/invoices/portal"),xr=()=>{const{refetchInvoices:t,invoices:n}=ho(),[a,o]=p.useState(!1),{locationSettings:r}=zn();return p.useEffect(()=>{t(),o(!0)},[]),e(x,{condition:n.length>0,show:e(ee,{header:e(ne,{title:"Invoices",actions:e(H,{href:wr,rel:"noreferrer",target:"_blank",endIcon:e(Qo,{}),children:"Billing portal"})}),children:e("div",{children:i(Wn,{children:[e(Hn,{children:i(et,{children:[e(se,{children:"Amount"}),e(se,{children:"Status"}),e(se,{children:"Due date"}),e(se,{children:"PDF"}),e(se,{children:"Link"})]})}),e(Ft,{children:n.map(s=>i(et,{style:{backgroundColor:s.status==="past-due"?"error.dark":"inherit"},children:[e(se,{style:{textAlign:"left"},children:s.amountFormatted}),e(se,{style:{textAlign:"left"},children:s.status}),e(se,{style:{textAlign:"left"},children:s.dueDate&&_n(s.dueDate,r.locale)}),e(se,{style:{textAlign:"left"},children:e("a",{href:s.invoicePDF,children:"PDF"})}),e(se,{style:{textAlign:"left"},children:e("a",{href:s.invoiceURL,target:"_blank",rel:"noreferrer",children:"Payment link"})})]},s.invoiceURL))})]})})}),elseShow:e("div",{children:a&&"No invoices to show."})})},Tr=()=>e("div",{children:e(Te,{permissions:Y,children:e(xr,{})})}),kr=()=>{const{uiConfig:t,loading:n}=W();return n?null:t.flags.UNLEASH_CLOUD?e(ea,{to:"/admin/billing",replace:!0}):e(Tr,{})},Er=()=>i(K,{severity:"info",children:[i("p",{children:["Use this page to configure allowed CORS origins for the Frontend API (",e("code",{children:"/api/frontend"}),")."]}),i("p",{children:["This configuration will not affect the Admin API (",e("code",{children:"/api/admin"}),") nor the Client API (",e("code",{children:"/api/client"}),")."]}),i("p",{children:["An asterisk (",e("code",{children:"*"}),") may be used to allow API calls from any origin."]}),e("br",{}),e("p",{children:"Be aware that changes here will take up to two minutes to be updated. In addition, there is a maxAge on the Access-Control-Allow-Origin header that will instruct browsers to cache this header for some time. The cache period is set to the maxium that the browser allows (2h for Chrome, 24h for Firefox)."})]}),Rr=()=>{const{makeRequest:t,createRequest:n,errors:a,loading:o}=Ge({propagateErrors:!0});return{setFrontendSettings:async s=>{const u=n("api/admin/ui-config",{method:"POST",body:JSON.stringify({frontendSettings:{frontendApiOrigins:s}})},"setFrontendSettings");await t(u.caller,u.id)},loading:o,errors:a}},Ar=({frontendApiOrigins:t})=>{const{setFrontendSettings:n}=Rr(),{setToastData:a,setToastApiError:o}=X(),[r,s]=p.useState(fn(t)),c=sn(),u=sn();return e("form",{onSubmit:async l=>{try{const h=Dr(r);l.preventDefault(),await n(h),s(fn(h)),a({title:"Settings saved",type:"success"})}catch(h){o(Z(h))}},children:i(z,{sx:{display:"grid",gap:1},children:[i("label",{htmlFor:c,children:["Which origins should be allowed to call the Frontend API? Add only one origin per line. The CORS specification does not support wildcard for subdomains, it needs to be a fully qualified domain, including the protocol.",e("br",{}),e("br",{}),'If you specify "*" it will be the chosen origin.',e("br",{}),e("br",{}),"Example:"]}),i("code",{style:{fontSize:"0.7em"},children:["https://www.example.com",e("br",{}),"https://www.example2.com"]}),e(Q,{id:c,"aria-describedby":u,placeholder:Pr,value:r,onChange:l=>s(l.target.value),multiline:!0,rows:12,variant:"outlined",fullWidth:!0,InputProps:{style:{fontFamily:"monospace",fontSize:"0.8em"}}}),e(qn,{permission:Y})]})})},Dr=t=>t.split(/[,\n\s]+/).map(n=>n.replace(/\/$/,"")).filter(Boolean),fn=t=>(t==null?void 0:t.join(`
|
|
@@ -12,7 +12,7 @@ import{t as y,r as p,aD as Bo,cA as Lo,aE as Oo,j as e,aF as In,cB as on,cC as E
|
|
|
12
12
|
--data-raw '${JSON.stringify(w(),void 0,2)}'`,A=()=>{u(Ae)},j=_=>_.length,J=_=>!(P!=null&&P.filter(oe=>oe.name===_&&oe.id!==n).length),R=j(d)&&J(d);return e(Ie,{loading:L,title:"Edit group",description:"Groups is the best and easiest way to organize users and then use them in projects to assign a specific role in one go to all the users in a group.",documentationLink:"https://docs.getunleash.io/advanced/groups",documentationLinkLabel:"Groups documentation",formatApiCode:M,children:e(go,{name:d,description:h,mappingsSSO:S,users:f,rootRole:T,setName:_=>{k(),J(_)||I({name:"A group with that name already exists."}),l(_)},setDescription:m,setMappingsSSO:g,setUsers:v,setRootRole:C,errors:E,handleSubmit:U,handleCancel:A,mode:Wt,children:e(H,{type:"submit",variant:"contained",color:"primary",disabled:!R,"data-testid":Zn,children:"Save"})})})},es=y(Xn)(({theme:t})=>({borderRadius:t.shape.borderRadiusLarge,padding:t.spacing(2.5,4),boxShadow:"none",marginBottom:t.spacing(2),fontSize:t.fontSizes.smallBody})),ts=y("div")(({theme:t})=>({display:"flex",alignItems:"center",justifyContent:"space-between"})),ns=y("h1")(({theme:t})=>({fontSize:t.fontSizes.mainHeader})),os=y("div")(({theme:t})=>({display:"flex"})),as=y("span")(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginLeft:t.spacing(1)})),is=({title:t,description:n,actions:a})=>(Nn(t),i(es,{children:[i(ts,{children:[e(ns,{children:t}),e(os,{children:a})]}),e(x,{condition:!!(n!=null&&n.length),show:i(O,{children:["Description:",e(as,{children:n})]})})]})),fo=({open:t,setOpen:n,group:a})=>{const{refetchGroups:o}=He(),{removeGroup:r}=it(),{setToastData:s,setToastApiError:c}=X(),u=Ce();return e(le,{open:t,primaryButtonText:"Delete group",secondaryButtonText:"Cancel",onClick:async()=>{try{await r(a.id),o(),n(!1),u("/admin/groups"),s({title:"Group removed successfully",type:"success"})}catch(l){c(Z(l))}},onClose:()=>{n(!1)},title:"Delete group?",children:i(D,{children:["Do you really want to delete ",e("strong",{children:a.name}),"? Users who are granted access to projects only via this group will lose access to those projects."]})})},rs=y("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),ss=y("p")(({theme:t})=>({color:t.palette.text.secondary,marginBottom:t.spacing(1)})),ls=y("div")(()=>({marginTop:"auto",display:"flex",justifyContent:"flex-end"})),cs=y(H)(({theme:t})=>({marginLeft:t.spacing(3)})),ds=y(z)(({theme:t})=>({marginTop:t.spacing(2)})),yo=({open:t,setOpen:n,group:a})=>{const{refetchGroup:o}=St(a.id),{refetchGroups:r}=He(),{updateGroup:s,loading:c}=it(),{setToastData:u,setToastApiError:d}=X(),{uiConfig:l}=W(),{users:h,setUsers:m,getGroupPayload:S}=en(a.name,a.description,a.mappingsSSO,a.users,a.rootRole);return p.useEffect(()=>{m(a.users)},[a.users,t,m]),e(Ht,{open:t,onClose:()=>{n(!1)},label:"Edit users",children:e(Ie,{loading:c,modal:!0,title:"Edit users",description:"Groups is the best and easiest way to organize users and then use them in projects to assign a specific role in one go to all the users in a group.",documentationLink:"https://docs.getunleash.io/advanced/groups",documentationLinkLabel:"Groups documentation",formatApiCode:()=>`curl --location --request PUT '${l.unleashUrl}/api/admin/groups/${a.id}' \\
|
|
13
13
|
--header 'Authorization: INSERT_API_KEY' \\
|
|
14
14
|
--header 'Content-Type: application/json' \\
|
|
15
|
-
--data-raw '${JSON.stringify(S(),void 0,2)}'`,children:i(rs,{onSubmit:async v=>{v.preventDefault();try{await s(a.id,S()),o(),r(),n(!1),u({title:"Group users saved successfully",type:"success"})}catch(T){d(Z(T))}},children:[i("div",{children:[e(ss,{children:"Edit users in this group"}),e(po,{users:h,setUsers:m}),e(mo,{users:h,setUsers:m})]}),e(ls,{children:i(ds,{children:[e(H,{type:"submit",variant:"contained",color:"primary","data-testid":Zn,children:"Save"}),e(cs,{onClick:()=>{n(!1)},children:"Cancel"})]})})]})})})},us=({open:t,setOpen:n,user:a,group:o})=>{const{refetchGroup:r}=St(o.id),{updateGroup:s}=it(),{setToastData:c,setToastApiError:u}=X(),d=async()=>{try{const h={...o,users:o.users.filter(({id:m})=>m!==(a==null?void 0:a.id)).map(({id:m})=>({user:{id:m}}))};await s(o.id,h),r(),n(!1),c({title:"User removed from group successfully",type:"success"})}catch(h){u(Z(h))}},l=(a==null?void 0:a.name)||(a==null?void 0:a.username)||(a==null?void 0:a.email);return e(le,{open:t&&!!a,primaryButtonText:"Remove user",secondaryButtonText:"Cancel",onClick:d,onClose:()=>{n(!1)},title:"Remove user from group?",children:i(D,{children:["Do you really want to remove ",e("strong",{children:l})," from"," ",e("strong",{children:o.name}),"? ",e("strong",{children:l})," will lose all access rights granted by this group."]})})},hs=Array(15).fill({name:"Name of the user",username:"Username of the user"}),ps={id:"joinedAt"},{value:Sn,setValue:ms}=ua("Group:v1",ps),gs=()=>{const t=Number(zt("groupId")),n=_t(),a=Se(n.breakpoints.down("md")),{group:o,loading:r}=St(t),[s,c]=p.useState(!1),[u,d]=p.useState(!1),[l,h]=p.useState(!1),[m,S]=p.useState(),g=p.useMemo(()=>[{Header:"Avatar",accessor:"imageUrl",Cell:({row:{original:A}})=>e(ce,{children:e(qe,{user:A})}),maxWidth:85,disableSortBy:!0},{id:"name",Header:"Name",accessor:A=>A.name||"",Cell:pe,minWidth:100,searchable:!0},{id:"username",Header:"Username",accessor:A=>A.username||A.email,Cell:pe,minWidth:100,searchable:!0},{Header:"Joined",accessor:"joinedAt",Cell:xe,sortType:"date",maxWidth:150},{id:"createdBy",Header:"Added by",accessor:"createdBy",Cell:pe,minWidth:90,searchable:!0},{Header:"Last login",accessor:A=>A.seenAt||"",Cell:({row:{original:A}})=>e(Ye,{value:A.seenAt,emptyText:"Never",title:j=>`Last login: ${j}`}),sortType:"date",maxWidth:150},{Header:"Actions",id:"Actions",align:"center",Cell:({row:{original:A}})=>e(gt,{children:e(Ne,{title:"Remove user from group",arrow:!0,describeChild:!0,children:e("span",{children:e(_e,{"data-testid":`${ha}-${A.id}`,onClick:()=>{S(A),h(!0)},children:e($e,{})})})})}),maxWidth:100,disableSortBy:!0}],[S,h]),[f,v]=Qn(),[T]=p.useState(()=>({sortBy:[{id:f.get("sort")||Sn.id,desc:f.has("order")?f.get("order")==="desc":Sn.desc}],hiddenColumns:["description"],globalFilter:f.get("search")||""})),[C,w]=p.useState(T.globalFilter),{data:k,getSearchText:E,getSearchContext:I}=bt(g,C,(o==null?void 0:o.users)??[]),P=p.useMemo(()=>(k==null?void 0:k.length)===0&&r?hs:k,[k,r]),{headerGroups:B,rows:L,prepareRow:U,state:{sortBy:M}}=N.useTable({columns:g,data:P,initialState:T,sortTypes:ke,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},N.useSortBy,N.useFlexLayout);return p.useEffect(()=>{const A={};A.sort=M[0].id,M[0].desc&&(A.order="desc"),C&&(A.search=C),v(A,{replace:!0}),ms({id:M[0].id,desc:M[0].desc||!1})},[M,C,v]),e(x,{condition:!!o,show:i(O,{children:[e(is,{title:o==null?void 0:o.name,description:o==null?void 0:o.description,actions:i(O,{children:[e(Re,{"data-testid":pa,to:`/admin/groups/${t}/edit`,component:he,"data-loading":!0,permission:Y,tooltipProps:{title:"Edit group"},children:e(ot,{})}),e(Re,{"data-testid":ma,"data-loading":!0,onClick:()=>c(!0),permission:Y,tooltipProps:{title:"Delete group"},children:e($e,{})})]})}),i(ee,{isLoading:r,header:e(ne,{secondary:!0,title:`Users (${L.length<P.length?`${L.length} of ${P.length}`:P.length})`,actions:i(O,{children:[e(x,{condition:!a,show:i(O,{children:[e(fe,{initialValue:C,onChange:w,hasFilters:!0,getSearchContext:I}),e(ne.Divider,{})]})}),e(qt,{"data-testid":ga,onClick:()=>{d(!0)},maxWidth:"700px",Icon:yt,permission:Y,children:"Edit users"})]}),children:e(x,{condition:a,show:e(fe,{initialValue:C,onChange:w,hasFilters:!0,getSearchContext:I})})}),children:[e(Je,{value:E(C),children:e(Be,{rows:L,headerGroups:B,prepareRow:U})}),e(x,{condition:L.length===0,show:e(x,{condition:(C==null?void 0:C.length)>0,show:i(be,{children:["No users found matching “",C,"” in this group."]}),elseShow:e(be,{children:"This group is empty. Get started by adding a user to the group."})})}),e(fo,{open:s,setOpen:c,group:o}),e(yo,{open:u,setOpen:d,group:o}),e(us,{open:l,setOpen:h,user:m,group:o})]})]})})},fs=y(eo)(({theme:t})=>({pointerEvents:"none",".MuiPaper-root":{padding:t.spacing(2)}})),ys=y("div")(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(1)})),bs=({user:t,open:n,anchorEl:a,onPopoverClose:o})=>i(fs,{open:n,anchorEl:a,onClose:o,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},children:[e(ys,{children:(t==null?void 0:t.name)||(t==null?void 0:t.username)}),e("div",{children:t==null?void 0:t.email})]}),Ss=y("div")(({theme:t})=>({display:"inline-flex",alignItems:"center",flexWrap:"wrap",marginLeft:t.spacing(1)})),vn=y(qe)(({theme:t})=>({outline:`${t.spacing(.25)} solid ${t.palette.background.paper}`,marginLeft:t.spacing(-1),"&:hover":{outlineColor:t.palette.primary.main}})),vs=({users:t})=>{const n=p.useMemo(()=>t.sort((l,h)=>(h==null?void 0:h.joinedAt.getTime())-(l==null?void 0:l.joinedAt.getTime())).slice(0,9),[t]),[a,o]=p.useState(null),[r,s]=p.useState(),c=l=>{o(l.currentTarget)},u=()=>{o(null)},d=!!a;return i(Ss,{children:[n.map(l=>e(vn,{user:l,onMouseEnter:h=>{c(h),s(l)},onMouseLeave:u},l.id)),e(x,{condition:t.length>9,show:i(vn,{children:["+",t.length-n.length]})}),e(bs,{open:d,user:r,anchorEl:a,onPopoverClose:u})]})},Cs=y("div")(({theme:t})=>({display:"flex",justifyContent:"center",transform:"translate3d(8px, -6px, 0)"})),ws=y(eo)(({theme:t})=>({borderRadius:t.shape.borderRadiusLarge,padding:t.spacing(1,1.5)})),xs=({groupId:t,onEditUsers:n,onRemove:a})=>{const[o,r]=p.useState(null),s=!!o,c=h=>{r(h.currentTarget)},u=()=>{r(null)},d=`feature-${t}-actions`,l=`${d}-menu`;return i(Cs,{onClick:h=>{h.preventDefault(),h.stopPropagation()},children:[e(Ne,{title:"Group actions",arrow:!0,describeChild:!0,children:e(_e,{id:d,"aria-controls":s?l:void 0,"aria-haspopup":"true","aria-expanded":s?"true":void 0,onClick:c,type:"button",children:e(fa,{})})}),e(ws,{id:l,anchorEl:o,open:s,onClose:u,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,children:i(ya,{"aria-labelledby":d,children:[i(Ee,{onClick:u,component:he,to:`/admin/groups/${t}/edit`,children:[e(At,{children:e(ot,{})}),e(Dt,{children:e(D,{variant:"body2",children:"Edit group"})})]}),i(Ee,{onClick:()=>{n(),u()},children:[e(At,{children:e(Bi,{})}),e(Dt,{children:e(D,{variant:"body2",children:"Edit group users"})})]}),i(Ee,{onClick:()=>{a(),u()},children:[e(At,{children:e($e,{})}),e(Dt,{children:e(D,{variant:"body2",children:"Delete group"})})]})]})})]})},Ts=y(he)(({theme:t})=>({textDecoration:"none",color:t.palette.text.primary})),ks=y("aside")(({theme:t})=>({padding:t.spacing(2.5),height:"100%",border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadiusLarge,boxShadow:t.boxShadows.card,display:"flex",flexDirection:"column",[t.breakpoints.up("md")]:{padding:t.spacing(4)},"&:hover":{transition:"background-color 0.2s ease-in-out",backgroundColor:t.palette.neutral.light}})),bo=y("div")(()=>({display:"flex",alignItems:"center",justifyContent:"space-between"})),Es=y(bo)(()=>({alignItems:"flex-start"})),Rs=y(bo)(()=>({marginTop:"auto"})),As=y("h2")(({theme:t})=>({fontSize:t.fontSizes.mainHeader,fontWeight:t.fontWeight.medium})),Ds=y("div")(({theme:t})=>({display:"flex",alignItems:"center",color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody})),Ps=y("p")(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(1),marginBottom:t.spacing(4)})),Is=y("span")(({theme:t})=>({color:t.palette.text.secondary,marginLeft:t.spacing(1)})),Bs=y("div")(({theme:t})=>({maxWidth:"50%",display:"flex",justifyContent:"flex-end",gap:t.spacing(.5),flexWrap:"wrap"})),Ls=y("span")(({theme:t})=>({display:"flex",color:t.palette.text.secondary,alignItems:"center",gap:t.spacing(1),fontSize:t.fontSizes.smallBody})),Os=({group:t,onEditUsers:n,onRemoveGroup:a})=>{var r;const o=Ce();return e(O,{children:e(Ts,{to:`/admin/groups/${t.id}`,children:i(ks,{children:[i(Es,{children:[e(As,{children:t.name}),e(Ds,{children:e(xs,{groupId:t.id,onEditUsers:()=>n(t),onRemove:()=>a(t)})})]}),e(x,{condition:!!t.rootRole,show:i(Ls,{children:[e("p",{children:"Root role:"}),e(ba,{roleId:t.rootRole})]})}),e(Ps,{children:t.description}),i(Rs,{children:[e(x,{condition:((r=t.users)==null?void 0:r.length)>0,show:e(vs,{users:t.users}),elseShow:e(Is,{children:"This group has no users."})}),e(Bs,{children:e(x,{condition:t.projects.length>0,show:t.projects.map(s=>e(Ne,{title:"View project",arrow:!0,placement:"bottom-end",describeChild:!0,children:e(ut,{onClick:c=>{c.preventDefault(),o(`/projects/${s}/settings/access`)},color:"secondary",icon:e(Sa,{}),children:s})},s)),elseShow:e(Ne,{title:"This group is not used in any project",arrow:!0,describeChild:!0,children:e(x,{condition:!t.rootRole,show:e(ut,{children:"Not used"})})})})})]})]})},t.id)})},Us=()=>{const t=y("div")(({theme:a})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:a.spacing(6),marginLeft:"auto",marginRight:"auto"})),n=y(D)(({theme:a})=>({fontSize:a.fontSizes.bodySize,marginBottom:a.spacing(2.5)}));return i(t,{children:[e(n,{children:"No groups available. Get started by adding a new group."}),e(H,{to:"/admin/groups/create-group",component:he,variant:"outlined",color:"primary",children:"Create your first group"})]})},Ns=(t,n)=>{var r,s,c,u,d,l;const a=n.toLowerCase(),o={names:(r=t.users)==null?void 0:r.map(h=>{var m;return((m=h.name)==null?void 0:m.toLowerCase())||""}),usernames:(s=t.users)==null?void 0:s.map(h=>{var m;return((m=h.username)==null?void 0:m.toLowerCase())||""}),emails:(c=t.users)==null?void 0:c.map(h=>{var m;return((m=h.email)==null?void 0:m.toLowerCase())||""})};return t.name.toLowerCase().includes(a)||t.description.toLowerCase().includes(a)||((u=o.names)==null?void 0:u.some(h=>h.includes(a)))||((d=o.usernames)==null?void 0:d.some(h=>h.includes(a)))||((l=o.emails)==null?void 0:l.some(h=>h.includes(a)))},$s=()=>{const t=Ce(),[n,a]=p.useState(!1),[o,r]=p.useState(!1),[s,c]=p.useState(void 0),{groups:u=[],loading:d}=He(),[l,h]=Qn(),[m,S]=p.useState(l.get("search")||""),g=Se(De.breakpoints.down("md"));p.useEffect(()=>{const C={};m&&(C.search=m),h(C,{replace:!0})},[m,h]);const f=p.useMemo(()=>{const C=u.sort((w,k)=>w.name.localeCompare(k.name));return m?C.filter(w=>Ns(w,m)):C},[u,m]),v=C=>{c(C),a(!0)},T=C=>{c(C),r(!0)};return i(ee,{isLoading:d,header:e(ne,{title:`Groups (${f.length})`,actions:i(O,{children:[e(x,{condition:!g,show:i(O,{children:[e(fe,{initialValue:m,onChange:S}),e(ne.Divider,{})]})}),e(qt,{onClick:()=>t("/admin/groups/create-group"),maxWidth:"700px",Icon:yt,permission:Y,"data-testid":va,children:"New group"})]}),children:e(x,{condition:g,show:e(fe,{initialValue:m,onChange:S})})}),children:[e(Je,{value:m,children:e(b,{container:!0,spacing:2,children:f.map(C=>e(b,{item:!0,xs:12,md:6,children:e(Os,{group:C,onEditUsers:v,onRemoveGroup:T})},C.id))})}),e(x,{condition:!d&&f.length===0,show:e(x,{condition:(m==null?void 0:m.length)>0,show:i(be,{children:["No groups found matching “",m,"”"]}),elseShow:e(Us,{})})}),e(x,{condition:!!s,show:e(yo,{open:n,setOpen:a,group:s})}),e(x,{condition:!!s,show:e(fo,{open:o,setOpen:r,group:s})})]})},Gs=()=>e("div",{children:e(Te,{permissions:ze,children:e($s,{})})}),Ms=()=>{const{data:t,error:n,mutate:a}=Pe(te("api/admin/instance-admin/statistics"),Fs);return p.useMemo(()=>({stats:t,loading:!n&&!t,refetchGroup:()=>a(),error:n}),[t,n,a])},Fs=t=>fetch(t).then(ve("Instance Stats")).then(n=>n.json()),js=()=>{const{stats:t}=Ms();let n,a;t!=null&&t.versionEnterprise?(n="Unleash Enterprise version",a=t.versionEnterprise):(n="Unleash OSS version",a=t==null?void 0:t.versionOSS);const o=[{title:"Instance Id",value:t==null?void 0:t.instanceId},{title:n,value:a},{title:"Users",value:t==null?void 0:t.users},{title:"Feature toggles",value:t==null?void 0:t.featureToggles},{title:"Projects",value:t==null?void 0:t.projects},{title:"Environments",value:t==null?void 0:t.environments},{title:"Roles",value:t==null?void 0:t.roles},{title:"Groups",value:t==null?void 0:t.groups},{title:"Context fields",value:t==null?void 0:t.contextFields},{title:"Strategies",value:t==null?void 0:t.strategies},{title:"Feature exports",value:t==null?void 0:t.featureExports},{title:"Feature imports",value:t==null?void 0:t.featureImports}];return t!=null&&t.versionEnterprise&&o.push({title:"SAML enabled",value:t!=null&&t.SAMLenabled?"Yes":"No"},{title:"OIDC enabled",value:t!=null&&t.OIDCenabled?"Yes":"No"}),e(ee,{header:e(ne,{title:"Instance Statistics"}),children:i(Ci,{sx:{display:"grid",gap:4},children:[i(Wn,{"aria-label":"Instance statistics",children:[e(Hn,{children:i(et,{children:[e(se,{children:"Field"}),e(se,{align:"right",children:"Value"})]})}),e(Ft,{children:o.map(r=>i(et,{children:[e(se,{component:"th",scope:"row",children:r.title}),e(se,{align:"right",children:r.value})]},r.title))})]}),e("span",{style:{textAlign:"center"},children:e(H,{startIcon:e(Ca,{}),"aria-label":"Download instance statistics",color:"primary",variant:"contained",target:"_blank",rel:"noreferrer",href:te("/api/admin/instance-admin/statistics/csv"),children:"Download"})})]})})},zs=()=>e("div",{children:e(js,{})}),Ws=()=>e(K,{severity:"warning",children:i("p",{children:[e("b",{children:"Heads up!"})," If you enable maintenance mode, edit access in the entire system will be disabled for all the users (admins, editors, custom roles, etc). During this time nobody will be able to do changes or to make new configurations."]})}),Hs=()=>{const{data:t,error:n,mutate:a}=Pe(te("api/admin/maintenance"),_s);return p.useMemo(()=>({enabled:!!(t!=null&&t.enabled),loading:!n&&!t,refetchMaintenance:a,error:n}),[t,n,a])},_s=t=>fetch(t).then(ve("Maintenance")).then(n=>n.json()),qs=()=>{const{makeRequest:t,createRequest:n,errors:a,loading:o}=Ge({propagateErrors:!0});return{toggleMaintenance:async s=>{const u=n("api/admin/maintenance",{method:"POST",body:JSON.stringify(s)});try{await t(u.caller,u.id)}catch(d){throw d}},errors:a,loading:o}},Vs=y("div")(({theme:t})=>({display:"flex",flexDirection:"column",padding:t.spacing(3),border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadiusLarge})),Ys=y(z)(({theme:t})=>({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"})),Js=y(z)(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(2)})),Ks=y(D)(({theme:t})=>({fontSize:t.fontSizes.smallBody})),Zs=()=>{const{enabled:t,refetchMaintenance:n}=Hs(),{toggleMaintenance:a}=qs(),{trackEvent:o}=Vt(),{setToastData:r}=X();return i(Vs,{children:[i(Ys,{children:[e("b",{children:"Maintenance Mode"}),e(ye,{sx:{margin:0},control:e(we,{onChange:async()=>{r({type:"success",title:`Maintenance mode has been successfully ${t?"disabled":"enabled"}`}),o("maintenance",{props:{eventType:`maintenance ${t?"de":""}activated`}}),await a({enabled:!t}),n()},value:t,name:"enabled",checked:t}),label:e(Ks,{children:t?"Enabled":"Disabled"})})]}),e(Js,{children:"Maintenance Mode is useful when you want to freeze your system so nobody can do any changes during this time. When enabled it will show a banner at the top of the applications and only an admin can enable it or disable it."})]})},Xs=()=>e("div",{children:e(Te,{permissions:Y,children:e(el,{})})}),Qs=y(z)(({theme:t})=>({display:"grid",gap:t.spacing(4)})),el=()=>{const{loading:t}=W();return t?null:e(ee,{header:e(ne,{title:"Maintenance"}),children:i(Qs,{children:[e(Ws,{}),e(Zs,{})]})})},tl=t=>{const n={display:"flex",justifyContent:"center",alignItems:"center",width:"100%",textDecoration:"none",color:"inherit",padding:t.theme.spacing(1.5,3)},a={fontWeight:"bold",borderRadius:"3px",padding:t.theme.spacing(1.5,3)};return t.isActive?{...n,...a}:n},ue=({to:t,children:n})=>{const a=_t();return e(wa,{to:t,style:({isActive:o})=>tl({isActive:o,theme:a}),children:n})},nl=y(Xn)(({theme:t})=>({marginBottom:"1rem",borderRadius:"12.5px",boxShadow:"none",padding:"0 2rem"}));function ol(){const{uiConfig:t,isEnterprise:n}=W(),{pathname:a}=Yt(),{isBilling:o}=jt(),{flags:r,networkViewEnabled:s}=t,c=a.split("/")[2];return e(nl,{children:i(Jt,{value:c,variant:"scrollable",scrollButtons:"auto",allowScrollButtonsMobile:!0,children:[e(de,{value:"users",label:e(ue,{to:"/admin/users",children:e("span",{children:"Users"})})}),n()&&e(de,{value:"service-accounts",label:e(ue,{to:"/admin/service-accounts",children:e("span",{children:"Service accounts"})})}),r.UG&&e(de,{value:"groups",label:e(ue,{to:"/admin/groups",children:e("span",{children:"Groups"})})}),n()&&e(de,{value:"roles",label:e(ue,{to:"/admin/roles",children:e("span",{children:"Roles"})})}),e(de,{value:"api",label:e(ue,{to:"/admin/api",children:"API access"})}),t.flags.embedProxyFrontend&&e(de,{value:"cors",label:e(ue,{to:"/admin/cors",children:"CORS origins"})}),e(de,{value:"auth",label:e(ue,{to:"/admin/auth",children:"Single sign-on"})}),e(de,{value:"instance",label:e(ue,{to:"/admin/instance",children:"Instance stats"})}),s&&e(de,{value:"network",label:e(ue,{to:"/admin/network",children:"Network"})}),e(de,{value:"maintenance",label:e(ue,{to:"/admin/maintenance",children:"Maintenance"})}),o&&e(de,{value:"billing",label:e(ue,{to:"/admin/billing",children:"Billing"})})]})})}const al=p.lazy(()=>import("./NetworkOverview-c0c2c8df.js").then(t=>t.N)),il=p.lazy(()=>import("./NetworkTraffic-9390e1ed.js")),rl=y(ee)(()=>({".page-header":{padding:0}})),sl=[{label:"Overview",path:"/admin/network"},{label:"Traffic",path:"/admin/network/traffic"}],ll=()=>{const{pathname:t}=Yt();return e("div",{children:e(rl,{headerClass:"page-header",header:e(Jt,{value:t,indicatorColor:"primary",textColor:"primary",variant:"scrollable",allowScrollButtonsMobile:!0,children:sl.map(({label:n,path:a})=>e(de,{value:a,label:e(ue,{to:a,children:e("span",{children:n})})},n))}),children:i(Kt,{children:[e(V,{path:"traffic",element:e(il,{})}),e(V,{path:"*",element:e(al,{})})]})})})},cl=y(z)(()=>({display:"flex",justifyContent:"center"})),dl=({role:t,onEdit:n,onDelete:a})=>{const o=We.includes(t.type);return i(cl,{children:[e(Re,{"data-loading":!0,onClick:n,permission:Y,disabled:o,tooltipProps:{title:o?"You cannot edit a predefined role":"Edit role"},children:e(ot,{})}),e(Re,{"data-loading":!0,onClick:a,permission:Y,disabled:o,tooltipProps:{title:o?"You cannot remove a predefined role":"Remove role"},children:e($e,{})})]})},ul=y(ut)(({theme:t})=>({marginLeft:t.spacing(1)})),hl=({role:t})=>e(pe,{value:t.name,subtitle:t.description,afterTitle:e(x,{condition:We.includes(t.type),show:e(ul,{color:"success",children:"Predefined"})})}),pl=({users:t})=>{const[n]=p.useState(()=>({sortBy:[{id:"last-login"}]})),a=p.useMemo(()=>[{id:"name",Header:"Name",accessor:c=>c.name||"",minWidth:200,Cell:({row:{original:c}})=>e(pe,{value:c.name,subtitle:c.email||c.username})},{Header:"Created",accessor:"createdAt",Cell:xe,sortType:"date",width:120,maxWidth:120},{id:"last-login",Header:"Last login",accessor:c=>c.seenAt||"",Cell:({row:{original:c}})=>e(Ye,{value:c.seenAt,emptyText:"Never",title:u=>`Last login: ${u}`}),sortType:"date",maxWidth:150}],[]),{headerGroups:o,rows:r,prepareRow:s}=N.useTable({columns:a,data:t,initialState:n,sortTypes:ke,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},N.useSortBy,N.useFlexLayout);return e(Be,{rows:r,headerGroups:o,prepareRow:s})},ml=y(D)(({theme:t})=>({fontSize:t.fontSizes.smallerBody})),So=({serviceAccount:t,value:n,onCreateToken:a})=>{var r,s,c;const{searchQuery:o}=xa();return!t.tokens||t.tokens.length===0?a?e(Ta,{title:"Create token",onClick:a}):e(ce,{children:"0 tokens"}):e(ce,{children:e(to,{tooltip:e(O,{children:(r=t.tokens)==null?void 0:r.map(({id:u,description:d})=>e(ml,{children:e(ka,{search:o,children:d})},u))}),highlighted:o.length>0&&n.toLowerCase().includes(o.toLowerCase()),children:((s=t.tokens)==null?void 0:s.length)===1?"1 token":`${(c=t.tokens)==null?void 0:c.length} tokens`})})},gl=({serviceAccounts:t})=>{const[n]=p.useState(()=>({sortBy:[{id:"seenAt"}]})),a=p.useMemo(()=>[{id:"name",Header:"Name",accessor:c=>c.name||"",minWidth:200,Cell:({row:{original:c}})=>e(pe,{value:c.name,subtitle:c.username})},{id:"tokens",Header:"Tokens",accessor:c=>{var u;return((u=c.tokens)==null?void 0:u.map(({description:d})=>d).join(`
|
|
15
|
+
--data-raw '${JSON.stringify(S(),void 0,2)}'`,children:i(rs,{onSubmit:async v=>{v.preventDefault();try{await s(a.id,S()),o(),r(),n(!1),u({title:"Group users saved successfully",type:"success"})}catch(T){d(Z(T))}},children:[i("div",{children:[e(ss,{children:"Edit users in this group"}),e(po,{users:h,setUsers:m}),e(mo,{users:h,setUsers:m})]}),e(ls,{children:i(ds,{children:[e(H,{type:"submit",variant:"contained",color:"primary","data-testid":Zn,children:"Save"}),e(cs,{onClick:()=>{n(!1)},children:"Cancel"})]})})]})})})},us=({open:t,setOpen:n,user:a,group:o})=>{const{refetchGroup:r}=St(o.id),{updateGroup:s}=it(),{setToastData:c,setToastApiError:u}=X(),d=async()=>{try{const h={...o,users:o.users.filter(({id:m})=>m!==(a==null?void 0:a.id)).map(({id:m})=>({user:{id:m}}))};await s(o.id,h),r(),n(!1),c({title:"User removed from group successfully",type:"success"})}catch(h){u(Z(h))}},l=(a==null?void 0:a.name)||(a==null?void 0:a.username)||(a==null?void 0:a.email);return e(le,{open:t&&!!a,primaryButtonText:"Remove user",secondaryButtonText:"Cancel",onClick:d,onClose:()=>{n(!1)},title:"Remove user from group?",children:i(D,{children:["Do you really want to remove ",e("strong",{children:l})," from"," ",e("strong",{children:o.name}),"? ",e("strong",{children:l})," will lose all access rights granted by this group."]})})},hs=Array(15).fill({name:"Name of the user",username:"Username of the user"}),ps={id:"joinedAt"},{value:Sn,setValue:ms}=ua("Group:v1",ps),gs=()=>{const t=Number(zt("groupId")),n=_t(),a=Se(n.breakpoints.down("md")),{group:o,loading:r}=St(t),[s,c]=p.useState(!1),[u,d]=p.useState(!1),[l,h]=p.useState(!1),[m,S]=p.useState(),g=p.useMemo(()=>[{Header:"Avatar",accessor:"imageUrl",Cell:({row:{original:A}})=>e(ce,{children:e(qe,{user:A})}),maxWidth:85,disableSortBy:!0},{id:"name",Header:"Name",accessor:A=>A.name||"",Cell:pe,minWidth:100,searchable:!0},{id:"username",Header:"Username",accessor:A=>A.username||A.email,Cell:pe,minWidth:100,searchable:!0},{Header:"Joined",accessor:"joinedAt",Cell:xe,sortType:"date",maxWidth:150},{id:"createdBy",Header:"Added by",accessor:"createdBy",Cell:pe,minWidth:90,searchable:!0},{Header:"Last login",accessor:A=>A.seenAt||"",Cell:({row:{original:A}})=>e(Ye,{value:A.seenAt,emptyText:"Never",title:j=>`Last login: ${j}`}),sortType:"date",maxWidth:150},{Header:"Actions",id:"Actions",align:"center",Cell:({row:{original:A}})=>e(gt,{children:e(Ne,{title:"Remove user from group",arrow:!0,describeChild:!0,children:e("span",{children:e(_e,{"data-testid":`${ha}-${A.id}`,onClick:()=>{S(A),h(!0)},children:e($e,{})})})})}),maxWidth:100,disableSortBy:!0}],[S,h]),[f,v]=Qn(),[T]=p.useState(()=>({sortBy:[{id:f.get("sort")||Sn.id,desc:f.has("order")?f.get("order")==="desc":Sn.desc}],hiddenColumns:["description"],globalFilter:f.get("search")||""})),[C,w]=p.useState(T.globalFilter),{data:k,getSearchText:E,getSearchContext:I}=bt(g,C,(o==null?void 0:o.users)??[]),P=p.useMemo(()=>(k==null?void 0:k.length)===0&&r?hs:k,[k,r]),{headerGroups:B,rows:L,prepareRow:U,state:{sortBy:M}}=N.useTable({columns:g,data:P,initialState:T,sortTypes:ke,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},N.useSortBy,N.useFlexLayout);return p.useEffect(()=>{const A={};A.sort=M[0].id,M[0].desc&&(A.order="desc"),C&&(A.search=C),v(A,{replace:!0}),ms({id:M[0].id,desc:M[0].desc||!1})},[M,C,v]),e(x,{condition:!!o,show:i(O,{children:[e(is,{title:o==null?void 0:o.name,description:o==null?void 0:o.description,actions:i(O,{children:[e(Re,{"data-testid":pa,to:`/admin/groups/${t}/edit`,component:he,"data-loading":!0,permission:Y,tooltipProps:{title:"Edit group"},children:e(ot,{})}),e(Re,{"data-testid":ma,"data-loading":!0,onClick:()=>c(!0),permission:Y,tooltipProps:{title:"Delete group"},children:e($e,{})})]})}),i(ee,{isLoading:r,header:e(ne,{secondary:!0,title:`Users (${L.length<P.length?`${L.length} of ${P.length}`:P.length})`,actions:i(O,{children:[e(x,{condition:!a,show:i(O,{children:[e(fe,{initialValue:C,onChange:w,hasFilters:!0,getSearchContext:I}),e(ne.Divider,{})]})}),e(qt,{"data-testid":ga,onClick:()=>{d(!0)},maxWidth:"700px",Icon:yt,permission:Y,children:"Edit users"})]}),children:e(x,{condition:a,show:e(fe,{initialValue:C,onChange:w,hasFilters:!0,getSearchContext:I})})}),children:[e(Je,{value:E(C),children:e(Be,{rows:L,headerGroups:B,prepareRow:U})}),e(x,{condition:L.length===0,show:e(x,{condition:(C==null?void 0:C.length)>0,show:i(be,{children:["No users found matching “",C,"” in this group."]}),elseShow:e(be,{children:"This group is empty. Get started by adding a user to the group."})})}),e(fo,{open:s,setOpen:c,group:o}),e(yo,{open:u,setOpen:d,group:o}),e(us,{open:l,setOpen:h,user:m,group:o})]})]})})},fs=y(eo)(({theme:t})=>({pointerEvents:"none",".MuiPaper-root":{padding:t.spacing(2)}})),ys=y("div")(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(1)})),bs=({user:t,open:n,anchorEl:a,onPopoverClose:o})=>i(fs,{open:n,anchorEl:a,onClose:o,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},children:[e(ys,{children:(t==null?void 0:t.name)||(t==null?void 0:t.username)}),e("div",{children:t==null?void 0:t.email})]}),Ss=y("div")(({theme:t})=>({display:"inline-flex",alignItems:"center",flexWrap:"wrap",marginLeft:t.spacing(1)})),vn=y(qe)(({theme:t})=>({outline:`${t.spacing(.25)} solid ${t.palette.background.paper}`,marginLeft:t.spacing(-1),"&:hover":{outlineColor:t.palette.primary.main}})),vs=({users:t})=>{const n=p.useMemo(()=>t.sort((l,h)=>(h==null?void 0:h.joinedAt.getTime())-(l==null?void 0:l.joinedAt.getTime())).slice(0,9),[t]),[a,o]=p.useState(null),[r,s]=p.useState(),c=l=>{o(l.currentTarget)},u=()=>{o(null)},d=!!a;return i(Ss,{children:[n.map(l=>e(vn,{user:l,onMouseEnter:h=>{c(h),s(l)},onMouseLeave:u},l.id)),e(x,{condition:t.length>9,show:i(vn,{children:["+",t.length-n.length]})}),e(bs,{open:d,user:r,anchorEl:a,onPopoverClose:u})]})},Cs=y("div")(({theme:t})=>({display:"flex",justifyContent:"center",transform:"translate3d(8px, -6px, 0)"})),ws=y(eo)(({theme:t})=>({borderRadius:t.shape.borderRadiusLarge,padding:t.spacing(1,1.5)})),xs=({groupId:t,onEditUsers:n,onRemove:a})=>{const[o,r]=p.useState(null),s=!!o,c=h=>{r(h.currentTarget)},u=()=>{r(null)},d=`feature-${t}-actions`,l=`${d}-menu`;return i(Cs,{onClick:h=>{h.preventDefault(),h.stopPropagation()},children:[e(Ne,{title:"Group actions",arrow:!0,describeChild:!0,children:e(_e,{id:d,"aria-controls":s?l:void 0,"aria-haspopup":"true","aria-expanded":s?"true":void 0,onClick:c,type:"button",children:e(fa,{})})}),e(ws,{id:l,anchorEl:o,open:s,onClose:u,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,children:i(ya,{"aria-labelledby":d,children:[i(Ee,{onClick:u,component:he,to:`/admin/groups/${t}/edit`,children:[e(At,{children:e(ot,{})}),e(Dt,{children:e(D,{variant:"body2",children:"Edit group"})})]}),i(Ee,{onClick:()=>{n(),u()},children:[e(At,{children:e(Bi,{})}),e(Dt,{children:e(D,{variant:"body2",children:"Edit group users"})})]}),i(Ee,{onClick:()=>{a(),u()},children:[e(At,{children:e($e,{})}),e(Dt,{children:e(D,{variant:"body2",children:"Delete group"})})]})]})})]})},Ts=y(he)(({theme:t})=>({textDecoration:"none",color:t.palette.text.primary})),ks=y("aside")(({theme:t})=>({padding:t.spacing(2.5),height:"100%",border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadiusLarge,boxShadow:t.boxShadows.card,display:"flex",flexDirection:"column",[t.breakpoints.up("md")]:{padding:t.spacing(4)},"&:hover":{transition:"background-color 0.2s ease-in-out",backgroundColor:t.palette.neutral.light}})),bo=y("div")(()=>({display:"flex",alignItems:"center",justifyContent:"space-between"})),Es=y(bo)(()=>({alignItems:"flex-start"})),Rs=y(bo)(()=>({marginTop:"auto"})),As=y("h2")(({theme:t})=>({fontSize:t.fontSizes.mainHeader,fontWeight:t.fontWeight.medium})),Ds=y("div")(({theme:t})=>({display:"flex",alignItems:"center",color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody})),Ps=y("p")(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(1),marginBottom:t.spacing(4)})),Is=y("span")(({theme:t})=>({color:t.palette.text.secondary,marginLeft:t.spacing(1)})),Bs=y("div")(({theme:t})=>({maxWidth:"50%",display:"flex",justifyContent:"flex-end",gap:t.spacing(.5),flexWrap:"wrap"})),Ls=y("span")(({theme:t})=>({display:"flex",color:t.palette.text.secondary,alignItems:"center",gap:t.spacing(1),fontSize:t.fontSizes.smallBody})),Os=({group:t,onEditUsers:n,onRemoveGroup:a})=>{var r;const o=Ce();return e(O,{children:e(Ts,{to:`/admin/groups/${t.id}`,children:i(ks,{children:[i(Es,{children:[e(As,{children:t.name}),e(Ds,{children:e(xs,{groupId:t.id,onEditUsers:()=>n(t),onRemove:()=>a(t)})})]}),e(x,{condition:!!t.rootRole,show:i(Ls,{children:[e("p",{children:"Root role:"}),e(ba,{roleId:t.rootRole})]})}),e(Ps,{children:t.description}),i(Rs,{children:[e(x,{condition:((r=t.users)==null?void 0:r.length)>0,show:e(vs,{users:t.users}),elseShow:e(Is,{children:"This group has no users."})}),e(Bs,{children:e(x,{condition:t.projects.length>0,show:t.projects.map(s=>e(Ne,{title:"View project",arrow:!0,placement:"bottom-end",describeChild:!0,children:e(ut,{onClick:c=>{c.preventDefault(),o(`/projects/${s}/settings/access`)},color:"secondary",icon:e(Sa,{}),children:s})},s)),elseShow:e(Ne,{title:"This group is not used in any project",arrow:!0,describeChild:!0,children:e(x,{condition:!t.rootRole,show:e(ut,{children:"Not used"})})})})})]})]})},t.id)})},Us=()=>{const t=y("div")(({theme:a})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:a.spacing(6),marginLeft:"auto",marginRight:"auto"})),n=y(D)(({theme:a})=>({fontSize:a.fontSizes.bodySize,marginBottom:a.spacing(2.5)}));return i(t,{children:[e(n,{children:"No groups available. Get started by adding a new group."}),e(H,{to:"/admin/groups/create-group",component:he,variant:"outlined",color:"primary",children:"Create your first group"})]})},Ns=(t,n)=>{var r,s,c,u,d,l;const a=n.toLowerCase(),o={names:(r=t.users)==null?void 0:r.map(h=>{var m;return((m=h.name)==null?void 0:m.toLowerCase())||""}),usernames:(s=t.users)==null?void 0:s.map(h=>{var m;return((m=h.username)==null?void 0:m.toLowerCase())||""}),emails:(c=t.users)==null?void 0:c.map(h=>{var m;return((m=h.email)==null?void 0:m.toLowerCase())||""})};return t.name.toLowerCase().includes(a)||t.description.toLowerCase().includes(a)||((u=o.names)==null?void 0:u.some(h=>h.includes(a)))||((d=o.usernames)==null?void 0:d.some(h=>h.includes(a)))||((l=o.emails)==null?void 0:l.some(h=>h.includes(a)))},$s=()=>{const t=Ce(),[n,a]=p.useState(!1),[o,r]=p.useState(!1),[s,c]=p.useState(void 0),{groups:u=[],loading:d}=He(),[l,h]=Qn(),[m,S]=p.useState(l.get("search")||""),g=Se(De.breakpoints.down("md"));p.useEffect(()=>{const C={};m&&(C.search=m),h(C,{replace:!0})},[m,h]);const f=p.useMemo(()=>{const C=u.sort((w,k)=>w.name.localeCompare(k.name));return m?C.filter(w=>Ns(w,m)):C},[u,m]),v=C=>{c(C),a(!0)},T=C=>{c(C),r(!0)};return i(ee,{isLoading:d,header:e(ne,{title:`Groups (${f.length})`,actions:i(O,{children:[e(x,{condition:!g,show:i(O,{children:[e(fe,{initialValue:m,onChange:S}),e(ne.Divider,{})]})}),e(qt,{onClick:()=>t("/admin/groups/create-group"),maxWidth:"700px",Icon:yt,permission:Y,"data-testid":va,children:"New group"})]}),children:e(x,{condition:g,show:e(fe,{initialValue:m,onChange:S})})}),children:[e(Je,{value:m,children:e(b,{container:!0,spacing:2,children:f.map(C=>e(b,{item:!0,xs:12,md:6,children:e(Os,{group:C,onEditUsers:v,onRemoveGroup:T})},C.id))})}),e(x,{condition:!d&&f.length===0,show:e(x,{condition:(m==null?void 0:m.length)>0,show:i(be,{children:["No groups found matching “",m,"”"]}),elseShow:e(Us,{})})}),e(x,{condition:!!s,show:e(yo,{open:n,setOpen:a,group:s})}),e(x,{condition:!!s,show:e(fo,{open:o,setOpen:r,group:s})})]})},Gs=()=>e("div",{children:e(Te,{permissions:ze,children:e($s,{})})}),Ms=()=>{const{data:t,error:n,mutate:a}=Pe(te("api/admin/instance-admin/statistics"),Fs);return p.useMemo(()=>({stats:t,loading:!n&&!t,refetchGroup:()=>a(),error:n}),[t,n,a])},Fs=t=>fetch(t).then(ve("Instance Stats")).then(n=>n.json()),js=()=>{const{stats:t}=Ms();let n,a;t!=null&&t.versionEnterprise?(n="Unleash Enterprise version",a=t.versionEnterprise):(n="Unleash OSS version",a=t==null?void 0:t.versionOSS);const o=[{title:"Instance Id",value:t==null?void 0:t.instanceId},{title:n,value:a},{title:"Users",value:t==null?void 0:t.users},{title:"Feature toggles",value:t==null?void 0:t.featureToggles},{title:"Projects",value:t==null?void 0:t.projects},{title:"Environments",value:t==null?void 0:t.environments},{title:"Roles",value:t==null?void 0:t.roles},{title:"Groups",value:t==null?void 0:t.groups},{title:"Context fields",value:t==null?void 0:t.contextFields},{title:"Strategies",value:t==null?void 0:t.strategies},{title:"Feature exports",value:t==null?void 0:t.featureExports},{title:"Feature imports",value:t==null?void 0:t.featureImports}];return t!=null&&t.versionEnterprise&&o.push({title:"SAML enabled",value:t!=null&&t.SAMLenabled?"Yes":"No"},{title:"OIDC enabled",value:t!=null&&t.OIDCenabled?"Yes":"No"}),e(ee,{header:e(ne,{title:"Instance Statistics"}),children:i(Ci,{sx:{display:"grid",gap:4},children:[i(Wn,{"aria-label":"Instance statistics",children:[e(Hn,{children:i(et,{children:[e(se,{children:"Field"}),e(se,{align:"right",children:"Value"})]})}),e(Ft,{children:o.map(r=>i(et,{children:[e(se,{component:"th",scope:"row",children:r.title}),e(se,{align:"right",children:r.value})]},r.title))})]}),e("span",{style:{textAlign:"center"},children:e(H,{startIcon:e(Ca,{}),"aria-label":"Download instance statistics",color:"primary",variant:"contained",target:"_blank",rel:"noreferrer",href:te("/api/admin/instance-admin/statistics/csv"),children:"Download"})})]})})},zs=()=>e("div",{children:e(js,{})}),Ws=()=>e(K,{severity:"warning",children:i("p",{children:[e("b",{children:"Heads up!"})," If you enable maintenance mode, edit access in the entire system will be disabled for all the users (admins, editors, custom roles, etc). During this time nobody will be able to do changes or to make new configurations."]})}),Hs=()=>{const{data:t,error:n,mutate:a}=Pe(te("api/admin/maintenance"),_s);return p.useMemo(()=>({enabled:!!(t!=null&&t.enabled),loading:!n&&!t,refetchMaintenance:a,error:n}),[t,n,a])},_s=t=>fetch(t).then(ve("Maintenance")).then(n=>n.json()),qs=()=>{const{makeRequest:t,createRequest:n,errors:a,loading:o}=Ge({propagateErrors:!0});return{toggleMaintenance:async s=>{const u=n("api/admin/maintenance",{method:"POST",body:JSON.stringify(s)});try{await t(u.caller,u.id)}catch(d){throw d}},errors:a,loading:o}},Vs=y("div")(({theme:t})=>({display:"flex",flexDirection:"column",padding:t.spacing(3),border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadiusLarge})),Ys=y(z)(({theme:t})=>({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"})),Js=y(z)(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(2)})),Ks=y(D)(({theme:t})=>({fontSize:t.fontSizes.smallBody})),Zs=()=>{const{enabled:t,refetchMaintenance:n}=Hs(),{toggleMaintenance:a}=qs(),{trackEvent:o}=Vt(),{setToastData:r}=X();return i(Vs,{children:[i(Ys,{children:[e("b",{children:"Maintenance Mode"}),e(ye,{sx:{margin:0},control:e(we,{onChange:async()=>{r({type:"success",title:`Maintenance mode has been successfully ${t?"disabled":"enabled"}`}),o("maintenance",{props:{eventType:`maintenance ${t?"de":""}activated`}}),await a({enabled:!t}),n()},value:t,name:"enabled",checked:t}),label:e(Ks,{children:t?"Enabled":"Disabled"})})]}),e(Js,{children:"Maintenance Mode is useful when you want to freeze your system so nobody can do any changes during this time. When enabled it will show a banner at the top of the applications and only an admin can enable it or disable it."})]})},Xs=()=>e("div",{children:e(Te,{permissions:Y,children:e(el,{})})}),Qs=y(z)(({theme:t})=>({display:"grid",gap:t.spacing(4)})),el=()=>{const{loading:t}=W();return t?null:e(ee,{header:e(ne,{title:"Maintenance"}),children:i(Qs,{children:[e(Ws,{}),e(Zs,{})]})})},tl=t=>{const n={display:"flex",justifyContent:"center",alignItems:"center",width:"100%",textDecoration:"none",color:"inherit",padding:t.theme.spacing(1.5,3)},a={fontWeight:"bold",borderRadius:"3px",padding:t.theme.spacing(1.5,3)};return t.isActive?{...n,...a}:n},ue=({to:t,children:n})=>{const a=_t();return e(wa,{to:t,style:({isActive:o})=>tl({isActive:o,theme:a}),children:n})},nl=y(Xn)(({theme:t})=>({marginBottom:"1rem",borderRadius:"12.5px",boxShadow:"none",padding:"0 2rem"}));function ol(){const{uiConfig:t,isEnterprise:n}=W(),{pathname:a}=Yt(),{isBilling:o}=jt(),{flags:r,networkViewEnabled:s}=t,c=a.split("/")[2];return e(nl,{children:i(Jt,{value:c,variant:"scrollable",scrollButtons:"auto",allowScrollButtonsMobile:!0,children:[e(de,{value:"users",label:e(ue,{to:"/admin/users",children:e("span",{children:"Users"})})}),n()&&e(de,{value:"service-accounts",label:e(ue,{to:"/admin/service-accounts",children:e("span",{children:"Service accounts"})})}),r.UG&&e(de,{value:"groups",label:e(ue,{to:"/admin/groups",children:e("span",{children:"Groups"})})}),n()&&e(de,{value:"roles",label:e(ue,{to:"/admin/roles",children:e("span",{children:"Roles"})})}),e(de,{value:"api",label:e(ue,{to:"/admin/api",children:"API access"})}),t.flags.embedProxyFrontend&&e(de,{value:"cors",label:e(ue,{to:"/admin/cors",children:"CORS origins"})}),e(de,{value:"auth",label:e(ue,{to:"/admin/auth",children:"Single sign-on"})}),e(de,{value:"instance",label:e(ue,{to:"/admin/instance",children:"Instance stats"})}),s&&e(de,{value:"network",label:e(ue,{to:"/admin/network",children:"Network"})}),e(de,{value:"maintenance",label:e(ue,{to:"/admin/maintenance",children:"Maintenance"})}),o&&e(de,{value:"billing",label:e(ue,{to:"/admin/billing",children:"Billing"})})]})})}const al=p.lazy(()=>import("./NetworkOverview-b82ebe0c.js").then(t=>t.N)),il=p.lazy(()=>import("./NetworkTraffic-51a825ea.js")),rl=y(ee)(()=>({".page-header":{padding:0}})),sl=[{label:"Overview",path:"/admin/network"},{label:"Traffic",path:"/admin/network/traffic"}],ll=()=>{const{pathname:t}=Yt();return e("div",{children:e(rl,{headerClass:"page-header",header:e(Jt,{value:t,indicatorColor:"primary",textColor:"primary",variant:"scrollable",allowScrollButtonsMobile:!0,children:sl.map(({label:n,path:a})=>e(de,{value:a,label:e(ue,{to:a,children:e("span",{children:n})})},n))}),children:i(Kt,{children:[e(V,{path:"traffic",element:e(il,{})}),e(V,{path:"*",element:e(al,{})})]})})})},cl=y(z)(()=>({display:"flex",justifyContent:"center"})),dl=({role:t,onEdit:n,onDelete:a})=>{const o=We.includes(t.type);return i(cl,{children:[e(Re,{"data-loading":!0,onClick:n,permission:Y,disabled:o,tooltipProps:{title:o?"You cannot edit a predefined role":"Edit role"},children:e(ot,{})}),e(Re,{"data-loading":!0,onClick:a,permission:Y,disabled:o,tooltipProps:{title:o?"You cannot remove a predefined role":"Remove role"},children:e($e,{})})]})},ul=y(ut)(({theme:t})=>({marginLeft:t.spacing(1)})),hl=({role:t})=>e(pe,{value:t.name,subtitle:t.description,afterTitle:e(x,{condition:We.includes(t.type),show:e(ul,{color:"success",children:"Predefined"})})}),pl=({users:t})=>{const[n]=p.useState(()=>({sortBy:[{id:"last-login"}]})),a=p.useMemo(()=>[{id:"name",Header:"Name",accessor:c=>c.name||"",minWidth:200,Cell:({row:{original:c}})=>e(pe,{value:c.name,subtitle:c.email||c.username})},{Header:"Created",accessor:"createdAt",Cell:xe,sortType:"date",width:120,maxWidth:120},{id:"last-login",Header:"Last login",accessor:c=>c.seenAt||"",Cell:({row:{original:c}})=>e(Ye,{value:c.seenAt,emptyText:"Never",title:u=>`Last login: ${u}`}),sortType:"date",maxWidth:150}],[]),{headerGroups:o,rows:r,prepareRow:s}=N.useTable({columns:a,data:t,initialState:n,sortTypes:ke,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},N.useSortBy,N.useFlexLayout);return e(Be,{rows:r,headerGroups:o,prepareRow:s})},ml=y(D)(({theme:t})=>({fontSize:t.fontSizes.smallerBody})),So=({serviceAccount:t,value:n,onCreateToken:a})=>{var r,s,c;const{searchQuery:o}=xa();return!t.tokens||t.tokens.length===0?a?e(Ta,{title:"Create token",onClick:a}):e(ce,{children:"0 tokens"}):e(ce,{children:e(to,{tooltip:e(O,{children:(r=t.tokens)==null?void 0:r.map(({id:u,description:d})=>e(ml,{children:e(ka,{search:o,children:d})},u))}),highlighted:o.length>0&&n.toLowerCase().includes(o.toLowerCase()),children:((s=t.tokens)==null?void 0:s.length)===1?"1 token":`${(c=t.tokens)==null?void 0:c.length} tokens`})})},gl=({serviceAccounts:t})=>{const[n]=p.useState(()=>({sortBy:[{id:"seenAt"}]})),a=p.useMemo(()=>[{id:"name",Header:"Name",accessor:c=>c.name||"",minWidth:200,Cell:({row:{original:c}})=>e(pe,{value:c.name,subtitle:c.username})},{id:"tokens",Header:"Tokens",accessor:c=>{var u;return((u=c.tokens)==null?void 0:u.map(({description:d})=>d).join(`
|
|
16
16
|
`))||""},Cell:({row:{original:c},value:u})=>e(So,{serviceAccount:c,value:u}),maxWidth:100},{Header:"Created",accessor:"createdAt",Cell:xe,sortType:"date",width:120,maxWidth:120},{id:"seenAt",Header:"Last seen",accessor:c=>{var u;return(u=c.tokens.sort((d,l)=>{const h=new Date(d.seenAt||0),m=new Date(l.seenAt||0);return(m==null?void 0:m.getTime())-(h==null?void 0:h.getTime())})[0])==null?void 0:u.seenAt},Cell:Ye,sortType:"date",maxWidth:150}],[]),{headerGroups:o,rows:r,prepareRow:s}=N.useTable({columns:a,data:t,initialState:n,sortTypes:ke,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},N.useSortBy,N.useFlexLayout);return e(Be,{rows:r,headerGroups:o,prepareRow:s})},fl=({groups:t})=>{const[n]=p.useState(()=>({sortBy:[{id:"createdAt"}]})),a=p.useMemo(()=>[{id:"name",Header:"Name",accessor:c=>c.name||"",minWidth:200,Cell:({row:{original:c}})=>e(pe,{value:c.name,subtitle:c.description})},{Header:"Created",accessor:"createdAt",Cell:xe,sortType:"date",width:120,maxWidth:120},{id:"users",Header:"Users",accessor:c=>c.users.length===1?"1 user":`${c.users.length} users`,Cell:ce,maxWidth:150}],[]),{headerGroups:o,rows:r,prepareRow:s}=N.useTable({columns:a,data:t,initialState:n,sortTypes:ke,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},N.useSortBy,N.useFlexLayout);return e(Be,{rows:r,headerGroups:o,prepareRow:s})},Lt=y("div")(({theme:t})=>({marginTop:t.spacing(1.5)})),Ot=y("p")(({theme:t})=>({marginTop:t.spacing(3)})),yl=({role:t,open:n,setOpen:a,onConfirm:o})=>{const{users:r}=Le(),{serviceAccounts:s}=at(),{groups:c}=He(),u=r.filter(({rootRole:m})=>m===(t==null?void 0:t.id)),d=s.filter(({rootRole:m})=>m===(t==null?void 0:t.id)),l=c==null?void 0:c.filter(({rootRole:m})=>m===(t==null?void 0:t.id)),h=!!(u.length||d.length||l!=null&&l.length);return e(le,{title:"Delete role?",open:n,primaryButtonText:"Delete role",secondaryButtonText:"Cancel",disabledPrimaryButton:h,onClick:()=>o(t),onClose:()=>{a(!1)},children:e(x,{condition:h,show:i(O,{children:[e(K,{severity:"error",children:"You are not allowed to delete a role that is currently in use. Please change the role of the following entities first:"}),e(x,{condition:!!u.length,show:i(O,{children:[i(Ot,{children:["Users (",u.length,"):"]}),e(Lt,{children:e(pl,{users:u})})]})}),e(x,{condition:!!d.length,show:i(O,{children:[i(Ot,{children:["Service accounts (",d.length,"):"]}),e(Lt,{children:e(gl,{serviceAccounts:d})})]})}),e(x,{condition:!!(l!=null&&l.length),show:i(O,{children:[i(Ot,{children:["Groups (",l==null?void 0:l.length,"):"]}),e(Lt,{children:e(fl,{groups:l})})]})})]}),elseShow:i("p",{children:["You are about to delete role:"," ",e("strong",{children:t==null?void 0:t.name})]})})})},vo=()=>{const{loading:t,makeRequest:n,createRequest:a,errors:o}=Ge({propagateErrors:!0});return{addRole:async d=>{const l="addRole",h=a("api/admin/roles",{method:"POST",body:JSON.stringify(d)},l);return await(await n(h.caller,h.id)).json()},updateRole:async(d,l)=>{const h="updateRole",m=a(`api/admin/roles/${d}`,{method:"PUT",body:JSON.stringify(l)},h);await n(m.caller,m.id)},removeRole:async d=>{const l="removeRole",h=a(`api/admin/roles/${d}`,{method:"DELETE"},l);await n(h.caller,h.id)},validateRole:async d=>{const l="validateRole",h=a("api/admin/roles/validate",{method:"POST",body:JSON.stringify(d)},l);await n(h.caller,h.id)},errors:o,loading:t}};var Co=(t=>(t.NAME="name",t))(Co||{});const bl=(t="",n="",a=[])=>{const{roles:o}=Ke(),[r,s]=p.useState(t),[c,u]=p.useState(n),[d,l]=p.useState({}),[h,m]=p.useState({});return p.useEffect(()=>{s(t)},[t]),p.useEffect(()=>{u(n)},[n]),p.useEffect(()=>{const w=Ea(a);l(w)},[a.length]),{name:r,description:c,checkedPermissions:d,errors:h,setName:s,setDescription:u,setCheckedPermissions:l,getRolePayload:(w=me)=>({name:r,description:c,type:w===me?"root-custom":"custom",permissions:Object.values(d)}),clearError:w=>{m(k=>({...k,[w]:void 0}))},setError:(w,k)=>{m(E=>({...E,[w]:k}))},isNameUnique:w=>!o.some(k=>k.name!==t&&k.name.toLowerCase()===w.toLowerCase()),isNotEmpty:w=>w.length,hasPermissions:w=>Object.keys(w).length>0,ErrorField:Co}},Sl=y(z)(({theme:t})=>({display:"flex",alignItems:"center",[t.breakpoints.down(500)]:{flexDirection:"column",alignItems:"flex-start"}})),vl=y(Ra)(({theme:t})=>({fontWeight:t.typography.fontWeightBold,marginRight:t.spacing(1)})),Cl=({title:t,permissions:n,checkedPermissions:a,Icon:o,isInitiallyExpanded:r=!1,context:s,onPermissionChange:c,onCheckAll:u})=>{const[d,l]=p.useState(r),h=p.useMemo(()=>(n==null?void 0:n.reduce((g,f)=>(g[rt(f)]=!0,g),{}))||{},[n]),m=p.useMemo(()=>Object.keys(a).filter(g=>h[g]).length||0,[a,h]),S=p.useMemo(()=>m===(n==null?void 0:n.length),[m,n]);return e(z,{sx:{my:2,pb:1},children:i(Aa,{expanded:d,onChange:()=>l(!d),sx:{boxShadow:"none",px:3,py:1,border:g=>`1px solid ${g.palette.divider}`,borderRadius:g=>`${g.shape.borderRadiusLarge}px`},children:[e(Da,{expandIcon:e(_e,{children:e(Pa,{titleAccess:"Toggle"})}),sx:{boxShadow:"none",padding:"0"},children:i(Sl,{children:[o,e(vl,{text:t,maxWidth:"120",maxLength:25})," ",i(D,{variant:"body2",color:"text.secondary",children:["(",m," / ",n==null?void 0:n.length," ","permissions)"]})]})}),i(Ia,{sx:{px:0,py:1,flexWrap:"wrap"},children:[e(Mt,{sx:{mb:1}}),i(H,{variant:"text",size:"small",onClick:u,sx:{fontWeight:g=>g.typography.fontWeightRegular},children:[S?"Unselect ":"Select ","all ",s," permissions"]}),e(z,{children:n==null?void 0:n.map(g=>e(ye,{sx:{minWidth:{sm:"300px",xs:"auto"}},"data-testid":rt(g),control:e(Yn,{checked:!!a[rt(g)],onChange:()=>c(g),color:"primary"}),label:g.displayName},rt(g)))})]})]})})},Ut=y("p")(({theme:t})=>({display:"flex",color:t.palette.text.primary,marginBottom:t.spacing(1),"&:not(:first-of-type)":{marginTop:t.spacing(4)}})),Cn=y(nt)(({theme:t})=>({width:"100%",maxWidth:t.spacing(50)})),wl=({type:t=me,name:n,onSetName:a,description:o,setDescription:r,checkedPermissions:s,setCheckedPermissions:c,errors:u})=>{const{permissions:d}=Ba({revalidateIfStale:!1,revalidateOnReconnect:!1,revalidateOnFocus:!1}),h=Jn.includes(t)?La(Oa(d.project,d.environments)):Ua(d.root),m=g=>{const f=Fa(s,g);c(f)},S=g=>{const f=ja(s,g);c(f)};return i("div",{children:[e(Ut,{children:"What is your new role name?"}),e(Cn,{autoFocus:!0,label:"Role name",error:!!u.name,errorText:u.name,value:n,onChange:g=>a(g.target.value),autoComplete:"off",required:!0}),e(Ut,{children:"What is your new role description?"}),e(Cn,{label:"Role description",value:o,onChange:g=>r(g.target.value),autoComplete:"off",required:!0}),e(Ut,{children:"What is your role allowed to do?"}),h.map(({label:g,type:f,permissions:v})=>e(Cl,{title:`${g} permissions`,context:g.toLowerCase(),Icon:f===Na?e(Oi,{color:"disabled",sx:{mr:1}}):f===$a?e(Ga,{color:"disabled",sx:{mr:1}}):e(Ma,{color:"disabled",sx:{mr:1}}),permissions:v,checkedPermissions:s,onPermissionChange:T=>m(T),onCheckAll:()=>S(v)},g))]})},xl=y("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),Tl=y("div")(({theme:t})=>({marginTop:"auto",display:"flex",justifyContent:"flex-end",paddingTop:t.spacing(4)})),kl=y(H)(({theme:t})=>({marginLeft:t.spacing(3)})),El=({type:t=me,roleId:n,open:a,setOpen:o})=>{const{role:r,refetch:s}=no(n==null?void 0:n.toString()),{name:c,setName:u,description:d,setDescription:l,checkedPermissions:h,setCheckedPermissions:m,getRolePayload:S,isNameUnique:g,isNotEmpty:f,hasPermissions:v,errors:T,setError:C,clearError:w,ErrorField:k}=bl(r==null?void 0:r.name,r==null?void 0:r.description,r==null?void 0:r.permissions),{refetch:E}=Ke(),{addRole:I,updateRole:P,loading:B}=vo(),{setToastData:L,setToastApiError:U}=X(),{uiConfig:M}=W(),A=r!==void 0,j=g(c)&&f(c)&&f(d)&&v(h),J=S(t),R=()=>`curl --location --request ${A?"PUT":"POST"} '${M.unleashUrl}/api/admin/roles${A?`/${r.id}`:""}' \\
|
|
17
17
|
--header 'Authorization: INSERT_API_KEY' \\
|
|
18
18
|
--header 'Content-Type: application/json' \\
|