unleash-server 4.22.0 → 4.22.2
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/dist/lib/routes/admin-api/api-token.js +1 -1
- package/dist/lib/routes/admin-api/api-token.js.map +1 -1
- package/dist/lib/routes/admin-api/project/api-token.js +1 -1
- package/dist/lib/routes/admin-api/project/api-token.js.map +1 -1
- package/dist/lib/routes/admin-api/user/pat.d.ts +1 -0
- package/dist/lib/routes/admin-api/user/pat.js +9 -0
- package/dist/lib/routes/admin-api/user/pat.js.map +1 -1
- package/dist/lib/services/project-schema.js +1 -4
- package/dist/lib/services/project-schema.js.map +1 -1
- package/dist/lib/services/proxy-service.d.ts +6 -1
- package/dist/lib/services/proxy-service.js +18 -7
- package/dist/lib/services/proxy-service.js.map +1 -1
- package/dist/lib/types/experimental.d.ts +1 -0
- package/dist/lib/types/experimental.js +1 -0
- package/dist/lib/types/experimental.js.map +1 -1
- package/dist/test/e2e/api/proxy/proxy.concurrency.e2e.test.d.ts +1 -0
- package/dist/test/e2e/api/proxy/proxy.concurrency.e2e.test.js +58 -0
- package/dist/test/e2e/api/proxy/proxy.concurrency.e2e.test.js.map +1 -0
- package/frontend/build/index.html +1 -1
- package/frontend/build/static/{CreateProject-79087949.js → CreateProject-51932050.js} +1 -1
- package/frontend/build/static/{Error-b8ec37c0.js → Error-e6e1194a.js} +1 -1
- package/frontend/build/static/{ExpandMore-4c20b51c.js → ExpandMore-d71bbced.js} +1 -1
- package/frontend/build/static/{FeatureArchiveDialog-b81c4e16.js → FeatureArchiveDialog-fd71aac2.js} +1 -1
- package/frontend/build/static/{FeatureMetricsChart-37e55387.js → FeatureMetricsChart-66e2ebdf.js} +1 -1
- package/frontend/build/static/FeatureViewLazyExport-3403c2b4.js +7 -0
- package/frontend/build/static/{LazyAdminExport-0f2734aa.js → LazyAdminExport-17ef1739.js} +2 -2
- package/frontend/build/static/{LazyProjectExport-cb47b897.js → LazyProjectExport-96365c31.js} +1 -1
- package/frontend/build/static/{NetworkOverview-8b64cc40.js → NetworkOverview-02d7cec9.js} +1 -1
- package/frontend/build/static/{NetworkTraffic-38cef6f4.js → NetworkTraffic-ea8ea762.js} +1 -1
- package/frontend/build/static/{Playground-4e2c6704.js → Playground-1b14c01c.js} +1 -1
- package/frontend/build/static/{StrategyItemContainer-d93244f3.js → StrategyItemContainer-7ce39bda.js} +1 -1
- package/frontend/build/static/{chartjs-adapter-date-fns.esm-24250637.js → chartjs-adapter-date-fns.esm-8ccfeb24.js} +1 -1
- package/frontend/build/static/{index-32a0dc63.js → index-17782336.js} +1 -1
- package/frontend/build/static/{index-c4e310cb.js → index-1d165488.js} +66 -66
- package/frontend/build/static/{index-fe84ab30.js → index-96dcc77e.js} +1 -1
- package/frontend/build/static/{unknownify-8af014d5.js → unknownify-132fbce3.js} +1 -1
- package/frontend/build/static/{useProjectRole-08992a4c.js → useProjectRole-f048973d.js} +1 -1
- package/package.json +1 -1
- package/frontend/build/static/FeatureViewLazyExport-10ea877c.js +0 -7
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{aB as mn,aC as fn,s as d,r as f,aD as yn,aE as Sn,aF as ht,j as t,aG as bn,aH as Cn,c as zt,aI as F,aJ as j,aK as vn,f as c,aL as wn,C as I,aM as Q,aN as le,aO as J,aP as me,aQ as Tn,aR as Qe,aS as be,aT as ke,aU as Ze,u as et,aV as oe,F as M,aW as mt,aX as ft,aY as tt,aZ as ae,a_ as de,T as N,a$ as Ce,a2 as G,ar as ge,b0 as nt,b1 as ve,A as he,b2 as Wt,a4 as z,b3 as xn,b4 as An,b5 as En,b6 as In,ap as we,b7 as Rn,b8 as ue,b9 as ee,m as $e,ba as Fn,bb as kn,bc as Pe,a8 as Be,bd as Ut,be as qt,bf as at,bg as $n,bh as Pn,bi as Bn,a as H,p as Dn,N as De,B as fe,bj as ot,a9 as re,bk as On,x as st,an as Ie,E as Vn,bl as rt,bm as Re,P as Mn,bn as Ln,bo as ne,bp as _n,bq as jn,D as Nn,br as zn,bs as Wn,bt as Un,bu as Ht,bv as qn,bw as Hn,bx as Gn,by as Yn,bz as Kn,bA as Jn,bB as Te,bC as Xn,bD as Qn,bE as it,bF as Zn,bG as ea,as as Gt,bH as ta,w as Yt,af as ye,bI as na,bJ as aa,bK as Ye,bL as Kt,bM as Jt,bN as se,bO as Ke,bP as oa,ac as Xt,bQ as Qt,a3 as ct,ad as sa,bR as ra,bS as Zt,bT as ia,bU as ca,bV as en,bW as la,H as lt,bX as da,am as ua,av as pa,bY as ce,bZ as yt,b_ as ga,b$ as ha,c0 as ma,c1 as fa,ak as dt,al as ya,V as St,c2 as Sa,c3 as ba,c4 as Ca,c5 as tn,d as Le,l as va,U as wa,g as Ta,S as xa,h as Aa,i as Ea,k as Ia,I as Ra,c6 as Fa,c7 as ka,c8 as bt,c9 as $a,ca as nn,cb as Pa,ae as Ba,cc as Ct,cd as Da,ce as Oa,cf as Va,cg as Ma,ch as La,ci as _a,M as ja,cj as Na,ck as za,cl as Wa,cm as Ua,cn as qa,co as Ha}from"./index-1d165488.js";import{C as Oe,f as Ga,u as Ya,U as Ka,E as Ja,V as Xa,a as Qa,b as Za,c as eo,T as to,d as no,F as ao,A as oo,W as so,e as ro,g as io}from"./FeatureArchiveDialog-fd71aac2.js";import{S as co}from"./StrategyItemContainer-7ce39bda.js";import{E as lo}from"./ExpandMore-d71bbced.js";import{v as _e}from"./v4-a960c1f4.js";function uo(e){return mn("MuiCardContent",e)}fn("MuiCardContent",["root"]);const po=["className","component"],go=e=>{const{classes:n}=e;return Cn({root:["root"]},uo,n)},ho=d("div",{name:"MuiCardContent",slot:"Root",overridesResolver:(e,n)=>n.root})(()=>({padding:16,"&:last-child":{paddingBottom:24}})),mo=f.forwardRef(function(n,a){const o=yn({props:n,name:"MuiCardContent"}),{className:s,component:i="div"}=o,r=Sn(o,po),l=ht({},o,{component:i}),u=go(l);return t(ho,ht({as:i,className:bn(u.root,s),ownerState:l,ref:a},r))}),fo=mo,yo=zt(t("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z"}),"Assessment"),So=zt(t("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96z"}),"Cloud"),bo=d("div")(({theme:e})=>({borderRadius:e.spacing(1.5),backgroundColor:e.palette.background.paper,padding:e.spacing(4)})),Co=()=>{const e=F("projectId"),n=F("featureId"),{feature:a}=j(e,n);return a.name?t(bo,{children:t(vn,{title:"Event log",feature:n,displayInline:!0})}):null},vo=d("div")(({theme:e})=>({borderRadius:e.shape.borderRadiusLarge,color:e.palette.primary.contrastText,backgroundColor:e.palette.background.alternative,display:"flex",flexDirection:"column",maxWidth:"350px",minWidth:"350px",marginRight:e.spacing(2),[e.breakpoints.down(1e3)]:{width:"100%",maxWidth:"none",minWidth:"auto"}})),wo=d("div")({padding:"1.5rem 1.5rem 0 1.5rem"}),To=d("div")({display:"flex",alignItems:"center"}),xo=d("h2")(({theme:e})=>({fontSize:e.fontSizes.bodySize,fontWeight:"normal",margin:0})),Ao=d("div")(({theme:e})=>({margin:e.spacing(2,0),display:"flex",flexDirection:"column"})),vt=d("span")(({theme:e})=>({margin:e.spacing(1,0),fontSize:e.fontSizes.bodySize,wordBreak:"break-all"})),wt=d("div")(({theme:e})=>({display:"flex",alignItems:"center",color:e.palette.primary.contrastText})),Eo=()=>{const e=F("projectId"),n=F("featureId"),{feature:a}=j(e,n),{project:o,description:s,type:i}=a,r=Tn(i);return t(vo,{children:c(wo,{children:[c(To,{"data-loading":!0,children:[t(r,{sx:l=>({marginRight:l.spacing(2),height:"40px",width:"40px",fill:l.palette.primary.contrastText})})," ",c(xo,{children:[wn(i||"")," toggle"]})]}),c(Ao,{children:[c(vt,{"data-loading":!0,children:["Project: ",o]}),t(I,{condition:Boolean(s),show:c(vt,{"data-loading":!0,children:[t("div",{children:"Description:"}),c(wt,{children:[t("p",{children:s}),t(Q,{projectId:e,permission:le,component:J,to:`/projects/${e}/features/${n}/settings`,tooltipProps:{title:"Edit description"},children:t(me,{sx:l=>({color:l.palette.primary.contrastText})})})]})]}),elseShow:t("span",{"data-loading":!0,children:c(wt,{children:["No description."," ",t(Q,{projectId:e,permission:le,component:J,to:`/projects/${e}/features/${n}/settings`,tooltipProps:{title:"Edit description"},children:t(me,{sx:l=>({color:l.palette.primary.contrastText})})})]})})})]})]})})},Tt={lastHourUsage:[],seenApplications:[]},Io=(e,n,a={})=>{const o=async()=>{const h=be(`api/admin/client-metrics/features/${n}`),g=await fetch(h,{method:"GET"}).then(ke("feature metrics"));return g.ok?g.json():Tt},s=`${e}_${n}_metrics`,{data:i,error:r}=Qe(s,o,{...a}),[l,u]=f.useState(!r&&!i),p=()=>{Ze(s)};return f.useEffect(()=>{u(!r&&!i)},[i,r]),{metrics:i||Tt,error:r,loading:l,refetch:p,FEATURE_METRICS_CACHE_KEY:s}},Ro=e=>({yes:0,no:0,environment:e,timestamp:""}),Fo=(e,n)=>e.map(a=>n.lastHourUsage.find(s=>s.environment===a.name)||Ro(a.name)),ko=({enabled:e,className:n})=>{const a=et(),o=e?"Environment enabled":"Environment disabled",s={backgroundColor:e?a.palette.primary.light:a.palette.neutral.border,borderRadius:"50%",width:"28px",height:"28px",minWidth:"28px",display:"flex",alignItems:"center",justifyContent:"center",marginRight:a.spacing(1)},i={fill:a.palette.common.white,width:"16px",height:"16px"};return t("div",{style:s,className:n,children:t(So,{style:i,titleAccess:o})})},an=()=>t(he,{severity:"error",children:"Removing the strategy will change which users receive access to the feature."}),$o=({onRemove:e,onClose:n,isOpen:a})=>t(de,{title:"Are you sure you want to delete this strategy?",open:a,primaryButtonText:"Remove strategy",secondaryButtonText:"Cancel",onClick:e,onClose:n,children:t(an,{})}),Po=d("div")(({theme:e})=>({marginTop:e.spacing(3),marginBottom:e.spacing(1)})),Bo=({onRemove:e,onClose:n,isOpen:a})=>c(de,{title:"Suggest changes",open:a,primaryButtonText:"Add suggestion to draft",secondaryButtonText:"Cancel",onClick:e,onClose:n,children:[t(an,{}),t(Po,{children:t(N,{variant:"body2",color:"text.secondary",children:"Your suggestion:"})}),t(N,{fontWeight:"bold",children:"Remove strategy"})]}),Do=({projectId:e,featureId:n,environmentId:a,strategyId:o})=>{const{deleteStrategyFromFeature:s}=Ce(),{setToastData:i,setToastApiError:r}=G(),l=ge(),{refetchFeature:u}=j(e,n);return async h=>{try{h.preventDefault(),await s(e,n,a,o),i({title:"Strategy deleted",type:"success"}),u(),l(Wt(e,n))}catch(g){r(z(g))}}},Oo=({projectId:e,featureId:n,environmentId:a,strategyId:o})=>{const{addChange:s}=nt(),{refetch:i}=ve(e),{setToastData:r,setToastApiError:l}=G();return async p=>{try{p.preventDefault(),await s(e,a,{action:"deleteStrategy",feature:n,payload:{id:o}}),r({title:"Changes added to the draft!",type:"success"}),await i()}catch(h){l(z(h))}}},Vo=({projectId:e,featureId:n,environmentId:a,strategyId:o,disabled:s,icon:i})=>{const[r,l]=f.useState(!1),{isChangeRequestConfigured:u}=oe(e),p=Do({featureId:n,projectId:e,strategyId:o,environmentId:a}),h=Oo({featureId:n,projectId:e,strategyId:o,environmentId:a});return c(M,{children:[t(I,{condition:Boolean(i),show:t(Q,{onClick:()=>l(!0),projectId:e,environmentId:a,disabled:s,permission:mt,"data-testid":ft,tooltipProps:{title:"Remove strategy"},type:"button",children:t(tt,{})}),elseShow:t(ae,{onClick:()=>l(!0),projectId:e,environmentId:a,disabled:s,permission:mt,"data-testid":ft,color:"secondary",variant:"text",type:"button",children:"Remove strategy"})}),t(I,{condition:u(a),show:t(Bo,{isOpen:r,onClose:()=>l(!1),onRemove:async g=>{await h(g),l(!1)}}),elseShow:t($o,{isOpen:r,onClose:()=>l(!1),onRemove:p})})]})},Mo=e=>(n,a,o)=>(o.revalidateOnFocus=!1,o.revalidateIfStale=!1,o.revalidateOnReconnect=!1,e(n,a,o));var Lo=xn(Qe,Mo);const on=(e,n)=>{const{refetchFeature:a}=j(e,n),o=An(e,n),{data:s,error:i,mutate:r}=Lo(["useFeatureImmutable",o],()=>En(o)),l=f.useCallback(async()=>{await r(),await a()},[r,a]);return{feature:(s==null?void 0:s.body)||In,refetchFeature:l,loading:!i&&!s,status:s==null?void 0:s.status,error:i}},ut=(e,n,a)=>{const{setToastData:o,setToastApiError:s}=G(),{addChange:i}=nt(),{refetch:r}=ve(e),[l,u]=f.useState({isOpen:!1}),p=f.useCallback((T,R,y)=>{u({featureName:n,environment:T,fromEnvironment:y,strategy:R,isOpen:!0})},[]),h=f.useCallback((T,R,y)=>{u({featureName:n,environment:T,fromEnvironment:y,strategies:R,isOpen:!0})},[]),g=f.useCallback(()=>{u({isOpen:!1})},[]),b=f.useCallback(async()=>{try{await i(e,l.environment,{feature:l.featureName,action:a,payload:l.strategy}),r(),u({isOpen:!1}),o({type:"success",title:"Changes added to the draft!"})}catch(T){s(z(T)),u({isOpen:!1})}},[i]),v=f.useCallback(async()=>{try{await Promise.all(l.strategies.map(T=>i(e,l.environment,{feature:l.featureName,action:a,payload:T}))),r(),u({isOpen:!1}),o({type:"success",title:"Changes added to the draft!"})}catch(T){s(z(T)),u({isOpen:!1})}},[i]);return{onChangeRequestAddStrategy:p,onChangeRequestAddStrategies:h,onChangeRequestAddStrategyClose:g,onChangeRequestAddStrategyConfirm:b,onChangeRequestAddStrategiesConfirm:v,changeRequestDialogDetails:l}},_o=({payload:e,fromEnvironment:n,environment:a})=>c(N,{children:[c("strong",{children:["Copy ",we((e==null?void 0:e.name)||"")," strategy"," "]})," ","from ",n," to ",a]}),jo=({environmentId:e,environments:n,strategy:a})=>{const o=F("projectId"),s=F("featureId"),[i,r]=f.useState(null),l=Boolean(i),{addStrategyToFeature:u}=Ce(),{setToastData:p,setToastApiError:h}=G(),{refetchFeature:g}=j(o,s),{refetchFeature:b}=on(o,s),v=()=>{r(null)},T=Rn(o),{isChangeRequestConfigured:R}=oe(o),{changeRequestDialogDetails:y,onChangeRequestAddStrategyClose:C,onChangeRequestAddStrategy:w,onChangeRequestAddStrategyConfirm:E}=ut(o,s,"addStrategy"),B=async P=>{const{id:O,...$}={...a,targetEnvironment:P};if(R(P)){await w(P,{id:O,...$},e);return}try{await u(o,s,P,a),g(),b(),p({title:"Strategy created",text:`Successfully copied a strategy to ${P}`,type:"success"})}catch(U){h(z(U))}v()},D=n.some(P=>T(ue,P));return c("div",{children:[t(Oe,{isOpen:y.isOpen,onClose:C,environment:y==null?void 0:y.environment,onConfirm:E,messageComponent:t(_o,{fromEnvironment:y.fromEnvironment,payload:y.strategy})}),t(ee,{title:`Copy to another environment${D?"":" (Access denied)"}`,children:t("div",{children:t($e,{size:"large",id:`copy-strategy-icon-menu-${a.id}`,"aria-controls":l?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":l?"true":void 0,onClick:P=>{r(P.currentTarget)},"data-testid":Fn,disabled:!D,children:t(kn,{})})})}),t(Pe,{id:"basic-menu",anchorEl:i,open:l,onClose:v,MenuListProps:{"aria-labelledby":`copy-strategy-icon-menu-${a.id}`},children:n.map(P=>{const O=T(ue,P);return t(ee,{title:O?"":"You don't have access to add a strategy to this environment",children:t("div",{children:c(Be,{onClick:()=>B(P),disabled:!O,children:[t(I,{condition:!O,show:t(Ut,{children:t(qt,{fontSize:"small"})})}),c(at,{children:["Copy to ",P]})]})})},P)})})]})},No=({environmentId:e,strategy:n,onDragStart:a,onDragEnd:o,otherEnvironments:s,orderNumber:i,headerChildren:r})=>{const l=F("projectId"),u=F("featureId"),p=$n(l,u,e,n.id);return t(co,{strategy:n,onDragStart:a,onDragEnd:o,orderNumber:i,actions:c(M,{children:[r,t(I,{condition:Boolean(s&&(s==null?void 0:s.length)>0),show:()=>t(jo,{environmentId:e,environments:s,strategy:n})}),t(Q,{permission:Pn,environmentId:e,projectId:l,component:J,to:p,tooltipProps:{title:"Edit strategy"},children:t(me,{})}),t(Vo,{projectId:l,featureId:u,environmentId:e,strategyId:n.id,icon:!0})]}),children:t(Bn,{strategy:n})})},zo=(e,n,a,o)=>{const{data:s}=ve(e),i=s==null?void 0:s.find(u=>u.environment===a),r=i==null?void 0:i.features.find(u=>u.name===n);return r==null?void 0:r.changes.find(u=>u.action==="updateStrategy"||u.action==="deleteStrategy"?u.payload.id===o:!1)},Wo=({strategy:e,index:n,environmentName:a,otherEnvironments:o,isDragging:s,onDragStartRef:i,onDragOver:r,onDragEnd:l})=>{const u=F("projectId"),p=F("featureId"),h=f.useRef(null),g=zo(u,p,a,e.id);return c(H,{ref:h,onDragOver:r(h,n),sx:{opacity:s?"0.5":"1"},children:[t(I,{condition:n>0,show:t(Dn,{text:"OR"})}),t(No,{strategy:e,environmentId:a,otherEnvironments:o,onDragStart:i(h,n),onDragEnd:l,orderNumber:n+1,headerChildren:t(Uo,{change:g})})]},e.id)},Uo=({change:e})=>{const n=et();return De(n.breakpoints.down("sm"))?null:c(H,{sx:{mr:1.5},children:[t(I,{condition:(e==null?void 0:e.action)==="updateStrategy",show:t(fe,{color:"warning",children:"Modified in draft"})}),t(I,{condition:(e==null?void 0:e.action)==="deleteStrategy",show:t(fe,{color:"error",children:"Deleted in draft"})})]})},qo=d("div")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",margin:"1rem 0",position:"relative","&:before":{content:'""',position:"absolute",top:"50%",transform:"translateY(-50%)",height:2,width:"100%",backgroundColor:e.palette.divider}})),Ho=d("span")(({theme:e})=>({fontSize:e.fontSizes.bodySize,textAlign:"center",padding:"0 1rem",background:e.palette.envAccordion.expanded,position:"relative",maxWidth:"80%",color:e.palette.text.primary})),sn=({children:e})=>t(qo,{children:t(Ho,{children:e})}),Go=({environmentId:e,environments:n,onClick:a})=>{const o=F("projectId"),[s,i]=f.useState(null),r=Boolean(s),{hasAccess:l}=f.useContext(ot),u=n.some(p=>l(ue,o,p));return c("div",{children:[t(ee,{title:u?"":"(Access denied)",children:t("div",{children:t(re,{id:`copy-all-strategies-${e}`,"aria-controls":r?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":r?"true":void 0,onClick:p=>{i(p.currentTarget)},disabled:!u,variant:"outlined",children:"Copy from another environment"})})}),t(Pe,{id:"basic-menu",anchorEl:s,open:r,onClose:()=>{i(null)},MenuListProps:{"aria-labelledby":`copy-all-strategies-${e}`},children:n.map(p=>{const h=l(ue,o,p);return t(ee,{title:h?"":"You don't have access to add a strategy to this environment",children:t("div",{children:c(Be,{onClick:()=>a(p),disabled:!h,children:[t(I,{condition:!h,show:t(Ut,{children:t(qt,{fontSize:"small"})})}),c(at,{children:["Copy from ",p]})]})})},p)})})]})},Yo=d("div")(({theme:e})=>({"&>*:nth-child(n)":{margin:e.spacing(1,0)}})),Ko=({payload:e,fromEnvironment:n,environment:a})=>c(Yo,{children:[t(N,{children:t("strong",{children:"Copy: "})}),e==null?void 0:e.map(o=>c(N,{children:[c("strong",{children:[we((o==null?void 0:o.name)||"")," strategy"," "]})," "]})),c(N,{children:["from ",n," to ",a]})]}),Jo=({payload:e,environment:n})=>c(M,{children:[t(N,{component:"span",children:"Add "}),c("strong",{children:[we((e==null?void 0:e.name)||"")," strategy"]})," to ",t("strong",{children:n})]}),Xo=d(On)(({theme:e})=>({display:"flex",flexDirection:"column",borderRadius:e.shape.borderRadiusMedium})),xt=({title:e,children:n,featureId:a,projectId:o,environmentId:s,strategy:i,Icon:r,onAfterAddStrategy:l})=>{const{addStrategyToFeature:u}=Ce(),{setToastApiError:p}=G(),{isChangeRequestConfigured:h}=oe(o),{changeRequestDialogDetails:g,onChangeRequestAddStrategy:b,onChangeRequestAddStrategyConfirm:v,onChangeRequestAddStrategyClose:T}=ut(o,a,"addStrategy");return c(M,{children:[t(Xo,{variant:"outlined",children:c(fo,{sx:{display:"flex",flexDirection:"column",flexGrow:1},children:[c(N,{variant:"body1",fontWeight:"medium",sx:{mb:.5,display:"flex",alignItems:"center"},children:[t(r,{color:"disabled",sx:{mr:1}})," ",e]}),t(N,{variant:"body2",color:"text.secondary",component:"p",children:n}),t(H,{sx:{ml:"auto",mt:"auto",pt:1,mr:{xs:"auto",sm:0}},children:t(ae,{permission:ue,projectId:o,environmentId:s,variant:"outlined",size:"small",onClick:async()=>{try{h(s)?b(s,i):(await u(o,a,s,i),l())}catch(y){p(z(y))}},children:"Use template"})})]})}),t(Oe,{isOpen:g.isOpen,onClose:T,environment:g==null?void 0:g.environment,onConfirm:v,messageComponent:t(Jo,{environment:s,payload:g.strategy})})]})},Qo=d("div")(({theme:e})=>({width:e.spacing(4),height:"auto","& > svg":{fill:e.palette.primary.main},"& > div":{height:e.spacing(2),marginLeft:"-.75rem",color:e.palette.primary.main}})),Zo=d("div")(({theme:e})=>({fontSize:e.fontSizes.smallBody})),es=d(st)(({theme:e})=>({fontWeight:e.fontWeight.bold})),ts=d(J)(({theme:e})=>({display:"grid",gridTemplateColumns:"3rem 1fr",width:"20rem",padding:e.spacing(2),color:"inherit",textDecoration:"inherit",lineHeight:1.25,borderWidth:"1px",borderStyle:"solid",borderColor:e.palette.divider,borderRadius:e.spacing(1),"&:hover, &:focus":{borderColor:e.palette.primary.main}})),ns=({projectId:e,featureId:n,environmentId:a,strategy:o})=>{const s=Ie(o.name),i=we(o.name),r=Ga(e,n,a,o.name);return c(ts,{to:r,children:[t(Qo,{children:t(s,{})}),c("div",{children:[t(es,{text:o.displayName||i,maxWidth:"200",maxLength:25}),t(Zo,{children:o.description})]})]})},as=({projectId:e,featureId:n,environmentId:a})=>{const{strategies:o}=Vn(),s=f.useMemo(()=>o.filter(i=>!i.deprecated),[o]);return t(rt,{dense:!0,children:s.map(i=>t(Re,{children:t(ns,{projectId:e,featureId:n,environmentId:a,strategy:i})},i.name))})},Je=({label:e,projectId:n,featureId:a,environmentId:o,variant:s,matchWidth:i})=>{const[r,l]=f.useState(),u=Boolean(r),p=u?"FeatureStrategyMenuPopover":void 0,h=()=>{l(void 0)};return c("div",{onClick:b=>b.stopPropagation(),children:[t(ae,{permission:ue,projectId:n,environmentId:o,onClick:b=>{l(b.currentTarget)},"aria-labelledby":p,variant:s,sx:{minWidth:i?"282px":"auto"},children:e}),t(Mn,{id:p,open:u,anchorEl:r,onClose:h,onClick:h,children:t(as,{projectId:n,featureId:a,environmentId:o})})]})},os=d("div")(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",paddingTop:e.spacing(2)})),ss=d("div")(({theme:e})=>({fontSize:e.fontSizes.bodySize,textAlign:"center",color:e.palette.text.primary,marginBottom:e.spacing(1)})),rs=d("p")(({theme:e})=>({color:e.palette.text.secondary,fontSize:e.fontSizes.smallBody,textAlign:"center",marginBottom:e.spacing(3),a:{color:e.palette.links}})),is=({projectId:e,featureId:n,environmentId:a})=>{const{addStrategyToFeature:o}=Ce(),{setToastData:s,setToastApiError:i}=G(),{refetchFeature:r}=j(e,n),{refetchFeature:l}=on(e,n),{feature:u}=j(e,n),p=u==null?void 0:u.environments.filter(w=>w.name!==a&&w.strategies&&w.strategies.length>0),{isChangeRequestConfigured:h}=oe(e),{changeRequestDialogDetails:g,onChangeRequestAddStrategies:b,onChangeRequestAddStrategiesConfirm:v,onChangeRequestAddStrategyClose:T}=ut(e,n,"addStrategy"),R=(w=!1)=>{r(),l(),s({title:w?"Strategies created":"Strategy created",text:w?"Successfully copied from another environment":"Successfully created strategy",type:"success"})},y=async w=>{var B;const E=((B=p==null?void 0:p.find(D=>D.name===w))==null?void 0:B.strategies)||[];if(h(a)){await b(a,E,w);return}try{await Promise.all(E.map(D=>{const{id:P,...O}={...D,environment:a};return o(e,n,a,O)})),R(!0)}catch(D){i(z(D))}},C=p&&p.length>0;return c(M,{children:[t(Oe,{isOpen:g.isOpen,onClose:T,environment:g==null?void 0:g.environment,onConfirm:v,messageComponent:t(Ko,{fromEnvironment:g.fromEnvironment,payload:g.strategies})}),c(os,{children:[t(ss,{children:"You have not defined any strategies yet."}),c(rs,{children:["Strategies added in this environment will only be executed if the SDK is using an"," ",t(J,{to:"/admin/api",children:"API key configured"})," for this environment."]}),c(H,{sx:{w:"100%",display:"flex",flexWrap:"wrap",gap:2,alignItems:"center",justifyContent:"center"},children:[t(Je,{label:"Add your first strategy",projectId:e,featureId:n,environmentId:a,matchWidth:C}),t(I,{condition:C,show:t(Go,{environmentId:a,environments:p.map(w=>w.name),onClick:y})})]}),t(H,{sx:{width:"100%",mt:3},children:t(sn,{children:"Or use a strategy template"})}),c(H,{sx:{display:"grid",width:"100%",gap:2,gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"}},children:[t(xt,{title:"Standard strategy",projectId:e,featureId:n,environmentId:a,onAfterAddStrategy:R,Icon:Ie("default"),strategy:{name:"default",parameters:{},constraints:[]},children:"The standard strategy is strictly on/off for your entire userbase."}),t(xt,{title:"Gradual rollout",projectId:e,featureId:n,environmentId:a,onAfterAddStrategy:R,Icon:Ie("flexibleRollout"),strategy:{name:"flexibleRollout",parameters:{rollout:"50",stickiness:"default",groupId:u.name},constraints:[]},children:"Roll out to a percentage of your userbase."})]})]})]})},cs=d("div")(({theme:e})=>({width:"100%",position:"relative",paddingBottom:e.spacing(2)})),ls=d("div")(({theme:e})=>({[e.breakpoints.down(400)]:{padding:e.spacing(1)}})),ds=({featureEnvironment:e,isDisabled:n,otherEnvironments:a})=>{const o=F("projectId"),s=F("featureId"),{setStrategiesSortOrder:i}=Ce(),{setToastData:r,setToastApiError:l}=G(),{refetchFeature:u}=j(o,s),[p,h]=f.useState((e==null?void 0:e.strategies)||[]),[g,b]=f.useState(null);if(f.useEffect(()=>{h((e==null?void 0:e.strategies)||[])},[e==null?void 0:e.strategies]),!e)return null;const v=async C=>{try{await i(o,s,e.name,C),u(),r({title:"Order of strategies updated",type:"success"})}catch(w){l(z(w))}},T=(C,w)=>E=>{var B;b({id:p[w].id,index:w,height:((B=C.current)==null?void 0:B.offsetHeight)||0}),C!=null&&C.current&&(E.dataTransfer.effectAllowed="move",E.dataTransfer.setData("text/html",C.current.outerHTML),E.dataTransfer.setDragImage(C.current,20,20))},R=C=>(w,E)=>B=>{if(g===null||w.current===null||g.index===E||C===g.id)return;const{top:D,bottom:P}=w.current.getBoundingClientRect(),O=B.clientY-D<g.height,$=P-B.clientY<g.height,U=g.index>E;if(O&&U||$&&!U){const Y=[...p],K=Y.splice(g.index,1)[0];Y.splice(E,0,K),h(Y),b({...g,index:E})}},y=()=>{b(null),v(p.map((C,w)=>({id:C.id,sortOrder:w})))};return t(cs,{children:c(ls,{children:[t(I,{condition:p.length>0&&n,show:()=>t(he,{severity:"warning",sx:{mb:2},children:"This environment is disabled, which means that none of your strategies are executing."})}),t(I,{condition:p.length>0,show:t(M,{children:p.map((C,w)=>t(Wo,{strategy:C,index:w,environmentName:e.name,otherEnvironments:a,isDragging:(g==null?void 0:g.id)===C.id,onDragStartRef:T,onDragOver:R(C.id),onDragEnd:y},C.id))}),elseShow:t(is,{projectId:o,featureId:s,environmentId:e.name})})]})})},rn=(e,n)=>e===0?0:Math.round(n/e*100);var Ve={},Me={};Object.defineProperty(Me,"__esModule",{value:!0});Me.defaultOptions=void 0;Me.defaultOptions={decimalSeparator:".",lowercase:!1,precision:1,space:!1,units:["","K","M","B","T","P","E"]};var pe={};Object.defineProperty(pe,"__esModule",{value:!0});pe.roundTo=pe.parseValue=void 0;function us(e){const n=parseFloat(e==null?void 0:e.toString());if(isNaN(n))throw new Error("Input value is not a number");if(n>Number.MAX_SAFE_INTEGER||n<Number.MIN_SAFE_INTEGER)throw new RangeError("Input value is outside of safe integer range");return n}pe.parseValue=us;function ps(e,n){if(!Number.isFinite(e))throw new Error("Input value is not a finite number");if(!Number.isInteger(n)||n<0)throw new Error("Precision is not a positive integer");return Number.isInteger(e)?e:parseFloat(e.toFixed(n))}pe.roundTo=ps;Object.defineProperty(Ve,"__esModule",{value:!0});Ve.millify=void 0;const je=Me,At=pe,Et=1e3;function*It(e){let n=Et;for(;;){const a=e/n;if(a<1)return;yield a,n*=Et}}function cn(e,n){var a;const o=n?Object.assign(Object.assign({},je.defaultOptions),n):je.defaultOptions;if(!Array.isArray(o.units)||!o.units.length)throw new Error("Option `units` must be a non-empty array");let s;try{s=At.parseValue(e)}catch(v){return v instanceof Error&&console.warn(`WARN: ${v.message} (millify)`),String(e)}const i=s<0?"-":"";s=Math.abs(s);let r=0;for(const v of It(s))s=v,r+=1;if(r>=o.units.length)return e.toString();let u=At.roundTo(s,o.precision);for(const v of It(u))u=v,r+=1;const p=(a=o.units[r])!==null&&a!==void 0?a:"",h=o.lowercase?p.toLowerCase():p,g=o.space?" ":"",b=u.toString().replace(je.defaultOptions.decimalSeparator,o.decimalSeparator);return`${i}${b}${g}${h}`}Ve.millify=cn;var gs=Ve.default=cn;const Fe=({value:e,threshold:n=1e6,precision:a=2})=>{let o,s=!1;e<n?o=e.toLocaleString():(o=gs(e,{precision:a}),s=!0);const i=t("span",{"data-testid":Ln,children:o});return t(I,{condition:s,show:t(ee,{title:e.toLocaleString(),arrow:!0,children:i}),elseShow:i})},Ne=d("article")(({theme:e})=>({padding:e.spacing(2),background:"transparent",borderRadius:e.spacing(2),textAlign:"center",[e.breakpoints.up("md")]:{padding:e.spacing(4)}})),ze=d("h3")(({theme:e})=>({margin:0,fontSize:e.fontSizes.bodySize,fontWeight:e.fontWeight.thin})),We=d("p")(({theme:e})=>({fontSize:"2.25rem",fontWeight:e.fontWeight.bold,color:e.palette.primary.main})),Ue=d("p")(({theme:e})=>({margin:e.spacing(1,0,0,0),padding:e.spacing(2,0,0,0),borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:e.palette.divider,fontSize:e.fontSizes.smallerBody,color:e.palette.text.secondary})),ln=({totalYes:e,totalNo:n,hoursBack:a,statsSectionId:o,tableSectionId:s})=>{const i=a===1?"in the last hour":`in the last ${a} hours`;return c(ne,{container:!0,spacing:2,id:o,"aria-describedby":s,"aria-label":"Feature metrics summary",component:"section",children:[t(ne,{item:!0,xs:12,sm:4,children:c(Ne,{children:[t(ze,{children:"Exposure"}),t(We,{children:t(Fe,{value:e})}),c(Ue,{children:["Total exposure of the feature in the environment"," ",i,"."]})]})}),t(ne,{item:!0,xs:12,sm:4,children:c(Ne,{children:[t(ze,{children:"Exposure %"}),c(We,{children:[rn(e+n,e),"%"]}),c(Ue,{children:["% total exposure of the feature in the environment"," ",i,"."]})]})}),t(ne,{item:!0,xs:12,sm:4,children:c(Ne,{children:[t(ze,{children:"Requests"}),t(We,{children:t(Fe,{value:e+n})}),c(Ue,{children:["Total requests for the feature in the environment"," ",i,"."]})]})})]})},hs=({environmentMetric:e})=>e?c(M,{children:[t(sn,{children:"Feature toggle exposure"}),t("div",{children:t(ln,{totalYes:e.yes,totalNo:e.no,hoursBack:1})})]}):null,Rt=d("div")({marginLeft:"auto",display:"flex",alignItems:"center"}),Ft=d("div")(({theme:e})=>({marginRight:e.spacing(1),display:"flex",flexDirection:"column"})),kt=d("p")(({theme:e})=>({color:e.palette.primary.main,textAlign:"right",fontSize:e.fontSizes.bodySize})),$t=d("p")(({theme:e})=>({maxWidth:"270px",marginTop:e.spacing(.5),fontSize:e.fontSizes.smallBody,textAlign:"right",[e.breakpoints.down(700)]:{display:"none"}})),ms=d(_n)(({theme:e})=>({fill:e.palette.background.elevation2,height:"75px",width:"75px",[e.breakpoints.down(500)]:{display:"none"}})),fs=d("div")(({theme:e})=>({margin:e.spacing(0,2),[e.breakpoints.down(500)]:{display:"none"}})),ys=({environmentMetric:e,disabled:n=!1})=>{const a=jn();if(!e)return null;const o=e.yes+e.no,s=rn(o,e==null?void 0:e.yes);return!e||e.yes===0&&e.no===0?c(Rt,{children:[c(Ft,{children:[c(kt,{style:{color:n?a.palette.text.secondary:void 0},"data-loading":!0,children:[s,"%"]}),c($t,{style:{color:n?a.palette.text.secondary:a.palette.text.primary},"data-loading":!0,children:["The feature has been requested ",t("b",{children:"0 times"})," and exposed",t("b",{children:" 0 times"})," in the last hour"]})]}),t(ms,{style:{transform:"scale(1.1)"},"data-loading":!0})]}):c(Rt,{children:[c(Ft,{children:[c(kt,{children:[s,"%"]}),c($t,{children:["The feature has been requested"," ",c("b",{children:[t(Fe,{value:o})," times"]})," ","and exposed"," ",c("b",{children:[t(Fe,{value:e.yes})," ","times"]})," ","in the last hour"]})]}),t(fs,{"data-loading":!0,children:t(Nn,{percentage:s,size:"3rem"})})]})},Ss=({strategyName:e})=>{const n=Ie(e);return t(ee,{title:we(e),arrow:!0,children:t(bs,{children:t(n,{})})})},bs=d("div")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",color:e.palette.action.disabled,"& svg":{width:e.spacing(2.5),height:e.spacing(2.5)}})),Cs=({strategies:e})=>e!=null&&e.length?t(vs,{"aria-label":"Feature strategies",children:e.map(n=>t(ws,{children:t(Ss,{strategyName:n.name})},n.id))}):null,vs=d("ul")(()=>({all:"unset",display:"flex",alignItems:"center",alignContent:"center"})),ws=d("li")(()=>({all:"unset",minWidth:30,textAlign:"center"})),Ts=d("div",{shouldForwardProp:e=>e!=="enabled"})(({theme:e,enabled:n})=>({borderRadius:e.shape.borderRadiusLarge,marginBottom:e.spacing(2),backgroundColor:n?e.palette.background.paper:e.palette.envAccordion.disabled})),xs=d(zn)({boxShadow:"none",background:"none"}),As=d(Wn)(({theme:e})=>({boxShadow:"none",padding:e.spacing(2,4),[e.breakpoints.down(400)]:{padding:e.spacing(1,2)}})),Es=d(Un,{shouldForwardProp:e=>e!=="enabled"})(({theme:e})=>({padding:e.spacing(3),background:e.palette.envAccordion.expanded,borderBottomLeftRadius:e.shape.borderRadiusLarge,borderBottomRightRadius:e.shape.borderRadiusLarge,boxShadow:"inset 0px 2px 4px rgba(32, 32, 33, 0.05)",[e.breakpoints.down("md")]:{padding:e.spacing(2,1)}})),Is=d(ds)(({theme:e})=>({width:"100%",position:"relative",paddingBottom:e.spacing(2)})),Rs=d("div",{shouldForwardProp:e=>e!=="enabled"})(({theme:e,enabled:n})=>({display:"flex",justifyContent:"center",flexDirection:"column",color:n?e.palette.text.primary:e.palette.text.secondary})),Fs=d("div")(({theme:e})=>({display:"flex",alignItems:"center",[e.breakpoints.down(560)]:{flexDirection:"column",textAlign:"center"}})),ks=d(ko)(({theme:e})=>({[e.breakpoints.down(560)]:{marginBottom:"0.5rem"}})),$s=d(st)(({theme:e})=>({fontSize:e.fontSizes.bodySize,fontWeight:e.typography.fontWeightMedium,[e.breakpoints.down(560)]:{textAlign:"center"}})),Ps=d("div")(({theme:e})=>({display:"flex",alignItems:"center",marginLeft:"1.8rem",[e.breakpoints.down(560)]:{flexDirection:"column",marginLeft:"0"}})),Bs=({env:e})=>{var p;const n=F("projectId"),a=F("featureId"),{metrics:o}=Io(n,a),{feature:s}=j(n,a),{value:i}=Ht(),l=Fo(s==null?void 0:s.environments,o).find(h=>h.environment===e.name),u=s==null?void 0:s.environments.find(h=>h.name===e.name);return t(I,{condition:!Boolean(new Set(i.hiddenEnvironments).has(e.name)),show:t(Ts,{enabled:e.enabled,children:c(xs,{"data-testid":`${qn}_${e.name}`,className:`environment-accordion ${e.enabled?"":"accordion-disabled"}`,children:[c(As,{expandIcon:t(lo,{titleAccess:"Toggle"}),children:[c(Rs,{"data-loading":!0,enabled:e.enabled,children:[c(Fs,{children:[t(ks,{enabled:e.enabled}),t("div",{children:t($s,{text:e.name,maxWidth:"100",maxLength:15})}),t(I,{condition:!e.enabled,show:t(fe,{color:"neutral",sx:{ml:1},children:"Disabled"})})]}),c(Ps,{children:[t(Je,{label:"Add strategy",projectId:n,featureId:a,environmentId:e.name,variant:"text"}),t(Cs,{strategies:u==null?void 0:u.strategies})]})]}),t(ys,{environmentMetric:l,disabled:!e.enabled})]}),c(Es,{enabled:e.enabled,children:[t(Is,{featureEnvironment:u,isDisabled:!e.enabled,otherEnvironments:s==null?void 0:s.environments.map(({name:h})=>h).filter(h=>h!==e.name)}),t(I,{condition:(((p=u==null?void 0:u.strategies)==null?void 0:p.length)||0)>0,show:c(M,{children:[t(H,{sx:{display:"flex",justifyContent:"center",py:1},children:t(Je,{label:"Add strategy",projectId:n,featureId:a,environmentId:e.name})}),t(hs,{environmentMetric:l})]})})]})]})})})},Ds=()=>{const e=F("projectId"),n=F("featureId"),{feature:a}=j(e,n);if(!a)return null;const{environments:o}=a;return t(M,{children:o==null?void 0:o.map(s=>t(Bs,{env:s},s.name))})},Os=d("div")(({theme:e})=>({display:"flex",flexDirection:"column",padding:e.spacing(3),fontSize:e.fontSizes.smallBody})),Vs=d("span")(({theme:e})=>({color:e.palette.text.secondary,marginRight:e.spacing(1)})),Ms=({feature:e,header:n})=>{const{locationSettings:a}=Hn();return c(Os,{children:[n,c("div",{"data-loading":!0,children:[t(Vs,{children:"Created at:"}),t("span",{children:Gn(Yn(e.createdAt),a.locale)})]})]})},Ls=d($e,{shouldForwardProp:e=>e!=="visibilityOff"})(({theme:e,visibilityOff:n})=>({marginLeft:"auto",marginRight:e.spacing(-1),color:n?e.palette.action.active:e.palette.action.focus,"&:hover":{color:e.palette.action.active}})),_s=({environment:e,hiddenEnvironments:n,setHiddenEnvironments:a})=>t(Ls,{onClick:()=>{a(e.name)},visibilityOff:n.has(e.name),children:t(I,{condition:n.has(e.name),show:t(Kn,{}),elseShow:t(Jn,{})})}),js=d("div")(({theme:e})=>({marginLeft:e.spacing(-1.5),"&:not(:last-of-type)":{marginBottom:e.spacing(2)},display:"flex",alignItems:"center"})),Ns=d("label")(()=>({display:"inline-flex",alignItems:"center",cursor:"pointer"})),zs=({environment:e,callback:n,showInfoBox:a,children:o,hiddenEnvironments:s,setHiddenEnvironments:i})=>{const{name:r,enabled:l}=e,u=F("projectId"),p=F("featureId"),{toggleFeatureEnvironmentOn:h,toggleFeatureEnvironmentOff:g}=Te(),{refetchFeature:b}=j(u,p),{setToastData:v,setToastApiError:T}=G(),{isChangeRequestConfigured:R}=oe(u),{onChangeRequestToggle:y,onChangeRequestToggleClose:C,onChangeRequestToggleConfirm:w,changeRequestDialogDetails:E}=Ya(u),B=async()=>{try{await h(u,p,r),v({type:"success",title:`Available in ${r}`,text:`${p} is now available in ${r} based on its defined strategies.`}),b(),n&&n()}catch($){$ instanceof Error&&$.message===Ja?a():T(z($))}},D=async()=>{try{await g(u,p,r),v({type:"success",title:`Unavailable in ${r}`,text:`${p} is unavailable in ${r} and its strategies will no longer have any effect.`}),b(),n&&n()}catch($){T(z($))}},P=async $=>{if(R(r)){$.preventDefault(),y(p,r,!l);return}if(l){await D();return}await B()},O=c(M,{children:[" ",c("span",{"data-loading":!0,children:[l?"enabled":"disabled"," in"]})," ",t(st,{text:r,maxWidth:"120",maxLength:15})]});return c(js,{children:[c(Ns,{children:[t(Xn,{tooltip:l?`Disable feature in ${r}`:`Enable feature in ${r}`,permission:Qn,projectId:u,checked:l,onChange:P,environmentId:r}),o??O]}),t(_s,{environment:e,hiddenEnvironments:s,setHiddenEnvironments:i}),t(Oe,{isOpen:E.isOpen,onClose:C,environment:E==null?void 0:E.environment,onConfirm:w,messageComponent:t(Ka,{enabled:E==null?void 0:E.enabled,featureName:E==null?void 0:E.featureName,environment:E.environment})})]})},Ws=d("div")(({theme:e})=>({padding:e.spacing(3)})),Us=d("div")(()=>({display:"flex",flexDirection:"column"})),qs=d("p")(({theme:e})=>({fontSize:e.fontSizes.bodySize})),Hs=d("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,display:"flex",alignItems:"center"})),Pt=d("span")(({theme:e})=>({padding:e.spacing(0,.5),"::after":{content:'"-"'}})),Gs=d(it)(()=>({"&:hover, &:focus":{textDecoration:"underline"}})),Ys=({feature:e,header:n,hiddenEnvironments:a,setHiddenEnvironments:o})=>{const[s,i]=f.useState(!1),[r,l]=f.useState(""),u=e.environments.some(p=>{var h;return p.enabled&&((h=p.variants)==null?void 0:h.length)});return c(Ws,{"data-testid":"feature-toggle-status",children:[n,e.environments.map(p=>{const h=p.strategies.length===1?"1 strategy":`${p.strategies.length} strategies`,g=p.variants??[],b=g.length>0&&c(M,{children:[t(Pt,{}),t(ee,{title:"View variants",arrow:!0,describeChild:!0,children:t(Gs,{component:J,to:`/projects/${e.project}/features/${e.name}/variants`,underline:"hover",children:g.length===1?"1 variant":`${g.length} variants`})})]}),v=p.enabled&&g.length===0&&u;return t(zs,{environment:p,hiddenEnvironments:a,setHiddenEnvironments:o,showInfoBox:()=>{l(p.name),i(!0)},children:c(Us,{children:[t(qs,{children:p.name}),c(Hs,{children:[h,b,t(I,{condition:v,show:c(M,{children:[t(Pt,{}),t(Xa,{})]})})]})]})},p.name)}),t(Qa,{open:s,onClose:()=>i(!1),projectId:e.project,featureId:e.name,environmentName:r})]})},dn=(e,n={})=>{const a=async()=>{const p=be(`api/admin/features/${e}/tags`);return(await fetch(p,{method:"GET"}).then(ke("Tags"))).json()},o=`api/admin/features/${e}/tags`,{data:s,error:i}=Zn(Boolean(e),{tags:[]},o,a,n),[r,l]=f.useState(!i&&!s),u=()=>{Ze(o)};return f.useEffect(()=>{l(!i&&!s)},[s,i]),{tags:(s==null?void 0:s.tags)||[],error:i,loading:r,refetch:u}},Ks=d("section")(({theme:e})=>({["& > *"]:{margin:e.spacing(1,0)}})),qe=e=>e.map(n=>({title:n.value})),Bt=(e,n)=>e.map(a=>({value:a.title,type:n})),un=({open:e,setOpen:n})=>{const{tagTypes:a}=ea(),o=F("featureId"),{createTag:s}=Za(),{updateFeatureTags:i,loading:r}=Te(),{tags:l,refetch:u,loading:p}=dn(o),{setToastData:h}=G(),[g,b]=f.useState({name:"simple",description:"Simple tag to get you started",icon:""}),v=r||p,[T,R]=f.useState(0),{trackEvent:y}=Gt(),[C,w]=f.useState(qe(l.filter(m=>m.type===g.name))),{tags:E,refetch:B}=eo(g.name),D=f.useMemo(()=>qe(E),[E]);f.useEffect(()=>{l&&g&&w(qe(l.filter(m=>m.type===g.name)))},[JSON.stringify(l),g]);const P=()=>{n(!1),w([])};function O(m,S){const A=m.filter(L=>L.type===g.name).filter(L=>!S.find(_=>L.value===_.value&&L.type===_.type)),V=S.filter(L=>L.type===g.name).filter(L=>!m.find(_=>L.value===_.value&&L.type===_.type));return R(A.length+V.length),{added:A,removed:V}}const $=m=>m.filter(S=>!S.title.startsWith("Create")),U=async(m,S)=>{try{await i(o,{addedTags:m,removedTags:S}),await u()}catch(A){const V=z(A);h({type:"error",title:"Failed to add tag",text:V,confetti:!1})}},Y=(m,S)=>{let A="We successfully";return m>0&&(A=A.concat(` added ${m} new tag${m>1?"s":""}`)),m>0&&S>0&&(A=A.concat(" and ")),S>0&&(A=A.concat(` removed ${S} tag${S>1?"s":""}`)),A},K=async m=>{m.preventDefault();const S=Bt($(C),g.name),{added:A,removed:V}=O(S,l);T>0&&(await U(A,V),T>1&&y("suggest_tags",{props:{eventType:"multiple_tags_added"}}),T>0&&h({type:"success",title:`Updated tag${A.length>1?"s":""} to toggle`,text:Y(A.length,V.length),confetti:!0})),R(0),w([]),n(!1)},te=(m,S)=>{S!=null&&typeof S!="string"&&(m.preventDefault(),b(S),w([]),R(0))},Z=(m,S,A)=>{const V=ta(S);A==="selectOption"&&S.forEach((_,q)=>{if(typeof _!="string"&&_.inputValue&&_.inputValue!==""){const xe={value:_.inputValue,type:g.name};s(xe).then(()=>{y("suggest_tags",{props:{eventType:"tag_created"}}),B()}),_.title=_.inputValue,_.inputValue="",V[q]=_}});const L=Bt($(V),g.name);O(L,l),w(V)},x="add-tag-form";return t(de,{open:e,secondaryButtonText:"Cancel",primaryButtonText:"Save tags",title:"Update tags to feature toggle",onClick:K,disabledPrimaryButton:v||T===0,onClose:P,formId:x,children:c(M,{children:[t(N,{paragraph:!0,sx:{marginBottom:m=>m.spacing(2.5)},children:"Tags allow you to group features together"}),t("form",{id:x,onSubmit:K,children:c(Ks,{children:[t(to,{options:a,value:g,onChange:te}),t(no,{options:D,existingTags:l,tagType:g,selectedOptions:C,onChange:Z})]})})]})})},Js=d("div")(({theme:e})=>({display:"flex",flexDirection:"column",padding:e.spacing(3)})),Xs=d("div")(({theme:e})=>({display:"flex",gap:e.spacing(1),flexWrap:"wrap"})),Qs=d(Yt)(({theme:e})=>({fontSize:e.fontSizes.smallBody})),Zs=d(ye)(({theme:e})=>({margin:e.spacing(3),borderStyle:"dashed"})),er=d(re)(({theme:e})=>({maxWidth:e.spacing(20),alignSelf:"center"})),tr=({feature:e,header:n})=>{const{tags:a,refetch:o}=dn(e.name),{deleteTagFromFeature:s}=Te(),[i,r]=f.useState(!1),[l,u]=f.useState(!1),[p,h]=f.useState(),{setToastData:g,setToastApiError:b}=G(),{hasAccess:v}=f.useContext(ot),T=v(le,e.project),R=async()=>{if(p)try{await s(e.name,p.type,p.value),o(),g({type:"success",title:"Tag deleted",text:"Successfully deleted tag"})}catch(y){b(z(y))}};return c(Js,{children:[n,t(Xs,{children:a.map(y=>{const C=`${y.type}:${y.value}`;return t(Qs,{label:C,deleteIcon:t(na,{titleAccess:"Remove"}),onDelete:T?()=>{u(!0),h(y)}:void 0},C)})}),t(I,{condition:T,show:c(M,{children:[t(I,{condition:a.length>0,show:t(Zs,{})}),t(er,{"data-loading":!0,variant:"outlined",startIcon:t(aa,{}),onClick:()=>r(!0),children:"Add new tag"})]})}),t(un,{open:i,setOpen:r}),c(de,{open:l,primaryButtonText:"Delete tag",secondaryButtonText:"Cancel",onClose:()=>{u(!1),h(void 0)},onClick:()=>{u(!1),R(),h(void 0)},title:"Delete tag?",children:["You are about to delete tag:"," ",c("strong",{children:[p==null?void 0:p.type,":",p==null?void 0:p.value]})]})]})},nr=d("div")(({theme:e})=>({position:"sticky",top:e.spacing(2),borderRadius:e.shape.borderRadiusLarge,backgroundColor:e.palette.background.paper,display:"flex",flexDirection:"column",maxWidth:"350px",minWidth:"350px",marginRight:"1rem",marginTop:"1rem",[e.breakpoints.down(1e3)]:{marginBottom:"1rem",width:"100%",maxWidth:"none",minWidth:"auto"}})),He=d("h3")(({theme:e})=>({display:"flex",gap:e.spacing(1),alignItems:"center",fontSize:e.fontSizes.bodySize,margin:0,marginBottom:e.spacing(3),"& > :last-child":{position:"relative",top:1}})),ar=({hiddenEnvironments:e,setHiddenEnvironments:n})=>{const a=F("projectId"),o=F("featureId"),{feature:s}=j(a,o);return c(nr,{children:[t(Ys,{header:c(He,{"data-loading":!0,children:["Enabled in environments (",s.environments.filter(({enabled:i})=>i).length,")",t(Ye,{tooltip:"When a feature is switched off in an environment, it will always return false. When switched on, it will return true or false depending on its strategies.",placement:"top"})]}),feature:s,hiddenEnvironments:e,setHiddenEnvironments:n}),t(ye,{}),t(Ms,{header:t(He,{"data-loading":!0,children:"Feature toggle details"}),feature:s}),t(ye,{}),t(tr,{header:t(He,{"data-loading":!0,children:"Tags for this feature toggle"}),feature:s})]})},or=()=>{const{trackEvent:e}=Gt(),{value:n,setValue:a}=Ht(),[o,s]=f.useState(new Set(n.hiddenEnvironments));return{hiddenEnvironments:o,setHiddenEnvironments:r=>{a(l=>{const u=new Set(l.hiddenEnvironments);return u.has(r)?(u.delete(r),e("hidden_environment",{props:{eventType:"environment unhidden"}})):(u.add(r),e("hidden_environment",{props:{eventType:"environment hidden"}})),s(u),{...n,hiddenEnvironments:u}})}}},sr=d("div")(({theme:e})=>({display:"flex",width:"100%",[e.breakpoints.down(1e3)]:{flexDirection:"column"}})),rr=d("div")(({theme:e})=>({display:"flex",flexDirection:"column",width:"calc(100% - (350px + 1rem))",[e.breakpoints.down(1e3)]:{width:"100%"}})),ir=()=>{const e=ge(),n=F("projectId"),a=F("featureId"),o=Wt(n,a),{hiddenEnvironments:s,setHiddenEnvironments:i}=or(),r=()=>e(o);return Kt(a),c(sr,{children:[c("div",{children:[t(Eo,{}),t(ar,{hiddenEnvironments:s,setHiddenEnvironments:i})]}),t(rr,{children:t(Ds,{})}),c(Jt,{children:[t(se,{path:"strategies/create",element:t(Ke,{label:"Create feature strategy",onClose:r,open:!0,children:t(ao,{})})}),t(se,{path:"strategies/edit",element:t(Ke,{label:"Edit feature strategy",onClose:r,open:!0,children:t(oa,{})})})]})]})},cr=({values:e=[],updateValues:n,placeholder:a="",error:o,...s})=>{const i=l=>{const p=l.target.value.split(/,\s?/).map(h=>h.trim());n(p)},r=l=>{if(l.key==="Backspace"){const u=l.target.value;if(u.endsWith(", ")){l.preventDefault();const p=u.slice(0,-2);n(p.split(/,\s*/))}}};return t(Xt,{...s,error:o,placeholder:a,value:e?e.join(", "):"",onKeyDown:r,onChange:i,style:{width:"100%"},variant:"outlined",size:"small"})},lr=d("div")(({theme:e})=>({display:"flex",alignItems:"center",rowGap:e.spacing(1.5),marginBottom:e.spacing(2),[e.breakpoints.down("sm")]:{flexDirection:"column","& > div, .MuiInputBase-root":{width:"100%",alignItems:"flex-start"}}})),dr=d(Qt)(({theme:e})=>({marginRight:e.spacing(10),[e.breakpoints.up("sm")]:{minWidth:e.spacing(20)}})),ur=d("div")(({theme:e})=>({width:"100%",gap:e.spacing(1.5),display:"flex"})),pr=d(cr)(()=>({width:"100%"})),gr=d(Xt)(()=>({width:"100%"})),hr=({overrides:e,overridesDispatch:n})=>{const{context:a}=ct(),o=a.map(({name:r})=>({key:r,label:r})),s=r=>l=>{n({type:"UPDATE_VALUES_AT",payload:[r,l]})},i=r=>(l,u)=>{l==null||l.preventDefault(),n({type:"UPDATE_VALUES_AT",payload:[r,u||[]]})};return t(M,{children:e.map((r,l)=>{var g;const u=a.find(({name:b})=>b===r.contextName),p=((g=u==null?void 0:u.legalValues)==null?void 0:g.map(({value:b})=>b))||[],h=r.values.filter(b=>p.includes(b));return c(lr,{children:[t(dr,{id:"override-context-name",name:"contextName",label:"Context Field",value:r.contextName,options:o,onChange:b=>n({type:"UPDATE_TYPE_AT",payload:[l,b.target.value]})}),c(ur,{children:[t(I,{condition:Boolean(p&&p.length>0),show:t(sa,{multiple:!0,id:`override-select-${l}`,isOptionEqualToValue:(b,v)=>b===v,options:p,onChange:i(l),getOptionLabel:b=>b,value:h,style:{width:"100%"},filterSelectedOptions:!0,size:"small",renderInput:b=>t(gr,{...b,variant:"outlined",label:"Legal values"})}),elseShow:t(pr,{label:"Values (v1, v2, ...)",name:"values",placeholder:"",values:r.values,updateValues:s(l)})}),t(ee,{title:"Remove",arrow:!0,children:t($e,{onClick:b=>{b.preventDefault(),n({type:"REMOVE",payload:l})},children:t(tt,{})})})]})]},`override=${l}`)})})},mr=(e,n)=>{switch(n.type){case"SET":return n.payload;case"CLEAR":return[];case"ADD":return[...e,n.payload];case"REMOVE":return e.filter((r,l)=>l!==n.payload);case"UPDATE_VALUES_AT":const[a,o]=n.payload;return e.map((r,l)=>l===a?{...r,values:o}:r);case"UPDATE_TYPE_AT":const[s,i]=n.payload;return e.map((r,l)=>l===s?{...r,contextName:i}:r)}},fr=(e=[])=>f.useReducer(mr,e);var X=(e=>(e.FIX="fix",e.VARIABLE="variable",e))(X||{});const yr=d("div")(({theme:e})=>({position:"relative",backgroundColor:e.palette.neutral.light,display:"flex",flexDirection:"column",padding:e.spacing(3),marginBottom:e.spacing(3),borderRadius:e.shape.borderRadiusLarge})),Sr=d(ee)(({theme:e})=>({position:"absolute",top:e.spacing(2),right:e.spacing(2)})),pn=d("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody})),Dt=d(pn)(({theme:e})=>({display:"flex",color:e.palette.text.primary,marginTop:e.spacing(1),marginBottom:e.spacing(2)})),br=d("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,marginBottom:e.spacing(2)})),Cr=d(ra)(({theme:e})=>({marginBottom:e.spacing(1),"& > span":{fontSize:e.fontSizes.smallBody},[e.breakpoints.down("sm")]:{marginTop:e.spacing(1),marginBottom:e.spacing(1.5)}})),vr=d("div")(({theme:e})=>({width:"100%",gap:e.spacing(1.5),display:"flex","& > div":{width:"100%"}})),Ot=d(Zt)(()=>({width:"100%"})),wr=d("div")(({theme:e})=>({marginLeft:e.spacing(3)})),Tr=d(Zt)(({theme:e})=>({width:e.spacing(24),[e.breakpoints.down("sm")]:{width:"100%"}})),xr=d("div")(({theme:e})=>({marginTop:e.spacing(3),flexGrow:1})),gn=d("div")(({theme:e})=>({display:"flex",rowGap:e.spacing(1.5),marginBottom:e.spacing(2),[e.breakpoints.down("sm")]:{flexDirection:"column","& > div, .MuiInputBase-root":{width:"100%"}}})),Ar=d(gn)({alignItems:"end",justifyContent:"space-between"}),Er=d(Qt)(({theme:e})=>({marginRight:e.spacing(10),[e.breakpoints.up("sm")]:{minWidth:e.spacing(20)}})),Ir=d(re)(({theme:e})=>({marginTop:e.spacing(-1),marginLeft:e.spacing(-1)})),Rr=[{key:"string",label:"string"},{key:"json",label:"json"},{key:"csv",label:"csv"}],Fr={type:"string",value:""},kr=({variant:e,variants:n,updateVariant:a,removeVariant:o,apiPayload:s})=>{const[i,r]=f.useState(e.name),[l,u]=f.useState(e.weightType===X.FIX),[p,h]=f.useState(String(e.weight/10)),[g,b]=f.useState(e.payload||Fr),[v,T]=fr(e.overrides||[]),{context:R}=ct(),[y,C]=f.useState({}),w=m=>{C(S=>({...S,[m]:void 0}))},E=(m,S)=>{C(A=>({...A,[m]:S}))};f.useEffect(()=>{var m;w("percentage"),(m=s.error)!=null&&m.includes("%")&&E("percentage","Total weight must equal 100%")},[s.error]);const B=!e.new,D=n.filter(({id:m,weightType:S})=>m!==e.id&&S===X.VARIABLE).length>0,P=m=>{const S=m.weightType===X.VARIABLE,A=n.some(L=>L.weightType===X.FIX),V=n.filter(L=>L.weightType===X.VARIABLE).length===1;return A&&V&&S},O=m=>{w("name"),te(m,e.id)||E("name","A variant with that name already exists for this environment."),r(m)},$=m=>{(m===""||Z(m))&&h(m)},U=m=>{x(m)||E("payload","Invalid JSON.")},Y=()=>{R.length>0&&T({type:"ADD",payload:{contextName:R[0].name,values:[]}})},K=m=>Boolean(m.length),te=(m,S)=>B||!n.some(A=>A.name===m&&A.id!==S),Z=m=>{if(!l)return!0;if(m===""||m.match(/\.[0-9]{2,}$/))return!1;const S=Number(m);return S>=0&&S<=100},x=m=>{try{return m.type==="json"&&JSON.parse(m.value),!0}catch{return!1}};return f.useEffect(()=>{a({...e,name:i,weight:Number(l?p:100)*10,weightType:l?X.FIX:X.VARIABLE,stickiness:(n==null?void 0:n.length)>0?n[0].stickiness:"default",payload:g.value?g:void 0,overrides:v.map(m=>({contextName:m.contextName,values:m.values})).filter(m=>m.values&&m.values.length>0),isValid:K(i)&&te(i,e.id)&&Z(p)&&x(g)&&!s.error})},[i,l,p,g,v]),f.useEffect(()=>{l||h(String(e.weight/10))},[e.weight]),c(yr,{children:[t(Sr,{arrow:!0,title:P(e)?"You need to have at least one variable variant":"Delete variant",children:t("div",{children:t($e,{"data-testid":`VARIANT_DELETE_BUTTON_${e.name}`,onClick:()=>o(e.id),disabled:P(e),children:t(tt,{})})})}),c(Ar,{children:[c(xr,{children:[t(pn,{children:"Variant name"}),t(br,{children:"This will be used to identify the variant in your code"}),t(Ot,{id:`variant-name-input-${e.id}`,"data-testid":"VARIANT_NAME_INPUT",label:"Variant name",error:Boolean(y.name),errorText:y.name,value:i,onChange:m=>O(m.target.value),disabled:B,required:!0})]}),t(I,{condition:D,show:c(wr,{children:[t(Cr,{label:"Custom percentage",control:t(ia,{"data-testid":"VARIANT_WEIGHT_CHECK",checked:l,onChange:m=>u(m.target.checked)})}),t(Tr,{"data-testid":"VARIANT_WEIGHT_INPUT",type:"number",label:"Variant weight",error:Boolean(y.percentage),errorText:y.percentage,value:p,onChange:m=>$(m.target.value),required:l,disabled:!l,"aria-valuemin":0,"aria-valuemax":100,InputProps:{endAdornment:t(ca,{position:"end",children:"%"})}})]})})]}),c(Dt,{children:["Payload",t(Ye,{tooltip:"Passed along with the the variant object."})]}),c(gn,{children:[t(Er,{id:"variant-payload-type",name:"type",label:"Type",value:g.type,options:Rr,onChange:m=>{w("payload"),b(S=>({...S,type:m.target.value}))}}),t(vr,{children:t(Ot,{id:"variant-payload-value",name:"variant-payload-value",label:"Value",multiline:g.type!=="string",rows:g.type==="string"?1:4,value:g.value,onChange:m=>{w("payload"),b(S=>({...S,value:m.target.value}))},placeholder:g.type==="json"?'{ "hello": "world" }':"",onBlur:()=>U(g),error:Boolean(y.payload),errorText:y.payload})})]}),c(Dt,{children:["Overrides",t(Ye,{tooltip:"Here you can specify which users should get this variant."})]}),t(hr,{overrides:v,overridesDispatch:T}),t("div",{children:t(Ir,{onClick:Y,variant:"text",color:"primary",children:"Add override"})})]})},$r=d("div")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between","& > div":{display:"flex",alignItems:"center"},marginTop:e.spacing(-3.5),marginBottom:e.spacing(2),backgroundColor:e.palette.background.default,paddingTop:e.spacing(2),paddingBottom:e.spacing(2),position:"sticky",top:0,zIndex:2})),Pr=d(en,{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:n})=>({color:n?e.palette.neutral.border:e.palette.primary.main})),Br=d("span",{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:n})=>({color:n?e.palette.text.secondary:e.palette.text.primary,marginLeft:e.spacing(1.25),fontSize:e.fontSizes.mainHeader,fontWeight:e.fontWeight.bold})),Dr=d("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),Or=d(he)(({theme:e})=>({marginBottom:e.spacing(2)})),Vr=d(he)(({theme:e})=>({marginTop:e.spacing(4)})),Mr=d("div")({display:"flex",flexDirection:"column"}),Lr=d("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1.5),marginBottom:e.spacing(.5)})),Vt=d("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,marginBottom:e.spacing(1.5)})),_r=d(ye)(({theme:e})=>({margin:e.spacing(4,0)})),jr=d(la)(({theme:e})=>({minWidth:e.spacing(20),width:"100%"})),Nr=d("div")(({theme:e})=>({marginTop:"auto",paddingTop:e.spacing(4),display:"flex",justifyContent:"flex-end"})),zr=d(re)(({theme:e})=>({marginLeft:e.spacing(3)})),Wr=({environment:e,open:n,setOpen:a,getApiPayload:o,getCrPayload:s,onConfirm:i})=>{var gt;const r=F("projectId"),l=F("featureId"),{uiConfig:u}=lt(),{context:p}=ct(),{defaultStickiness:h,loading:g}=da(r),{isChangeRequestConfigured:b}=oe(r),{data:v}=ve(r),{changeRequestInReviewOrApproved:T,alert:R}=ga(v),y=(e==null?void 0:e.variants)||[],[C,w]=f.useState([]),[E,B]=f.useState();f.useEffect(()=>{g||w(y.length?y.map(k=>({...k,isValid:!0,new:!1,id:_e()})):[{name:"",weightType:X.VARIABLE,weight:0,overrides:[],stickiness:(C==null?void 0:C.length)>0?C[0].stickiness:h,new:!0,isValid:!1,id:_e()}])},[n,g]);const D=(k,W)=>{w(ie=>yt(ie.map(Ae=>Ae.id===W?k:Ae),1e3))},P=()=>{const k=_e();w(W=>[...W,{name:"",weightType:X.VARIABLE,weight:0,overrides:[],stickiness:(W==null?void 0:W.length)>0?W[0].stickiness:h,new:!0,isValid:!1,id:k}]),B(k)};f.useEffect(()=>{if(E){const k=document.getElementById(`variant-name-input-${E}`);k==null||k.scrollIntoView({behavior:"smooth",block:"center"}),k==null||k.focus({preventScroll:!0}),B(void 0)}},[E]);const O=C.map(({new:k,isValid:W,id:ie,...Ae})=>Ae),$=o(y,O),U=s(O),Y=async k=>{k.preventDefault(),i(O)},K=()=>m?`curl --location --request POST '${u.unleashUrl}/api/admin/projects/${r}/environments/${e==null?void 0:e.name}/change-requests' \\
|
|
2
|
+
--header 'Authorization: INSERT_API_KEY' \\
|
|
3
|
+
--header 'Content-Type: application/json' \\
|
|
4
|
+
--data-raw '${JSON.stringify(U,void 0,2)}'`:`curl --location --request PATCH '${u.unleashUrl}/api/admin/projects/${r}/features/${l}/environments/${e==null?void 0:e.name}/variants' \\
|
|
5
|
+
--header 'Authorization: INSERT_API_KEY' \\
|
|
6
|
+
--header 'Content-Type: application/json' \\
|
|
7
|
+
--data-raw '${JSON.stringify($.patch,void 0,2)}'`,te=C.every(({isValid:k})=>k),Z=T((e==null?void 0:e.name)||""),x=Z?"Add to existing change request":"Add change to draft",m=b((e==null?void 0:e.name)||"")&&u.flags.crOnVariants,S=((gt=O[0])==null?void 0:gt.stickiness)||h,A=f.useMemo(()=>["default",...p.filter(k=>k.stickiness).map(k=>k.name)],[p]),V=A.map(k=>({key:k,label:k}));A.includes(S)||V.push({key:S,label:S});const L=async k=>{w(W=>W.map(ie=>({...ie,stickiness:k})))},_=k=>{L(k).catch(console.warn)},[q,xe]=f.useState();f.useEffect(()=>{xe(void 0),$.error&&xe($.error)},[$.error]);const pt=()=>{L(h).catch(console.warn),a(!1)};return g||S===""?t(ua,{}):t(Ke,{open:n,onClose:pt,label:"",children:c(pa,{modal:!0,title:"",description:"Variants allows you to return a variant object if the feature toggle is considered enabled for the current request.",documentationLink:"https://docs.getunleash.io/reference/feature-toggle-variants",documentationLinkLabel:"Feature toggle variants documentation",formatApiCode:K,loading:!n,children:[c($r,{children:[c("div",{children:[t(Pr,{deprecated:!(e!=null&&e.enabled)}),t(Br,{deprecated:!(e!=null&&e.enabled),children:e==null?void 0:e.name})]}),t(ae,{"data-testid":"MODAL_ADD_VARIANT_BUTTON",onClick:P,variant:"outlined",permission:ce,projectId:r,environmentId:e==null?void 0:e.name,children:"Add variant"})]}),c(Dr,{onSubmit:Y,children:[t(I,{condition:Z,show:R,elseShow:t(I,{condition:Boolean(m),show:c(Or,{severity:"info",children:[t("strong",{children:"Change requests"})," are enabled",e?` for ${e.name}`:"",". Your changes need to be approved before they will be live. All the changes you do now will be added into a draft that you can submit for review."]})})}),t(Mr,{children:C.map(k=>t(kr,{variant:k,variants:C,updateVariant:W=>D(W,k.id),removeVariant:()=>w(W=>yt(W.filter(ie=>ie.id!==k.id),1e3)),projectId:r,apiPayload:$},k.id))}),t(ae,{onClick:P,variant:"outlined",permission:ce,projectId:r,environmentId:e==null?void 0:e.name,children:"Add variant"}),t(_r,{}),t(I,{condition:C.length>0,show:c(M,{children:[t(Lr,{children:t("p",{children:"Stickiness"})}),c(Vt,{children:["By overriding the stickiness you can control which parameter is used to ensure consistent traffic allocation across variants."," ",t(it,{href:"https://docs.getunleash.io/reference/feature-toggle-variants",target:"_blank",rel:"noreferrer",children:"Read more"})]}),t("div",{children:t(jr,{value:S,label:"",editable:!0,onChange:k=>_(k.target.value)})})]}),elseShow:t(Vt,{children:"This environment has no variants. Get started by adding a variant."})}),c(Vr,{severity:"error",hidden:!Boolean(q),children:[t("strong",{children:"Error: "}),q]}),c(Nr,{children:[t(re,{"data-testid":"DIALOGUE_CONFIRM_ID",type:"submit",variant:"contained",color:"primary",disabled:!te,children:m?x:"Save variants"}),t(zr,{onClick:pt,children:"Cancel"})]})]})]})})},Ur=d("div")(({theme:e})=>({padding:e.spacing(3),borderRadius:e.shape.borderRadiusLarge,border:`1px solid ${e.palette.divider}`,"&:not(:last-child)":{marginBottom:e.spacing(3)}})),qr=d("div")({display:"flex",alignItems:"center",justifyContent:"space-between","& > div":{display:"flex",alignItems:"center"}}),Hr=d(en,{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:n})=>({color:n?e.palette.neutral.border:e.palette.primary.main})),Gr=d("span",{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:n})=>({color:n?e.palette.text.secondary:e.palette.text.primary,marginLeft:e.spacing(1.25),fontWeight:e.fontWeight.bold})),Yr=d("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,marginBottom:e.spacing(1.5)})),Kr=d("div")(({theme:e})=>({margin:e.spacing(3,0)})),Jr=d("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1.5),marginBottom:e.spacing(.5)})),Xr=({environment:e,searchValue:n,children:a})=>{var i;const o=e.variants??[],s=((i=o[0])==null?void 0:i.stickiness)||"default";return c(Ur,{children:[c(qr,{children:[c("div",{children:[t(Hr,{deprecated:!e.enabled}),t(Gr,{deprecated:!e.enabled,children:e.name})]}),a]}),t(I,{condition:o.length>0,show:c(M,{children:[t(Kr,{children:t(ha,{variants:o,searchValue:n})}),t(I,{condition:o.length>1,show:c(M,{children:[c(Jr,{children:[t("p",{children:"Stickiness:"}),t(fe,{children:s})]}),c(Yr,{children:["By overriding the stickiness you can control which parameter is used to ensure consistent traffic allocation across variants."," ",t(it,{href:"https://docs.getunleash.io/reference/feature-toggle-variants",target:"_blank",rel:"noreferrer",children:"Read more"})]})]})})]})})]})},Qr=d(at)(({theme:e})=>({"& span":{fontSize:e.fontSizes.smallBody}})),Zr=({environment:e,permission:n,projectId:a,environmentId:o,onCopyVariantsFrom:s,otherEnvsWithVariants:i})=>{const[r,l]=f.useState(null),u=Boolean(r),p=e.variants??[];return t(I,{condition:i.length>0&&p.length===0,show:c(M,{children:[t(ae,{onClick:h=>{l(h.currentTarget)},id:`copy-from-menu-${e.name}`,"aria-controls":u?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":u?"true":void 0,variant:"outlined",permission:n,projectId:a,environmentId:o,children:"Copy variants from"}),t(Pe,{anchorEl:r,open:u,onClose:()=>l(null),MenuListProps:{"aria-labelledby":`copy-from-menu-${e.name}`},children:i.map(h=>t(Be,{onClick:()=>s(h,e),children:t(Qr,{children:`Copy from ${h.name}`})},h.name))})]})})},ei=({permission:e,projectId:n,environment:a,checked:o,onClick:s,...i})=>{const r=ma(e,n,a);return c(Be,{disabled:!r,onClick:s,...i,children:[t(fa,{checked:o}),a]})},ti=d(Pe)(({theme:e})=>({"& > div > ul":{display:"flex",flexDirection:"column",justifyContent:"center","& > li":{padding:e.spacing(0,1)}}})),ni=d("div")(({theme:e})=>({margin:e.spacing(1,2)})),ai=d(re)(({theme:e})=>({marginTop:e.spacing(2)})),oi=({current:e,environments:n,permission:a,projectId:o,onSubmit:s})=>{var R;const[i,r]=f.useState(null),l=Boolean(i),[u,p]=f.useState([]),h=y=>{p(C=>[...C,y])},g=y=>{p(C=>C.filter(({name:w})=>w!==y.name))},b=y=>{u.includes(y)?g(y):h(y)},v=()=>{p([]),r(null)},T=((R=n.find(y=>y.name===e))==null?void 0:R.variants)??[];return t(I,{condition:T.length>0&&n.length>1,show:c(M,{children:[t(re,{onClick:y=>{r(y.currentTarget)},id:`push-to-menu-${e}`,"aria-controls":l?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":l?"true":void 0,variant:"outlined",children:"Push to environment"}),c(ti,{anchorEl:i,open:l,onClose:()=>r(null),MenuListProps:{"aria-labelledby":`push-to-menu-${e}`},children:[n.filter(y=>y.name!==e).map(y=>t(ei,{projectId:o,permission:a,environment:y.name,checked:u.includes(y),onClick:()=>b(y)},y.name)),c(ni,{children:[t(ye,{}),c(ai,{variant:"outlined",onClick:()=>{s(u),v()},disabled:u.length===0,children:["Push to selected (",u.length,")"]})]})]})]})})},si=d(he)(({theme:e})=>({marginBottom:e.spacing(4),"& code":{fontWeight:e.fontWeight.bold}})),ri=d("div")(({theme:e})=>({display:"flex",gap:e.spacing(1.5)})),ii=()=>{const{uiConfig:e}=lt(),{setToastData:n,setToastApiError:a}=G(),o=et(),s=De(o.breakpoints.down("md")),i=F("projectId"),r=F("featureId"),{feature:l,refetchFeature:u,loading:p}=j(i,r),{patchFeatureEnvironmentVariants:h,overrideVariantsInEnvironments:g}=Te(),{refetch:b}=ve(i),{addChange:v}=nt(),{isChangeRequestConfigured:T}=oe(i),[R,y]=f.useState(""),[C,w]=f.useState(),[E,B]=f.useState(!1),D=f.useMemo(()=>{var x;return((x=l==null?void 0:l.environments)==null?void 0:x.map(m=>({...m,crEnabled:e.flags.crOnVariants&&T(m.name)})))||[]},[l.environments,e.flags.crOnVariants]),P=(x,m)=>ba(x,m),O=(x,m)=>{try{const S=Sa(m,1e3);return{patch:P(x,S)}}catch(S){return{patch:[],error:z(S)}}},$=x=>({feature:r,action:"patchVariant",payload:{variants:x}}),U=async(x,m)=>{if(x.crEnabled)await v(i,x.name,$(m)),b();else{const S=x.variants??[],{patch:A,error:V}=O(S,m);if(A.length===0)return;if(V){n({type:"error",title:V});return}await h(i,r,x.name,A)}u()},Y=async(x,m)=>{try{const S=m.filter(({crEnabled:q})=>q),A=m.filter(({crEnabled:q})=>!q);S.length&&await Promise.all(S.map(q=>v(i,q.name,$(x)))),A.length&&await g(i,r,x,A.map(({name:q})=>q)),b(),u();const V=A.length?`Variants pushed to ${A.length===1?A[0].name:`${A.length} environments`}`:"",L=S.length?`Variants push added to ${S.length===1?`${S[0].name} draft`:`${S.length} drafts`}`:"",_=`${V}${V&&L?". ":""}${L}`;n({title:_,type:"success"})}catch(S){a(z(S))}},K=x=>{w(x),B(!0)},te=async x=>{if(C)try{await U(C,x),B(!1),n({title:C.crEnabled?"Variant changes added to draft":"Variants updated successfully",type:"success"})}catch(m){a(z(m))}},Z=async(x,m)=>{try{const S=x.variants??[];await U(m,S),n({title:m.crEnabled?"Variants copy added to draft":"Variants copied successfully",type:"success"})}catch(S){a(z(S))}};return c(dt,{isLoading:p,header:t(ya,{title:"Variants",actions:t(I,{condition:!s,show:t(M,{children:t(St,{initialValue:R,onChange:y})})}),children:t(I,{condition:s,show:t(St,{initialValue:R,onChange:y})})}),children:[c(si,{severity:"info",children:["Variants allows you to return a variant object if the feature toggle is considered enabled for the current request. When using variants you should use the ",t("code",{children:"getVariant()"})," method in the Client SDK."]}),D.map(x=>{var S;const m=D.filter(({name:A,variants:V})=>A!==x.name&&(V==null?void 0:V.length));return t(Xr,{environment:x,searchValue:R,children:c(ri,{children:[t(oi,{current:x.name,environments:D,permission:ce,projectId:i,onSubmit:A=>Y(x.variants??[],A)}),t(Zr,{environment:x,permission:ce,projectId:i,environmentId:x.name,onCopyVariantsFrom:Z,otherEnvsWithVariants:m}),t(I,{condition:Boolean((S=x.variants)==null?void 0:S.length),show:t(Q,{"data-testid":"EDIT_VARIANTS_BUTTON",onClick:()=>K(x),permission:ce,projectId:i,environmentId:x.name,tooltipProps:{title:"Edit variants"},children:t(me,{})}),elseShow:t(ae,{"data-testid":"ADD_VARIANT_BUTTON",onClick:()=>K(x),variant:"outlined",permission:ce,projectId:i,environmentId:x.name,children:"Add variant"})})]})},x.name)}),t(Wr,{environment:C,open:E,setOpen:B,getApiPayload:O,getCrPayload:$,onConfirm:te})]})},ci=be("api/admin/client-metrics/features"),hn=(e,n)=>{const a=be(`api/admin/client-metrics/features/${e}/raw?hoursBack=${n}`),{data:o,error:s}=Qe(a,()=>li(a)),i=f.useCallback(()=>{Ze(ci).catch(console.warn)},[]);return{featureMetrics:o==null?void 0:o.data,loading:!s&&!o,refetchFeatureMetrics:i,error:s}},li=e=>fetch(e).then(ke("Features")).then(n=>n.json()).then(),Se=48,di=({hoursBack:e,setHoursBack:n})=>{const a=o=>{n(ui(o))};return t(Ca,{label:"Period",name:"feature-metrics-period",id:"feature-metrics-period",options:pi,value:String(e),onChange:a,fullWidth:!0})},ui=e=>{switch(e){case"1":return 1;case"24":return 24;default:return Se}},pi=[{key:"1",label:"Last hour"},{key:"24",label:"Last 24 hours"},{key:`${Se}`,label:`Last ${Se} hours`}],gi=({metrics:e,tableSectionId:n})=>{const a=De(tn.breakpoints.down("md")),o=f.useMemo(()=>({sortBy:[{id:"timestamp"}]}),[]),{getTableProps:s,getTableBodyProps:i,headerGroups:r,rows:l,prepareRow:u,setHiddenColumns:p}=Le.useTable({initialState:o,columns:Mt,data:e,autoResetHiddenColumns:!1,disableSortRemove:!0,defaultColumn:{Cell:va}},Le.useGlobalFilter,Le.useSortBy);return wa([{condition:a,columns:["appName","environment"]}],p,Mt),e.length===0?null:c(Ta,{...s(),rowHeight:"standard",id:n,children:[t(xa,{headerGroups:r}),t(Aa,{...i(),children:l.map(h=>(u(h),t(Ea,{hover:!0,...h.getRowProps(),children:h.cells.map(g=>t(Ia,{...g.getCellProps(),children:g.render("Cell")}))})))})]})},Mt=[{id:"Icon",width:"1%",disableSortBy:!0,Cell:()=>t(Ra,{icon:t(yo,{color:"disabled"})})},{Header:"Time",accessor:"timestamp",Cell:e=>t(Fa,{value:e.row.original.timestamp})},{Header:"Application",accessor:"appName"},{Header:"Environment",accessor:"environment"},{id:"requested",Header:"Requested",accessor:e=>e.yes+e.no},{Header:"Exposed",accessor:"yes"}],hi=({metrics:e,...n})=>{const a=f.useMemo(()=>e.reduce((s,i)=>s+i.yes,0),[e]),o=f.useMemo(()=>e.reduce((s,i)=>s+i.no,0),[e]);return t(ln,{...n,totalYes:a,totalNo:o})},mi=({metrics:e,hoursBack:n})=>{const a=bt(),o=bt();return e.length===0?c(H,{mt:6,children:[t(N,{variant:"body1",paragraph:!0,children:"We have yet to receive any metrics for this feature toggle in the selected time period."}),t(N,{variant:"body1",paragraph:!0,children:"Please note that, since the SDKs send metrics on an interval, it might take some time before metrics appear."})]}):c(f.Suspense,{fallback:null,children:[t(H,{borderTop:1,pt:2,mt:3,borderColor:tn.palette.divider,children:t(fi,{metrics:e,hoursBack:n,statsSectionId:a})}),t(H,{mt:4,children:t(hi,{metrics:e,hoursBack:n,statsSectionId:a,tableSectionId:o})}),t(H,{mt:4,children:t(gi,{metrics:e,tableSectionId:o})})]})},fi=ka.lazy(()=>import("./FeatureMetricsChart-66e2ebdf.js")),Xe=e=>{const{search:n}=window.location,a=ge(),o=f.useMemo(()=>new URLSearchParams(n),[n]),s=f.useCallback(i=>{const r=new URLSearchParams(n);r.set(e,i),a({search:r.toString()},{replace:!0})},[e,n,a]);return[o.get(e)||void 0,s]},yi=e=>{const[n,a]=Xe(e),o=f.useCallback(s=>a(String(s)),[a]);return[Number.isFinite(Number(n))?Number(n):void 0,o]},Si=d("h2")(({theme:e})=>({margin:0,marginBottom:e.spacing(1),fontSize:e.fontSizes.smallBody,fontWeight:e.fontWeight.thin,color:e.palette.text.secondary})),bi=d("ul")(({theme:e})=>({display:"flex",flexWrap:"wrap",gap:e.spacing(1),listStyleType:"none",padding:0,minHeight:"100%"})),Ci=d("li")(({theme:e})=>({"& > [aria-pressed=true]":{backgroundColor:e.palette.background.alternative,color:e.palette.primary.contrastText},"& > [aria-pressed=true]:hover":{backgroundColor:e.palette.primary.light}})),Lt=({title:e,values:n,value:a,setValue:o})=>{const s=r=>()=>{n.has(r)&&o(r)},i=f.useMemo(()=>Array.from(n).sort((r,l)=>r.localeCompare(l)),[n]);return c("div",{children:[t(Si,{children:e}),t(bi,{children:i.map(r=>t(Ci,{children:t(Yt,{label:r,onClick:s(r),"aria-pressed":r===a,sx:$a})},r))})]})},vi=d("div")(({theme:e})=>({[e.breakpoints.down("md")]:{marginTop:e.spacing(2)}})),wi=()=>{const e=F("projectId"),n=F("featureId"),a=Ti(e,n),o=xi(n);Kt("Metrics");const[s=Se,i]=yi("hoursBack"),{featureMetrics:r}=hn(n,s),[l,u]=f.useState(r);f.useEffect(()=>{r&&u(r)},[r]);const p=Array.from(a)[0],h=Array.from(o)[0],[g=p,b]=Xe("environment"),[v=h,T]=Xe("application"),R=f.useMemo(()=>l==null?void 0:l.filter(y=>y.environment===g).filter(y=>y.appName===v),[l,g,v]);return R?c(dt,{children:[c(ne,{container:!0,component:"header",spacing:2,alignItems:"flex-end",children:[t(ne,{item:!0,xs:12,md:5,children:t(I,{condition:a.size>0,show:t(Lt,{title:"Environments",values:a,value:g,setValue:b})})}),t(ne,{item:!0,xs:12,md:5,children:t(I,{condition:o.size>0,show:t(Lt,{title:"Applications",values:o,value:v,setValue:T})})}),t(ne,{item:!0,xs:12,md:2,children:t(vi,{children:t(di,{hoursBack:s,setHoursBack:i})})})]}),t(mi,{metrics:R,hoursBack:s})]}):null},Ti=(e,n)=>{const{feature:a}=j(e,n),o=a.environments.map(s=>s.name);return new Set(o)},xi=e=>{const{featureMetrics:n=[]}=hn(e,Se),a=n.map(o=>o.appName);return new Set(a)},Ai=(e,n)=>{const a=new Set(e),o=new Set(n);return a.size!==o.size?!1:[...a].every(s=>o.has(s))},_t=d("div")(({theme:e})=>({display:"grid",gap:e.spacing(2)})),jt=d(he)(({theme:e})=>({marginBottom:e.spacing(1)})),Ei=d(rt)({padding:0}),Ii=({projectId:e,open:n,onClose:a,onClick:o,feature:s,changeRequests:i})=>{const r=F("projectId"),{project:l}=nn(e),{isChangeRequestConfiguredInAnyEnv:u}=oe(e),p=u(),h=f.useMemo(()=>Ai(s.environments.map(b=>b.name),l.environments),[s,l]),g=i?i.length>0:!1;return t(I,{condition:h&&!g&&!p,show:t(de,{open:n,onClose:a,onClick:o,title:"Confirm change project",primaryButtonText:"Change project",secondaryButtonText:"Cancel",children:c(_t,{children:[t(jt,{severity:"success",children:"This feature toggle is compatible with the new project."}),t("p",{children:"Are you sure you want to change the project for this toggle?"})]})}),elseShow:t(de,{open:n,onClick:a,title:"Confirm change project",primaryButtonText:"Close",children:c(_t,{children:[t(jt,{severity:"warning",children:"Cannot proceed with the move"}),t(I,{condition:!h,show:t("p",{children:"In order to move a feature toggle between two projects, both projects must have the exact same environments enabled."})}),t(I,{condition:g,show:c(M,{children:[t("p",{children:"The feature toggle must not have any pending change requests. This feature toggle is currently referenced in the following change requests:"}),t(Ei,{children:i==null?void 0:i.map(b=>t(Re,{children:c(J,{to:`/projects/${r}/change-requests/${b.id}`,children:["View change request"," ",b.id]})},b.id))})]})}),t(I,{condition:p,show:c("p",{children:["You're not allowed to move the feature to project"," ",t(J,{to:`/projects/${e}/settings/change-requests`,children:e}),". This project has change requests enabled."]})})]})})})},Ri=e=>fetch(e).then(ke("ChangeRequest")).then(n=>n.json()),Fi=(e,n)=>{const{data:a,error:o,mutate:s}=Pa([],be(`api/admin/projects/${e}/change-requests/pending/${n}`),Ri);return{changeRequests:a,loading:!o&&!a,refetch:s,error:o}},ki=()=>{const{hasAccess:e}=f.useContext(ot),n=F("projectId"),a=F("featureId"),{feature:o,refetchFeature:s}=j(n,a),[i,r]=f.useState(!1),{changeFeatureProject:l}=Te(),{setToastData:u,setToastApiError:p}=G(),[h,g]=f.useState(n),{projects:b}=Ba(),v=ge(),{changeRequests:T}=Fi(n,a),R=async()=>{try{h&&(await l(n,a,h),s(),u({title:"Project changed",type:"success"}),r(!1),v(`/projects/${h}/features/${a}/settings`,{replace:!0}))}catch(C){p(z(C))}},y=f.useMemo(()=>b.map(C=>C.id).filter(C=>e(Ct,C)),[b,e]);return y.length===0?null:c(M,{children:[t(Da,{value:h,onChange:g,label:"Project",filter:C=>y.includes(C),enabled:!0}),t(ae,{permission:Ct,onClick:()=>r(!0),disabled:h===n,projectId:n,children:"Save"}),t(Ii,{changeRequests:T,projectId:h,open:i,feature:o,onClose:()=>r(!1),onClick:R})]})},$i=d("div")({display:"flex",alignItems:"center"}),Pi=d(N)(({theme:e})=>({fontSize:e.fontSizes.mainHeader})),Bi=({projectId:e,featureId:n})=>{var i;const{feature:a}=j(e,n),o=ge();return c(M,{children:[c($i,{children:[t(Pi,{children:"Feature information"}),t(Q,{permission:le,projectId:e,"data-loading":!0,onClick:()=>{o(`/projects/${e}/features/${n}/edit`)},tooltipProps:{title:"Edit"},children:t(me,{})})]}),c(N,{children:["Name: ",t("strong",{children:a.name})]}),c(N,{children:["Description:"," ",t("strong",{children:(i=a.description)!=null&&i.length?a.description:"no description"})]}),c(N,{children:["Type: ",t("strong",{children:a.type})]}),c(N,{children:["Impression Data:"," ",t("strong",{children:a.impressionData?"enabled":"disabled"})]})]})},Ee="metadata",Ge="project",Di=d("div")(({theme:e})=>({width:"20%",borderRight:`1px solid ${e.palette.divider}`,padding:e.spacing(2,0),[e.breakpoints.down("md")]:{width:"35%"}})),Oi=d("div")(({theme:e})=>({padding:e.spacing(4),display:"flex",flexDirection:"column",width:400,["& > *"]:{margin:e.spacing(1,0)}})),Vi=()=>{const e=F("projectId"),n=F("featureId"),[a,o]=f.useState(Ee),{uiConfig:s}=lt();return t(dt,{header:"Settings",sx:{padding:0},children:c(H,{sx:{display:"flex"},children:[t(Di,{children:c(rt,{children:[t(Re,{sx:{padding:"0.75rem 2rem"},button:!0,onClick:()=>o(Ee),selected:a===Ee,children:"Metadata"},0),t(Re,{sx:{padding:"0.75rem 2rem"},button:!0,onClick:()=>o(Ge),selected:a===Ge,hidden:!s.flags.P,children:"Project"},1)]})}),c(Oi,{children:[t(I,{condition:a===Ee,show:t(Bi,{projectId:e,featureId:n})}),t(I,{condition:a===Ge&&s.flags.P,show:t(ki,{})})]})]})})},Mi=({stale:e,showActive:n=!0})=>!e&&!n?null:t("div",{"data-loading":!0,style:{marginLeft:"8px"},children:t(fe,{color:e?"error":"success",title:e?"Feature toggle is deprecated.":"Feature toggle is active.",children:e?"Stale":"Active"})}),Nt=d("strong")({wordBreak:"break-all"}),Li=()=>{const e=F("projectId"),n=F("featureId"),{archivedFeatures:a}=Oa(),o=Va(e,{name:n});return a?a.some(i=>i.name===n)?c("p",{children:["The feature ",t(Nt,{children:n})," has been archived. You can find it on the"," ",t(J,{to:`/projects/${e}/archive`,children:"project archive page"}),"."]}):c("p",{children:["The feature ",t(Nt,{children:n})," does not exist. Would you like to"," ",t(J,{to:o,children:"create it"}),"?"]}):null},_i=d("div")(({theme:e})=>({backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadiusLarge,marginBottom:e.spacing(2)})),ji=d("div")(({theme:e})=>({padding:e.spacing(2,4,2,2),display:"flex",justifyContent:"space-between",alignItems:"center",[e.breakpoints.down(500)]:{flexDirection:"column"}})),Ni=d("div")({display:"flex",alignItems:"center"}),zi=d("h1")(({theme:e})=>({fontSize:e.fontSizes.mainHeader,fontWeight:"normal",display:"flex",alignItems:"center",wordBreak:"break-all"})),Wi=d("div")({flexShrink:0,display:"flex"}),Ui=d("div")(({theme:e})=>({width:"100%",backgroundColor:e.palette.divider,height:"1px"})),qi=d("div")(({theme:e})=>({padding:e.spacing(0,4)})),Hi=d(Ma)(({theme:e})=>({textTransform:"none",width:"auto",fontSize:e.fontSizes.bodySize,padding:"0 !important",[e.breakpoints.up("md")]:{minWidth:160}})),Qi=()=>{const e=F("projectId"),n=F("featureId"),{refetch:a}=nn(e),{favorite:o,unfavorite:s}=La(),{refetchFeature:i}=j(e,n),[r,l]=f.useState(!1),[u,p]=f.useState(!1),[h,g]=f.useState(!1),b=De(`(max-width:${500}px)`),{feature:v,loading:T,error:R,status:y}=j(e,n),C=ge(),{pathname:w}=_a(),E=ja(T),B=`/projects/${e}/features/${n}`,D=[{title:"Overview",path:`${B}`,name:"overview"},{title:"Metrics",path:`${B}/metrics`,name:"Metrics"},{title:"Variants",path:`${B}/variants`,name:"Variants"},{title:"Settings",path:`${B}/settings`,name:"Settings"},{title:"Event log",path:`${B}/logs`,name:"Event log"}],P=D.find($=>$.path===w)??D[0],O=async()=>{v!=null&&v.favorite?await s(e,v.name):await o(e,v.name),i()};return y===404?t(Li,{}):R!==void 0?t("div",{ref:E}):c("div",{ref:E,children:[c(_i,{children:[c(ji,{children:[c(Ni,{children:[t(Na,{onClick:O,isFavorite:v==null?void 0:v.favorite}),c(zi,{"data-loading":!0,children:[v.name," "]}),t(I,{condition:!b,show:t(Mi,{stale:v==null?void 0:v.stale})})]}),c(Wi,{children:[t(Q,{permission:za,projectId:e,"data-loading":!0,component:J,to:`/projects/${e}/features/${n}/strategies/copy`,tooltipProps:{title:"Copy feature toggle"},children:t(Wa,{})}),t(Q,{permission:Ua,projectId:e,tooltipProps:{title:"Archive feature toggle"},"data-loading":!0,onClick:()=>p(!0),children:t(oo,{})}),t(Q,{onClick:()=>g(!0),permission:le,projectId:e,tooltipProps:{title:"Toggle stale state"},"data-loading":!0,children:t(so,{})}),t(Q,{onClick:()=>l(!0),permission:le,projectId:e,tooltipProps:{title:"Add tag"},"data-loading":!0,children:t(qa,{})})]})]}),t(Ui,{}),t(qi,{children:t(Ha,{value:P.path,indicatorColor:"primary",textColor:"primary",children:D.map($=>t(Hi,{label:$.title,value:$.path,onClick:()=>C($.path)},$.title))})})]}),c(Jt,{children:[t(se,{path:"metrics",element:t(wi,{})}),t(se,{path:"logs",element:t(Co,{})}),t(se,{path:"variants",element:t(ii,{})}),t(se,{path:"settings",element:t(Vi,{})}),t(se,{path:"*",element:t(ir,{})})]}),t(ro,{isOpen:u,onConfirm:()=>{a(),C(`/projects/${e}`)},onClose:()=>p(!1),projectId:e,featureIds:[n]}),t(io,{isStale:v.stale,isOpen:h,onClose:()=>{g(!1),i()},featureId:n,projectId:e}),t(un,{open:r,setOpen:l})]})};export{Qi as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{s as f,r as p,aD as yo,cH as bo,aE as So,j as e,aF as vn,cI as Kt,cJ as Tt,cK as vo,cL as Co,cM as wo,cN as xo,c as ut,cO as Cn,cP as Oe,cQ as It,aS as oe,aR as Te,aT as Ce,bj as he,cR as wn,C as k,cS as Zt,ak as Q,al as te,f as r,F,V as ye,cT as xn,cU as $e,cV as ht,cW as ko,cX as To,ae as Ao,cY as Eo,a2 as K,H as Y,ar as ae,bL as kn,av as we,ax as Ot,cZ as Nt,a4 as V,aA as me,bo as y,bR as ie,bT as be,a5 as Ze,a6 as Ro,a7 as Po,a8 as He,ac as X,Z as Ie,c_ as We,c$ as z,A as _,a9 as M,a as j,d0 as Do,T as I,af as Gt,d1 as Tn,a1 as Io,d2 as Uo,d3 as Me,B as Ut,d4 as Bo,aO as Re,d as Z,e as je,l as Se,g as An,S as En,h as pt,i as qe,k as Rn,W as ge,c6 as Ne,m as Fe,d5 as Lo,aU as $t,d6 as jt,bw as Pn,d7 as Oo,d8 as Dn,d9 as In,da as ne,bx as Un,db as No,c8 as Xt,dc as Ft,bF as Bn,ad as Go,dd as $o,de as At,c1 as Ln,cG as jo,cE as Fo,N as ve,c5 as Ge,df as ze,R as xe,b9 as Pe,aY as De,U as Xe,Y as Qe,bS as Ve,bJ as zt,w as zo,dg as Mo,dh as Ho,bK as Wo,di as qo,dj as _o,dk as Vo,aI as mt,dl as Mt,dm as On,ah as Nn,a_ as se,bO as Gn,K as Yo,u as Ht,dn as gt,dp as Jo,L as $n,Q as Wt,aM as ke,dq as Ko,aP as et,dr as Zo,ds as jn,dt as Xo,X as Ye,P as Fn,du as Qo,bd as Et,bf as Rt,dv as ea,dw as ta,dx as na,as as qt,dy as oa,ci as zn,co as Mn,cg as de,bM as Hn,bN as J,x as aa,br as ra,bs as ia,bt as sa,bV as la,dz as ca,bH as Pt,I as da,dA as Wn,dB as ct,dC as qn,dD as ua,dE as ha,dF as dt,dG as Bt,bE as _n,dH as pa,O as ma,dI as ga,dJ as fa,dK as ya,dL as ba,dM as Sa,dN as va,dO as Ca,dP as wa,c4 as xa,aZ as ka,dQ as Vn,dR as Ta,dS as Aa,dT as Ea,dU as Ra,dV as Qt,M as Yn,be as Pa,by as Dt,dW as Da}from"./index-
|
|
1
|
+
import{s as f,r as p,aD as yo,cH as bo,aE as So,j as e,aF as vn,cI as Kt,cJ as Tt,cK as vo,cL as Co,cM as wo,cN as xo,c as ut,cO as Cn,cP as Oe,cQ as It,aS as oe,aR as Te,aT as Ce,bj as he,cR as wn,C as k,cS as Zt,ak as Q,al as te,f as r,F,V as ye,cT as xn,cU as $e,cV as ht,cW as ko,cX as To,ae as Ao,cY as Eo,a2 as K,H as Y,ar as ae,bL as kn,av as we,ax as Ot,cZ as Nt,a4 as V,aA as me,bo as y,bR as ie,bT as be,a5 as Ze,a6 as Ro,a7 as Po,a8 as He,ac as X,Z as Ie,c_ as We,c$ as z,A as _,a9 as M,a as j,d0 as Do,T as I,af as Gt,d1 as Tn,a1 as Io,d2 as Uo,d3 as Me,B as Ut,d4 as Bo,aO as Re,d as Z,e as je,l as Se,g as An,S as En,h as pt,i as qe,k as Rn,W as ge,c6 as Ne,m as Fe,d5 as Lo,aU as $t,d6 as jt,bw as Pn,d7 as Oo,d8 as Dn,d9 as In,da as ne,bx as Un,db as No,c8 as Xt,dc as Ft,bF as Bn,ad as Go,dd as $o,de as At,c1 as Ln,cG as jo,cE as Fo,N as ve,c5 as Ge,df as ze,R as xe,b9 as Pe,aY as De,U as Xe,Y as Qe,bS as Ve,bJ as zt,w as zo,dg as Mo,dh as Ho,bK as Wo,di as qo,dj as _o,dk as Vo,aI as mt,dl as Mt,dm as On,ah as Nn,a_ as se,bO as Gn,K as Yo,u as Ht,dn as gt,dp as Jo,L as $n,Q as Wt,aM as ke,dq as Ko,aP as et,dr as Zo,ds as jn,dt as Xo,X as Ye,P as Fn,du as Qo,bd as Et,bf as Rt,dv as ea,dw as ta,dx as na,as as qt,dy as oa,ci as zn,co as Mn,cg as de,bM as Hn,bN as J,x as aa,br as ra,bs as ia,bt as sa,bV as la,dz as ca,bH as Pt,I as da,dA as Wn,dB as ct,dC as qn,dD as ua,dE as ha,dF as dt,dG as Bt,bE as _n,dH as pa,O as ma,dI as ga,dJ as fa,dK as ya,dL as ba,dM as Sa,dN as va,dO as Ca,dP as wa,c4 as xa,aZ as ka,dQ as Vn,dR as Ta,dS as Aa,dT as Ea,dU as Ra,dV as Qt,M as Yn,be as Pa,by as Dt,dW as Da}from"./index-1d165488.js";import{u as Ia,C as Ua,A as Ba,a as La,R as Oa,S as Na,T as Ga,b as $a,c as ja,d as Fa,e as za,E as Ma,f as Ha,m as Wa,g as ft,M as qa,B as _a,h as en}from"./useProjectRole-f048973d.js";import{E as Va}from"./ExpandMore-d71bbced.js";import{a as Ya}from"./index-96dcc77e.js";import{a as Ja}from"./index-17782336.js";const Ka=["component","direction","spacing","divider","children"];function Za(t,n){const o=p.Children.toArray(t).filter(Boolean);return o.reduce((a,i,s)=>(a.push(i),s<o.length-1&&a.push(p.cloneElement(n,{key:`separator-${s}`})),a),[])}const Xa=t=>({row:"Left","row-reverse":"Right",column:"Top","column-reverse":"Bottom"})[t],Qa=({ownerState:t,theme:n})=>{let o=vn({display:"flex",flexDirection:"column"},Kt({theme:n},Tt({values:t.direction,breakpoints:n.breakpoints.values}),a=>({flexDirection:a})));if(t.spacing){const a=vo(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=Tt({values:t.direction,base:i}),d=Tt({values:t.spacing,base:i});typeof s=="object"&&Object.keys(s).forEach((l,c,u)=>{if(!s[l]){const b=c>0?s[u[c-1]]:"column";s[l]=b}}),o=Co(o,Kt({theme:n},d,(l,c)=>({"& > :not(style) + :not(style)":{margin:0,[`margin${Xa(c?s[c]:t.direction)}`]:xo(a,l)}})))}return o=wo(n.breakpoints,o),o},er=f("div",{name:"MuiStack",slot:"Root",overridesResolver:(t,n)=>[n.root]})(Qa),tr=p.forwardRef(function(n,o){const a=yo({props:n,name:"MuiStack"}),i=bo(a),{component:s="div",direction:d="column",spacing:h=0,divider:l,children:c}=i,u=So(i,Ka);return e(er,vn({as:s,ownerState:{direction:d,spacing:h},ref:o},u,{children:l?Za(c,l):c}))}),nr=tr,or=ut(e("path",{d:"M11.8 10.9c-2.27-.59-3-1.2-3-2.15 0-1.09 1.01-1.85 2.7-1.85 1.42 0 2.13.54 2.39 1.4.12.4.45.7.87.7h.3c.66 0 1.13-.65.9-1.27-.42-1.18-1.4-2.16-2.96-2.54V4.5c0-.83-.67-1.5-1.5-1.5S10 3.67 10 4.5v.66c-1.94.42-3.5 1.68-3.5 3.61 0 2.31 1.91 3.46 4.7 4.13 2.5.6 3 1.48 3 2.41 0 .69-.49 1.79-2.7 1.79-1.65 0-2.5-.59-2.83-1.43-.15-.39-.49-.67-.9-.67h-.28c-.67 0-1.14.68-.89 1.3.57 1.39 1.9 2.21 3.4 2.53v.67c0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5v-.65c1.95-.37 3.5-1.5 3.5-3.55 0-2.84-2.43-3.81-4.7-4.4z"}),"AttachMoneyRounded"),ar=ut(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"),rr=ut(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"),ir=ut(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 st(t){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?st=function(o){return typeof o}:st=function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},st(t)}function lt(t,n){if(Cn(2,arguments),!n||st(n)!=="object")return new Date(NaN);var o=n.years?Oe(n.years):0,a=n.months?Oe(n.months):0,i=n.weeks?Oe(n.weeks):0,s=n.days?Oe(n.days):0,d=n.hours?Oe(n.hours):0,h=n.minutes?Oe(n.minutes):0,l=n.seconds?Oe(n.seconds):0,c=It(t),u=a||o?Ja(c,a+o*12):c,m=s||i?Ya(u,s+i*7):u,b=h+d*60,v=l+b*60,g=v*1e3,C=new Date(m.getTime()+g);return C}function tn(t,n){Cn(2,arguments);var o=It(t),a=It(n);return o.getTime()>a.getTime()}const Jn=(t={})=>{const n=oe("api/admin/api-tokens"),{data:o,error:a,mutate:i}=Te(n,sr,t),s=p.useMemo(()=>o??[],[o]),d=p.useCallback(()=>{i().catch(console.warn)},[i]);return{tokens:s,error:a,loading:!a&&!o,refetch:d}},sr=async t=>(await(await fetch(t).then(Ce("Api tokens"))).json()).tokens,lr=()=>{const{hasAccess:t}=p.useContext(he),{tokens:n,loading:o,refetch:a}=Jn(),{deleteToken:i}=wn(),{getTableProps:s,getTableBodyProps:d,headerGroups:h,rows:l,prepareRow:c,state:{globalFilter:u},setGlobalFilter:m,setHiddenColumns:b,columns:v}=Ia(n,g=>r(ht,{children:[e(La,{token:g.row.original,permission:Zt}),e(Oa,{token:g.row.original,permission:ko,onRemove:async()=>{await i(g.row.original.secret),a()}})]}));return e(k,{condition:t(Zt),show:()=>e(Q,{header:e(te,{title:`API access (${l.length})`,actions:r(F,{children:[e(ye,{initialValue:u,onChange:m}),e(te.Divider,{}),e(Ua,{permission:xn,path:"/admin/api/create-token"})]})}),children:e(Ba,{loading:o,headerGroups:h,setHiddenColumns:b,prepareRow:c,getTableBodyProps:d,getTableProps:s,rows:l,columns:v,globalFilter:u})}),elseShow:()=>e($e,{})})},cr=({type:t,projects:n,setProjects:o,errors:a,clearErrors:i})=>{const s=To("projectId"),{projects:d}=Ao(),h=d.map(l=>({value:l.id,label:l.name}));return s?null:r(F,{children:[e(Na,{children:"Which project do you want to give access to?"}),e(Eo,{disabled:t===Ga.ADMIN,options:h,defaultValue:n,onChange:o,error:a==null?void 0:a.projects,onFocus:()=>i("projects")})]})},nn="Create API token",dr=({modal:t=!1})=>{const{setToastApiError:n}=K(),{uiConfig:o}=Y(),a=ae(),[i,s]=p.useState(!1),[d,h]=p.useState(""),{getApiTokenPayload:l,username:c,type:u,projects:m,environment:b,setUsername:v,setTokenType:g,setProjects:C,setEnvironment:w,isValid:S,errors:x,clearErrors:P}=$a(),{createToken:L,loading:T}=wn(),{refetch:R}=Jn();kn(nn);const U="api/admin/api-tokens";return r(we,{loading:T,title:nn,modal:t,description:"Unleash SDKs use API tokens to authenticate to the Unleash API. Client SDKs need a token with 'client privileges', which allows them to fetch feature toggle configurations and post usage metrics.",documentationLink:"https://docs.getunleash.io/reference/api-tokens-and-client-keys",documentationLinkLabel:"API tokens documentation",formatApiCode:()=>`curl --location --request POST '${o.unleashUrl}/${U}' \\
|
|
2
2
|
--header 'Authorization: INSERT_API_KEY' \\
|
|
3
3
|
--header 'Content-Type: application/json' \\
|
|
4
4
|
--data-raw '${JSON.stringify(l(),void 0,2)}'`,children:[r(ja,{handleSubmit:async q=>{if(q.preventDefault(),!!S())try{const E=l();await L(E).then(N=>N.json()).then(N=>{Nt(),h(N.secret),s(!0),R()})}catch(E){n(V(E))}},handleCancel:()=>{a(me)},mode:"Create",actions:e(Ot,{name:"token",permission:xn}),children:[e(Fa,{username:c,setUsername:v,errors:x,clearErrors:P}),e(za,{type:u,setType:g}),e(cr,{type:u,projects:m,setProjects:C,errors:x,clearErrors:P}),e(Ma,{type:u,environment:b,setEnvironment:w})]}),e(Ha,{open:i,closeConfirm:()=>{s(!1),a(me)},token:d,type:u})]})},Kn=({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(p.Fragment,{children:[r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Auto-create users"}),e("p",{children:"Enable automatic creation of new users when signing in."})]}),e(y,{item:!0,md:6,style:{padding:"20px"},children:e(ie,{control:e(be,{onChange:o,name:"enabled",checked:t.autoCreate,disabled:!t.enabled}),label:"Auto-create users"})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{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(y,{item:!0,md:6,children:r(Ze,{style:{minWidth:"200px"},children:[e(Ro,{id:"defaultRootRole-label",children:"Default Role"}),r(Po,{label:"Default Role",labelId:"defaultRootRole-label",id:"defaultRootRole",name:"defaultRootRole",disabled:!t.autoCreate||!t.enabled,value:t.defaultRootRole||"Editor",onChange:a,children:[e(He,{value:"Viewer",children:"Viewer"}),e(He,{value:"Editor",children:"Editor"}),e(He,{value:"Admin",children:"Admin"})]})]})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{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(y,{item:!0,md:6,children:e(X,{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"})})]})]})},ur=async(t,n)=>{if(t){if(n){const o=await n.json();throw t({message:o.message}),new Error(o.message)}throw new Error}},yt=t=>{const{makeRequest:n,createRequest:o,errors:a,loading:i}=Ie({propagateErrors:!0,handleBadRequest:ur});return{updateSettings:async d=>{const h=`api/admin/auth/${t}/settings`,l=o(h,{method:"POST",body:JSON.stringify(d)});try{await n(l.caller,l.id)}catch(c){throw c}},errors:a,loading:i}},_t=t=>{const o=Object.entries(t).filter(([,a])=>a!=="");return Object.fromEntries(o)},Zn=({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(F,{children:[r(y,{container:!0,spacing:3,mb:2,children:[r(y,{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(y,{item:!0,md:6,style:{padding:"20px"},children:e(ie,{control:e(be,{onChange:a,value:n.enableGroupSyncing,name:"enableGroupSyncing",checked:n.enableGroupSyncing,disabled:!n.enabled}),label:n.enableGroupSyncing?"Enabled":"Disabled"})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{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(y,{item:!0,md:6,children:e(X,{onChange:i,label:"Group JSON Path",name:"groupJsonPath",value:n.groupJsonPath,disabled:!n.enableGroupSyncing,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]})]})},hr={enabled:!1,enableSingleSignOut:!1,enableGroupSyncing:!1,autoCreate:!1,unleashHostname:location.hostname,groupJsonPath:"",clientId:"",discoverUrl:"",secret:"",acrValues:""},pr=()=>{const{setToastData:t,setToastApiError:n}=K(),{uiConfig:o}=Y(),[a,i]=p.useState(hr),{hasAccess:s}=p.useContext(he),{config:d}=We("oidc"),{updateSettings:h,errors:l,loading:c}=yt("oidc");if(p.useEffect(()=>{d.discoverUrl&&i(d)},[d]),!s(z))return e(_,{severity:"error",children:"You need to be a root admin to access this section."});const u=C=>{v(C.target.name,C.target.value)},m=()=>{i({...a,enabled:!a.enabled})},b=()=>{i({...a,enableSingleSignOut:!a.enableSingleSignOut})},v=(C,w)=>{i({...a,[C]:w})},g=async C=>{C.preventDefault();try{await h(_t(a)),t({title:"Settings stored",type:"success"})}catch(w){n(V(w))}};return r(Q,{children:[e(y,{container:!0,style:{marginBottom:"1rem"},children:e(y,{item:!0,md:12,children:r(_,{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:g,children:[r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Enable"}),e("p",{children:"Enable Open Id Connect Authentication."})]}),e(y,{item:!0,md:6,style:{padding:"20px"},children:e(ie,{control:e(be,{onChange:m,value:a.enabled,name:"enabled",checked:a.enabled}),label:a.enabled?"Enabled":"Disabled"})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Discover URL"}),e("p",{children:"(Required) Issuer discover metadata URL"})]}),e(y,{item:!0,md:6,children:e(X,{onChange:u,label:"Discover URL",name:"discoverUrl",value:a.discoverUrl,disabled:!a.enabled,style:{width:"400px"},variant:"outlined",size:"small"})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Client ID"}),e("p",{children:"(Required) Client ID of your OpenID application"})]}),e(y,{item:!0,md:6,children:e(X,{onChange:u,label:"Client ID",name:"clientId",value:a.clientId,disabled:!a.enabled,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),r(y,{container:!0,spacing:3,mb:4,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Client secret"}),r("p",{children:["(Required) Client secret of your OpenID application."," "]})]}),e(y,{item:!0,md:6,children:e(X,{onChange:u,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(y,{container:!0,spacing:3,mb:2,children:[r(y,{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(y,{item:!0,md:6,style:{padding:"20px"},children:e(ie,{control:e(be,{onChange:b,value:a.enableSingleSignOut,disabled:!a.enabled,name:"enableSingleSignOut",checked:a.enableSingleSignOut}),label:a.enableSingleSignOut?"Enabled":"Disabled"})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{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(y,{item:!0,md:6,children:e(X,{onChange:u,label:"ACR Values",name:"acrValues",value:a.acrValues,disabled:!a.enabled,style:{width:"400px"},variant:"outlined",size:"small"})})]}),e(Zn,{ssoType:"OIDC",data:a,setValue:v}),e(Kn,{data:a,setValue:v}),e(y,{container:!0,spacing:3,children:r(y,{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})})]})})]})]})},mr={enabled:!1,autoCreate:!1,enableGroupSyncing:!1,unleashHostname:location.hostname,entityId:"",signOnUrl:"",certificate:"",signOutUrl:"",spCertificate:"",groupJsonPath:""},gr=()=>{const{setToastData:t,setToastApiError:n}=K(),{uiConfig:o}=Y(),[a,i]=p.useState(mr),{hasAccess:s}=p.useContext(he),{config:d}=We("saml"),{updateSettings:h,errors:l,loading:c}=yt("saml");if(p.useEffect(()=>{d.entityId&&i(d)},[d]),!s(z))return e(_,{severity:"error",children:"You need to be a root admin to access this section."});const u=g=>{b(g.target.name,g.target.value)},m=()=>{i({...a,enabled:!a.enabled})},b=(g,C)=>{i({...a,[g]:C})},v=async g=>{g.preventDefault();try{await h(_t(a)),t({title:"Settings stored",type:"success"})}catch(C){n(V(C))}};return r(Q,{children:[e(y,{container:!0,style:{marginBottom:"1rem"},children:e(y,{item:!0,md:12,children:r(_,{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:v,children:[r(y,{container:!0,spacing:3,children:[r(y,{item:!0,md:5,mb:2,children:[e("strong",{children:"Enable"}),e("p",{children:"Enable SAML 2.0 Authentication."})]}),e(y,{item:!0,md:6,children:e(ie,{control:e(be,{onChange:m,value:a.enabled,name:"enabled",checked:a.enabled}),label:a.enabled?"Enabled":"Disabled"})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Entity ID"}),e("p",{children:"(Required) The Entity Identity provider issuer."})]}),e(y,{item:!0,md:6,children:e(X,{onChange:u,label:"Entity ID",name:"entityId",value:a.entityId,disabled:!a.enabled,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{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(y,{item:!0,md:6,children:e(X,{onChange:u,label:"Single Sign-On URL",name:"signOnUrl",value:a.signOnUrl,disabled:!a.enabled,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),r(y,{container:!0,spacing:3,mb:4,children:[r(y,{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(y,{item:!0,md:7,children:e(X,{onChange:u,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(y,{container:!0,spacing:3,mb:2,children:[r(y,{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(y,{item:!0,md:6,children:e(X,{onChange:u,label:"Single Sign-out URL",name:"signOutUrl",value:a.signOutUrl,disabled:!a.enabled,style:{width:"400px"},variant:"outlined",size:"small"})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{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(y,{item:!0,md:7,children:e(X,{onChange:u,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(Zn,{ssoType:"SAML",data:a,setValue:b}),e(Kn,{data:a,setValue:b}),e(y,{container:!0,spacing:3,children:r(y,{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})})]})})]})]})},fr=()=>{const{setToastData:t,setToastApiError:n}=K(),{config:o}=We("simple"),[a,i]=p.useState(!1),{updateSettings:s,errors:d,loading:h}=yt("simple"),{hasAccess:l}=p.useContext(he);return p.useEffect(()=>{i(!!o.disabled)},[o.disabled]),l(z)?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(b){n(V(b)),i(o.disabled)}},children:[r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Password based login"}),e("p",{children:"Allow users to login with username & password"})]}),e(y,{item:!0,md:6,style:{padding:"20px"},children:e(ie,{control:e(be,{onChange:()=>{i(!a)},value:!a,name:"disabled",checked:!a}),label:a?"Disabled":"Enabled"})})]}),e(y,{container:!0,spacing:3,children:r(y,{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:d==null?void 0:d.message})})]})})]})}):e(_,{severity:"error",children:"You need to be a root admin to access this section."})},yr={enabled:!1,autoCreate:!1,unleashHostname:location.hostname,clientId:"",clientSecret:"",emailDomains:""},br=()=>{const{setToastData:t,setToastApiError:n}=K(),{uiConfig:o}=Y(),[a,i]=p.useState(yr),{hasAccess:s}=p.useContext(he),{config:d}=We("google"),{updateSettings:h,errors:l,loading:c}=yt("google");if(p.useEffect(()=>{d.clientId&&i(d)},[d]),!s(z))return e("span",{children:"You need admin privileges to access this section."});const u=g=>{i({...a,[g.target.name]:g.target.value})},m=()=>{i({...a,enabled:!a.enabled})},b=()=>{i({...a,autoCreate:!a.autoCreate})},v=async g=>{g.preventDefault();try{await h(_t(a)),t({title:"Settings stored",type:"success"})}catch(C){n(V(C))}};return r(Q,{children:[r(j,{children:[r(_,{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(_,{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:v,children:[r(y,{container:!0,spacing:3,mb:2,children:[r(y,{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(y,{item:!0,xs:6,style:{padding:"20px"},children:e(ie,{control:e(be,{onChange:m,value:a.enabled,name:"enabled",checked:a.enabled}),label:a.enabled?"Enabled":"Disabled"})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{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(y,{item:!0,xs:6,children:e(X,{onChange:u,label:"Client ID",name:"clientId",placeholder:"",value:a.clientId,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Client Secret"}),e("p",{children:"(Required) Client Secret provided by Google when registering the application."})]}),e(y,{item:!0,md:6,children:e(X,{onChange:u,label:"Client Secret",name:"clientSecret",value:a.clientSecret,placeholder:"",style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{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(y,{item:!0,md:6,children:e(X,{onChange:u,label:"Unleash Hostname",name:"unleashHostname",placeholder:"",value:a.unleashHostname||"",style:{width:"400px"},variant:"outlined",size:"small"})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{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(y,{item:!0,md:6,style:{padding:"20px"},children:e(be,{onChange:b,name:"enabled",checked:a.autoCreate})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{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(y,{item:!0,md:6,children:e(X,{onChange:u,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(y,{container:!0,spacing:3,children:r(y,{item:!0,md:5,children:[e(M,{variant:"contained",color:"primary",type:"submit",disabled:c,children:"Save"})," ",e("p",{children:e("small",{style:{color:"error.dark"},children:l==null?void 0:l.message})})]})})]})]})},Sr=()=>{const{authenticationType:t}=Y().uiConfig;return e("div",{children:r(Q,{header:"Single Sign-On",children:[e(k,{condition:t==="enterprise",show:e(Do,{tabData:[{label:"OpenID Connect",component:e(pr,{})},{label:"SAML 2.0",component:e(gr,{})},{label:"Password",component:e(fr,{})},{label:"Google",component:e(br,{})}]})}),e(k,{condition:t==="open-source",show:e(_,{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(k,{condition:t==="demo",show:e(_,{severity:"warning",children:"You are running Unleash in demo mode. You have to use the Enterprise edition in order configure Single Sign-on."})}),e(k,{condition:t==="custom",show:e(_,{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(k,{condition:t==="hosted",show:e(_,{severity:"info",children:"Your Unleash instance is managed by the Unleash team."})})]})})},vr=oe("api/admin/invoices"),Cr=f(M)(({theme:t})=>({width:"100%",marginBottom:t.spacing(1.5)})),wr=({update:t})=>e(Cr,{href:`${vr}/${t?"portal":"checkout"}`,variant:t?"outlined":"contained",children:t?"Update billing information":"Add billing information"}),xr=f("aside")(({theme:t})=>({padding:t.spacing(4),height:"100%",borderRadius:t.shape.borderRadiusLarge,backgroundColor:t.palette.background.elevation2})),kr=f(I)(({theme:t})=>({marginBottom:t.spacing(4)})),Tr=f(_)(({theme:t})=>({marginBottom:t.spacing(4)})),on=f(I)(({theme:t})=>({fontSize:t.fontSizes.smallBody,color:t.palette.text.secondary})),Ar=f(Gt)(({theme:t})=>({margin:`${t.spacing(2.5)} 0`,borderColor:t.palette.divider})),Er=({instanceStatus:t})=>{const n=t.state!==Tn.ACTIVE;return e(y,{item:!0,xs:12,md:5,children:r(xr,{children:[e(kr,{variant:"body1",children:"Billing information"}),e(k,{condition:n,show:r(Tr,{severity:"warning",children:["In order to ",e("strong",{children:"Upgrade trial"})," you need to provide us your billing information."]})}),e(wr,{update:!n}),e(on,{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(Ar,{}),r(on,{children:[e("a",{href:"mailto:elise@getunleash.ai?subject=PRO plan clarifications",children:"Get in touch with us"})," ","for any clarification"]})]})})},Ue=()=>{const{data:t,error:n,mutate:o}=Te(oe("api/admin/user-admin"),Rr);return p.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])},Rr=t=>fetch(t).then(Ce("Users")).then(n=>n.json()),Pr=f(y)(({theme:t})=>({flexWrap:"nowrap",gap:t.spacing(1)})),nt=({sx:t,children:n})=>e(Pr,{container:!0,item:!0,justifyContent:"space-between",alignItems:"center",sx:t,children:n}),Ee=({children:t,vertical:n=!1})=>e(y,{container:n,item:!0,display:"flex",alignItems:n?"start":"center",direction:n?"column":void 0,children:t}),Dr=f("span")(({theme:t})=>({fontSize:t.fontSizes.smallBody,marginLeft:t.spacing(1)})),an=({children:t})=>r(Dr,{children:["(",t,")"]}),Ir=f("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)}})),rn=f(I)(({theme:t})=>({fontSize:t.fontSizes.smallBody,color:t.palette.text.secondary})),Ur=f("span")(({theme:t})=>({fontSize:"3.25rem",lineHeight:1,color:t.palette.primary.main,fontWeight:800})),Br=f("span")(({theme:t})=>({marginLeft:t.spacing(1.5),fontWeight:t.fontWeight.bold})),Lr=f("span")(({theme:t})=>({color:t.palette.primary.main,fontSize:t.fontSizes.mainHeader,fontWeight:t.fontWeight.bold})),Or=f(_)(({theme:t})=>({fontSize:t.fontSizes.smallerBody,marginBottom:t.spacing(3),marginTop:t.spacing(-1.5),[t.breakpoints.up("md")]:{marginTop:t.spacing(-4.5)}})),Nr=f(Io)(({theme:t})=>({fontSize:"1rem",marginRight:t.spacing(1)})),Gr=f(Gt)(({theme:t})=>({margin:`${t.spacing(3)} 0`})),$r=({instanceStatus:t})=>{var v;const{users:n}=Ue(),o=Uo(t),{uiConfig:a}=Y(),i=n.filter(g=>g.email),s={[Me.PRO]:80,[Me.COMPANY]:0,[Me.TEAM]:0,[Me.UNKNOWN]:0,user:15},d=s[t.plan],h=t.seats??5,l=Math.min(i.length,h),c=i.length-l,u=s.user*c,m=d+u,b=t.state!==Tn.ACTIVE;return e(y,{item:!0,xs:12,md:7,children:r(Ir,{children:[e(k,{condition:b,show:r(Or,{severity:"info",children:["After you have sent your billing information, your instance will be upgraded - you don't have to do anything."," ",e("a",{href:"mailto:elise@getunleash.ai?subject=PRO plan clarifications",children:"Get in touch with us"})," ","for any clarification"]})}),e(Ut,{color:"success",children:"Current plan"}),e(y,{container:!0,children:r(nt,{sx:g=>({marginBottom:g.spacing(3)}),children:[r(Ee,{children:[e(Ur,{children:t.plan}),e(k,{condition:Bo(t),show:e(Br,{sx:g=>({color:o?g.palette.error.dark:g.palette.warning.dark}),children:o?"Trial expired":t.trialExtended?"Extended Trial":"Trial"})})]}),e(Ee,{children:e(k,{condition:d>0,show:r(Lr,{children:["$",d.toFixed(2)]})})})]})}),e(k,{condition:Boolean(((v=a==null?void 0:a.flags)==null?void 0:v.proPlanAutoCharge)&&t.plan===Me.PRO),show:r(F,{children:[r(y,{container:!0,children:[r(nt,{sx:g=>({marginBottom:g.spacing(1.5)}),children:[r(Ee,{vertical:!0,children:[r(I,{children:[e("strong",{children:"Included members"}),e(an,{children:r(Re,{to:"/admin/users",children:[l," of 5 assigned"]})})]}),e(rn,{children:"You have 5 team members included in your PRO plan"})]}),r(Ee,{children:[e(Nr,{}),e(I,{variant:"body2",children:"included"})]})]}),r(nt,{children:[r(Ee,{vertical:!0,children:[r(I,{children:[e("strong",{children:"Paid members"}),e(an,{children:r(Re,{to:"/admin/users",children:[c," assigned"]})})]}),e(rn,{children:"$15/month per paid member"})]}),e(Ee,{children:r(I,{sx:g=>({fontSize:g.fontSizes.mainHeader}),children:["$",u.toFixed(2)]})})]})]}),e(Gr,{}),e(y,{container:!0,children:r(nt,{children:[e(Ee,{children:e(I,{sx:g=>({fontWeight:g.fontWeight.bold,fontSize:g.fontSizes.mainHeader}),children:"Total per month"})}),e(Ee,{children:r(I,{sx:g=>({fontWeight:g.fontWeight.bold,fontSize:"2rem"}),children:["$",m.toFixed(2)]})})]})})]})})]})})},jr=({instanceStatus:t})=>r(y,{container:!0,spacing:4,children:[e(Er,{instanceStatus:t}),e($r,{instanceStatus:t})]}),Fr=f(I)(({theme:t})=>({marginTop:t.spacing(6),marginBottom:t.spacing(2.5),fontSize:t.fontSizes.mainHeader})),zr=[{Header:"Amount",accessor:"amountFormatted"},{Header:"Status",accessor:"status",disableGlobalFilter:!0},{Header:"Created date",accessor:"created",Cell:Ne,sortType:"date",disableGlobalFilter:!0},{Header:"Due date",accessor:"dueDate",Cell:Ne,sortType:"date",disableGlobalFilter:!0},{Header:"Download",accessor:"invoicePDF",align:"center",Cell:({value:t})=>e(j,{sx:{display:"flex",justifyContent:"center"},"data-loading":!0,children:e(Fe,{href:t,children:e(Lo,{})})}),width:100,disableGlobalFilter:!0,disableSortBy:!0}],Mr=({data:t,isLoading:n=!1})=>{const o=p.useMemo(()=>({sortBy:[{id:"created"}]}),[]),{getTableProps:a,getTableBodyProps:i,headerGroups:s,rows:d,prepareRow:h}=Z.useTable({columns:zr,data:t,initialState:o,sortTypes:je,autoResetGlobalFilter:!1,disableSortRemove:!0,defaultColumn:{Cell:Se}},Z.useGlobalFilter,Z.useSortBy);return r(Q,{isLoading:n,disablePadding:!0,children:[e(Fr,{children:"Payment history"}),r(An,{...a(),children:[e(En,{headerGroups:s}),e(pt,{...i(),children:d.map(l=>(h(l),e(qe,{hover:!0,...l.getRowProps(),children:l.cells.map(c=>e(Rn,{...c.getCellProps(),children:c.render("Cell")}))})))})]}),e(k,{condition:d.length===0,show:e(ge,{children:"No invoices to show."})})]})},Lt="api/admin/invoices",Hr=oe(Lt),Xn=(t={})=>{const n=()=>fetch(Hr,{method:"GET"}).then(Ce("Invoices")).then(h=>h.json()),{data:o,error:a}=Te(Lt,n,t),[i,s]=p.useState(!a&&!o),d=()=>{$t(Lt)};return p.useEffect(()=>{s(!a&&!o)},[o,a]),{invoices:(o==null?void 0:o.invoices)||[],error:a,loading:i,refetchInvoices:d}},Wr=()=>{const{instanceStatus:t,isBilling:n,refetchInstanceStatus:o,refresh:a,loading:i}=jt(),{invoices:s}=Xn(),{hasAccess:d}=p.useContext(he);return p.useEffect(()=>{(async()=>{await a(),o()})()},[o,a]),e("div",{children:e(Q,{header:"Billing",isLoading:i,children:e(k,{condition:n,show:e(k,{condition:d(z),show:()=>r(F,{children:[e(jr,{instanceStatus:t}),e(Mr,{data:s})]}),elseShow:()=>e($e,{})}),elseShow:e(_,{severity:"error",children:"Billing is not enabled for this instance."})})})})},qr=oe("api/admin/invoices/portal"),_r=()=>{const{refetchInvoices:t,invoices:n}=Xn(),[o,a]=p.useState(!1),{locationSettings:i}=Pn();return p.useEffect(()=>{t(),a(!0)},[]),e(k,{condition:n.length>0,show:e(Q,{header:e(te,{title:"Invoices",actions:e(M,{href:qr,rel:"noreferrer",target:"_blank",endIcon:e(Oo,{}),children:"Billing portal"})}),children:e("div",{children:r(Dn,{children:[e(In,{children:r(qe,{children:[e(ne,{children:"Amount"}),e(ne,{children:"Status"}),e(ne,{children:"Due date"}),e(ne,{children:"PDF"}),e(ne,{children:"Link"})]})}),e(pt,{children:n.map(s=>r(qe,{style:{backgroundColor:s.status==="past-due"?"error.dark":"inherit"},children:[e(ne,{style:{textAlign:"left"},children:s.amountFormatted}),e(ne,{style:{textAlign:"left"},children:s.status}),e(ne,{style:{textAlign:"left"},children:s.dueDate&&Un(s.dueDate,i.locale)}),e(ne,{style:{textAlign:"left"},children:e("a",{href:s.invoicePDF,children:"PDF"})}),e(ne,{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."})})},Vr=()=>{const{hasAccess:t}=p.useContext(he);return e("div",{children:e(k,{condition:t(z),show:e(_r,{}),elseShow:e(_,{severity:"error",children:"You need to be instance admin to access this section."})})})},Yr=()=>{const{uiConfig:t,loading:n}=Y();return n?null:t.flags.UNLEASH_CLOUD?e(No,{to:"/admin/billing",replace:!0}):e(Vr,{})},Jr=()=>r(_,{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)."})]}),Kr=()=>{const{makeRequest:t,createRequest:n,errors:o,loading:a}=Ie({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}},Zr=({frontendApiOrigins:t})=>{const{setFrontendSettings:n}=Kr(),{setToastData:o,setToastApiError:a}=K(),[i,s]=p.useState(sn(t)),d=Xt(),h=Xt();return e("form",{onSubmit:async c=>{try{const u=Xr(i);c.preventDefault(),await n(u),s(sn(u)),o({title:"Settings saved",type:"success"})}catch(u){a(V(u))}},children:r(j,{sx:{display:"grid",gap:1},children:[r("label",{htmlFor:d,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(X,{id:d,"aria-describedby":h,placeholder:Qr,value:i,onChange:c=>s(c.target.value),multiline:!0,rows:12,variant:"outlined",fullWidth:!0,InputProps:{style:{fontFamily:"monospace",fontSize:"0.8em"}}}),e(Ft,{permission:z})]})})},Xr=t=>t.split(/[,\n\s]+/).map(n=>n.replace(/\/$/,"")).filter(Boolean),sn=t=>(t==null?void 0:t.join(`
|
|
@@ -12,7 +12,7 @@ import{s as f,r as p,aD as yo,cH as bo,aE as So,j as e,aF as vn,cI as Kt,cJ as T
|
|
|
12
12
|
--data-raw '${JSON.stringify(w(),void 0,2)}'`,H=()=>{h(me)},B=E=>E.length,D=E=>!(L!=null&&L.filter(N=>N.name===E&&N.id!==n).length),O=B(l)&&D(l);return e(we,{loading:R,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:A,children:e(to,{name:l,description:u,mappingsSSO:b,users:g,setName:E=>{S(),D(E)||P({name:"A group with that name already exists."}),c(E)},setDescription:m,setMappingsSSO:v,setUsers:C,errors:x,handleSubmit:U,handleCancel:H,mode:Mt,children:e(M,{type:"submit",variant:"contained",color:"primary",disabled:!O,"data-testid":On,children:"Save"})})})},Ci=f(Nn)(({theme:t})=>({borderRadius:t.shape.borderRadiusLarge,padding:t.spacing(2.5,4),boxShadow:"none",marginBottom:t.spacing(2),fontSize:t.fontSizes.smallBody})),wi=f("div")(({theme:t})=>({display:"flex",alignItems:"center",justifyContent:"space-between"})),xi=f("h1")(({theme:t})=>({fontSize:t.fontSizes.mainHeader})),ki=f("div")(({theme:t})=>({display:"flex"})),Ti=f("span")(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginLeft:t.spacing(1)})),Ai=({title:t,description:n,actions:o})=>(kn(t),r(Ci,{children:[r(wi,{children:[e(xi,{children:t}),e(ki,{children:o})]}),e(k,{condition:Boolean(n==null?void 0:n.length),show:r(F,{children:["Description:",e(Ti,{children:n})]})})]})),no=({open:t,setOpen:n,group:o})=>{const{refetchGroups:a}=_e(),{removeGroup:i}=tt(),{setToastData:s,setToastApiError:d}=K(),h=ae();return e(se,{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){d(V(c))}},onClose:()=>{n(!1)},title:"Delete group?",children:r(I,{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."]})})},Ei=f("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),Ri=f("p")(({theme:t})=>({color:t.palette.text.secondary,marginBottom:t.spacing(1)})),Pi=f("div")(()=>({marginTop:"auto",display:"flex",justifyContent:"flex-end"})),Di=f(M)(({theme:t})=>({marginLeft:t.spacing(3)})),Ii=f(j)(({theme:t})=>({marginTop:t.spacing(2)})),oo=({open:t,setOpen:n,group:o})=>{const{refetchGroup:a}=ft(o.id),{refetchGroups:i}=_e(),{updateGroup:s,loading:d}=tt(),{setToastData:h,setToastApiError:l}=K(),{uiConfig:c}=Y(),{users:u,setUsers:m,getGroupPayload:b}=Vt(o.name,o.description,o.mappingsSSO,o.users);return p.useEffect(()=>{m(o.users)},[o.users,t,m]),e(Gn,{open:t,onClose:()=>{n(!1)},label:"Edit users",children:e(we,{loading:d,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(b(),void 0,2)}'`,children:r(Ei,{onSubmit:async C=>{C.preventDefault();try{await s(o.id,b()),a(),i(),n(!1),h({title:"Group users saved successfully",type:"success"})}catch(w){l(V(w))}},children:[r("div",{children:[e(Ri,{children:"Edit users in this group"}),e(Qn,{users:u,setUsers:m}),e(eo,{users:u,setUsers:m})]}),e(Pi,{children:r(Ii,{children:[e(M,{type:"submit",variant:"contained",color:"primary","data-testid":On,children:"Save"}),e(Di,{onClick:()=>{n(!1)},children:"Cancel"})]})})]})})})},Ui=({open:t,setOpen:n,user:o,group:a})=>{const{refetchGroup:i}=ft(a.id),{updateGroup:s}=tt(),{setToastData:d,setToastApiError:h}=K(),l=async()=>{try{const u={...a,users:a.users.filter(({id:m})=>m!==(o==null?void 0:o.id)).map(({id:m})=>({user:{id:m}}))};await s(a.id,u),i(),n(!1),d({title:"User removed from group successfully",type:"success"})}catch(u){h(V(u))}},c=(o==null?void 0:o.name)||(o==null?void 0:o.username)||(o==null?void 0:o.email);return e(se,{open:t&&Boolean(o),primaryButtonText:"Remove user",secondaryButtonText:"Cancel",onClick:l,onClose:()=>{n(!1)},title:"Remove user from group?",children:r(I,{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."]})})},Bi=Array(15).fill({name:"Name of the user",username:"Username of the user"}),Li={id:"joinedAt"},{value:cn,setValue:Oi}=Yo("Group:v1",Li),Ni=()=>{const t=Number(mt("groupId")),n=Ht(),o=ve(n.breakpoints.down("md")),{group:a,loading:i}=ft(t),[s,d]=p.useState(!1),[h,l]=p.useState(!1),[c,u]=p.useState(!1),[m,b]=p.useState(),v=p.useMemo(()=>[{Header:"Avatar",accessor:"imageUrl",Cell:({row:{original:D}})=>e(Se,{children:e(ze,{user:D})}),maxWidth:85,disableSortBy:!0},{id:"name",Header:"Name",accessor:D=>D.name||"",Cell:xe,minWidth:100,searchable:!0},{id:"username",Header:"Username",accessor:D=>D.username||D.email,Cell:xe,minWidth:100,searchable:!0},{Header:"Joined",accessor:"joinedAt",Cell:Ne,sortType:"date",maxWidth:150},{id:"createdBy",Header:"Added by",accessor:"createdBy",Cell:xe,minWidth:90,searchable:!0},{Header:"Last login",accessor:D=>D.seenAt||"",Cell:({row:{original:D}})=>e(gt,{value:D.seenAt,emptyText:"Never",title:O=>`Last login: ${O}`}),sortType:"date",maxWidth:150},{Header:"Actions",id:"Actions",align:"center",Cell:({row:{original:D}})=>e(ht,{children:e(Pe,{title:"Remove user from group",arrow:!0,describeChild:!0,children:e("span",{children:e(Fe,{"data-testid":`${Jo}-${D.id}`,onClick:()=>{b(D),u(!0)},children:e(De,{})})})})}),maxWidth:100,disableSortBy:!0}],[b,u]),[g,C]=$n(),[w]=p.useState(()=>({sortBy:[{id:g.get("sort")||cn.id,desc:g.has("order")?g.get("order")==="desc":cn.desc}],hiddenColumns:["description"],globalFilter:g.get("search")||""})),[S,x]=p.useState(w.globalFilter),{data:P,getSearchText:L,getSearchContext:T}=Wt(v,S,(a==null?void 0:a.users)??[]),R=p.useMemo(()=>(P==null?void 0:P.length)===0&&i?Bi:P,[P,i]),{headerGroups:U,rows:A,prepareRow:H,state:{sortBy:B}}=Z.useTable({columns:v,data:R,initialState:w,sortTypes:je,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},Z.useSortBy,Z.useFlexLayout);return p.useEffect(()=>{const D={};D.sort=B[0].id,B[0].desc&&(D.order="desc"),S&&(D.search=S),C(D,{replace:!0}),Oi({id:B[0].id,desc:B[0].desc||!1})},[B,S,C]),e(k,{condition:Boolean(a),show:r(F,{children:[e(Ai,{title:a==null?void 0:a.name,description:a==null?void 0:a.description,actions:r(F,{children:[e(ke,{"data-testid":Ko,to:`/admin/groups/${t}/edit`,component:Re,"data-loading":!0,permission:z,tooltipProps:{title:"Edit group"},children:e(et,{})}),e(ke,{"data-testid":Zo,"data-loading":!0,onClick:()=>d(!0),permission:z,tooltipProps:{title:"Delete group"},children:e(De,{})})]})}),r(Q,{isLoading:i,header:e(te,{secondary:!0,title:`Users (${A.length<R.length?`${A.length} of ${R.length}`:R.length})`,actions:r(F,{children:[e(k,{condition:!o,show:r(F,{children:[e(ye,{initialValue:S,onChange:x,hasFilters:!0,getSearchContext:T}),e(te.Divider,{})]})}),e(jn,{"data-testid":Xo,onClick:()=>{l(!0)},maxWidth:"700px",Icon:zt,permission:z,children:"Edit users"})]}),children:e(k,{condition:o,show:e(ye,{initialValue:S,onChange:x,hasFilters:!0,getSearchContext:T})})}),children:[e(Ye,{value:L(S),children:e(Qe,{rows:A,headerGroups:U,prepareRow:H})}),e(k,{condition:A.length===0,show:e(k,{condition:(S==null?void 0:S.length)>0,show:r(ge,{children:["No users found matching “",S,"” in this group."]}),elseShow:e(ge,{children:"This group is empty. Get started by adding a user to the group."})})}),e(no,{open:s,setOpen:d,group:a}),e(oo,{open:h,setOpen:l,group:a}),e(Ui,{open:c,setOpen:u,user:m,group:a})]})]})})},Gi=f(Fn)(({theme:t})=>({pointerEvents:"none",".MuiPaper-root":{padding:t.spacing(2)}})),$i=f("div")(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(1)})),ji=({user:t,open:n,anchorEl:o,onPopoverClose:a})=>r(Gi,{open:n,anchorEl:o,onClose:a,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},children:[e($i,{children:(t==null?void 0:t.name)||(t==null?void 0:t.username)}),e("div",{children:t==null?void 0:t.email})]}),Fi=f("div")(({theme:t})=>({display:"inline-flex",alignItems:"center",flexWrap:"wrap",marginLeft:t.spacing(1)})),dn=f(ze)(({theme:t})=>({outline:`${t.spacing(.25)} solid ${t.palette.background.paper}`,marginLeft:t.spacing(-1),"&:hover":{outlineColor:t.palette.primary.main}})),zi=({users:t})=>{const n=p.useMemo(()=>t.sort((c,u)=>(u==null?void 0:u.joinedAt.getTime())-(c==null?void 0:c.joinedAt.getTime())).slice(0,9),[t]),[o,a]=p.useState(null),[i,s]=p.useState(),d=c=>{a(c.currentTarget)},h=()=>{a(null)},l=Boolean(o);return r(Fi,{children:[n.map(c=>e(dn,{user:c,onMouseEnter:u=>{d(u),s(c)},onMouseLeave:h},c.id)),e(k,{condition:t.length>9,show:r(dn,{children:["+",t.length-n.length]})}),e(ji,{open:l,user:i,anchorEl:o,onPopoverClose:h})]})},Mi=f("div")(({theme:t})=>({display:"flex",justifyContent:"center",transform:"translate3d(8px, -6px, 0)"})),Hi=f(Fn)(({theme:t})=>({borderRadius:t.shape.borderRadiusLarge,padding:t.spacing(1,1.5)})),Wi=({groupId:t,onEditUsers:n,onRemove:o})=>{const[a,i]=p.useState(null),s=Boolean(a),d=u=>{i(u.currentTarget)},h=()=>{i(null)},l=`feature-${t}-actions`,c=`${l}-menu`;return r(Mi,{onClick:u=>{u.preventDefault(),u.stopPropagation()},children:[e(Pe,{title:"Group actions",arrow:!0,describeChild:!0,children:e(Fe,{id:l,"aria-controls":s?c:void 0,"aria-haspopup":"true","aria-expanded":s?"true":void 0,onClick:d,type:"button",children:e(qa,{})})}),e(Hi,{id:c,anchorEl:a,open:s,onClose:h,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,children:r(Qo,{"aria-labelledby":l,children:[r(He,{onClick:h,component:Re,to:`/admin/groups/${t}/edit`,children:[e(Et,{children:e(et,{})}),e(Rt,{children:e(I,{variant:"body2",children:"Edit group"})})]}),r(He,{onClick:()=>{n(),h()},children:[e(Et,{children:e(ar,{})}),e(Rt,{children:e(I,{variant:"body2",children:"Edit group users"})})]}),r(He,{onClick:()=>{o(),h()},children:[e(Et,{children:e(De,{})}),e(Rt,{children:e(I,{variant:"body2",children:"Delete group"})})]})]})})]})},qi=f(Re)(({theme:t})=>({textDecoration:"none",color:t.palette.text.primary})),_i=f("aside")(({theme:t})=>({padding:t.spacing(2.5),height:"100%",border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadiusLarge,boxShadow:t.boxShadows.card,display:"flex",flexDirection:"column",[t.breakpoints.up("md")]:{padding:t.spacing(4)},"&:hover":{transition:"background-color 0.2s ease-in-out",backgroundColor:t.palette.neutral.light}})),ao=f("div")(()=>({display:"flex",alignItems:"center",justifyContent:"space-between"})),Vi=f(ao)(()=>({alignItems:"flex-start"})),Yi=f(ao)(()=>({marginTop:"auto"})),Ji=f("h2")(({theme:t})=>({fontSize:t.fontSizes.mainHeader,fontWeight:t.fontWeight.medium})),Ki=f("div")(({theme:t})=>({display:"flex",alignItems:"center",color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody})),Zi=f("p")(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(1),marginBottom:t.spacing(4)})),Xi=f("span")(({theme:t})=>({color:t.palette.text.secondary,marginLeft:t.spacing(1)})),Qi=f("div")(({theme:t})=>({maxWidth:"50%",display:"flex",justifyContent:"flex-end",gap:t.spacing(.5),flexWrap:"wrap"})),es=({group:t,onEditUsers:n,onRemoveGroup:o})=>{var i;const a=ae();return e(F,{children:e(qi,{to:`/admin/groups/${t.id}`,children:r(_i,{children:[r(Vi,{children:[e(Ji,{children:t.name}),e(Ki,{children:e(Wi,{groupId:t.id,onEditUsers:()=>n(t),onRemove:()=>o(t)})})]}),e(Zi,{children:t.description}),r(Yi,{children:[e(k,{condition:((i=t.users)==null?void 0:i.length)>0,show:e(zi,{users:t.users}),elseShow:e(Xi,{children:"This group has no users."})}),e(Qi,{children:e(k,{condition:t.projects.length>0,show:t.projects.map(s=>e(Pe,{title:"View project",arrow:!0,placement:"bottom-end",describeChild:!0,children:e(Ut,{onClick:d=>{d.preventDefault(),a(`/projects/${s}/settings/access`)},color:"secondary",icon:e(ea,{}),children:s})},s)),elseShow:e(Pe,{title:"This group is not used in any project",arrow:!0,describeChild:!0,children:e(Ut,{children:"Not used"})})})})]})]})},t.id)})},ts=()=>{const t=f("div")(({theme:o})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:o.spacing(6),marginLeft:"auto",marginRight:"auto"})),n=f(I)(({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:Re,variant:"outlined",color:"primary",children:"Create your first group"})]})},ns=(t,n)=>{var i,s,d,h,l,c;const o=n.toLowerCase(),a={names:(i=t.users)==null?void 0:i.map(u=>{var m;return((m=u.name)==null?void 0:m.toLowerCase())||""}),usernames:(s=t.users)==null?void 0:s.map(u=>{var m;return((m=u.username)==null?void 0:m.toLowerCase())||""}),emails:(d=t.users)==null?void 0:d.map(u=>{var m;return((m=u.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(u=>u.includes(o)))||((l=a.usernames)==null?void 0:l.some(u=>u.includes(o)))||((c=a.emails)==null?void 0:c.some(u=>u.includes(o)))},os=()=>{const t=ae(),[n,o]=p.useState(!1),[a,i]=p.useState(!1),[s,d]=p.useState(void 0),{groups:h=[],loading:l}=_e(),[c,u]=$n(),[m,b]=p.useState(c.get("search")||""),v=ve(Ge.breakpoints.down("md"));p.useEffect(()=>{const S={};m&&(S.search=m),u(S,{replace:!0})},[m,u]);const g=p.useMemo(()=>{const S=h.sort((x,P)=>x.name.localeCompare(P.name));return m?S.filter(x=>ns(x,m)):S},[h,m]),C=S=>{d(S),o(!0)},w=S=>{d(S),i(!0)};return r(Q,{isLoading:l,header:e(te,{title:`Groups (${g.length})`,actions:r(F,{children:[e(k,{condition:!v,show:r(F,{children:[e(ye,{initialValue:m,onChange:b}),e(te.Divider,{})]})}),e(jn,{onClick:()=>t("/admin/groups/create-group"),maxWidth:"700px",Icon:zt,permission:z,"data-testid":ta,children:"New group"})]}),children:e(k,{condition:v,show:e(ye,{initialValue:m,onChange:b})})}),children:[e(Ye,{value:m,children:e(y,{container:!0,spacing:2,children:g.map(S=>e(y,{item:!0,xs:12,md:6,children:e(es,{group:S,onEditUsers:C,onRemoveGroup:w})},S.id))})}),e(k,{condition:!l&&g.length===0,show:e(k,{condition:(m==null?void 0:m.length)>0,show:r(ge,{children:["No groups found matching “",m,"”"]}),elseShow:e(ts,{})})}),e(k,{condition:Boolean(s),show:e(oo,{open:n,setOpen:o,group:s})}),e(k,{condition:Boolean(s),show:e(no,{open:a,setOpen:i,group:s})})]})},as=()=>e("div",{children:e(os,{})}),rs=()=>{const{data:t,error:n,mutate:o}=Te(oe("api/admin/instance-admin/statistics"),is);return p.useMemo(()=>({stats:t,loading:!n&&!t,refetchGroup:()=>o(),error:n}),[t,n,o])},is=t=>fetch(t).then(Ce("Instance Stats")).then(n=>n.json()),ss=()=>{const{stats:t}=rs();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},{title:"Feature exports",value:t==null?void 0:t.featureExports},{title:"Feature imports",value:t==null?void 0:t.featureImports}];return t!=null&&t.versionEnterprise&&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(te,{title:"Instance Statistics"}),children:r(_a,{sx:{display:"grid",gap:4},children:[r(Dn,{"aria-label":"Instance statistics",children:[e(In,{children:r(qe,{children:[e(ne,{children:"Field"}),e(ne,{align:"right",children:"Value"})]})}),e(pt,{children:a.map(i=>r(qe,{children:[e(ne,{component:"th",scope:"row",children:i.title}),e(ne,{align:"right",children:i.value})]},i.title))})]}),e("span",{style:{textAlign:"center"},children:e(M,{startIcon:e(na,{}),"aria-label":"Download instance statistics",color:"primary",variant:"contained",target:"_blank",href:oe("/api/admin/instance-admin/statistics/csv"),children:"Download"})})]})})},ls=()=>e("div",{children:e(ss,{})}),cs=()=>e(_,{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."]})}),ds=()=>{const{data:t,error:n,mutate:o}=Te(oe("api/admin/maintenance"),us);return p.useMemo(()=>({enabled:Boolean(t==null?void 0:t.enabled),loading:!n&&!t,refetchMaintenance:o,error:n}),[t,n,o])},us=t=>fetch(t).then(Ce("Maintenance")).then(n=>n.json()),hs=()=>{const{makeRequest:t,createRequest:n,errors:o,loading:a}=Ie({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}},ps=f("div")(({theme:t})=>({display:"flex",flexDirection:"column",padding:t.spacing(3),border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadiusLarge})),ms=f(j)(({theme:t})=>({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"})),gs=f(j)(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(2)})),fs=f(I)(({theme:t})=>({fontSize:t.fontSizes.smallBody})),ys=()=>{const{enabled:t,refetchMaintenance:n}=ds(),{toggleMaintenance:o}=hs(),{trackEvent:a}=qt(),{setToastData:i}=K();return r(ps,{children:[r(ms,{children:[e("b",{children:"Maintenance Mode"}),e(ie,{sx:{margin:0},control:e(be,{onChange:async()=>{i({type:"success",title:`Maintenance mode has been successfully ${t?"disabled":"enabled"}`}),a("maintenance",{props:{eventType:`maintenance ${t?"de":""}activated`}}),await o({enabled:!t}),n()},value:t,name:"enabled",checked:t}),label:e(fs,{children:t?"Enabled":"Disabled"})})]}),e(gs,{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."})]})},bs=()=>{const{hasAccess:t}=p.useContext(he);return e("div",{children:e(k,{condition:t(z),show:e(vs,{}),elseShow:e($e,{})})})},Ss=f(j)(({theme:t})=>({display:"grid",gap:t.spacing(4)})),vs=()=>{const{loading:t}=Y();return t?null:e(Q,{header:e(te,{title:"Maintenance"}),children:r(Ss,{children:[e(cs,{}),e(ys,{})]})})},Cs=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},ue=({to:t,children:n})=>{const o=Ht();return e(oa,{to:t,style:({isActive:a})=>Cs({isActive:a,theme:o}),children:n})},ws=f(Nn)(({theme:t})=>({marginBottom:"1rem",borderRadius:"12.5px",boxShadow:"none",padding:"0 2rem"}));function xs(){const{uiConfig:t,isEnterprise:n}=Y(),{pathname:o}=zn(),{isBilling:a}=jt(),{flags:i,networkViewEnabled:s}=t,d=o.split("/")[2];return e(ws,{children:r(Mn,{value:d,variant:"scrollable",scrollButtons:"auto",allowScrollButtonsMobile:!0,children:[e(de,{value:"users",label:e(ue,{to:"/admin/users",children:e("span",{children:"Users"})})}),n()&&e(de,{value:"service-accounts",label:e(ue,{to:"/admin/service-accounts",children:e("span",{children:"Service accounts"})})}),i.UG&&e(de,{value:"groups",label:e(ue,{to:"/admin/groups",children:e("span",{children:"Groups"})})}),i.RE&&e(de,{value:"roles",label:e(ue,{to:"/admin/roles",children:e("span",{children:"Project roles"})})}),e(de,{value:"api",label:e(ue,{to:"/admin/api",children:"API access"})}),t.flags.embedProxyFrontend&&e(de,{value:"cors",label:e(ue,{to:"/admin/cors",children:"CORS origins"})}),e(de,{value:"auth",label:e(ue,{to:"/admin/auth",children:"Single sign-on"})}),e(de,{value:"instance",label:e(ue,{to:"/admin/instance",children:"Instance stats"})}),s&&e(de,{value:"network",label:e(ue,{to:"/admin/network",children:"Network"})}),e(de,{value:"maintenance",label:e(ue,{to:"/admin/maintenance",children:"Maintenance"})}),a&&e(de,{value:"billing",label:e(ue,{to:"/admin/billing",children:"Billing"})})]})})}const ks=p.lazy(()=>import("./NetworkOverview-8b64cc40.js")),Ts=p.lazy(()=>import("./NetworkTraffic-38cef6f4.js")),As=f(Q)(()=>({".page-header":{padding:0}})),Es=[{label:"Overview",path:"/admin/network"},{label:"Traffic",path:"/admin/network/traffic"}],Rs=()=>{const{pathname:t}=zn();return e("div",{children:e(As,{headerClass:"page-header",header:e(Mn,{value:t,indicatorColor:"primary",textColor:"primary",variant:"scrollable",allowScrollButtonsMobile:!0,children:Es.map(({label:n,path:o})=>e(de,{value:o,label:e(ue,{to:o,children:e("span",{children:n})})},n))}),children:r(Hn,{children:[e(J,{path:"traffic",element:e(Ts,{})}),e(J,{path:"*",element:e(ks,{})})]})})})},St=()=>{const{makeRequest:t,createRequest:n,errors:o,loading:a}=Ie({propagateErrors:!0});return{createRole:async l=>{const u=n("api/admin/roles",{method:"POST",body:JSON.stringify(l)});try{return await t(u.caller,u.id)}catch(m){throw m}},deleteRole:async l=>{const c=`api/admin/roles/${l}`,u=n(c,{method:"DELETE"});try{return await t(u.caller,u.id)}catch(m){throw m}},editRole:async(l,c)=>{const u=`api/admin/roles/${l}`,m=n(u,{method:"PUT",body:JSON.stringify(c)});try{return await t(m.caller,m.id)}catch(b){throw b}},validateRole:async l=>{const u=n("api/admin/roles/validate",{method:"POST",body:JSON.stringify(l)});try{return await t(u.caller,u.id)}catch(m){throw m}},errors:o,loading:a}},Ps=f(j)(({theme:t})=>({display:"flex",alignItems:"center",[t.breakpoints.down(500)]:{flexDirection:"column",alignItems:"flex-start"}})),Ds=f(aa)(({theme:t})=>({fontWeight:t.typography.fontWeightBold,marginRight:t.spacing(1)})),un=({title:t,permissions:n,checkedPermissions:o,Icon:a,isInitiallyExpanded:i,context:s,onPermissionChange:d,onCheckAll:h,getRoleKey:l})=>{const[c,u]=p.useState(i),m=p.useMemo(()=>(n==null?void 0:n.reduce((g,C)=>(g[l(C)]=!0,g),{}))||{},[n]),b=p.useMemo(()=>Object.keys(o).filter(g=>m[g]).length||0,[o,m]),v=p.useMemo(()=>b===(n==null?void 0:n.length),[b,n]);return e(j,{sx:{my:2,pb:1},children:r(ra,{expanded:c,onChange:()=>u(!c),sx:{boxShadow:"none",px:3,py:1,border:g=>`1px solid ${g.palette.divider}`,borderRadius:g=>`${g.shape.borderRadiusLarge}px`},children:[e(ia,{expandIcon:e(Fe,{children:e(Va,{titleAccess:"Toggle"})}),sx:{boxShadow:"none",padding:"0"},children:r(Ps,{children:[a,e(Ds,{text:t,maxWidth:"120",maxLength:25})," ",r(I,{variant:"body2",color:"text.secondary",children:["(",b," / ",n==null?void 0:n.length," ","permissions)"]})]})}),r(sa,{sx:{px:0,py:1,flexWrap:"wrap"},children:[e(Gt,{sx:{mb:1}}),r(M,{variant:"text",size:"small",onClick:h,sx:{fontWeight:g=>g.typography.fontWeightRegular},children:[v?"Unselect ":"Select ","all ",s," permissions"]}),e(j,{children:n==null?void 0:n.map(g=>e(ie,{sx:{minWidth:{sm:"300px",xs:"auto"}},control:e(Ln,{checked:!!o[l(g)],onChange:()=>d(g),color:"primary"}),label:g.displayName},l(g)))})]})]})})},ro=({children:t,roleName:n,roleDesc:o,checkedPermissions:a,errors:i,permissions:s,onSubmit:d,onCancel:h,setRoleName:l,setRoleDesc:c,handlePermissionChange:u,checkAllProjectPermissions:m,checkAllEnvironmentPermissions:b,validateNameUniqueness:v,clearErrors:g,getRoleKey:C})=>{const{project:w,environments:S}=s;return r("form",{onSubmit:d,children:[r(j,{sx:{maxWidth:"400px"},children:[e(I,{sx:{mb:1},children:"What is your role name?"}),e(Ve,{label:"Role name",value:n,onChange:x=>l(x.target.value),error:Boolean(i.name),errorText:i.name,onFocus:()=>g(),onBlur:v,autoFocus:!0,sx:{width:"100%",marginBottom:"1rem"}}),e(I,{sx:{mb:1},children:"What is this role for?"}),e(X,{label:"Role description",variant:"outlined",multiline:!0,maxRows:4,value:o,onChange:x=>c(x.target.value),sx:{width:"100%",marginBottom:"1rem"}})]}),e("div",{children:e(k,{condition:Boolean(i.permissions),show:e(I,{variant:"body2",color:"error.main",children:"You must select at least one permission for a role."})})}),e(un,{isInitiallyExpanded:!0,title:"Project permissions",Icon:e(ir,{color:"disabled",sx:{mr:1}}),permissions:w,checkedPermissions:a,onPermissionChange:x=>u(x),onCheckAll:m,getRoleKey:C,context:"project"}),e("div",{children:S.map(x=>e(un,{title:x.name,Icon:e(la,{sx:{mr:1},color:"disabled"}),permissions:x.permissions,checkedPermissions:a,onPermissionChange:P=>u(P),onCheckAll:()=>b(x.name),getRoleKey:C,context:"environment"},x.name))}),r(j,{sx:{marginTop:"auto",display:"flex",justifyContent:"flex-end"},children:[t,e(M,{onClick:h,sx:{marginLeft:2},children:"Cancel"})]})]})},pe=t=>t.environment?`${t.id}-${t.environment}`:`${t.id}`,io=(t="",n="",o=[])=>{const{permissions:a}=ca({revalidateIfStale:!1,revalidateOnReconnect:!1,revalidateOnFocus:!1}),[i,s]=p.useState(t),[d,h]=p.useState(n),[l,c]=p.useState({});p.useEffect(()=>{o.length>0&&c(o==null?void 0:o.reduce((T,R)=>(T[pe(R)]=R,T),{}))},[o==null?void 0:o.length]);const[u,m]=p.useState({}),{validateRole:b}=St();p.useEffect(()=>{s(t)},[t]),p.useEffect(()=>{h(n)},[n]);const v=T=>{let R=Pt(l);R[pe(T)]?delete R[pe(T)]:R[pe(T)]={...T},c(R)},g=()=>{const{project:T}=a;let R=Pt(l);T.every(A=>R[pe(A)])?T.forEach(A=>{delete R[pe(A)]}):T.forEach(A=>{R[pe(A)]={...A}}),c(R)},C=T=>{const{environments:R}=a,U=Pt(l),A=R.find(B=>B.name===T);if(!A)return;A.permissions.every(B=>U[pe(B)])?A.permissions.forEach(B=>{delete U[pe(B)]}):A.permissions.forEach(B=>{U[pe(B)]={...B}}),c(U)},w=()=>({name:i,description:d,permissions:Object.values(l)});return{roleName:i,roleDesc:d,errors:u,checkedPermissions:l,permissions:a,setRoleName:s,setRoleDesc:h,handlePermissionChange:v,onToggleAllProjectPermissions:g,onToggleAllEnvironmentPermissions:C,getProjectRolePayload:w,validatePermissions:()=>Object.keys(l).length===0?(m(T=>({...T,permissions:"You must include at least one permission."})),!1):!0,validateName:()=>i.length===0?(m(T=>({...T,name:"Name can not be empty."})),!1):!0,clearErrors:()=>{m({})},validateNameUniqueness:async()=>{const T=w();try{await b(T)}catch(R){m(U=>({...U,name:V(R)}))}},getRoleKey:pe}},Is=()=>{const{setToastData:t,setToastApiError:n}=K(),{uiConfig:o}=Y(),a=ae(),{roleName:i,roleDesc:s,permissions:d,checkedPermissions:h,errors:l,setRoleName:c,setRoleDesc:u,handlePermissionChange:m,onToggleAllProjectPermissions:b,onToggleAllEnvironmentPermissions:v,getProjectRolePayload:g,validatePermissions:C,validateName:w,validateNameUniqueness:S,clearErrors:x,getRoleKey:P}=io(),{createRole:L,loading:T}=St();return e(we,{loading:T,title:"Create project role",description:`A project role can be
|
|
15
|
+
--data-raw '${JSON.stringify(b(),void 0,2)}'`,children:r(Ei,{onSubmit:async C=>{C.preventDefault();try{await s(o.id,b()),a(),i(),n(!1),h({title:"Group users saved successfully",type:"success"})}catch(w){l(V(w))}},children:[r("div",{children:[e(Ri,{children:"Edit users in this group"}),e(Qn,{users:u,setUsers:m}),e(eo,{users:u,setUsers:m})]}),e(Pi,{children:r(Ii,{children:[e(M,{type:"submit",variant:"contained",color:"primary","data-testid":On,children:"Save"}),e(Di,{onClick:()=>{n(!1)},children:"Cancel"})]})})]})})})},Ui=({open:t,setOpen:n,user:o,group:a})=>{const{refetchGroup:i}=ft(a.id),{updateGroup:s}=tt(),{setToastData:d,setToastApiError:h}=K(),l=async()=>{try{const u={...a,users:a.users.filter(({id:m})=>m!==(o==null?void 0:o.id)).map(({id:m})=>({user:{id:m}}))};await s(a.id,u),i(),n(!1),d({title:"User removed from group successfully",type:"success"})}catch(u){h(V(u))}},c=(o==null?void 0:o.name)||(o==null?void 0:o.username)||(o==null?void 0:o.email);return e(se,{open:t&&Boolean(o),primaryButtonText:"Remove user",secondaryButtonText:"Cancel",onClick:l,onClose:()=>{n(!1)},title:"Remove user from group?",children:r(I,{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."]})})},Bi=Array(15).fill({name:"Name of the user",username:"Username of the user"}),Li={id:"joinedAt"},{value:cn,setValue:Oi}=Yo("Group:v1",Li),Ni=()=>{const t=Number(mt("groupId")),n=Ht(),o=ve(n.breakpoints.down("md")),{group:a,loading:i}=ft(t),[s,d]=p.useState(!1),[h,l]=p.useState(!1),[c,u]=p.useState(!1),[m,b]=p.useState(),v=p.useMemo(()=>[{Header:"Avatar",accessor:"imageUrl",Cell:({row:{original:D}})=>e(Se,{children:e(ze,{user:D})}),maxWidth:85,disableSortBy:!0},{id:"name",Header:"Name",accessor:D=>D.name||"",Cell:xe,minWidth:100,searchable:!0},{id:"username",Header:"Username",accessor:D=>D.username||D.email,Cell:xe,minWidth:100,searchable:!0},{Header:"Joined",accessor:"joinedAt",Cell:Ne,sortType:"date",maxWidth:150},{id:"createdBy",Header:"Added by",accessor:"createdBy",Cell:xe,minWidth:90,searchable:!0},{Header:"Last login",accessor:D=>D.seenAt||"",Cell:({row:{original:D}})=>e(gt,{value:D.seenAt,emptyText:"Never",title:O=>`Last login: ${O}`}),sortType:"date",maxWidth:150},{Header:"Actions",id:"Actions",align:"center",Cell:({row:{original:D}})=>e(ht,{children:e(Pe,{title:"Remove user from group",arrow:!0,describeChild:!0,children:e("span",{children:e(Fe,{"data-testid":`${Jo}-${D.id}`,onClick:()=>{b(D),u(!0)},children:e(De,{})})})})}),maxWidth:100,disableSortBy:!0}],[b,u]),[g,C]=$n(),[w]=p.useState(()=>({sortBy:[{id:g.get("sort")||cn.id,desc:g.has("order")?g.get("order")==="desc":cn.desc}],hiddenColumns:["description"],globalFilter:g.get("search")||""})),[S,x]=p.useState(w.globalFilter),{data:P,getSearchText:L,getSearchContext:T}=Wt(v,S,(a==null?void 0:a.users)??[]),R=p.useMemo(()=>(P==null?void 0:P.length)===0&&i?Bi:P,[P,i]),{headerGroups:U,rows:A,prepareRow:H,state:{sortBy:B}}=Z.useTable({columns:v,data:R,initialState:w,sortTypes:je,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},Z.useSortBy,Z.useFlexLayout);return p.useEffect(()=>{const D={};D.sort=B[0].id,B[0].desc&&(D.order="desc"),S&&(D.search=S),C(D,{replace:!0}),Oi({id:B[0].id,desc:B[0].desc||!1})},[B,S,C]),e(k,{condition:Boolean(a),show:r(F,{children:[e(Ai,{title:a==null?void 0:a.name,description:a==null?void 0:a.description,actions:r(F,{children:[e(ke,{"data-testid":Ko,to:`/admin/groups/${t}/edit`,component:Re,"data-loading":!0,permission:z,tooltipProps:{title:"Edit group"},children:e(et,{})}),e(ke,{"data-testid":Zo,"data-loading":!0,onClick:()=>d(!0),permission:z,tooltipProps:{title:"Delete group"},children:e(De,{})})]})}),r(Q,{isLoading:i,header:e(te,{secondary:!0,title:`Users (${A.length<R.length?`${A.length} of ${R.length}`:R.length})`,actions:r(F,{children:[e(k,{condition:!o,show:r(F,{children:[e(ye,{initialValue:S,onChange:x,hasFilters:!0,getSearchContext:T}),e(te.Divider,{})]})}),e(jn,{"data-testid":Xo,onClick:()=>{l(!0)},maxWidth:"700px",Icon:zt,permission:z,children:"Edit users"})]}),children:e(k,{condition:o,show:e(ye,{initialValue:S,onChange:x,hasFilters:!0,getSearchContext:T})})}),children:[e(Ye,{value:L(S),children:e(Qe,{rows:A,headerGroups:U,prepareRow:H})}),e(k,{condition:A.length===0,show:e(k,{condition:(S==null?void 0:S.length)>0,show:r(ge,{children:["No users found matching “",S,"” in this group."]}),elseShow:e(ge,{children:"This group is empty. Get started by adding a user to the group."})})}),e(no,{open:s,setOpen:d,group:a}),e(oo,{open:h,setOpen:l,group:a}),e(Ui,{open:c,setOpen:u,user:m,group:a})]})]})})},Gi=f(Fn)(({theme:t})=>({pointerEvents:"none",".MuiPaper-root":{padding:t.spacing(2)}})),$i=f("div")(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(1)})),ji=({user:t,open:n,anchorEl:o,onPopoverClose:a})=>r(Gi,{open:n,anchorEl:o,onClose:a,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},children:[e($i,{children:(t==null?void 0:t.name)||(t==null?void 0:t.username)}),e("div",{children:t==null?void 0:t.email})]}),Fi=f("div")(({theme:t})=>({display:"inline-flex",alignItems:"center",flexWrap:"wrap",marginLeft:t.spacing(1)})),dn=f(ze)(({theme:t})=>({outline:`${t.spacing(.25)} solid ${t.palette.background.paper}`,marginLeft:t.spacing(-1),"&:hover":{outlineColor:t.palette.primary.main}})),zi=({users:t})=>{const n=p.useMemo(()=>t.sort((c,u)=>(u==null?void 0:u.joinedAt.getTime())-(c==null?void 0:c.joinedAt.getTime())).slice(0,9),[t]),[o,a]=p.useState(null),[i,s]=p.useState(),d=c=>{a(c.currentTarget)},h=()=>{a(null)},l=Boolean(o);return r(Fi,{children:[n.map(c=>e(dn,{user:c,onMouseEnter:u=>{d(u),s(c)},onMouseLeave:h},c.id)),e(k,{condition:t.length>9,show:r(dn,{children:["+",t.length-n.length]})}),e(ji,{open:l,user:i,anchorEl:o,onPopoverClose:h})]})},Mi=f("div")(({theme:t})=>({display:"flex",justifyContent:"center",transform:"translate3d(8px, -6px, 0)"})),Hi=f(Fn)(({theme:t})=>({borderRadius:t.shape.borderRadiusLarge,padding:t.spacing(1,1.5)})),Wi=({groupId:t,onEditUsers:n,onRemove:o})=>{const[a,i]=p.useState(null),s=Boolean(a),d=u=>{i(u.currentTarget)},h=()=>{i(null)},l=`feature-${t}-actions`,c=`${l}-menu`;return r(Mi,{onClick:u=>{u.preventDefault(),u.stopPropagation()},children:[e(Pe,{title:"Group actions",arrow:!0,describeChild:!0,children:e(Fe,{id:l,"aria-controls":s?c:void 0,"aria-haspopup":"true","aria-expanded":s?"true":void 0,onClick:d,type:"button",children:e(qa,{})})}),e(Hi,{id:c,anchorEl:a,open:s,onClose:h,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,children:r(Qo,{"aria-labelledby":l,children:[r(He,{onClick:h,component:Re,to:`/admin/groups/${t}/edit`,children:[e(Et,{children:e(et,{})}),e(Rt,{children:e(I,{variant:"body2",children:"Edit group"})})]}),r(He,{onClick:()=>{n(),h()},children:[e(Et,{children:e(ar,{})}),e(Rt,{children:e(I,{variant:"body2",children:"Edit group users"})})]}),r(He,{onClick:()=>{o(),h()},children:[e(Et,{children:e(De,{})}),e(Rt,{children:e(I,{variant:"body2",children:"Delete group"})})]})]})})]})},qi=f(Re)(({theme:t})=>({textDecoration:"none",color:t.palette.text.primary})),_i=f("aside")(({theme:t})=>({padding:t.spacing(2.5),height:"100%",border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadiusLarge,boxShadow:t.boxShadows.card,display:"flex",flexDirection:"column",[t.breakpoints.up("md")]:{padding:t.spacing(4)},"&:hover":{transition:"background-color 0.2s ease-in-out",backgroundColor:t.palette.neutral.light}})),ao=f("div")(()=>({display:"flex",alignItems:"center",justifyContent:"space-between"})),Vi=f(ao)(()=>({alignItems:"flex-start"})),Yi=f(ao)(()=>({marginTop:"auto"})),Ji=f("h2")(({theme:t})=>({fontSize:t.fontSizes.mainHeader,fontWeight:t.fontWeight.medium})),Ki=f("div")(({theme:t})=>({display:"flex",alignItems:"center",color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody})),Zi=f("p")(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(1),marginBottom:t.spacing(4)})),Xi=f("span")(({theme:t})=>({color:t.palette.text.secondary,marginLeft:t.spacing(1)})),Qi=f("div")(({theme:t})=>({maxWidth:"50%",display:"flex",justifyContent:"flex-end",gap:t.spacing(.5),flexWrap:"wrap"})),es=({group:t,onEditUsers:n,onRemoveGroup:o})=>{var i;const a=ae();return e(F,{children:e(qi,{to:`/admin/groups/${t.id}`,children:r(_i,{children:[r(Vi,{children:[e(Ji,{children:t.name}),e(Ki,{children:e(Wi,{groupId:t.id,onEditUsers:()=>n(t),onRemove:()=>o(t)})})]}),e(Zi,{children:t.description}),r(Yi,{children:[e(k,{condition:((i=t.users)==null?void 0:i.length)>0,show:e(zi,{users:t.users}),elseShow:e(Xi,{children:"This group has no users."})}),e(Qi,{children:e(k,{condition:t.projects.length>0,show:t.projects.map(s=>e(Pe,{title:"View project",arrow:!0,placement:"bottom-end",describeChild:!0,children:e(Ut,{onClick:d=>{d.preventDefault(),a(`/projects/${s}/settings/access`)},color:"secondary",icon:e(ea,{}),children:s})},s)),elseShow:e(Pe,{title:"This group is not used in any project",arrow:!0,describeChild:!0,children:e(Ut,{children:"Not used"})})})})]})]})},t.id)})},ts=()=>{const t=f("div")(({theme:o})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:o.spacing(6),marginLeft:"auto",marginRight:"auto"})),n=f(I)(({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:Re,variant:"outlined",color:"primary",children:"Create your first group"})]})},ns=(t,n)=>{var i,s,d,h,l,c;const o=n.toLowerCase(),a={names:(i=t.users)==null?void 0:i.map(u=>{var m;return((m=u.name)==null?void 0:m.toLowerCase())||""}),usernames:(s=t.users)==null?void 0:s.map(u=>{var m;return((m=u.username)==null?void 0:m.toLowerCase())||""}),emails:(d=t.users)==null?void 0:d.map(u=>{var m;return((m=u.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(u=>u.includes(o)))||((l=a.usernames)==null?void 0:l.some(u=>u.includes(o)))||((c=a.emails)==null?void 0:c.some(u=>u.includes(o)))},os=()=>{const t=ae(),[n,o]=p.useState(!1),[a,i]=p.useState(!1),[s,d]=p.useState(void 0),{groups:h=[],loading:l}=_e(),[c,u]=$n(),[m,b]=p.useState(c.get("search")||""),v=ve(Ge.breakpoints.down("md"));p.useEffect(()=>{const S={};m&&(S.search=m),u(S,{replace:!0})},[m,u]);const g=p.useMemo(()=>{const S=h.sort((x,P)=>x.name.localeCompare(P.name));return m?S.filter(x=>ns(x,m)):S},[h,m]),C=S=>{d(S),o(!0)},w=S=>{d(S),i(!0)};return r(Q,{isLoading:l,header:e(te,{title:`Groups (${g.length})`,actions:r(F,{children:[e(k,{condition:!v,show:r(F,{children:[e(ye,{initialValue:m,onChange:b}),e(te.Divider,{})]})}),e(jn,{onClick:()=>t("/admin/groups/create-group"),maxWidth:"700px",Icon:zt,permission:z,"data-testid":ta,children:"New group"})]}),children:e(k,{condition:v,show:e(ye,{initialValue:m,onChange:b})})}),children:[e(Ye,{value:m,children:e(y,{container:!0,spacing:2,children:g.map(S=>e(y,{item:!0,xs:12,md:6,children:e(es,{group:S,onEditUsers:C,onRemoveGroup:w})},S.id))})}),e(k,{condition:!l&&g.length===0,show:e(k,{condition:(m==null?void 0:m.length)>0,show:r(ge,{children:["No groups found matching “",m,"”"]}),elseShow:e(ts,{})})}),e(k,{condition:Boolean(s),show:e(oo,{open:n,setOpen:o,group:s})}),e(k,{condition:Boolean(s),show:e(no,{open:a,setOpen:i,group:s})})]})},as=()=>e("div",{children:e(os,{})}),rs=()=>{const{data:t,error:n,mutate:o}=Te(oe("api/admin/instance-admin/statistics"),is);return p.useMemo(()=>({stats:t,loading:!n&&!t,refetchGroup:()=>o(),error:n}),[t,n,o])},is=t=>fetch(t).then(Ce("Instance Stats")).then(n=>n.json()),ss=()=>{const{stats:t}=rs();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},{title:"Feature exports",value:t==null?void 0:t.featureExports},{title:"Feature imports",value:t==null?void 0:t.featureImports}];return t!=null&&t.versionEnterprise&&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(te,{title:"Instance Statistics"}),children:r(_a,{sx:{display:"grid",gap:4},children:[r(Dn,{"aria-label":"Instance statistics",children:[e(In,{children:r(qe,{children:[e(ne,{children:"Field"}),e(ne,{align:"right",children:"Value"})]})}),e(pt,{children:a.map(i=>r(qe,{children:[e(ne,{component:"th",scope:"row",children:i.title}),e(ne,{align:"right",children:i.value})]},i.title))})]}),e("span",{style:{textAlign:"center"},children:e(M,{startIcon:e(na,{}),"aria-label":"Download instance statistics",color:"primary",variant:"contained",target:"_blank",href:oe("/api/admin/instance-admin/statistics/csv"),children:"Download"})})]})})},ls=()=>e("div",{children:e(ss,{})}),cs=()=>e(_,{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."]})}),ds=()=>{const{data:t,error:n,mutate:o}=Te(oe("api/admin/maintenance"),us);return p.useMemo(()=>({enabled:Boolean(t==null?void 0:t.enabled),loading:!n&&!t,refetchMaintenance:o,error:n}),[t,n,o])},us=t=>fetch(t).then(Ce("Maintenance")).then(n=>n.json()),hs=()=>{const{makeRequest:t,createRequest:n,errors:o,loading:a}=Ie({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}},ps=f("div")(({theme:t})=>({display:"flex",flexDirection:"column",padding:t.spacing(3),border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadiusLarge})),ms=f(j)(({theme:t})=>({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"})),gs=f(j)(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(2)})),fs=f(I)(({theme:t})=>({fontSize:t.fontSizes.smallBody})),ys=()=>{const{enabled:t,refetchMaintenance:n}=ds(),{toggleMaintenance:o}=hs(),{trackEvent:a}=qt(),{setToastData:i}=K();return r(ps,{children:[r(ms,{children:[e("b",{children:"Maintenance Mode"}),e(ie,{sx:{margin:0},control:e(be,{onChange:async()=>{i({type:"success",title:`Maintenance mode has been successfully ${t?"disabled":"enabled"}`}),a("maintenance",{props:{eventType:`maintenance ${t?"de":""}activated`}}),await o({enabled:!t}),n()},value:t,name:"enabled",checked:t}),label:e(fs,{children:t?"Enabled":"Disabled"})})]}),e(gs,{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."})]})},bs=()=>{const{hasAccess:t}=p.useContext(he);return e("div",{children:e(k,{condition:t(z),show:e(vs,{}),elseShow:e($e,{})})})},Ss=f(j)(({theme:t})=>({display:"grid",gap:t.spacing(4)})),vs=()=>{const{loading:t}=Y();return t?null:e(Q,{header:e(te,{title:"Maintenance"}),children:r(Ss,{children:[e(cs,{}),e(ys,{})]})})},Cs=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},ue=({to:t,children:n})=>{const o=Ht();return e(oa,{to:t,style:({isActive:a})=>Cs({isActive:a,theme:o}),children:n})},ws=f(Nn)(({theme:t})=>({marginBottom:"1rem",borderRadius:"12.5px",boxShadow:"none",padding:"0 2rem"}));function xs(){const{uiConfig:t,isEnterprise:n}=Y(),{pathname:o}=zn(),{isBilling:a}=jt(),{flags:i,networkViewEnabled:s}=t,d=o.split("/")[2];return e(ws,{children:r(Mn,{value:d,variant:"scrollable",scrollButtons:"auto",allowScrollButtonsMobile:!0,children:[e(de,{value:"users",label:e(ue,{to:"/admin/users",children:e("span",{children:"Users"})})}),n()&&e(de,{value:"service-accounts",label:e(ue,{to:"/admin/service-accounts",children:e("span",{children:"Service accounts"})})}),i.UG&&e(de,{value:"groups",label:e(ue,{to:"/admin/groups",children:e("span",{children:"Groups"})})}),i.RE&&e(de,{value:"roles",label:e(ue,{to:"/admin/roles",children:e("span",{children:"Project roles"})})}),e(de,{value:"api",label:e(ue,{to:"/admin/api",children:"API access"})}),t.flags.embedProxyFrontend&&e(de,{value:"cors",label:e(ue,{to:"/admin/cors",children:"CORS origins"})}),e(de,{value:"auth",label:e(ue,{to:"/admin/auth",children:"Single sign-on"})}),e(de,{value:"instance",label:e(ue,{to:"/admin/instance",children:"Instance stats"})}),s&&e(de,{value:"network",label:e(ue,{to:"/admin/network",children:"Network"})}),e(de,{value:"maintenance",label:e(ue,{to:"/admin/maintenance",children:"Maintenance"})}),a&&e(de,{value:"billing",label:e(ue,{to:"/admin/billing",children:"Billing"})})]})})}const ks=p.lazy(()=>import("./NetworkOverview-02d7cec9.js")),Ts=p.lazy(()=>import("./NetworkTraffic-ea8ea762.js")),As=f(Q)(()=>({".page-header":{padding:0}})),Es=[{label:"Overview",path:"/admin/network"},{label:"Traffic",path:"/admin/network/traffic"}],Rs=()=>{const{pathname:t}=zn();return e("div",{children:e(As,{headerClass:"page-header",header:e(Mn,{value:t,indicatorColor:"primary",textColor:"primary",variant:"scrollable",allowScrollButtonsMobile:!0,children:Es.map(({label:n,path:o})=>e(de,{value:o,label:e(ue,{to:o,children:e("span",{children:n})})},n))}),children:r(Hn,{children:[e(J,{path:"traffic",element:e(Ts,{})}),e(J,{path:"*",element:e(ks,{})})]})})})},St=()=>{const{makeRequest:t,createRequest:n,errors:o,loading:a}=Ie({propagateErrors:!0});return{createRole:async l=>{const u=n("api/admin/roles",{method:"POST",body:JSON.stringify(l)});try{return await t(u.caller,u.id)}catch(m){throw m}},deleteRole:async l=>{const c=`api/admin/roles/${l}`,u=n(c,{method:"DELETE"});try{return await t(u.caller,u.id)}catch(m){throw m}},editRole:async(l,c)=>{const u=`api/admin/roles/${l}`,m=n(u,{method:"PUT",body:JSON.stringify(c)});try{return await t(m.caller,m.id)}catch(b){throw b}},validateRole:async l=>{const u=n("api/admin/roles/validate",{method:"POST",body:JSON.stringify(l)});try{return await t(u.caller,u.id)}catch(m){throw m}},errors:o,loading:a}},Ps=f(j)(({theme:t})=>({display:"flex",alignItems:"center",[t.breakpoints.down(500)]:{flexDirection:"column",alignItems:"flex-start"}})),Ds=f(aa)(({theme:t})=>({fontWeight:t.typography.fontWeightBold,marginRight:t.spacing(1)})),un=({title:t,permissions:n,checkedPermissions:o,Icon:a,isInitiallyExpanded:i,context:s,onPermissionChange:d,onCheckAll:h,getRoleKey:l})=>{const[c,u]=p.useState(i),m=p.useMemo(()=>(n==null?void 0:n.reduce((g,C)=>(g[l(C)]=!0,g),{}))||{},[n]),b=p.useMemo(()=>Object.keys(o).filter(g=>m[g]).length||0,[o,m]),v=p.useMemo(()=>b===(n==null?void 0:n.length),[b,n]);return e(j,{sx:{my:2,pb:1},children:r(ra,{expanded:c,onChange:()=>u(!c),sx:{boxShadow:"none",px:3,py:1,border:g=>`1px solid ${g.palette.divider}`,borderRadius:g=>`${g.shape.borderRadiusLarge}px`},children:[e(ia,{expandIcon:e(Fe,{children:e(Va,{titleAccess:"Toggle"})}),sx:{boxShadow:"none",padding:"0"},children:r(Ps,{children:[a,e(Ds,{text:t,maxWidth:"120",maxLength:25})," ",r(I,{variant:"body2",color:"text.secondary",children:["(",b," / ",n==null?void 0:n.length," ","permissions)"]})]})}),r(sa,{sx:{px:0,py:1,flexWrap:"wrap"},children:[e(Gt,{sx:{mb:1}}),r(M,{variant:"text",size:"small",onClick:h,sx:{fontWeight:g=>g.typography.fontWeightRegular},children:[v?"Unselect ":"Select ","all ",s," permissions"]}),e(j,{children:n==null?void 0:n.map(g=>e(ie,{sx:{minWidth:{sm:"300px",xs:"auto"}},control:e(Ln,{checked:!!o[l(g)],onChange:()=>d(g),color:"primary"}),label:g.displayName},l(g)))})]})]})})},ro=({children:t,roleName:n,roleDesc:o,checkedPermissions:a,errors:i,permissions:s,onSubmit:d,onCancel:h,setRoleName:l,setRoleDesc:c,handlePermissionChange:u,checkAllProjectPermissions:m,checkAllEnvironmentPermissions:b,validateNameUniqueness:v,clearErrors:g,getRoleKey:C})=>{const{project:w,environments:S}=s;return r("form",{onSubmit:d,children:[r(j,{sx:{maxWidth:"400px"},children:[e(I,{sx:{mb:1},children:"What is your role name?"}),e(Ve,{label:"Role name",value:n,onChange:x=>l(x.target.value),error:Boolean(i.name),errorText:i.name,onFocus:()=>g(),onBlur:v,autoFocus:!0,sx:{width:"100%",marginBottom:"1rem"}}),e(I,{sx:{mb:1},children:"What is this role for?"}),e(X,{label:"Role description",variant:"outlined",multiline:!0,maxRows:4,value:o,onChange:x=>c(x.target.value),sx:{width:"100%",marginBottom:"1rem"}})]}),e("div",{children:e(k,{condition:Boolean(i.permissions),show:e(I,{variant:"body2",color:"error.main",children:"You must select at least one permission for a role."})})}),e(un,{isInitiallyExpanded:!0,title:"Project permissions",Icon:e(ir,{color:"disabled",sx:{mr:1}}),permissions:w,checkedPermissions:a,onPermissionChange:x=>u(x),onCheckAll:m,getRoleKey:C,context:"project"}),e("div",{children:S.map(x=>e(un,{title:x.name,Icon:e(la,{sx:{mr:1},color:"disabled"}),permissions:x.permissions,checkedPermissions:a,onPermissionChange:P=>u(P),onCheckAll:()=>b(x.name),getRoleKey:C,context:"environment"},x.name))}),r(j,{sx:{marginTop:"auto",display:"flex",justifyContent:"flex-end"},children:[t,e(M,{onClick:h,sx:{marginLeft:2},children:"Cancel"})]})]})},pe=t=>t.environment?`${t.id}-${t.environment}`:`${t.id}`,io=(t="",n="",o=[])=>{const{permissions:a}=ca({revalidateIfStale:!1,revalidateOnReconnect:!1,revalidateOnFocus:!1}),[i,s]=p.useState(t),[d,h]=p.useState(n),[l,c]=p.useState({});p.useEffect(()=>{o.length>0&&c(o==null?void 0:o.reduce((T,R)=>(T[pe(R)]=R,T),{}))},[o==null?void 0:o.length]);const[u,m]=p.useState({}),{validateRole:b}=St();p.useEffect(()=>{s(t)},[t]),p.useEffect(()=>{h(n)},[n]);const v=T=>{let R=Pt(l);R[pe(T)]?delete R[pe(T)]:R[pe(T)]={...T},c(R)},g=()=>{const{project:T}=a;let R=Pt(l);T.every(A=>R[pe(A)])?T.forEach(A=>{delete R[pe(A)]}):T.forEach(A=>{R[pe(A)]={...A}}),c(R)},C=T=>{const{environments:R}=a,U=Pt(l),A=R.find(B=>B.name===T);if(!A)return;A.permissions.every(B=>U[pe(B)])?A.permissions.forEach(B=>{delete U[pe(B)]}):A.permissions.forEach(B=>{U[pe(B)]={...B}}),c(U)},w=()=>({name:i,description:d,permissions:Object.values(l)});return{roleName:i,roleDesc:d,errors:u,checkedPermissions:l,permissions:a,setRoleName:s,setRoleDesc:h,handlePermissionChange:v,onToggleAllProjectPermissions:g,onToggleAllEnvironmentPermissions:C,getProjectRolePayload:w,validatePermissions:()=>Object.keys(l).length===0?(m(T=>({...T,permissions:"You must include at least one permission."})),!1):!0,validateName:()=>i.length===0?(m(T=>({...T,name:"Name can not be empty."})),!1):!0,clearErrors:()=>{m({})},validateNameUniqueness:async()=>{const T=w();try{await b(T)}catch(R){m(U=>({...U,name:V(R)}))}},getRoleKey:pe}},Is=()=>{const{setToastData:t,setToastApiError:n}=K(),{uiConfig:o}=Y(),a=ae(),{roleName:i,roleDesc:s,permissions:d,checkedPermissions:h,errors:l,setRoleName:c,setRoleDesc:u,handlePermissionChange:m,onToggleAllProjectPermissions:b,onToggleAllEnvironmentPermissions:v,getProjectRolePayload:g,validatePermissions:C,validateName:w,validateNameUniqueness:S,clearErrors:x,getRoleKey:P}=io(),{createRole:L,loading:T}=St();return e(we,{loading:T,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' \\
|