unleash-server 6.2.0 → 6.2.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/features/project/can-grant-project-role.d.ts +4 -0
- package/dist/lib/features/project/can-grant-project-role.d.ts.map +1 -0
- package/dist/lib/features/project/can-grant-project-role.js +17 -0
- package/dist/lib/features/project/can-grant-project-role.js.map +1 -0
- package/dist/lib/features/project/can-grant-project-role.test.d.ts +2 -0
- package/dist/lib/features/project/can-grant-project-role.test.d.ts.map +1 -0
- package/dist/lib/features/project/can-grant-project-role.test.js +111 -0
- package/dist/lib/features/project/can-grant-project-role.test.js.map +1 -0
- package/dist/lib/features/project/project-service.d.ts.map +1 -1
- package/dist/lib/features/project/project-service.e2e.test.js +31 -29
- package/dist/lib/features/project/project-service.e2e.test.js.map +1 -1
- package/dist/lib/features/project/project-service.js +13 -1
- package/dist/lib/features/project/project-service.js.map +1 -1
- package/dist/lib/features/project-environments/environments.d.ts.map +1 -1
- package/dist/lib/features/project-environments/environments.js +1 -1
- package/dist/lib/features/project-environments/environments.js.map +1 -1
- package/dist/lib/routes/admin-api/user/user.d.ts +1 -0
- package/dist/lib/routes/admin-api/user/user.d.ts.map +1 -1
- package/dist/lib/routes/admin-api/user/user.js +8 -1
- package/dist/lib/routes/admin-api/user/user.js.map +1 -1
- package/dist/lib/types/experimental.d.ts +1 -1
- package/dist/lib/types/experimental.d.ts.map +1 -1
- package/dist/lib/types/experimental.js +1 -0
- package/dist/lib/types/experimental.js.map +1 -1
- package/frontend/build/index.html +1 -1
- package/frontend/build/static/{AdvancedPlayground-CRj3J15M.js → AdvancedPlayground-CRdeeG3w.js} +1 -1
- package/frontend/build/static/{CreateProject-CoMWBmMC.js → CreateProject-8AyZj2dp.js} +1 -1
- package/frontend/build/static/{FeatureMetricsChart-CJrrWMue.js → FeatureMetricsChart-DEo4WxO1.js} +1 -1
- package/frontend/build/static/FeatureStaleDialog-CrsbH2rq.js +7 -0
- package/frontend/build/static/{FeatureViewLazyExport-CCemx_kk.js → FeatureViewLazyExport-BwY7TYmZ.js} +2 -2
- package/frontend/build/static/{LazyAdminExport-C8Z5ig95.js → LazyAdminExport-0g_UOhr3.js} +2 -2
- package/frontend/build/static/{LazyProjectExport-Dooc4t2t.js → LazyProjectExport-C1eSkT3Z.js} +18 -18
- package/frontend/build/static/LineChartComponent-BLXX5chp.js +1 -0
- package/frontend/build/static/{NetworkOverview-DakM348r.js → NetworkOverview-DqGLVIJ6.js} +1 -1
- package/frontend/build/static/{NetworkTraffic-CfqRQOHm.js → NetworkTraffic-BWFLlaz7.js} +1 -1
- package/frontend/build/static/{NetworkTrafficUsage-BnIFfNNJ.js → NetworkTrafficUsage-BvoBumVR.js} +1 -1
- package/frontend/build/static/{ReactJSONEditor-z4lldZFR.js → ReactJSONEditor-Bvhd5heT.js} +1 -1
- package/frontend/build/static/{RoleCell-BLQYE7NO.js → RoleCell-DGcue0jn.js} +1 -1
- package/frontend/build/static/{StrategyItemContainer-0nEHrvdC.js → StrategyItemContainer-Das6_30A.js} +1 -1
- package/frontend/build/static/{index-DhEaCpkq.js → index-BsIpdLcw.js} +1 -1
- package/frontend/build/static/{index-C5Z6aehP.js → index-Cx91uh9W.js} +17 -17
- package/frontend/build/static/{unknownify-CLPkLMVA.js → unknownify-8qa4PVkQ.js} +1 -1
- package/frontend/build/static/{useApiTokens-DfEYjYPV.js → useApiTokens-5JgqgHim.js} +1 -1
- package/package.json +1 -1
- package/frontend/build/static/FeatureStaleDialog-Yc2Yc4V5.js +0 -7
- package/frontend/build/static/LineChartComponent-BxkVmXGQ.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bj as r,b5 as a,r as o,b7 as c}from"./index-
|
|
1
|
+
import{bj as r,b5 as a,r as o,b7 as c}from"./index-Cx91uh9W.js";const u=(e={})=>{const{data:t,error:n,mutate:s}=r(a("api/admin/metrics/rps"),i,e);return o.useMemo(()=>({metrics:t,loading:!n&&!t,refetch:()=>s(),error:n}),[t,n,s])},i=e=>fetch(e).then(c("Instance Metrics")).then(t=>t.json()),f=e=>!e||e==="undefined"?"unknown":e;export{f as a,u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b5 as i,bj as p,r as n,b7 as u}from"./index-
|
|
1
|
+
import{b5 as i,bj as p,r as n,b7 as u}from"./index-Cx91uh9W.js";const k=(s={})=>{const a=i("api/admin/api-tokens"),{data:t,error:e,mutate:o}=p(a,h,s),r=n.useMemo(()=>t??[],[t]),c=n.useCallback(()=>{o().catch(console.warn)},[o]);return{tokens:r,error:e,loading:!e&&!t,refetch:c}},h=async s=>(await(await fetch(s).then(u("Api tokens"))).json()).tokens;export{k as u};
|
package/package.json
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{x as M,y as H,j as e,c4 as ke,b5 as z,b7 as he,aN as q,C as S,N as V,T,L,aV as pe,aW as ge,e as B,cF as J,fc as K,aT as fe,aU as I,h as F,r as v,fE as me,fF as ve,s as $,A as Q,aP as xe,l as X,aQ as je,aR as be,hP as Re,an as Z,B as Y,eK as $e,hQ as W,eL as G,aK as ee,cZ as Pe,b as ye,cV as re,cK as De,cD as Ve,hR as Fe,cT as Oe,cY as ie,b3 as N,cX as _e,c3 as qe,cW as Be,hS as Le,bU as Ne,ca as Se,ba as Te,b8 as Ce,hT as Me,hU as He,hV as ze,hW as Ue,hX as We,i as Ge,hY as Ye,dd as we,c7 as Je,cb as Ke,c9 as Ie,ce as Qe,bK as Xe,c1 as Ze,hZ as et,al as tt,fe as at,h_ as nt,aL as st,be as oe,h$ as rt,i0 as it,i1 as ot,fH as lt,cI as ct,i2 as dt,u as ut,b6 as ht,bk as pt}from"./index-C5Z6aehP.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(F(k)),n()}}},Ft=(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}=Ft(s,n,t),m=c.length===0&&o;return e.jsx(q,{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})]})})})},Ot=(t,a)=>`/api/admin/projects/${t}/features/${a}/parents`,pa=(t,a)=>{const i=z(Ot(t,a)),{data:n,refetch:s,loading:l,error:r}=me(i,()=>ve(i,"Parent Options"));return{parentOptions:n,loading:l,error:r}},_t=(t,a)=>`/api/admin/projects/${t}/features/${a}/parent-variants`,Ae=(t,a)=>{const i=z(_t(t,a)),{data:n,refetch:s,loading:l,error:r}=me(i,()=>ve(i,"Parent Variant Options"));return{parentVariantOptions:n||[],loading:l,error:r}},qt=$(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(qt,{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(q,{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(q,{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(Fe,{}),r.map((c,o)=>e.jsx(Oe,{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:_e,projectId:i,environmentId:n,"data-testid":"ADD_STRATEGY_VARIANT_BUTTON",children:"Add variant"}),e.jsx(qe,{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 O=b=>o.parameters.find(C=>C.name===b),A=(b,C)=>{const E=O(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`)},_=async b=>{if(b.preventDefault(),u())n();else return};return e.jsxs(Ht,{onSubmit:_,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,O=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 _=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(_),await l(),O(E)}catch(D){m(F(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,_,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
|
-
--header 'Authorization: INSERT_API_KEY' \\
|
|
3
|
-
--header 'Content-Type: application/json' \\
|
|
4
|
-
--data-raw '${d}'`},Jt=`
|
|
5
|
-
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.
|
|
6
|
-
If any of a feature flag's activation strategies returns true, the user will get access.
|
|
7
|
-
`,Kt="https://docs.getunleash.io/reference/projects#project-default-strategy",It="Default strategy documentation",Qt=t=>{const[a,i]=v.useState(t),n=v.useCallback(()=>i(t),[t]);return v.useEffect(()=>{i(t)},[t]),[a,i,n]},Xt=$(Y)(()=>({mx:"auto",...tt})),ma=({projectId:t,featureId:a,environmentName:i,value:n,onToggle:s})=>{const[l,r,d]=Qt(n),h=()=>{r(!l),requestAnimationFrame(()=>{s(!l,d)})},g=`${a}-${i}`;return e.jsx(e.Fragment,{children:e.jsx(Xt,{"data-testid":`TOGGLE-${g}`,children:e.jsx(at,{tooltip:l?`Disable feature in ${i}`:`Enable feature in ${i}`,checked:n,environmentId:i,projectId:t,permission:nt,inputProps:{"aria-label":i},onClick:h,"data-testid":"permission-switch",disableRipple:!0,disabled:n!==l})},g)})},Zt=t=>{const{setToastData:a,setToastApiError:i}=B(),{addChange:n}=fe(),{refetch:s}=I(t),[l,r]=v.useState(!1),[d,h]=v.useState({isOpen:!1}),g=v.useCallback((c,o,m,x)=>{h({featureName:c,environment:o,enabled:m,shouldActivateDisabledStrategies:x,isOpen:!0})},[]),f=v.useCallback(()=>{h(c=>({...c,isOpen:!1}))},[]),p=v.useCallback(async()=>{try{r(!0),await n(t,d.environment,{feature:d.featureName,action:"updateEnabled",payload:{enabled:!!d.enabled,shouldActivateDisabledStrategies:!!d.shouldActivateDisabledStrategies}}),s(),h(c=>({...c,isOpen:!1})),a({type:"success",title:"Changes added to the draft!"})}catch(c){i(F(c)),h(o=>({...o,isOpen:!1}))}finally{r(!1)}},[n]);return{pending:l,onChangeRequestToggle:g,onChangeRequestToggleClose:f,onChangeRequestToggleConfirm:p,changeRequestDialogDetails:d}},ea=({enabled:t,featureName:a,environment:i})=>e.jsxs(T,{"data-testid":"update-enabled-message",children:[e.jsx("strong",{children:t?"Enable":"Disable"})," feature flag"," ",e.jsx("strong",{children:a})," in ",e.jsx("strong",{children:i})]}),ta=$("ul")(({theme:t})=>({margin:t.spacing(1),paddingLeft:t.spacing(2)})),aa=({isOpen:t,onAddDefaultStrategy:a,onActivateDisabledStrategies:i,onClose:n,environment:s,featureId:l})=>{var f,p,c;const r=ee("projectId"),{feature:d}=st(r,l),h=(c=(p=(f=d.environments)==null?void 0:f.find(({name:o})=>o===s))==null?void 0:p.strategies)==null?void 0:c.filter(({disabled:o})=>o).length,g=h?h===1?"1 disabled strategy":`${h} disabled strategies`:"disabled strategies";return e.jsxs(q,{open:t,secondaryButtonText:"Cancel",permissionButton:e.jsxs(e.Fragment,{children:[e.jsx(N,{type:"button",variant:"outlined",permission:oe,projectId:r,environmentId:s,onClick:a,children:"Add default strategy"}),e.jsx(N,{type:"button",variant:"outlined",permission:oe,projectId:r,environmentId:s,onClick:i,children:"Enable all strategies"})]}),onClose:n,title:`Enable feature flag in ${s}`,fullWidth:!0,children:[e.jsx(T,{sx:{mb:o=>o.spacing(3)},children:"A feature flag cannot be enabled without an enabled strategy."}),e.jsx(T,{children:"To enable this feature flag you can choose to:"}),e.jsxs(ta,{children:[e.jsx("li",{children:e.jsx(T,{children:e.jsx("strong",{children:"Add the default strategy"})})}),e.jsx("li",{children:e.jsxs(T,{children:[e.jsx("strong",{children:"Enable all the disabled strategies"})," ","(this feature flag has ",g,")"]})})]})]})},na=t=>{const a=i=>{i<t.length&&t[i](()=>a(i+1))};a(0)},va=t=>{const{toggleFeatureEnvironmentOn:a,toggleFeatureEnvironmentOff:i}=J(),{setToastData:n,setToastApiError:s}=B(),[l,r]=v.useState({open:!1,label:"",loading:!1,onClose:()=>{},onClick:()=>{}}),[d,h]=v.useState({isOpen:!1,environment:"",featureId:"",onClose:()=>{},onActivateDisabledStrategies:()=>{},onAddDefaultStrategy:()=>{}}),{pending:g,onChangeRequestToggle:f,onChangeRequestToggleClose:p,onChangeRequestToggleConfirm:c,changeRequestDialogDetails:o}=Zt(t),[m,x]=v.useState(),w=v.useCallback(async(A,u)=>{let P=!1;return na([y=>{if(u.isChangeRequestEnabled||!it(u.environmentType||""))return y();r({open:!0,label:`${A?"Enable":"Disable"} Environment`,loading:!1,onClose:()=>{var j;r(R=>({...R,open:!1})),(j=u.onRollback)==null||j.call(u)},onClick:()=>{r(j=>({...j,open:!1,loading:!0})),y()}})},y=>{if(A===!1||!u.hasStrategies||u.hasEnabledStrategies)return y();h({isOpen:!0,environment:u.environmentName,featureId:u.featureId,onClose:()=>{var j;h(R=>({...R,isOpen:!1})),(j=u.onRollback)==null||j.call(u)},onActivateDisabledStrategies:()=>{h(j=>({...j,isOpen:!1})),P=!0,y()},onAddDefaultStrategy:()=>{h(j=>({...j,isOpen:!1})),y()}})},y=>{if(!u.isChangeRequestEnabled)return y();x(()=>{var j;x(void 0),(j=u.onRollback)==null||j.call(u)}),f(u.featureId,u.environmentName,A,P)},async y=>{var j,R;if(A!==!1)return y();try{await i(u.projectId,u.featureId,u.environmentName),n({type:"success",title:`Disabled in ${u.environmentName}`,text:`${u.featureId} is unavailable in ${u.environmentName} and its strategies will no longer have any effect.`}),(j=u.onSuccess)==null||j.call(u)}catch(U){s(F(U)),(R=u.onRollback)==null||R.call(u)}},async y=>{var j,R;if(A!==!0)return y();try{await a(u.projectId,u.featureId,u.environmentName,P),n({type:"success",title:`Enabled in ${u.environmentName}`,text:`${u.featureId} is now available in ${u.environmentName} based on its defined strategies.`}),(j=u.onSuccess)==null||j.call(u)}catch(U){s(F(U)),(R=u.onRollback)==null||R.call(u)}}])},[r]),k=d.featureId.length!==0,O=e.jsxs(e.Fragment,{children:[e.jsx(rt,{...l}),e.jsx(S,{condition:k,show:e.jsx(aa,{...d})}),e.jsx(Lt,{isOpen:o.isOpen,onClose:()=>{m==null||m(),p()},environment:o==null?void 0:o.environment,disabled:g,onConfirm:()=>{m==null||m(),c()},messageComponent:e.jsx(ea,{enabled:o==null?void 0:o.enabled,featureName:o==null?void 0:o.featureName,environment:o.environment})})]});return{onToggle:w,modals:O}},sa=$(ot)(({theme:t})=>({color:t.palette.warning.main,fontSize:t.fontSizes.bodySize})),xa=()=>e.jsx(lt,{arrow:!0,title:e.jsxs(e.Fragment,{children:["This environment has no variants enabled. If you check this feature's variants in this environment, you will get the"," ",e.jsx("a",{href:"https://docs.getunleash.io/reference/feature-toggle-variants#the-disabled-variant",target:"_blank",rel:"noreferrer",children:"disabled variant"}),"."]}),children:e.jsx(sa,{})});var se={},ra=H;Object.defineProperty(se,"__esModule",{value:!0});var Ee=se.default=void 0,ia=ra(M()),oa=e,la=(0,ia.default)((0,oa.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");Ee=se.default=la;const ca=dt(),ja=({options:t,selectedOptions:a,indeterminateOptions:i,tagType:n,existingTags:s,disabled:l=!1,onChange:r})=>{const d=e.jsx(je,{fontSize:"small"}),h=p=>p.inputValue?p.inputValue:p.title,g=(p,c,{selected:o})=>{const m=(i==null?void 0:i.some(x=>x.title===c.title))??!1;return e.jsxs("li",{...p,children:[e.jsx(S,{condition:!!c.inputValue,show:e.jsx(ct,{sx:{mr:x=>x.spacing(.5)}}),elseShow:e.jsx(xe,{icon:d,checkedIcon:e.jsx(be,{fontSize:"small"}),indeterminateIcon:e.jsx(Ee,{fontSize:"small"}),sx:{mr:x=>x.spacing(.5)},checked:o&&!m,indeterminate:m})}),c.title]})},f=(p,c)=>{const o=c.inputValue.trim(),m=ca(p,{...c,inputValue:o}),x=p.some(w=>o===w.title);return o.length>=2&&!x&&m.push({inputValue:o,title:`Create new value "${o}"`}),m};return e.jsx(Q,{multiple:!0,id:"checkboxes-tag",sx:{marginTop:p=>p.spacing(2),width:500},disableCloseOnSelect:!0,options:t,value:a,isOptionEqualToValue:(p,c)=>c.inputValue&&c.inputValue!==""?p.title===c.inputValue:p.title===c.title,getOptionLabel:h,renderOption:g,filterOptions:f,ListboxProps:{style:{maxHeight:200,overflow:"auto"}},onChange:r,renderInput:p=>e.jsx(X,{...p,label:"Select values",placeholder:"Select values"}),disabled:l})},da=$("li")({flexDirection:"column"}),ba=({options:t,value:a,disabled:i=!1,onChange:n})=>{const s=ye();return e.jsx(Q,{disablePortal:!0,disabled:i,id:"tag-type-select",sx:{marginTop:l=>l.spacing(2),width:500},options:t,disableClearable:!0,value:a,getOptionLabel:l=>l.name,renderOption:(l,r)=>e.jsxs(da,{...l,style:{alignItems:"flex-start",gap:s.spacing(.5)},children:[e.jsx(T,{variant:"body1",children:r.name}),e.jsx(T,{variant:"caption",children:r.description})]}),renderInput:l=>e.jsx(X,{...l,label:"Tag type",value:a}),onChange:n,ListboxProps:{style:{maxHeight:200,overflow:"auto"}}})},ya=()=>{const{makeRequest:t,createRequest:a,errors:i,loading:n}=ut({propagateErrors:!0});return{createTag:async r=>{const h=a("api/admin/tags",{method:"POST",body:JSON.stringify(r)});return t(h.caller,h.id)},bulkUpdateTags:async(r,d)=>{const h=`api/admin/projects/${d}/tags`,g=a(h,{method:"PUT",body:JSON.stringify(r)});return t(g.caller,g.id)},errors:i,loading:n}},Sa=(t,a={})=>{const i=async()=>{const g=z(`api/admin/tags/${t}`);return(await fetch(g,{method:"GET"}).then(he("Tags"))).json()},n=`api/admin/tags/${t}`,{data:s,error:l}=ht(!!t,{tags:[]},n,i,a),[r,d]=v.useState(!l&&!s),h=()=>{pt(n)};return v.useEffect(()=>{d(!l&&!s)},[s,l]),{tags:(s==null?void 0:s.tags)||[],error:l,loading:r,refetch:h}},Ta=({isStale:t,isOpen:a,projectId:i,featureId:n,onClose:s})=>{const{setToastData:l,setToastApiError:r}=B(),{patchFeatureToggle:d}=J(),h=e.jsx(T,{children:"Setting a flag to stale marks it for cleanup"}),g=e.jsx(T,{children:"Setting a flag to active marks it as in active use"}),f=t?"active":"stale",p=async c=>{c.stopPropagation();try{await d(i,n,[{op:"replace",path:"/stale",value:!t}]),s()}catch(o){r(F(o))}l(t?{type:"success",title:"And we're back!",text:"The flag is no longer marked as stale."}:{type:"success",title:"A job well done.",text:"The flag has been marked as stale."})};return e.jsx(q,{open:a,secondaryButtonText:"Cancel",primaryButtonText:`Flip to ${f}`,title:`Set feature state to ${f}`,onClick:p,onClose:s,children:e.jsx(S,{condition:t,show:g,elseShow:h})})};export{Lt as C,fa as E,ha as F,ga as M,ba as T,xa as V,pa as a,Wt as b,va as c,ma as d,ya as e,Sa as f,ja as g,wt as h,ft as i,bt as j,Ta as k,Ae as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as c,j as a,B as p,E as f,T as y,V as m,b as S,bb as C,r as u,C as h,i7 as j,i8 as I,i9 as v,ia as L,ib as w,ic as k,id as R,ie as z,ig as A}from"./index-C5Z6aehP.js";import{L as B}from"./index-DhEaCpkq.js";const E=c("ul")(({theme:e})=>({listStyle:"none",margin:0,padding:0})),P=c("li")(({theme:e})=>({marginBottom:e.spacing(.5),display:"flex",alignItems:"center"})),T=c("span")(({theme:e})=>({display:"inline-block",width:8,height:8,borderRadius:"50%",marginRight:e.spacing(1)})),g=16,D=e=>e==="left"?"flex-start":e==="right"?"flex-end":"center",Y=(e=0,t)=>t==="left"?e+g:t==="right"?e-g:e,b=({tooltip:e,children:t})=>a.jsx(p,{sx:n=>({top:((e==null?void 0:e.caretY)||0)+g,left:Y(e==null?void 0:e.caretX,e==null?void 0:e.align),width:"1px",position:"absolute",display:e?"flex":"none",pointerEvents:"none",zIndex:n.zIndex.tooltip,flexDirection:"column",alignItems:D(e==null?void 0:e.align)}),children:t}),_=({tooltip:e})=>a.jsx(b,{tooltip:e,children:a.jsxs(f,{elevation:3,sx:t=>({width:220,padding:t.spacing(1.5,2)}),children:[a.jsx(y,{variant:"body2",sx:t=>({marginBottom:t.spacing(1),color:t.palette.text.secondary}),children:e==null?void 0:e.title}),a.jsx(E,{children:e==null?void 0:e.body.map(t=>a.jsxs(P,{children:[a.jsx(T,{sx:{backgroundColor:t.color},children:" "}),a.jsx(y,{variant:"body2",sx:{display:"inline-block"},children:t.title})]},m(t)))})]})}),M=e=>t=>{var s,r;const n=t.tooltip;if(n.opacity===0){e(null);return}e({caretX:n==null?void 0:n.caretX,caretY:n==null?void 0:n.caretY,title:((s=n==null?void 0:n.title)==null?void 0:s.join(" "))||"",align:n==null?void 0:n.xAlign,body:((r=n==null?void 0:n.body)==null?void 0:r.map((i,o)=>{var l,d,x;return{title:(l=i==null?void 0:i.lines)==null?void 0:l.join(" "),color:(x=(d=n==null?void 0:n.labelColors)==null?void 0:d[o])==null?void 0:x.borderColor,value:""}}))||[],dataPoints:(n==null?void 0:n.dataPoints)||[]})},O={position:"bottom",labels:{boxWidth:12,padding:30,generateLabels:e=>{var o;const t=e.data.datasets,{labels:{usePointStyle:n,pointStyle:s,textAlign:r,color:i}}=((o=e==null?void 0:e.legend)==null?void 0:o.options)||{labels:{}};return e._getSortedDatasetMetas().map(l=>{const d=l.controller.getStyle(n?0:void 0);return{text:t[l.index].label,fillStyle:d.borderColor,fontColor:i,hidden:!l.visible,lineWidth:0,borderRadius:6,strokeStyle:d.borderColor,pointStyle:s||d.pointStyle,textAlign:r||d.textAlign,datasetIndex:l.index}})}}},W=(e,t,n,s)=>({responsive:!0,...s?{animation:{duration:0}}:{},plugins:{legend:{...O,display:!s},tooltip:{enabled:!1,position:"nearest",interaction:{axis:"xy",mode:"nearest"},external:M(n)}},locale:t.locale,interaction:{intersect:!1,axis:"xy",mode:"nearest"},elements:{point:{radius:0,hitRadius:15}},tension:.1,color:e.palette.text.secondary,scales:{y:{beginAtZero:!0,type:"linear",grid:{color:e.palette.divider,borderColor:e.palette.divider},ticks:{color:e.palette.text.secondary,display:!s,precision:0}},x:{type:"time",time:{unit:"week",tooltipFormat:"PPP"},grid:{color:"transparent",borderColor:"transparent"},ticks:{color:e.palette.text.secondary,display:!s,source:"data",maxRotation:90,minRotation:23.5}}}}),X=c("div")(({theme:e})=>({position:"relative"})),F=c("div")(({theme:e})=>({position:"absolute",inset:0,display:"flex",zIndex:e.zIndex.appBar,"&::before":{zIndex:e.zIndex.fab,content:'""',position:"absolute",inset:0,backgroundColor:e.palette.background.paper,opacity:.8}})),G=c("div")(({theme:e})=>({zIndex:e.zIndex.modal,margin:"auto",color:e.palette.text.secondary,textAlign:"center"})),H={id:"customLine",afterDraw:e=>{var n;if((n=e.tooltip)!=null&&n.opacity&&e.tooltip.x){const s=e.tooltip.caretX,r=e.scales.y,i=e.ctx;i.save();const o=i.createLinearGradient(s,r.top,s,r.bottom);o.addColorStop(0,"rgba(129, 122, 254, 0)"),o.addColorStop(1,"rgba(129, 122, 254, 0.12)"),i.fillStyle=o,i.fillRect(s-26/2,r.top,26,r.bottom-r.top),i.restore()}}},q=({data:e,aspectRatio:t=2.5,cover:n,overrideOptions:s,TooltipComponent:r})=>{const i=S(),{locationSettings:o}=C(),[l,d]=u.useState(null),x=u.useMemo(()=>({...W(i,o,d,!!n),...s}),[i,o,s,n]);return a.jsxs(X,{children:[a.jsx(B,{options:x,data:e,plugins:[H],height:100,width:100*t},n?"cover":"chart"),a.jsx(h,{condition:!n,show:r?a.jsx(b,{tooltip:l,children:a.jsx(r,{tooltip:l})}):a.jsx(_,{tooltip:l}),elseShow:a.jsx(F,{children:a.jsx(G,{children:n!==!0?n:" "})})})]})};j.register(I,v,L,w,k,R,z,A);export{q as default};
|