unleash-server
Version:
Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.
8 lines (7 loc) • 21.2 kB
JavaScript
import{G as V,H as L,j as t,A as Q,l as Z,C as _,bp as ce,m as ue,o as pe,iw as he,n as ge,s as j,b as X,T as E,u as fe,bi as me,r as v,bh as xe,bj as ve,bl as be,t as ye,bs as Se,aB as ee,d7 as W,cU as je,b_ as Te,ix as Ce,d5 as Ee,da as J,be as O,cE as we,d9 as Re,d8 as Ae,iy as ke,ck as Ie,bI as te,bA as ae,bk as se,iz as _e,iA as Fe,iB as Pe,iC as $e,hQ as De,hH as ne,iD as Oe,i as Ve,iE as Le,dt as re,aZ as z,bF as Be,fG as qe,e as B,bJ as ze,bH as Ne,bO as He,bZ as Me,hU as Ue,iF as Ge,h as D,cM as We,bB as Je,dl as Ye,bw as Ke,iG as Qe,y as Ze,iH as Xe,b1 as et,b2 as oe,b5 as N,W as tt,db as at,a_ as st,bq as Y,bn as ie,iI as nt,iJ as rt,B as ot,az as it,fI as lt,iK as dt,fk as ct,ga as ut}from"./index-DEkgmbaI.js";var H={},pt=L;Object.defineProperty(H,"__esModule",{value:!0});var le=H.default=void 0,ht=pt(V()),gt=t,ft=(0,ht.default)((0,gt.jsx)("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-2zm-2 10H7v-2h10v2z"}),"IndeterminateCheckBox");le=H.default=ft;const mt=he(),ca=({options:e,selectedOptions:a,indeterminateOptions:s,tagType:l,existingTags:n,disabled:i=!1,onChange:r})=>{const d=t.jsx(ge,{fontSize:"small"}),u=p=>p.inputValue?p.inputValue:p.title,g=({key:p,...h},o,{selected:f})=>{const y=(s==null?void 0:s.some(b=>b.title===o.title))??!1;return t.jsxs("li",{...h,children:[t.jsx(_,{condition:!!o.inputValue,show:t.jsx(ce,{sx:{mr:b=>b.spacing(.5)}}),elseShow:t.jsx(ue,{icon:d,checkedIcon:t.jsx(pe,{fontSize:"small"}),indeterminateIcon:t.jsx(le,{fontSize:"small"}),sx:{mr:b=>b.spacing(.5)},checked:f&&!y,indeterminate:y})}),o.title]},p)},m=(p,h)=>{const o=h.inputValue.trim(),f=mt(p,{...h,inputValue:o}),y=p.some(b=>o===b.title);return o.length>=2&&!y&&f.push({inputValue:o,title:`Create new value "${o}"`}),f};return t.jsx(Q,{multiple:!0,id:"checkboxes-tag",sx:{marginTop:p=>p.spacing(2),width:500},disableCloseOnSelect:!0,options:e,value:a,isOptionEqualToValue:(p,h)=>h.inputValue&&h.inputValue!==""?p.title===h.inputValue:p.title===h.title,getOptionLabel:u,renderOption:g,filterOptions:m,ListboxProps:{style:{maxHeight:200,overflow:"auto"}},onChange:r,renderInput:p=>t.jsx(Z,{...p,label:"Select values",placeholder:"Select values"}),disabled:i})},xt=j("li")({flexDirection:"column"}),ua=({options:e,value:a,disabled:s=!1,onChange:l})=>{const n=X();return t.jsx(Q,{disablePortal:!0,disabled:s,id:"tag-type-select",sx:{marginTop:i=>i.spacing(2),width:500},options:e,disableClearable:!0,value:a,getOptionLabel:i=>i.name,renderOption:({key:i,...r},d)=>t.jsxs(xt,{...r,style:{alignItems:"flex-start",gap:n.spacing(.5)},children:[t.jsx(E,{variant:"body1",children:d.name}),t.jsx(E,{variant:"caption",children:d.description})]},i),renderInput:i=>t.jsx(Z,{...i,label:"Tag type",value:a}),onChange:l,ListboxProps:{style:{maxHeight:200,overflow:"auto"}}})},pa=()=>{const{makeRequest:e,createRequest:a,errors:s,loading:l}=fe({propagateErrors:!0});return{createTag:async r=>{const u=a("api/admin/tags",{method:"POST",body:JSON.stringify(r)});return e(u.caller,u.id)},bulkUpdateTags:async(r,d)=>{const u=`api/admin/projects/${d}/tags`,g=a(u,{method:"PUT",body:JSON.stringify(r)});return e(g.caller,g.id)},errors:s,loading:l}},ha=(e,a={})=>{const s=async()=>{const g=xe(`api/admin/tags/${e}`);return(await fetch(g,{method:"GET"}).then(ve("Tags"))).json()},l=`api/admin/tags/${e}`,{data:n,error:i}=me(!!e,{tags:[]},l,s,a),[r,d]=v.useState(!i&&!n),u=()=>{be(l)};return v.useEffect(()=>{d(!i&&!n)},[n,i]),{tags:(n==null?void 0:n.tags)||[],error:i,loading:r,refetch:u}},vt=j(ye)(({theme:e,$color:a})=>({borderRadius:e.spacing(2),border:`1px solid ${e.palette.divider}`,backgroundColor:e.palette.background.paper,color:e.palette.text.primary,height:"26px","& .MuiChip-label":{display:"flex",alignItems:"center",gap:e.spacing(1),paddingRight:e.spacing(1)},"& .MuiChip-deleteIcon":{marginLeft:e.spacing(.5),marginRight:e.spacing(.5)}})),bt=j("div")(({theme:e,$color:a})=>({width:e.spacing(1.3),height:e.spacing(1.3),borderRadius:"50%",backgroundColor:a,border:`1px solid ${a==="#FFFFFF"?e.palette.divider:a}`,flexShrink:0})),ga=({tag:e,onDelete:a,deleteIcon:s,maxLength:l=30})=>{const n=Se(e),i=n.length>l,r=e.color&&e.color!=="#FFFFFF";let d=e.value;if(i){const g=Math.max(0,l-e.type.length-1);d=`${e.value.substring(0,g)}...`}const u=t.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"8px",width:"100%"},children:[r&&t.jsx(bt,{$color:e.color}),t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:`${e.type}:${d}`})]});return t.jsx(vt,{label:u,onDelete:a,deleteIcon:s,title:i?n:void 0})},yt=j("div")({display:"flex",flexDirection:"column"}),St=({strategy:e,setStrategy:a,projectId:s,environment:l,editable:n,permission:i=Re})=>{const{trackEvent:r}=ee(),[d,u]=v.useState([]),g=X(),m=e!=null&&e.parameters&&"stickiness"in(e==null?void 0:e.parameters)?String(e.parameters.stickiness):"default";v.useEffect(()=>{u((e.variants||[]).map(o=>({...o,new:n||!1,isValid:!0,id:W(),overrides:[]})))},[]),v.useEffect(()=>{a(o=>({...o,variants:d.map(f=>({stickiness:m,name:f.name,weight:f.weight,payload:f.payload,weightType:f.weightType}))}))},[m,JSON.stringify(d)]);const p=(o,f)=>{u(y=>J(y.map(b=>b.id===f?o:b),1e3))},h=()=>{const o=W();u(f=>[...f,{name:"",weightType:Ae.VARIABLE,weight:0,stickiness:m,new:!0,isValid:!1,id:o}]),r("strategy-variants",{props:{eventType:"variant added"}})};return t.jsxs(t.Fragment,{children:[t.jsxs(E,{component:"h3",sx:{m:0,display:"flex",gap:"1ch"},variant:"h3",children:["Variants",t.jsx(je,{htmlTooltip:!0,tooltip:t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Variants allow to attach one or more values to this strategy. Variants at the strategy level override variants at the feature level."}),t.jsx(Te,{target:"_blank",href:"https://docs.getunleash.io/reference/strategy-variants",children:"Learn more"})]})})]}),t.jsxs(yt,{children:[t.jsx(Ce,{}),d.map((o,f)=>t.jsx(Ee,{disableOverrides:!0,variant:o,variants:d,updateVariant:y=>p(y,o.id),removeVariant:()=>u(y=>J(y.filter(b=>b.id!==o.id),1e3)),decorationColor:g.palette.variants[f%g.palette.variants.length]},o.id))]}),t.jsx(O,{onClick:h,variant:"outlined",permission:i,projectId:s,environmentId:l,"data-testid":"ADD_STRATEGY_VARIANT_BUTTON",children:"Add variant"}),t.jsx(we,{variants:d})]})},jt=j("form")(({theme:e})=>({display:"grid",gap:e.spacing(2)})),K=j("hr")(({theme:e})=>({width:"100%",height:"1px",margin:e.spacing(2,0),border:"none",background:e.palette.background.elevation2})),Tt=j("div")(({theme:e})=>({display:"flex",justifyContent:"end",gap:e.spacing(2),paddingBottom:e.spacing(10)})),Ct=({projectId:e,environmentId:a,permission:s,onSubmit:l,onCancel:n,loading:i,strategy:r,setStrategy:d,segments:u,setSegments:g,errors:m})=>{const p=ke(r.constraints),h=Ie(s,e,a),{strategyDefinition:o}=te(r==null?void 0:r.name),f=ae(),{uiConfig:y,error:b,loading:F}=se();if(b)throw b;if(F||!o)return null;const P=S=>o.parameters.find(C=>C.name===S),w=(S,C)=>{const R=P(S);if(S!=="groupId"){const I=Le(R,C);return I?(m.setFormError(S,I),!1):(m.removeFormError(S),!0)}return!0},c=()=>o.parameters.map(S=>S.name).map(S=>{var C;return w(S,(C=r.parameters)==null?void 0:C[S])}).every(Boolean),k=()=>{f(`/projects/${e}/settings/default-strategy`)},$=async S=>{if(S.preventDefault(),c())l();else return};return t.jsxs(jt,{onSubmit:$,children:[t.jsx(_e,{title:r.title||"",setTitle:S=>{d(C=>({...C,title:S}))}}),t.jsx(Fe,{segments:u,setSegments:g,projectId:e}),t.jsx(Pe,{projectId:e,environmentId:a,strategy:r,setStrategy:d}),t.jsx(K,{}),t.jsx($e,{strategy:r,strategyDefinition:o,setStrategy:d,validateParameter:w,errors:m,hasAccess:h}),t.jsx(_,{condition:r.parameters!=null&&"stickiness"in r.parameters,show:t.jsx(St,{strategy:r,setStrategy:d,environment:a,projectId:e,permission:[De,ne]})}),t.jsx(K,{}),t.jsxs(Tt,{children:[t.jsx(O,{permission:s,projectId:e,environmentId:a,variant:"contained",color:"primary",type:"submit",disabled:i||!p||m.hasFormErrors(),"data-testid":Oe,children:"Save strategy"}),t.jsx(Ve,{type:"button",color:"primary",onClick:n||k,disabled:i,children:"Cancel"})]})]})},Et=(e,a)=>{var r;const{project:s,refetch:l}=re(e),n={name:"flexibleRollout",constraints:[],parameters:{rollout:"100",stickiness:s.defaultStickiness||"default",groupId:""}},i=(r=s.environments.find(d=>d.environment===a))==null?void 0:r.defaultStrategy;return{defaultStrategyFallback:n,strategy:i,refetch:l}},fa=()=>{const e=z("projectId"),a=Be("environmentId"),{refetch:s}=re(e),{defaultStrategyFallback:l,strategy:n,refetch:i}=Et(e,a),[r,d]=v.useState(n||l),[u,g]=v.useState([]),{updateDefaultStrategy:m,loading:p}=qe(),{strategyDefinition:h}=te(r==null?void 0:r.name),{setToastData:o,setToastApiError:f}=B(),y=ze(),{uiConfig:b}=se(),{unleashUrl:F}=b,P=ae(),{trackEvent:w}=ee(),{segments:c,refetchSegments:k}=Ne();v.useEffect(()=>{if(c&&(n!=null&&n.segments)){const R=[];for(const I of n==null?void 0:n.segments)R.push(...c.filter(T=>T.id===I));g(R)}},[JSON.stringify(c),JSON.stringify(n==null?void 0:n.segments)]);const $=wt(r,u),S=async R=>{await m(e,a,R),w("default_strategy",{props:{action:"edit",hasTitle:!!R.title}}),k(),s(),o({text:"Default Strategy updated",type:"success"})},C=async()=>{const R=`/projects/${e}/settings/default-strategy`;try{await S($),await i(),P(R)}catch(I){f(D(I))}};return!h||!r?null:t.jsx(He,{modal:!0,title:Me((r==null?void 0:r.name)??""),description:At,documentationLink:kt,documentationLinkLabel:It,formatApiCode:()=>Rt(e,a,$,h,F),children:t.jsx(Ct,{projectId:e,strategy:r,setStrategy:d,segments:u,setSegments:g,environmentId:a,onSubmit:C,loading:p,permission:[Ue,ne],errors:y,isChangeRequest:!1})})},wt=(e,a)=>({name:e.name,title:e.title,constraints:e.constraints??[],parameters:e.parameters??{},variants:e.variants??[],segments:a.map(s=>s.id),disabled:e.disabled??!1}),Rt=(e,a,s,l,n)=>{if(!n)return"";const i={...s,parameters:Ge(s.parameters??{},l)},r=`${n}/api/admin/projects/${e}/environments/${a}/default-strategy}`,d=JSON.stringify(i,void 0,2);return`curl --location --request PUT '${r}' \\
--header 'Authorization: INSERT_API_KEY' \\
--header 'Content-Type: application/json' \\
--data-raw '${d}'`},At=`
An activation strategy will only run when a feature flag is enabled and provides a way to control who will get access to the feature.
If any of a feature flag's activation strategies returns true, the user will get access.
`,kt="https://docs.getunleash.io/reference/projects#project-default-strategy",It="Default strategy documentation",_t=j(We,{shouldForwardProp:e=>e!=="expandable"})(({theme:e,expandable:a})=>({boxShadow:"none",padding:e.spacing(.5,3,.5,2),display:"flex",alignItems:"center",borderRadius:e.shape.borderRadiusLarge,pointerEvents:"auto",opacity:1,"&&&":{cursor:a?"pointer":"default"},":focus-within":{background:"none"}})),Ft=j("header")(({theme:e})=>({display:"flex",columnGap:e.spacing(1),paddingRight:e.spacing(1),width:"100%",color:e.palette.text.primary,alignItems:"center",minHeight:e.spacing(8),containerType:"inline-size"})),Pt=j("hgroup")(({theme:e})=>({display:"grid",gridTemplateColumns:"auto 1fr",flexDirection:"column",flex:1,columnGap:e.spacing(1),"@container (max-width: 500px)":{gridTemplateColumns:"1fr"}})),$t=j("p")(({theme:e})=>({fontSize:e.fontSizes.smallerBody,color:e.palette.text.secondary,gridColumn:"1/-1"})),Dt=j(Je)(({theme:e})=>({fontSize:e.typography.h2.fontSize,fontWeight:e.typography.fontWeightMedium})),de=j("p")(({theme:e})=>({fontSize:e.fontSizes.smallerBody,color:e.palette.info.contrastText,backgroundColor:e.palette.info.light,whiteSpace:"nowrap",width:"min-content",borderRadius:e.shape.borderRadiusExtraLarge,padding:e.spacing(.5,1)})),Ot=j(de)(({theme:e})=>({fontSize:e.fontSizes.smallerBody,color:e.palette.text.secondary,backgroundColor:e.palette.neutral.light})),Vt=({strategyCount:e,releasePlanCount:a})=>{if(e===0&&a===0)return t.jsx(Ot,{children:"0 strategies added"});const n=`${[a>0?"Release plan":void 0,(()=>{switch(e){case 0:return;case 1:return"1 strategy";default:return`${e} strategies`}})()].filter(Boolean).join(", ")} added`;return t.jsx(de,{children:n})},Lt="environment-accordion-summary",ma=({environmentId:e,children:a,expandable:s=!0,environmentMetadata:l,...n})=>{const i=Ye();return t.jsx(_t,{...n,expandIcon:t.jsx(Ke,{sx:{visibility:s?"visible":"hidden"}}),id:i,"aria-controls":`environment-accordion-${i}-content`,expandable:s,tabIndex:s?0:-1,className:Lt,children:t.jsxs(Ft,{"data-loading":!0,children:[t.jsxs(Pt,{children:[t.jsx($t,{children:"Environment"}),t.jsx(Dt,{component:"h2",children:e}),l?t.jsx(Vt,{...l}):null]}),a]})})},xa=({value:e,threshold:a=1e6,precision:s=2})=>{let l,n=!1;e<a?l=e.toLocaleString():(l=Qe(e,{precision:s}),n=!0);const i=t.jsx("span",{"data-testid":Xe,children:l});return t.jsx(_,{condition:n,show:t.jsx(Ze,{title:e.toLocaleString(),arrow:!0,children:i}),elseShow:i})},Bt=e=>{const{setToastData:a,setToastApiError:s}=B(),{addChange:l}=et(),{refetch:n}=oe(e),[i,r]=v.useState(!1),[d,u]=v.useState({isOpen:!1}),g=v.useCallback((h,o,f,y)=>{u({featureName:h,environment:o,enabled:f,shouldActivateDisabledStrategies:y,isOpen:!0})},[]),m=v.useCallback(()=>{u(h=>({...h,isOpen:!1}))},[]),p=v.useCallback(async()=>{try{r(!0),await l(e,d.environment,{feature:d.featureName,action:"updateEnabled",payload:{enabled:!!d.enabled,shouldActivateDisabledStrategies:!!d.shouldActivateDisabledStrategies}}),n(),u(h=>({...h,isOpen:!1})),a({type:"success",text:"Changes added to draft"})}catch(h){s(D(h)),u(o=>({...o,isOpen:!1}))}finally{r(!1)}},[l]);return{pending:i,onChangeRequestToggle:g,onChangeRequestToggleClose:m,onChangeRequestToggleConfirm:p,changeRequestDialogDetails:d}},qt=({enabled:e,featureName:a,environment:s})=>t.jsxs(E,{"data-testid":"update-enabled-message",children:[t.jsx("strong",{children:e?"Enable":"Disable"})," feature flag"," ",t.jsx("strong",{children:a})," in ",t.jsx("strong",{children:s})]}),zt=({isOpen:e,disabled:a=!1,onConfirm:s,onClose:l,showBanner:n,environment:i,messageComponent:r})=>{const d=z("projectId"),{data:u}=oe(d),{changeRequestInReviewOrApproved:g,alert:m}=at(u),p=g(i||""),h=p?"Add to existing change request":"Add suggestion to draft";return t.jsxs(N,{open:e,primaryButtonText:h,secondaryButtonText:"Cancel",disabledPrimaryButton:a,onClick:s,onClose:l,title:"Request changes",fullWidth:!0,children:[t.jsx(_,{condition:p,show:m}),t.jsx(_,{condition:!!n,show:t.jsxs(tt,{severity:"info",sx:{mb:2},children:["Change requests feature is enabled for ",i,". 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.jsx(E,{variant:"body2",color:"text.secondary",children:"Your suggestion:"}),r]})},Nt=j("ul")(({theme:e})=>({margin:e.spacing(1),paddingLeft:e.spacing(2)})),Ht=({isOpen:e,onAddDefaultStrategy:a,onActivateDisabledStrategies:s,onClose:l,environment:n,featureId:i})=>{var m,p,h;const r=z("projectId"),{feature:d}=st(r,i),u=(h=(p=(m=d.environments)==null?void 0:m.find(({name:o})=>o===n))==null?void 0:p.strategies)==null?void 0:h.filter(({disabled:o})=>o).length,g=u?u===1?"1 disabled strategy":`${u} disabled strategies`:"disabled strategies";return t.jsxs(N,{open:e,secondaryButtonText:"Cancel",permissionButton:t.jsxs(t.Fragment,{children:[t.jsx(O,{type:"button",variant:"outlined",permission:Y,projectId:r,environmentId:n,onClick:a,children:"Add default strategy"}),t.jsx(O,{type:"button",variant:"outlined",permission:Y,projectId:r,environmentId:n,onClick:s,children:"Enable all strategies"})]}),onClose:l,title:`Enable feature flag in ${n}`,fullWidth:!0,children:[t.jsx(E,{sx:{mb:o=>o.spacing(3)},children:"A feature flag cannot be enabled without an enabled strategy."}),t.jsx(E,{children:"To enable this feature flag you can choose to:"}),t.jsxs(Nt,{children:[t.jsx("li",{children:t.jsx(E,{children:t.jsx("strong",{children:"Add the default strategy"})})}),t.jsx("li",{children:t.jsxs(E,{children:[t.jsx("strong",{children:"Enable all the disabled strategies"})," ","(this feature flag has ",g,")"]})})]})]})},Mt=e=>{const a=s=>{s<e.length&&e[s](()=>a(s+1))};a(0)},va=e=>{const{toggleFeatureEnvironmentOn:a,toggleFeatureEnvironmentOff:s}=ie(),{setToastData:l,setToastApiError:n}=B(),[i,r]=v.useState({open:!1,label:"",loading:!1,onClose:()=>{},onClick:()=>{}}),[d,u]=v.useState({isOpen:!1,environment:"",featureId:"",onClose:()=>{},onActivateDisabledStrategies:()=>{},onAddDefaultStrategy:()=>{}}),{pending:g,onChangeRequestToggle:m,onChangeRequestToggleClose:p,onChangeRequestToggleConfirm:h,changeRequestDialogDetails:o}=Bt(e),[f,y]=v.useState(),b=v.useCallback(async(w,c)=>{let k=!1;return Mt([T=>{if(c.isChangeRequestEnabled||!rt(c.environmentType||""))return T();r({open:!0,label:`${w?"Enable":"Disable"} Environment`,loading:!1,onClose:()=>{var x;r(A=>({...A,open:!1})),(x=c.onRollback)==null||x.call(c)},onClick:()=>{r(x=>({...x,open:!1,loading:!0})),T()}})},T=>{if(w===!1||!c.hasStrategies||c.hasEnabledStrategies)return T();u({isOpen:!0,environment:c.environmentName,featureId:c.featureId,onClose:()=>{var x;u(A=>({...A,isOpen:!1})),(x=c.onRollback)==null||x.call(c)},onActivateDisabledStrategies:()=>{u(x=>({...x,isOpen:!1})),k=!0,T()},onAddDefaultStrategy:()=>{u(x=>({...x,isOpen:!1})),T()}})},T=>{if(!c.isChangeRequestEnabled)return T();y(()=>{var x;y(void 0),(x=c.onRollback)==null||x.call(c)}),m(c.featureId,c.environmentName,w,k)},async T=>{var x,A;if(w!==!1)return T();try{await s(c.projectId,c.featureId,c.environmentName),l({type:"success",text:`Disabled in ${c.environmentName}`}),(x=c.onSuccess)==null||x.call(c)}catch(q){n(D(q)),(A=c.onRollback)==null||A.call(c)}},async T=>{var x,A;if(w!==!0)return T();try{await a(c.projectId,c.featureId,c.environmentName,k),l({type:"success",text:`Enabled in ${c.environmentName}`}),(x=c.onSuccess)==null||x.call(c)}catch(q){n(D(q)),(A=c.onRollback)==null||A.call(c)}}])},[r]),F=d.featureId.length!==0,P=t.jsxs(t.Fragment,{children:[t.jsx(nt,{...i}),t.jsx(_,{condition:F,show:t.jsx(Ht,{...d})}),t.jsx(zt,{isOpen:o.isOpen,onClose:()=>{f==null||f(),p()},environment:o==null?void 0:o.environment,disabled:g,onConfirm:()=>{f==null||f(),h()},messageComponent:t.jsx(qt,{enabled:o==null?void 0:o.enabled,featureName:o==null?void 0:o.featureName,environment:o.environment})})]});return{onToggle:b,modals:P}},Ut=e=>{const[a,s]=v.useState(e),l=v.useCallback(()=>s(e),[e]);return v.useEffect(()=>{s(e)},[e]),[a,s,l]},Gt=j(ot)(()=>({mx:"auto",...it})),ba=({projectId:e,featureId:a,environmentName:s,value:l,onToggle:n})=>{const[i,r,d]=Ut(l),u=()=>{r(!i),requestAnimationFrame(()=>{n(!i,d)})},g=`${a}-${s}`;return t.jsx(t.Fragment,{children:t.jsx(Gt,{"data-testid":`TOGGLE-${g}`,children:t.jsx(lt,{tooltip:i?`Disable feature in ${s}`:`Enable feature in ${s}`,checked:l,environmentId:s,projectId:e,permission:dt,inputProps:{"aria-label":s},onClick:u,"data-testid":"permission-switch",disableRipple:!0,disabled:l!==i})},g)})},Wt=j(ct)(({theme:e})=>({color:e.palette.warning.main,fontSize:e.fontSizes.bodySize})),ya=()=>t.jsx(ut,{arrow:!0,title:t.jsxs(t.Fragment,{children:["This environment has no variants enabled. If you check this feature's variants in this environment, you will get the"," ",t.jsx("a",{href:"https://docs.getunleash.io/reference/feature-toggle-variants#the-disabled-variant",target:"_blank",rel:"noreferrer",children:"disabled variant"}),"."]}),children:t.jsx(Wt,{})});var M={},Jt=L;Object.defineProperty(M,"__esModule",{value:!0});var Yt=M.default=void 0,Kt=Jt(V()),Qt=t,Zt=(0,Kt.default)((0,Qt.jsx)("path",{d:"m20.54 5.23-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.16.55L3.46 5.23C3.17 5.57 3 6.02 3 6.5V19c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.48-.17-.93-.46-1.27zM12 17.5 6.5 12H10v-2h4v2h3.5L12 17.5zM5.12 5l.81-1h12l.94 1H5.12z"}),"Archive");Yt=M.default=Zt;var U={},Xt=L;Object.defineProperty(U,"__esModule",{value:!0});var ea=U.default=void 0,ta=Xt(V()),aa=t,sa=(0,ta.default)((0,aa.jsx)("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm4.2 14.2L11 13V7h1.5v5.2l4.5 2.7-.8 1.3z"}),"WatchLater");ea=U.default=sa;var G={},na=L;Object.defineProperty(G,"__esModule",{value:!0});var ra=G.default=void 0,oa=na(V()),ia=t,la=(0,oa.default)((0,ia.jsx)("path",{d:"M4 6H2v14c0 1.1.9 2 2 2h14v-2H4V6zm16-4H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-1 9h-4v4h-2v-4H9V9h4V5h2v4h4v2z"}),"LibraryAdd");ra=G.default=la;const Sa=({isStale:e,isOpen:a,projectId:s,featureId:l,onClose:n})=>{const{setToastData:i,setToastApiError:r}=B(),{patchFeatureToggle:d}=ie(),u=t.jsx(E,{children:"Setting a flag to stale marks it for cleanup"}),g=t.jsx(E,{children:"Setting a flag to active marks it as in active use"}),m=e?"active":"stale",p=async h=>{h.stopPropagation();try{await d(s,l,[{op:"replace",path:"/stale",value:!e}]),n()}catch(o){r(D(o))}i(e?{type:"success",text:"The flag is no longer marked as stale"}:{type:"success",text:"The flag has been marked as stale"})};return t.jsx(N,{open:a,secondaryButtonText:"Cancel",primaryButtonText:`Flip to ${m}`,title:`Set feature state to ${m}`,onClick:p,onClose:n,children:t.jsx(_,{condition:e,show:g,elseShow:u})})};export{zt as C,ma as E,ba as F,xa as P,ua as T,ya as V,ha as a,ca as b,ga as c,Et as d,va as e,Lt as f,ra as g,Yt as h,ea as i,Sa as j,fa as k,pa as u};