unleash-server 4.20.3 → 4.20.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/{CreateProject-f5c561c6.js → CreateProject-29a2b285.js} +1 -1
- package/frontend/build/static/{Error-cf50f470.js → Error-934cc570.js} +1 -1
- package/frontend/build/static/{ExpandMore-fa515e9b.js → ExpandMore-c3e13d73.js} +1 -1
- package/frontend/build/static/{FeatureArchiveDialog-9726aebb.js → FeatureArchiveDialog-b5fc8177.js} +1 -1
- package/frontend/build/static/{FeatureMetricsChart-2099cc8f.js → FeatureMetricsChart-13ce1b57.js} +1 -1
- package/frontend/build/static/{FeatureViewLazyExport-251c75f0.js → FeatureViewLazyExport-1bee3351.js} +2 -2
- package/frontend/build/static/{LazyAdminExport-110237f4.js → LazyAdminExport-2f5a25ac.js} +2 -2
- package/frontend/build/static/{LazyProjectExport-22be702f.js → LazyProjectExport-dc65603b.js} +1 -1
- package/frontend/build/static/{NetworkOverview-fa11486d.js → NetworkOverview-8018cd89.js} +45 -45
- package/frontend/build/static/{NetworkTraffic-e401fa21.js → NetworkTraffic-84935c51.js} +1 -1
- package/frontend/build/static/{Playground-d443ad89.js → Playground-6d2eacce.js} +1 -1
- package/frontend/build/static/{StrategyItemContainer-6834f121.js → StrategyItemContainer-93cba46f.js} +1 -1
- package/frontend/build/static/{chartjs-adapter-date-fns.esm-25ba860d.js → chartjs-adapter-date-fns.esm-38d041f7.js} +1 -1
- package/frontend/build/static/{index-ad851f89.js → index-3132dba8.js} +1 -1
- package/frontend/build/static/{index-3efe35ce.js → index-66dec49c.js} +1 -1
- package/frontend/build/static/{index-a09b079f.js → index-c290f941.js} +2 -2
- package/frontend/build/static/{unknownify-a62439db.js → unknownify-86fd295b.js} +1 -1
- package/frontend/build/static/{useProjectRole-6f60c011.js → useProjectRole-b5b140d2.js} +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{s as g,r as d,aB as wo,cI as xo,_ as ko,j as e,$ as An,cJ as on,cK as Rt,cL as To,cM as Ao,cN as Eo,cO as Po,c as ze,cP as En,cQ as Ge,cR as $t,aJ as se,a_ as xe,aK as ke,H as q,f as r,A as W,ar as ae,cS as Ft,bN as bt,cT as Do,cU as Ro,a2 as Y,be as Se,m as Re,ct as Io,cV as Uo,aN as de,cW as Pn,F as z,C as x,cX as Lo,b2 as Pe,aP as oe,aX as De,c8 as Dn,l as fe,c9 as pt,N as be,c0 as Be,d as _,e as Ne,U as Ze,ak as Q,al as ne,V as ve,a as O,X as Me,c1 as zt,S as Mt,h as nt,i as je,k as Ht,W as ce,I as Rn,R as ge,ce as Fe,cY as ot,cb as St,cZ as Bo,c_ as He,bK as We,bJ as In,a9 as M,aj as Un,ae as No,bI as Ln,a5 as Ye,c$ as ft,bY as ie,d0 as tt,T as R,d1 as Oo,d2 as $o,bU as Wt,d3 as Bn,bP as Nn,au as Te,aw as _t,d4 as j,d5 as qt,a4 as V,ay as Ce,bs as b,d6 as we,a6 as Go,a7 as jo,a8 as Ve,ac as Z,Z as _e,aI as vt,d7 as Fo,af as Vt,d8 as On,a1 as zo,d9 as Mo,da as st,B as Gt,db as Ho,g as $n,dc as Wo,dd as Yt,bF as Gn,de as _o,df as jn,c2 as re,bG as Fn,dg as qo,cg as an,dh as Jt,aH as Vo,ad as Yo,di as Jo,dj as It,cd as zn,dk as Ko,dl as Zo,dm as qe,Y as at,w as Xo,dn as Qo,dp as ea,bE as ta,dq as na,dr as oa,ds as aa,aE as Ct,dt as Kt,du as Mn,ah as Hn,bS as Wn,K as ra,u as Zt,dv as ia,L as _n,Q as Xt,aW as Ee,dw as sa,aY as rt,dx as la,dy as ca,P as qn,dz as da,bi as Ut,bk as Lt,dA as ua,dB as ha,bO as Qt,dC as pa,cq as Vn,cv as Yn,co as he,bQ as Jn,bR as J,x as ma,bv as ga,bw as fa,bx as ya,c6 as ba,dD as Sa,b$ as Bt,dE as Kn,dF as yt,dG as Zn,dH as va,dI as Xn,dJ as Ca,O as wa,ca as xa,dK as ka,dL as Ta,dM as Aa,dN as Ea,dO as Pa,dP as Da,b3 as Ra,bV as Ia,dQ as Ua,dR as La,bL as Ba,dS as rn,M as Qn,bj as Na,bH as Nt,dT as Oa}from"./index-a09b079f.js";import{m as $a,u as wt,B as Ga,a as sn}from"./useProjectRole-6f60c011.js";import{E as ja}from"./ExpandMore-fa515e9b.js";import{a as Fa}from"./index-ad851f89.js";import{a as za}from"./index-3efe35ce.js";const Ma=["component","direction","spacing","divider","children"];function Ha(t,n){const o=d.Children.toArray(t).filter(Boolean);return o.reduce((a,i,s)=>(a.push(i),s<o.length-1&&a.push(d.cloneElement(n,{key:`separator-${s}`})),a),[])}const Wa=t=>({row:"Left","row-reverse":"Right",column:"Top","column-reverse":"Bottom"})[t],_a=({ownerState:t,theme:n})=>{let o=An({display:"flex",flexDirection:"column"},on({theme:n},Rt({values:t.direction,breakpoints:n.breakpoints.values}),a=>({flexDirection:a})));if(t.spacing){const a=To(n),i=Object.keys(n.breakpoints.values).reduce((l,c)=>((typeof t.spacing=="object"&&t.spacing[c]!=null||typeof t.direction=="object"&&t.direction[c]!=null)&&(l[c]=!0),l),{}),s=Rt({values:t.direction,base:i}),u=Rt({values:t.spacing,base:i});typeof s=="object"&&Object.keys(s).forEach((l,c,p)=>{if(!s[l]){const y=c>0?s[p[c-1]]:"column";s[l]=y}}),o=Ao(o,on({theme:n},u,(l,c)=>({"& > :not(style) + :not(style)":{margin:0,[`margin${Wa(c?s[c]:t.direction)}`]:Po(a,l)}})))}return o=Eo(n.breakpoints,o),o},qa=g("div",{name:"MuiStack",slot:"Root",overridesResolver:(t,n)=>[n.root]})(_a),Va=d.forwardRef(function(n,o){const a=wo({props:n,name:"MuiStack"}),i=xo(a),{component:s="div",direction:u="column",spacing:h=0,divider:l,children:c}=i,p=ko(i,Ma);return e(qa,An({as:s,ownerState:{direction:u,spacing:h},ref:o},p,{children:l?Ha(c,l):c}))}),Ya=Va,Ja=ze(e("path",{d:"M5 20h14v-2H5v2zM19 9h-4V3H9v6H5l7 7 7-7z"}),"Download"),Ka=ze(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"),Za=ze(e("path",{d:"M21 10h-8.35C11.83 7.67 9.61 6 7 6c-3.31 0-6 2.69-6 6s2.69 6 6 6c2.61 0 4.83-1.67 5.65-4H13l2 2 2-2 2 2 4-4.04L21 10zM7 15c-1.65 0-3-1.35-3-3s1.35-3 3-3 3 1.35 3 3-1.35 3-3 3z"}),"Key"),Xa=ze(e("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1.41 16.09V20h-2.67v-1.93c-1.71-.36-3.16-1.46-3.27-3.4h1.96c.1 1.05.82 1.87 2.65 1.87 1.96 0 2.4-.98 2.4-1.59 0-.83-.44-1.61-2.67-2.14-2.48-.6-4.18-1.62-4.18-3.67 0-1.72 1.39-2.84 3.11-3.21V4h2.67v1.95c1.86.45 2.79 1.86 2.85 3.39H14.3c-.05-1.11-.64-1.87-2.22-1.87-1.5 0-2.4.68-2.4 1.64 0 .84.65 1.39 2.67 1.91s4.18 1.39 4.18 3.91c-.01 1.83-1.38 2.83-3.12 3.16z"}),"MonetizationOn"),Qa=ze(e("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"}),"MoreVert"),er=ze(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"),tr=ze(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 mt(t){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?mt=function(o){return typeof o}:mt=function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},mt(t)}function gt(t,n){if(En(2,arguments),!n||mt(n)!=="object")return new Date(NaN);var o=n.years?Ge(n.years):0,a=n.months?Ge(n.months):0,i=n.weeks?Ge(n.weeks):0,s=n.days?Ge(n.days):0,u=n.hours?Ge(n.hours):0,h=n.minutes?Ge(n.minutes):0,l=n.seconds?Ge(n.seconds):0,c=$t(t),p=a||o?za(c,a+o*12):c,m=s||i?Fa(p,s+i*7):p,y=h+u*60,S=l+y*60,f=S*1e3,C=new Date(m.getTime()+f);return C}function ln(t,n){En(2,arguments);var o=$t(t),a=$t(n);return o.getTime()>a.getTime()}const eo=(t={})=>{const n=se("api/admin/api-tokens"),{data:o,error:a,mutate:i}=xe(n,nr,t),s=d.useMemo(()=>o??[],[o]),u=d.useCallback(()=>{i().catch(console.warn)},[i]);return{tokens:s,error:a,loading:!a&&!o,refetch:u}},nr=async t=>(await(await fetch(t).then(ke("Api tokens"))).json()).tokens,or=()=>{const{uiConfig:t}=q();return r(W,{severity:"info",children:[r("p",{children:["Read the"," ",e("a",{href:"https://docs.getunleash.io/reference/sdks",target:"_blank",rel:"noreferrer",children:"SDK overview"})," ","to connect Unleash to your application. Please note it can take up to ",e("strong",{children:"1 minute"})," before a new API key is activated."]}),e("br",{}),e("strong",{children:"API URL: "})," ",r("pre",{style:{display:"inline"},children:[t.unleashUrl,"/api/"]})]})},ar=()=>{const t=ae();return e(Ft,{Icon:bt,onClick:()=>t("/admin/api/create-token"),"data-testid":Do,permission:Ro,maxWidth:"700px",children:"New API token"})},rr=({token:t})=>{const{setToastData:n}=Y(),o=a=>{Uo(a)&&n({type:"success",title:"Token copied to clipboard"})};return e(Se,{title:"Copy token",arrow:!0,children:e(Re,{onClick:()=>o(t.secret),size:"large",children:e(Io,{})})})},ir=g("ul")({marginBottom:0}),sr=({token:t})=>{const{hasAccess:n}=d.useContext(de),{deleteToken:o}=Pn(),[a,i]=d.useState(!1),{setToastData:s}=Y(),{refetch:u}=eo(),h=async()=>{await o(t.secret),i(!1),u(),s({type:"success",title:"API token removed"})};return r(z,{children:[e(x,{condition:n(Lo),show:e(Se,{title:"Delete token",arrow:!0,children:e(Re,{onClick:()=>i(!0),size:"large",children:e(Pe,{})})})}),e(oe,{open:a,onClick:h,onClose:()=>i(!1),title:"Confirm deletion",children:r("div",{children:["Are you sure you want to delete the following API token?",e("br",{}),r(ir,{children:[r("li",{children:[e("strong",{children:"username"}),":"," ",e("code",{children:t.username})]}),r("li",{children:[e("strong",{children:"type"}),": ",e("code",{children:t.type})]})]})]})})]})},lr=g(De)(()=>({textDecoration:"none","&:hover, &:focus":{textDecoration:"underline"}})),cr=({projects:t,project:n})=>{const{searchQuery:o}=Dn();let a=t&&Array.isArray(t)?t:n?[n]:[];return a.length===0?e(fe,{children:e(pt,{search:o,children:"*"})}):e(fe,{children:a.map((i,s)=>r(d.Fragment,{children:[s>0&&", ",!i||i==="*"?e(pt,{search:o,children:"*"}):e(lr,{to:`/projects/${i}`,children:e(pt,{search:o,children:i})})]},i))})},dr=["Icon","createdAt"],ur=()=>{const{tokens:t,loading:n}=eo(),o=d.useMemo(()=>({sortBy:[{id:"createdAt"}]}),[]);q();const a=be(Be.breakpoints.down("md")),{getTableProps:i,getTableBodyProps:s,headerGroups:u,rows:h,prepareRow:l,state:{globalFilter:c},setGlobalFilter:p,setHiddenColumns:m}=_.useTable({columns:dn,data:t,initialState:o,sortTypes:Ne,autoResetHiddenColumns:!1,disableSortRemove:!0},_.useGlobalFilter,_.useSortBy);return Ze([{condition:a,columns:dr}],m,dn),r(Q,{header:e(ne,{title:`API access (${h.length})`,actions:r(z,{children:[e(ve,{initialValue:c,onChange:p}),e(ne.Divider,{}),e(ar,{})]})}),children:[e(x,{condition:h.length>0,show:e(O,{sx:{mb:4},children:e(or,{})})}),e(O,{sx:{overflowX:"auto"},children:e(Me,{value:c,children:r(zt,{...i(),children:[e(Mt,{headerGroups:u}),e(nt,{...s(),children:h.map(y=>(l(y),e(je,{hover:!0,...y.getRowProps(),children:y.cells.map(S=>e(Ht,{...S.getCellProps(),children:S.render("Cell")}))})))})]})})}),e(x,{condition:h.length===0&&!n,show:e(x,{condition:(c==null?void 0:c.length)>0,show:r(ce,{children:["No tokens found matching “",c,"”"]}),elseShow:e(ce,{children:r("span",{children:["No tokens available. Read ",e("a",{href:"https://docs.getunleash.io/how-to/api",target:"_blank",rel:"noreferrer",children:"API How-to guides"})," "," to learn more."]})})})})]})},cn={client:{label:"CLIENT",title:"Connect server-side SDK or Unleash Proxy"},frontend:{label:"FRONTEND",title:"Connect web and mobile SDK"},admin:{label:"ADMIN",title:"Full access for managing Unleash"}},dn=[{id:"Icon",width:"1%",Cell:()=>e(Rn,{icon:e(Za,{color:"disabled"})}),disableSortBy:!0,disableGlobalFilter:!0},{Header:"Username",accessor:"username",Cell:ge},{Header:"Type",accessor:"type",Cell:({value:t})=>e(ge,{value:cn[t].label,subtitle:cn[t].title}),minWidth:280},{Header:"Project",accessor:"project",Cell:t=>e(cr,{project:t.row.original.project,projects:t.row.original.projects}),minWidth:120},{Header:"Environment",accessor:"environment",Cell:ge,minWidth:120},{Header:"Created",accessor:"createdAt",Cell:Fe,minWidth:150,disableGlobalFilter:!0},{Header:"Last seen",accessor:"seenAt",Cell:ot,minWidth:150,disableGlobalFilter:!0},{Header:"Actions",id:"Actions",align:"center",width:"1%",disableSortBy:!0,disableGlobalFilter:!0,Cell:t=>r(St,{children:[e(rr,{token:t.row.original}),e(sr,{token:t.row.original})]})}],hr=()=>{const{hasAccess:t}=d.useContext(de);return e(x,{condition:t(Bo),show:()=>e(ur,{}),elseShow:()=>e(He,{})})},pr=()=>e("div",{children:e(hr,{})});var me=(t=>(t.ADMIN="ADMIN",t.CLIENT="CLIENT",t.FRONTEND="FRONTEND",t))(me||{});const mr=g("div")(()=>({maxWidth:"400px"})),gr=g("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),fr=g(We)(({theme:t})=>({width:"100%",marginBottom:t.spacing(2)})),yr=g(In)(({theme:t})=>({marginBottom:t.spacing(2),minWidth:"400px",[t.breakpoints.down("sm")]:{minWidth:"379px"}})),Ot=g("p")(({theme:t})=>({marginBottom:t.spacing(1)})),br=g("label")(({theme:t})=>({marginBottom:t.spacing(1)})),Sr=g(M)(({theme:t})=>({marginLeft:t.spacing(3)})),vr=g(O)({marginTop:"auto",display:"flex",justifyContent:"flex-end"}),Cr=({children:t,username:n,type:o,projects:a,environment:i,setUsername:s,setTokenType:u,setProjects:h,setEnvironment:l,handleSubmit:c,handleCancel:p,errors:m,clearErrors:y})=>{var B;const{uiConfig:S}=q(),{environments:f}=Un(),{projects:C}=No(),k=[{key:me.CLIENT,label:`Server-side SDK (${me.CLIENT})`,title:"Connect server-side SDK or Unleash Proxy"},{key:me.ADMIN,label:me.ADMIN,title:"Full access for managing Unleash"}];S.flags.embedProxyFrontend&&k.splice(1,0,{key:me.FRONTEND,label:`Client-side SDK (${me.FRONTEND})`,title:"Connect web and mobile SDK directly to Unleash"});const v=C.map(w=>({value:w.id,label:w.name})),T=o===me.ADMIN?[{key:"*",label:"ALL"}]:f.map(w=>({key:w.name,label:w.name,title:w.name,disabled:!w.enabled})),A=Boolean((B=S==null?void 0:S.flags)==null?void 0:B.UNLEASH_CLOUD);return r(gr,{onSubmit:c,children:[e(x,{condition:A,show:r(W,{severity:"info",sx:{mb:4},children:["Please be aware of our"," ",e(Ln,{href:"https://www.getunleash.io/fair-use-policy",children:"fair use policy"}),"."]})}),r(mr,{children:[e(Ot,{children:"What would you like to call this token?"}),e(fr,{value:n,name:"username",onChange:w=>s(w.target.value),label:"Token name",error:m.username!==void 0,errorText:m.username,onFocus:()=>y("username"),autoFocus:!0}),r(Ye,{sx:{mb:2,width:"100%"},children:[e(br,{id:"token-type",children:"What do you want to connect?"}),e(ft,{"aria-labelledby":"token-type",defaultValue:"CLIENT",name:"radio-buttons-group",value:o,onChange:(w,P)=>u(P),children:k.map(({key:w,label:P,title:L})=>e(ie,{value:w,sx:{mb:1},control:e(tt,{sx:{ml:.75,alignSelf:"flex-start"}}),label:e(O,{children:r(O,{children:[e(R,{children:P}),e(R,{variant:"body2",color:"text.secondary",children:L})]})})},w))})]}),e(Ot,{children:"Which project do you want to give access to?"}),e(Oo,{disabled:o===me.ADMIN,options:v,defaultValue:a,onChange:h,error:m==null?void 0:m.projects,onFocus:()=>y("projects")}),e(Ot,{children:"Which environment should the token have access to?"}),e(yr,{disabled:o===me.ADMIN,options:T,value:i,onChange:l,label:"Environment",id:"api_key_environment",name:"environment",IconComponent:$o,fullWidth:!0})]}),r(vr,{children:[t,e(Sr,{onClick:p,children:"Cancel"})]})]})},wr=()=>{var T;const{environments:t}=Un(),n=(T=t==null?void 0:t.find(A=>A.enabled))==null?void 0:T.name,[o,a]=d.useState(""),[i,s]=d.useState("CLIENT"),[u,h]=d.useState(["*"]),[l,c]=d.useState(u),[p,m]=d.useState(),[y,S]=d.useState({});return d.useEffect(()=>{m(i==="ADMIN"?"*":n)},[i,n]),{username:o,type:i,projects:u,environment:p,setUsername:a,setTokenType:A=>{A==="ADMIN"?(s(A),c(u),h(["*"]),m("*")):(s(A),h(l),m(n))},setProjects:h,setEnvironment:m,getApiTokenPayload:()=>({username:o,type:i,environment:p,projects:u}),isValid:()=>{const A={};return o||(A.username="Username is required"),u.length===0&&(A.projects="At least one project is required"),S(A),Object.keys(A).length===0},clearErrors:A=>{if(A){const B={...y};delete B[A],S(B)}else S({})},errors:y}},xr=({open:t,closeConfirm:n,token:o,type:a})=>(Wt(),r(oe,{open:t,onClick:n,primaryButtonText:"Close",title:"New token created",children:[e(R,{variant:"body1",children:"Your new token has been created successfully."}),e(Bn,{token:o}),e(x,{condition:a===me.FRONTEND,show:r(W,{sx:{mt:2},severity:"info",children:["By default, all ",me.FRONTEND," tokens may be used from any CORS origin. If you'd like to configure a strict set of origins, please use the"," ",e(De,{to:"/admin/cors",target:"_blank",children:"CORS origins configuration page"}),"."]})})]})),un="Create API token",kr=()=>{const{setToastApiError:t}=Y(),{uiConfig:n}=q(),o=ae(),[a,i]=d.useState(!1),[s,u]=d.useState(""),{getApiTokenPayload:h,username:l,type:c,projects:p,environment:m,setUsername:y,setTokenType:S,setProjects:f,setEnvironment:C,isValid:k,errors:v,clearErrors:T}=wr(),{createToken:A,loading:B}=Pn();return Nn(un),r(Te,{loading:B,title:un,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 '${n.unleashUrl}/api/admin/api-tokens' \\
|
|
1
|
+
import{s as g,r as d,aB as wo,cI as xo,_ as ko,j as e,$ as An,cJ as on,cK as Rt,cL as To,cM as Ao,cN as Eo,cO as Po,c as ze,cP as En,cQ as Ge,cR as $t,aJ as se,a_ as xe,aK as ke,H as q,f as r,A as W,ar as ae,cS as Ft,bN as bt,cT as Do,cU as Ro,a2 as Y,be as Se,m as Re,ct as Io,cV as Uo,aN as de,cW as Pn,F as z,C as x,cX as Lo,b2 as Pe,aP as oe,aX as De,c8 as Dn,l as fe,c9 as pt,N as be,c0 as Be,d as _,e as Ne,U as Ze,ak as Q,al as ne,V as ve,a as O,X as Me,c1 as zt,S as Mt,h as nt,i as je,k as Ht,W as ce,I as Rn,R as ge,ce as Fe,cY as ot,cb as St,cZ as Bo,c_ as He,bK as We,bJ as In,a9 as M,aj as Un,ae as No,bI as Ln,a5 as Ye,c$ as ft,bY as ie,d0 as tt,T as R,d1 as Oo,d2 as $o,bU as Wt,d3 as Bn,bP as Nn,au as Te,aw as _t,d4 as j,d5 as qt,a4 as V,ay as Ce,bs as b,d6 as we,a6 as Go,a7 as jo,a8 as Ve,ac as Z,Z as _e,aI as vt,d7 as Fo,af as Vt,d8 as On,a1 as zo,d9 as Mo,da as st,B as Gt,db as Ho,g as $n,dc as Wo,dd as Yt,bF as Gn,de as _o,df as jn,c2 as re,bG as Fn,dg as qo,cg as an,dh as Jt,aH as Vo,ad as Yo,di as Jo,dj as It,cd as zn,dk as Ko,dl as Zo,dm as qe,Y as at,w as Xo,dn as Qo,dp as ea,bE as ta,dq as na,dr as oa,ds as aa,aE as Ct,dt as Kt,du as Mn,ah as Hn,bS as Wn,K as ra,u as Zt,dv as ia,L as _n,Q as Xt,aW as Ee,dw as sa,aY as rt,dx as la,dy as ca,P as qn,dz as da,bi as Ut,bk as Lt,dA as ua,dB as ha,bO as Qt,dC as pa,cq as Vn,cv as Yn,co as he,bQ as Jn,bR as J,x as ma,bv as ga,bw as fa,bx as ya,c6 as ba,dD as Sa,b$ as Bt,dE as Kn,dF as yt,dG as Zn,dH as va,dI as Xn,dJ as Ca,O as wa,ca as xa,dK as ka,dL as Ta,dM as Aa,dN as Ea,dO as Pa,dP as Da,b3 as Ra,bV as Ia,dQ as Ua,dR as La,bL as Ba,dS as rn,M as Qn,bj as Na,bH as Nt,dT as Oa}from"./index-c290f941.js";import{m as $a,u as wt,B as Ga,a as sn}from"./useProjectRole-b5b140d2.js";import{E as ja}from"./ExpandMore-c3e13d73.js";import{a as Fa}from"./index-3132dba8.js";import{a as za}from"./index-66dec49c.js";const Ma=["component","direction","spacing","divider","children"];function Ha(t,n){const o=d.Children.toArray(t).filter(Boolean);return o.reduce((a,i,s)=>(a.push(i),s<o.length-1&&a.push(d.cloneElement(n,{key:`separator-${s}`})),a),[])}const Wa=t=>({row:"Left","row-reverse":"Right",column:"Top","column-reverse":"Bottom"})[t],_a=({ownerState:t,theme:n})=>{let o=An({display:"flex",flexDirection:"column"},on({theme:n},Rt({values:t.direction,breakpoints:n.breakpoints.values}),a=>({flexDirection:a})));if(t.spacing){const a=To(n),i=Object.keys(n.breakpoints.values).reduce((l,c)=>((typeof t.spacing=="object"&&t.spacing[c]!=null||typeof t.direction=="object"&&t.direction[c]!=null)&&(l[c]=!0),l),{}),s=Rt({values:t.direction,base:i}),u=Rt({values:t.spacing,base:i});typeof s=="object"&&Object.keys(s).forEach((l,c,p)=>{if(!s[l]){const y=c>0?s[p[c-1]]:"column";s[l]=y}}),o=Ao(o,on({theme:n},u,(l,c)=>({"& > :not(style) + :not(style)":{margin:0,[`margin${Wa(c?s[c]:t.direction)}`]:Po(a,l)}})))}return o=Eo(n.breakpoints,o),o},qa=g("div",{name:"MuiStack",slot:"Root",overridesResolver:(t,n)=>[n.root]})(_a),Va=d.forwardRef(function(n,o){const a=wo({props:n,name:"MuiStack"}),i=xo(a),{component:s="div",direction:u="column",spacing:h=0,divider:l,children:c}=i,p=ko(i,Ma);return e(qa,An({as:s,ownerState:{direction:u,spacing:h},ref:o},p,{children:l?Ha(c,l):c}))}),Ya=Va,Ja=ze(e("path",{d:"M5 20h14v-2H5v2zM19 9h-4V3H9v6H5l7 7 7-7z"}),"Download"),Ka=ze(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"),Za=ze(e("path",{d:"M21 10h-8.35C11.83 7.67 9.61 6 7 6c-3.31 0-6 2.69-6 6s2.69 6 6 6c2.61 0 4.83-1.67 5.65-4H13l2 2 2-2 2 2 4-4.04L21 10zM7 15c-1.65 0-3-1.35-3-3s1.35-3 3-3 3 1.35 3 3-1.35 3-3 3z"}),"Key"),Xa=ze(e("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1.41 16.09V20h-2.67v-1.93c-1.71-.36-3.16-1.46-3.27-3.4h1.96c.1 1.05.82 1.87 2.65 1.87 1.96 0 2.4-.98 2.4-1.59 0-.83-.44-1.61-2.67-2.14-2.48-.6-4.18-1.62-4.18-3.67 0-1.72 1.39-2.84 3.11-3.21V4h2.67v1.95c1.86.45 2.79 1.86 2.85 3.39H14.3c-.05-1.11-.64-1.87-2.22-1.87-1.5 0-2.4.68-2.4 1.64 0 .84.65 1.39 2.67 1.91s4.18 1.39 4.18 3.91c-.01 1.83-1.38 2.83-3.12 3.16z"}),"MonetizationOn"),Qa=ze(e("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"}),"MoreVert"),er=ze(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"),tr=ze(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 mt(t){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?mt=function(o){return typeof o}:mt=function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},mt(t)}function gt(t,n){if(En(2,arguments),!n||mt(n)!=="object")return new Date(NaN);var o=n.years?Ge(n.years):0,a=n.months?Ge(n.months):0,i=n.weeks?Ge(n.weeks):0,s=n.days?Ge(n.days):0,u=n.hours?Ge(n.hours):0,h=n.minutes?Ge(n.minutes):0,l=n.seconds?Ge(n.seconds):0,c=$t(t),p=a||o?za(c,a+o*12):c,m=s||i?Fa(p,s+i*7):p,y=h+u*60,S=l+y*60,f=S*1e3,C=new Date(m.getTime()+f);return C}function ln(t,n){En(2,arguments);var o=$t(t),a=$t(n);return o.getTime()>a.getTime()}const eo=(t={})=>{const n=se("api/admin/api-tokens"),{data:o,error:a,mutate:i}=xe(n,nr,t),s=d.useMemo(()=>o??[],[o]),u=d.useCallback(()=>{i().catch(console.warn)},[i]);return{tokens:s,error:a,loading:!a&&!o,refetch:u}},nr=async t=>(await(await fetch(t).then(ke("Api tokens"))).json()).tokens,or=()=>{const{uiConfig:t}=q();return r(W,{severity:"info",children:[r("p",{children:["Read the"," ",e("a",{href:"https://docs.getunleash.io/reference/sdks",target:"_blank",rel:"noreferrer",children:"SDK overview"})," ","to connect Unleash to your application. Please note it can take up to ",e("strong",{children:"1 minute"})," before a new API key is activated."]}),e("br",{}),e("strong",{children:"API URL: "})," ",r("pre",{style:{display:"inline"},children:[t.unleashUrl,"/api/"]})]})},ar=()=>{const t=ae();return e(Ft,{Icon:bt,onClick:()=>t("/admin/api/create-token"),"data-testid":Do,permission:Ro,maxWidth:"700px",children:"New API token"})},rr=({token:t})=>{const{setToastData:n}=Y(),o=a=>{Uo(a)&&n({type:"success",title:"Token copied to clipboard"})};return e(Se,{title:"Copy token",arrow:!0,children:e(Re,{onClick:()=>o(t.secret),size:"large",children:e(Io,{})})})},ir=g("ul")({marginBottom:0}),sr=({token:t})=>{const{hasAccess:n}=d.useContext(de),{deleteToken:o}=Pn(),[a,i]=d.useState(!1),{setToastData:s}=Y(),{refetch:u}=eo(),h=async()=>{await o(t.secret),i(!1),u(),s({type:"success",title:"API token removed"})};return r(z,{children:[e(x,{condition:n(Lo),show:e(Se,{title:"Delete token",arrow:!0,children:e(Re,{onClick:()=>i(!0),size:"large",children:e(Pe,{})})})}),e(oe,{open:a,onClick:h,onClose:()=>i(!1),title:"Confirm deletion",children:r("div",{children:["Are you sure you want to delete the following API token?",e("br",{}),r(ir,{children:[r("li",{children:[e("strong",{children:"username"}),":"," ",e("code",{children:t.username})]}),r("li",{children:[e("strong",{children:"type"}),": ",e("code",{children:t.type})]})]})]})})]})},lr=g(De)(()=>({textDecoration:"none","&:hover, &:focus":{textDecoration:"underline"}})),cr=({projects:t,project:n})=>{const{searchQuery:o}=Dn();let a=t&&Array.isArray(t)?t:n?[n]:[];return a.length===0?e(fe,{children:e(pt,{search:o,children:"*"})}):e(fe,{children:a.map((i,s)=>r(d.Fragment,{children:[s>0&&", ",!i||i==="*"?e(pt,{search:o,children:"*"}):e(lr,{to:`/projects/${i}`,children:e(pt,{search:o,children:i})})]},i))})},dr=["Icon","createdAt"],ur=()=>{const{tokens:t,loading:n}=eo(),o=d.useMemo(()=>({sortBy:[{id:"createdAt"}]}),[]);q();const a=be(Be.breakpoints.down("md")),{getTableProps:i,getTableBodyProps:s,headerGroups:u,rows:h,prepareRow:l,state:{globalFilter:c},setGlobalFilter:p,setHiddenColumns:m}=_.useTable({columns:dn,data:t,initialState:o,sortTypes:Ne,autoResetHiddenColumns:!1,disableSortRemove:!0},_.useGlobalFilter,_.useSortBy);return Ze([{condition:a,columns:dr}],m,dn),r(Q,{header:e(ne,{title:`API access (${h.length})`,actions:r(z,{children:[e(ve,{initialValue:c,onChange:p}),e(ne.Divider,{}),e(ar,{})]})}),children:[e(x,{condition:h.length>0,show:e(O,{sx:{mb:4},children:e(or,{})})}),e(O,{sx:{overflowX:"auto"},children:e(Me,{value:c,children:r(zt,{...i(),children:[e(Mt,{headerGroups:u}),e(nt,{...s(),children:h.map(y=>(l(y),e(je,{hover:!0,...y.getRowProps(),children:y.cells.map(S=>e(Ht,{...S.getCellProps(),children:S.render("Cell")}))})))})]})})}),e(x,{condition:h.length===0&&!n,show:e(x,{condition:(c==null?void 0:c.length)>0,show:r(ce,{children:["No tokens found matching “",c,"”"]}),elseShow:e(ce,{children:r("span",{children:["No tokens available. Read ",e("a",{href:"https://docs.getunleash.io/how-to/api",target:"_blank",rel:"noreferrer",children:"API How-to guides"})," "," to learn more."]})})})})]})},cn={client:{label:"CLIENT",title:"Connect server-side SDK or Unleash Proxy"},frontend:{label:"FRONTEND",title:"Connect web and mobile SDK"},admin:{label:"ADMIN",title:"Full access for managing Unleash"}},dn=[{id:"Icon",width:"1%",Cell:()=>e(Rn,{icon:e(Za,{color:"disabled"})}),disableSortBy:!0,disableGlobalFilter:!0},{Header:"Username",accessor:"username",Cell:ge},{Header:"Type",accessor:"type",Cell:({value:t})=>e(ge,{value:cn[t].label,subtitle:cn[t].title}),minWidth:280},{Header:"Project",accessor:"project",Cell:t=>e(cr,{project:t.row.original.project,projects:t.row.original.projects}),minWidth:120},{Header:"Environment",accessor:"environment",Cell:ge,minWidth:120},{Header:"Created",accessor:"createdAt",Cell:Fe,minWidth:150,disableGlobalFilter:!0},{Header:"Last seen",accessor:"seenAt",Cell:ot,minWidth:150,disableGlobalFilter:!0},{Header:"Actions",id:"Actions",align:"center",width:"1%",disableSortBy:!0,disableGlobalFilter:!0,Cell:t=>r(St,{children:[e(rr,{token:t.row.original}),e(sr,{token:t.row.original})]})}],hr=()=>{const{hasAccess:t}=d.useContext(de);return e(x,{condition:t(Bo),show:()=>e(ur,{}),elseShow:()=>e(He,{})})},pr=()=>e("div",{children:e(hr,{})});var me=(t=>(t.ADMIN="ADMIN",t.CLIENT="CLIENT",t.FRONTEND="FRONTEND",t))(me||{});const mr=g("div")(()=>({maxWidth:"400px"})),gr=g("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),fr=g(We)(({theme:t})=>({width:"100%",marginBottom:t.spacing(2)})),yr=g(In)(({theme:t})=>({marginBottom:t.spacing(2),minWidth:"400px",[t.breakpoints.down("sm")]:{minWidth:"379px"}})),Ot=g("p")(({theme:t})=>({marginBottom:t.spacing(1)})),br=g("label")(({theme:t})=>({marginBottom:t.spacing(1)})),Sr=g(M)(({theme:t})=>({marginLeft:t.spacing(3)})),vr=g(O)({marginTop:"auto",display:"flex",justifyContent:"flex-end"}),Cr=({children:t,username:n,type:o,projects:a,environment:i,setUsername:s,setTokenType:u,setProjects:h,setEnvironment:l,handleSubmit:c,handleCancel:p,errors:m,clearErrors:y})=>{var B;const{uiConfig:S}=q(),{environments:f}=Un(),{projects:C}=No(),k=[{key:me.CLIENT,label:`Server-side SDK (${me.CLIENT})`,title:"Connect server-side SDK or Unleash Proxy"},{key:me.ADMIN,label:me.ADMIN,title:"Full access for managing Unleash"}];S.flags.embedProxyFrontend&&k.splice(1,0,{key:me.FRONTEND,label:`Client-side SDK (${me.FRONTEND})`,title:"Connect web and mobile SDK directly to Unleash"});const v=C.map(w=>({value:w.id,label:w.name})),T=o===me.ADMIN?[{key:"*",label:"ALL"}]:f.map(w=>({key:w.name,label:w.name,title:w.name,disabled:!w.enabled})),A=Boolean((B=S==null?void 0:S.flags)==null?void 0:B.UNLEASH_CLOUD);return r(gr,{onSubmit:c,children:[e(x,{condition:A,show:r(W,{severity:"info",sx:{mb:4},children:["Please be aware of our"," ",e(Ln,{href:"https://www.getunleash.io/fair-use-policy",children:"fair use policy"}),"."]})}),r(mr,{children:[e(Ot,{children:"What would you like to call this token?"}),e(fr,{value:n,name:"username",onChange:w=>s(w.target.value),label:"Token name",error:m.username!==void 0,errorText:m.username,onFocus:()=>y("username"),autoFocus:!0}),r(Ye,{sx:{mb:2,width:"100%"},children:[e(br,{id:"token-type",children:"What do you want to connect?"}),e(ft,{"aria-labelledby":"token-type",defaultValue:"CLIENT",name:"radio-buttons-group",value:o,onChange:(w,P)=>u(P),children:k.map(({key:w,label:P,title:L})=>e(ie,{value:w,sx:{mb:1},control:e(tt,{sx:{ml:.75,alignSelf:"flex-start"}}),label:e(O,{children:r(O,{children:[e(R,{children:P}),e(R,{variant:"body2",color:"text.secondary",children:L})]})})},w))})]}),e(Ot,{children:"Which project do you want to give access to?"}),e(Oo,{disabled:o===me.ADMIN,options:v,defaultValue:a,onChange:h,error:m==null?void 0:m.projects,onFocus:()=>y("projects")}),e(Ot,{children:"Which environment should the token have access to?"}),e(yr,{disabled:o===me.ADMIN,options:T,value:i,onChange:l,label:"Environment",id:"api_key_environment",name:"environment",IconComponent:$o,fullWidth:!0})]}),r(vr,{children:[t,e(Sr,{onClick:p,children:"Cancel"})]})]})},wr=()=>{var T;const{environments:t}=Un(),n=(T=t==null?void 0:t.find(A=>A.enabled))==null?void 0:T.name,[o,a]=d.useState(""),[i,s]=d.useState("CLIENT"),[u,h]=d.useState(["*"]),[l,c]=d.useState(u),[p,m]=d.useState(),[y,S]=d.useState({});return d.useEffect(()=>{m(i==="ADMIN"?"*":n)},[i,n]),{username:o,type:i,projects:u,environment:p,setUsername:a,setTokenType:A=>{A==="ADMIN"?(s(A),c(u),h(["*"]),m("*")):(s(A),h(l),m(n))},setProjects:h,setEnvironment:m,getApiTokenPayload:()=>({username:o,type:i,environment:p,projects:u}),isValid:()=>{const A={};return o||(A.username="Username is required"),u.length===0&&(A.projects="At least one project is required"),S(A),Object.keys(A).length===0},clearErrors:A=>{if(A){const B={...y};delete B[A],S(B)}else S({})},errors:y}},xr=({open:t,closeConfirm:n,token:o,type:a})=>(Wt(),r(oe,{open:t,onClick:n,primaryButtonText:"Close",title:"New token created",children:[e(R,{variant:"body1",children:"Your new token has been created successfully."}),e(Bn,{token:o}),e(x,{condition:a===me.FRONTEND,show:r(W,{sx:{mt:2},severity:"info",children:["By default, all ",me.FRONTEND," tokens may be used from any CORS origin. If you'd like to configure a strict set of origins, please use the"," ",e(De,{to:"/admin/cors",target:"_blank",children:"CORS origins configuration page"}),"."]})})]})),un="Create API token",kr=()=>{const{setToastApiError:t}=Y(),{uiConfig:n}=q(),o=ae(),[a,i]=d.useState(!1),[s,u]=d.useState(""),{getApiTokenPayload:h,username:l,type:c,projects:p,environment:m,setUsername:y,setTokenType:S,setProjects:f,setEnvironment:C,isValid:k,errors:v,clearErrors:T}=wr(),{createToken:A,loading:B}=Pn();return Nn(un),r(Te,{loading:B,title:un,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 '${n.unleashUrl}/api/admin/api-tokens' \\
|
|
2
2
|
--header 'Authorization: INSERT_API_KEY' \\
|
|
3
3
|
--header 'Content-Type: application/json' \\
|
|
4
4
|
--data-raw '${JSON.stringify(h(),void 0,2)}'`,children:[e(Cr,{username:l,type:c,projects:p,environment:m,setEnvironment:C,setTokenType:S,setUsername:y,setProjects:f,errors:v,handleSubmit:async H=>{if(H.preventDefault(),!!k())try{const U=h();await A(U).then(D=>D.json()).then(D=>{qt(),u(D.secret),i(!0)})}catch(U){t(V(U))}},handleCancel:()=>{o(Ce)},mode:"Create",clearErrors:T,children:e(_t,{name:"token",permission:j})}),e(xr,{open:a,closeConfirm:()=>{i(!1),o("/admin/api")},token:s,type:c})]})},to=({data:t={enabled:!1,autoCreate:!1},setValue:n})=>{const o=()=>{n("autoCreate",!t.autoCreate)},a=s=>{n("defaultRootRole",s.target.value)},i=s=>{n(s.target.name,s.target.value)};return r(d.Fragment,{children:[r(b,{container:!0,spacing:3,mb:2,children:[r(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(ie,{control:e(we,{onChange:o,name:"enabled",checked:t.autoCreate,disabled:!t.enabled}),label:"Auto-create users"})})]}),r(b,{container:!0,spacing:3,mb:2,children:[r(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:r(Ye,{style:{minWidth:"200px"},children:[e(Go,{id:"defaultRootRole-label",children:"Default Role"}),r(jo,{label:"Default Role",labelId:"defaultRootRole-label",id:"defaultRootRole",name:"defaultRootRole",disabled:!t.autoCreate||!t.enabled,value:t.defaultRootRole||"Editor",onChange:a,children:[e(Ve,{value:"Viewer",children:"Viewer"}),e(Ve,{value:"Editor",children:"Editor"}),e(Ve,{value:"Admin",children:"Admin"})]})]})})]}),r(b,{container:!0,spacing:3,mb:2,children:[r(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(Z,{onChange:i,label:"Email domains",name:"emailDomains",disabled:!t.autoCreate||!t.enabled,required:Boolean(t.autoCreate),value:t.emailDomains||"",placeholder:"@company.com, @anotherCompany.com",style:{width:"400px"},rows:2,variant:"outlined",size:"small"})})]})]})},Tr=async(t,n)=>{if(t){if(n){const o=await n.json();throw t({message:o.message}),new Error(o.message)}throw new Error}},xt=t=>{const{makeRequest:n,createRequest:o,errors:a,loading:i}=_e({propagateErrors:!0,handleBadRequest:Tr});return{updateSettings:async u=>{const h=`api/admin/auth/${t}/settings`,l=o(h,{method:"POST",body:JSON.stringify(u)});try{await n(l.caller,l.id)}catch(c){throw c}},errors:a,loading:i}},Je=(t,n={})=>{const o=async()=>{const c=se(`api/admin/auth/${t}/settings`);return(await fetch(c,{method:"GET"}).then(ke("Auth settings"))).json()},a=`api/admin/auth/${t}/settings`,{data:i,error:s}=xe(a,o,n),[u,h]=d.useState(!s&&!i),l=()=>{vt(a)};return d.useEffect(()=>{h(!s&&!i)},[i,s]),{config:i||{},error:s,loading:u,refetch:l}},en=t=>{const o=Object.entries(t).filter(([,a])=>a!=="");return Object.fromEntries(o)},no=({ssoType:t,data:n={enabled:!1,enableGroupSyncing:!1,groupJsonPath:""},setValue:o})=>{const a=()=>{o("enableGroupSyncing",!n.enableGroupSyncing)},i=s=>{o(s.target.name,s.target.value)};return r(z,{children:[r(b,{container:!0,spacing:3,mb:2,children:[r(b,{item:!0,md:5,children:[e("strong",{children:"Enable Group Syncing"}),r("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(ie,{control:e(we,{onChange:a,value:n.enableGroupSyncing,name:"enableGroupSyncing",checked:n.enableGroupSyncing,disabled:!n.enabled}),label:n.enableGroupSyncing?"Enabled":"Disabled"})})]}),r(b,{container:!0,spacing:3,mb:2,children:[r(b,{item:!0,md:5,children:[e("strong",{children:"Group Field JSON Path"}),r("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(Z,{onChange:i,label:"Group JSON Path",name:"groupJsonPath",value:n.groupJsonPath,disabled:!n.enableGroupSyncing,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]})]})},Ar={enabled:!1,enableSingleSignOut:!1,enableGroupSyncing:!1,autoCreate:!1,unleashHostname:location.hostname,groupJsonPath:"",clientId:"",discoverUrl:"",secret:"",acrValues:""},Er=()=>{const{setToastData:t,setToastApiError:n}=Y(),{uiConfig:o}=q(),[a,i]=d.useState(Ar),{hasAccess:s}=d.useContext(de),{config:u}=Je("oidc"),{updateSettings:h,errors:l,loading:c}=xt("oidc");if(d.useEffect(()=>{u.discoverUrl&&i(u)},[u]),!s(j))return e(W,{severity:"error",children:"You need to be a root admin to access this section."});const p=C=>{S(C.target.name,C.target.value)},m=()=>{i({...a,enabled:!a.enabled})},y=()=>{i({...a,enableSingleSignOut:!a.enableSingleSignOut})},S=(C,k)=>{i({...a,[C]:k})},f=async C=>{C.preventDefault();try{await h(en(a)),t({title:"Settings stored",type:"success"})}catch(k){n(V(k))}};return r(Q,{children:[e(b,{container:!0,style:{marginBottom:"1rem"},children:e(b,{item:!0,md:12,children:r(W,{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:"," ",r("code",{children:[o.unleashUrl,"/auth/oidc/callback"]})]})})}),r("form",{onSubmit:f,children:[r(b,{container:!0,spacing:3,mb:2,children:[r(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(ie,{control:e(we,{onChange:m,value:a.enabled,name:"enabled",checked:a.enabled}),label:a.enabled?"Enabled":"Disabled"})})]}),r(b,{container:!0,spacing:3,mb:2,children:[r(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(Z,{onChange:p,label:"Discover URL",name:"discoverUrl",value:a.discoverUrl,disabled:!a.enabled,style:{width:"400px"},variant:"outlined",size:"small"})})]}),r(b,{container:!0,spacing:3,mb:2,children:[r(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(Z,{onChange:p,label:"Client ID",name:"clientId",value:a.clientId,disabled:!a.enabled,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),r(b,{container:!0,spacing:3,mb:4,children:[r(b,{item:!0,md:5,children:[e("strong",{children:"Client secret"}),r("p",{children:["(Required) Client secret of your OpenID application."," "]})]}),e(b,{item:!0,md:6,children:e(Z,{onChange:p,label:"Client Secret",name:"secret",value:a.secret,disabled:!a.enabled,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),e("h3",{children:"Optional Configuration"}),r(b,{container:!0,spacing:3,mb:2,children:[r(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(ie,{control:e(we,{onChange:y,value:a.enableSingleSignOut,disabled:!a.enabled,name:"enableSingleSignOut",checked:a.enableSingleSignOut}),label:a.enableSingleSignOut?"Enabled":"Disabled"})})]}),r(b,{container:!0,spacing:3,mb:2,children:[r(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(Z,{onChange:p,label:"ACR Values",name:"acrValues",value:a.acrValues,disabled:!a.enabled,style:{width:"400px"},variant:"outlined",size:"small"})})]}),e(no,{ssoType:"OIDC",data:a,setValue:S}),e(to,{data:a,setValue:S}),e(b,{container:!0,spacing:3,children:r(b,{item:!0,md:12,children:[e(M,{variant:"contained",color:"primary",type:"submit",disabled:c,children:"Save"})," ",e("p",{children:e("small",{style:{color:"red"},children:l==null?void 0:l.message})})]})})]})]})},Pr={enabled:!1,autoCreate:!1,enableGroupSyncing:!1,unleashHostname:location.hostname,entityId:"",signOnUrl:"",certificate:"",signOutUrl:"",spCertificate:"",groupJsonPath:""},Dr=()=>{const{setToastData:t,setToastApiError:n}=Y(),{uiConfig:o}=q(),[a,i]=d.useState(Pr),{hasAccess:s}=d.useContext(de),{config:u}=Je("saml"),{updateSettings:h,errors:l,loading:c}=xt("saml");if(d.useEffect(()=>{u.entityId&&i(u)},[u]),!s(j))return e(W,{severity:"error",children:"You need to be a root admin to access this section."});const p=f=>{y(f.target.name,f.target.value)},m=()=>{i({...a,enabled:!a.enabled})},y=(f,C)=>{i({...a,[f]:C})},S=async f=>{f.preventDefault();try{await h(en(a)),t({title:"Settings stored",type:"success"})}catch(C){n(V(C))}};return r(Q,{children:[e(b,{container:!0,style:{marginBottom:"1rem"},children:e(b,{item:!0,md:12,children:r(W,{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:"," ",r("code",{children:[o.unleashUrl,"/auth/saml/callback"]})]})})}),r("form",{onSubmit:S,children:[r(b,{container:!0,spacing:3,children:[r(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(ie,{control:e(we,{onChange:m,value:a.enabled,name:"enabled",checked:a.enabled}),label:a.enabled?"Enabled":"Disabled"})})]}),r(b,{container:!0,spacing:3,mb:2,children:[r(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(Z,{onChange:p,label:"Entity ID",name:"entityId",value:a.entityId,disabled:!a.enabled,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),r(b,{container:!0,spacing:3,mb:2,children:[r(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(Z,{onChange:p,label:"Single Sign-On URL",name:"signOnUrl",value:a.signOnUrl,disabled:!a.enabled,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),r(b,{container:!0,spacing:3,mb:4,children:[r(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(Z,{onChange:p,label:"X.509 Certificate",name:"certificate",value:a.certificate,disabled:!a.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"}),r(b,{container:!0,spacing:3,mb:2,children:[r(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(Z,{onChange:p,label:"Single Sign-out URL",name:"signOutUrl",value:a.signOutUrl,disabled:!a.enabled,style:{width:"400px"},variant:"outlined",size:"small"})})]}),r(b,{container:!0,spacing:3,mb:2,children:[r(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(Z,{onChange:p,label:"X.509 Certificate",name:"spCertificate",value:a.spCertificate,disabled:!a.enabled,style:{width:"100%"},InputProps:{style:{fontSize:"0.6em",fontFamily:"monospace"}},multiline:!0,rows:14,maxRows:14,variant:"outlined",size:"small"})})]}),e(no,{ssoType:"SAML",data:a,setValue:y}),e(to,{data:a,setValue:y}),e(b,{container:!0,spacing:3,children:r(b,{item:!0,md:5,children:[e(M,{variant:"contained",color:"primary",type:"submit",disabled:c,children:"Save"})," ",e("p",{children:e("small",{style:{color:"red"},children:l==null?void 0:l.message})})]})})]})]})},Rr=()=>{const{setToastData:t,setToastApiError:n}=Y(),{config:o}=Je("simple"),[a,i]=d.useState(!1),{updateSettings:s,errors:u,loading:h}=xt("simple"),{hasAccess:l}=d.useContext(de);return d.useEffect(()=>{i(!!o.disabled)},[o.disabled]),l(j)?e(Q,{children:r("form",{onSubmit:async m=>{m.preventDefault();try{await s({disabled:a}),t({title:"Successfully saved",text:"Password authentication settings stored.",autoHideDuration:4e3,type:"success",show:!0})}catch(y){n(V(y)),i(o.disabled)}},children:[r(b,{container:!0,spacing:3,mb:2,children:[r(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(ie,{control:e(we,{onChange:()=>{i(!a)},value:!a,name:"disabled",checked:!a}),label:a?"Disabled":"Enabled"})})]}),e(b,{container:!0,spacing:3,children:r(b,{item:!0,md:12,children:[e(M,{variant:"contained",color:"primary",type:"submit",disabled:h,children:"Save"})," ",e("p",{children:e("small",{style:{color:"red"},children:u==null?void 0:u.message})})]})})]})}):e(W,{severity:"error",children:"You need to be a root admin to access this section."})},Ir={enabled:!1,autoCreate:!1,unleashHostname:location.hostname,clientId:"",clientSecret:"",emailDomains:""},Ur=()=>{const{setToastData:t,setToastApiError:n}=Y(),{uiConfig:o}=q(),[a,i]=d.useState(Ir),{hasAccess:s}=d.useContext(de),{config:u}=Je("google"),{updateSettings:h,errors:l,loading:c}=xt("google");if(d.useEffect(()=>{u.clientId&&i(u)},[u]),!s(j))return e("span",{children:"You need admin privileges to access this section."});const p=f=>{i({...a,[f.target.name]:f.target.value})},m=()=>{i({...a,enabled:!a.enabled})},y=()=>{i({...a,autoCreate:!a.autoCreate})},S=async f=>{f.preventDefault();try{await h(en(a)),t({title:"Settings stored",type:"success"})}catch(C){n(V(C))}};return r(Q,{children:[r(O,{children:[r(W,{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."]}),r(W,{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:"," ",r("code",{children:[o.unleashUrl,"/auth/google/callback"]})]})]}),r("form",{onSubmit:S,children:[r(b,{container:!0,spacing:3,mb:2,children:[r(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(ie,{control:e(we,{onChange:m,value:a.enabled,name:"enabled",checked:a.enabled}),label:a.enabled?"Enabled":"Disabled"})})]}),r(b,{container:!0,spacing:3,mb:2,children:[r(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(Z,{onChange:p,label:"Client ID",name:"clientId",placeholder:"",value:a.clientId,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),r(b,{container:!0,spacing:3,mb:2,children:[r(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(Z,{onChange:p,label:"Client Secret",name:"clientSecret",value:a.clientSecret,placeholder:"",style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),r(b,{container:!0,spacing:3,mb:2,children:[r(b,{item:!0,md:5,children:[e("strong",{children:"Unleash hostname"}),r("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(Z,{onChange:p,label:"Unleash Hostname",name:"unleashHostname",placeholder:"",value:a.unleashHostname||"",style:{width:"400px"},variant:"outlined",size:"small"})})]}),r(b,{container:!0,spacing:3,mb:2,children:[r(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:y,name:"enabled",checked:a.autoCreate})})]}),r(b,{container:!0,spacing:3,mb:2,children:[r(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(Z,{onChange:p,label:"Email domains",name:"emailDomains",value:a.emailDomains,placeholder:"@company.com, @anotherCompany.com",style:{width:"400px"},rows:2,multiline:!0,variant:"outlined",size:"small"})})]}),e(b,{container:!0,spacing:3,children:r(b,{item:!0,md:5,children:[e(M,{variant:"contained",color:"primary",type:"submit",disabled:c,children:"Save"})," ",e("p",{children:e("small",{style:{color:"red"},children:l==null?void 0:l.message})})]})})]})]})},Lr=()=>{const{authenticationType:t}=q().uiConfig;return e("div",{children:r(Q,{header:"Single Sign-On",children:[e(x,{condition:t==="enterprise",show:e(Fo,{tabData:[{label:"OpenID Connect",component:e(Er,{})},{label:"SAML 2.0",component:e(Dr,{})},{label:"Password",component:e(Rr,{})},{label:"Google",component:e(Ur,{})}]})}),e(x,{condition:t==="open-source",show:e(W,{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(W,{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(W,{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(W,{severity:"info",children:"Your Unleash instance is managed by the Unleash team."})})]})})},Br=se("api/admin/invoices"),Nr=g(M)(({theme:t})=>({width:"100%",marginBottom:t.spacing(1.5)})),Or=({update:t})=>e(Nr,{href:`${Br}/${t?"portal":"checkout"}`,variant:t?"outlined":"contained",children:t?"Update billing information":"Add billing information"}),$r=g("aside")(({theme:t})=>({padding:t.spacing(4),height:"100%",borderRadius:t.shape.borderRadiusLarge,backgroundColor:t.palette.secondaryContainer})),Gr=g(R)(({theme:t})=>({marginBottom:t.spacing(4)})),jr=g(W)(({theme:t})=>({marginBottom:t.spacing(4)})),hn=g(R)(({theme:t})=>({fontSize:t.fontSizes.smallBody,color:t.palette.text.secondary})),Fr=g(Vt)(({theme:t})=>({margin:`${t.spacing(2.5)} 0`,borderColor:t.palette.dividerAlternative})),zr=({instanceStatus:t})=>{const n=t.state!==On.ACTIVE;return e(b,{item:!0,xs:12,md:5,children:r($r,{children:[e(Gr,{variant:"body1",children:"Billing information"}),e(x,{condition:n,show:r(jr,{severity:"warning",children:["In order to ",e("strong",{children:"Upgrade trial"})," you need to provide us your billing information."]})}),e(Or,{update:!n}),e(hn,{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(Fr,{}),r(hn,{children:[e("a",{href:"mailto:elise@getunleash.ai?subject=PRO plan clarifications",children:"Get in touch with us"})," ","for any clarification"]})]})})},Xe=()=>{const{data:t,error:n,mutate:o}=xe(se("api/admin/user-admin"),Mr);return d.useMemo(()=>({users:(t==null?void 0:t.users)??[],roles:(t==null?void 0:t.rootRoles)??[],loading:!n&&!t,refetch:()=>o(),error:n}),[t,n,o])},Mr=t=>fetch(t).then(ke("Users")).then(n=>n.json()),Hr=g(b)(({theme:t})=>({flexWrap:"nowrap",gap:t.spacing(1)})),lt=({sx:t,children:n})=>e(Hr,{container:!0,item:!0,justifyContent:"space-between",alignItems:"center",sx:t,children:n}),Le=({children:t,vertical:n=!1})=>e(b,{container:n,item:!0,display:"flex",alignItems:n?"start":"center",direction:n?"column":void 0,children:t}),Wr=g("span")(({theme:t})=>({fontSize:t.fontSizes.smallBody,marginLeft:t.spacing(1)})),pn=({children:t})=>r(Wr,{children:["(",t,")"]}),oo=!1,_r=g("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)}})),qr=g(R)(({theme:t})=>({fontSize:t.fontSizes.smallBody,color:t.palette.text.secondary})),Vr=g("span")(({theme:t})=>({fontSize:"3.25rem",lineHeight:1,color:t.palette.primary.main,fontWeight:800})),Yr=g("span")(({theme:t})=>({marginLeft:t.spacing(1.5),fontWeight:t.fontWeight.bold})),Jr=g("span")(({theme:t})=>({color:t.palette.primary.main,fontSize:t.fontSizes.mainHeader,fontWeight:t.fontWeight.bold})),Kr=g(W)(({theme:t})=>({fontSize:t.fontSizes.smallerBody,marginBottom:t.spacing(3),marginTop:t.spacing(-1.5),[t.breakpoints.up("md")]:{marginTop:t.spacing(-4.5)}})),Zr=g(zo)(({theme:t})=>({fontSize:"1rem",marginRight:t.spacing(1)})),Xr=g(Vt)(({theme:t})=>({margin:`${t.spacing(3)} 0`})),Qr=({instanceStatus:t})=>{const{users:n}=Xe(),o=Mo(t),a={[st.PRO]:80,[st.COMPANY]:0,[st.TEAM]:0,[st.UNKNOWN]:0,user:15},i=a[t.plan],s=t.seats??5,u=Math.min(n.length,s),h=n.length-u,l=a.user*h,c=i+l,p=t.state!==On.ACTIVE;return e(b,{item:!0,xs:12,md:7,children:r(_r,{children:[e(x,{condition:p,show:r(Kr,{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(Gt,{color:"success",children:"Current plan"}),e(b,{container:!0,children:r(lt,{sx:m=>({marginBottom:m.spacing(3)}),children:[r(Le,{children:[e(Vr,{children:t.plan}),e(x,{condition:Ho(t),show:e(Yr,{sx:m=>({color:o?m.palette.error.dark:m.palette.warning.dark}),children:o?"Trial expired":t.trialExtended?"Extended Trial":"Trial"})})]}),e(Le,{children:e(x,{condition:i>0,show:r(Jr,{children:["$",i.toFixed(2)]})})})]})}),e(x,{condition:oo,show:r(z,{children:[r(b,{container:!0,children:[r(lt,{sx:m=>({marginBottom:m.spacing(1.5)}),children:[e(Le,{children:r(R,{children:[e("strong",{children:s})," team members",e(pn,{children:r(De,{to:"/admin/users",children:[u," assigned"]})})]})}),r(Le,{children:[e(Zr,{}),e(R,{variant:"body2",children:"included"})]})]}),r(lt,{children:[r(Le,{vertical:!0,children:[r(R,{children:["Paid members",e(pn,{children:r(De,{to:"/admin/users",children:[h," assigned"]})})]}),r(qr,{children:["Add up to 15 extra paid members - $",a.user,"/month per member"]})]}),e(Le,{children:r(R,{sx:m=>({fontSize:m.fontSizes.mainHeader}),children:["$",l.toFixed(2)]})})]})]}),e(Xr,{}),e(b,{container:!0,children:r(lt,{children:[e(Le,{children:e(R,{sx:m=>({fontWeight:m.fontWeight.bold,fontSize:m.fontSizes.mainHeader}),children:"Total per month"})}),e(Le,{children:r(R,{sx:m=>({fontWeight:m.fontWeight.bold,fontSize:"2rem"}),children:["$",c.toFixed(2)]})})]})})]})})]})})},ei=({instanceStatus:t})=>r(b,{container:!0,spacing:4,children:[e(zr,{instanceStatus:t}),e(Qr,{instanceStatus:t})]}),ti=g(R)(({theme:t})=>({marginTop:t.spacing(6),marginBottom:t.spacing(2.5),fontSize:t.fontSizes.mainHeader})),ni=[{Header:"Amount",accessor:"amountFormatted"},{Header:"Status",accessor:"status",disableGlobalFilter:!0},{Header:"Due date",accessor:"dueDate",Cell:Fe,sortType:"date",disableGlobalFilter:!0},{Header:"Download",accessor:"invoicePDF",align:"center",Cell:({value:t})=>e(O,{sx:{display:"flex",justifyContent:"center"},"data-loading":!0,children:e(Re,{href:t,children:e(Wo,{})})}),width:100,disableGlobalFilter:!0,disableSortBy:!0}],oi=({data:t,isLoading:n=!1})=>{const o=d.useMemo(()=>({sortBy:[{id:"dueDate"}]}),[]),{getTableProps:a,getTableBodyProps:i,headerGroups:s,rows:u,prepareRow:h}=_.useTable({columns:ni,data:t,initialState:o,sortTypes:Ne,autoResetGlobalFilter:!1,disableSortRemove:!0,defaultColumn:{Cell:fe}},_.useGlobalFilter,_.useSortBy);return r(Q,{isLoading:n,disablePadding:!0,children:[e(ti,{children:"Payment history"}),r($n,{...a(),children:[e(Mt,{headerGroups:s}),e(nt,{...i(),children:u.map(l=>(h(l),e(je,{hover:!0,...l.getRowProps(),children:l.cells.map(c=>e(Ht,{...c.getCellProps(),children:c.render("Cell")}))})))})]}),e(x,{condition:u.length===0,show:e(ce,{children:"No invoices to show."})})]})},jt="api/admin/invoices",ai=se(jt),ao=(t={})=>{const n=()=>fetch(ai,{method:"GET"}).then(ke("Invoices")).then(h=>h.json()),{data:o,error:a}=xe(jt,n,t),[i,s]=d.useState(!a&&!o),u=()=>{vt(jt)};return d.useEffect(()=>{s(!a&&!o)},[o,a]),{invoices:(o==null?void 0:o.invoices)||[],error:a,loading:i,refetchInvoices:u}},ri=()=>{const{instanceStatus:t,isBilling:n,refetchInstanceStatus:o,refresh:a,loading:i}=Yt(),{invoices:s}=ao(),{hasAccess:u}=d.useContext(de);return d.useEffect(()=>{(async()=>{await a(),o()})()},[o,a]),e("div",{children:e(Q,{header:"Billing",isLoading:i,children:e(x,{condition:n,show:e(x,{condition:u(j),show:()=>r(z,{children:[e(ei,{instanceStatus:t}),e(oi,{data:s})]}),elseShow:()=>e(He,{})}),elseShow:e(W,{severity:"error",children:"Billing is not enabled for this instance."})})})})},ii=se("api/admin/invoices/portal"),si=()=>{const{refetchInvoices:t,invoices:n}=ao(),[o,a]=d.useState(!1),{locationSettings:i}=Gn();return d.useEffect(()=>{t(),a(!0)},[]),e(x,{condition:n.length>0,show:e(Q,{header:e(ne,{title:"Invoices",actions:e(M,{href:ii,rel:"noreferrer",target:"_blank",endIcon:e(_o,{}),children:"Billing portal"})}),children:e("div",{children:r(zt,{children:[e(jn,{children:r(je,{children:[e(re,{children:"Amount"}),e(re,{children:"Status"}),e(re,{children:"Due date"}),e(re,{children:"PDF"}),e(re,{children:"Link"})]})}),e(nt,{children:n.map(s=>r(je,{style:{backgroundColor:s.status==="past-due"?"#ff9194":"inherit"},children:[e(re,{style:{textAlign:"left"},children:s.amountFormatted}),e(re,{style:{textAlign:"left"},children:s.status}),e(re,{style:{textAlign:"left"},children:s.dueDate&&Fn(s.dueDate,i.locale)}),e(re,{style:{textAlign:"left"},children:e("a",{href:s.invoicePDF,children:"PDF"})}),e(re,{style:{textAlign:"left"},children:e("a",{href:s.invoiceURL,target:"_blank",rel:"noreferrer",children:"Payment link"})})]},s.invoiceURL))})]})})}),elseShow:e("div",{children:o&&"No invoices to show."})})},li=()=>{const{hasAccess:t}=d.useContext(de);return e("div",{children:e(x,{condition:t(j),show:e(si,{}),elseShow:e(W,{severity:"error",children:"You need to be instance admin to access this section."})})})},ci=()=>{const{uiConfig:t,loading:n}=q();return n?null:t.flags.UNLEASH_CLOUD?e(qo,{to:"/admin/billing",replace:!0}):e(li,{})},di=()=>r(W,{severity:"info",children:[r("p",{children:["Use this page to configure allowed CORS origins for the Frontend API (",e("code",{children:"/api/frontend"}),")."]}),r("p",{children:["This configuration will not affect the Admin API (",e("code",{children:"/api/admin"}),") nor the Client API (",e("code",{children:"/api/client"}),")."]}),r("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)."})]}),ui=()=>{const{makeRequest:t,createRequest:n,errors:o,loading:a}=_e({propagateErrors:!0});return{setFrontendSettings:async s=>{const h=n("api/admin/ui-config",{method:"POST",body:JSON.stringify({frontendSettings:{frontendApiOrigins:s}})},"setFrontendSettings");await t(h.caller,h.id)},loading:a,errors:o}},hi=({frontendApiOrigins:t})=>{const{setFrontendSettings:n}=ui(),{setToastData:o,setToastApiError:a}=Y(),[i,s]=d.useState(mn(t)),u=an(),h=an();return e("form",{onSubmit:async c=>{try{const p=pi(i);c.preventDefault(),await n(p),s(mn(p)),o({title:"Settings saved",type:"success"})}catch(p){a(V(p))}},children:r(O,{sx:{display:"grid",gap:1},children:[r("label",{htmlFor:u,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:"]}),r("code",{style:{fontSize:"0.7em"},children:["https://www.example.com",e("br",{}),"https://www.example2.com"]}),e(Z,{id:u,"aria-describedby":h,placeholder:mi,value:i,onChange:c=>s(c.target.value),multiline:!0,rows:12,variant:"outlined",fullWidth:!0,InputProps:{style:{fontFamily:"monospace",fontSize:"0.8em"}}}),e(Jt,{permission:j})]})})},pi=t=>t.split(/[,\n\s]+/).map(n=>n.replace(/\/$/,"")).filter(Boolean),mn=t=>(t==null?void 0:t.join(`
|
|
@@ -12,7 +12,7 @@ import{s as g,r as d,aB as wo,cI as xo,_ as ko,j as e,$ as An,cJ as on,cK as Rt,
|
|
|
12
12
|
--data-raw '${JSON.stringify(k(),void 0,2)}'`,H=()=>{h(Ce)},U=I=>I.length,D=I=>!(B!=null&&B.filter(G=>G.name===I&&G.id!==t).length),N=U(l)&&D(l);return e(Te,{loading:P,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:E,children:e(so,{name:l,description:p,mappingsSSO:y,users:f,setName:I=>{v(),D(I)||A({name:"A group with that name already exists."}),c(I)},setDescription:m,setMappingsSSO:S,setUsers:C,errors:T,handleSubmit:L,handleCancel:H,mode:Kt,children:e(M,{type:"submit",variant:"contained",color:"primary",disabled:!N,"data-testid":Mn,children:"Save"})})})},Ni=g(Hn)(({theme:t})=>({borderRadius:t.shape.borderRadiusLarge,padding:t.spacing(2.5,4),boxShadow:"none",marginBottom:t.spacing(2),fontSize:t.fontSizes.smallBody})),Oi=g("div")(({theme:t})=>({display:"flex",alignItems:"center",justifyContent:"space-between"})),$i=g("h1")(({theme:t})=>({fontSize:t.fontSizes.mainHeader})),Gi=g("div")(({theme:t})=>({display:"flex"})),ji=g("span")(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginLeft:t.spacing(1)})),Fi=({title:t,description:n,actions:o})=>(Nn(t),r(Ni,{children:[r(Oi,{children:[e($i,{children:t}),e(Gi,{children:o})]}),e(x,{condition:Boolean(n==null?void 0:n.length),show:r(z,{children:["Description:",e(ji,{children:n})]})})]})),lo=({open:t,setOpen:n,group:o})=>{const{refetchGroups:a}=Ke(),{removeGroup:i}=it(),{setToastData:s,setToastApiError:u}=Y(),h=ae();return e(oe,{open:t,primaryButtonText:"Delete group",secondaryButtonText:"Cancel",onClick:async()=>{try{await i(o.id),a(),n(!1),h("/admin/groups"),s({title:"Group removed successfully",type:"success"})}catch(c){u(V(c))}},onClose:()=>{n(!1)},title:"Delete group?",children:r(R,{children:["Do you really want to delete ",e("strong",{children:o.name}),"? Users who are granted access to projects only via this group will lose access to those projects."]})})},zi=g("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),Mi=g("p")(({theme:t})=>({color:t.palette.text.secondary,marginBottom:t.spacing(1)})),Hi=g("div")(()=>({marginTop:"auto",display:"flex",justifyContent:"flex-end"})),Wi=g(M)(({theme:t})=>({marginLeft:t.spacing(3)})),_i=g(O)(({theme:t})=>({marginTop:t.spacing(2)})),co=({open:t,setOpen:n,group:o})=>{const{refetchGroup:a}=wt(o.id),{refetchGroups:i}=Ke(),{updateGroup:s,loading:u}=it(),{setToastData:h,setToastApiError:l}=Y(),{uiConfig:c}=q(),{users:p,setUsers:m,getGroupPayload:y}=tn(o.name,o.description,o.mappingsSSO,o.users);return d.useEffect(()=>{m(o.users)},[o.users,t,m]),e(Wn,{open:t,onClose:()=>{n(!1)},label:"Edit users",children:e(Te,{loading:u,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 '${c.unleashUrl}/api/admin/groups/${o.id}' \\
|
|
13
13
|
--header 'Authorization: INSERT_API_KEY' \\
|
|
14
14
|
--header 'Content-Type: application/json' \\
|
|
15
|
-
--data-raw '${JSON.stringify(y(),void 0,2)}'`,children:r(zi,{onSubmit:async C=>{C.preventDefault();try{await s(o.id,y()),a(),i(),n(!1),h({title:"Group users saved successfully",type:"success"})}catch(k){l(V(k))}},children:[r("div",{children:[e(Mi,{children:"Edit users in this group"}),e(ro,{users:p,setUsers:m}),e(io,{users:p,setUsers:m})]}),e(Hi,{children:r(_i,{children:[e(M,{type:"submit",variant:"contained",color:"primary","data-testid":Mn,children:"Save"}),e(Wi,{onClick:()=>{n(!1)},children:"Cancel"})]})})]})})})},qi=({open:t,setOpen:n,user:o,group:a})=>{const{refetchGroup:i}=wt(a.id),{updateGroup:s}=it(),{setToastData:u,setToastApiError:h}=Y(),l=async()=>{try{const p={...a,users:a.users.filter(({id:m})=>m!==(o==null?void 0:o.id)).map(({id:m})=>({user:{id:m}}))};await s(a.id,p),i(),n(!1),u({title:"User removed from group successfully",type:"success"})}catch(p){h(V(p))}},c=(o==null?void 0:o.name)||(o==null?void 0:o.username)||(o==null?void 0:o.email);return e(oe,{open:t&&Boolean(o),primaryButtonText:"Remove user",secondaryButtonText:"Cancel",onClick:l,onClose:()=>{n(!1)},title:"Remove user from group?",children:r(R,{children:["Do you really want to remove ",e("strong",{children:c})," from"," ",e("strong",{children:a.name}),"? ",e("strong",{children:c})," will lose all access rights granted by this group."]})})},Vi=Array(15).fill({name:"Name of the user",username:"Username of the user"}),Yi={id:"joinedAt"},{value:fn,setValue:Ji}=ra("Group:v1",Yi),Ki=()=>{const t=Number(Ct("groupId")),n=Zt(),o=be(n.breakpoints.down("md")),{group:a,loading:i}=wt(t),[s,u]=d.useState(!1),[h,l]=d.useState(!1),[c,p]=d.useState(!1),[m,y]=d.useState(),S=d.useMemo(()=>[{Header:"Avatar",accessor:"imageUrl",Cell:({row:{original:D}})=>e(fe,{children:e(qe,{user:D})}),maxWidth:85,disableSortBy:!0},{id:"name",Header:"Name",accessor:D=>D.name||"",Cell:ge,minWidth:100,searchable:!0},{id:"username",Header:"Username",accessor:D=>D.username||D.email,Cell:ge,minWidth:100,searchable:!0},{Header:"Joined",accessor:"joinedAt",Cell:Fe,sortType:"date",maxWidth:150},{id:"createdBy",Header:"Added by",accessor:"createdBy",Cell:ge,minWidth:90,searchable:!0},{Header:"Last login",accessor:D=>D.seenAt||"",Cell:({row:{original:D}})=>e(ot,{value:D.seenAt,emptyText:"Never",title:N=>`Last login: ${N}`}),sortType:"date",maxWidth:150},{Header:"Actions",id:"Actions",align:"center",Cell:({row:{original:D}})=>e(St,{children:e(Se,{title:"Remove user from group",arrow:!0,describeChild:!0,children:e("span",{children:e(Re,{"data-testid":`${ia}-${D.id}`,onClick:()=>{y(D),p(!0)},children:e(Pe,{})})})})}),maxWidth:100,disableSortBy:!0}],[y,p]),[f,C]=_n(),[k]=d.useState(()=>({sortBy:[{id:f.get("sort")||fn.id,desc:f.has("order")?f.get("order")==="desc":fn.desc}],hiddenColumns:["description"],globalFilter:f.get("search")||""})),[v,T]=d.useState(k.globalFilter),{data:A,getSearchText:B,getSearchContext:w}=Xt(S,v,(a==null?void 0:a.users)??[]),P=d.useMemo(()=>(A==null?void 0:A.length)===0&&i?Vi:A,[A,i]),{headerGroups:L,rows:E,prepareRow:H,state:{sortBy:U}}=_.useTable({columns:S,data:P,initialState:k,sortTypes:Ne,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},_.useSortBy,_.useFlexLayout);return d.useEffect(()=>{const D={};D.sort=U[0].id,U[0].desc&&(D.order="desc"),v&&(D.search=v),C(D,{replace:!0}),Ji({id:U[0].id,desc:U[0].desc||!1})},[U,v,C]),e(x,{condition:Boolean(a),show:r(z,{children:[e(Fi,{title:a==null?void 0:a.name,description:a==null?void 0:a.description,actions:r(z,{children:[e(Ee,{"data-testid":sa,to:`/admin/groups/${t}/edit`,component:De,"data-loading":!0,permission:j,tooltipProps:{title:"Edit group"},children:e(rt,{})}),e(Ee,{"data-testid":la,"data-loading":!0,onClick:()=>u(!0),permission:j,tooltipProps:{title:"Delete group"},children:e(Pe,{})})]})}),r(Q,{isLoading:i,header:e(ne,{secondary:!0,title:`Users (${E.length<P.length?`${E.length} of ${P.length}`:P.length})`,actions:r(z,{children:[e(x,{condition:!o,show:r(z,{children:[e(ve,{initialValue:v,onChange:T,hasFilters:!0,getSearchContext:w}),e(ne.Divider,{})]})}),e(Ft,{"data-testid":ca,onClick:()=>{l(!0)},maxWidth:"700px",Icon:bt,permission:j,children:"Edit users"})]}),children:e(x,{condition:o,show:e(ve,{initialValue:v,onChange:T,hasFilters:!0,getSearchContext:w})})}),children:[e(Me,{value:B(v),children:e(at,{rows:E,headerGroups:L,prepareRow:H})}),e(x,{condition:E.length===0,show:e(x,{condition:(v==null?void 0:v.length)>0,show:r(ce,{children:["No users found matching “",v,"” in this group."]}),elseShow:e(ce,{children:"This group is empty. Get started by adding a user to the group."})})}),e(lo,{open:s,setOpen:u,group:a}),e(co,{open:h,setOpen:l,group:a}),e(qi,{open:c,setOpen:p,user:m,group:a})]})]})})},Zi=g(qn)(({theme:t})=>({pointerEvents:"none",".MuiPaper-root":{padding:t.spacing(2)}})),Xi=g("div")(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(1)})),Qi=({user:t,open:n,anchorEl:o,onPopoverClose:a})=>r(Zi,{open:n,anchorEl:o,onClose:a,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},children:[e(Xi,{children:(t==null?void 0:t.name)||(t==null?void 0:t.username)}),e("div",{children:t==null?void 0:t.email})]}),es=g("div")(({theme:t})=>({display:"inline-flex",alignItems:"center",flexWrap:"wrap",marginLeft:t.spacing(1)})),yn=g(qe)(({theme:t})=>({outline:`${t.spacing(.25)} solid ${t.palette.background.paper}`,marginLeft:t.spacing(-1),"&:hover":{outlineColor:t.palette.primary.main}})),ts=({users:t})=>{const n=d.useMemo(()=>t.sort((c,p)=>(p==null?void 0:p.joinedAt.getTime())-(c==null?void 0:c.joinedAt.getTime())).slice(0,9),[t]),[o,a]=d.useState(null),[i,s]=d.useState(),u=c=>{a(c.currentTarget)},h=()=>{a(null)},l=Boolean(o);return r(es,{children:[n.map(c=>e(yn,{user:c,onMouseEnter:p=>{u(p),s(c)},onMouseLeave:h},c.id)),e(x,{condition:t.length>9,show:r(yn,{children:["+",t.length-n.length]})}),e(Qi,{open:l,user:i,anchorEl:o,onPopoverClose:h})]})},ns=g("div")(({theme:t})=>({display:"flex",justifyContent:"center",transform:"translate3d(8px, -6px, 0)"})),os=g(qn)(({theme:t})=>({borderRadius:t.shape.borderRadiusLarge,padding:t.spacing(1,1.5)})),as=({groupId:t,onEditUsers:n,onRemove:o})=>{const[a,i]=d.useState(null),s=Boolean(a),u=p=>{i(p.currentTarget)},h=()=>{i(null)},l=`feature-${t}-actions`,c=`${l}-menu`;return r(ns,{onClick:p=>{p.preventDefault(),p.stopPropagation()},children:[e(Se,{title:"Group actions",arrow:!0,describeChild:!0,children:e(Re,{id:l,"aria-controls":s?c:void 0,"aria-haspopup":"true","aria-expanded":s?"true":void 0,onClick:u,type:"button",children:e(Qa,{})})}),e(os,{id:c,anchorEl:a,open:s,onClose:h,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,children:r(da,{"aria-labelledby":l,children:[r(Ve,{onClick:h,component:De,to:`/admin/groups/${t}/edit`,children:[e(Ut,{children:e(rt,{})}),e(Lt,{children:e(R,{variant:"body2",children:"Edit group"})})]}),r(Ve,{onClick:()=>{n(),h()},children:[e(Ut,{children:e(Ka,{})}),e(Lt,{children:e(R,{variant:"body2",children:"Edit group users"})})]}),r(Ve,{onClick:()=>{o(),h()},children:[e(Ut,{children:e(Pe,{})}),e(Lt,{children:e(R,{variant:"body2",children:"Delete group"})})]})]})})]})},rs=g(De)(({theme:t})=>({textDecoration:"none",color:t.palette.text.primary})),is=g("aside")(({theme:t})=>({padding:t.spacing(2.5),height:"100%",border:`1px solid ${t.palette.dividerAlternative}`,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}})),uo=g("div")(()=>({display:"flex",alignItems:"center",justifyContent:"space-between"})),ss=g(uo)(()=>({alignItems:"flex-start"})),ls=g(uo)(()=>({marginTop:"auto"})),cs=g("h2")(({theme:t})=>({fontSize:t.fontSizes.mainHeader,fontWeight:t.fontWeight.medium})),ds=g("div")(({theme:t})=>({display:"flex",alignItems:"center",color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody})),us=g("p")(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(1),marginBottom:t.spacing(4)})),hs=g("span")(({theme:t})=>({color:t.palette.text.secondary,marginLeft:t.spacing(1)})),ps=g("div")(({theme:t})=>({maxWidth:"50%",display:"flex",justifyContent:"flex-end",gap:t.spacing(.5),flexWrap:"wrap"})),ms=({group:t,onEditUsers:n,onRemoveGroup:o})=>{var i;const a=ae();return e(z,{children:e(rs,{to:`/admin/groups/${t.id}`,children:r(is,{children:[r(ss,{children:[e(cs,{children:t.name}),e(ds,{children:e(as,{groupId:t.id,onEditUsers:()=>n(t),onRemove:()=>o(t)})})]}),e(us,{children:t.description}),r(ls,{children:[e(x,{condition:((i=t.users)==null?void 0:i.length)>0,show:e(ts,{users:t.users}),elseShow:e(hs,{children:"This group has no users."})}),e(ps,{children:e(x,{condition:t.projects.length>0,show:t.projects.map(s=>e(Se,{title:"View project",arrow:!0,placement:"bottom-end",describeChild:!0,children:e(Gt,{onClick:u=>{u.preventDefault(),a(`/projects/${s}/settings/access`)},color:"secondary",icon:e(ua,{}),children:s})},s)),elseShow:e(Se,{title:"This group is not used in any project",arrow:!0,describeChild:!0,children:e(Gt,{children:"Not used"})})})})]})]})},t.id)})},gs=()=>{const t=g("div")(({theme:o})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:o.spacing(6),marginLeft:"auto",marginRight:"auto"})),n=g(R)(({theme:o})=>({fontSize:o.fontSizes.bodySize,marginBottom:o.spacing(2.5)}));return r(t,{children:[e(n,{children:"No groups available. Get started by adding a new group."}),e(M,{to:"/admin/groups/create-group",component:De,variant:"outlined",color:"secondary",children:"Create your first group"})]})},fs=(t,n)=>{var i,s,u,h,l,c;const o=n.toLowerCase(),a={names:(i=t.users)==null?void 0:i.map(p=>{var m;return((m=p.name)==null?void 0:m.toLowerCase())||""}),usernames:(s=t.users)==null?void 0:s.map(p=>{var m;return((m=p.username)==null?void 0:m.toLowerCase())||""}),emails:(u=t.users)==null?void 0:u.map(p=>{var m;return((m=p.email)==null?void 0:m.toLowerCase())||""})};return t.name.toLowerCase().includes(o)||t.description.toLowerCase().includes(o)||((h=a.names)==null?void 0:h.some(p=>p.includes(o)))||((l=a.usernames)==null?void 0:l.some(p=>p.includes(o)))||((c=a.emails)==null?void 0:c.some(p=>p.includes(o)))},ys=()=>{const t=ae(),[n,o]=d.useState(!1),[a,i]=d.useState(!1),[s,u]=d.useState(void 0),{groups:h=[],loading:l}=Ke(),[c,p]=_n(),[m,y]=d.useState(c.get("search")||""),S=be(Be.breakpoints.down("md"));d.useEffect(()=>{const v={};m&&(v.search=m),p(v,{replace:!0})},[m,p]);const f=d.useMemo(()=>{const v=h.sort((T,A)=>T.name.localeCompare(A.name));return m?v.filter(T=>fs(T,m)):v},[h,m]),C=v=>{u(v),o(!0)},k=v=>{u(v),i(!0)};return r(Q,{isLoading:l,header:e(ne,{title:`Groups (${f.length})`,actions:r(z,{children:[e(x,{condition:!S,show:r(z,{children:[e(ve,{initialValue:m,onChange:y}),e(ne.Divider,{})]})}),e(Ft,{onClick:()=>t("/admin/groups/create-group"),maxWidth:"700px",Icon:bt,permission:j,"data-testid":ha,children:"New group"})]}),children:e(x,{condition:S,show:e(ve,{initialValue:m,onChange:y})})}),children:[e(Me,{value:m,children:e(b,{container:!0,spacing:2,children:f.map(v=>e(b,{item:!0,xs:12,md:6,children:e(ms,{group:v,onEditUsers:C,onRemoveGroup:k})},v.id))})}),e(x,{condition:!l&&f.length===0,show:e(x,{condition:(m==null?void 0:m.length)>0,show:r(ce,{children:["No groups found matching “",m,"”"]}),elseShow:e(gs,{})})}),e(x,{condition:Boolean(s),show:e(co,{open:n,setOpen:o,group:s})}),e(x,{condition:Boolean(s),show:e(lo,{open:a,setOpen:i,group:s})})]})},bs=()=>e("div",{children:e(ys,{})}),Ss=()=>{const{data:t,error:n,mutate:o}=xe(se("api/admin/instance-admin/statistics"),vs);return d.useMemo(()=>({stats:t,loading:!n&&!t,refetchGroup:()=>o(),error:n}),[t,n,o])},vs=t=>fetch(t).then(ke("Instance Stats")).then(n=>n.json()),Cs=()=>{const{stats:t}=Ss();let n,o;t!=null&&t.versionEnterprise?(n="Unleash Enterprise version",o=t.versionEnterprise):(n="Unleash OSS version",o=t==null?void 0:t.versionOSS);const a=[{title:"Instance Id",value:t==null?void 0:t.instanceId},{title:n,value:o},{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}];return t!=null&&t.versionEnterprise&&a.push({title:"SAML enabled",value:t!=null&&t.SAMLenabled?"Yes":"No"},{title:"OIDC enabled",value:t!=null&&t.OIDCenabled?"Yes":"No"}),e(Q,{header:e(ne,{title:"Instance Statistics"}),children:r(Ga,{sx:{display:"grid",gap:4},children:[r(zt,{"aria-label":"Instance statistics",children:[e(jn,{children:r(je,{children:[e(re,{children:"Field"}),e(re,{align:"right",children:"Value"})]})}),e(nt,{children:a.map(i=>r(je,{children:[e(re,{component:"th",scope:"row",children:i.title}),e(re,{align:"right",children:i.value})]},i.title))})]}),e("span",{style:{textAlign:"center"},children:e(M,{startIcon:e(Ja,{}),"aria-label":"Download instance statistics",color:"primary",variant:"contained",target:"_blank",href:se("/api/admin/instance-admin/statistics/csv"),children:"Download"})})]})})},ws=()=>e("div",{children:e(Cs,{})}),xs=()=>e(W,{severity:"warning",children:r("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."]})}),ks=()=>{const{data:t,error:n,mutate:o}=xe(se("api/admin/maintenance"),Ts);return d.useMemo(()=>({enabled:Boolean(t==null?void 0:t.enabled),loading:!n&&!t,refetchMaintenance:o,error:n}),[t,n,o])},Ts=t=>fetch(t).then(ke("Maintenance")).then(n=>n.json()),As=()=>{const{makeRequest:t,createRequest:n,errors:o,loading:a}=_e({propagateErrors:!0});return{toggleMaintenance:async s=>{const h=n("api/admin/maintenance",{method:"POST",body:JSON.stringify(s)});try{await t(h.caller,h.id)}catch(l){throw l}},errors:o,loading:a}},Es=g("div")(({theme:t})=>({display:"flex",flexDirection:"column",padding:t.spacing(3),border:`1px solid ${t.palette.dividerAlternative}`,borderRadius:t.shape.borderRadiusLarge})),Ps=g(O)(({theme:t})=>({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"})),Ds=g(O)(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(2)})),Rs=g(R)(({theme:t})=>({fontSize:t.fontSizes.smallBody})),Is=()=>{const{enabled:t,refetchMaintenance:n}=ks(),{toggleMaintenance:o}=As(),{trackEvent:a}=Qt();return r(Es,{children:[r(Ps,{children:[e("b",{children:"Maintenance Mode"}),e(ie,{sx:{margin:0},control:e(we,{onChange:async()=>{a("maintenance",{props:{eventType:`maintenance ${t?"de":""}activated`}}),await o({enabled:!t}),n()},value:t,name:"enabled",checked:t}),label:e(Rs,{children:t?"Enabled":"Disabled"})})]}),e(Ds,{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."})]})},Us=()=>{const{hasAccess:t}=d.useContext(de);return e("div",{children:e(x,{condition:t(j),show:e(Bs,{}),elseShow:e(He,{})})})},Ls=g(O)(({theme:t})=>({display:"grid",gap:t.spacing(4)})),Bs=()=>{const{loading:t}=q();return t?null:e(Q,{header:e(ne,{title:"Maintenance"}),children:r(Ls,{children:[e(xs,{}),e(Is,{})]})})},Ns=t=>{const n={display:"flex",justifyContent:"center",alignItems:"center",width:"100%",textDecoration:"none",color:"inherit",padding:t.theme.spacing(1.5,3)},o={fontWeight:"bold",borderRadius:"3px",padding:t.theme.spacing(1.5,3)};return t.isActive?{...n,...o}:n},pe=({to:t,children:n})=>{const o=Zt();return e(pa,{to:t,style:({isActive:a})=>Ns({isActive:a,theme:o}),children:n})},Os=g(Hn)(({theme:t})=>({marginBottom:"1rem",borderRadius:"12.5px",boxShadow:"none",padding:"0 2rem"}));function $s(){const{uiConfig:t}=q(),{pathname:n}=Vn(),{isBilling:o}=Yt(),{flags:a}=t,i=n.split("/")[2];return e(Os,{children:r(Yn,{value:i,variant:"scrollable",scrollButtons:"auto",allowScrollButtonsMobile:!0,children:[e(he,{value:"users",label:e(pe,{to:"/admin/users",children:e("span",{children:"Users"})})}),a.serviceAccounts&&e(he,{value:"service-accounts",label:e(pe,{to:"/admin/service-accounts",children:e("span",{children:"Service accounts"})})}),a.UG&&e(he,{value:"groups",label:e(pe,{to:"/admin/groups",children:e("span",{children:"Groups"})})}),a.RE&&e(he,{value:"roles",label:e(pe,{to:"/admin/roles",children:e("span",{children:"Project roles"})})}),e(he,{value:"api",label:e(pe,{to:"/admin/api",children:"API access"})}),t.flags.embedProxyFrontend&&e(he,{value:"cors",label:e(pe,{to:"/admin/cors",children:"CORS origins"})}),e(he,{value:"auth",label:e(pe,{to:"/admin/auth",children:"Single sign-on"})}),e(he,{value:"instance",label:e(pe,{to:"/admin/instance",children:"Instance stats"})}),a.networkView&&e(he,{value:"network",label:e(pe,{to:"/admin/network",children:"Network"})}),a.maintenance&&e(he,{value:"maintenance",label:e(pe,{to:"/admin/maintenance",children:"Maintenance"})}),o&&e(he,{value:"billing",label:e(pe,{to:"/admin/billing",children:"Billing"})})]})})}const Gs=d.lazy(()=>import("./NetworkOverview-fa11486d.js")),js=d.lazy(()=>import("./NetworkTraffic-e401fa21.js")),Fs=g(Q)(()=>({".page-header":{padding:0}})),zs=[{label:"Overview",path:"/admin/network"},{label:"Traffic",path:"/admin/network/traffic"}],Ms=()=>{const{pathname:t}=Vn();return e("div",{children:e(Fs,{headerClass:"page-header",header:e(Yn,{value:t,indicatorColor:"primary",textColor:"primary",variant:"scrollable",allowScrollButtonsMobile:!0,children:zs.map(({label:n,path:o})=>e(he,{value:o,label:e(pe,{to:o,children:e("span",{children:n})})},n))}),children:r(Jn,{children:[e(J,{path:"traffic",element:e(js,{})}),e(J,{path:"*",element:e(Gs,{})})]})})})},Tt=()=>{const{makeRequest:t,createRequest:n,errors:o,loading:a}=_e({propagateErrors:!0});return{createRole:async l=>{const p=n("api/admin/roles",{method:"POST",body:JSON.stringify(l)});try{return await t(p.caller,p.id)}catch(m){throw m}},deleteRole:async l=>{const c=`api/admin/roles/${l}`,p=n(c,{method:"DELETE"});try{return await t(p.caller,p.id)}catch(m){throw m}},editRole:async(l,c)=>{const p=`api/admin/roles/${l}`,m=n(p,{method:"PUT",body:JSON.stringify(c)});try{return await t(m.caller,m.id)}catch(y){throw y}},validateRole:async l=>{const p=n("api/admin/roles/validate",{method:"POST",body:JSON.stringify(l)});try{return await t(p.caller,p.id)}catch(m){throw m}},errors:o,loading:a}},Hs=g(O)(({theme:t})=>({display:"flex",alignItems:"center",[t.breakpoints.down(500)]:{flexDirection:"column",alignItems:"flex-start"}})),Ws=g(ma)(({theme:t})=>({fontWeight:t.typography.fontWeightBold,marginRight:t.spacing(1)})),bn=({title:t,permissions:n,checkedPermissions:o,Icon:a,isInitiallyExpanded:i,context:s,onPermissionChange:u,onCheckAll:h,getRoleKey:l})=>{const[c,p]=d.useState(i),m=d.useMemo(()=>(n==null?void 0:n.reduce((f,C)=>(f[l(C)]=!0,f),{}))||{},[n]),y=d.useMemo(()=>Object.keys(o).filter(f=>m[f]).length||0,[o,m]),S=d.useMemo(()=>y===(n==null?void 0:n.length),[y,n]);return e(O,{sx:{my:2,pb:1},children:r(ga,{expanded:c,onChange:()=>p(!c),sx:{boxShadow:"none",px:3,py:1,border:f=>`1px solid ${f.palette.divider}`,borderRadius:f=>`${f.shape.borderRadiusLarge}px`},children:[e(fa,{expandIcon:e(Re,{children:e(ja,{titleAccess:"Toggle"})}),sx:{boxShadow:"none",padding:"0"},children:r(Hs,{children:[a,e(Ws,{text:t,maxWidth:"120",maxLength:25})," ",r(R,{variant:"body2",color:"text.secondary",children:["(",y," / ",n==null?void 0:n.length," ","permissions)"]})]})}),r(ya,{sx:{px:0,py:1,flexWrap:"wrap"},children:[e(Vt,{sx:{mb:1}}),r(M,{variant:"text",size:"small",onClick:h,sx:{fontWeight:f=>f.typography.fontWeightRegular},children:[S?"Unselect ":"Select ","all ",s," permissions"]}),e(O,{children:n==null?void 0:n.map(f=>e(ie,{sx:{minWidth:{sm:"300px",xs:"auto"}},control:e(zn,{checked:!!o[l(f)],onChange:()=>u(f),color:"primary"}),label:f.displayName},l(f)))})]})]})})},ho=({children:t,roleName:n,roleDesc:o,checkedPermissions:a,errors:i,permissions:s,onSubmit:u,onCancel:h,setRoleName:l,setRoleDesc:c,handlePermissionChange:p,checkAllProjectPermissions:m,checkAllEnvironmentPermissions:y,validateNameUniqueness:S,clearErrors:f,getRoleKey:C})=>{const{project:k,environments:v}=s;return r("form",{onSubmit:u,children:[r(O,{sx:{maxWidth:"400px"},children:[e(R,{sx:{mb:1},children:"What is your role name?"}),e(We,{label:"Role name",value:n,onChange:T=>l(T.target.value),error:Boolean(i.name),errorText:i.name,onFocus:()=>f(),onBlur:S,autoFocus:!0,sx:{width:"100%",marginBottom:"1rem"}}),e(R,{sx:{mb:1},children:"What is this role for?"}),e(Z,{label:"Role description",variant:"outlined",multiline:!0,maxRows:4,value:o,onChange:T=>c(T.target.value),sx:{width:"100%",marginBottom:"1rem"}})]}),e("div",{children:e(x,{condition:Boolean(i.permissions),show:e(R,{variant:"body2",color:"error.main",children:"You must select at least one permission for a role."})})}),e(bn,{isInitiallyExpanded:!0,title:"Project permissions",Icon:e(tr,{color:"disabled",sx:{mr:1}}),permissions:k,checkedPermissions:a,onPermissionChange:T=>p(T),onCheckAll:m,getRoleKey:C,context:"project"}),e("div",{children:v.map(T=>e(bn,{title:T.name,Icon:e(ba,{sx:{mr:1},color:"disabled"}),permissions:T.permissions,checkedPermissions:a,onPermissionChange:A=>p(A),onCheckAll:()=>y(T.name),getRoleKey:C,context:"environment"},T.name))}),r(O,{sx:{marginTop:"auto",display:"flex",justifyContent:"flex-end"},children:[t,e(M,{onClick:h,sx:{marginLeft:2},children:"Cancel"})]})]})},ye=t=>t.environment?`${t.id}-${t.environment}`:`${t.id}`,po=(t="",n="",o=[])=>{q();const{permissions:a}=Sa({revalidateIfStale:!1,revalidateOnReconnect:!1,revalidateOnFocus:!1}),[i,s]=d.useState(t),[u,h]=d.useState(n),[l,c]=d.useState({});d.useEffect(()=>{o.length>0&&c(o==null?void 0:o.reduce((w,P)=>(w[ye(P)]=P,w),{}))},[o==null?void 0:o.length]);const[p,m]=d.useState({}),{validateRole:y}=Tt();d.useEffect(()=>{s(t)},[t]),d.useEffect(()=>{h(n)},[n]);const S=w=>{let P=Bt(l);P[ye(w)]?delete P[ye(w)]:P[ye(w)]={...w},c(P)},f=()=>{const{project:w}=a;let P=Bt(l);w.every(E=>P[ye(E)])?w.forEach(E=>{delete P[ye(E)]}):w.forEach(E=>{P[ye(E)]={...E}}),c(P)},C=w=>{const{environments:P}=a,L=Bt(l),E=P.find(U=>U.name===w);if(!E)return;E.permissions.every(U=>L[ye(U)])?E.permissions.forEach(U=>{delete L[ye(U)]}):E.permissions.forEach(U=>{L[ye(U)]={...U}}),c(L)},k=()=>({name:i,description:u,permissions:Object.values(l)});return{roleName:i,roleDesc:u,errors:p,checkedPermissions:l,permissions:a,setRoleName:s,setRoleDesc:h,handlePermissionChange:S,onToggleAllProjectPermissions:f,onToggleAllEnvironmentPermissions:C,getProjectRolePayload:k,validatePermissions:()=>Object.keys(l).length===0?(m(w=>({...w,permissions:"You must include at least one permission."})),!1):!0,validateName:()=>i.length===0?(m(w=>({...w,name:"Name can not be empty."})),!1):!0,clearErrors:()=>{m({})},validateNameUniqueness:async()=>{const w=k();try{await y(w)}catch(P){m(L=>({...L,name:V(P)}))}},getRoleKey:ye}},_s=()=>{const{setToastData:t,setToastApiError:n}=Y(),{uiConfig:o}=q(),a=ae(),{roleName:i,roleDesc:s,permissions:u,checkedPermissions:h,errors:l,setRoleName:c,setRoleDesc:p,handlePermissionChange:m,onToggleAllProjectPermissions:y,onToggleAllEnvironmentPermissions:S,getProjectRolePayload:f,validatePermissions:C,validateName:k,validateNameUniqueness:v,clearErrors:T,getRoleKey:A}=po(),{createRole:B,loading:w}=Tt();return e(Te,{loading:w,title:"Create project role",description:`A project role can be
|
|
15
|
+
--data-raw '${JSON.stringify(y(),void 0,2)}'`,children:r(zi,{onSubmit:async C=>{C.preventDefault();try{await s(o.id,y()),a(),i(),n(!1),h({title:"Group users saved successfully",type:"success"})}catch(k){l(V(k))}},children:[r("div",{children:[e(Mi,{children:"Edit users in this group"}),e(ro,{users:p,setUsers:m}),e(io,{users:p,setUsers:m})]}),e(Hi,{children:r(_i,{children:[e(M,{type:"submit",variant:"contained",color:"primary","data-testid":Mn,children:"Save"}),e(Wi,{onClick:()=>{n(!1)},children:"Cancel"})]})})]})})})},qi=({open:t,setOpen:n,user:o,group:a})=>{const{refetchGroup:i}=wt(a.id),{updateGroup:s}=it(),{setToastData:u,setToastApiError:h}=Y(),l=async()=>{try{const p={...a,users:a.users.filter(({id:m})=>m!==(o==null?void 0:o.id)).map(({id:m})=>({user:{id:m}}))};await s(a.id,p),i(),n(!1),u({title:"User removed from group successfully",type:"success"})}catch(p){h(V(p))}},c=(o==null?void 0:o.name)||(o==null?void 0:o.username)||(o==null?void 0:o.email);return e(oe,{open:t&&Boolean(o),primaryButtonText:"Remove user",secondaryButtonText:"Cancel",onClick:l,onClose:()=>{n(!1)},title:"Remove user from group?",children:r(R,{children:["Do you really want to remove ",e("strong",{children:c})," from"," ",e("strong",{children:a.name}),"? ",e("strong",{children:c})," will lose all access rights granted by this group."]})})},Vi=Array(15).fill({name:"Name of the user",username:"Username of the user"}),Yi={id:"joinedAt"},{value:fn,setValue:Ji}=ra("Group:v1",Yi),Ki=()=>{const t=Number(Ct("groupId")),n=Zt(),o=be(n.breakpoints.down("md")),{group:a,loading:i}=wt(t),[s,u]=d.useState(!1),[h,l]=d.useState(!1),[c,p]=d.useState(!1),[m,y]=d.useState(),S=d.useMemo(()=>[{Header:"Avatar",accessor:"imageUrl",Cell:({row:{original:D}})=>e(fe,{children:e(qe,{user:D})}),maxWidth:85,disableSortBy:!0},{id:"name",Header:"Name",accessor:D=>D.name||"",Cell:ge,minWidth:100,searchable:!0},{id:"username",Header:"Username",accessor:D=>D.username||D.email,Cell:ge,minWidth:100,searchable:!0},{Header:"Joined",accessor:"joinedAt",Cell:Fe,sortType:"date",maxWidth:150},{id:"createdBy",Header:"Added by",accessor:"createdBy",Cell:ge,minWidth:90,searchable:!0},{Header:"Last login",accessor:D=>D.seenAt||"",Cell:({row:{original:D}})=>e(ot,{value:D.seenAt,emptyText:"Never",title:N=>`Last login: ${N}`}),sortType:"date",maxWidth:150},{Header:"Actions",id:"Actions",align:"center",Cell:({row:{original:D}})=>e(St,{children:e(Se,{title:"Remove user from group",arrow:!0,describeChild:!0,children:e("span",{children:e(Re,{"data-testid":`${ia}-${D.id}`,onClick:()=>{y(D),p(!0)},children:e(Pe,{})})})})}),maxWidth:100,disableSortBy:!0}],[y,p]),[f,C]=_n(),[k]=d.useState(()=>({sortBy:[{id:f.get("sort")||fn.id,desc:f.has("order")?f.get("order")==="desc":fn.desc}],hiddenColumns:["description"],globalFilter:f.get("search")||""})),[v,T]=d.useState(k.globalFilter),{data:A,getSearchText:B,getSearchContext:w}=Xt(S,v,(a==null?void 0:a.users)??[]),P=d.useMemo(()=>(A==null?void 0:A.length)===0&&i?Vi:A,[A,i]),{headerGroups:L,rows:E,prepareRow:H,state:{sortBy:U}}=_.useTable({columns:S,data:P,initialState:k,sortTypes:Ne,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},_.useSortBy,_.useFlexLayout);return d.useEffect(()=>{const D={};D.sort=U[0].id,U[0].desc&&(D.order="desc"),v&&(D.search=v),C(D,{replace:!0}),Ji({id:U[0].id,desc:U[0].desc||!1})},[U,v,C]),e(x,{condition:Boolean(a),show:r(z,{children:[e(Fi,{title:a==null?void 0:a.name,description:a==null?void 0:a.description,actions:r(z,{children:[e(Ee,{"data-testid":sa,to:`/admin/groups/${t}/edit`,component:De,"data-loading":!0,permission:j,tooltipProps:{title:"Edit group"},children:e(rt,{})}),e(Ee,{"data-testid":la,"data-loading":!0,onClick:()=>u(!0),permission:j,tooltipProps:{title:"Delete group"},children:e(Pe,{})})]})}),r(Q,{isLoading:i,header:e(ne,{secondary:!0,title:`Users (${E.length<P.length?`${E.length} of ${P.length}`:P.length})`,actions:r(z,{children:[e(x,{condition:!o,show:r(z,{children:[e(ve,{initialValue:v,onChange:T,hasFilters:!0,getSearchContext:w}),e(ne.Divider,{})]})}),e(Ft,{"data-testid":ca,onClick:()=>{l(!0)},maxWidth:"700px",Icon:bt,permission:j,children:"Edit users"})]}),children:e(x,{condition:o,show:e(ve,{initialValue:v,onChange:T,hasFilters:!0,getSearchContext:w})})}),children:[e(Me,{value:B(v),children:e(at,{rows:E,headerGroups:L,prepareRow:H})}),e(x,{condition:E.length===0,show:e(x,{condition:(v==null?void 0:v.length)>0,show:r(ce,{children:["No users found matching “",v,"” in this group."]}),elseShow:e(ce,{children:"This group is empty. Get started by adding a user to the group."})})}),e(lo,{open:s,setOpen:u,group:a}),e(co,{open:h,setOpen:l,group:a}),e(qi,{open:c,setOpen:p,user:m,group:a})]})]})})},Zi=g(qn)(({theme:t})=>({pointerEvents:"none",".MuiPaper-root":{padding:t.spacing(2)}})),Xi=g("div")(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(1)})),Qi=({user:t,open:n,anchorEl:o,onPopoverClose:a})=>r(Zi,{open:n,anchorEl:o,onClose:a,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},children:[e(Xi,{children:(t==null?void 0:t.name)||(t==null?void 0:t.username)}),e("div",{children:t==null?void 0:t.email})]}),es=g("div")(({theme:t})=>({display:"inline-flex",alignItems:"center",flexWrap:"wrap",marginLeft:t.spacing(1)})),yn=g(qe)(({theme:t})=>({outline:`${t.spacing(.25)} solid ${t.palette.background.paper}`,marginLeft:t.spacing(-1),"&:hover":{outlineColor:t.palette.primary.main}})),ts=({users:t})=>{const n=d.useMemo(()=>t.sort((c,p)=>(p==null?void 0:p.joinedAt.getTime())-(c==null?void 0:c.joinedAt.getTime())).slice(0,9),[t]),[o,a]=d.useState(null),[i,s]=d.useState(),u=c=>{a(c.currentTarget)},h=()=>{a(null)},l=Boolean(o);return r(es,{children:[n.map(c=>e(yn,{user:c,onMouseEnter:p=>{u(p),s(c)},onMouseLeave:h},c.id)),e(x,{condition:t.length>9,show:r(yn,{children:["+",t.length-n.length]})}),e(Qi,{open:l,user:i,anchorEl:o,onPopoverClose:h})]})},ns=g("div")(({theme:t})=>({display:"flex",justifyContent:"center",transform:"translate3d(8px, -6px, 0)"})),os=g(qn)(({theme:t})=>({borderRadius:t.shape.borderRadiusLarge,padding:t.spacing(1,1.5)})),as=({groupId:t,onEditUsers:n,onRemove:o})=>{const[a,i]=d.useState(null),s=Boolean(a),u=p=>{i(p.currentTarget)},h=()=>{i(null)},l=`feature-${t}-actions`,c=`${l}-menu`;return r(ns,{onClick:p=>{p.preventDefault(),p.stopPropagation()},children:[e(Se,{title:"Group actions",arrow:!0,describeChild:!0,children:e(Re,{id:l,"aria-controls":s?c:void 0,"aria-haspopup":"true","aria-expanded":s?"true":void 0,onClick:u,type:"button",children:e(Qa,{})})}),e(os,{id:c,anchorEl:a,open:s,onClose:h,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,children:r(da,{"aria-labelledby":l,children:[r(Ve,{onClick:h,component:De,to:`/admin/groups/${t}/edit`,children:[e(Ut,{children:e(rt,{})}),e(Lt,{children:e(R,{variant:"body2",children:"Edit group"})})]}),r(Ve,{onClick:()=>{n(),h()},children:[e(Ut,{children:e(Ka,{})}),e(Lt,{children:e(R,{variant:"body2",children:"Edit group users"})})]}),r(Ve,{onClick:()=>{o(),h()},children:[e(Ut,{children:e(Pe,{})}),e(Lt,{children:e(R,{variant:"body2",children:"Delete group"})})]})]})})]})},rs=g(De)(({theme:t})=>({textDecoration:"none",color:t.palette.text.primary})),is=g("aside")(({theme:t})=>({padding:t.spacing(2.5),height:"100%",border:`1px solid ${t.palette.dividerAlternative}`,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}})),uo=g("div")(()=>({display:"flex",alignItems:"center",justifyContent:"space-between"})),ss=g(uo)(()=>({alignItems:"flex-start"})),ls=g(uo)(()=>({marginTop:"auto"})),cs=g("h2")(({theme:t})=>({fontSize:t.fontSizes.mainHeader,fontWeight:t.fontWeight.medium})),ds=g("div")(({theme:t})=>({display:"flex",alignItems:"center",color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody})),us=g("p")(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(1),marginBottom:t.spacing(4)})),hs=g("span")(({theme:t})=>({color:t.palette.text.secondary,marginLeft:t.spacing(1)})),ps=g("div")(({theme:t})=>({maxWidth:"50%",display:"flex",justifyContent:"flex-end",gap:t.spacing(.5),flexWrap:"wrap"})),ms=({group:t,onEditUsers:n,onRemoveGroup:o})=>{var i;const a=ae();return e(z,{children:e(rs,{to:`/admin/groups/${t.id}`,children:r(is,{children:[r(ss,{children:[e(cs,{children:t.name}),e(ds,{children:e(as,{groupId:t.id,onEditUsers:()=>n(t),onRemove:()=>o(t)})})]}),e(us,{children:t.description}),r(ls,{children:[e(x,{condition:((i=t.users)==null?void 0:i.length)>0,show:e(ts,{users:t.users}),elseShow:e(hs,{children:"This group has no users."})}),e(ps,{children:e(x,{condition:t.projects.length>0,show:t.projects.map(s=>e(Se,{title:"View project",arrow:!0,placement:"bottom-end",describeChild:!0,children:e(Gt,{onClick:u=>{u.preventDefault(),a(`/projects/${s}/settings/access`)},color:"secondary",icon:e(ua,{}),children:s})},s)),elseShow:e(Se,{title:"This group is not used in any project",arrow:!0,describeChild:!0,children:e(Gt,{children:"Not used"})})})})]})]})},t.id)})},gs=()=>{const t=g("div")(({theme:o})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:o.spacing(6),marginLeft:"auto",marginRight:"auto"})),n=g(R)(({theme:o})=>({fontSize:o.fontSizes.bodySize,marginBottom:o.spacing(2.5)}));return r(t,{children:[e(n,{children:"No groups available. Get started by adding a new group."}),e(M,{to:"/admin/groups/create-group",component:De,variant:"outlined",color:"secondary",children:"Create your first group"})]})},fs=(t,n)=>{var i,s,u,h,l,c;const o=n.toLowerCase(),a={names:(i=t.users)==null?void 0:i.map(p=>{var m;return((m=p.name)==null?void 0:m.toLowerCase())||""}),usernames:(s=t.users)==null?void 0:s.map(p=>{var m;return((m=p.username)==null?void 0:m.toLowerCase())||""}),emails:(u=t.users)==null?void 0:u.map(p=>{var m;return((m=p.email)==null?void 0:m.toLowerCase())||""})};return t.name.toLowerCase().includes(o)||t.description.toLowerCase().includes(o)||((h=a.names)==null?void 0:h.some(p=>p.includes(o)))||((l=a.usernames)==null?void 0:l.some(p=>p.includes(o)))||((c=a.emails)==null?void 0:c.some(p=>p.includes(o)))},ys=()=>{const t=ae(),[n,o]=d.useState(!1),[a,i]=d.useState(!1),[s,u]=d.useState(void 0),{groups:h=[],loading:l}=Ke(),[c,p]=_n(),[m,y]=d.useState(c.get("search")||""),S=be(Be.breakpoints.down("md"));d.useEffect(()=>{const v={};m&&(v.search=m),p(v,{replace:!0})},[m,p]);const f=d.useMemo(()=>{const v=h.sort((T,A)=>T.name.localeCompare(A.name));return m?v.filter(T=>fs(T,m)):v},[h,m]),C=v=>{u(v),o(!0)},k=v=>{u(v),i(!0)};return r(Q,{isLoading:l,header:e(ne,{title:`Groups (${f.length})`,actions:r(z,{children:[e(x,{condition:!S,show:r(z,{children:[e(ve,{initialValue:m,onChange:y}),e(ne.Divider,{})]})}),e(Ft,{onClick:()=>t("/admin/groups/create-group"),maxWidth:"700px",Icon:bt,permission:j,"data-testid":ha,children:"New group"})]}),children:e(x,{condition:S,show:e(ve,{initialValue:m,onChange:y})})}),children:[e(Me,{value:m,children:e(b,{container:!0,spacing:2,children:f.map(v=>e(b,{item:!0,xs:12,md:6,children:e(ms,{group:v,onEditUsers:C,onRemoveGroup:k})},v.id))})}),e(x,{condition:!l&&f.length===0,show:e(x,{condition:(m==null?void 0:m.length)>0,show:r(ce,{children:["No groups found matching “",m,"”"]}),elseShow:e(gs,{})})}),e(x,{condition:Boolean(s),show:e(co,{open:n,setOpen:o,group:s})}),e(x,{condition:Boolean(s),show:e(lo,{open:a,setOpen:i,group:s})})]})},bs=()=>e("div",{children:e(ys,{})}),Ss=()=>{const{data:t,error:n,mutate:o}=xe(se("api/admin/instance-admin/statistics"),vs);return d.useMemo(()=>({stats:t,loading:!n&&!t,refetchGroup:()=>o(),error:n}),[t,n,o])},vs=t=>fetch(t).then(ke("Instance Stats")).then(n=>n.json()),Cs=()=>{const{stats:t}=Ss();let n,o;t!=null&&t.versionEnterprise?(n="Unleash Enterprise version",o=t.versionEnterprise):(n="Unleash OSS version",o=t==null?void 0:t.versionOSS);const a=[{title:"Instance Id",value:t==null?void 0:t.instanceId},{title:n,value:o},{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}];return t!=null&&t.versionEnterprise&&a.push({title:"SAML enabled",value:t!=null&&t.SAMLenabled?"Yes":"No"},{title:"OIDC enabled",value:t!=null&&t.OIDCenabled?"Yes":"No"}),e(Q,{header:e(ne,{title:"Instance Statistics"}),children:r(Ga,{sx:{display:"grid",gap:4},children:[r(zt,{"aria-label":"Instance statistics",children:[e(jn,{children:r(je,{children:[e(re,{children:"Field"}),e(re,{align:"right",children:"Value"})]})}),e(nt,{children:a.map(i=>r(je,{children:[e(re,{component:"th",scope:"row",children:i.title}),e(re,{align:"right",children:i.value})]},i.title))})]}),e("span",{style:{textAlign:"center"},children:e(M,{startIcon:e(Ja,{}),"aria-label":"Download instance statistics",color:"primary",variant:"contained",target:"_blank",href:se("/api/admin/instance-admin/statistics/csv"),children:"Download"})})]})})},ws=()=>e("div",{children:e(Cs,{})}),xs=()=>e(W,{severity:"warning",children:r("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."]})}),ks=()=>{const{data:t,error:n,mutate:o}=xe(se("api/admin/maintenance"),Ts);return d.useMemo(()=>({enabled:Boolean(t==null?void 0:t.enabled),loading:!n&&!t,refetchMaintenance:o,error:n}),[t,n,o])},Ts=t=>fetch(t).then(ke("Maintenance")).then(n=>n.json()),As=()=>{const{makeRequest:t,createRequest:n,errors:o,loading:a}=_e({propagateErrors:!0});return{toggleMaintenance:async s=>{const h=n("api/admin/maintenance",{method:"POST",body:JSON.stringify(s)});try{await t(h.caller,h.id)}catch(l){throw l}},errors:o,loading:a}},Es=g("div")(({theme:t})=>({display:"flex",flexDirection:"column",padding:t.spacing(3),border:`1px solid ${t.palette.dividerAlternative}`,borderRadius:t.shape.borderRadiusLarge})),Ps=g(O)(({theme:t})=>({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"})),Ds=g(O)(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(2)})),Rs=g(R)(({theme:t})=>({fontSize:t.fontSizes.smallBody})),Is=()=>{const{enabled:t,refetchMaintenance:n}=ks(),{toggleMaintenance:o}=As(),{trackEvent:a}=Qt();return r(Es,{children:[r(Ps,{children:[e("b",{children:"Maintenance Mode"}),e(ie,{sx:{margin:0},control:e(we,{onChange:async()=>{a("maintenance",{props:{eventType:`maintenance ${t?"de":""}activated`}}),await o({enabled:!t}),n()},value:t,name:"enabled",checked:t}),label:e(Rs,{children:t?"Enabled":"Disabled"})})]}),e(Ds,{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."})]})},Us=()=>{const{hasAccess:t}=d.useContext(de);return e("div",{children:e(x,{condition:t(j),show:e(Bs,{}),elseShow:e(He,{})})})},Ls=g(O)(({theme:t})=>({display:"grid",gap:t.spacing(4)})),Bs=()=>{const{loading:t}=q();return t?null:e(Q,{header:e(ne,{title:"Maintenance"}),children:r(Ls,{children:[e(xs,{}),e(Is,{})]})})},Ns=t=>{const n={display:"flex",justifyContent:"center",alignItems:"center",width:"100%",textDecoration:"none",color:"inherit",padding:t.theme.spacing(1.5,3)},o={fontWeight:"bold",borderRadius:"3px",padding:t.theme.spacing(1.5,3)};return t.isActive?{...n,...o}:n},pe=({to:t,children:n})=>{const o=Zt();return e(pa,{to:t,style:({isActive:a})=>Ns({isActive:a,theme:o}),children:n})},Os=g(Hn)(({theme:t})=>({marginBottom:"1rem",borderRadius:"12.5px",boxShadow:"none",padding:"0 2rem"}));function $s(){const{uiConfig:t}=q(),{pathname:n}=Vn(),{isBilling:o}=Yt(),{flags:a}=t,i=n.split("/")[2];return e(Os,{children:r(Yn,{value:i,variant:"scrollable",scrollButtons:"auto",allowScrollButtonsMobile:!0,children:[e(he,{value:"users",label:e(pe,{to:"/admin/users",children:e("span",{children:"Users"})})}),a.serviceAccounts&&e(he,{value:"service-accounts",label:e(pe,{to:"/admin/service-accounts",children:e("span",{children:"Service accounts"})})}),a.UG&&e(he,{value:"groups",label:e(pe,{to:"/admin/groups",children:e("span",{children:"Groups"})})}),a.RE&&e(he,{value:"roles",label:e(pe,{to:"/admin/roles",children:e("span",{children:"Project roles"})})}),e(he,{value:"api",label:e(pe,{to:"/admin/api",children:"API access"})}),t.flags.embedProxyFrontend&&e(he,{value:"cors",label:e(pe,{to:"/admin/cors",children:"CORS origins"})}),e(he,{value:"auth",label:e(pe,{to:"/admin/auth",children:"Single sign-on"})}),e(he,{value:"instance",label:e(pe,{to:"/admin/instance",children:"Instance stats"})}),a.networkView&&e(he,{value:"network",label:e(pe,{to:"/admin/network",children:"Network"})}),a.maintenance&&e(he,{value:"maintenance",label:e(pe,{to:"/admin/maintenance",children:"Maintenance"})}),o&&e(he,{value:"billing",label:e(pe,{to:"/admin/billing",children:"Billing"})})]})})}const Gs=d.lazy(()=>import("./NetworkOverview-8018cd89.js")),js=d.lazy(()=>import("./NetworkTraffic-84935c51.js")),Fs=g(Q)(()=>({".page-header":{padding:0}})),zs=[{label:"Overview",path:"/admin/network"},{label:"Traffic",path:"/admin/network/traffic"}],Ms=()=>{const{pathname:t}=Vn();return e("div",{children:e(Fs,{headerClass:"page-header",header:e(Yn,{value:t,indicatorColor:"primary",textColor:"primary",variant:"scrollable",allowScrollButtonsMobile:!0,children:zs.map(({label:n,path:o})=>e(he,{value:o,label:e(pe,{to:o,children:e("span",{children:n})})},n))}),children:r(Jn,{children:[e(J,{path:"traffic",element:e(js,{})}),e(J,{path:"*",element:e(Gs,{})})]})})})},Tt=()=>{const{makeRequest:t,createRequest:n,errors:o,loading:a}=_e({propagateErrors:!0});return{createRole:async l=>{const p=n("api/admin/roles",{method:"POST",body:JSON.stringify(l)});try{return await t(p.caller,p.id)}catch(m){throw m}},deleteRole:async l=>{const c=`api/admin/roles/${l}`,p=n(c,{method:"DELETE"});try{return await t(p.caller,p.id)}catch(m){throw m}},editRole:async(l,c)=>{const p=`api/admin/roles/${l}`,m=n(p,{method:"PUT",body:JSON.stringify(c)});try{return await t(m.caller,m.id)}catch(y){throw y}},validateRole:async l=>{const p=n("api/admin/roles/validate",{method:"POST",body:JSON.stringify(l)});try{return await t(p.caller,p.id)}catch(m){throw m}},errors:o,loading:a}},Hs=g(O)(({theme:t})=>({display:"flex",alignItems:"center",[t.breakpoints.down(500)]:{flexDirection:"column",alignItems:"flex-start"}})),Ws=g(ma)(({theme:t})=>({fontWeight:t.typography.fontWeightBold,marginRight:t.spacing(1)})),bn=({title:t,permissions:n,checkedPermissions:o,Icon:a,isInitiallyExpanded:i,context:s,onPermissionChange:u,onCheckAll:h,getRoleKey:l})=>{const[c,p]=d.useState(i),m=d.useMemo(()=>(n==null?void 0:n.reduce((f,C)=>(f[l(C)]=!0,f),{}))||{},[n]),y=d.useMemo(()=>Object.keys(o).filter(f=>m[f]).length||0,[o,m]),S=d.useMemo(()=>y===(n==null?void 0:n.length),[y,n]);return e(O,{sx:{my:2,pb:1},children:r(ga,{expanded:c,onChange:()=>p(!c),sx:{boxShadow:"none",px:3,py:1,border:f=>`1px solid ${f.palette.divider}`,borderRadius:f=>`${f.shape.borderRadiusLarge}px`},children:[e(fa,{expandIcon:e(Re,{children:e(ja,{titleAccess:"Toggle"})}),sx:{boxShadow:"none",padding:"0"},children:r(Hs,{children:[a,e(Ws,{text:t,maxWidth:"120",maxLength:25})," ",r(R,{variant:"body2",color:"text.secondary",children:["(",y," / ",n==null?void 0:n.length," ","permissions)"]})]})}),r(ya,{sx:{px:0,py:1,flexWrap:"wrap"},children:[e(Vt,{sx:{mb:1}}),r(M,{variant:"text",size:"small",onClick:h,sx:{fontWeight:f=>f.typography.fontWeightRegular},children:[S?"Unselect ":"Select ","all ",s," permissions"]}),e(O,{children:n==null?void 0:n.map(f=>e(ie,{sx:{minWidth:{sm:"300px",xs:"auto"}},control:e(zn,{checked:!!o[l(f)],onChange:()=>u(f),color:"primary"}),label:f.displayName},l(f)))})]})]})})},ho=({children:t,roleName:n,roleDesc:o,checkedPermissions:a,errors:i,permissions:s,onSubmit:u,onCancel:h,setRoleName:l,setRoleDesc:c,handlePermissionChange:p,checkAllProjectPermissions:m,checkAllEnvironmentPermissions:y,validateNameUniqueness:S,clearErrors:f,getRoleKey:C})=>{const{project:k,environments:v}=s;return r("form",{onSubmit:u,children:[r(O,{sx:{maxWidth:"400px"},children:[e(R,{sx:{mb:1},children:"What is your role name?"}),e(We,{label:"Role name",value:n,onChange:T=>l(T.target.value),error:Boolean(i.name),errorText:i.name,onFocus:()=>f(),onBlur:S,autoFocus:!0,sx:{width:"100%",marginBottom:"1rem"}}),e(R,{sx:{mb:1},children:"What is this role for?"}),e(Z,{label:"Role description",variant:"outlined",multiline:!0,maxRows:4,value:o,onChange:T=>c(T.target.value),sx:{width:"100%",marginBottom:"1rem"}})]}),e("div",{children:e(x,{condition:Boolean(i.permissions),show:e(R,{variant:"body2",color:"error.main",children:"You must select at least one permission for a role."})})}),e(bn,{isInitiallyExpanded:!0,title:"Project permissions",Icon:e(tr,{color:"disabled",sx:{mr:1}}),permissions:k,checkedPermissions:a,onPermissionChange:T=>p(T),onCheckAll:m,getRoleKey:C,context:"project"}),e("div",{children:v.map(T=>e(bn,{title:T.name,Icon:e(ba,{sx:{mr:1},color:"disabled"}),permissions:T.permissions,checkedPermissions:a,onPermissionChange:A=>p(A),onCheckAll:()=>y(T.name),getRoleKey:C,context:"environment"},T.name))}),r(O,{sx:{marginTop:"auto",display:"flex",justifyContent:"flex-end"},children:[t,e(M,{onClick:h,sx:{marginLeft:2},children:"Cancel"})]})]})},ye=t=>t.environment?`${t.id}-${t.environment}`:`${t.id}`,po=(t="",n="",o=[])=>{q();const{permissions:a}=Sa({revalidateIfStale:!1,revalidateOnReconnect:!1,revalidateOnFocus:!1}),[i,s]=d.useState(t),[u,h]=d.useState(n),[l,c]=d.useState({});d.useEffect(()=>{o.length>0&&c(o==null?void 0:o.reduce((w,P)=>(w[ye(P)]=P,w),{}))},[o==null?void 0:o.length]);const[p,m]=d.useState({}),{validateRole:y}=Tt();d.useEffect(()=>{s(t)},[t]),d.useEffect(()=>{h(n)},[n]);const S=w=>{let P=Bt(l);P[ye(w)]?delete P[ye(w)]:P[ye(w)]={...w},c(P)},f=()=>{const{project:w}=a;let P=Bt(l);w.every(E=>P[ye(E)])?w.forEach(E=>{delete P[ye(E)]}):w.forEach(E=>{P[ye(E)]={...E}}),c(P)},C=w=>{const{environments:P}=a,L=Bt(l),E=P.find(U=>U.name===w);if(!E)return;E.permissions.every(U=>L[ye(U)])?E.permissions.forEach(U=>{delete L[ye(U)]}):E.permissions.forEach(U=>{L[ye(U)]={...U}}),c(L)},k=()=>({name:i,description:u,permissions:Object.values(l)});return{roleName:i,roleDesc:u,errors:p,checkedPermissions:l,permissions:a,setRoleName:s,setRoleDesc:h,handlePermissionChange:S,onToggleAllProjectPermissions:f,onToggleAllEnvironmentPermissions:C,getProjectRolePayload:k,validatePermissions:()=>Object.keys(l).length===0?(m(w=>({...w,permissions:"You must include at least one permission."})),!1):!0,validateName:()=>i.length===0?(m(w=>({...w,name:"Name can not be empty."})),!1):!0,clearErrors:()=>{m({})},validateNameUniqueness:async()=>{const w=k();try{await y(w)}catch(P){m(L=>({...L,name:V(P)}))}},getRoleKey:ye}},_s=()=>{const{setToastData:t,setToastApiError:n}=Y(),{uiConfig:o}=q(),a=ae(),{roleName:i,roleDesc:s,permissions:u,checkedPermissions:h,errors:l,setRoleName:c,setRoleDesc:p,handlePermissionChange:m,onToggleAllProjectPermissions:y,onToggleAllEnvironmentPermissions:S,getProjectRolePayload:f,validatePermissions:C,validateName:k,validateNameUniqueness:v,clearErrors:T,getRoleKey:A}=po(),{createRole:B,loading:w}=Tt();return e(Te,{loading:w,title:"Create project role",description:`A project role can be
|
|
16
16
|
customised to limit access
|
|
17
17
|
to resources within a project`,documentationLink:"https://docs.getunleash.io/reference/rbac#custom-project-roles",documentationLinkLabel:"Project roles documentation",formatApiCode:()=>`curl --location --request POST '${o.unleashUrl}/api/admin/roles' \\
|
|
18
18
|
--header 'Authorization: INSERT_API_KEY' \\
|
package/frontend/build/static/{LazyProjectExport-22be702f.js → LazyProjectExport-dc65603b.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as U1,j as t,cP as n4,cQ as a4,s as l,cr as r4,co as _2,g as q2,r as s,dV as o4,l as n1,d as t1,f as c,S as G2,h as K2,i as J2,k as Y2,bK as i4,aP as Q2,A as q1,a_ as v2,aJ as G1,aK as K1,dW as We,aE as J,dX as O1,bP as $1,a2 as b1,H as y1,ci as X2,at as O3,dY as c4,R as g2,cb as Ue,bC as $3,dZ as x1,al as d1,V as Z1,ak as g1,C as T,aX as H1,X as J1,W as f1,cm as s4,K as e3,d_ as l4,a as A,d$ as w1,e0 as d4,bD as u4,e1 as Y1,e2 as Q1,e3 as X1,be as y2,m as t3,e4 as p4,P as F3,dz as B3,e5 as h3,cs as qe,a8 as h2,e6 as m3,bi as $2,dN as h4,bk as F2,T as O,cu as m4,aO as g4,af as Ge,cd as Ke,u as h1,N as m1,e7 as f4,F as Q,e8 as Je,cS as Ye,by as v4,ar as b2,L as V3,a$ as L3,e9 as y4,aM as b4,cp as C4,a4 as E1,ea as S4,eb as x4,ec as Qe,ed as Xe,O as e0,ee as w4,ce as n3,Q as a3,U as C2,cn as T4,bN as t0,Y as r3,D as A4,aZ as d2,ef as E4,eg as Z4,aI as n0,ah as F1,eh as _3,a1 as R4,ei as a0,ej as P4,ek as I4,el as D4,em as j4,bH as r0,en as o0,eo as i0,e as S2,ep as k4,eq as O4,aG as $4,bo as F4,er as x2,es as c0,et as B4,az as e2,aA as B1,aV as R1,aB as t2,_ as n2,$ as r1,aC as a2,aD as r2,eu as V4,cf as m2,bM as s0,ev as l0,aN as w2,aq as d0,b6 as u0,b5 as M3,b3 as p0,ew as L4,ag as _4,ex as M4,ey as z4,ac as M2,ez as H4,eA as N4,a9 as v1,eB as W4,dm as o3,bu as U4,bI as q4,c0 as G4,cY as z2,eC as K4,cv as z3,cj as J4,eD as H3,bS as N3,aW as k1,aY as W3,b2 as U3,ay as g3,au as Y4,eE as Q4,ad as le,eF as X4,dj as I2,eG as et,eH as tt,dk as nt,dl as at,ca as rt,eI as ot,eJ as it,eK as ct,bQ as q3,bR as c1,eL as st,bO as lt,eM as dt,bJ as h0,d2 as m0,cq as g0,eN as ut,dg as f0,eO as N,eP as de,Z as v0,dq as pt,M as ht,eQ as mt,eR as gt,eS as ft}from"./index-a09b079f.js";import{u as vt,E as yt,V as bt,a as Ct,c as St,b as xt,C as wt,U as Tt}from"./FeatureArchiveDialog-9726aebb.js";import{a as At}from"./index-ad851f89.js";import{m as Et,a as Zt,B as y0}from"./useProjectRole-6f60c011.js";import{E as Rt}from"./Error-cf50f470.js";const Pt=U1(t("path",{d:"M6 6v2h8.59L5 17.59 6.41 19 16 9.41V18h2V6z"}),"ArrowOutward"),It=U1(t("path",{d:"m4 12 1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z"}),"ArrowUpward"),Dt=U1(t("path",{d:"M9 16h6v-6h4l-7-7-7 7h4zm-4 2h14v2H5z"}),"FileUpload"),jt=U1(t("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM7 13.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"}),"Pending"),kt=U1(t("path",{d:"M12 5.99 19.53 19H4.47L12 5.99M12 2 1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z"}),"ReportProblemOutlined"),Ot=U1(t("path",{d:"M19 9h-2v6.59L5.41 4 4 5.41 15.59 17H9v2h10V9z"}),"SouthEast");function $t(e,n){n4(2,arguments);var a=a4(n);return At(e,-a)}const D2=l("div")(()=>({display:"flex"})),Ft=l("div")(()=>({display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%"})),Bt=l("div")(()=>({display:"flex",flexDirection:"column"})),Vt=l("div")(()=>({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),E3=l("span")(({theme:e})=>({fontSize:e.fontSizes.smallBody,fontWeight:"normal"})),ue=l(E3)(({theme:e})=>({color:e.palette.neutral.dark})),Lt=l(r4)(({theme:e})=>({marginLeft:e.spacing(-1.5)})),_t=l("div")(({theme:e})=>({backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadiusLarge,marginBottom:e.spacing(2)})),Mt=l("div")(({theme:e})=>({padding:e.spacing(2.5,5),display:"flex",flexDirection:"column",alignItems:"start"})),pe=l("h2")(({theme:e})=>({margin:0,width:"100%",fontSize:e.fontSizes.mainHeader,fontWeight:"bold",display:"flex",justifyContent:"space-between",alignItems:"center",gap:e.spacing(2)})),zt=l("div")(({theme:e})=>({width:"100%",backgroundColor:e.palette.tertiary.light,height:"1px"})),Ht=l("div")(({theme:e})=>({padding:e.spacing(0,4)})),Nt=l(_2)(({theme:e})=>({textTransform:"none",fontSize:e.fontSizes.bodySize,flexGrow:1,flexBasis:0,[e.breakpoints.down("md")]:{paddingLeft:e.spacing(1),paddingRight:e.spacing(1)},[e.breakpoints.up("md")]:{minWidth:160}})),Wt=e=>e.reduce((n,a)=>a.enabled?n+1:n,0),Ut=l(q2)(({theme:e})=>({marginTop:e.spacing(3)})),qt=l("p",{shouldForwardProp:e=>e!=="warning"})(({theme:e,warning:n})=>({color:n?e.palette.error.dark:e.palette.text.primary,textAlign:"center"})),Gt=({environment:e,warnEnabledToggles:n})=>{const a=s.useMemo(()=>[{id:"Icon",width:"1%",Cell:({row:{original:h}})=>t(o4,{environment:h})},{Header:"Name",accessor:"name",Cell:n1},{Header:"Type",accessor:"type",Cell:n1},{Header:"Toggles enabled",accessor:"projectEnabledToggleCount",Cell:({value:h})=>t(n1,{children:t(qt,{warning:h>0,children:h===1?"1 toggle":`${h} toggles`})}),align:"center"}],[n]),{getTableProps:r,getTableBodyProps:o,headerGroups:i,rows:d,prepareRow:p}=t1.useTable({columns:a,data:[e],disableSortBy:!0});return c(Ut,{...r(),rowHeight:"compact",children:[t(G2,{headerGroups:i}),t(K2,{...o(),children:d.map(h=>(p(h),t(J2,{hover:!0,...h.getRowProps(),children:h.cells.map(u=>t(Y2,{...u.getCellProps(),children:u.render("Cell")}))})))})]})},Kt=l("p")(({theme:e})=>({marginTop:e.spacing(3),marginBottom:e.spacing(1.5)})),Jt=l(i4)(()=>({width:"100%"})),Yt=({environment:e,open:n,setOpen:a,onConfirm:r})=>{const[o,i]=s.useState("");return s.useEffect(()=>{i("")},[n]),c(Q2,{title:"Hide environment and disable feature toggles?",open:n,primaryButtonText:"Hide environment and disable feature toggles",disabledPrimaryButton:(e==null?void 0:e.name)!==o,secondaryButtonText:"Close",onClick:r,onClose:()=>{a(!1)},children:[c(q1,{severity:"error",children:[t("strong",{children:"Danger!"})," Hiding an environment will disable all the feature toggles that are enabled in this environment and it can impact client applications connected to the environment."]}),t(Gt,{environment:e}),c(Kt,{children:["In order to hide this environment, please enter the id of the environment in the textfield below:"," ",t("strong",{children:e==null?void 0:e.name})]}),t(Jt,{label:"Environment name",value:o,onChange:d=>i(d.target.value)})]})},b0=e=>{const{data:n,error:a,mutate:r}=v2(G1(`api/admin/environments/project/${e}`),Qt),o=s.useMemo(()=>n||[],[n]),i=s.useCallback(async()=>{await r()},[r]);return{environments:o,refetchEnvironments:i,loading:!a&&!n,error:a}},Qt=async e=>(await fetch(e).then(K1("Environments")).then(a=>a.json())).environments.sort((a,r)=>a.sortOrder-r.sortOrder),Xt=l(q1)(({theme:e})=>({marginBottom:e.spacing(4)})),en=l("div")(({theme:e})=>({display:"flex",flexWrap:"wrap",[e.breakpoints.down("sm")]:{justifyContent:"center"}})),tn=l(We)(({theme:e})=>({maxWidth:"400px",marginBottom:e.spacing(2)})),C0=()=>{const e=J("projectId"),n=O1(e);$1(`Project environments – ${n}`);const{setToastData:a,setToastApiError:r}=b1();y1();const{environments:o,loading:i,error:d,refetchEnvironments:p}=b0(e),{project:h,refetch:u}=X2(e),{removeEnvironmentFromProject:g,addEnvironmentToProject:v}=O3(),[f,S]=s.useState(),[j,P]=s.useState(!1),{isOss:D}=y1(),w=s.useMemo(()=>o.map(R=>({...R,projectVisible:h==null?void 0:h.environments.includes(R.name)})),[o,h==null?void 0:h.environments]),$=()=>{p(),u()},W=()=>t(tn,{onClick:$,text:"Error fetching environments"}),F=R=>`Got an API error when trying to set the environment as ${R?"visible":"hidden"}`,U=async R=>{if(R.projectVisible){if(Wt(w)>1){S(R),P(!0);return}a({title:"One environment must be visible",text:"You must always have at least one visible environment per project",type:"error"})}else try{await v(e,R.name),$(),a({title:"Environment set as visible",text:"Environment successfully set as visible.",type:"success"})}catch{r(F(!0))}},y=async()=>{if(f)try{await g(e,f.name),$(),a({title:"Environment set as hidden",text:"Environment successfully set as hidden.",type:"success"})}catch{r(F(!1))}finally{P(!1)}},Z=R=>D()&&R==="default",H=s.useMemo(()=>[{Header:"Name",accessor:"name",Cell:({row:{original:R}})=>t(c4,{environment:R})},{Header:"Type",accessor:"type",Cell:g2},{Header:"Project API tokens",accessor:R=>R.projectApiTokenCount===1?"1 token":`${R.projectApiTokenCount} tokens`,Cell:n1},{Header:"Visible in project",accessor:"enabled",align:"center",width:1,Cell:({row:{original:R}})=>t(Ue,{children:t($3,{tooltip:R.projectVisible?"Hide environment and disable feature toggles":"Make it visible",size:"medium",disabled:Z(R.name),projectId:e,permission:x1,checked:R.projectVisible,onChange:()=>U(R)})}),disableGlobalFilter:!0}],[w]),{getTableProps:G,getTableBodyProps:B,headerGroups:u1,rows:o1,prepareRow:X,state:{globalFilter:m},setGlobalFilter:b}=t1.useTable({columns:H,data:w,disableSortBy:!0},t1.useGlobalFilter),k=t(d1,{title:`Environments (${o1.length})`,actions:t(Z1,{initialValue:m,onChange:b})});return t(g1,{header:k,isLoading:i,children:c(en,{children:[t(T,{condition:Boolean(d),show:W()}),c(Xt,{severity:"info",children:[t("strong",{children:"Important!"})," In order for your application to retrieve configured activation strategies for a specific environment, the application must use an environment specific API token. You can look up the environment-specific"," ",t(H1,{to:"/admin/api",children:"API tokens here"}),".",t("br",{}),t("br",{}),"Your administrator can configure an environment-specific API token to be used in the SDK. If you are an administrator you can ",t(H1,{to:"/admin/api",children:"create a new API token here"}),"."]}),t(J1,{value:m,children:c(q2,{...G(),rowHeight:"compact",children:[t(G2,{headerGroups:u1}),t(K2,{...B(),children:o1.map(R=>(X(R),t(J2,{hover:!0,...R.getRowProps(),children:R.cells.map(L=>t(Y2,{...L.getCellProps(),children:L.render("Cell")}))})))})]})}),t(T,{condition:o1.length===0,show:t(T,{condition:(m==null?void 0:m.length)>0,show:c(f1,{children:["No environments found matching “",m,"”"]}),elseShow:t(f1,{children:"No environments available. Get started by adding one."})})}),t(Yt,{environment:f,open:j,setOpen:P,onConfirm:y})]})})},nn={id:"archivedAt"},an=({projectId:e})=>{const{archivedFeatures:n,loading:a,refetchArchived:r}=s4(e),{value:o,setValue:i}=e3(`${e}:ProjectFeaturesArchiveTable`,nn);return t(l4,{title:"Project archive",archivedFeatures:n||[],loading:a,storedParams:o,setStoredParams:i,refetch:r,projectId:e})},rn=()=>{const e=J("projectId"),n=O1(e);return $1(`Project archive – ${n}`),t(an,{projectId:e})},on=(e=[])=>{var a;const n=s.useRef(e);return(e==null?void 0:e.join(""))!==((a=n.current)==null?void 0:a.join(""))&&(n.current=e),n.current},cn=l(A)(()=>({mx:"auto",...w1})),sn=({projectId:e,featureName:n,environmentName:a,value:r,onToggle:o})=>{const[i,d,p]=d4(r);return t(cn,{children:t($3,{checked:r,environmentId:a,projectId:e,permission:u4,inputProps:{"aria-label":a},onClick:()=>{d(!i),o(e,n,a,!i).catch(p)},disabled:i!==r})},`${n}-${a}`)};var G3={},ln=Q1;Object.defineProperty(G3,"__esModule",{value:!0});var S0=G3.default=void 0,dn=ln(Y1()),un=X1,pn=(0,dn.default)((0,un.jsx)("path",{d:"m20.54 5.23-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.16.55L3.46 5.23C3.17 5.57 3 6.02 3 6.5V19c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.48-.17-.93-.46-1.27zM12 17.5 6.5 12H10v-2h4v2h3.5L12 17.5zM5.12 5l.81-1h12l.94 1H5.12z"}),"Archive");S0=G3.default=pn;var K3={},hn=Q1;Object.defineProperty(K3,"__esModule",{value:!0});var x0=K3.default=void 0,mn=hn(Y1()),gn=X1,fn=(0,mn.default)((0,gn.jsx)("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm4.2 14.2L11 13V7h1.5v5.2l4.5 2.7-.8 1.3z"}),"WatchLater");x0=K3.default=fn;const vn=l(A)(({theme:e})=>({display:"flex",justifyContent:"center",paddingRight:e.spacing(2)})),yn=({projectId:e,row:n,onOpenArchiveDialog:a,onOpenStaleDialog:r})=>{const[o,i]=s.useState(null),{original:{name:d,stale:p}}=n,h=Boolean(o),u=S=>{i(S.currentTarget)},g=()=>{i(null)},v=`feature-${d}-actions`,f=`${v}-menu`;return c(vn,{children:[t(y2,{title:"Feature toggle actions",arrow:!0,describeChild:!0,children:t(t3,{id:v,"aria-controls":h?f:void 0,"aria-haspopup":"true","aria-expanded":h?"true":void 0,onClick:u,type:"button",children:t(p4,{})})}),t(F3,{id:f,anchorEl:o,open:h,onClose:g,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,PaperProps:{sx:S=>({borderRadius:S.shape.borderRadius,padding:S.spacing(1,1.5)})},children:c(B3,{"aria-labelledby":v,children:[t(h3,{projectId:e,permission:qe,children:({hasAccess:S})=>c(h2,{sx:m3,onClick:g,disabled:!S,component:H1,to:`/projects/${e}/features/${d}/strategies/copy`,children:[t($2,{children:t(h4,{})}),t(F2,{children:t(O,{variant:"body2",children:"Copy"})})]})}),t(h3,{projectId:e,permission:m4,children:({hasAccess:S})=>c(h2,{sx:m3,onClick:()=>{a(d),g()},disabled:!S,children:[t($2,{children:t(S0,{})}),t(F2,{children:t(O,{variant:"body2",children:"Archive"})})]})}),t(h3,{projectId:e,permission:g4,children:({hasAccess:S})=>c(h2,{sx:m3,onClick:()=>{g(),r({featureId:d,stale:p===!0})},disabled:!S,children:[t($2,{children:t(x0,{})}),t(F2,{children:c(O,{variant:"body2",children:[p?"Un-mark":"Mark"," as stale"]})})]})})]})})]})};var J3={},bn=Q1;Object.defineProperty(J3,"__esModule",{value:!0});var w0=J3.default=void 0,Cn=bn(Y1()),Sn=X1,xn=(0,Cn.default)((0,Sn.jsx)("path",{d:"M5.33 20H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2h1.33c1.1 0 2 .9 2 2v12c0 1.1-.89 2-2 2zM22 18V6c0-1.1-.9-2-2-2h-1.33c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2H20c1.11 0 2-.9 2-2zm-7.33 0V6c0-1.1-.9-2-2-2h-1.33c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h1.33c1.1 0 2-.9 2-2z"}),"ViewWeek");w0=J3.default=xn;const wn=l(A)(()=>({...w1,justifyContent:"center"})),Tn=l(t3)(({theme:e})=>({margin:e.spacing(-1,0)})),An=l(A)(({theme:e})=>({...w1,justifyContent:"space-between",padding:e.spacing(1,1,0,4)})),En=l(h2)(({theme:e})=>({padding:e.spacing(0,2),margin:e.spacing(0,2),borderRadius:e.shape.borderRadius})),he=l(Ge)(({theme:e})=>({"&.MuiDivider-root.MuiDivider-fullWidth":{margin:e.spacing(.75,0)}})),Zn=l(Ke)(({theme:e})=>({padding:e.spacing(.75,1)})),Rn={favorite:"Favorite"},Pn=({allColumns:e,staticColumns:n=[],dividerBefore:a=[],dividerAfter:r=[],isCustomized:o=!1,setHiddenColumns:i})=>{const[d,p]=s.useState(null),h=h1(),u=m1(h.breakpoints.down("sm")),g=m1(h.breakpoints.down("md")),v=m1(h.breakpoints.down("lg"));s.useEffect(()=>{if(o)return;const w=($,W=0)=>{const F=e.filter(({id:y})=>y.startsWith("environments.")!==!1).map(({id:y})=>y).slice(0,W),U=e.map(({id:y})=>y).filter(y=>!$.includes(y)).filter(y=>!n.includes(y)).filter(y=>!F.includes(y));i(U)};if(u)return w(["createdAt"]);if(g)return w(["createdAt"],1);if(v)return w(["type","createdAt"],1);w(["lastSeenAt","type","createdAt"],3)},[u,g,v]);const f=w=>{p(w.currentTarget)},S=()=>{p(null)},j=Boolean(d),P="columns-menu",D=`columns-menu-list-${P}`;return c(wn,{children:[t(y2,{title:"Select columns",arrow:!0,describeChild:!0,children:t(Tn,{id:P,"aria-controls":j?D:void 0,"aria-haspopup":"true","aria-expanded":j?"true":void 0,onClick:f,type:"button",size:"large","data-loading":!0,children:t(w0,{})})}),c(F3,{id:D,open:j,anchorEl:d,onClose:S,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},disableScrollLock:!0,PaperProps:{sx:w=>({borderRadius:w.shape.borderRadius,paddingBottom:w.spacing(2)})},children:[c(An,{children:[t(O,{variant:"body2",children:t("strong",{children:"Columns"})}),t(t3,{onClick:S,children:t(f4,{})})]}),t(B3,{children:e.filter(({hideInMenu:w})=>!w).map(w=>[t(T,{condition:a.includes(w.id),show:t(he,{})}),c(En,{onClick:()=>w.toggleHidden(w.isVisible),disabled:n.includes(w.id),children:[t($2,{children:t(Zn,{edge:"start",checked:w.isVisible,disableRipple:!0,inputProps:{"aria-labelledby":w.id},size:"medium"})}),t(F2,{id:w.id,primary:t(O,{variant:"body2",children:t(T,{condition:Boolean(typeof w.Header=="string"&&w.Header),show:()=>t(Q,{children:w.Header}),elseShow:()=>Rn[w.id]||w.id})})})]}),t(T,{condition:r.includes(w.id),show:t(he,{})})])})]})]})},In=Je()(e=>({container:{boxShadow:"none",marginLeft:"1rem",minHeight:"100%",width:"calc(100% - 1rem)",position:"relative",[e.breakpoints.down("md")]:{marginLeft:"0",paddingBottom:"4rem",width:"inherit"}}})),Dn=l(Ye)(()=>({whiteSpace:"nowrap"})),jn=l("div",{shouldForwardProp:e=>e!=="hasWarning"})(({theme:e,hasWarning:n})=>({flexGrow:0,...w1,justifyContent:"center",...n&&{"::before":{content:'""',display:"block",width:e.spacing(2)}}})),j2=["Actions","name","favorite"],kn={id:"createdAt"},On=({features:e,loading:n,environments:a=[]})=>{const{classes:r}=In(),o=h1(),i=m1(o.breakpoints.down("md")),[d,p]=s.useState({open:!1,featureId:"",environmentName:""}),[h,u]=s.useState({}),[g,v]=s.useState(),f=J("projectId"),{value:S,setValue:j}=e3(`${f}:FeatureToggleListTable:v1`,kn),{value:P,setValue:D}=v4(),w=b2(),[$,W]=V3(),{isChangeRequestConfigured:F}=L3(f),U=on(n?["a","b","c"]:a),{refetch:y}=X2(f),{setToastData:Z,setToastApiError:H}=b1(),{isFavoritesPinned:G,sortTypes:B,onChangeIsFavoritePinned:u1}=y4($.has("favorites")?$.get("favorites")==="true":P.favorites),{toggleFeatureEnvironmentOn:o1,toggleFeatureEnvironmentOff:X}=b4(),{favorite:m,unfavorite:b}=C4(),{onChangeRequestToggle:k,onChangeRequestToggleClose:R,onChangeRequestToggleConfirm:L,changeRequestDialogDetails:x}=vt(f),q=s.useCallback(async(E,V,z,_)=>{if(F(z))throw k(V,z,_),new Error("Additional approval required");try{_?await o1(E,V,z):await X(E,V,z),y()}catch(l1){const C=E1(l1);throw C===yt?p({open:!0,featureId:V,environmentName:z}):H(C),l1}Z({type:"success",title:"Updated toggle status",text:"Successfully updated toggle status."}),y()},[X,o1,F]),s1=s.useCallback(async E=>{E!=null&&E.favorite?await b(f,E.name):await m(f,E.name),y()},[f,y]),i1=s.useMemo(()=>[{id:"favorite",Header:t(S4,{isActive:G,onClick:u1}),accessor:"favorite",Cell:({row:{original:E}})=>t(x4,{value:E==null?void 0:E.favorite,onClick:()=>s1(E)}),maxWidth:50,disableSortBy:!0},{Header:"Seen",accessor:"lastSeenAt",Cell:Qe,sortType:"date",align:"center",maxWidth:80},{Header:"Type",accessor:"type",Cell:Xe,align:"center",maxWidth:80},{Header:"Name",accessor:"name",Cell:({value:E})=>t(e0,{title:E,to:`/projects/${f}/features/${E}`}),minWidth:100,sortType:"alphanumeric",searchable:!0},{id:"tags",Header:"Tags",accessor:E=>{var V;return((V=E.tags)==null?void 0:V.map(({type:z,value:_})=>`${z}:${_}`).join(`
|
|
1
|
+
import{c as U1,j as t,cP as n4,cQ as a4,s as l,cr as r4,co as _2,g as q2,r as s,dV as o4,l as n1,d as t1,f as c,S as G2,h as K2,i as J2,k as Y2,bK as i4,aP as Q2,A as q1,a_ as v2,aJ as G1,aK as K1,dW as We,aE as J,dX as O1,bP as $1,a2 as b1,H as y1,ci as X2,at as O3,dY as c4,R as g2,cb as Ue,bC as $3,dZ as x1,al as d1,V as Z1,ak as g1,C as T,aX as H1,X as J1,W as f1,cm as s4,K as e3,d_ as l4,a as A,d$ as w1,e0 as d4,bD as u4,e1 as Y1,e2 as Q1,e3 as X1,be as y2,m as t3,e4 as p4,P as F3,dz as B3,e5 as h3,cs as qe,a8 as h2,e6 as m3,bi as $2,dN as h4,bk as F2,T as O,cu as m4,aO as g4,af as Ge,cd as Ke,u as h1,N as m1,e7 as f4,F as Q,e8 as Je,cS as Ye,by as v4,ar as b2,L as V3,a$ as L3,e9 as y4,aM as b4,cp as C4,a4 as E1,ea as S4,eb as x4,ec as Qe,ed as Xe,O as e0,ee as w4,ce as n3,Q as a3,U as C2,cn as T4,bN as t0,Y as r3,D as A4,aZ as d2,ef as E4,eg as Z4,aI as n0,ah as F1,eh as _3,a1 as R4,ei as a0,ej as P4,ek as I4,el as D4,em as j4,bH as r0,en as o0,eo as i0,e as S2,ep as k4,eq as O4,aG as $4,bo as F4,er as x2,es as c0,et as B4,az as e2,aA as B1,aV as R1,aB as t2,_ as n2,$ as r1,aC as a2,aD as r2,eu as V4,cf as m2,bM as s0,ev as l0,aN as w2,aq as d0,b6 as u0,b5 as M3,b3 as p0,ew as L4,ag as _4,ex as M4,ey as z4,ac as M2,ez as H4,eA as N4,a9 as v1,eB as W4,dm as o3,bu as U4,bI as q4,c0 as G4,cY as z2,eC as K4,cv as z3,cj as J4,eD as H3,bS as N3,aW as k1,aY as W3,b2 as U3,ay as g3,au as Y4,eE as Q4,ad as le,eF as X4,dj as I2,eG as et,eH as tt,dk as nt,dl as at,ca as rt,eI as ot,eJ as it,eK as ct,bQ as q3,bR as c1,eL as st,bO as lt,eM as dt,bJ as h0,d2 as m0,cq as g0,eN as ut,dg as f0,eO as N,eP as de,Z as v0,dq as pt,M as ht,eQ as mt,eR as gt,eS as ft}from"./index-c290f941.js";import{u as vt,E as yt,V as bt,a as Ct,c as St,b as xt,C as wt,U as Tt}from"./FeatureArchiveDialog-b5fc8177.js";import{a as At}from"./index-3132dba8.js";import{m as Et,a as Zt,B as y0}from"./useProjectRole-b5b140d2.js";import{E as Rt}from"./Error-934cc570.js";const Pt=U1(t("path",{d:"M6 6v2h8.59L5 17.59 6.41 19 16 9.41V18h2V6z"}),"ArrowOutward"),It=U1(t("path",{d:"m4 12 1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z"}),"ArrowUpward"),Dt=U1(t("path",{d:"M9 16h6v-6h4l-7-7-7 7h4zm-4 2h14v2H5z"}),"FileUpload"),jt=U1(t("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM7 13.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"}),"Pending"),kt=U1(t("path",{d:"M12 5.99 19.53 19H4.47L12 5.99M12 2 1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z"}),"ReportProblemOutlined"),Ot=U1(t("path",{d:"M19 9h-2v6.59L5.41 4 4 5.41 15.59 17H9v2h10V9z"}),"SouthEast");function $t(e,n){n4(2,arguments);var a=a4(n);return At(e,-a)}const D2=l("div")(()=>({display:"flex"})),Ft=l("div")(()=>({display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%"})),Bt=l("div")(()=>({display:"flex",flexDirection:"column"})),Vt=l("div")(()=>({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),E3=l("span")(({theme:e})=>({fontSize:e.fontSizes.smallBody,fontWeight:"normal"})),ue=l(E3)(({theme:e})=>({color:e.palette.neutral.dark})),Lt=l(r4)(({theme:e})=>({marginLeft:e.spacing(-1.5)})),_t=l("div")(({theme:e})=>({backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadiusLarge,marginBottom:e.spacing(2)})),Mt=l("div")(({theme:e})=>({padding:e.spacing(2.5,5),display:"flex",flexDirection:"column",alignItems:"start"})),pe=l("h2")(({theme:e})=>({margin:0,width:"100%",fontSize:e.fontSizes.mainHeader,fontWeight:"bold",display:"flex",justifyContent:"space-between",alignItems:"center",gap:e.spacing(2)})),zt=l("div")(({theme:e})=>({width:"100%",backgroundColor:e.palette.tertiary.light,height:"1px"})),Ht=l("div")(({theme:e})=>({padding:e.spacing(0,4)})),Nt=l(_2)(({theme:e})=>({textTransform:"none",fontSize:e.fontSizes.bodySize,flexGrow:1,flexBasis:0,[e.breakpoints.down("md")]:{paddingLeft:e.spacing(1),paddingRight:e.spacing(1)},[e.breakpoints.up("md")]:{minWidth:160}})),Wt=e=>e.reduce((n,a)=>a.enabled?n+1:n,0),Ut=l(q2)(({theme:e})=>({marginTop:e.spacing(3)})),qt=l("p",{shouldForwardProp:e=>e!=="warning"})(({theme:e,warning:n})=>({color:n?e.palette.error.dark:e.palette.text.primary,textAlign:"center"})),Gt=({environment:e,warnEnabledToggles:n})=>{const a=s.useMemo(()=>[{id:"Icon",width:"1%",Cell:({row:{original:h}})=>t(o4,{environment:h})},{Header:"Name",accessor:"name",Cell:n1},{Header:"Type",accessor:"type",Cell:n1},{Header:"Toggles enabled",accessor:"projectEnabledToggleCount",Cell:({value:h})=>t(n1,{children:t(qt,{warning:h>0,children:h===1?"1 toggle":`${h} toggles`})}),align:"center"}],[n]),{getTableProps:r,getTableBodyProps:o,headerGroups:i,rows:d,prepareRow:p}=t1.useTable({columns:a,data:[e],disableSortBy:!0});return c(Ut,{...r(),rowHeight:"compact",children:[t(G2,{headerGroups:i}),t(K2,{...o(),children:d.map(h=>(p(h),t(J2,{hover:!0,...h.getRowProps(),children:h.cells.map(u=>t(Y2,{...u.getCellProps(),children:u.render("Cell")}))})))})]})},Kt=l("p")(({theme:e})=>({marginTop:e.spacing(3),marginBottom:e.spacing(1.5)})),Jt=l(i4)(()=>({width:"100%"})),Yt=({environment:e,open:n,setOpen:a,onConfirm:r})=>{const[o,i]=s.useState("");return s.useEffect(()=>{i("")},[n]),c(Q2,{title:"Hide environment and disable feature toggles?",open:n,primaryButtonText:"Hide environment and disable feature toggles",disabledPrimaryButton:(e==null?void 0:e.name)!==o,secondaryButtonText:"Close",onClick:r,onClose:()=>{a(!1)},children:[c(q1,{severity:"error",children:[t("strong",{children:"Danger!"})," Hiding an environment will disable all the feature toggles that are enabled in this environment and it can impact client applications connected to the environment."]}),t(Gt,{environment:e}),c(Kt,{children:["In order to hide this environment, please enter the id of the environment in the textfield below:"," ",t("strong",{children:e==null?void 0:e.name})]}),t(Jt,{label:"Environment name",value:o,onChange:d=>i(d.target.value)})]})},b0=e=>{const{data:n,error:a,mutate:r}=v2(G1(`api/admin/environments/project/${e}`),Qt),o=s.useMemo(()=>n||[],[n]),i=s.useCallback(async()=>{await r()},[r]);return{environments:o,refetchEnvironments:i,loading:!a&&!n,error:a}},Qt=async e=>(await fetch(e).then(K1("Environments")).then(a=>a.json())).environments.sort((a,r)=>a.sortOrder-r.sortOrder),Xt=l(q1)(({theme:e})=>({marginBottom:e.spacing(4)})),en=l("div")(({theme:e})=>({display:"flex",flexWrap:"wrap",[e.breakpoints.down("sm")]:{justifyContent:"center"}})),tn=l(We)(({theme:e})=>({maxWidth:"400px",marginBottom:e.spacing(2)})),C0=()=>{const e=J("projectId"),n=O1(e);$1(`Project environments – ${n}`);const{setToastData:a,setToastApiError:r}=b1();y1();const{environments:o,loading:i,error:d,refetchEnvironments:p}=b0(e),{project:h,refetch:u}=X2(e),{removeEnvironmentFromProject:g,addEnvironmentToProject:v}=O3(),[f,S]=s.useState(),[j,P]=s.useState(!1),{isOss:D}=y1(),w=s.useMemo(()=>o.map(R=>({...R,projectVisible:h==null?void 0:h.environments.includes(R.name)})),[o,h==null?void 0:h.environments]),$=()=>{p(),u()},W=()=>t(tn,{onClick:$,text:"Error fetching environments"}),F=R=>`Got an API error when trying to set the environment as ${R?"visible":"hidden"}`,U=async R=>{if(R.projectVisible){if(Wt(w)>1){S(R),P(!0);return}a({title:"One environment must be visible",text:"You must always have at least one visible environment per project",type:"error"})}else try{await v(e,R.name),$(),a({title:"Environment set as visible",text:"Environment successfully set as visible.",type:"success"})}catch{r(F(!0))}},y=async()=>{if(f)try{await g(e,f.name),$(),a({title:"Environment set as hidden",text:"Environment successfully set as hidden.",type:"success"})}catch{r(F(!1))}finally{P(!1)}},Z=R=>D()&&R==="default",H=s.useMemo(()=>[{Header:"Name",accessor:"name",Cell:({row:{original:R}})=>t(c4,{environment:R})},{Header:"Type",accessor:"type",Cell:g2},{Header:"Project API tokens",accessor:R=>R.projectApiTokenCount===1?"1 token":`${R.projectApiTokenCount} tokens`,Cell:n1},{Header:"Visible in project",accessor:"enabled",align:"center",width:1,Cell:({row:{original:R}})=>t(Ue,{children:t($3,{tooltip:R.projectVisible?"Hide environment and disable feature toggles":"Make it visible",size:"medium",disabled:Z(R.name),projectId:e,permission:x1,checked:R.projectVisible,onChange:()=>U(R)})}),disableGlobalFilter:!0}],[w]),{getTableProps:G,getTableBodyProps:B,headerGroups:u1,rows:o1,prepareRow:X,state:{globalFilter:m},setGlobalFilter:b}=t1.useTable({columns:H,data:w,disableSortBy:!0},t1.useGlobalFilter),k=t(d1,{title:`Environments (${o1.length})`,actions:t(Z1,{initialValue:m,onChange:b})});return t(g1,{header:k,isLoading:i,children:c(en,{children:[t(T,{condition:Boolean(d),show:W()}),c(Xt,{severity:"info",children:[t("strong",{children:"Important!"})," In order for your application to retrieve configured activation strategies for a specific environment, the application must use an environment specific API token. You can look up the environment-specific"," ",t(H1,{to:"/admin/api",children:"API tokens here"}),".",t("br",{}),t("br",{}),"Your administrator can configure an environment-specific API token to be used in the SDK. If you are an administrator you can ",t(H1,{to:"/admin/api",children:"create a new API token here"}),"."]}),t(J1,{value:m,children:c(q2,{...G(),rowHeight:"compact",children:[t(G2,{headerGroups:u1}),t(K2,{...B(),children:o1.map(R=>(X(R),t(J2,{hover:!0,...R.getRowProps(),children:R.cells.map(L=>t(Y2,{...L.getCellProps(),children:L.render("Cell")}))})))})]})}),t(T,{condition:o1.length===0,show:t(T,{condition:(m==null?void 0:m.length)>0,show:c(f1,{children:["No environments found matching “",m,"”"]}),elseShow:t(f1,{children:"No environments available. Get started by adding one."})})}),t(Yt,{environment:f,open:j,setOpen:P,onConfirm:y})]})})},nn={id:"archivedAt"},an=({projectId:e})=>{const{archivedFeatures:n,loading:a,refetchArchived:r}=s4(e),{value:o,setValue:i}=e3(`${e}:ProjectFeaturesArchiveTable`,nn);return t(l4,{title:"Project archive",archivedFeatures:n||[],loading:a,storedParams:o,setStoredParams:i,refetch:r,projectId:e})},rn=()=>{const e=J("projectId"),n=O1(e);return $1(`Project archive – ${n}`),t(an,{projectId:e})},on=(e=[])=>{var a;const n=s.useRef(e);return(e==null?void 0:e.join(""))!==((a=n.current)==null?void 0:a.join(""))&&(n.current=e),n.current},cn=l(A)(()=>({mx:"auto",...w1})),sn=({projectId:e,featureName:n,environmentName:a,value:r,onToggle:o})=>{const[i,d,p]=d4(r);return t(cn,{children:t($3,{checked:r,environmentId:a,projectId:e,permission:u4,inputProps:{"aria-label":a},onClick:()=>{d(!i),o(e,n,a,!i).catch(p)},disabled:i!==r})},`${n}-${a}`)};var G3={},ln=Q1;Object.defineProperty(G3,"__esModule",{value:!0});var S0=G3.default=void 0,dn=ln(Y1()),un=X1,pn=(0,dn.default)((0,un.jsx)("path",{d:"m20.54 5.23-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.16.55L3.46 5.23C3.17 5.57 3 6.02 3 6.5V19c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.48-.17-.93-.46-1.27zM12 17.5 6.5 12H10v-2h4v2h3.5L12 17.5zM5.12 5l.81-1h12l.94 1H5.12z"}),"Archive");S0=G3.default=pn;var K3={},hn=Q1;Object.defineProperty(K3,"__esModule",{value:!0});var x0=K3.default=void 0,mn=hn(Y1()),gn=X1,fn=(0,mn.default)((0,gn.jsx)("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm4.2 14.2L11 13V7h1.5v5.2l4.5 2.7-.8 1.3z"}),"WatchLater");x0=K3.default=fn;const vn=l(A)(({theme:e})=>({display:"flex",justifyContent:"center",paddingRight:e.spacing(2)})),yn=({projectId:e,row:n,onOpenArchiveDialog:a,onOpenStaleDialog:r})=>{const[o,i]=s.useState(null),{original:{name:d,stale:p}}=n,h=Boolean(o),u=S=>{i(S.currentTarget)},g=()=>{i(null)},v=`feature-${d}-actions`,f=`${v}-menu`;return c(vn,{children:[t(y2,{title:"Feature toggle actions",arrow:!0,describeChild:!0,children:t(t3,{id:v,"aria-controls":h?f:void 0,"aria-haspopup":"true","aria-expanded":h?"true":void 0,onClick:u,type:"button",children:t(p4,{})})}),t(F3,{id:f,anchorEl:o,open:h,onClose:g,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,PaperProps:{sx:S=>({borderRadius:S.shape.borderRadius,padding:S.spacing(1,1.5)})},children:c(B3,{"aria-labelledby":v,children:[t(h3,{projectId:e,permission:qe,children:({hasAccess:S})=>c(h2,{sx:m3,onClick:g,disabled:!S,component:H1,to:`/projects/${e}/features/${d}/strategies/copy`,children:[t($2,{children:t(h4,{})}),t(F2,{children:t(O,{variant:"body2",children:"Copy"})})]})}),t(h3,{projectId:e,permission:m4,children:({hasAccess:S})=>c(h2,{sx:m3,onClick:()=>{a(d),g()},disabled:!S,children:[t($2,{children:t(S0,{})}),t(F2,{children:t(O,{variant:"body2",children:"Archive"})})]})}),t(h3,{projectId:e,permission:g4,children:({hasAccess:S})=>c(h2,{sx:m3,onClick:()=>{g(),r({featureId:d,stale:p===!0})},disabled:!S,children:[t($2,{children:t(x0,{})}),t(F2,{children:c(O,{variant:"body2",children:[p?"Un-mark":"Mark"," as stale"]})})]})})]})})]})};var J3={},bn=Q1;Object.defineProperty(J3,"__esModule",{value:!0});var w0=J3.default=void 0,Cn=bn(Y1()),Sn=X1,xn=(0,Cn.default)((0,Sn.jsx)("path",{d:"M5.33 20H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2h1.33c1.1 0 2 .9 2 2v12c0 1.1-.89 2-2 2zM22 18V6c0-1.1-.9-2-2-2h-1.33c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2H20c1.11 0 2-.9 2-2zm-7.33 0V6c0-1.1-.9-2-2-2h-1.33c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h1.33c1.1 0 2-.9 2-2z"}),"ViewWeek");w0=J3.default=xn;const wn=l(A)(()=>({...w1,justifyContent:"center"})),Tn=l(t3)(({theme:e})=>({margin:e.spacing(-1,0)})),An=l(A)(({theme:e})=>({...w1,justifyContent:"space-between",padding:e.spacing(1,1,0,4)})),En=l(h2)(({theme:e})=>({padding:e.spacing(0,2),margin:e.spacing(0,2),borderRadius:e.shape.borderRadius})),he=l(Ge)(({theme:e})=>({"&.MuiDivider-root.MuiDivider-fullWidth":{margin:e.spacing(.75,0)}})),Zn=l(Ke)(({theme:e})=>({padding:e.spacing(.75,1)})),Rn={favorite:"Favorite"},Pn=({allColumns:e,staticColumns:n=[],dividerBefore:a=[],dividerAfter:r=[],isCustomized:o=!1,setHiddenColumns:i})=>{const[d,p]=s.useState(null),h=h1(),u=m1(h.breakpoints.down("sm")),g=m1(h.breakpoints.down("md")),v=m1(h.breakpoints.down("lg"));s.useEffect(()=>{if(o)return;const w=($,W=0)=>{const F=e.filter(({id:y})=>y.startsWith("environments.")!==!1).map(({id:y})=>y).slice(0,W),U=e.map(({id:y})=>y).filter(y=>!$.includes(y)).filter(y=>!n.includes(y)).filter(y=>!F.includes(y));i(U)};if(u)return w(["createdAt"]);if(g)return w(["createdAt"],1);if(v)return w(["type","createdAt"],1);w(["lastSeenAt","type","createdAt"],3)},[u,g,v]);const f=w=>{p(w.currentTarget)},S=()=>{p(null)},j=Boolean(d),P="columns-menu",D=`columns-menu-list-${P}`;return c(wn,{children:[t(y2,{title:"Select columns",arrow:!0,describeChild:!0,children:t(Tn,{id:P,"aria-controls":j?D:void 0,"aria-haspopup":"true","aria-expanded":j?"true":void 0,onClick:f,type:"button",size:"large","data-loading":!0,children:t(w0,{})})}),c(F3,{id:D,open:j,anchorEl:d,onClose:S,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},disableScrollLock:!0,PaperProps:{sx:w=>({borderRadius:w.shape.borderRadius,paddingBottom:w.spacing(2)})},children:[c(An,{children:[t(O,{variant:"body2",children:t("strong",{children:"Columns"})}),t(t3,{onClick:S,children:t(f4,{})})]}),t(B3,{children:e.filter(({hideInMenu:w})=>!w).map(w=>[t(T,{condition:a.includes(w.id),show:t(he,{})}),c(En,{onClick:()=>w.toggleHidden(w.isVisible),disabled:n.includes(w.id),children:[t($2,{children:t(Zn,{edge:"start",checked:w.isVisible,disableRipple:!0,inputProps:{"aria-labelledby":w.id},size:"medium"})}),t(F2,{id:w.id,primary:t(O,{variant:"body2",children:t(T,{condition:Boolean(typeof w.Header=="string"&&w.Header),show:()=>t(Q,{children:w.Header}),elseShow:()=>Rn[w.id]||w.id})})})]}),t(T,{condition:r.includes(w.id),show:t(he,{})})])})]})]})},In=Je()(e=>({container:{boxShadow:"none",marginLeft:"1rem",minHeight:"100%",width:"calc(100% - 1rem)",position:"relative",[e.breakpoints.down("md")]:{marginLeft:"0",paddingBottom:"4rem",width:"inherit"}}})),Dn=l(Ye)(()=>({whiteSpace:"nowrap"})),jn=l("div",{shouldForwardProp:e=>e!=="hasWarning"})(({theme:e,hasWarning:n})=>({flexGrow:0,...w1,justifyContent:"center",...n&&{"::before":{content:'""',display:"block",width:e.spacing(2)}}})),j2=["Actions","name","favorite"],kn={id:"createdAt"},On=({features:e,loading:n,environments:a=[]})=>{const{classes:r}=In(),o=h1(),i=m1(o.breakpoints.down("md")),[d,p]=s.useState({open:!1,featureId:"",environmentName:""}),[h,u]=s.useState({}),[g,v]=s.useState(),f=J("projectId"),{value:S,setValue:j}=e3(`${f}:FeatureToggleListTable:v1`,kn),{value:P,setValue:D}=v4(),w=b2(),[$,W]=V3(),{isChangeRequestConfigured:F}=L3(f),U=on(n?["a","b","c"]:a),{refetch:y}=X2(f),{setToastData:Z,setToastApiError:H}=b1(),{isFavoritesPinned:G,sortTypes:B,onChangeIsFavoritePinned:u1}=y4($.has("favorites")?$.get("favorites")==="true":P.favorites),{toggleFeatureEnvironmentOn:o1,toggleFeatureEnvironmentOff:X}=b4(),{favorite:m,unfavorite:b}=C4(),{onChangeRequestToggle:k,onChangeRequestToggleClose:R,onChangeRequestToggleConfirm:L,changeRequestDialogDetails:x}=vt(f),q=s.useCallback(async(E,V,z,_)=>{if(F(z))throw k(V,z,_),new Error("Additional approval required");try{_?await o1(E,V,z):await X(E,V,z),y()}catch(l1){const C=E1(l1);throw C===yt?p({open:!0,featureId:V,environmentName:z}):H(C),l1}Z({type:"success",title:"Updated toggle status",text:"Successfully updated toggle status."}),y()},[X,o1,F]),s1=s.useCallback(async E=>{E!=null&&E.favorite?await b(f,E.name):await m(f,E.name),y()},[f,y]),i1=s.useMemo(()=>[{id:"favorite",Header:t(S4,{isActive:G,onClick:u1}),accessor:"favorite",Cell:({row:{original:E}})=>t(x4,{value:E==null?void 0:E.favorite,onClick:()=>s1(E)}),maxWidth:50,disableSortBy:!0},{Header:"Seen",accessor:"lastSeenAt",Cell:Qe,sortType:"date",align:"center",maxWidth:80},{Header:"Type",accessor:"type",Cell:Xe,align:"center",maxWidth:80},{Header:"Name",accessor:"name",Cell:({value:E})=>t(e0,{title:E,to:`/projects/${f}/features/${E}`}),minWidth:100,sortType:"alphanumeric",searchable:!0},{id:"tags",Header:"Tags",accessor:E=>{var V;return((V=E.tags)==null?void 0:V.map(({type:z,value:_})=>`${z}:${_}`).join(`
|
|
2
2
|
`))||""},Cell:w4,width:80,hideInMenu:!0,searchable:!0},{Header:"Created",accessor:"createdAt",Cell:n3,sortType:"date",minWidth:120},...U.map(E=>({Header:n?()=>"":E,maxWidth:90,id:`environments.${E}`,accessor:V=>{var z;return(z=V.environments[E])==null?void 0:z.enabled},align:"center",Cell:({value:V,row:{original:z}})=>{const _=z.someEnabledEnvironmentHasVariants&&z.environments[E].variantCount===0&&z.environments[E].enabled;return c(jn,{hasWarning:_,children:[t(sn,{value:V,projectId:f,featureName:z==null?void 0:z.name,environmentName:E,onToggle:q}),t(T,{condition:_,show:t(bt,{})})]})},sortType:"boolean",filterName:E,filterParsing:V=>V?"enabled":"disabled"})),{id:"Actions",maxWidth:56,width:56,Cell:E=>t(yn,{projectId:f,onOpenArchiveDialog:v,onOpenStaleDialog:u,...E}),disableSortBy:!0}],[f,U,n,q]),[Y,T1]=s.useState($.get("search")||""),A2=s.useMemo(()=>e.map(E=>{var V;return{...E,environments:Object.fromEntries(U.map(z=>{const _=E==null?void 0:E.environments.find(l1=>(l1==null?void 0:l1.name)===z);return[z,{name:z,enabled:(_==null?void 0:_.enabled)||!1,variantCount:(_==null?void 0:_.variantCount)||0}]})),someEnabledEnvironmentHasVariants:((V=E.environments)==null?void 0:V.some(z=>z.variantCount>0&&z.enabled))||!1}}),[e,U]),{data:C1,getSearchText:E2,getSearchContext:s2}=a3(i1,Y,A2),Z2=s.useMemo(()=>n?Array(6).fill({type:"-",name:"Feature name",createdAt:new Date,environments:{production:{name:"production",enabled:!1}}}):C1,[n,C1]),V1=s.useMemo(()=>{var z;const E=i1.map(_=>(_==null?void 0:_.accessor)||(_==null?void 0:_.id));let V=U.filter((_,l1)=>l1>=3).map(_=>`environments.${_}`);if($.has("columns")){const _=((z=$.get("columns"))==null?void 0:z.split(","))||[],l1=[...j2,..._];V=E.filter(C=>!l1.includes(C))}else if(S.columns){const _=[...j2,...S.columns];V=E.filter(l1=>!_.includes(l1))}return{sortBy:[{id:$.get("sort")||"createdAt",desc:$.has("order")?$.get("order")==="desc":S.desc}],hiddenColumns:V}},[U]),L1=s.useCallback(E=>E.name,[]),{allColumns:A1,headerGroups:R2,rows:_1,state:{sortBy:P1,hiddenColumns:D1},prepareRow:I1,setHiddenColumns:M1}=t1.useTable({columns:i1,data:Z2,initialState:V1,sortTypes:B,autoResetHiddenColumns:!1,disableSortRemove:!0,autoResetSortBy:!1,getRowId:L1},t1.useFlexLayout,t1.useSortBy);return C2([{condition:!e.some(({tags:E})=>E==null?void 0:E.length),columns:["tags"]}],M1,i1),s.useEffect(()=>{if(n)return;const E={};E.sort=P1[0].id,P1[0].desc&&(E.order="desc"),Y&&(E.search=Y),G&&(E.favorites="true"),E.columns=A1.map(({id:V})=>V).filter(V=>!j2.includes(V)&&!(D1!=null&&D1.includes(V))).join(","),W(E,{replace:!0}),j(V=>({...V,id:P1[0].id,desc:P1[0].desc||!1,columns:E.columns.split(",")})),D(V=>({...V,favorites:Boolean(G)}))},[n,P1,D1,Y,W,G]),c(g1,{isLoading:n,className:r.container,header:t(d1,{titleElement:`Feature toggles (${_1.length})`,actions:c(Q,{children:[t(T,{condition:!i,show:t(Z1,{initialValue:Y,onChange:T1,hasFilters:!0,getSearchContext:s2})}),t(Pn,{allColumns:A1,staticColumns:j2,dividerAfter:["createdAt"],dividerBefore:["Actions"],isCustomized:Boolean(S.columns),setHiddenColumns:M1}),t(d1.Divider,{sx:{marginLeft:0}}),t(Dn,{onClick:()=>w(T4(f)),maxWidth:"960px",Icon:t0,projectId:f,permission:qe,children:"New feature toggle"})]}),children:t(T,{condition:i,show:t(Z1,{initialValue:Y,onChange:T1,hasFilters:!0,getSearchContext:s2})})}),children:[t(J1,{value:E2(Y),children:t(r3,{rows:_1,headerGroups:R2,prepareRow:I1})}),t(T,{condition:_1.length===0,show:t(T,{condition:(Y==null?void 0:Y.length)>0,show:c(f1,{children:["No feature toggles found matching “",Y,"”"]}),elseShow:t(f1,{children:"No feature toggles available. Get started by adding a new feature toggle."})})}),t(Ct,{onClose:()=>p(E=>({...E,open:!1})),projectId:f,...d}),t(St,{isStale:h.stale===!0,isOpen:Boolean(h.featureId),onClose:()=>{u({}),y()},featureId:h.featureId||"",projectId:f}),t(xt,{isOpen:Boolean(g),onConfirm:()=>{y()},onClose:()=>{v(void 0)},featureId:g||"",projectId:f})," ",t(wt,{isOpen:x.isOpen,onClose:R,environment:x==null?void 0:x.environment,onConfirm:L,messageComponent:t(Tt,{featureName:x.featureName,enabled:x.enabled,environment:x==null?void 0:x.environment})})]})};var Y3={},$n=Q1;Object.defineProperty(Y3,"__esModule",{value:!0});var T0=Y3.default=void 0,Fn=$n(Y1()),Bn=X1,Vn=(0,Fn.default)((0,Bn.jsx)("path",{d:"m12 4-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z"}),"ArrowForward");T0=Y3.default=Vn;const Ln=l("div")(({theme:e})=>({...w1,width:"225px",flexDirection:"column",boxShadow:"none",[e.breakpoints.down("md")]:{flexDirection:"row",alignItems:"stretch",width:"100%",marginBottom:e.spacing(2)}})),_n=l("div")(({theme:e})=>({display:"flex",justifyContent:"center",margin:e.spacing(2,0)})),Q3=l("div")(({theme:e})=>({margin:"0",textAlign:"center",marginBottom:e.spacing(2),backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadiusLarge,width:"100%",padding:e.spacing(3,2,3,2),[e.breakpoints.down("md")]:{margin:e.spacing(0,.5),...w1,flexDirection:"column",justifyContent:"center",fontSize:e.fontSizes.smallBody,position:"relative",padding:e.spacing(1.5),"&:first-of-type":{marginLeft:"0"},"&:last-of-type":{marginRight:"0"}}})),X3=l("p")(({theme:e})=>({marginBottom:e.spacing(2)})),u2=l("div")(({theme:e})=>({display:"grid",gridGap:e.spacing(1),gridTemplateColumns:`${e.spacing(1.25)} auto auto`,margin:e.spacing(1,0,1,0),fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,textAlign:"left",alignItems:"center"})),A0=l("p")(({theme:e})=>({fontSize:"1.5rem",marginBottom:e.spacing(2),[e.breakpoints.down("md")]:{fontSize:e.fontSizes.bodySize,marginBottom:e.spacing(4)}})),p2=l("p")(({theme:e})=>({fontSize:e.typography.h2.fontSize,fontWeight:"bold",textAlign:"right",color:e.palette.text.primary})),E0=l("p")(({theme:e})=>({[e.breakpoints.down("md")]:{display:"none"}})),Z0=l(H1)(({theme:e})=>({textDecoration:"none",...w1,justifyContent:"center",color:e.palette.primary.main,[e.breakpoints.down("md")]:{position:"absolute",bottom:e.spacing(1.5)}})),R0=l(T0)(({theme:e})=>({color:e.palette.primary.main,marginLeft:e.spacing(1)})),Mn=({projectId:e,health:n})=>c(Q3,{children:[t(_n,{children:t(A4,{percentage:n})}),t(X3,{"data-loading":!0,children:"Overall health rating"}),c(A0,{"data-loading":!0,children:[n,"%"]}),c(Z0,{"data-loading":!0,to:`/projects/${e}/health`,children:[t(E0,{"data-loading":!0,children:"view more "}),t(R0,{"data-loading":!0})]})]}),zn=({features:e})=>{const{release:n,experiment:a,operational:r,kill:o,permission:i}=s.useMemo(()=>{const v=(e==null?void 0:e.filter(D=>D.type==="release").length)||0,f=(e==null?void 0:e.filter(D=>D.type==="experiment").length)||0,S=(e==null?void 0:e.filter(D=>D.type==="operational").length)||0,j=(e==null?void 0:e.filter(D=>D.type==="kill-switch").length)||0,P=(e==null?void 0:e.filter(D=>D.type==="permission").length)||0;return{release:v,experiment:f,operational:S,kill:j,permission:P}},[e]),d=d2("release"),p=d2("experiment"),h=d2("operational"),u=d2("kill-switch"),g=d2("permission");return c(Q3,{children:[t(X3,{"data-loading":!0,children:"Toggle types used"}),c(u2,{"data-loading":!0,children:[t(d,{fontSize:"small","data-loading":!0}),t("div",{children:"Release"}),t(p2,{children:n})]}),c(u2,{"data-loading":!0,children:[t(p,{fontSize:"small","data-loading":!0}),t("div",{children:"Experiment"}),t(p2,{children:a})]}),c(u2,{"data-loading":!0,children:[t(h,{fontSize:"small","data-loading":!0}),t("div",{children:"Operational"}),t(p2,{children:r})]}),c(u2,{"data-loading":!0,children:[t(u,{fontSize:"small","data-loading":!0}),t("div",{children:"Kill switch"}),t(p2,{children:o})]}),c(u2,{"data-loading":!0,style:{margin:0},children:[t(g,{fontSize:"small","data-loading":!0}),t("div",{children:"Permission"}),t(p2,{children:i})]})]})},Hn=({projectId:e,memberCount:n})=>{var o,i;const{uiConfig:a}=y1();let r="/admin/users";return(i=(o=a==null?void 0:a.versionInfo)==null?void 0:o.current)!=null&&i.enterprise&&(r=`/projects/${e}/settings/access`),c(Q3,{children:[t(X3,{"data-loading":!0,children:"Project members"}),t(A0,{"data-loading":!0,children:n}),c(Z0,{"data-loading":!0,to:r,children:[t(E0,{"data-loading":!0,children:"view more "}),t(R0,{"data-loading":!0})]})]})},Nn=({id:e,memberCount:n,health:a,features:r})=>{const{uiConfig:o}=y1();return t("aside",{children:c(Ln,{children:[t(Mn,{projectId:e,health:a}),t(T,{condition:e!==E4,show:t(Hn,{projectId:e,memberCount:n})}),t(T,{condition:Boolean(o==null?void 0:o.flags.newProjectOverview),show:t(zn,{features:r})})]})})},Wn=l(A)(({theme:e})=>({padding:e.spacing(4,2),backgroundColor:e.palette.background.paper,minWidth:"240px",display:"flex",flexDirection:"column",alignItems:"center",borderRadius:`${e.shape.borderRadiusLarge}px`})),Un=l(O)(({theme:e})=>({marginBottom:e.spacing(2)})),qn=l(O)(({theme:e})=>({fontSize:e.fontSizes.largeHeader,fontWeight:"bold"})),Gn=l(A)(({theme:e})=>({...w1,flexDirection:"column",alignItems:"center",marginLeft:e.spacing(1.5)})),Kn=l(O)(({theme:e})=>({color:e.palette.neutral.main,fontSize:e.fontSizes.smallBody})),Jn=l(O)(({theme:e})=>({marginLeft:e.spacing(1),fontSize:e.fontSizes.smallBody})),Yn=e=>e>0?t(Pt,{sx:{color:"success.main",height:18,width:18}}):t(Ot,{sx:{color:"warning.dark",height:18,width:18}}),Qn=e=>e>0?"success.main":"error.main",k2=({title:e,boxText:n,change:a})=>c(Wn,{children:[t(Un,{children:e}),c(A,{sx:{...w1},children:[t(qn,{children:n}),c(Gn,{children:[c(A,{sx:{...w1},children:[Yn(a),t(Jn,{color:Qn(a),children:a})]}),t(Kn,{children:"this month"})]})]})]}),Xn=l(A)(({theme:e})=>({padding:e.spacing(0,0,2,2),display:"flex",justifyContent:"space-between",flexWrap:"wrap"})),e5=()=>c(Xn,{children:[t(k2,{title:"Total changes",boxText:"86",change:-24}),t(k2,{title:"Total changes",boxText:"6 days",change:-12})," ",t(k2,{title:"Total changes",boxText:"86",change:-24}),t(k2,{title:"Total changes",boxText:"86",change:-24})]}),t5=15*1e3,n5=l("div")(({theme:e})=>({display:"flex",[e.breakpoints.down("md")]:{flexDirection:"column"}})),a5=l("div")(()=>({width:"100%",minWidth:0})),r5=l(A)(()=>({display:"flex",flexDirection:"column",width:"100%",minWidth:0})),o5=()=>{const e=J("projectId"),n=O1(e),{project:a,loading:r}=X2(e,{refreshInterval:t5}),{members:o,features:i,health:d,description:p,environments:h}=a;$1(`Project overview – ${n}`);const{setLastViewed:u}=Z4(),{uiConfig:g}=y1();return s.useEffect(()=>{u(e)},[e,u]),c(n5,{children:[t(Nn,{id:e,description:p,memberCount:o,health:d,features:i}),c(r5,{children:[t(T,{condition:Boolean(g==null?void 0:g.flags.newProjectOverview),show:t(e5,{})}),t(a5,{children:t(On,{features:i,environments:h,loading:r})})]})]})},i5=(e,n)=>{const a=G1(`api/admin/projects/${e}/health-report`),{data:r,error:o}=v2(a,c5,n),i=s.useCallback(()=>{n0(a).catch(console.warn)},[a]);return{healthReport:r,refetchHealthReport:i,loading:!o&&!r,error:o}},c5=e=>fetch(e).then(K1("Health report")).then(n=>n.json());var ee={},s5=Q1;Object.defineProperty(ee,"__esModule",{value:!0});var Z3=ee.default=void 0,l5=s5(Y1()),d5=X1,u5=(0,l5.default)((0,d5.jsx)("path",{d:"M12 5.99 19.53 19H4.47L12 5.99M12 2 1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z"}),"ReportProblemOutlined");Z3=ee.default=u5;const p5=l(A)(({theme:e})=>({display:"flex",alignItems:"center",color:e.palette.success.dark,"& svg":{color:e.palette.success.main}})),me=l(A)(({theme:e})=>({display:"flex",alignItems:"center",color:e.palette.warning.dark,"& svg":{color:e.palette.warning.main}})),h5=l(F1)(({theme:e})=>({padding:e.spacing(4),marginBottom:e.spacing(2),borderRadius:e.shape.borderRadiusLarge,boxShadow:"none",display:"flex",justifyContent:"space-between",[e.breakpoints.down("md")]:{flexDirection:"column",gap:e.spacing(2)}})),f3=l("h2")(({theme:e})=>({fontSize:e.fontSizes.mainHeader,marginBottom:e.spacing(1)})),m5=l("p")(({theme:e})=>({fontSize:"2rem",fontWeight:e.fontWeight.bold})),g5=l("p")(({theme:e})=>({color:e.palette.text.secondary})),ge=l("ul")(({theme:e})=>({listStyleType:"none",margin:0,padding:0,"& svg":{marginRight:e.spacing(1)}})),fe=l("p")(({theme:e})=>({marginLeft:e.spacing(4)})),f5=({healthReport:e})=>{const n=e.health<50?"error.main":e.health<75?"warning.main":"success.main",a=()=>c(p5,{children:[t(R4,{}),c("span",{children:[e.activeCount," active toggles"]})]}),r=()=>c(me,{children:[t(Z3,{}),c("span",{children:[e.staleCount," stale toggles"]})]}),o=()=>c(me,{children:[t(Z3,{}),c("span",{children:[e.potentiallyStaleCount," potentially stale toggles"]})]});return c(h5,{children:[c(A,{children:[t(f3,{children:"Health rating"}),t(T,{condition:e.health>-1,show:c(Q,{children:[c(m5,{sx:{color:n},children:[e.health,"%"]}),c(g5,{children:["Last updated:"," ",t(_3,{date:e.updatedAt,live:!1})]})]})})]}),c(A,{children:[t(f3,{children:"Toggle report"}),c(ge,{children:[t("li",{children:t(T,{condition:Boolean(e.activeCount),show:a})}),t(T,{condition:Boolean(e.activeCount),show:t(fe,{children:"Also includes potentially stale toggles."})}),t("li",{children:t(T,{condition:Boolean(e.staleCount),show:r})})]})]}),c(A,{sx:{flexBasis:"40%"},children:[t(f3,{children:"Potential actions"}),t(ge,{children:t("li",{children:t(T,{condition:Boolean(e.potentiallyStaleCount),show:o})})}),t(T,{condition:Boolean(e.potentiallyStaleCount),show:t(fe,{children:"Review your feature toggles and delete unused toggles."}),elseShow:t("span",{children:"No action is required"})})]})]})},v5=({row:e})=>{const n=h1();return e.original.expiredAt?t(n3,{value:e.original.expiredAt}):t(n1,{children:t(O,{variant:"body2",color:n.palette.text.secondary,children:"N/A"})})},y5=l("span")(({theme:e})=>({display:"flex",gap:"1ch",alignItems:"center",color:e.palette.warning.dark,"& svg":{color:e.palette.warning.main}})),b5=l("span")(({theme:e})=>({display:"flex",gap:"1ch",alignItems:"center",color:e.palette.success.dark,"& svg":{color:e.palette.success.main}})),C5=({row:e})=>e.original.status==="potentially-stale"?t(n1,{children:c(y5,{children:[t(kt,{}),t("span",{children:"Potentially stale"})]})}):t(n1,{children:c(b5,{children:[t(a0,{}),t("span",{children:"Healthy"})]})}),ve=40,S5=7,P0={[I4]:ve,[D4]:ve,[j4]:S5},I0=(e,n)=>Math.abs(P4(e,n)),D0=(e,n)=>e>=P0[n],x5=e=>{const{type:n,createdAt:a}=e,r=r0(a),o=new Date,i=I0(r,o);return D0(i,n)&&n!==o0&&n!==i0?"potentially-stale":"healthy"},w5=e=>{const{type:n,createdAt:a}=e;if(n===o0||n===i0)return;const r=r0(a),o=new Date,i=I0(r,o);if(D0(i,n)){const d=i-P0[n];return $t(o,d).toISOString()}},T5=({projectId:e,features:n})=>{const a=h1(),r=m1(a.breakpoints.down("sm")),o=m1(a.breakpoints.down("md")),i=m1(a.breakpoints.down("lg")),d=s.useMemo(()=>n.map(P=>({project:e,name:P.name,type:P.type,stale:P.stale,status:x5(P),lastSeenAt:P.lastSeenAt,createdAt:P.createdAt,expiredAt:w5(P)})),[e,n]),p=s.useMemo(()=>({hiddenColumns:[],sortBy:[{id:"createdAt"}]}),[]),{headerGroups:h,rows:u,prepareRow:g,state:{globalFilter:v},setGlobalFilter:f,setHiddenColumns:S}=t1.useTable({columns:ye,data:d,initialState:p,sortTypes:S2,autoResetGlobalFilter:!1,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0},t1.useGlobalFilter,t1.useFlexLayout,t1.useSortBy);C2([{condition:r,columns:["stale"]},{condition:o,columns:["expiredAt","lastSeenAt"]},{condition:i,columns:["createdAt"]}],S,ye);const j=u.length<d.length?`Feature toggles (${u.length} of ${d.length})`:`Feature toggles (${d.length})`;return c(g1,{header:t(d1,{title:j,actions:t(Z1,{initialValue:v,onChange:f})}),children:[t(J1,{value:v,children:t(r3,{headerGroups:h,prepareRow:g,rows:u})}),t(T,{condition:u.length===0,show:t(T,{condition:(v==null?void 0:v.length)>0,show:c(f1,{children:["No feature toggles found matching “",v,"”"]}),elseShow:t(f1,{children:"No feature toggles available. Get started by adding a new feature toggle."})})})]})},ye=[{Header:"Seen",accessor:"lastSeenAt",sortType:"date",align:"center",Cell:Qe,disableGlobalFilter:!0,maxWidth:85},{Header:"Type",accessor:"type",align:"center",Cell:Xe,disableGlobalFilter:!0,maxWidth:85},{Header:"Name",accessor:"name",sortType:"alphanumeric",Cell:k4,minWidth:120},{Header:"Created",accessor:"createdAt",sortType:"date",Cell:n3,disableGlobalFilter:!0,maxWidth:150},{Header:"Expired",accessor:"expiredAt",Cell:v5,disableGlobalFilter:!0,maxWidth:150},{Header:"Status",id:"status",accessor:"status",Cell:C5,disableGlobalFilter:!0,width:180},{Header:"State",accessor:"stale",sortType:"boolean",Cell:O4,disableGlobalFilter:!0,maxWidth:120}],A5=()=>{const e=J("projectId"),n=O1(e);$1(`Project health – ${n}`);const{healthReport:a,refetchHealthReport:r,error:o}=i5(e,{refreshInterval:15*1e3});return a?c("div",{children:[t(T,{condition:Boolean(o),show:t(We,{"data-loading":!0,style:{maxWidth:"500px",marginTop:"1rem"},onClick:r,text:`Could not fetch health rating for ${e}`})}),t(f5,{healthReport:a}),t(T5,{projectId:e,features:a.features})]}):null},E5=l("div")(({theme:e})=>({borderRadius:"12.5px",backgroundColor:e.palette.background.paper,padding:"2rem"})),Z5=()=>{const e=J("projectId");return t(E5,{children:t($4,{title:"Event Log",project:e,displayInline:!0})})},j0=(e,n)=>{const{data:a,error:r,mutate:o}=v2(G1(`api/admin/projects/${e}/change-requests/${n}`),R5,{refreshInterval:15e3});return{data:a,loading:!r&&!a,refetchChangeRequest:()=>o(),error:r}},R5=e=>fetch(e).then(K1("Request changes")).then(n=>n.json()),P5=l(F1)(({theme:e})=>({padding:e.spacing(3,4),borderRadius:`${e.shape.borderRadiusLarge}px`})),I5=l(A)(({theme:e})=>({display:"flex",alignItems:"center",marginBottom:e.spacing(2)})),D5=l(A)(({theme:e})=>({display:"flex",alignItems:"center"})),j5=l(O)(({theme:e})=>({display:"flex",alignItems:"center",marginRight:e.spacing(1),fontSize:e.fontSizes.mainHeader})),k5=l(F4)(({theme:e})=>({padding:e.spacing(.75,1.5),backgroundColor:e.palette.tertiary.light})),k0=l(x2)(({theme:e})=>({height:"24px",width:"24px"})),O5=({changeRequest:e})=>{var n,a;return c(P5,{elevation:0,children:[c(I5,{children:[c(j5,{variant:"h1",sx:{mr:1.5},children:["Change request #",e.id]}),t(c0,{state:e.state})]}),c(D5,{children:[c(O,{variant:"body2",sx:{margin:"auto 0"},children:["Created"," ",t(_3,{minPeriod:60,date:new Date(e.createdAt)})," ","by"]}),t(A,{sx:r=>({marginLeft:r.spacing(1)}),children:t(y2,{title:(n=e==null?void 0:e.createdBy)==null?void 0:n.username,children:t(k0,{src:(a=e==null?void 0:e.createdBy)==null?void 0:a.imageUrl})})}),t(A,{sx:r=>({marginLeft:r.spacing(1.5)}),children:t(k5,{variant:"outlined",children:c(O,{variant:"body2",sx:{lineHeight:1},children:["Environment:"," ",t(O,{display:"inline",fontWeight:"bold",variant:"body2",component:"span",children:e==null?void 0:e.environment})," ",t(B4,{})," Updates:"," ",c(O,{variant:"body2",display:"inline",fontWeight:"bold",component:"span",children:[e.features.length," ",e.features.length===1?"feature toggle":"feature toggles"]})]})})})]})]})},$5=s.createContext({}),H2=$5;function F5(e){return e2("MuiTimeline",e)}B1("MuiTimeline",["root","positionLeft","positionRight","positionAlternate"]);const B5=["position","className"],V5=e=>{const{position:n,classes:a}=e,r={root:["root",n&&`position${R1(n)}`]};return r2(r,F5,a)},L5=l("ul",{name:"MuiTimeline",slot:"Root",overridesResolver:(e,n)=>{const{ownerState:a}=e;return[n.root,a.position&&n[`position${R1(a.position)}`]]}})({display:"flex",flexDirection:"column",padding:"6px 16px",flexGrow:1}),_5=s.forwardRef(function(n,a){const r=t2({props:n,name:"MuiTimeline"}),{position:o="right",className:i}=r,d=n2(r,B5),p=r1({},r,{position:o}),h=V5(p),u=s.useMemo(()=>({position:o}),[o]);return t(H2.Provider,{value:u,children:t(L5,r1({className:a2(h.root,i),ownerState:p,ref:a},d))})}),O0=_5;function M5(e){return e2("MuiTimelineContent",e)}const z5=B1("MuiTimelineContent",["root","positionLeft","positionRight","positionAlternate"]),H5=["className"],N5=e=>{const{position:n,classes:a}=e,r={root:["root",`position${R1(n)}`]};return r2(r,M5,a)},W5=l(O,{name:"MuiTimelineContent",slot:"Root",overridesResolver:(e,n)=>{const{ownerState:a}=e;return[n.root,n[`position${R1(a.position)}`]]}})(({ownerState:e})=>r1({flex:1,padding:"6px 16px",textAlign:"left"},e.position==="left"&&{textAlign:"right"})),U5=s.forwardRef(function(n,a){const r=t2({props:n,name:"MuiTimelineContent"}),{className:o}=r,i=n2(r,H5),{position:d}=s.useContext(H2),p=r1({},r,{position:d||"right"}),h=N5(p);return t(W5,r1({component:"div",className:a2(h.root,o),ownerState:p,ref:a},i))}),$0=U5,q5=B1("MuiTimelineOppositeContent",["root","positionLeft","positionRight","positionAlternate"]),G5=q5;function K5(e){return e2("MuiTimelineItem",e)}const J5=B1("MuiTimelineItem",["root","positionLeft","positionRight","positionAlternate","missingOppositeContent"]),F0=J5,Y5=["position","className"],Q5=e=>{const{position:n,classes:a,hasOppositeContent:r}=e,o={root:["root",`position${R1(n)}`,!r&&"missingOppositeContent"]};return r2(o,K5,a)},X5=l("li",{name:"MuiTimelineItem",slot:"Root",overridesResolver:(e,n)=>{const{ownerState:a}=e;return[n.root,n[`position${R1(a.position)}`]]}})(({ownerState:e})=>r1({listStyle:"none",display:"flex",position:"relative",minHeight:70},e.position==="left"&&{flexDirection:"row-reverse"},e.position==="alternate"&&{"&:nth-of-type(even)":{flexDirection:"row-reverse",[`& .${z5.root}`]:{textAlign:"right"},[`& .${G5.root}`]:{textAlign:"left"}}},!e.hasOppositeContent&&{"&:before":{content:'""',flex:1,padding:"6px 16px"}})),e6=s.forwardRef(function(n,a){const r=t2({props:n,name:"MuiTimelineItem"}),{position:o,className:i}=r,d=n2(r,Y5),{position:p}=s.useContext(H2);let h=!1;s.Children.forEach(r.children,f=>{V4(f,["TimelineOppositeContent"])&&(h=!0)});const u=r1({},r,{position:o||p||"right",hasOppositeContent:h}),g=Q5(u),v=s.useMemo(()=>({position:u.position}),[u.position]);return t(H2.Provider,{value:v,children:t(X5,r1({className:a2(g.root,i),ownerState:u,ref:a},d))})}),B2=e6;function t6(e){return e2("MuiTimelineSeparator",e)}B1("MuiTimelineSeparator",["root"]);const n6=["className"],a6=e=>{const{classes:n}=e;return r2({root:["root"]},t6,n)},r6=l("div",{name:"MuiTimelineSeparator",slot:"Root",overridesResolver:(e,n)=>n.root})({display:"flex",flexDirection:"column",flex:0,alignItems:"center"}),o6=s.forwardRef(function(n,a){const r=t2({props:n,name:"MuiTimelineSeparator"}),{className:o}=r,i=n2(r,n6),d=r,p=a6(d);return t(r6,r1({className:a2(p.root,o),ownerState:d,ref:a},i))}),V2=o6;function i6(e){return e2("MuiTimelineDot",e)}B1("MuiTimelineDot",["root","filled","outlined","filledGrey","outlinedGrey","filledPrimary","outlinedPrimary","filledSecondary","outlinedSecondary"]);const c6=["className","color","variant"],s6=e=>{const{color:n,variant:a,classes:r}=e,o={root:["root",a,n!=="inherit"&&`${a}${R1(n)}`]};return r2(o,i6,r)},l6=l("span",{name:"MuiTimelineDot",slot:"Root",overridesResolver:(e,n)=>{const{ownerState:a}=e;return[n.root,n[a.color!=="inherit"&&`${a.variant}${R1(a.color)}`],n[a.variant]]}})(({ownerState:e,theme:n})=>r1({display:"flex",alignSelf:"baseline",borderStyle:"solid",borderWidth:2,padding:4,borderRadius:"50%",boxShadow:(n.vars||n).shadows[1],margin:"11.5px 0"},e.variant==="filled"&&r1({borderColor:"transparent"},e.color!=="inherit"&&r1({},e.color==="grey"?{color:(n.vars||n).palette.grey[50],backgroundColor:(n.vars||n).palette.grey[400]}:{color:(n.vars||n).palette[e.color].contrastText,backgroundColor:(n.vars||n).palette[e.color].main})),e.variant==="outlined"&&r1({boxShadow:"none",backgroundColor:"transparent"},e.color!=="inherit"&&r1({},e.color==="grey"?{borderColor:(n.vars||n).palette.grey[400]}:{borderColor:(n.vars||n).palette[e.color].main})))),d6=s.forwardRef(function(n,a){const r=t2({props:n,name:"MuiTimelineDot"}),{className:o,color:i="grey",variant:d="filled"}=r,p=n2(r,c6),h=r1({},r,{color:i,variant:d}),u=s6(h);return t(l6,r1({className:a2(u.root,o),ownerState:h,ref:a},p))}),B0=d6;function u6(e){return e2("MuiTimelineConnector",e)}B1("MuiTimelineConnector",["root"]);const p6=["className"],h6=e=>{const{classes:n}=e;return r2({root:["root"]},u6,n)},m6=l("span",{name:"MuiTimelineConnector",slot:"Root",overridesResolver:(e,n)=>n.root})(({theme:e})=>({width:2,backgroundColor:(e.vars||e).palette.grey[400],flexGrow:1})),g6=s.forwardRef(function(n,a){const r=t2({props:n,name:"MuiTimelineConnector"}),{className:o}=r,i=n2(r,p6),d=r,p=h6(d);return t(m6,r1({className:a2(p.root,o),ownerState:d,ref:a},i))}),te=g6,f6=l(F1)(({theme:e})=>({marginTop:e.spacing(2),borderRadius:`${e.shape.borderRadiusLarge}px`})),v6=l(A)(({theme:e})=>({padding:e.spacing(2),marginBottom:`-${e.spacing(4)}`})),y6=l(O0)(()=>({[`& .${F0.root}:before`]:{flex:0,padding:0}})),b6=({state:e})=>{const n=r=>["Draft","In review","Approved","Applied"].map(i=>({title:i,active:i===r}));return t(f6,{elevation:0,children:t(v6,{children:t(y6,{children:(()=>{const r=n(e),o=r.findIndex(d=>d.active),i=o!==-1?o:null;return e==="Cancelled"?S6(r):C6(r,i)})()})})})},C6=(e,n)=>e.map(({title:a},r)=>{const o=r<e.length-1,i=t(T,{condition:o,show:t(te,{})});return n!==null&&n>=r?L2("success",a,i):n!==null&&n+1===r?L2("primary",a,i,{variant:"outlined"}):L2("grey",a,i)}),S6=e=>e.map(({title:n},a)=>{const r=a<e.length-1;return L2("grey",n,t(T,{condition:r,show:t(te,{})}))}),L2=(e,n,a,r={})=>c(B2,{children:[c(V2,{children:[t(B0,{color:e,...r}),a]}),t($0,{children:n})]},n),x6=l(A)(({theme:e})=>({marginBottom:e.spacing(2)})),w6=({actualApprovals:e,minApprovals:n})=>c(Q,{children:["Reviewers"," ",c(O,{component:"span",color:"text.secondary",children:["(",e,"/",n," required)"]})]}),T6=({header:e,children:n})=>c(F1,{elevation:0,sx:a=>({marginTop:a.spacing(2),padding:a.spacing(4),borderRadius:r=>`${r.shape.borderRadiusLarge}px`}),children:[t(x6,{children:e}),t(O,{variant:"body1",color:"text.secondary",children:t(T,{condition:m2.Children.count(n)>0,show:"Approved by",elseShow:"No approvals yet"})}),n]}),A6=e=>s.createElement("svg",{width:18,height:14,viewBox:"0 0 18 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},s.createElement("path",{d:"M0.59 2.00016L2 0.590157L5.41 4.00016L4 5.41016L0.59 2.00016ZM13 11.5002L13 8.00016L7.41 8.00016L2 13.4102L0.59 12.0002L6.59 6.00016L13 6.00016L13 2.50016L17.5 7.00016L13 11.5002Z",fill:"currentColor"})),ne=()=>e=>e!=="color"&&e!=="sx"&&e!=="approved"&&e!=="border"&&e!=="bgColor"&&e!=="svgColor",N1=l(A)(({theme:e})=>({display:"flex",alignItems:"center"})),E6=l(s0)(({theme:e})=>({color:e.palette.error.main,height:"35px",width:"35px",marginRight:e.spacing(1)})),be=l(s0)(({theme:e})=>({color:e.palette.warning.main,height:"35px",width:"35px",marginRight:e.spacing(1)})),R3=l(l0)(({theme:e})=>({color:e.palette.success.main,height:"35px",width:"35px",marginRight:e.spacing(1)})),Z6=l(A)(({theme:e})=>({display:"flex",marginTop:e.spacing(2)})),R6=l(A,{shouldForwardProp:ne()})(({theme:e,bgColor:n,svgColor:a})=>({borderRadius:`${e.shape.borderRadiusMedium}px`,backgroundColor:n,padding:e.spacing(1,2),marginRight:e.spacing(2),height:"45px",width:"45px",display:"flex",alignItems:"center",justifyContent:"center",svg:{color:a}})),V0=l(Ge)(({theme:e})=>({margin:e.spacing(2.5,0)})),P6=l(A,{shouldForwardProp:ne()})(({theme:e,border:n})=>({borderRadius:`${e.shape.borderRadiusLarge}px`,border:n,padding:e.spacing(3),width:"100%"})),W1=l(O,{shouldForwardProp:ne()})(({theme:e,color:n})=>({fontWeight:"bold",color:n})),I6=(e,n)=>e==="Approved"?`2px solid ${n.palette.success.main}`:e==="Applied"?`2px solid ${n.palette.primary.main}`:`1px solid ${n.palette.tertiary.main}`,D6=(e,n)=>e==="Approved"?{bgColor:n.palette.success.main,svgColor:n.palette.tertiary.background}:e==="Applied"?{bgColor:n.palette.primary.main,svgColor:n.palette.tertiary.background}:{bgColor:n.palette.tableHeaderBackground,svgColor:n.palette.neutral.main},j6=({changeRequest:e})=>{const n=h1();return c(Z6,{children:[t(R6,{...D6(e.state,n),children:t(A6,{style:{transform:"scale(1.5)"}})}),t(P6,{sx:{backgroundColor:e.state==="In review"?n.palette.warning.light:"initial"},border:I6(e.state,n),children:t(k6,{changeRequest:e})})]})},k6=({changeRequest:e})=>{const{state:n}=e;return n?n==="Approved"?t(O6,{}):n==="Applied"?t(F6,{}):n==="Cancelled"?t(B6,{}):t($6,{minApprovals:e.minApprovals}):null},O6=()=>{const e=h1();return c(Q,{children:[c(N1,{children:[t(R3,{}),c(A,{children:[t(W1,{color:e.palette.success.main,children:"Changed approved"}),t(O,{children:"One approving review from requested approvers"})]})]}),t(V0,{}),c(N1,{children:[t(R3,{}),t(A,{children:t(W1,{color:e.palette.success.main,children:"Changes are ready to be applied"})})]})]})},$6=({minApprovals:e})=>{const n=h1();return c(Q,{children:[c(N1,{children:[t(be,{}),c(A,{children:[t(W1,{color:n.palette.warning.main,children:"Review required"}),c(O,{children:["At least ",e," approval(s) must be submitted before changes can be applied"]})]})]}),t(V0,{}),c(N1,{children:[t(be,{}),t(W1,{color:n.palette.warning.main,children:"Apply changes is blocked"})]})]})},F6=()=>{const e=h1();return t(Q,{children:c(N1,{children:[t(R3,{sx:{color:e.palette.primary.main}}),t(A,{children:t(W1,{color:e.palette.primary.main,children:"Changes applied"})})]})})},B6=()=>{const e=h1();return t(Q,{children:c(N1,{children:[t(E6,{}),t(A,{children:t(W1,{color:e.palette.error.main,children:"Changes cancelled"})})]})})};var ae={},V6=Q1;Object.defineProperty(ae,"__esModule",{value:!0});var L0=ae.default=void 0,L6=V6(Y1()),_6=X1,M6=(0,L6.default)((0,_6.jsx)("path",{d:"m7 10 5 5 5-5z"}),"ArrowDropDown");L0=ae.default=M6;const z6=({disabled:e})=>{const{isAdmin:n}=s.useContext(w2),a=J("projectId"),r=J("id"),{user:o}=d0(),{refetchChangeRequest:i,data:d}=j0(a,r),{refetch:p}=u0(a),{setToastApiError:h,setToastData:u}=b1(),{changeState:g}=M3(),[v,f]=m2.useState(!1),S=m2.useRef(null),j=async()=>{try{await g(a,Number(r),{state:"Approved"}),i(),p(),u({type:"success",title:"Success",text:"Changes approved"})}catch(w){h(E1(w))}},P=()=>{f(w=>!w)},D=w=>{S.current&&S.current.contains(w.target)||f(!1)};return c(m2.Fragment,{children:[t(p0,{variant:"contained",disabled:e||(d==null?void 0:d.createdBy.id)===(o==null?void 0:o.id)&&!n,"aria-controls":v?"review-options-menu":void 0,"aria-expanded":v?"true":void 0,"aria-label":"review changes","aria-haspopup":"menu",onClick:P,ref:S,endIcon:t(L0,{}),permission:L4,projectId:a,environmentId:d==null?void 0:d.environment,children:"Review changes"}),t(_4,{sx:{zIndex:1},open:v,anchorEl:S.current,role:void 0,transition:!0,disablePortal:!0,children:({TransitionProps:w,placement:$})=>t(M4,{...w,style:{transformOrigin:$==="bottom"?"center top":"center bottom"},children:t(F1,{children:t(z4,{onClickAway:D,children:t(B3,{id:"review-options-menu",autoFocusItem:!0,children:t(h2,{onClick:j,children:"Approve changes"})})})})})})]})},H6=l(A)(({theme:e})=>({display:"flex",alignItems:"center",flexWrap:"wrap",marginTop:e.spacing(1.5),gap:e.spacing(1)})),N6=l(l0)(({theme:e})=>({color:e.palette.success.main,marginLeft:"auto"})),W6=({name:e,imageUrl:n})=>c(H6,{children:[t(k0,{src:n}),t(O,{variant:"body1",color:"text.primary",sx:{maxWidth:"170px",textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap"},children:e}),t(N6,{})]}),_0=l(x2)(({theme:e})=>({height:"32px",width:"32px",marginTop:e.spacing(1),marginRight:e.spacing(2)})),U6=l(A)(({theme:e})=>({display:"flex",marginTop:e.spacing(2)})),q6=l(F1)(({theme:e})=>({width:"100%",padding:e.spacing(1.5,3,2.5,3),backgroundColor:e.palette.neutral.light,borderRadius:e.shape.borderRadiusLarge,borderColor:e.palette.divider})),G6=l(A)(({theme:e})=>({display:"flex",borderBottom:"1px solid",borderColor:e.palette.dividerAlternative,paddingBottom:e.spacing(1.5)})),K6=({comment:e})=>c(U6,{children:[t(y2,{title:e.createdBy.username,children:t(_0,{src:e.createdBy.imageUrl})}),c(q6,{variant:"outlined",children:[t(G6,{children:c(A,{children:[t("strong",{children:e.createdBy.username})," ",c(O,{color:"text.secondary",component:"span",children:["commented"," ",t(_3,{minPeriod:60,date:new Date(e.createdAt)})]})]})}),t(A,{sx:{paddingTop:2.5},children:e.text})]})]}),J6=l(A)(({theme:e})=>({display:"flex",marginTop:e.spacing(2),marginBottom:e.spacing(1)})),Y6=({user:e,commentText:n,onTypeComment:a,children:r})=>c(Q,{children:[c(J6,{children:[t(y2,{title:(e==null?void 0:e.name)||(e==null?void 0:e.username),children:t(_0,{src:(e==null?void 0:e.imageUrl)||""})}),t(M2,{variant:"outlined",placeholder:"Add your comment here",fullWidth:!0,multiline:!0,minRows:2,onChange:o=>a(o.target.value),value:n})]}),t(A,{sx:{display:"flex",justifyContent:"flex-end"},children:r})]}),Q6=l(A)(({theme:e})=>({width:"30%",display:"flex",flexDirection:"column",[e.breakpoints.down("sm")]:{width:"100%"}})),X6=l(F1)(({theme:e})=>({marginTop:e.spacing(2),marginLeft:e.spacing(2),width:"70%",padding:e.spacing(1,2),borderRadius:e.shape.borderRadiusLarge,[e.breakpoints.down("sm")]:{marginLeft:0,width:"100%"}})),ea=l(A)(({theme:e})=>({marginTop:e.spacing(3),display:"flex",justifyContent:"flex-end"})),ta=l(A)(({theme:e})=>({padding:e.spacing(2)})),na=l(A)(({theme:e})=>({display:"flex",[e.breakpoints.down("sm")]:{flexDirection:"column"}})),aa=()=>{var H,G;const e=J("projectId"),[n,a]=s.useState(!1),{user:r}=d0(),{isAdmin:o}=s.useContext(w2),[i,d]=s.useState(""),p=J("id"),{data:h,refetchChangeRequest:u}=j0(e,p),{changeState:g,addComment:v}=M3(),{refetch:f}=u0(e),{setToastData:S,setToastApiError:j}=b1(),{isChangeRequestConfigured:P}=L3(e);if(!h)return null;const D=P(h.environment),w=async()=>{try{await g(e,Number(p),{state:"Applied"}),u(),f(),S({type:"success",title:"Success",text:"Changes applied"})}catch(B){j(E1(B))}},$=async()=>{try{await v(e,p,i),d(""),u(),S({type:"success",title:"Success",text:"Comment added"})}catch(B){j(E1(B))}},W=async()=>{try{await g(e,Number(p),{state:"Cancelled"}),a(!1),u(),f(),S({type:"success",title:"Success",text:"Changes cancelled"})}catch(B){j(E1(B))}},F=()=>a(!0),U=()=>a(!1),y=(h==null?void 0:h.createdBy.id)===(r==null?void 0:r.id)&&h.state==="In review"&&!o,Z=h.approvals.some(B=>B.createdBy.id===(r==null?void 0:r.id));return c(Q,{children:[t(O5,{changeRequest:h}),c(na,{children:[c(Q6,{children:[t(b6,{state:h.state}),t(T6,{header:t(w6,{actualApprovals:h.approvals.length,minApprovals:h.minApprovals}),children:(H=h.approvals)==null?void 0:H.map(B=>t(W6,{name:B.createdBy.username||"Unknown user",imageUrl:B.createdBy.imageUrl},B.createdBy.username))})]}),t(X6,{elevation:0,children:c(ta,{children:["Requested Changes (",H4(h),")",t(N4,{changeRequest:h,onRefetch:u}),(G=h.comments)==null?void 0:G.map(B=>t(K6,{comment:B},B.id)),t(Y6,{user:r,commentText:i,onTypeComment:d,children:t(v1,{variant:"outlined",onClick:$,disabled:!D||i.trim().length===0||i.trim().length>1e3,children:"Comment"})}),t(T,{condition:y,show:t(q1,{sx:B=>({marginTop:B.spacing(1.5)}),severity:"info",children:"You can not approve your own change request"})}),t(j6,{changeRequest:h}),c(ea,{children:[t(T,{condition:h.state==="In review"&&!Z,show:t(z6,{disabled:!D})}),t(T,{condition:h.state==="Approved",show:t(p0,{variant:"contained",onClick:w,projectId:e,permission:W4,environmentId:h.environment,disabled:!D,children:"Apply changes"})}),t(T,{condition:h.state!=="Applied"&&h.state!=="Cancelled"&&(h.createdBy.id===(r==null?void 0:r.id)||o),show:t(v1,{sx:{marginLeft:B=>B.spacing(2)},variant:"outlined",onClick:F,children:"Cancel changes"})})]})]})}),c(Q2,{open:n,onClick:W,onClose:U,title:"Cancel change request",children:[t(O,{sx:{marginBottom:2},children:"You are about to cancel this change request"}),t(O,{variant:"body2",sx:B=>({color:B.palette.neutral.dark}),children:"The change request will be moved to closed, and it can't be applied anymore. Once cancelled, the change request can't be reopened."})]})]})]})},ra=({value:e})=>{const n=()=>e?t(c0,{state:e}):null;return e?t(n1,{children:n()}):t(n1,{})},oa=({value:e})=>t(n1,{children:t(o3,{user:e,sx:{maxWidth:"30px",maxHeight:"30px",alignSelf:"left"}})}),ia=l("div")(({theme:e})=>({display:"flex",flexDirection:"row",margin:0})),ca=({value:e,row:{original:n}})=>{const a=J("projectId"),{id:r,features:o}=n,i=U4(),d=`/projects/${a}/change-requests/${r}`;return e?c(n1,{sx:{minWidth:"200px"},children:[t(ia,{children:c(O,{component:"span",variant:"body2",color:i.palette.text.secondary,children:[t(q4,{component:H1,underline:"hover",to:d,sx:p=>({paddingTop:p.spacing(.2),marginRight:p.spacing(1),"&:hover":{textDecoration:"underline"}}),children:"Change request"}),`#${r}`]})}),c("span",{children:[`${o==null?void 0:o.length}`," ",o.length<=1?"update":"updates"]})]}):t(n1,{})},sa=Je()(e=>({header:{padding:e.spacing(0,4)},bodyClass:{padding:e.spacing(4),overflowX:"auto"}})),la={id:"createdAt"},da=l("div")({paddingLeft:0,paddingBottom:0}),ua=l(_2)(({theme:e})=>({textTransform:"none",width:"auto",fontSize:e.fontSizes.bodySize,[e.breakpoints.up("md")]:{minWidth:160}})),pa=({changeRequests:e=[],loading:n,projectId:a})=>{var X,m;const{classes:r}=sa(),o=m1(G4.breakpoints.down("md")),[i,d]=V3(),[p,h]=s.useState(i.get("search")||""),{value:u,setValue:g}=e3(`${a}:ProjectChangeRequest`,la),[v,f]=s.useMemo(()=>{const b=e.filter(R=>R.state!=="Cancelled"&&R.state!=="Applied"),k=e.filter(R=>R.state==="Cancelled"||R.state==="Applied");return[b,k]},[e]),S=[{title:"Change requests",data:v},{title:"Closed",data:f}],[j,P]=s.useState(0),D=s.useMemo(()=>[{id:"Title",Header:"Title",width:100,canSort:!0,accessor:"id",Cell:ca},{Header:"By",accessor:"createdBy",maxWidth:50,canSort:!1,Cell:oa,align:"center"},{Header:"Submitted",accessor:"createdAt",searchable:!0,maxWidth:100,Cell:z2,sortType:"alphanumeric"},{Header:"Environment",accessor:"environment",searchable:!0,maxWidth:100,Cell:n1},{Header:"Status",accessor:"state",searchable:!0,minWidth:150,width:150,Cell:ra}],[a]),{data:w,getSearchText:$,getSearchContext:W}=a3(D,p,(X=S[j])==null?void 0:X.data),F=s.useMemo(()=>n?K4:w,[w,n]),[U]=s.useState(()=>({sortBy:[{id:i.get("sort")||u.id,desc:i.has("order")?i.get("order")==="desc":u.desc}],hiddenColumns:[]})),{headerGroups:y,rows:Z,state:{sortBy:H},prepareRow:G,setHiddenColumns:B,getTableProps:u1,getTableBodyProps:o1}=t1.useTable({columns:D,data:F,initialState:U,sortTypes:S2,autoResetHiddenColumns:!1,disableSortRemove:!0,autoResetSortBy:!1,defaultColumn:{Cell:n1}},t1.useSortBy);return C2([{condition:o,columns:["createdBy"]}],B,D),s.useEffect(()=>{if(n)return;const b={};b.sort=H[0].id,H[0].desc&&(b.order="desc"),p&&(b.search=p),d(b,{replace:!0}),g(k=>({...k,id:H[0].id,desc:H[0].desc||!1}))},[n,H,p,d]),c(g1,{isLoading:n,bodyClass:r.bodyClass,headerClass:r.header,header:t(d1,{titleElement:t(da,{children:t(z3,{value:(m=S[j])==null?void 0:m.title,indicatorColor:"primary",textColor:"primary",variant:"scrollable",allowScrollButtonsMobile:!0,children:S.map((b,k)=>t(ua,{label:`${b.title} (${b.data.length})`,value:b.title,onClick:()=>P(k)},b.title))})}),actions:t(Z1,{initialValue:p,onChange:h,hasFilters:!0,getSearchContext:W})}),children:[t(J1,{value:$(p),children:c(q2,{...u1(),children:[t(G2,{headerGroups:y}),t(K2,{...o1(),children:Z.map(b=>(G(b),t(J2,{hover:!0,...b.getRowProps(),children:b.cells.map(k=>t(Y2,{...k.getCellProps(),padding:"none",children:k.render("Cell")}))})))})]})}),t(T,{condition:Z.length===0,show:()=>t(T,{condition:(p==null?void 0:p.length)>0,show:c(f1,{children:["No changes found matching “",p,"”"]}),elseShow:t(f1,{children:"None of the changes were submitted yet."})})})]})},ha=e=>fetch(e).then(K1("ChangeRequest")).then(n=>n.json()),ma=e=>{const{data:n,error:a,mutate:r}=J4([],G1(`api/admin/projects/${e}/change-requests`),ha);return s.useMemo(()=>({changeRequests:n,loading:!a&&!n,refetch:r,error:a}),[n,a,r])},ga=()=>{const e=J("projectId"),n=O1(e),{isOss:a,isPro:r}=y1();$1(`Change requests – ${n}`);const{changeRequests:o,loading:i}=ma(e);return a()||r()?t(g1,{sx:{justifyContent:"center"},children:t(H3,{feature:"change-requests"})}):t(pa,{changeRequests:o,projectId:e,loading:i})};var M=(e=>(e.USER="USERS",e.GROUP="GROUPS",e.SERVICE_ACCOUNT="SERVICE ACCOUNTS",e))(M||{});const o2=(e,n={})=>{const a=G1(`api/admin/projects/${e}/access`),r=()=>fetch(a,{method:"GET"}).then(K1("project access")).then(v=>v.json()),o=`api/admin/projects/${e}/users`,{data:i,error:d}=v2(o,r,n),[p,h]=s.useState(!d&&!i),u=()=>{n0(o)};return s.useEffect(()=>{h(!d&&!i)},[i,d]),{access:s.useMemo(()=>{if(i)return fa({roles:i.roles,users:i.users.filter(({accountType:v})=>!v||v==="User"),serviceAccounts:i.users.filter(({accountType:v})=>v==="Service Account"),groups:(i==null?void 0:i.groups.map(v=>({...v,users:Et(v.users??[])})))??[]})},[i]),error:d,loading:p,refetchProjectAccess:u}},fa=e=>{const n=e.users||[],a=e.serviceAccounts||[],r=e.groups||[];return{...e,rows:[...n.map(o=>({entity:o,type:"USERS"})),...a.map(o=>({entity:o,type:"SERVICE ACCOUNTS"})),...r.map(o=>({entity:o,type:"GROUPS"}))]}},va=l(g1)(({theme:e})=>({height:"100vh",overflow:"auto",padding:e.spacing(7.5,6),[e.breakpoints.down("md")]:{padding:e.spacing(4,2)},"& .header":{padding:e.spacing(0,0,2,0)},"& .body":{padding:e.spacing(3,0,0,0)},borderRadius:`${e.spacing(1.5,0,0,1.5)} !important`})),ya=l("div")(({theme:e})=>({display:"flex",flexDirection:"column","& > span":{color:e.palette.text.secondary,fontSize:e.fontSizes.bodySize}})),Ce={id:"joinedAt"},v3=[{Header:"Avatar",accessor:"imageUrl",Cell:({row:{original:e}})=>t(n1,{children:t(o3,{user:e})}),maxWidth:85,disableSortBy:!0},{id:"name",Header:"Name",accessor:e=>e.name||"",Cell:g2,minWidth:100,searchable:!0},{id:"username",Header:"Username",accessor:e=>e.username||e.email,Cell:g2,minWidth:100,searchable:!0},{id:"joined",Header:"Joined",accessor:"joinedAt",Cell:n3,sortType:"date",maxWidth:150},{id:"lastLogin",Header:"Last login",accessor:e=>e.seenAt||"",Cell:({row:{original:e}})=>t(z2,{value:e.seenAt,emptyText:"Never",title:n=>`Last login: ${n}`}),sortType:"date",maxWidth:150}],ba=["imageUrl","name","joined","lastLogin"],Ca=({open:e,setOpen:n,group:a,projectId:r,subtitle:o,onEdit:i,onRemove:d})=>{const p=h1(),h=m1(p.breakpoints.down("md")),[u]=s.useState(()=>({sortBy:[{id:Ce.id,desc:Ce.desc}]})),[g,v]=s.useState(""),{data:f,getSearchText:S,getSearchContext:j}=a3(v3,g,(a==null?void 0:a.users)??[]),{headerGroups:P,rows:D,prepareRow:w,setHiddenColumns:$}=t1.useTable({columns:v3,data:f,initialState:u,sortTypes:S2,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},t1.useSortBy,t1.useFlexLayout);return C2([{condition:h,columns:ba}],$,v3),t(N3,{open:e,onClose:()=>{n(!1)},label:(a==null?void 0:a.name)||"Group",children:c(va,{header:t(d1,{secondary:!0,titleElement:c(ya,{children:[a==null?void 0:a.name," (",D.length<f.length?`${D.length} of ${f.length}`:f.length,")",t("span",{children:o})]}),actions:c(Q,{children:[t(T,{condition:!h,show:c(Q,{children:[t(Z1,{initialValue:g,onChange:v,hasFilters:!0,getSearchContext:j}),t(d1.Divider,{})]})}),t(k1,{permission:x1,projectId:r,tooltipProps:{title:"Edit group access"},onClick:i,children:t(W3,{})}),t(k1,{permission:x1,projectId:r,tooltipProps:{title:"Remove group access"},onClick:d,children:t(U3,{})})]}),children:t(T,{condition:h,show:t(Z1,{initialValue:g,onChange:v,hasFilters:!0,getSearchContext:j})})}),children:[t(J1,{value:S(g),children:t(r3,{rows:D,headerGroups:P,prepareRow:w})}),t(T,{condition:D.length===0,show:t(T,{condition:(g==null?void 0:g.length)>0,show:c(f1,{children:["No users found matching “",g,"” in this group."]}),elseShow:t(f1,{children:"This group is empty. Get started by adding a user to the group."})})})]})})},Sa=({permissions:e})=>t(Q,{children:e==null?void 0:e.filter(n=>!n.environment).map(n=>n.displayName).sort().map(n=>t("p",{children:n},n))}),xa=({environment:e,permissions:n})=>t(Q,{children:[...new Set(n.filter(a=>a.environment===e).map(a=>a.displayName))].sort().map(a=>t("p",{children:a},`${e}-${a}`))}),wa=l("div",{shouldForwardProp:e=>e!=="roleId"&&e!=="popover"&&e!=="sx"})(({theme:e,popover:n})=>({width:"100%",maxWidth:e.spacing(50),padding:e.spacing(3),backgroundColor:n?e.palette.background.paper:e.palette.neutral.light,color:e.palette.text.secondary,fontSize:e.fontSizes.smallBody,borderRadius:e.shape.borderRadiusMedium})),y3=l("div")(({theme:e})=>({"& p:last-child":{marginBottom:e.spacing(2)}})),Se=l("p")(({theme:e})=>({color:e.palette.text.primary,fontSize:e.fontSizes.smallBody,fontWeight:e.fontWeight.bold,marginBottom:e.spacing(2)})),xe=l("p")(({theme:e})=>({color:e.palette.text.primary,fontSize:e.fontSizes.smallBody,marginBottom:e.spacing(1)})),M0=s.forwardRef(({roleId:e,projectId:n,className:a,sx:r,...o},i)=>{var v;const{role:d}=Zt(e.toString()),{access:p}=o2(n),h=p==null?void 0:p.roles.find(f=>f.id===e),u=s.useMemo(()=>{var S;const f=new Set;return(S=d.permissions)==null||S.filter(j=>j.environment).forEach(j=>{f.add(j.environment)}),[...f].sort()},[d]),g=s.useMemo(()=>{var f;return(f=d.permissions)==null?void 0:f.filter(S=>!S.environment)},[d]);return t(wa,{className:a,sx:r,...o,ref:i,children:t(T,{condition:((v=d.permissions)==null?void 0:v.length)>0,show:c(Q,{children:[t(T,{condition:Boolean(g==null?void 0:g.length),show:c(Q,{children:[t(Se,{children:"Project permissions"}),t(y3,{children:t(Sa,{permissions:d.permissions})})]})}),t(T,{condition:Boolean(u.length),show:c(Q,{children:[t(Se,{children:"Environment permissions"}),u.map(f=>c("div",{children:[t(xe,{children:f}),t(y3,{children:t(xa,{environment:f,permissions:d.permissions})})]},f))]})})]}),elseShow:c(Q,{children:[t(xe,{children:h==null?void 0:h.name}),t(y3,{children:h==null?void 0:h.description})]})})})}),Ta=l("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),we=l("p")(({theme:e})=>({color:e.palette.text.secondary,marginBottom:e.spacing(1)})),Te=l("div")(({theme:e})=>({"& > div:first-of-type":{width:"100%",maxWidth:e.spacing(50),marginBottom:e.spacing(2)}})),Aa=l("div")(({theme:e})=>({marginTop:e.spacing(6),display:"flex",justifyContent:"flex-end"})),Ea=l(v1)(({theme:e})=>({marginLeft:e.spacing(3)})),Za=l("div")(({theme:e})=>({display:"flex",flexDirection:"column","& > span:last-of-type":{color:e.palette.text.secondary}})),Ra=l("div")(({theme:e})=>({display:"flex",flexDirection:"column","& > span:first-of-type":{color:e.palette.text.secondary}})),Pa=l("div")(({theme:e})=>({display:"flex",flexDirection:"column","& > span:last-of-type":{fontSize:e.fontSizes.smallerBody,color:e.palette.text.secondary}})),re=({selected:e,accesses:n,users:a,serviceAccounts:r,groups:o,roles:i})=>{const{uiConfig:d}=y1(),{flags:p}=d,h=p.UG?"user / group":"user",u=J("projectId"),{refetchProjectAccess:g}=o2(u),{addAccessToProject:v,changeUserRole:f,changeGroupRole:S,loading:j}=O3(),P=Boolean(e),{setToastData:D,setToastApiError:w}=b1(),$=b2(),W=[...o.filter(m=>P||!n.some(({entity:{id:b},type:k})=>m.id===b&&k===M.GROUP)).map(m=>({id:m.id,entity:m,type:M.GROUP})),...a.filter(m=>P||!n.some(({entity:{id:b},type:k})=>m.id===b&&k===M.USER)).sort((m,b)=>{const k=m.name||m.username||"",R=b.name||b.username||"";return k.localeCompare(R)}).map(m=>({id:m.id,entity:m,type:M.USER})),...r.filter(m=>P||!n.some(({entity:{id:b},type:k})=>m.id===b&&k===M.SERVICE_ACCOUNT)).sort((m,b)=>{const k=m.name||m.username||"",R=b.name||b.username||"";return k.localeCompare(R)}).map(m=>({id:m.id,entity:m,type:M.SERVICE_ACCOUNT}))],[F,U]=s.useState(()=>W.filter(({id:m,type:b})=>m===(e==null?void 0:e.entity.id)&&b===(e==null?void 0:e.type))),[y,Z]=s.useState(i.find(({id:m})=>m===(e==null?void 0:e.entity.roleId))??null),H={users:F==null?void 0:F.filter(({type:m})=>m===M.USER||m===M.SERVICE_ACCOUNT).map(({id:m})=>({id:m})),groups:F==null?void 0:F.filter(({type:m})=>m===M.GROUP).map(({id:m})=>({id:m}))},G=async m=>{if(m.preventDefault(),!!X)try{P?(e==null?void 0:e.type)===M.USER||(e==null?void 0:e.type)===M.SERVICE_ACCOUNT?await f(u,y.id,e.entity.id):(e==null?void 0:e.type)===M.GROUP&&await S(u,y.id,e.entity.id):await v(u,y.id,H),g(),$(g3),D({title:`${F.length} ${F.length===1?"access":"accesses"} ${P?"edited":"assigned"} successfully`,type:"success"})}catch(b){w(E1(b))}},B=()=>P?`curl --location --request ${P?"PUT":"POST"} '${d.unleashUrl}/api/admin/projects/${u}/${(e==null?void 0:e.type)===M.USER||(e==null?void 0:e.type)===M.SERVICE_ACCOUNT?"users":"groups"}/${e==null?void 0:e.entity.id}/roles/${y==null?void 0:y.id}' \\
|
|
3
3
|
--header 'Authorization: INSERT_API_KEY'`:`curl --location --request ${P?"PUT":"POST"} '${d.unleashUrl}/api/admin/projects/${u}/role/${y==null?void 0:y.id}/access' \\
|
|
4
4
|
--header 'Authorization: INSERT_API_KEY' \\
|