unleash-server 6.0.0 → 6.0.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.
Files changed (37) hide show
  1. package/dist/lib/features/feature-lifecycle/feature-lifecycle-service.d.ts.map +1 -1
  2. package/dist/lib/features/feature-lifecycle/feature-lifecycle-service.js +1 -1
  3. package/dist/lib/features/feature-lifecycle/feature-lifecycle-service.js.map +1 -1
  4. package/dist/lib/features/feature-lifecycle/feature-lifecycle-service.test.js +2 -2
  5. package/dist/lib/features/feature-lifecycle/feature-lifecycle-service.test.js.map +1 -1
  6. package/dist/lib/features/feature-lifecycle/feature-lifecycle.e2e.test.js +3 -3
  7. package/dist/lib/features/feature-lifecycle/feature-lifecycle.e2e.test.js.map +1 -1
  8. package/dist/lib/features/metrics/client-metrics/metrics-service-v2.d.ts +1 -1
  9. package/dist/lib/features/metrics/client-metrics/metrics-service-v2.d.ts.map +1 -1
  10. package/dist/lib/features/metrics/client-metrics/metrics-service-v2.js +2 -0
  11. package/dist/lib/features/metrics/client-metrics/metrics-service-v2.js.map +1 -1
  12. package/dist/lib/types/events.d.ts +1 -0
  13. package/dist/lib/types/events.d.ts.map +1 -1
  14. package/dist/lib/types/events.js +5 -4
  15. package/dist/lib/types/events.js.map +1 -1
  16. package/frontend/build/index.html +1 -1
  17. package/frontend/build/static/{AdvancedPlayground-DIV201O4.js → AdvancedPlayground-p7tDUOqb.js} +1 -1
  18. package/frontend/build/static/{CheckCircleOutline-DDRfoMo-.js → CheckCircleOutline-CZoWHYza.js} +1 -1
  19. package/frontend/build/static/{CreateProject-CP51S2Nl.js → CreateProject-DhmoT0x8.js} +1 -1
  20. package/frontend/build/static/{FeatureMetricsChart-C22E7CHm.js → FeatureMetricsChart-CrJhmvRS.js} +1 -1
  21. package/frontend/build/static/{FeatureStaleDialog-CYuAeCFM.js → FeatureStaleDialog-z-UTple3.js} +1 -1
  22. package/frontend/build/static/{FeatureViewLazyExport-Bk1x90Kb.js → FeatureViewLazyExport-BOJHJp48.js} +2 -2
  23. package/frontend/build/static/{LazyAdminExport-Bq-oujr9.js → LazyAdminExport-BfaFcAaS.js} +2 -2
  24. package/frontend/build/static/{LazyProjectExport-DkbRhMrD.js → LazyProjectExport-DbkNqnlj.js} +13 -13
  25. package/frontend/build/static/{LineChartComponent-DvXrMkk5.js → LineChartComponent-CLaoKci9.js} +1 -1
  26. package/frontend/build/static/{NetworkOverview-D6owvVGW.js → NetworkOverview-Cq83oqfi.js} +1 -1
  27. package/frontend/build/static/{NetworkTraffic-D1BTTyb9.js → NetworkTraffic-Bt6v3FUz.js} +1 -1
  28. package/frontend/build/static/{NetworkTrafficUsage-BzhZdcFn.js → NetworkTrafficUsage-Dv8h54l9.js} +1 -1
  29. package/frontend/build/static/{ProjectForm-DAM_SI2w.js → ProjectForm-CrLtsMQu.js} +1 -1
  30. package/frontend/build/static/{ReactJSONEditor-DDbLRmis.js → ReactJSONEditor-C-nON7ak.js} +1 -1
  31. package/frontend/build/static/{RoleCell-C3ZKNTZg.js → RoleCell-6hhnTvjl.js} +1 -1
  32. package/frontend/build/static/{StrategyItemContainer-HujAs_3i.js → StrategyItemContainer-BDY93O1W.js} +1 -1
  33. package/frontend/build/static/{index-C5Of-pcr.js → index-DZdOsPxT.js} +1 -1
  34. package/frontend/build/static/{index-CamDenZi.js → index-lGwH-xa2.js} +6 -6
  35. package/frontend/build/static/{unknownify-Cate6SHg.js → unknownify-D-iKcXLX.js} +1 -1
  36. package/frontend/build/static/{useApiTokens-DSkTQEX_.js → useApiTokens-BhaMXLXr.js} +1 -1
  37. package/package.json +1 -1
@@ -1 +1 @@
1
- import{w as r,x as t,j as a}from"./index-CamDenZi.js";var e={},u=t;Object.defineProperty(e,"__esModule",{value:!0});var l=e.default=void 0,i=u(r()),o=a,s=(0,i.default)((0,o.jsx)("path",{d:"M16.59 7.58 10 14.17l-3.59-3.58L5 12l5 5 8-8zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}),"CheckCircleOutline");l=e.default=s;export{l as d};
1
+ import{w as r,x as t,j as a}from"./index-lGwH-xa2.js";var e={},u=t;Object.defineProperty(e,"__esModule",{value:!0});var l=e.default=void 0,i=u(r()),o=a,s=(0,i.default)((0,o.jsx)("path",{d:"M16.59 7.58 10 14.17l-3.59-3.58L5 12l5 5 8-8zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}),"CheckCircleOutline");l=e.default=s;export{l as d};
@@ -1,4 +1,4 @@
1
- import{s as w,h as F,c as O,c5 as b,b8 as B,b9 as D,ba as J,ak as L,gF as K,j as e,d_ as $,fa as M,ce as q,dC as z,hy as G,gH as H,f as Y,dE as Q}from"./index-CamDenZi.js";import{P as V}from"./ProjectForm-DAM_SI2w.js";const W="CREATE_PROJECT_BTN",X=w(F)(({theme:o})=>({marginLeft:o.spacing(3)})),te=()=>{const{setToastData:o,setToastApiError:l}=O(),{refetchUser:u}=b(),{uiConfig:p}=B(),t=D("newCreateProjectUI"),r=J(),{trackEvent:s}=L(),{projectId:m,projectName:P,projectDesc:C,projectMode:c,setProjectMode:f,setProjectId:E,setProjectName:g,setProjectDesc:h,getCreateProjectPayload:n,clearErrors:i,validateProjectId:d,validateName:T,setProjectStickiness:N,projectStickiness:j,errors:_}=K();if(t)return e.jsx($,{to:"/projects?create=true",replace:!0});const{createProject:y,loading:I}=M(),A=async S=>{S.preventDefault(),i();const x=T(),R=t||await d();if(x&&R){const U=n({omitId:t});try{const a=await y(U);u(),r(`/projects/${a.id}`,{replace:!0}),o({title:"Project created",text:"Now you can add flags to this project",confetti:!0,type:"success"}),j!==H&&s("project_stickiness_set"),s("project-mode",{props:{mode:c,action:"added"}})}catch(a){l(Y(a))}}},k=()=>`curl --location --request POST '${p.unleashUrl}/api/admin/projects' \\
1
+ import{s as w,h as F,c as O,c5 as b,b8 as B,b9 as D,ba as J,ak as L,gF as K,j as e,d_ as $,fa as M,ce as q,dC as z,hy as G,gH as H,f as Y,dE as Q}from"./index-lGwH-xa2.js";import{P as V}from"./ProjectForm-CrLtsMQu.js";const W="CREATE_PROJECT_BTN",X=w(F)(({theme:o})=>({marginLeft:o.spacing(3)})),te=()=>{const{setToastData:o,setToastApiError:l}=O(),{refetchUser:u}=b(),{uiConfig:p}=B(),t=D("newCreateProjectUI"),r=J(),{trackEvent:s}=L(),{projectId:m,projectName:P,projectDesc:C,projectMode:c,setProjectMode:f,setProjectId:E,setProjectName:g,setProjectDesc:h,getCreateProjectPayload:n,clearErrors:i,validateProjectId:d,validateName:T,setProjectStickiness:N,projectStickiness:j,errors:_}=K();if(t)return e.jsx($,{to:"/projects?create=true",replace:!0});const{createProject:y,loading:I}=M(),A=async S=>{S.preventDefault(),i();const x=T(),R=t||await d();if(x&&R){const U=n({omitId:t});try{const a=await y(U);u(),r(`/projects/${a.id}`,{replace:!0}),o({title:"Project created",text:"Now you can add flags to this project",confetti:!0,type:"success"}),j!==H&&s("project_stickiness_set"),s("project-mode",{props:{mode:c,action:"added"}})}catch(a){l(Y(a))}}},k=()=>`curl --location --request POST '${p.unleashUrl}/api/admin/projects' \\
2
2
  --header 'Authorization: INSERT_API_KEY' \\
3
3
  --header 'Content-Type: application/json' \\
4
4
  --data-raw '${JSON.stringify(n({omitId:t}),void 0,2)}'`,v=()=>{r(Q)};return e.jsx(q,{loading:I,title:"Create project",description:"Projects allows you to group feature flags together in the management UI.",documentationLink:"https://docs.getunleash.io/reference/projects",documentationLinkLabel:"Projects documentation",formatApiCode:k,children:e.jsxs(V,{errors:_,handleSubmit:A,projectId:m,setProjectId:E,projectName:P,projectStickiness:j,projectMode:c,setProjectMode:f,setProjectStickiness:N,setProjectName:g,projectDesc:C,setProjectDesc:h,mode:"Create",clearErrors:i,validateProjectId:d,children:[e.jsx(z,{name:"project",permission:G,"data-testid":W}),e.jsx(X,{onClick:v,children:"Cancel"})]})})};export{te as default};
@@ -1,2 +1,2 @@
1
- import{hJ as c,d0 as m,hK as u,bf as x,a as f,bb as g,r as d,j as b,hA as C,hB as h,hC as v,hD as M,hE as S,hF as q,hH as D,hG as E,hL as L}from"./index-CamDenZi.js";import{L as T}from"./index-C5Of-pcr.js";import{d as $}from"./FeatureViewLazyExport-Bk1x90Kb.js";import"./FeatureStaleDialog-CYuAeCFM.js";import"./StrategyItemContainer-HujAs_3i.js";const j=(e,l,s)=>{const a={label:"Total requests",borderColor:e.palette.primary.main,backgroundColor:e.palette.primary.main,data:p(l,s,o=>o.yes+o.no),elements:{point:{radius:6,pointStyle:"circle"},line:{borderDash:[8,4]}}},t={label:"Exposed",borderColor:e.palette.success.main,backgroundColor:e.palette.success.main,data:p(l,s,o=>o.yes),elements:{point:{radius:6,pointStyle:"triangle"}}},r={label:"Not exposed",borderColor:e.palette.error.main,backgroundColor:e.palette.error.main,data:p(l,s,o=>o.no),elements:{point:{radius:6,pointStyle:"triangle",pointRotation:180}}};return{datasets:[t,r,a]}},p=(e,l,s)=>e.map(a=>({x:a.timestamp,y:s(a),variants:a.variants||{}})),k=(e,l)=>{if(l===0)return"";const[s,a]=e,t=Math.floor(Number(a)/l*100);return`${a} (${t}%) - ${s}`},H=(e,l,s,a)=>({locale:a.locale,responsive:!0,maintainAspectRatio:!1,interaction:{mode:"index",intersect:!1},color:e.palette.text.secondary,plugins:{tooltip:{backgroundColor:e.palette.background.paper,bodyColor:e.palette.text.primary,titleColor:e.palette.text.secondary,borderColor:e.palette.primary.main,borderWidth:1,padding:10,boxPadding:5,usePointStyle:!0,itemSort:(t,r)=>{const o=["Total requests","Exposed","Not exposed"],n=o.indexOf(t.dataset.label),i=o.indexOf(r.dataset.label);return n-i},callbacks:{label:t=>`${t.formattedValue} - ${t.dataset.label}`,afterLabel:t=>{const r=t.dataset.data[t.dataIndex];if(t.dataset.label!=="Exposed"||r.variants===void 0)return"";const{disabled:o,...n}=r.variants;return Object.entries(n).map(i=>k(i,r.y)).join(`
1
+ import{hJ as c,d0 as m,hK as u,bf as x,a as f,bb as g,r as d,j as b,hA as C,hB as h,hC as v,hD as M,hE as S,hF as q,hH as D,hG as E,hL as L}from"./index-lGwH-xa2.js";import{L as T}from"./index-DZdOsPxT.js";import{d as $}from"./FeatureViewLazyExport-BOJHJp48.js";import"./FeatureStaleDialog-z-UTple3.js";import"./StrategyItemContainer-BDY93O1W.js";const j=(e,l,s)=>{const a={label:"Total requests",borderColor:e.palette.primary.main,backgroundColor:e.palette.primary.main,data:p(l,s,o=>o.yes+o.no),elements:{point:{radius:6,pointStyle:"circle"},line:{borderDash:[8,4]}}},t={label:"Exposed",borderColor:e.palette.success.main,backgroundColor:e.palette.success.main,data:p(l,s,o=>o.yes),elements:{point:{radius:6,pointStyle:"triangle"}}},r={label:"Not exposed",borderColor:e.palette.error.main,backgroundColor:e.palette.error.main,data:p(l,s,o=>o.no),elements:{point:{radius:6,pointStyle:"triangle",pointRotation:180}}};return{datasets:[t,r,a]}},p=(e,l,s)=>e.map(a=>({x:a.timestamp,y:s(a),variants:a.variants||{}})),k=(e,l)=>{if(l===0)return"";const[s,a]=e,t=Math.floor(Number(a)/l*100);return`${a} (${t}%) - ${s}`},H=(e,l,s,a)=>({locale:a.locale,responsive:!0,maintainAspectRatio:!1,interaction:{mode:"index",intersect:!1},color:e.palette.text.secondary,plugins:{tooltip:{backgroundColor:e.palette.background.paper,bodyColor:e.palette.text.primary,titleColor:e.palette.text.secondary,borderColor:e.palette.primary.main,borderWidth:1,padding:10,boxPadding:5,usePointStyle:!0,itemSort:(t,r)=>{const o=["Total requests","Exposed","Not exposed"],n=o.indexOf(t.dataset.label),i=o.indexOf(r.dataset.label);return n-i},callbacks:{label:t=>`${t.formattedValue} - ${t.dataset.label}`,afterLabel:t=>{const r=t.dataset.data[t.dataIndex];if(t.dataset.label!=="Exposed"||r.variants===void 0)return"";const{disabled:o,...n}=r.variants;return Object.entries(n).map(i=>k(i,r.y)).join(`
2
2
  `)},title:t=>`Time: ${s>48?m(t[0].parsed.x,a.locale,"UTC"):u(t[0].parsed.x,a.locale)}`}},legend:{position:"top",align:"end",labels:{boxWidth:10,boxHeight:10,usePointStyle:!0}},title:{text:O(s),position:"top",align:"start",display:!0,font:{size:16,weight:"400"},color:e.palette.text.primary}},scales:{y:{type:"linear",title:{display:!0,text:"Number of requests",color:e.palette.text.secondary},suggestedMin:0,ticks:{precision:0,color:e.palette.text.secondary},grid:{color:e.palette.divider,borderColor:e.palette.divider}},x:{type:"time",time:{unit:s>48?"day":"hour"},grid:{display:!1},ticks:{callback:(t,r,o)=>s>48?x(o[r].value,a.locale,"UTC"):u(o[r].value,a.locale),color:e.palette.text.secondary}}}}),O=e=>e===1?"Requests in the last hour":`Requests in the last ${$(e)}`;c.font={...c.font,family:"Sen",size:13,weight:"400"};const A=({metrics:e,hoursBack:l,statsSectionId:s})=>{const a=f(),{locationSettings:t}=g(),r=d.useMemo(()=>[...e].sort((i,y)=>i.timestamp.localeCompare(y.timestamp)),[e]),o=d.useMemo(()=>H(a,r,l,t),[a,r,l,t]),n=d.useMemo(()=>j(a,r,t),[a,r,t]);return b.jsx("div",{style:{height:400},children:b.jsx(T,{options:o,data:n,"aria-label":"A feature metrics line chart, with three lines: all requests, positive requests, and negative requests.","aria-describedby":s})})};C.register(h,v,M,S,q,D,E,L);export{A as FeatureMetricsChart,A as default};
@@ -1,4 +1,4 @@
1
- import{w as M,x as H,j as e,c4 as ke,b5 as z,b7 as he,aN as _,C as S,K as V,T,aM as L,aV as pe,aW as ge,c as B,cC as J,fa as K,aT as fe,aU as I,f as O,r as v,fK as me,fL as ve,s as $,A as Q,aP as xe,k as X,aQ as je,aR as be,hf as Re,ak as Z,B as Y,eI as $e,hg as W,eJ as G,aJ as ee,cW as Pe,a as ye,cS as re,cH as De,cA as Ve,hh as Oe,cQ as qe,cV as ie,b3 as N,cU as Fe,c3 as _e,cT as Be,hi as Le,bU as Ne,ca as Se,ba as Te,b8 as Ce,hj as Me,hk as He,hl as ze,hm as Ue,hn as We,h as Ge,ho as Ye,da as we,c7 as Je,cb as Ke,c9 as Ie,ce as Qe,bK as Xe,c1 as Ze,hp as et,ai as tt,fc as at,hq as nt,aK as st,be as oe,hr as rt,hs as it,ht as ot,fq as lt,cF as ct,hu as dt,u as ut,b6 as ht,bk as pt}from"./index-CamDenZi.js";var te={},gt=H;Object.defineProperty(te,"__esModule",{value:!0});var ft=te.default=void 0,mt=gt(M()),vt=e,xt=(0,mt.default)((0,vt.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");ft=te.default=xt;var ae={},jt=H;Object.defineProperty(ae,"__esModule",{value:!0});var bt=ae.default=void 0,yt=jt(M()),St=e,Tt=(0,yt.default)((0,St.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");bt=ae.default=Tt;var ne={},Ct=H;Object.defineProperty(ne,"__esModule",{value:!0});var wt=ne.default=void 0,At=Ct(M()),Et=e,kt=(0,At.default)((0,Et.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");wt=ne.default=kt;const Rt=t=>fetch(t).then(he("ChangeRequest")).then(a=>a.json()),$t=(t,a)=>{const i=a.map(r=>`feature=${r}`).join("&"),{data:n,error:s,mutate:l}=ke([],z(`api/admin/projects/${t}/change-requests/scheduled?${i}`),Rt);return{changeRequests:n,loading:!s&&!n,refetch:l,error:s}},le=()=>e.jsx(V,{severity:"warning",sx:{m:t=>t.spacing(2,0)},children:"Archiving features with dependencies will also remove those dependencies."}),Pt=({ids:t,projectId:a})=>{const i=n=>`/projects/${a}/features/${n}`;return t?e.jsxs(V,{severity:"warning",sx:{m:n=>n.spacing(2,0)},children:[e.jsx(T,{fontWeight:"bold",variant:"body2",display:"inline",children:`${t.length} feature flags `}),e.jsx("span",{children:"have usage from applications. If you archive these feature flags they will not be available to Client SDKs:"}),e.jsx("ul",{children:t==null?void 0:t.map(n=>e.jsx("li",{children:e.jsx(L,{to:i(n),children:n})},n))})]}):null},ce=({ids:t,projectId:a})=>{const i=n=>`/projects/${a}/features/${n}`;return t&&t.length>1?e.jsxs(V,{severity:"error",sx:{m:n=>n.spacing(2,0)},children:[e.jsx(T,{fontWeight:"bold",variant:"body2",display:"inline",children:`${t.length} feature flags `}),e.jsx("span",{children:"have child features that depend on them and are not part of the archive operation. These parent features can not be archived:"}),e.jsx("ul",{children:t==null?void 0:t.map(n=>e.jsx("li",{children:e.jsx(L,{to:i(n),children:n})},n))})]}):t&&t.length===1?e.jsxs(V,{severity:"error",sx:{m:n=>n.spacing(2,0)},children:[e.jsx(L,{to:i(t[0]),children:t[0]})," has child features that depend on it and are not part of the archive operation."]}):null},de=({changeRequests:t,projectId:a})=>t&&t.length>0?e.jsxs(V,{severity:"warning",sx:{m:i=>i.spacing(2,0)},children:[e.jsxs("p",{children:["This archive operation would conflict with"," ",t.length," scheduled change request(s). The change request(s) that would be affected by this are:"]}),e.jsx("ul",{children:t.map(({id:i,title:n})=>{const s=n?`#${i} (${n})`:`Change request #${i}`;return e.jsx("li",{children:e.jsx(L,{to:`/projects/${a}/change-requests/${i}`,target:"_blank",rel:"noopener noreferrer",title:`Change request ${i}`,children:s})},i)})})]}):t===void 0?e.jsx(V,{severity:"warning",children:e.jsx("p",{children:"This archive operation might conflict with one or more scheduled change requests. If you complete it, those change requests can no longer be applied."})}):null,Dt=(t,a)=>{const n=pe(t)(),{isChangeRequestConfiguredForReview:s}=ge(t);return n&&s(n)&&a?"Add to change request":n&&s(n)?"Add change to draft":a?"Archive flags":"Archive flag"},Vt=({projectId:t,featureIds:a,onSuccess:i,onError:n})=>{const{setToastData:s,setToastApiError:l}=B(),{archiveFeatureToggle:r}=J(),{archiveFeatures:d}=K(),{isChangeRequestConfiguredForReview:h}=ge(t),{addChange:g}=fe(),{refetch:f}=I(t),p=pe(t),c=(a==null?void 0:a.length)>1,o=p(),m=async()=>{if(!o){console.error("No change request environment");return}await g(t,o,a.map(k=>({action:"archiveFeature",feature:k,payload:void 0}))),f(),s({text:c?"Your archive feature flags changes have been added to change request":"Your archive feature flag change has been added to change request",type:"success",title:c?"Changes added to a draft":"Change added to a draft"})},x=async()=>{await r(t,a[0]),s({text:"Your feature flag has been archived",type:"success",title:"Feature archived"})},w=async()=>{await d(t,a),s({text:"Selected feature flags have been archived",type:"success",title:"Features archived"})};return async()=>{try{o&&h(o)?await m():c?await w():await x(),i()}catch(k){l(O(k)),n()}}},Ot=(t,a,i)=>{const[n,s]=v.useState(!0),[l,r]=v.useState([]),[d,h]=v.useState(!1),{verifyArchiveFeatures:g}=K();return v.useEffect(()=>{i&&g(a,t).then(f=>f.json()).then(({hasDeletedDependencies:f,parentsWithChildFeatures:p})=>{p.length===0?(s(!1),r(p)):(s(!0),r(p)),h(f)})},[JSON.stringify(t),i,a,r,s,h]),{disableArchive:n,offendingParents:l,hasDeletedDependencies:d}},ha=({isOpen:t,onClose:a,onConfirm:i,projectId:n,featureIds:s,featuresWithUsage:l})=>{const r=(s==null?void 0:s.length)>1,d=Dt(n,r),h=r?"Archive feature flags":"Archive feature flag",g=Vt({projectId:n,featureIds:s,onSuccess(){i(),a()},onError(){a()}}),{changeRequests:f}=$t(n,s),{disableArchive:p,offendingParents:c,hasDeletedDependencies:o}=Ot(s,n,t),m=c.length===0&&o;return e.jsx(_,{onClick:g,open:t,onClose:a,primaryButtonText:d,secondaryButtonText:"Cancel",title:h,disabledPrimaryButton:p,children:e.jsx(S,{condition:r,show:e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Are you sure you want to archive"," ",e.jsx("strong",{children:s==null?void 0:s.length})," feature flags?"]}),e.jsx(S,{condition:!!(l&&(l==null?void 0:l.length)>0),show:e.jsx(Pt,{ids:l,projectId:n})}),e.jsx(S,{condition:c.length>0,show:e.jsx(ce,{ids:c,projectId:n})}),e.jsx(S,{condition:m,show:e.jsx(le,{})}),e.jsx(de,{changeRequests:f,projectId:n}),e.jsx(S,{condition:(s==null?void 0:s.length)<=5,show:e.jsx("ul",{children:s==null?void 0:s.map(x=>e.jsx("li",{children:x},x))})})]}),elseShow:e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Are you sure you want to archive"," ",r?"these feature flags":"this feature flag","?"]}),e.jsx(S,{condition:c.length>0,show:e.jsx(ce,{ids:c,projectId:n})}),e.jsx(S,{condition:m,show:e.jsx(le,{})}),e.jsx(de,{changeRequests:f,projectId:n})]})})})},qt=(t,a)=>`/api/admin/projects/${t}/features/${a}/parents`,pa=(t,a)=>{const i=z(qt(t,a)),{data:n,refetch:s,loading:l,error:r}=me(i,()=>ve(i,"Parent Options"));return{parentOptions:n,loading:l,error:r}},Ft=(t,a)=>`/api/admin/projects/${t}/features/${a}/parent-variants`,Ae=(t,a)=>{const i=z(Ft(t,a)),{data:n,refetch:s,loading:l,error:r}=me(i,()=>ve(i,"Parent Variant Options"));return{parentVariantOptions:n||[],loading:l,error:r}},_t=$(Q)(({theme:t})=>({marginTop:t.spacing(2),marginBottom:t.spacing(1.5)})),Bt=({project:t,parent:a,onSelect:i})=>{const{parentVariantOptions:n}=Ae(t,a),s=e.jsx(je,{fontSize:"small"}),l=e.jsx(be,{fontSize:"small"});return e.jsx(_t,{id:"single-variant-options",options:n,renderOption:(r,d,{selected:h})=>e.jsxs("li",{...r,children:[e.jsx(xe,{icon:s,checkedIcon:l,style:{marginRight:8},checked:h}),d]}),renderInput:r=>e.jsx(X,{...r,placeholder:"Select variant"}),fullWidth:!0,onChange:(r,d)=>{i(String(d))}})},ga=({projectId:t,featureId:a,isOpen:i,setIsOpen:n,onComplete:s})=>{const{markFeatureCompleted:l}=Re(),{parentVariantOptions:r}=Ae(t,a),[d,h]=v.useState("kept"),[g,f]=v.useState(void 0),{trackEvent:p}=Z(),c=async()=>{const o=d==="kept-with-variant"?"kept":d;await l(a,t,{status:o,statusValue:g}),n(!1),s(),p("feature-lifecycle",{props:{eventType:"complete",status:o}})};return e.jsx(_,{open:i,title:"Mark completed",onClose:()=>{n(!1)},disabledPrimaryButton:d==="kept-with-variant"&&g===null,onClick:c,primaryButtonText:"Mark completed",secondaryButtonText:"Cancel",children:e.jsxs(Y,{children:[e.jsx(Y,{sx:{mt:2,mb:4},children:"Marking the feature flag as complete does not affect any configuration, but it moves the feature flag into it’s next life cycle stage and is an indication that you have learned what you needed in order to progress with the feature. It serves as a reminder to start cleaning up the feature flag and removing it from the code."}),e.jsx(T,{sx:{mb:2},children:e.jsx("b",{children:"What was the outcome of this feature?"})}),e.jsxs($e,{"aria-label":"selected-value",name:"selected",sx:{gap:o=>o.spacing(.5)},onChange:(o,m)=>{h(m)},children:[e.jsx(W,{value:"kept",legal:{value:"We decided to keep the feature"},control:e.jsx(G,{})},"kept"),e.jsx(W,{value:"discarded",legal:{value:"We decided to discard the feature"},control:e.jsx(G,{})},"discarded"),e.jsx(S,{condition:r.length>0,show:e.jsx(W,{value:"kept-with-variant",legal:{value:"We decided to keep the feature variant",description:"Choose to specify which feature variant will be kept"},control:e.jsx(G,{})},"kept-with-variant")}),e.jsx(S,{condition:r.length>0&&d==="kept-with-variant",show:e.jsx(Bt,{parent:a,project:t,onSelect:o=>{f(o)}})})]})]})})},Lt=({isOpen:t,disabled:a=!1,onConfirm:i,onClose:n,showBanner:s,environment:l,messageComponent:r})=>{const d=ee("projectId"),{data:h}=I(d),{changeRequestInReviewOrApproved:g,alert:f}=Pe(h),p=g(l||""),c=p?"Add to existing change request":"Add suggestion to draft";return e.jsxs(_,{open:t,primaryButtonText:c,secondaryButtonText:"Cancel",disabledPrimaryButton:a,onClick:i,onClose:n,title:"Request changes",fullWidth:!0,children:[e.jsx(S,{condition:p,show:f}),e.jsx(S,{condition:!!s,show:e.jsxs(V,{severity:"info",sx:{mb:2},children:["Change requests feature is enabled for ",l,". 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."]})}),e.jsx(T,{variant:"body2",color:"text.secondary",children:"Your suggestion:"}),r]})},Nt=$("div")({display:"flex",flexDirection:"column"}),Mt=({strategy:t,setStrategy:a,projectId:i,environment:n,editable:s})=>{const{trackEvent:l}=Z(),[r,d]=v.useState([]),h=ye(),g=t!=null&&t.parameters&&"stickiness"in(t==null?void 0:t.parameters)?String(t.parameters.stickiness):"default";v.useEffect(()=>{d((t.variants||[]).map(c=>({...c,new:s||!1,isValid:!0,id:re(),overrides:[]})))},[]),v.useEffect(()=>{a(c=>({...c,variants:r.map(o=>({stickiness:g,name:o.name,weight:o.weight,payload:o.payload,weightType:o.weightType}))}))},[g,JSON.stringify(r)]);const f=(c,o)=>{d(m=>ie(m.map(x=>x.id===o?c:x),1e3))},p=()=>{const c=re();d(o=>[...o,{name:"",weightType:Be.VARIABLE,weight:0,stickiness:g,new:!0,isValid:!1,id:c}]),l("strategy-variants",{props:{eventType:"variant added"}})};return e.jsxs(e.Fragment,{children:[e.jsxs(T,{component:"h3",sx:{m:0,display:"flex",gap:"1ch"},variant:"h3",children:["Variants",e.jsx(De,{htmlTooltip:!0,tooltip:e.jsxs(e.Fragment,{children:[e.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."}),e.jsx(Ve,{target:"_blank",href:"https://docs.getunleash.io/reference/strategy-variants",children:"Learn more"})]})})]}),e.jsxs(Nt,{children:[e.jsx(Oe,{}),r.map((c,o)=>e.jsx(qe,{disableOverrides:!0,variant:c,variants:r,updateVariant:m=>f(m,c.id),removeVariant:()=>d(m=>ie(m.filter(x=>x.id!==c.id),1e3)),decorationColor:h.palette.variants[o%h.palette.variants.length]},c.id))]}),e.jsx(N,{onClick:p,variant:"outlined",permission:Fe,projectId:i,environmentId:n,"data-testid":"ADD_STRATEGY_VARIANT_BUTTON",children:"Add variant"}),e.jsx(_e,{variants:r})]})},Ht=$("form")(({theme:t})=>({display:"grid",gap:t.spacing(2)})),ue=$("hr")(({theme:t})=>({width:"100%",height:"1px",margin:t.spacing(2,0),border:"none",background:t.palette.background.elevation2})),zt=$("div")(({theme:t})=>({display:"flex",justifyContent:"end",gap:t.spacing(2),paddingBottom:t.spacing(10)})),Ut=({projectId:t,environmentId:a,permission:i,onSubmit:n,onCancel:s,loading:l,strategy:r,setStrategy:d,segments:h,setSegments:g,errors:f})=>{const p=Le(r.constraints),c=Ne(i,t,a),{strategyDefinition:o}=Se(r==null?void 0:r.name),m=Te(),{uiConfig:x,error:w,loading:k}=Ce();if(w)throw w;if(k||!o)return null;const q=b=>o.parameters.find(C=>C.name===b),A=(b,C)=>{const E=q(b);if(b!=="groupId"){const D=Ye(E,C);return D?(f.setFormError(b,D),!1):(f.removeFormError(b),!0)}return!0},u=()=>o.parameters.map(b=>b.name).map(b=>{var C;return A(b,(C=r.parameters)==null?void 0:C[b])}).every(Boolean),P=()=>{m(`/projects/${t}/settings/default-strategy`)},F=async b=>{if(b.preventDefault(),u())n();else return};return e.jsxs(Ht,{onSubmit:F,children:[e.jsx(Me,{title:r.title||"",setTitle:b=>{d(C=>({...C,title:b}))}}),e.jsx(He,{segments:h,setSegments:g,projectId:t}),e.jsx(ze,{projectId:t,environmentId:a,strategy:r,setStrategy:d}),e.jsx(ue,{}),e.jsx(Ue,{strategy:r,strategyDefinition:o,setStrategy:d,validateParameter:A,errors:f,hasAccess:c}),e.jsx(S,{condition:r.parameters!=null&&"stickiness"in r.parameters,show:e.jsx(Mt,{strategy:r,setStrategy:d,environment:a,projectId:t})}),e.jsx(ue,{}),e.jsxs(zt,{children:[e.jsx(N,{permission:i,projectId:t,environmentId:a,variant:"contained",color:"primary",type:"submit",disabled:l||!p||f.hasFormErrors(),"data-testid":We,children:"Save strategy"}),e.jsx(Ge,{type:"button",color:"primary",onClick:s||P,disabled:l,children:"Cancel"})]})]})},Wt=(t,a)=>{var r;const{project:i,refetch:n}=we(t),s={name:"flexibleRollout",constraints:[],parameters:{rollout:"100",stickiness:i.defaultStickiness||"default",groupId:""}},l=(r=i.environments.find(d=>d.environment===a))==null?void 0:r.defaultStrategy;return{defaultStrategyFallback:s,strategy:l,refetch:n}},fa=()=>{const t=ee("projectId"),a=Je("environmentId"),{refetch:i}=we(t),{defaultStrategyFallback:n,strategy:s,refetch:l}=Wt(t,a),[r,d]=v.useState(s||n),[h,g]=v.useState([]),{updateDefaultStrategy:f,loading:p}=K(),{strategyDefinition:c}=Se(r==null?void 0:r.name),{setToastData:o,setToastApiError:m}=B(),x=Ke(),{uiConfig:w}=Ce(),{unleashUrl:k}=w,q=Te(),{trackEvent:A}=Z(),{segments:u,refetchSegments:P}=Ie();v.useEffect(()=>{if(u&&(s!=null&&s.segments)){const E=[];for(const D of s==null?void 0:s.segments)E.push(...u.filter(y=>y.id===D));g(E)}},[JSON.stringify(u),JSON.stringify(s==null?void 0:s.segments)]);const F=Gt(r,h),b=async E=>{await f(t,a,E),A("default_strategy",{props:{action:"edit",hasTitle:!!E.title}}),P(),i(),o({title:"Default Strategy updated",type:"success",confetti:!0})},C=async()=>{const E=`/projects/${t}/settings/default-strategy`;try{await b(F),await l(),q(E)}catch(D){m(O(D))}};return!c||!r?null:e.jsx(Qe,{modal:!0,title:Xe((r==null?void 0:r.name)??""),description:Jt,documentationLink:Kt,documentationLinkLabel:It,formatApiCode:()=>Yt(t,a,F,c,k),children:e.jsx(Ut,{projectId:t,strategy:r,setStrategy:d,segments:h,setSegments:g,environmentId:a,onSubmit:C,loading:p,permission:Ze,errors:x,isChangeRequest:!1})})},Gt=(t,a)=>({name:t.name,title:t.title,constraints:t.constraints??[],parameters:t.parameters??{},variants:t.variants??[],segments:a.map(i=>i.id),disabled:t.disabled??!1}),Yt=(t,a,i,n,s)=>{if(!s)return"";const l={...i,parameters:et(i.parameters??{},n)},r=`${s}/api/admin/projects/${t}/environments/${a}/default-strategy}`,d=JSON.stringify(l,void 0,2);return`curl --location --request PUT '${r}' \\
1
+ import{w as M,x as H,j as e,c4 as ke,b5 as z,b7 as he,aN as _,C as S,K as V,T,aM as L,aV as pe,aW as ge,c as B,cC as J,fa as K,aT as fe,aU as I,f as O,r as v,fK as me,fL as ve,s as $,A as Q,aP as xe,k as X,aQ as je,aR as be,hf as Re,ak as Z,B as Y,eI as $e,hg as W,eJ as G,aJ as ee,cW as Pe,a as ye,cS as re,cH as De,cA as Ve,hh as Oe,cQ as qe,cV as ie,b3 as N,cU as Fe,c3 as _e,cT as Be,hi as Le,bU as Ne,ca as Se,ba as Te,b8 as Ce,hj as Me,hk as He,hl as ze,hm as Ue,hn as We,h as Ge,ho as Ye,da as we,c7 as Je,cb as Ke,c9 as Ie,ce as Qe,bK as Xe,c1 as Ze,hp as et,ai as tt,fc as at,hq as nt,aK as st,be as oe,hr as rt,hs as it,ht as ot,fq as lt,cF as ct,hu as dt,u as ut,b6 as ht,bk as pt}from"./index-lGwH-xa2.js";var te={},gt=H;Object.defineProperty(te,"__esModule",{value:!0});var ft=te.default=void 0,mt=gt(M()),vt=e,xt=(0,mt.default)((0,vt.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");ft=te.default=xt;var ae={},jt=H;Object.defineProperty(ae,"__esModule",{value:!0});var bt=ae.default=void 0,yt=jt(M()),St=e,Tt=(0,yt.default)((0,St.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");bt=ae.default=Tt;var ne={},Ct=H;Object.defineProperty(ne,"__esModule",{value:!0});var wt=ne.default=void 0,At=Ct(M()),Et=e,kt=(0,At.default)((0,Et.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");wt=ne.default=kt;const Rt=t=>fetch(t).then(he("ChangeRequest")).then(a=>a.json()),$t=(t,a)=>{const i=a.map(r=>`feature=${r}`).join("&"),{data:n,error:s,mutate:l}=ke([],z(`api/admin/projects/${t}/change-requests/scheduled?${i}`),Rt);return{changeRequests:n,loading:!s&&!n,refetch:l,error:s}},le=()=>e.jsx(V,{severity:"warning",sx:{m:t=>t.spacing(2,0)},children:"Archiving features with dependencies will also remove those dependencies."}),Pt=({ids:t,projectId:a})=>{const i=n=>`/projects/${a}/features/${n}`;return t?e.jsxs(V,{severity:"warning",sx:{m:n=>n.spacing(2,0)},children:[e.jsx(T,{fontWeight:"bold",variant:"body2",display:"inline",children:`${t.length} feature flags `}),e.jsx("span",{children:"have usage from applications. If you archive these feature flags they will not be available to Client SDKs:"}),e.jsx("ul",{children:t==null?void 0:t.map(n=>e.jsx("li",{children:e.jsx(L,{to:i(n),children:n})},n))})]}):null},ce=({ids:t,projectId:a})=>{const i=n=>`/projects/${a}/features/${n}`;return t&&t.length>1?e.jsxs(V,{severity:"error",sx:{m:n=>n.spacing(2,0)},children:[e.jsx(T,{fontWeight:"bold",variant:"body2",display:"inline",children:`${t.length} feature flags `}),e.jsx("span",{children:"have child features that depend on them and are not part of the archive operation. These parent features can not be archived:"}),e.jsx("ul",{children:t==null?void 0:t.map(n=>e.jsx("li",{children:e.jsx(L,{to:i(n),children:n})},n))})]}):t&&t.length===1?e.jsxs(V,{severity:"error",sx:{m:n=>n.spacing(2,0)},children:[e.jsx(L,{to:i(t[0]),children:t[0]})," has child features that depend on it and are not part of the archive operation."]}):null},de=({changeRequests:t,projectId:a})=>t&&t.length>0?e.jsxs(V,{severity:"warning",sx:{m:i=>i.spacing(2,0)},children:[e.jsxs("p",{children:["This archive operation would conflict with"," ",t.length," scheduled change request(s). The change request(s) that would be affected by this are:"]}),e.jsx("ul",{children:t.map(({id:i,title:n})=>{const s=n?`#${i} (${n})`:`Change request #${i}`;return e.jsx("li",{children:e.jsx(L,{to:`/projects/${a}/change-requests/${i}`,target:"_blank",rel:"noopener noreferrer",title:`Change request ${i}`,children:s})},i)})})]}):t===void 0?e.jsx(V,{severity:"warning",children:e.jsx("p",{children:"This archive operation might conflict with one or more scheduled change requests. If you complete it, those change requests can no longer be applied."})}):null,Dt=(t,a)=>{const n=pe(t)(),{isChangeRequestConfiguredForReview:s}=ge(t);return n&&s(n)&&a?"Add to change request":n&&s(n)?"Add change to draft":a?"Archive flags":"Archive flag"},Vt=({projectId:t,featureIds:a,onSuccess:i,onError:n})=>{const{setToastData:s,setToastApiError:l}=B(),{archiveFeatureToggle:r}=J(),{archiveFeatures:d}=K(),{isChangeRequestConfiguredForReview:h}=ge(t),{addChange:g}=fe(),{refetch:f}=I(t),p=pe(t),c=(a==null?void 0:a.length)>1,o=p(),m=async()=>{if(!o){console.error("No change request environment");return}await g(t,o,a.map(k=>({action:"archiveFeature",feature:k,payload:void 0}))),f(),s({text:c?"Your archive feature flags changes have been added to change request":"Your archive feature flag change has been added to change request",type:"success",title:c?"Changes added to a draft":"Change added to a draft"})},x=async()=>{await r(t,a[0]),s({text:"Your feature flag has been archived",type:"success",title:"Feature archived"})},w=async()=>{await d(t,a),s({text:"Selected feature flags have been archived",type:"success",title:"Features archived"})};return async()=>{try{o&&h(o)?await m():c?await w():await x(),i()}catch(k){l(O(k)),n()}}},Ot=(t,a,i)=>{const[n,s]=v.useState(!0),[l,r]=v.useState([]),[d,h]=v.useState(!1),{verifyArchiveFeatures:g}=K();return v.useEffect(()=>{i&&g(a,t).then(f=>f.json()).then(({hasDeletedDependencies:f,parentsWithChildFeatures:p})=>{p.length===0?(s(!1),r(p)):(s(!0),r(p)),h(f)})},[JSON.stringify(t),i,a,r,s,h]),{disableArchive:n,offendingParents:l,hasDeletedDependencies:d}},ha=({isOpen:t,onClose:a,onConfirm:i,projectId:n,featureIds:s,featuresWithUsage:l})=>{const r=(s==null?void 0:s.length)>1,d=Dt(n,r),h=r?"Archive feature flags":"Archive feature flag",g=Vt({projectId:n,featureIds:s,onSuccess(){i(),a()},onError(){a()}}),{changeRequests:f}=$t(n,s),{disableArchive:p,offendingParents:c,hasDeletedDependencies:o}=Ot(s,n,t),m=c.length===0&&o;return e.jsx(_,{onClick:g,open:t,onClose:a,primaryButtonText:d,secondaryButtonText:"Cancel",title:h,disabledPrimaryButton:p,children:e.jsx(S,{condition:r,show:e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Are you sure you want to archive"," ",e.jsx("strong",{children:s==null?void 0:s.length})," feature flags?"]}),e.jsx(S,{condition:!!(l&&(l==null?void 0:l.length)>0),show:e.jsx(Pt,{ids:l,projectId:n})}),e.jsx(S,{condition:c.length>0,show:e.jsx(ce,{ids:c,projectId:n})}),e.jsx(S,{condition:m,show:e.jsx(le,{})}),e.jsx(de,{changeRequests:f,projectId:n}),e.jsx(S,{condition:(s==null?void 0:s.length)<=5,show:e.jsx("ul",{children:s==null?void 0:s.map(x=>e.jsx("li",{children:x},x))})})]}),elseShow:e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Are you sure you want to archive"," ",r?"these feature flags":"this feature flag","?"]}),e.jsx(S,{condition:c.length>0,show:e.jsx(ce,{ids:c,projectId:n})}),e.jsx(S,{condition:m,show:e.jsx(le,{})}),e.jsx(de,{changeRequests:f,projectId:n})]})})})},qt=(t,a)=>`/api/admin/projects/${t}/features/${a}/parents`,pa=(t,a)=>{const i=z(qt(t,a)),{data:n,refetch:s,loading:l,error:r}=me(i,()=>ve(i,"Parent Options"));return{parentOptions:n,loading:l,error:r}},Ft=(t,a)=>`/api/admin/projects/${t}/features/${a}/parent-variants`,Ae=(t,a)=>{const i=z(Ft(t,a)),{data:n,refetch:s,loading:l,error:r}=me(i,()=>ve(i,"Parent Variant Options"));return{parentVariantOptions:n||[],loading:l,error:r}},_t=$(Q)(({theme:t})=>({marginTop:t.spacing(2),marginBottom:t.spacing(1.5)})),Bt=({project:t,parent:a,onSelect:i})=>{const{parentVariantOptions:n}=Ae(t,a),s=e.jsx(je,{fontSize:"small"}),l=e.jsx(be,{fontSize:"small"});return e.jsx(_t,{id:"single-variant-options",options:n,renderOption:(r,d,{selected:h})=>e.jsxs("li",{...r,children:[e.jsx(xe,{icon:s,checkedIcon:l,style:{marginRight:8},checked:h}),d]}),renderInput:r=>e.jsx(X,{...r,placeholder:"Select variant"}),fullWidth:!0,onChange:(r,d)=>{i(String(d))}})},ga=({projectId:t,featureId:a,isOpen:i,setIsOpen:n,onComplete:s})=>{const{markFeatureCompleted:l}=Re(),{parentVariantOptions:r}=Ae(t,a),[d,h]=v.useState("kept"),[g,f]=v.useState(void 0),{trackEvent:p}=Z(),c=async()=>{const o=d==="kept-with-variant"?"kept":d;await l(a,t,{status:o,statusValue:g}),n(!1),s(),p("feature-lifecycle",{props:{eventType:"complete",status:o}})};return e.jsx(_,{open:i,title:"Mark completed",onClose:()=>{n(!1)},disabledPrimaryButton:d==="kept-with-variant"&&g===null,onClick:c,primaryButtonText:"Mark completed",secondaryButtonText:"Cancel",children:e.jsxs(Y,{children:[e.jsx(Y,{sx:{mt:2,mb:4},children:"Marking the feature flag as complete does not affect any configuration, but it moves the feature flag into it’s next life cycle stage and is an indication that you have learned what you needed in order to progress with the feature. It serves as a reminder to start cleaning up the feature flag and removing it from the code."}),e.jsx(T,{sx:{mb:2},children:e.jsx("b",{children:"What was the outcome of this feature?"})}),e.jsxs($e,{"aria-label":"selected-value",name:"selected",sx:{gap:o=>o.spacing(.5)},onChange:(o,m)=>{h(m)},children:[e.jsx(W,{value:"kept",legal:{value:"We decided to keep the feature"},control:e.jsx(G,{})},"kept"),e.jsx(W,{value:"discarded",legal:{value:"We decided to discard the feature"},control:e.jsx(G,{})},"discarded"),e.jsx(S,{condition:r.length>0,show:e.jsx(W,{value:"kept-with-variant",legal:{value:"We decided to keep the feature variant",description:"Choose to specify which feature variant will be kept"},control:e.jsx(G,{})},"kept-with-variant")}),e.jsx(S,{condition:r.length>0&&d==="kept-with-variant",show:e.jsx(Bt,{parent:a,project:t,onSelect:o=>{f(o)}})})]})]})})},Lt=({isOpen:t,disabled:a=!1,onConfirm:i,onClose:n,showBanner:s,environment:l,messageComponent:r})=>{const d=ee("projectId"),{data:h}=I(d),{changeRequestInReviewOrApproved:g,alert:f}=Pe(h),p=g(l||""),c=p?"Add to existing change request":"Add suggestion to draft";return e.jsxs(_,{open:t,primaryButtonText:c,secondaryButtonText:"Cancel",disabledPrimaryButton:a,onClick:i,onClose:n,title:"Request changes",fullWidth:!0,children:[e.jsx(S,{condition:p,show:f}),e.jsx(S,{condition:!!s,show:e.jsxs(V,{severity:"info",sx:{mb:2},children:["Change requests feature is enabled for ",l,". 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."]})}),e.jsx(T,{variant:"body2",color:"text.secondary",children:"Your suggestion:"}),r]})},Nt=$("div")({display:"flex",flexDirection:"column"}),Mt=({strategy:t,setStrategy:a,projectId:i,environment:n,editable:s})=>{const{trackEvent:l}=Z(),[r,d]=v.useState([]),h=ye(),g=t!=null&&t.parameters&&"stickiness"in(t==null?void 0:t.parameters)?String(t.parameters.stickiness):"default";v.useEffect(()=>{d((t.variants||[]).map(c=>({...c,new:s||!1,isValid:!0,id:re(),overrides:[]})))},[]),v.useEffect(()=>{a(c=>({...c,variants:r.map(o=>({stickiness:g,name:o.name,weight:o.weight,payload:o.payload,weightType:o.weightType}))}))},[g,JSON.stringify(r)]);const f=(c,o)=>{d(m=>ie(m.map(x=>x.id===o?c:x),1e3))},p=()=>{const c=re();d(o=>[...o,{name:"",weightType:Be.VARIABLE,weight:0,stickiness:g,new:!0,isValid:!1,id:c}]),l("strategy-variants",{props:{eventType:"variant added"}})};return e.jsxs(e.Fragment,{children:[e.jsxs(T,{component:"h3",sx:{m:0,display:"flex",gap:"1ch"},variant:"h3",children:["Variants",e.jsx(De,{htmlTooltip:!0,tooltip:e.jsxs(e.Fragment,{children:[e.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."}),e.jsx(Ve,{target:"_blank",href:"https://docs.getunleash.io/reference/strategy-variants",children:"Learn more"})]})})]}),e.jsxs(Nt,{children:[e.jsx(Oe,{}),r.map((c,o)=>e.jsx(qe,{disableOverrides:!0,variant:c,variants:r,updateVariant:m=>f(m,c.id),removeVariant:()=>d(m=>ie(m.filter(x=>x.id!==c.id),1e3)),decorationColor:h.palette.variants[o%h.palette.variants.length]},c.id))]}),e.jsx(N,{onClick:p,variant:"outlined",permission:Fe,projectId:i,environmentId:n,"data-testid":"ADD_STRATEGY_VARIANT_BUTTON",children:"Add variant"}),e.jsx(_e,{variants:r})]})},Ht=$("form")(({theme:t})=>({display:"grid",gap:t.spacing(2)})),ue=$("hr")(({theme:t})=>({width:"100%",height:"1px",margin:t.spacing(2,0),border:"none",background:t.palette.background.elevation2})),zt=$("div")(({theme:t})=>({display:"flex",justifyContent:"end",gap:t.spacing(2),paddingBottom:t.spacing(10)})),Ut=({projectId:t,environmentId:a,permission:i,onSubmit:n,onCancel:s,loading:l,strategy:r,setStrategy:d,segments:h,setSegments:g,errors:f})=>{const p=Le(r.constraints),c=Ne(i,t,a),{strategyDefinition:o}=Se(r==null?void 0:r.name),m=Te(),{uiConfig:x,error:w,loading:k}=Ce();if(w)throw w;if(k||!o)return null;const q=b=>o.parameters.find(C=>C.name===b),A=(b,C)=>{const E=q(b);if(b!=="groupId"){const D=Ye(E,C);return D?(f.setFormError(b,D),!1):(f.removeFormError(b),!0)}return!0},u=()=>o.parameters.map(b=>b.name).map(b=>{var C;return A(b,(C=r.parameters)==null?void 0:C[b])}).every(Boolean),P=()=>{m(`/projects/${t}/settings/default-strategy`)},F=async b=>{if(b.preventDefault(),u())n();else return};return e.jsxs(Ht,{onSubmit:F,children:[e.jsx(Me,{title:r.title||"",setTitle:b=>{d(C=>({...C,title:b}))}}),e.jsx(He,{segments:h,setSegments:g,projectId:t}),e.jsx(ze,{projectId:t,environmentId:a,strategy:r,setStrategy:d}),e.jsx(ue,{}),e.jsx(Ue,{strategy:r,strategyDefinition:o,setStrategy:d,validateParameter:A,errors:f,hasAccess:c}),e.jsx(S,{condition:r.parameters!=null&&"stickiness"in r.parameters,show:e.jsx(Mt,{strategy:r,setStrategy:d,environment:a,projectId:t})}),e.jsx(ue,{}),e.jsxs(zt,{children:[e.jsx(N,{permission:i,projectId:t,environmentId:a,variant:"contained",color:"primary",type:"submit",disabled:l||!p||f.hasFormErrors(),"data-testid":We,children:"Save strategy"}),e.jsx(Ge,{type:"button",color:"primary",onClick:s||P,disabled:l,children:"Cancel"})]})]})},Wt=(t,a)=>{var r;const{project:i,refetch:n}=we(t),s={name:"flexibleRollout",constraints:[],parameters:{rollout:"100",stickiness:i.defaultStickiness||"default",groupId:""}},l=(r=i.environments.find(d=>d.environment===a))==null?void 0:r.defaultStrategy;return{defaultStrategyFallback:s,strategy:l,refetch:n}},fa=()=>{const t=ee("projectId"),a=Je("environmentId"),{refetch:i}=we(t),{defaultStrategyFallback:n,strategy:s,refetch:l}=Wt(t,a),[r,d]=v.useState(s||n),[h,g]=v.useState([]),{updateDefaultStrategy:f,loading:p}=K(),{strategyDefinition:c}=Se(r==null?void 0:r.name),{setToastData:o,setToastApiError:m}=B(),x=Ke(),{uiConfig:w}=Ce(),{unleashUrl:k}=w,q=Te(),{trackEvent:A}=Z(),{segments:u,refetchSegments:P}=Ie();v.useEffect(()=>{if(u&&(s!=null&&s.segments)){const E=[];for(const D of s==null?void 0:s.segments)E.push(...u.filter(y=>y.id===D));g(E)}},[JSON.stringify(u),JSON.stringify(s==null?void 0:s.segments)]);const F=Gt(r,h),b=async E=>{await f(t,a,E),A("default_strategy",{props:{action:"edit",hasTitle:!!E.title}}),P(),i(),o({title:"Default Strategy updated",type:"success",confetti:!0})},C=async()=>{const E=`/projects/${t}/settings/default-strategy`;try{await b(F),await l(),q(E)}catch(D){m(O(D))}};return!c||!r?null:e.jsx(Qe,{modal:!0,title:Xe((r==null?void 0:r.name)??""),description:Jt,documentationLink:Kt,documentationLinkLabel:It,formatApiCode:()=>Yt(t,a,F,c,k),children:e.jsx(Ut,{projectId:t,strategy:r,setStrategy:d,segments:h,setSegments:g,environmentId:a,onSubmit:C,loading:p,permission:Ze,errors:x,isChangeRequest:!1})})},Gt=(t,a)=>({name:t.name,title:t.title,constraints:t.constraints??[],parameters:t.parameters??{},variants:t.variants??[],segments:a.map(i=>i.id),disabled:t.disabled??!1}),Yt=(t,a,i,n,s)=>{if(!s)return"";const l={...i,parameters:et(i.parameters??{},n)},r=`${s}/api/admin/projects/${t}/environments/${a}/default-strategy}`,d=JSON.stringify(l,void 0,2);return`curl --location --request PUT '${r}' \\
2
2
  --header 'Authorization: INSERT_API_KEY' \\
3
3
  --header 'Content-Type: application/json' \\
4
4
  --data-raw '${d}'`},Jt=`