unleash-server 7.6.2 → 7.6.3
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/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-BTPrG6RW.js → AdvancedPlayground-D7wyJyhf.js} +1 -1
- package/frontend/build/static/{BackendConnections-CRh8Vxoe.js → BackendConnections-B2fwWxNM.js} +1 -1
- package/frontend/build/static/{CreateProject-DEMalH1j.js → CreateProject-DCsDw61O.js} +1 -1
- package/frontend/build/static/{EnterpriseEdge-Cp-pGMa0.js → EnterpriseEdge-Bzf3ZWSM.js} +1 -1
- package/frontend/build/static/{FeatureMetricsChart-DQOE71LA.js → FeatureMetricsChart-CA7ccj4F.js} +1 -1
- package/frontend/build/static/{FeatureStaleDialog-B6BfnDiQ.js → FeatureStaleDialog-DFGtgX-I.js} +1 -1
- package/frontend/build/static/{FeatureViewLazyExport-BkNTNFqK.js → FeatureViewLazyExport-CVIpdGgg.js} +3 -3
- package/frontend/build/static/{FlagMetricsChart-zYDF9bet.js → FlagMetricsChart-Dcc3RwL2.js} +1 -1
- package/frontend/build/static/{FrontendNetworkTrafficUsage-CbxdFXH7.js → FrontendNetworkTrafficUsage-C6ZZ-igE.js} +1 -1
- package/frontend/build/static/{GridLayoutWrapper-Cq6Bzm36.js → GridLayoutWrapper-mu3C2OC4.js} +1 -1
- package/frontend/build/static/{ImpactMetricsPage-CFYXYXPb.js → ImpactMetricsPage-DQ3DugFo.js} +1 -1
- package/frontend/build/static/{LazyAdminExport-ByTh4iFa.js → LazyAdminExport-CEik6N0e.js} +3 -3
- package/frontend/build/static/{LazyProjectExport-K12Xy3w9.js → LazyProjectExport-C8B0wkkW.js} +2 -2
- package/frontend/build/static/{LifecycleChartComponent-DHvlFNd2.js → LifecycleChartComponent-DgMY7X0Z.js} +1 -1
- package/frontend/build/static/{LineChartComponent-BlhKm3cw.js → LineChartComponent-FVKRZKUW.js} +1 -1
- package/frontend/build/static/{MarkCompletedDialogue-apmlFjVY.js → MarkCompletedDialogue-BFMzJ-VW.js} +1 -1
- package/frontend/build/static/{NetworkOverview-BiLOuQ4c.js → NetworkOverview-D8wtNaRF.js} +1 -1
- package/frontend/build/static/{NetworkPrometheusAPIWarning-CYo3j2Tj.js → NetworkPrometheusAPIWarning-D5-OGJsP.js} +1 -1
- package/frontend/build/static/{NetworkTraffic-DONL5oIx.js → NetworkTraffic-3cnRG5P0.js} +1 -1
- package/frontend/build/static/{NetworkTrafficUsage-DjQiYq0S.js → NetworkTrafficUsage-CSiuPn9W.js} +1 -1
- package/frontend/build/static/{PercentageDonut-CA9hYg3v.js → PercentageDonut-C51wuJjA.js} +1 -1
- package/frontend/build/static/{ReactJSONEditor-9cJL1vJY.js → ReactJSONEditor-BFCTTSFc.js} +1 -1
- package/frontend/build/static/{RoleCell-ZzU5Oqy8.js → RoleCell-CIeC6DEg.js} +1 -1
- package/frontend/build/static/{Safeguard-DY1N4aPz.js → Safeguard-C9U0j0cL.js} +1 -1
- package/frontend/build/static/{aggregateFeatureMetrics-D6bHft_C.js → aggregateFeatureMetrics-B-7cFh4G.js} +1 -1
- package/frontend/build/static/{formatTickValue-BcLsqREh.js → formatTickValue-CaA_jBqg.js} +1 -1
- package/frontend/build/static/{index-CoLhlfXP.js → index-C0tV9tYB.js} +10 -10
- package/frontend/build/static/{networkTrafficUsageHighlightPlugin-CqEM-cK_.js → networkTrafficUsageHighlightPlugin-D5DxaVbe.js} +1 -1
- package/frontend/build/static/{useApiTokens-ClWvohC9.js → useApiTokens-DDEZMbRy.js} +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{l8 as w,l9 as p,la as K,lb as V,lc as W,ld as v,le as Y,lf as Z,lg as Q,lh as ee,li as re,dv as D,l2 as O,b as te,bp as ae,r as ie,j as ne,l1 as oe,lj as le,ds as se,dt as ue,du as de,lk as fe,l4 as ve,l5 as he,dx as ye}from"./index-
|
|
1
|
+
import{l8 as w,l9 as p,la as K,lb as V,lc as W,ld as v,le as Y,lf as Z,lg as Q,lh as ee,li as re,dv as D,l2 as O,b as te,bp as ae,r as ie,j as ne,l1 as oe,lj as le,ds as se,dt as ue,du as de,lk as fe,l4 as ve,l5 as he,dx as ye}from"./index-C0tV9tYB.js";/*!
|
|
2
2
|
* chartjs-plugin-datalabels v2.2.0
|
|
3
3
|
* https://chartjs-plugin-datalabels.netlify.app
|
|
4
4
|
* (c) 2017-2022 chartjs-plugin-datalabels contributors
|
package/frontend/build/static/{LineChartComponent-BlhKm3cw.js → LineChartComponent-FVKRZKUW.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ll as g,lm as y,b,bp as m,r as c,j as i,dr as C,ln as S,C as j,lo as h,lp as L,lq as w,lj as f,s as k,ds as A,dt as T,du as v,dv as E,dw as _,lk as D,l4 as F,l5 as M,dx as R}from"./index-
|
|
1
|
+
import{ll as g,lm as y,b,bp as m,r as c,j as i,dr as C,ln as S,C as j,lo as h,lp as L,lq as w,lj as f,s as k,ds as A,dt as T,du as v,dv as E,dw as _,lk as D,l4 as F,l5 as M,dx as R}from"./index-C0tV9tYB.js";const W={position:"bottom",labels:{boxWidth:12,padding:30,generateLabels:t=>{var r;const l=t.data.datasets,{labels:{usePointStyle:e,pointStyle:o,textAlign:d,color:a}}=((r=t==null?void 0:t.legend)==null?void 0:r.options)||{labels:{}};return t._getSortedDatasetMetas().map(n=>{const s=n.controller.getStyle(e?0:void 0);return{text:l[n.index].label,fillStyle:s.borderColor,fontColor:a,hidden:!n.visible,lineWidth:0,borderRadius:6,strokeStyle:s.borderColor,pointStyle:o||s.pointStyle,textAlign:d||s.textAlign,datasetIndex:n.index}})}}},q=(t,l,e,o)=>({responsive:!0,...o?{animation:{duration:0}}:{},plugins:{legend:{...W,display:!o},tooltip:{enabled:!1,position:"nearest",external:y(e)}},locale:l.locale,interaction:{intersect:!1,axis:"xy",mode:"nearest"},elements:{point:{radius:0,hitRadius:15}},color:t.palette.text.secondary,scales:{y:{beginAtZero:!0,type:"linear",grid:{color:t.palette.divider,borderColor:t.palette.divider},ticks:{color:t.palette.text.secondary,display:!o,precision:0}},x:{adapters:{date:{locale:g(l.locale)}},type:"time",time:{unit:"week",tooltipFormat:"P"},grid:{color:"transparent",borderColor:"transparent"},ticks:{color:t.palette.text.secondary,display:!o,source:"data",maxRotation:90,minRotation:23.5}}}}),B=k("div")(({theme:t})=>({position:"relative"}));function G(t){return f.all(t.filter(l=>l))}const I=({data:t,aspectRatio:l=2.5,cover:e,overrideOptions:o,TooltipComponent:d,chartRef:a})=>{const r=b(),{locationSettings:n}=m(),[s,p]=c.useState(null),u=c.useMemo(()=>G([q(r,n,p,!!e),o??{}]),[r,n,p,o,e]);return i.jsxs(B,{children:[i.jsx(C,{ref:x=>{a==null||a(x??null)},options:u,data:t,plugins:[S({width:26})],height:100,width:100*l},e?"cover":"chart"),i.jsx(j,{condition:!e,show:d?i.jsx(L,{tooltip:s,children:i.jsx(d,{tooltip:s})}):i.jsx(w,{tooltip:s}),elseShow:i.jsx(h,{children:e!==!0?e:" "})})]})};A.register(T,v,E,_,D,F,M,R);export{I as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cQ as H,b6 as k,b8 as L,j as e,aU as R,C as x,aS as P,aT as D,f as M,bc as _,hQ as E,aQ as Q,aR as W,h as z,r as f,Q as m,T as C,L as y,dm as F,dn as B,l as G,m as N,s as J,A as K,n as X,o as Y,l6 as Z,ao as U,B as T,fh as I,l7 as A,fi as b}from"./index-
|
|
1
|
+
import{cQ as H,b6 as k,b8 as L,j as e,aU as R,C as x,aS as P,aT as D,f as M,bc as _,hQ as E,aQ as Q,aR as W,h as z,r as f,Q as m,T as C,L as y,dm as F,dn as B,l as G,m as N,s as J,A as K,n as X,o as Y,l6 as Z,ao as U,B as T,fh as I,l7 as A,fi as b}from"./index-C0tV9tYB.js";const ee=t=>fetch(t).then(L("ChangeRequest")).then(s=>s.json()),te=(t,s)=>{const r=s.map(i=>`feature=${i}`).join("&"),{data:n,error:a,mutate:o}=H([],k(`api/admin/projects/${t}/change-requests/scheduled?${r}`),ee);return{changeRequests:n,loading:!a&&!n,refetch:o,error:a}},S=()=>e.jsx(m,{severity:"warning",sx:{m:t=>t.spacing(2,0)},children:"Archiving flags with dependencies will also remove those dependencies."}),ne=({ids:t,projectId:s})=>{const r=n=>`/projects/${s}/features/${n}`;return t?e.jsxs(m,{severity:"warning",sx:{m:n=>n.spacing(2,0)},children:[e.jsx(C,{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(y,{to:r(n),children:n})},n))})]}):null},$=({ids:t,projectId:s})=>{const r=n=>`/projects/${s}/features/${n}`;return t&&t.length>1?e.jsxs(m,{severity:"error",sx:{m:n=>n.spacing(2,0)},children:[e.jsx(C,{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(y,{to:r(n),children:n})},n))})]}):t&&t.length===1?e.jsxs(m,{severity:"error",sx:{m:n=>n.spacing(2,0)},children:[e.jsx(y,{to:r(t[0]),children:t[0]})," has child features that depend on it and are not part of the archive operation."]}):null},q=({changeRequests:t,projectId:s})=>t&&t.length>0?e.jsxs(m,{severity:"warning",sx:{m:r=>r.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:r,title:n})=>{const a=n?`#${r} (${n})`:`Change request #${r}`;return e.jsx("li",{children:e.jsx(y,{to:`/projects/${s}/change-requests/${r}`,target:"_blank",rel:"noopener noreferrer",title:`Change request ${r}`,children:a})},r)})})]}):t===void 0?e.jsx(m,{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,se=(t,s)=>{const n=P(t)(),{isChangeRequestConfiguredForReview:a}=D(t);return n&&a(n)&&s?"Add to change request":n&&a(n)?"Add change to draft":s?"Archive flags":"Archive flag"},ae=({projectId:t,featureIds:s,onSuccess:r,onError:n})=>{const{setToastData:a,setToastApiError:o}=M(),{archiveFeatureToggle:i}=_(),{archiveFeatures:c}=E(),{isChangeRequestConfiguredForReview:h}=D(t),{addChange:d}=Q(),{refetch:u}=W(t),p=P(t),g=(s==null?void 0:s.length)>1,l=p(),v=async()=>{if(!l){console.error("No change request environment");return}await d(t,l,s.map(w=>({action:"archiveFeature",feature:w,payload:void 0}))),u(),a({type:"success",text:g?"Changes added to a draft":"Change added to a draft"})},j=async()=>{await i(t,s[0]),a({type:"success",text:"Feature flag archived"})},V=async()=>{await c(t,s),a({type:"success",text:"Feature flags archived"})};return async()=>{try{l&&h(l)?await v():g?await V():await j(),r()}catch(w){o(z(w)),n()}}},re=(t,s,r)=>{const[n,a]=f.useState(!0),[o,i]=f.useState([]),[c,h]=f.useState(!1),{verifyArchiveFeatures:d}=E();return f.useEffect(()=>{r&&d(s,t).then(u=>u.json()).then(({hasDeletedDependencies:u,parentsWithChildFeatures:p})=>{p.length===0?(a(!1),i(p)):(a(!0),i(p)),h(u)})},[JSON.stringify(t),r,s,i,a,h,d]),{disableArchive:n,offendingParents:o,hasDeletedDependencies:c}},ue=({isOpen:t,onClose:s,onConfirm:r,projectId:n,featureIds:a,featuresWithUsage:o})=>{const i=(a==null?void 0:a.length)>1,c=se(n,i),h=i?"Archive feature flags":"Archive feature flag",d=ae({projectId:n,featureIds:a,onSuccess(){r(),s()},onError(){s()}}),{changeRequests:u}=te(n,a),{disableArchive:p,offendingParents:g,hasDeletedDependencies:l}=re(a,n,t),v=g.length===0&&l;return e.jsx(R,{onClick:d,open:t,onClose:s,primaryButtonText:c,secondaryButtonText:"Cancel",title:h,disabledPrimaryButton:p,children:e.jsx(x,{condition:i,show:e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Are you sure you want to archive"," ",e.jsx("strong",{children:a==null?void 0:a.length})," feature flags?"]}),e.jsx(x,{condition:!!(o&&(o==null?void 0:o.length)>0),show:e.jsx(ne,{ids:o,projectId:n})}),e.jsx(x,{condition:g.length>0,show:e.jsx($,{ids:g,projectId:n})}),e.jsx(x,{condition:v,show:e.jsx(S,{})}),e.jsx(q,{changeRequests:u,projectId:n}),e.jsx(x,{condition:(a==null?void 0:a.length)<=5,show:e.jsx("ul",{children:a==null?void 0:a.map(j=>e.jsx("li",{children:j},j))})})]}),elseShow:e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Are you sure you want to archive"," ",i?"these feature flags":"this feature flag","?"]}),e.jsx(x,{condition:g.length>0,show:e.jsx($,{ids:g,projectId:n})}),e.jsx(x,{condition:v,show:e.jsx(S,{})}),e.jsx(q,{changeRequests:u,projectId:n})]})})})},ie=(t,s)=>`/api/admin/projects/${t}/features/${s}/parents`,ge=(t,s)=>{const r=k(ie(t,s)),{data:n,loading:a,error:o}=F(r,()=>B(r,"Parent Options"));return{parentOptions:n,loading:a,error:o}},oe=(t,s)=>`/api/admin/projects/${t}/features/${s}/parent-variants`,O=(t,s)=>{const r=k(oe(t,s)),{data:n,loading:a,error:o}=F(r,()=>B(r,"Parent Variant Options"));return{parentVariantOptions:n||[],loading:a,error:o}},ce=J(K)(({theme:t})=>({marginTop:t.spacing(2),marginBottom:t.spacing(1.5)})),le=({project:t,parent:s,onSelect:r})=>{const{parentVariantOptions:n}=O(t,s),a=e.jsx(Y,{fontSize:"small"}),o=e.jsx(X,{fontSize:"small"});return e.jsx(ce,{id:"single-variant-options",options:n,renderOption:(i,c,{selected:h})=>e.jsxs("li",{...i,children:[e.jsx(N,{icon:a,checkedIcon:o,style:{marginRight:8},checked:h}),c]}),renderInput:i=>e.jsx(G,{...i,placeholder:"Select variant"}),fullWidth:!0,onChange:(i,c)=>{r(String(c))}})},de=({projectId:t,featureId:s,isOpen:r,setIsOpen:n,onComplete:a})=>{const{markFeatureCompleted:o}=Z(),{parentVariantOptions:i}=O(t,s),[c,h]=f.useState("kept"),[d,u]=f.useState(void 0),{trackEvent:p}=U(),g=async()=>{const l=c==="kept-with-variant"?"kept":c;await o(s,t,{status:l,statusValue:d}),n(!1),a(),p("feature-lifecycle",{props:{eventType:"complete",status:l}})};return e.jsx(R,{open:r,title:"Mark completed",onClose:()=>{n(!1)},disabledPrimaryButton:c==="kept-with-variant"&&d===null,onClick:g,primaryButtonText:"Mark completed",secondaryButtonText:"Cancel",children:e.jsxs(T,{children:[e.jsxs(T,{sx:{mt:2,mb:4},children:["Marking the feature ",e.jsx("b",{children:s})," 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(C,{sx:{mb:2},children:e.jsx("b",{children:"What was the outcome of this feature?"})}),e.jsxs(I,{"aria-label":"selected-value",name:"selected",sx:{gap:l=>l.spacing(.5)},onChange:(l,v)=>{h(v)},children:[e.jsx(A,{value:"kept",legal:{value:"We decided to keep the feature"},control:e.jsx(b,{})},"kept"),e.jsx(A,{value:"discarded",legal:{value:"We decided to discard the feature"},control:e.jsx(b,{})},"discarded"),e.jsx(x,{condition:i.length>0,show:e.jsx(A,{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(b,{})},"kept-with-variant")}),e.jsx(x,{condition:i.length>0&&c==="kept-with-variant",show:e.jsx(le,{parent:s,project:t,onSelect:l=>{u(l)}})})]})]})})};export{ue as F,de as M,ge as a,O as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cz as g,b as u,r as x,j as t,Q as y,ky as c,lt as m,lu as f,lv as j,T as d,s as i}from"./index-
|
|
1
|
+
import{cz as g,b as u,r as x,j as t,Q as y,ky as c,lt as m,lu as f,lv as j,T as d,s as i}from"./index-C0tV9tYB.js";import{u as b,N as v}from"./NetworkPrometheusAPIWarning-D5-OGJsP.js";import{u as h}from"./unknownify-B7hmSXnj.js";const w=i("div")(({theme:e})=>({marginBottom:e.spacing(18),display:"flex",justifyContent:"center"})),S=i("div")(({theme:e})=>({display:"flex",justifyContent:"center",gap:e.spacing(4),flexWrap:"wrap"})),p=i("div")(({theme:e})=>({borderRadius:e.shape.borderRadiusMedium,border:"1px solid",borderColor:e.palette.secondary.border,backgroundColor:e.palette.secondary.light,display:"flex",flexDirection:"column",alignItems:"center",padding:e.spacing(1.5),zIndex:1,"& > svg":{width:e.spacing(9),height:e.spacing(9)}})),k=i(d)(({theme:e})=>({fontWeight:e.fontWeight.bold})),A=i(d)(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary})),q=i(d)(({theme:e})=>({fontSize:e.fontSizes.smallerBody,color:e.palette.text.secondary})),C=e=>e[0]*1e3>Date.now()-6e5,E=e=>{var a,s;const r=(e.values||[]).filter(l=>C(l)),o=r.length?Number.parseFloat(r[r.length-1][1]):0;return{label:e.label,reqs:o,type:h((s=(a=e.metric)==null?void 0:a.endpoint)==null?void 0:s.split("/")[2])}},B=(e,n)=>{var o;const r=n.label+n.type;return e[r]={...n,reqs:n.reqs+(((o=e[r])==null?void 0:o.reqs)??0)},e},N=e=>{var o,a;const r=(((a=(o=e==null?void 0:e.data)==null?void 0:o.result)==null?void 0:a.map(s=>{var l;return{...s,label:h((l=s.metric)==null?void 0:l.appName)}}).filter(s=>s.label!=="unknown"))||[]).map(E).reduce(B,{});return Object.values(r).map(s=>({...s,reqs:s.reqs.toFixed(2)})).filter(s=>s.reqs!=="0.00")??[]},D=()=>{g("Network - Overview");const e=u(),{metrics:n}=b(),r=x.useMemo(()=>N(n),[n]);return r.length===0?t.jsxs(y,{severity:"warning",children:["No data available.",t.jsx(v,{})]}):t.jsxs(c.ArcherContainer,{strokeColor:e.palette.text.primary,endShape:{arrow:{arrowLength:4,arrowThickness:4}},children:[t.jsx(w,{children:t.jsx(c.ArcherElement,{id:"unleash",children:t.jsxs(p,{children:[t.jsx(m,{darkmode:t.jsx(j,{}),lightmode:t.jsx(f,{})}),t.jsx(d,{sx:{marginTop:e.spacing(1)},children:"Unleash"})]})})}),t.jsx(S,{children:r.map(({label:o,reqs:a,type:s},l)=>t.jsx(c.ArcherElement,{id:`${l}`,relations:[{targetId:"unleash",targetAnchor:"bottom",sourceAnchor:"top",style:{strokeColor:e.palette.secondary.border}}],children:t.jsxs(p,{children:[t.jsx(k,{children:o}),t.jsxs(A,{children:[a," req/s"]}),t.jsxs(q,{children:[s," app"]})]})}))})]})};export{D as NetworkOverview,D as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b9 as a,b7 as i,b6 as c,r as u,b8 as h,j as n}from"./index-
|
|
1
|
+
import{b9 as a,b7 as i,b6 as c,r as u,b8 as h,j as n}from"./index-C0tV9tYB.js";const f=(e={})=>{const{uiConfig:{prometheusAPIAvailable:r}}=a(),{data:t,error:s,mutate:o}=i(r,{},c("api/admin/metrics/rps"),l,e);return u.useMemo(()=>({metrics:t,loading:!s&&!t,refetch:()=>o(),error:s}),[t,s,o])},l=e=>fetch(e).then(h("Instance Metrics")).then(r=>r.json()),p=()=>{const{uiConfig:{prometheusAPIAvailable:e}}=a();return e?null:n.jsxs("p",{children:["This view requires the ",n.jsx("strong",{children:"PROMETHEUS_API"})," environment variable to be set. Refer to our"," ",n.jsx("a",{href:"https://docs.getunleash.io/concepts/network-view#data-source",target:"_blank",rel:"noreferrer",children:"documentation"})," ","for more information."]})};export{p as N,f as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var f=Object.defineProperty;var h=(e,t,a)=>t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a;var s=(e,t,a)=>h(e,typeof t!="symbol"?t+"":t,a);import{bp as C,b as w,r as p,cz as v,j as o,C as P,cR as S,dr as j,Q as N,k$ as u,lw as I,ds as R,dt as A,du as M,dv as T,dw as q,lk as E,l5 as L,l4 as _,l3 as D}from"./index-
|
|
1
|
+
var f=Object.defineProperty;var h=(e,t,a)=>t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a;var s=(e,t,a)=>h(e,typeof t!="symbol"?t+"":t,a);import{bp as C,b as w,r as p,cz as v,j as o,C as P,cR as S,dr as j,Q as N,k$ as u,lw as I,ds as R,dt as A,du as M,dv as T,dw as q,lk as E,l5 as L,l4 as _,l3 as D}from"./index-C0tV9tYB.js";import{u as W,N as $}from"./NetworkPrometheusAPIWarning-D5-OGJsP.js";import{u as g}from"./unknownify-B7hmSXnj.js";const m=["circle","rect","rectRounded","rectRot","triangle"],z=(e,t)=>e.map(a=>({x:a[0],y:t(a[1])})),H=(e,t)=>({locale:t.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.action.active,borderColor:e.palette.primary.main,borderWidth:1,padding:10,boxPadding:5,usePointStyle:!0,callbacks:{title:a=>u(1e3*a[0].parsed.x,t.locale)},itemSort:(a,i)=>i.parsed.y-a.parsed.y},legend:{position:"bottom",align:"start",labels:{boxWidth:10,boxHeight:10,usePointStyle:!0,padding:24}},title:{text:"Top 10 requests per second in the last 6 hours",position:"top",align:"start",display:!0,font:{size:16,weight:"400"},color:e.palette.text.primary,padding:{bottom:32}}},scales:{y:{type:"linear",title:{display:!0,text:"Requests per second",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:"minute"},grid:{display:!0,color:e.palette.divider,borderColor:e.palette.divider},ticks:{callback:(a,i,r)=>u(r[i].value*1e3,t.locale)}}}});class B{constructor(t){s(this,"items");s(this,"picked",new Map);this.items=new I(t)}pick(t){return this.picked.has(t)||this.picked.set(t,this.items.next()),this.picked.get(t)}}const F=(e,t)=>{var a;if((a=t==null?void 0:t.data)!=null&&a.result){const i=new B([e.palette.success,e.palette.error,e.palette.primary,e.palette.warning]);return t.data.result.map((r,x)=>{var c,d;const n=g((c=r.metric)==null?void 0:c.endpoint),y=g((d=r.metric)==null?void 0:d.appName),l=i.pick(n),b=r.values||[];return{label:`${n}: ${y}`,borderColor:l.main,backgroundColor:l.main,data:z(b,k=>Number.parseFloat(k)),elements:{point:{radius:4,pointStyle:m[x%m.length]},line:{borderDash:[8,4]}}}})}return[]},K=()=>{const{locationSettings:e}=C(),{metrics:t}=W(),a=w(),i=p.useMemo(()=>H(a,e),[a,e]);v("Network - Traffic");const r=p.useMemo(()=>({datasets:F(a,t)}),[a,t,e]);return o.jsx(P,{condition:r.datasets.length===0,show:o.jsxs(N,{severity:"warning",children:["No data available.",o.jsx($,{})]}),elseShow:o.jsx(S,{sx:{display:"grid",gap:4},children:o.jsx("div",{style:{height:400},children:o.jsx(j,{data:r,options:i,"aria-label":"An instance metrics line chart with two lines: requests per second for admin API and requests per second for client API"})})})})};R.register(A,M,T,q,E,L,_,D);export{K as NetworkTraffic,K as default};
|
package/frontend/build/static/{NetworkTrafficUsage-DjQiYq0S.js → NetworkTrafficUsage-CSiuPn9W.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bp as E,j as e,K as d,cL as v,s as c,hF as f,b9 as y,b6 as B,cp as q,r as A,b8 as F,cz as I,cg as P,C as p,Q as x,L as m,l1 as _,ds as M,dt as N,du as k,l2 as z,l3 as $,l4 as H,l5 as O}from"./index-
|
|
1
|
+
import{bp as E,j as e,K as d,cL as v,s as c,hF as f,b9 as y,b6 as B,cp as q,r as A,b8 as F,cz as I,cg as P,C as p,Q as x,L as m,l1 as _,ds as M,dt as N,du as k,l2 as z,l3 as $,l4 as H,l5 as O}from"./index-C0tV9tYB.js";import{a as W}from"./formatTickValue-CaA_jBqg.js";import{u as Y,a as G,B as K,S as Q,T as J,P as V,n as X,g as Z}from"./networkTrafficUsageHighlightPlugin-D5DxaVbe.js";import{p as ee,c as l}from"./LazyAdminExport-CEik6N0e.js";import"./RoleCell-CIeC6DEg.js";import"./useApiTokens-DDEZMbRy.js";import"./PercentageDonut-C51wuJjA.js";const S=c("article")(({theme:s})=>({minWidth:"200px",border:`2px solid ${s.palette.divider}`,borderRadius:s.shape.borderRadiusLarge,padding:s.spacing(3),display:"flex",flexDirection:"column",gap:s.spacing(2)})),T=c("h3")(({theme:s})=>({margin:0,fontSize:s.typography.body1.fontSize})),w=c("dl")(({theme:s})=>({display:"flex",flexDirection:"column",gap:s.spacing(2.5),padding:0,margin:0})),a=c("div")(({theme:s})=>({display:"flex",flexFlow:"row wrap",justifyContent:"space-between",gap:s.spacing(1,3),fontSize:s.typography.body2.fontSize,color:s.palette.text.secondary,"& dd":{margin:0,color:s.palette.text.primary}})),se=s=>{const r=t=>t.toLocaleString("en-US",{month:"short",year:"numeric"});if(s.grouping==="monthly"){const t=new Date,n=f(t,s.monthsBack),o=f(t,1);return`Average requests from ${r(n)} to ${r(o)}`}return`Requests used in ${r(ee(s.month))}`},te=({period:s,usageTotal:r,includedTraffic:t,purchasedTraffic:n,currentMonth:o})=>{const{locationSettings:i}=E();return e.jsxs(S,{children:[e.jsx(T,{children:"Number of requests to Unleash"}),e.jsxs(w,{children:[e.jsxs(a,{children:[e.jsx("dt",{children:se(s)}),e.jsx("dd",{children:e.jsxs(d,{color:t>0?r<=t?"success":"error":"neutral",children:[r.toLocaleString(i.locale??"en-US")," ","requests"]})})]}),t>0&&e.jsxs(a,{children:[e.jsx("dt",{children:"Included in your plan"}),e.jsxs("dd",{children:[t.toLocaleString("en-US")," requests"]})]}),n>0&&o&&e.jsxs(a,{children:[e.jsx("dt",{children:"Additional traffic purchased"}),e.jsxs("dd",{children:[n.toLocaleString("en-US")," requests"]})]}),t>0&&o&&e.jsxs(a,{children:[e.jsx("dt",{children:"Total traffic available"}),e.jsxs("dd",{children:[(t+n).toLocaleString("en-US")," ","requests"]})]})]})]})},ne=({overages:s,overageCost:r,estimatedMonthlyCost:t})=>e.jsxs(S,{children:[e.jsx(T,{children:"Accrued traffic charges"}),e.jsxs(w,{children:[e.jsxs(a,{children:[e.jsxs("dt",{children:["Request overages this month (",e.jsx(v,{href:"https://www.getunleash.io/pricing",children:"pricing"}),")"]}),e.jsxs("dd",{children:[s.toLocaleString()," requests"]})]}),e.jsxs(a,{children:[e.jsx("dt",{children:"Accrued traffic charges"}),e.jsx("dd",{children:e.jsxs(d,{color:"secondary",children:[r," USD"]})})]}),t>0&&e.jsxs(a,{children:[e.jsx("dt",{children:"Estimated charges based on current usage"}),e.jsx("dd",{children:e.jsxs(d,{color:"secondary",children:[t," USD"]})})]})]})]}),re=53,oe=259,j=1e6,ae=(s,r)=>!s||r==="pay-as-you-go"?re:oe;function ie(s,r,t){return s===void 0?ae(r,t):s}function ce(s){return s===void 0?0:s}const le=()=>{const{isEnterprise:s,uiConfig:r}=y(),t=B("/api/instance/trafficBundles"),{data:n,error:o,mutate:i}=q(t,de);return{trafficBundles:A.useMemo(()=>({includedTraffic:ie(n==null?void 0:n.includedTraffic,s(),r.billing)*j,purchasedTraffic:ce(n==null?void 0:n.purchasedTraffic)*j}),[n]),loading:!o&&!n,refetch:i}},de=s=>fetch(s).then(F("configuration")).then(r=>r.json()),ue=c("div")(({theme:s})=>({display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, max-content))",flex:1,gap:s.spacing(2,4)})),ye=()=>{I("Network - Data Usage");const s=P("estimateTrafficDataCost"),{isOss:r}=y(),{trafficBundles:t}=le(),n=t.includedTraffic+t.purchasedTraffic,{chartDataSelection:o,setChartDataSelection:i,options:u}=Y(n),{chartData:C,usageTotal:h,overageCost:g,estimatedMonthlyCost:L,requestSummaryUsage:b}=G(n,o),U=o.grouping==="daily"&&o.month===l&&n>0&&h-n>0&&s,D=o.grouping==="daily"&&o.month===l,R=(o.grouping==="monthly"||o.month===l)&&n>0&&g>0;return e.jsx(p,{condition:r(),show:e.jsx(x,{severity:"warning",children:"Not enabled."}),elseShow:e.jsxs(e.Fragment,{children:[e.jsx(p,{condition:R,show:e.jsxs(x,{severity:"warning",sx:{mb:4},children:[e.jsx(K,{children:"Heads up!"})," You are currently consuming more requests than your plan includes and will be billed according to our terms. Please see"," ",e.jsx(m,{to:"https://www.getunleash.io/pricing",children:"this page"})," ","for more information. In order to reduce your traffic consumption, you may configure an"," ",e.jsx(m,{to:"https://docs.getunleash.io/unleash-edge",children:"Unleash Edge instance"})," ","in your own datacenter."]})}),e.jsxs(Q,{children:[e.jsxs(J,{children:[e.jsxs(ue,{children:[e.jsx(te,{period:o,usageTotal:b,includedTraffic:t.includedTraffic,purchasedTraffic:t.purchasedTraffic,currentMonth:D}),U&&e.jsx(ne,{overageCost:g,overages:h-n,estimatedMonthlyCost:L})]}),e.jsx(V,{selectedPeriod:o,setPeriod:i})]}),e.jsx(_,{data:C,plugins:[X],options:u,"aria-label":Z(o)})]})]})})};M.register(W,N,k,z,$,H,O);export{ye as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as p,j as o,s as l}from"./index-
|
|
1
|
+
import{b as p,j as o,s as l}from"./index-C0tV9tYB.js";const x=l("div")(()=>({display:"flex",alignItems:"center",justifyContent:"center",position:"relative",margin:0})),y=l("div",{shouldForwardProp:e=>e!=="color"})(({theme:e,color:r})=>({position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",color:r,fontSize:e.fontSizes.smallerBody,margin:0})),u=({percentage:e,size:r="4rem",disabled:c=!1,children:d,strokeRatio:h=.2})=>{const s=p(),m={display:"block",borderRadius:"100%",transform:"rotate(-90deg)",height:r,width:r},t=100/(2*Math.PI),n=2*t,a=n*h,i=c?s.palette.neutral.border:s.palette.primary.light;return o.jsxs(x,{children:[o.jsxs("svg",{viewBox:`0 0 ${n} ${n}`,style:m,"aria-hidden":!0,children:[o.jsx("circle",{r:t,cx:t,cy:t,fill:"none",stroke:s.palette.background.elevation2,strokeWidth:a}),o.jsx("circle",{r:t,cx:t,cy:t,fill:"none",stroke:i,strokeWidth:a,strokeDasharray:`${e} 100`})]}),o.jsx(y,{color:i,children:d})]})};export{u as P};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as bb,ck as yb,r as Cl,U as jb,j as Fd,s as xb}from"./index-
|
|
1
|
+
import{g as bb,ck as yb,r as Cl,U as jb,j as Fd,s as xb}from"./index-C0tV9tYB.js";import{V as Kh,I as wb,J as kb,A as zs,K as ru,R as Gh,L as Yh,H as Sb,B as pl,o as Qh,E as ci,y as Nf,C as Cb,M as hl,N as Ob,b as Eb,e as Mb,g as _b,j as Tb,k as Ab,m as zb,n as Pb,z as Nb,p as Rb,q as Ib,r as qb,t as Lb,u as Ub,v as Db,w as $b,c as Bb,d as Fb,s as Wb,f as Vb,a as Hb,l as Jb,G as Kb,O as Gb,P as Yb,Q as Rf,T as Qb,U as ld,W as If,X as Xb,x as Zb,F as e1,Y as t1,Z as n1,_ as r1,$ as o1,a0 as a1,a1 as s1}from"./index-B87DWXbl.js";function vr(e){return Array.isArray(e)}function yr(e){return e!==null&&typeof e=="object"&&(e.constructor===void 0||e.constructor.name==="Object")}function Xh(e){return e&&typeof e=="object"?e.op==="add":!1}function Zh(e){return e&&typeof e=="object"?e.op==="remove":!1}function qv(e){return e&&typeof e=="object"?e.op==="replace":!1}function Wd(e){return e&&typeof e=="object"?e.op==="copy":!1}function Ds(e){return e&&typeof e=="object"?e.op==="move":!1}function i1(e,t){return JSON.stringify(e)===JSON.stringify(t)}function l1(e,t){return e===t}function eg(e){return e.slice(0,e.length-1)}function c1(e){return e[e.length-1]}function u1(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:l1;if(e.length<t.length)return!1;for(let o=0;o<t.length;o++)if(!n(e[o],t[o]))return!1;return!0}function tg(e){return typeof e=="object"&&e!==null}function Lv(e){if(vr(e)){const t=e.slice();return Object.getOwnPropertySymbols(e).forEach(n=>{t[n]=e[n]}),t}if(yr(e)){const t={...e};return Object.getOwnPropertySymbols(e).forEach(n=>{t[n]=e[n]}),t}return e}function Uv(e,t,n){if(e[t]===n)return e;const o=Lv(e);return o[t]=n,o}function Ye(e,t){let n=e,o=0;for(;o<t.length;)yr(n)?n=n[t[o]]:vr(n)?n=n[Number.parseInt(t[o])]:n=void 0,o++;return n}function co(e,t,n){let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(t.length===0)return n;const a=t[0],s=co(e?e[a]:void 0,t.slice(1),n,o);if(yr(e)||vr(e))return Uv(e,a,s);if(o){const i=d1.test(a)?[]:{};return i[a]=s,i}throw new Error("Path does not exist")}const d1=/^\d+$/;function Dv(e,t,n){if(t.length===0)return n(e);if(!tg(e))throw new Error("Path doesn't exist");const o=t[0],a=Dv(e[o],t.slice(1),n);return Uv(e,o,a)}function Pu(e,t){if(t.length===0)return e;if(!tg(e))throw new Error("Path does not exist");if(t.length===1){const a=t[0];if(!(a in e))return e;const s=Lv(e);return vr(s)&&s.splice(Number.parseInt(a),1),yr(s)&&delete s[a],s}const n=t[0],o=Pu(e[n],t.slice(1));return Uv(e,n,o)}function $v(e,t,n){const o=t.slice(0,t.length-1),a=t[t.length-1];return Dv(e,o,s=>{if(!Array.isArray(s))throw new TypeError(`Array expected at path ${JSON.stringify(o)}`);const i=Lv(s);return i.splice(Number.parseInt(a),0,n),i})}function ho(e,t){return e===void 0?!1:t.length===0?!0:e===null?!1:ho(e[t[0]],t.slice(1))}function go(e){const t=e.split("/");return t.shift(),t.map(n=>n.replace(/~1/g,"/").replace(/~0/g,"~"))}function vt(e){return e.map(ng).join("")}function ng(e){return`/${String(e).replace(/~/g,"~0").replace(/\//g,"~1")}`}function yc(e,t){return e+ng(t)}function Vo(e,t,n){let o=e;for(let a=0;a<t.length;a++){y1(t[a]);let s=t[a];if(n!=null&&n.before){const c=n.before(o,s);if(c!==void 0){if(c.document!==void 0&&(o=c.document),c.json!==void 0)throw new Error('Deprecation warning: returned object property ".json" has been renamed to ".document"');c.operation!==void 0&&(s=c.operation)}}const i=o,l=Ho(o,s.path);if(s.op==="add")o=p1(o,l,s.value);else if(s.op==="remove")o=f1(o,l);else if(s.op==="replace")o=v1(o,l,s.value);else if(s.op==="copy")o=h1(o,l,Vd(s.from));else if(s.op==="move")o=g1(o,l,Vd(s.from));else if(s.op==="test")m1(o,l,s.value);else throw new Error(`Unknown JSONPatch operation ${JSON.stringify(s)}`);if(n!=null&&n.after){const c=n.after(o,s,i);c!==void 0&&(o=c)}}return o}function v1(e,t,n){return ho(e,t)?co(e,t,n):e}function f1(e,t){return Pu(e,t)}function p1(e,t,n){return rc(e,t)?$v(e,t,n):co(e,t,n)}function h1(e,t,n){const o=Ye(e,n);return rc(e,t)?$v(e,t,o):co(e,t,o)}function g1(e,t,n){const o=Ye(e,n),a=Pu(e,n);return rc(a,t)?$v(a,t,o):co(a,t,o)}function m1(e,t,n){if(n===void 0)throw new Error(`Test failed: no value provided (path: "${vt(t)}")`);if(!ho(e,t))throw new Error(`Test failed: path not found (path: "${vt(t)}")`);const o=Ye(e,t);if(!i1(o,n))throw new Error(`Test failed, value differs (path: "${vt(t)}")`)}function rc(e,t){if(t.length===0)return!1;const n=Ye(e,eg(t));return Array.isArray(n)}function b1(e,t){if(c1(t)!=="-")return t;const n=eg(t),o=Ye(e,n);return n.concat(o.length)}function y1(e){if(!["add","remove","replace","copy","move","test"].includes(e.op))throw new Error(`Unknown JSONPatch op ${JSON.stringify(e.op)}`);if(typeof e.path!="string")throw new Error(`Required property "path" missing or not a string in operation ${JSON.stringify(e)}`);if((e.op==="copy"||e.op==="move")&&typeof e.from!="string")throw new Error(`Required property "from" missing or not a string in operation ${JSON.stringify(e)}`)}function Ho(e,t){return b1(e,go(t))}function Vd(e){return go(e)}function rg(e,t,n){let o=[];return Vo(e,t,{before:(s,i)=>{let l;const c=Ho(s,i.path);if(i.op==="add")l=sg(s,c);else if(i.op==="remove")l=ag(s,c);else if(i.op==="replace")l=og(s,c);else if(i.op==="copy")l=j1(s,c);else if(i.op==="move")l=x1(s,c,Vd(i.from));else if(i.op==="test")l=[];else throw new Error(`Unknown JSONPatch operation ${JSON.stringify(i)}`);let u;if(n!=null&&n.before){const d=n.before(s,i,l);if(d!=null&&d.revertOperations&&(l=d.revertOperations),d!=null&&d.document&&(u=d.document),d!=null&&d.json)throw new Error('Deprecation warning: returned object property ".json" has been renamed to ".document"')}if(o=l.concat(o),u!==void 0)return{document:u}}}),o}function og(e,t){return ho(e,t)?[{op:"replace",path:vt(t),value:Ye(e,t)}]:[]}function ag(e,t){return[{op:"add",path:vt(t),value:Ye(e,t)}]}function sg(e,t){return rc(e,t)||!ho(e,t)?[{op:"remove",path:vt(t)}]:og(e,t)}function j1(e,t){return sg(e,t)}function x1(e,t,n){if(t.length<n.length&&u1(n,t))return[{op:"replace",path:vt(t),value:e}];const o={op:"move",from:vt(t),path:vt(n)};return!rc(e,t)&&ho(e,t)?[o,...ag(e,t)]:[o]}var Nu={},qf={b:"\b",f:"\f",n:`
|
|
2
2
|
`,r:"\r",t:" ",'"':'"',"/":"/","\\":"\\"},w1=97;Nu.parse=function(e,t,n){var o={},a=0,s=0,i=0,l=n&&n.bigint&&typeof BigInt<"u";return{data:c("",!0),pointers:o};function c(E,L){u();var W;z(E,"value");var q=g();switch(q){case"t":b("rue"),W=!0;break;case"f":b("alse"),W=!1;break;case"n":b("ull"),W=null;break;case'"':W=d();break;case"[":W=y(E);break;case"{":W=h(E);break;default:j(),"-0123456789".indexOf(q)>=0?W=v():T()}return z(E,"valueEnd"),u(),L&&i<e.length&&T(),W}function u(){e:for(;i<e.length;){switch(e[i]){case" ":s++;break;case" ":s+=4;break;case"\r":s=0;break;case`
|
|
3
3
|
`:s=0,a++;break;default:break e}i++}}function d(){for(var E="",L;L=g(),L!='"';)L=="\\"?(L=g(),L in qf?E+=qf[L]:L=="u"?E+=w():P()):E+=L;return E}function v(){var E="",L=!0;e[i]=="-"&&(E+=g()),E+=e[i]=="0"?g():S(),e[i]=="."&&(E+=g()+S(),L=!1),(e[i]=="e"||e[i]=="E")&&(E+=g(),(e[i]=="+"||e[i]=="-")&&(E+=g()),E+=S(),L=!1);var W=+E;return l&&L&&(W>Number.MAX_SAFE_INTEGER||W<Number.MIN_SAFE_INTEGER)?BigInt(E):W}function y(E){u();var L=[],W=0;if(g()=="]")return L;for(j();;){var q=E+"/"+W;L.push(c(q)),u();var Y=g();if(Y=="]")break;Y!=","&&P(),u(),W++}return L}function h(E){u();var L={};if(g()=="}")return L;for(j();;){var W=x();g()!='"'&&P();var q=d(),Y=E+"/"+Hd(q);O(Y,"key",W),z(Y,"keyEnd"),u(),g()!=":"&&P(),u(),L[q]=c(Y),u();var be=g();if(be=="}")break;be!=","&&P(),u()}return L}function b(E){for(var L=0;L<E.length;L++)g()!==E[L]&&P()}function g(){B();var E=e[i];return i++,s++,E}function j(){i--,s--}function w(){for(var E=4,L=0;E--;){L<<=4;var W=g().toLowerCase();W>="a"&&W<="f"?L+=W.charCodeAt()-w1+10:W>="0"&&W<="9"?L+=+W:P()}return String.fromCharCode(L)}function S(){for(var E="";e[i]>="0"&&e[i]<="9";)E+=g();if(E.length)return E;B(),T()}function z(E,L){O(E,L,x())}function O(E,L,W){o[E]=o[E]||{},o[E][L]=W}function x(){return{line:a,column:s,pos:i}}function T(){throw new SyntaxError("Unexpected token "+e[i]+" in JSON at position "+i)}function P(){j(),T()}function B(){if(i>=e.length)throw new SyntaxError("Unexpected end of JSON input")}};Nu.stringify=function(e,t,n){if(!jc(e))return;var o=0,a,s,i=typeof n=="object"?n.space:n;switch(typeof i){case"number":var l=i>10?10:i<0?0:Math.floor(i);i=l&&O(l," "),a=l,s=l;break;case"string":i=i.slice(0,10),a=0,s=0;for(var c=0;c<i.length;c++){var u=i[c];switch(u){case" ":s++;break;case" ":s+=4;break;case"\r":s=0;break;case`
|
|
4
4
|
`:s=0,o++;break;default:throw new Error("whitespace characters not allowed in JSON")}a++}break;default:i=void 0}var d="",v={},y=0,h=0,b=0,g=n&&n.es6&&typeof Map=="function";return j(e,0,""),{json:d,pointers:v};function j(x,T,P){switch(z(P,"value"),typeof x){case"number":case"bigint":case"boolean":w(""+x);break;case"string":w(xc(x));break;case"object":x===null?w("null"):typeof x.toJSON=="function"?w(xc(x.toJSON())):Array.isArray(x)?B():g?x.constructor.BYTES_PER_ELEMENT?B():x instanceof Map?L():x instanceof Set?L(!0):E():E()}z(P,"valueEnd");function B(){if(x.length){w("[");for(var W=T+1,q=0;q<x.length;q++){q&&w(","),S(W);var Y=jc(x[q])?x[q]:null,be=P+"/"+q;j(Y,W,be)}S(T),w("]")}else w("[]")}function E(){var W=Object.keys(x);if(W.length){w("{");for(var q=T+1,Y=0;Y<W.length;Y++){var be=W[Y],ce=x[be];if(jc(ce)){Y&&w(",");var Me=P+"/"+Hd(be);S(q),z(Me,"key"),w(xc(be)),z(Me,"keyEnd"),w(":"),i&&w(" "),j(ce,q,Me)}}S(T),w("}")}else w("{}")}function L(W){if(x.size){w("{");for(var q=T+1,Y=!0,be=x.entries(),ce=be.next();!ce.done;){var Me=ce.value,Le=Me[0],ue=W?!0:Me[1];if(jc(ue)){Y||w(","),Y=!1;var se=P+"/"+Hd(Le);S(q),z(se,"key"),w(xc(Le)),z(se,"keyEnd"),w(":"),i&&w(" "),j(ue,q,se)}ce=be.next()}S(T),w("}")}else w("{}")}}function w(x){h+=x.length,b+=x.length,d+=x}function S(x){if(i){for(d+=`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aD as ae,aE as le,r as d,aH as ie,_ as ce,a as $,j as e,aI as de,aK as ue,s as c,Q as U,f as L,ae as q,et as v,w as he,x as pe,hL as V,d3 as X,b9 as y,er as xe,es as me,ad as je,i as Q,ai as ge,dd as be,al as fe,C as f,B as g,au as ye,am as Te,av as K,cL as B,T as A,bq as Ce,eI as ke,kO as ve,bf as Ae,ey as we,ah as w,c9 as D,ez as E,ar as Se,L as Y,E as Ee,F as Ne,ag as G,fv as Ie,aj as N,eh as Re,eP as De,a9 as C,aa as Ue,cX as J,a$ as Le,aU as Z,h as Be,y as Pe,G as _e,ax as ee,b_ as I,jw as Fe,dK as Me,dJ as Oe,e1 as He,dZ as $e,fh as Ke,dX as Ge,fi as We,iu as ze,cp as qe,b6 as te,b8 as se,b7 as Ve,b0 as Xe,dT as Qe,b4 as Ye}from"./index-CoLhlfXP.js";import{u as Je}from"./useApiTokens-ClWvohC9.js";function Ze(t){return ae("MuiTableContainer",t)}le("MuiTableContainer",["root"]);const et=["className","component"],tt=t=>{const{classes:s}=t;return ue({root:["root"]},Ze,s)},st=c("div",{name:"MuiTableContainer",slot:"Root",overridesResolver:(t,s)=>s.root})({width:"100%",overflowX:"auto"}),nt=d.forwardRef(function(s,n){const o=ie({props:s,name:"MuiTableContainer"}),{className:r,component:a="div"}=o,l=ce(o,et),u=$({},o,{component:a}),i=tt(u);return e.jsx(st,$({ref:n,as:a,className:de(i.root,r),ownerState:u},l))}),ot=()=>e.jsx(U,{severity:"info",children:e.jsxs("p",{children:["Read the"," ",e.jsx("a",{href:"https://docs.getunleash.io/sdks",target:"_blank",rel:"noreferrer",children:"SDK overview"})," ","to connect Unleash to your application. Please note it can take up to ",e.jsx("strong",{children:"1 minute"})," before a new API key is activated."]})}),k=({title:t,url:s})=>{const{setToastData:n}=L(),o=r=>()=>{X(r),n({type:"success",text:"Copied to clipboard"})};return e.jsxs(q,{children:[e.jsx(v,{component:"th",scope:"row",children:t}),e.jsx(v,{children:e.jsx("pre",{style:{display:"inline"},children:s})}),e.jsx(v,{align:"center",children:e.jsx(he,{title:"Copy URL",arrow:!0,children:e.jsx(pe,{onClick:o(s),size:"small","aria-label":`Copy ${t} to clipboard`,children:e.jsx(V,{})})})})]})},R=c(v)(({theme:t})=>({color:t.palette.text.secondary})),rt=({compact:t})=>{const{uiConfig:s}=y(),[n,o]=d.useState(!t),r=s.unleashUrl&&(n||!s.edgeUrl),a=t&&s.edgeUrl&&s.unleashUrl,l=s.edgeUrl?{edgeUrl:`${s.edgeUrl}/api/`,edgeFrontendUrl:`${s.edgeUrl}/api/frontend/`}:void 0,u=`${s.unleashUrl}/api/`,i=`${s.unleashUrl}/api/frontend/`;return e.jsxs(nt,{role:"region","aria-live":"polite",children:[e.jsxs(xe,{"aria-label":"API URLs",id:"api-urls-table",children:[e.jsx(me,{children:e.jsxs(q,{children:[e.jsx(R,{children:"Type"}),e.jsx(R,{children:"URL"}),e.jsx(R,{align:"center",children:"Actions"})]})}),e.jsxs(je,{children:[l&&e.jsxs(e.Fragment,{children:[e.jsx(k,{title:"Edge Backend",url:l.edgeUrl}),e.jsx(k,{title:"Edge Frontend",url:l.edgeFrontendUrl})]}),r&&e.jsxs(e.Fragment,{children:[e.jsx(k,{title:"Backend",url:u}),e.jsx(k,{title:"Frontend",url:i})]})]})]}),a&&e.jsx(Q,{sx:{mt:1,marginInline:1.5},variant:"text",size:"small","aria-expanded":n,"aria-controls":"api-urls-table",onClick:()=>o(!n),children:n?"Show less":"Show all"})]})},at=["Icon","createdAt","seenAt"],lt=["Icon","project","seenAt"],W=c(A)(({theme:t})=>({margin:0,marginBottom:t.spacing(1.5),fontSize:t.fontSizes.smallBody,color:t.palette.text.primary})),_t=({compact:t=!1,setHiddenColumns:s,columns:n,loading:o,rows:r,headerGroups:a,globalFilter:l,prepareRow:u})=>{const i=ge(be.breakpoints.down("xl"));return fe([{condition:i,columns:at},{condition:t,columns:lt}],s,n),e.jsxs(e.Fragment,{children:[e.jsx(f,{condition:r.length>0,show:e.jsxs(g,{sx:{mb:4},children:[e.jsx(ot,{}),e.jsxs(g,{sx:{marginBlock:4},children:[e.jsx(W,{variant:"h2",children:"API URLs"}),e.jsx(rt,{compact:t})]})]})}),e.jsxs(g,{sx:{overflowX:"auto"},children:[e.jsx(W,{variant:"h2",children:"API Tokens"}),e.jsx(ye,{value:l,children:e.jsx(Te,{rows:r,headerGroups:a,prepareRow:u})})]}),e.jsx(f,{condition:r.length===0&&!o,show:e.jsx(f,{condition:(l==null?void 0:l.length)>0,show:e.jsxs(K,{children:["No tokens found matching “",l,"”"]}),elseShow:e.jsx(K,{children:e.jsxs("span",{children:["No tokens available. Read ",e.jsx(B,{href:"https://docs.getunleash.io/api-overview",target:"_blank",rel:"noreferrer",children:"API How-to guides"})," "," to learn more."]})})})})]})},it=(t,s)=>{const n=s>=t;return{limitReached:n,limitMessage:n?`You have reached the limit of ${t} API tokens`:void 0}},Ft=({path:t,permission:s,project:n})=>{const o=Ce(),{tokens:r,loading:a}=Je(),{uiConfig:l}=y(),{limitReached:u,limitMessage:i}=it(l.resourceLimits.apiTokens,r.length);return e.jsx(ke,{Icon:Ae,onClick:()=>o(t),"data-testid":ve,permission:s,projectId:n,maxWidth:"700px",disabled:a||u,tooltipProps:{title:i},children:"New API token"})},ct=c(Y)(({theme:t})=>({textDecoration:"none",color:t.palette.links,"&:hover, &:focus":{textDecoration:"underline"}})),dt=c("div")({display:"flex",alignItems:"center"}),ut=({projects:t,project:s})=>{const{searchQuery:n}=we(),o=t&&Array.isArray(t)&&t.length>1?t:[];if(o.length>0)return e.jsx(w,{children:e.jsx(D,{title:o.map((r,a)=>e.jsxs(d.Fragment,{children:[a>0&&", ",!r||r==="*"?e.jsx(E,{search:n,children:"*"}):e.jsx(ct,{to:`/projects/${r}`,children:e.jsx(E,{search:n,children:r})})]},r)),placement:"bottom-start",arrow:!0,tabIndex:0,children:e.jsxs("span",{children:[`${o.length}`," projects"]})})});if(o.length===1&&o[0]!=="*"||s&&s!=="*"){const r=s||o[0];return e.jsx(Se,{to:`/projects/${r}`,title:r})}return e.jsx(w,{children:e.jsx(D,{title:"ALL current and future projects.",placement:"bottom",arrow:!0,children:e.jsx(dt,{children:e.jsx(E,{search:n,children:"*"})})})})};var P={},ht=Ne;Object.defineProperty(P,"__esModule",{value:!0});var ne=P.default=void 0,pt=ht(Ee()),xt=e,mt=(0,pt.default)((0,xt.jsx)("path",{d:"M21 10h-8.35C11.83 7.67 9.61 6 7 6c-3.31 0-6 2.69-6 6s2.69 6 6 6c2.61 0 4.83-1.67 5.65-4H13l2 2 2-2 2 2 4-4.04L21 10zM7 15c-1.65 0-3-1.35-3-3s1.35-3 3-3 3 1.35 3 3-1.35 3-3 3z"}),"Key");ne=P.default=mt;const jt=({secret:t,project:s,projects:n})=>{const o=t!=null&&t.includes(":")?"v2":"v1",r=t==null?void 0:t.startsWith("*:"),a=n&&(n==null?void 0:n.length)>1||(n==null?void 0:n.length)===1&&n[0]!=="*"||s&&s!=="*";return o==="v2"&&!r&&!a},gt=({...t})=>jt(t)?e.jsx(G,{icon:e.jsx(D,{title:e.jsxs("p",{children:["This is an orphaned token. All of its original projects have been deleted and it now has access to all current and future projects. You should stop using this token and delete it. Read more in"," ",e.jsx(B,{target:"_blank",rel:"noopener noreferrer",href:"https://github.com/Unleash/unleash/releases/tag/v6.1.0",children:"release notes"}),"."]}),placement:"bottom-start",arrow:!0,children:e.jsx(Ie,{"aria-label":"Orphaned token",color:"warning","data-testid":"orphaned-token-icon"})})}):e.jsx(G,{icon:e.jsx(ne,{color:"disabled"})}),Mt=(t,s)=>{const n=d.useMemo(()=>({sortBy:[{id:"createdAt",desc:!0}]}),[]),o=d.useMemo(()=>[{id:"Icon",Cell:p=>e.jsx(gt,{secret:p.row.original.secret,project:p.row.original.project,projects:p.row.original.projects}),disableSortBy:!0,disableGlobalFilter:!0,width:50},{Header:"Token name",accessor:"tokenName",Cell:N,minWidth:35},{Header:"Type",accessor:"type",Cell:({value:p})=>e.jsx(N,{value:z[p.toLowerCase()].label,subtitle:z[p.toLowerCase()].title,subtitleTooltip:!0}),width:180},{Header:"Project",accessor:"project",Cell:p=>e.jsx(ut,{project:p.row.original.project,projects:p.row.original.projects}),width:160},{Header:"Environment",accessor:"environment",Cell:N,width:120},{Header:"Created",accessor:"createdAt",Cell:Re,width:150,disableGlobalFilter:!0},{Header:"Last seen",accessor:"seenAt",Cell:De,width:140,disableGlobalFilter:!0},{Header:"Actions",width:120,id:"Actions",align:"center",disableSortBy:!0,disableGlobalFilter:!0,Cell:s}],[]),{getTableProps:r,getTableBodyProps:a,headerGroups:l,rows:u,prepareRow:i,state:j,setGlobalFilter:m,setHiddenColumns:b}=C.useTable({columns:o,data:t,initialState:n,sortTypes:Ue,autoResetHiddenColumns:!1,disableSortRemove:!0},C.useGlobalFilter,C.useSortBy,C.useFlexLayout);return{getTableProps:r,getTableBodyProps:a,headerGroups:l,rows:u,prepareRow:i,state:j,setGlobalFilter:m,setHiddenColumns:b,columns:o}},z={client:{label:"BACKEND",title:"Connect backend SDK or Unleash Edge"},backend:{label:"BACKEND",title:"Connect backend SDK or Unleash Edge"},frontend:{label:"FRONTEND",title:"Connect frontend SDK"},admin:{label:"ADMIN",title:"Full access for managing Unleash"}},Ot=({token:t,project:s,permission:n,track:o})=>{const{setToastData:r}=L(),a=l=>{X(l)&&(r({type:"success",text:"Token copied to clipboard"}),o&&typeof o=="function"&&o())};return e.jsx(J,{permission:n,projectId:s,tooltipProps:{title:"Copy token",arrow:!0},onClick:()=>a(t.secret),size:"large",children:e.jsx(V,{})})},bt=c("ul")({marginBottom:0}),Ht=({token:t,permission:s,onRemove:n,project:o})=>{const[r,a]=d.useState(!1),{setToastData:l,setToastApiError:u}=L(),i=async()=>{try{await n(),a(!1),l({type:"success",text:"API token removed"})}catch(j){u(Be(j))}};return e.jsxs(e.Fragment,{children:[e.jsx(J,{permission:s,projectId:o,tooltipProps:{title:"Delete token",arrow:!0},onClick:()=>a(!0),size:"large",children:e.jsx(Le,{})}),e.jsx(Z,{open:r,onClick:i,onClose:()=>a(!1),title:"Confirm deletion",children:e.jsxs("div",{children:["Are you sure you want to delete the following API token?",e.jsx("br",{}),e.jsxs(bt,{children:[e.jsxs("li",{children:[e.jsx("strong",{children:"name"}),":"," ",e.jsx("code",{children:t.tokenName})]}),e.jsxs("li",{children:[e.jsx("strong",{children:"type"}),": ",e.jsx("code",{children:t.type})]}),e.jsxs("li",{children:[e.jsx("strong",{children:"environment"}),":"," ",e.jsx("code",{children:t.environment})]})]})]})})]})},ft=c("div")(()=>({maxWidth:"400px"})),yt=c("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),Tt=c(Pe)(({theme:t})=>({width:"100%",marginBottom:t.spacing(2)})),Ct=c(_e)(({theme:t})=>({marginBottom:t.spacing(2),minWidth:"400px",[t.breakpoints.down("sm")]:{minWidth:"379px"}})),oe=c("p")(({theme:t})=>({marginBottom:t.spacing(1)})),kt=c("label")(({theme:t})=>({marginBottom:t.spacing(1)})),vt=c(Q)(({theme:t})=>({marginLeft:t.spacing(3)})),At=c(g)({marginTop:"auto",display:"flex",justifyContent:"flex-end"}),$t=({children:t,actions:s,handleSubmit:n,handleCancel:o})=>{var l;const{uiConfig:r}=y(),a=!!((l=r==null?void 0:r.flags)!=null&&l.UNLEASH_CLOUD);return e.jsxs(yt,{onSubmit:n,children:[e.jsx(f,{condition:a,show:e.jsxs(U,{severity:"info",sx:{mb:4},children:["Please be aware of our"," ",e.jsx(B,{href:"https://www.getunleash.io/fair-use-policy",children:"fair use policy"}),"."]})}),t,e.jsxs(At,{children:[s,e.jsx(vt,{onClick:o,children:"Cancel"})]})]})};var x=(t=>(t.ADMIN="ADMIN",t.CLIENT="CLIENT",t.FRONTEND="FRONTEND",t))(x||{});const Kt=t=>{var M,O;const{environments:s}=ee(),n=(M=s==null?void 0:s.find(h=>h.enabled))==null?void 0:M.name,o=I(Fe,t),r=[{key:x.CLIENT,label:"Backend SDK",title:"Creates a backend token to connect a backend SDK or Unleash Edge",enabled:I(Me)||o},{key:x.FRONTEND,label:"Frontend SDK",title:"Creates a frontend token to connect a frontend SDK",enabled:I(Oe)||o}],a=(O=r.find(h=>h.enabled))==null?void 0:O.key,[l,u]=d.useState(""),[i,j]=d.useState(a||x.CLIENT),[m,b]=d.useState([t||"*"]),[p,re]=d.useState(m),[_,T]=d.useState(),[F,S]=d.useState({});return d.useEffect(()=>{T(i==="ADMIN"?"*":n)},[i,n]),{tokenName:l,type:i,apiTokenTypes:r,projects:m,environment:_,setTokenName:u,setTokenType:h=>{h==="ADMIN"?(j(x.ADMIN),re(m),b(["*"]),T("*")):(j(h),b(p),T(n))},setProjects:b,setEnvironment:T,getApiTokenPayload:()=>({tokenName:l,type:i,environment:_,projects:m}),isValid:()=>{const h={};return l||(h.tokenName="Token name is required"),m.length===0&&(h.projects="At least one project is required"),S(h),Object.keys(h).length===0},clearErrors:h=>{if(h){const H={...F};delete H[h],S(H)}else S({})},errors:F}},Gt=({open:t,setOpen:s,closeConfirm:n,token:o,type:r})=>e.jsxs(Z,{open:t,setOpen:s,onClick:n,primaryButtonText:"Close",title:"New token created",children:[e.jsx(A,{variant:"body1",children:"Your new token has been created successfully."}),e.jsx(He,{token:o}),e.jsx(f,{condition:r===x.FRONTEND,show:e.jsxs(U,{sx:{mt:2},severity:"info",children:["By default, all ",x.FRONTEND," tokens may be used from any CORS origin. If you'd like to configure a strict set of origins, please use the"," ",e.jsx(Y,{to:"/admin/cors",target:"_blank",rel:"noreferrer",children:"CORS origins configuration page"}),"."]})})]}),Wt=({tokenName:t,setTokenName:s,errors:n,clearErrors:o})=>e.jsxs(e.Fragment,{children:[e.jsx(oe,{children:"What would you like to call this token?"}),e.jsx(Tt,{value:t,name:"tokenName",onChange:r=>s(r.target.value),label:"Token name",error:n.tokenName!==void 0,errorText:n.tokenName,onFocus:()=>o("tokenName"),autoFocus:!0})]}),zt=({type:t,setType:s,apiTokenTypes:n})=>e.jsx(ft,{children:e.jsxs($e,{sx:{mb:2,width:"100%"},children:[e.jsx(kt,{id:"token-type",children:"What do you want to connect?"}),e.jsx(Ke,{"aria-labelledby":"token-type",defaultValue:"CLIENT",name:"radio-buttons-group",value:t,onChange:(o,r)=>s(r),children:n.map(({key:o,label:r,title:a,enabled:l})=>e.jsx(Ge,{value:o,sx:{mb:1},disabled:!l,control:e.jsx(We,{sx:{ml:.75,alignSelf:"flex-start"}}),label:e.jsx(g,{children:e.jsxs(g,{children:[e.jsx(A,{children:r}),e.jsx(A,{variant:"body2",color:"text.secondary",children:a})]})})},o))})]})}),qt=({type:t,environment:s,setEnvironment:n})=>{const{environments:o}=ee(),r=t===x.ADMIN?[{key:"*",label:"ALL"}]:o.map(a=>({key:a.name,label:`${a.name.concat(a.enabled?"":" - deprecated")}`,title:a.name,disabled:!1}));return e.jsxs(e.Fragment,{children:[e.jsx(oe,{children:"Which environment should the token have access to?"}),e.jsx(Ct,{disabled:t===x.ADMIN,options:r,value:s,onChange:n,label:"Environment",id:"api_key_environment",name:"environment",IconComponent:ze,fullWidth:!0})]})},wt=t=>t.map(s=>({...s.user,joinedAt:new Date(s.joinedAt),createdBy:s.createdBy})),Vt=t=>{const{data:s,error:n,mutate:o}=qe(te(`api/admin/groups/${t}`),St);return d.useMemo(()=>({group:s&&{...s,users:wt((s==null?void 0:s.users)??[])},loading:!n&&!s,refetchGroup:()=>o(),error:n}),[s,n,o])},St=t=>fetch(t).then(se("Group")).then(s=>s.json()),Xt=()=>{const{isEnterprise:t}=y(),{data:s,error:n,mutate:o}=Ve(t(),{serviceAccounts:[],rootRoles:[]},te("api/admin/service-account"),Et);return d.useMemo(()=>({serviceAccounts:(s==null?void 0:s.serviceAccounts)??[],roles:(s==null?void 0:s.rootRoles)??[],loading:!n&&!s,refetch:()=>o(),error:n}),[s,n,o])},Et=t=>fetch(t).then(se("Service Accounts")).then(s=>s.json()),Nt=c("div")(({theme:t})=>({display:"flex",flexDirection:"column",gap:t.spacing(.5),"& > *:not(:last-child)":{borderBottom:`1px solid ${t.palette.divider}`,paddingBottom:t.spacing(1)}})),It=c(Ye)(()=>({display:"block"})),Qt=({role:t,roles:s,value:n})=>{const{isEnterprise:o}=y();if(o()){const r=s||[t];return e.jsx(w,{children:e.jsx(Xe,{tooltip:e.jsx(Nt,{children:r.map(a=>e.jsx(Qe,{roleId:a,tooltip:!0},a))}),children:e.jsx(It,{children:n})})})}return e.jsx(w,{children:n})};export{_t as A,Ft as C,qt as E,Ht as R,oe as S,x as T,Ot as a,Kt as b,$t as c,Wt as d,zt as e,Gt as f,Xt as g,Vt as h,Qt as i,ne as j,wt as m,Mt as u};
|
|
1
|
+
import{aD as ae,aE as le,r as d,aH as ie,_ as ce,a as $,j as e,aI as de,aK as ue,s as c,Q as U,f as L,ae as q,et as v,w as he,x as pe,hL as V,d3 as X,b9 as y,er as xe,es as me,ad as je,i as Q,ai as ge,dd as be,al as fe,C as f,B as g,au as ye,am as Te,av as K,cL as B,T as A,bq as Ce,eI as ke,kO as ve,bf as Ae,ey as we,ah as w,c9 as D,ez as E,ar as Se,L as Y,E as Ee,F as Ne,ag as G,fv as Ie,aj as N,eh as Re,eP as De,a9 as C,aa as Ue,cX as J,a$ as Le,aU as Z,h as Be,y as Pe,G as _e,ax as ee,b_ as I,jw as Fe,dK as Me,dJ as Oe,e1 as He,dZ as $e,fh as Ke,dX as Ge,fi as We,iu as ze,cp as qe,b6 as te,b8 as se,b7 as Ve,b0 as Xe,dT as Qe,b4 as Ye}from"./index-C0tV9tYB.js";import{u as Je}from"./useApiTokens-DDEZMbRy.js";function Ze(t){return ae("MuiTableContainer",t)}le("MuiTableContainer",["root"]);const et=["className","component"],tt=t=>{const{classes:s}=t;return ue({root:["root"]},Ze,s)},st=c("div",{name:"MuiTableContainer",slot:"Root",overridesResolver:(t,s)=>s.root})({width:"100%",overflowX:"auto"}),nt=d.forwardRef(function(s,n){const o=ie({props:s,name:"MuiTableContainer"}),{className:r,component:a="div"}=o,l=ce(o,et),u=$({},o,{component:a}),i=tt(u);return e.jsx(st,$({ref:n,as:a,className:de(i.root,r),ownerState:u},l))}),ot=()=>e.jsx(U,{severity:"info",children:e.jsxs("p",{children:["Read the"," ",e.jsx("a",{href:"https://docs.getunleash.io/sdks",target:"_blank",rel:"noreferrer",children:"SDK overview"})," ","to connect Unleash to your application. Please note it can take up to ",e.jsx("strong",{children:"1 minute"})," before a new API key is activated."]})}),k=({title:t,url:s})=>{const{setToastData:n}=L(),o=r=>()=>{X(r),n({type:"success",text:"Copied to clipboard"})};return e.jsxs(q,{children:[e.jsx(v,{component:"th",scope:"row",children:t}),e.jsx(v,{children:e.jsx("pre",{style:{display:"inline"},children:s})}),e.jsx(v,{align:"center",children:e.jsx(he,{title:"Copy URL",arrow:!0,children:e.jsx(pe,{onClick:o(s),size:"small","aria-label":`Copy ${t} to clipboard`,children:e.jsx(V,{})})})})]})},R=c(v)(({theme:t})=>({color:t.palette.text.secondary})),rt=({compact:t})=>{const{uiConfig:s}=y(),[n,o]=d.useState(!t),r=s.unleashUrl&&(n||!s.edgeUrl),a=t&&s.edgeUrl&&s.unleashUrl,l=s.edgeUrl?{edgeUrl:`${s.edgeUrl}/api/`,edgeFrontendUrl:`${s.edgeUrl}/api/frontend/`}:void 0,u=`${s.unleashUrl}/api/`,i=`${s.unleashUrl}/api/frontend/`;return e.jsxs(nt,{role:"region","aria-live":"polite",children:[e.jsxs(xe,{"aria-label":"API URLs",id:"api-urls-table",children:[e.jsx(me,{children:e.jsxs(q,{children:[e.jsx(R,{children:"Type"}),e.jsx(R,{children:"URL"}),e.jsx(R,{align:"center",children:"Actions"})]})}),e.jsxs(je,{children:[l&&e.jsxs(e.Fragment,{children:[e.jsx(k,{title:"Edge Backend",url:l.edgeUrl}),e.jsx(k,{title:"Edge Frontend",url:l.edgeFrontendUrl})]}),r&&e.jsxs(e.Fragment,{children:[e.jsx(k,{title:"Backend",url:u}),e.jsx(k,{title:"Frontend",url:i})]})]})]}),a&&e.jsx(Q,{sx:{mt:1,marginInline:1.5},variant:"text",size:"small","aria-expanded":n,"aria-controls":"api-urls-table",onClick:()=>o(!n),children:n?"Show less":"Show all"})]})},at=["Icon","createdAt","seenAt"],lt=["Icon","project","seenAt"],W=c(A)(({theme:t})=>({margin:0,marginBottom:t.spacing(1.5),fontSize:t.fontSizes.smallBody,color:t.palette.text.primary})),_t=({compact:t=!1,setHiddenColumns:s,columns:n,loading:o,rows:r,headerGroups:a,globalFilter:l,prepareRow:u})=>{const i=ge(be.breakpoints.down("xl"));return fe([{condition:i,columns:at},{condition:t,columns:lt}],s,n),e.jsxs(e.Fragment,{children:[e.jsx(f,{condition:r.length>0,show:e.jsxs(g,{sx:{mb:4},children:[e.jsx(ot,{}),e.jsxs(g,{sx:{marginBlock:4},children:[e.jsx(W,{variant:"h2",children:"API URLs"}),e.jsx(rt,{compact:t})]})]})}),e.jsxs(g,{sx:{overflowX:"auto"},children:[e.jsx(W,{variant:"h2",children:"API Tokens"}),e.jsx(ye,{value:l,children:e.jsx(Te,{rows:r,headerGroups:a,prepareRow:u})})]}),e.jsx(f,{condition:r.length===0&&!o,show:e.jsx(f,{condition:(l==null?void 0:l.length)>0,show:e.jsxs(K,{children:["No tokens found matching “",l,"”"]}),elseShow:e.jsx(K,{children:e.jsxs("span",{children:["No tokens available. Read ",e.jsx(B,{href:"https://docs.getunleash.io/api-overview",target:"_blank",rel:"noreferrer",children:"API How-to guides"})," "," to learn more."]})})})})]})},it=(t,s)=>{const n=s>=t;return{limitReached:n,limitMessage:n?`You have reached the limit of ${t} API tokens`:void 0}},Ft=({path:t,permission:s,project:n})=>{const o=Ce(),{tokens:r,loading:a}=Je(),{uiConfig:l}=y(),{limitReached:u,limitMessage:i}=it(l.resourceLimits.apiTokens,r.length);return e.jsx(ke,{Icon:Ae,onClick:()=>o(t),"data-testid":ve,permission:s,projectId:n,maxWidth:"700px",disabled:a||u,tooltipProps:{title:i},children:"New API token"})},ct=c(Y)(({theme:t})=>({textDecoration:"none",color:t.palette.links,"&:hover, &:focus":{textDecoration:"underline"}})),dt=c("div")({display:"flex",alignItems:"center"}),ut=({projects:t,project:s})=>{const{searchQuery:n}=we(),o=t&&Array.isArray(t)&&t.length>1?t:[];if(o.length>0)return e.jsx(w,{children:e.jsx(D,{title:o.map((r,a)=>e.jsxs(d.Fragment,{children:[a>0&&", ",!r||r==="*"?e.jsx(E,{search:n,children:"*"}):e.jsx(ct,{to:`/projects/${r}`,children:e.jsx(E,{search:n,children:r})})]},r)),placement:"bottom-start",arrow:!0,tabIndex:0,children:e.jsxs("span",{children:[`${o.length}`," projects"]})})});if(o.length===1&&o[0]!=="*"||s&&s!=="*"){const r=s||o[0];return e.jsx(Se,{to:`/projects/${r}`,title:r})}return e.jsx(w,{children:e.jsx(D,{title:"ALL current and future projects.",placement:"bottom",arrow:!0,children:e.jsx(dt,{children:e.jsx(E,{search:n,children:"*"})})})})};var P={},ht=Ne;Object.defineProperty(P,"__esModule",{value:!0});var ne=P.default=void 0,pt=ht(Ee()),xt=e,mt=(0,pt.default)((0,xt.jsx)("path",{d:"M21 10h-8.35C11.83 7.67 9.61 6 7 6c-3.31 0-6 2.69-6 6s2.69 6 6 6c2.61 0 4.83-1.67 5.65-4H13l2 2 2-2 2 2 4-4.04L21 10zM7 15c-1.65 0-3-1.35-3-3s1.35-3 3-3 3 1.35 3 3-1.35 3-3 3z"}),"Key");ne=P.default=mt;const jt=({secret:t,project:s,projects:n})=>{const o=t!=null&&t.includes(":")?"v2":"v1",r=t==null?void 0:t.startsWith("*:"),a=n&&(n==null?void 0:n.length)>1||(n==null?void 0:n.length)===1&&n[0]!=="*"||s&&s!=="*";return o==="v2"&&!r&&!a},gt=({...t})=>jt(t)?e.jsx(G,{icon:e.jsx(D,{title:e.jsxs("p",{children:["This is an orphaned token. All of its original projects have been deleted and it now has access to all current and future projects. You should stop using this token and delete it. Read more in"," ",e.jsx(B,{target:"_blank",rel:"noopener noreferrer",href:"https://github.com/Unleash/unleash/releases/tag/v6.1.0",children:"release notes"}),"."]}),placement:"bottom-start",arrow:!0,children:e.jsx(Ie,{"aria-label":"Orphaned token",color:"warning","data-testid":"orphaned-token-icon"})})}):e.jsx(G,{icon:e.jsx(ne,{color:"disabled"})}),Mt=(t,s)=>{const n=d.useMemo(()=>({sortBy:[{id:"createdAt",desc:!0}]}),[]),o=d.useMemo(()=>[{id:"Icon",Cell:p=>e.jsx(gt,{secret:p.row.original.secret,project:p.row.original.project,projects:p.row.original.projects}),disableSortBy:!0,disableGlobalFilter:!0,width:50},{Header:"Token name",accessor:"tokenName",Cell:N,minWidth:35},{Header:"Type",accessor:"type",Cell:({value:p})=>e.jsx(N,{value:z[p.toLowerCase()].label,subtitle:z[p.toLowerCase()].title,subtitleTooltip:!0}),width:180},{Header:"Project",accessor:"project",Cell:p=>e.jsx(ut,{project:p.row.original.project,projects:p.row.original.projects}),width:160},{Header:"Environment",accessor:"environment",Cell:N,width:120},{Header:"Created",accessor:"createdAt",Cell:Re,width:150,disableGlobalFilter:!0},{Header:"Last seen",accessor:"seenAt",Cell:De,width:140,disableGlobalFilter:!0},{Header:"Actions",width:120,id:"Actions",align:"center",disableSortBy:!0,disableGlobalFilter:!0,Cell:s}],[]),{getTableProps:r,getTableBodyProps:a,headerGroups:l,rows:u,prepareRow:i,state:j,setGlobalFilter:m,setHiddenColumns:b}=C.useTable({columns:o,data:t,initialState:n,sortTypes:Ue,autoResetHiddenColumns:!1,disableSortRemove:!0},C.useGlobalFilter,C.useSortBy,C.useFlexLayout);return{getTableProps:r,getTableBodyProps:a,headerGroups:l,rows:u,prepareRow:i,state:j,setGlobalFilter:m,setHiddenColumns:b,columns:o}},z={client:{label:"BACKEND",title:"Connect backend SDK or Unleash Edge"},backend:{label:"BACKEND",title:"Connect backend SDK or Unleash Edge"},frontend:{label:"FRONTEND",title:"Connect frontend SDK"},admin:{label:"ADMIN",title:"Full access for managing Unleash"}},Ot=({token:t,project:s,permission:n,track:o})=>{const{setToastData:r}=L(),a=l=>{X(l)&&(r({type:"success",text:"Token copied to clipboard"}),o&&typeof o=="function"&&o())};return e.jsx(J,{permission:n,projectId:s,tooltipProps:{title:"Copy token",arrow:!0},onClick:()=>a(t.secret),size:"large",children:e.jsx(V,{})})},bt=c("ul")({marginBottom:0}),Ht=({token:t,permission:s,onRemove:n,project:o})=>{const[r,a]=d.useState(!1),{setToastData:l,setToastApiError:u}=L(),i=async()=>{try{await n(),a(!1),l({type:"success",text:"API token removed"})}catch(j){u(Be(j))}};return e.jsxs(e.Fragment,{children:[e.jsx(J,{permission:s,projectId:o,tooltipProps:{title:"Delete token",arrow:!0},onClick:()=>a(!0),size:"large",children:e.jsx(Le,{})}),e.jsx(Z,{open:r,onClick:i,onClose:()=>a(!1),title:"Confirm deletion",children:e.jsxs("div",{children:["Are you sure you want to delete the following API token?",e.jsx("br",{}),e.jsxs(bt,{children:[e.jsxs("li",{children:[e.jsx("strong",{children:"name"}),":"," ",e.jsx("code",{children:t.tokenName})]}),e.jsxs("li",{children:[e.jsx("strong",{children:"type"}),": ",e.jsx("code",{children:t.type})]}),e.jsxs("li",{children:[e.jsx("strong",{children:"environment"}),":"," ",e.jsx("code",{children:t.environment})]})]})]})})]})},ft=c("div")(()=>({maxWidth:"400px"})),yt=c("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),Tt=c(Pe)(({theme:t})=>({width:"100%",marginBottom:t.spacing(2)})),Ct=c(_e)(({theme:t})=>({marginBottom:t.spacing(2),minWidth:"400px",[t.breakpoints.down("sm")]:{minWidth:"379px"}})),oe=c("p")(({theme:t})=>({marginBottom:t.spacing(1)})),kt=c("label")(({theme:t})=>({marginBottom:t.spacing(1)})),vt=c(Q)(({theme:t})=>({marginLeft:t.spacing(3)})),At=c(g)({marginTop:"auto",display:"flex",justifyContent:"flex-end"}),$t=({children:t,actions:s,handleSubmit:n,handleCancel:o})=>{var l;const{uiConfig:r}=y(),a=!!((l=r==null?void 0:r.flags)!=null&&l.UNLEASH_CLOUD);return e.jsxs(yt,{onSubmit:n,children:[e.jsx(f,{condition:a,show:e.jsxs(U,{severity:"info",sx:{mb:4},children:["Please be aware of our"," ",e.jsx(B,{href:"https://www.getunleash.io/fair-use-policy",children:"fair use policy"}),"."]})}),t,e.jsxs(At,{children:[s,e.jsx(vt,{onClick:o,children:"Cancel"})]})]})};var x=(t=>(t.ADMIN="ADMIN",t.CLIENT="CLIENT",t.FRONTEND="FRONTEND",t))(x||{});const Kt=t=>{var M,O;const{environments:s}=ee(),n=(M=s==null?void 0:s.find(h=>h.enabled))==null?void 0:M.name,o=I(Fe,t),r=[{key:x.CLIENT,label:"Backend SDK",title:"Creates a backend token to connect a backend SDK or Unleash Edge",enabled:I(Me)||o},{key:x.FRONTEND,label:"Frontend SDK",title:"Creates a frontend token to connect a frontend SDK",enabled:I(Oe)||o}],a=(O=r.find(h=>h.enabled))==null?void 0:O.key,[l,u]=d.useState(""),[i,j]=d.useState(a||x.CLIENT),[m,b]=d.useState([t||"*"]),[p,re]=d.useState(m),[_,T]=d.useState(),[F,S]=d.useState({});return d.useEffect(()=>{T(i==="ADMIN"?"*":n)},[i,n]),{tokenName:l,type:i,apiTokenTypes:r,projects:m,environment:_,setTokenName:u,setTokenType:h=>{h==="ADMIN"?(j(x.ADMIN),re(m),b(["*"]),T("*")):(j(h),b(p),T(n))},setProjects:b,setEnvironment:T,getApiTokenPayload:()=>({tokenName:l,type:i,environment:_,projects:m}),isValid:()=>{const h={};return l||(h.tokenName="Token name is required"),m.length===0&&(h.projects="At least one project is required"),S(h),Object.keys(h).length===0},clearErrors:h=>{if(h){const H={...F};delete H[h],S(H)}else S({})},errors:F}},Gt=({open:t,setOpen:s,closeConfirm:n,token:o,type:r})=>e.jsxs(Z,{open:t,setOpen:s,onClick:n,primaryButtonText:"Close",title:"New token created",children:[e.jsx(A,{variant:"body1",children:"Your new token has been created successfully."}),e.jsx(He,{token:o}),e.jsx(f,{condition:r===x.FRONTEND,show:e.jsxs(U,{sx:{mt:2},severity:"info",children:["By default, all ",x.FRONTEND," tokens may be used from any CORS origin. If you'd like to configure a strict set of origins, please use the"," ",e.jsx(Y,{to:"/admin/cors",target:"_blank",rel:"noreferrer",children:"CORS origins configuration page"}),"."]})})]}),Wt=({tokenName:t,setTokenName:s,errors:n,clearErrors:o})=>e.jsxs(e.Fragment,{children:[e.jsx(oe,{children:"What would you like to call this token?"}),e.jsx(Tt,{value:t,name:"tokenName",onChange:r=>s(r.target.value),label:"Token name",error:n.tokenName!==void 0,errorText:n.tokenName,onFocus:()=>o("tokenName"),autoFocus:!0})]}),zt=({type:t,setType:s,apiTokenTypes:n})=>e.jsx(ft,{children:e.jsxs($e,{sx:{mb:2,width:"100%"},children:[e.jsx(kt,{id:"token-type",children:"What do you want to connect?"}),e.jsx(Ke,{"aria-labelledby":"token-type",defaultValue:"CLIENT",name:"radio-buttons-group",value:t,onChange:(o,r)=>s(r),children:n.map(({key:o,label:r,title:a,enabled:l})=>e.jsx(Ge,{value:o,sx:{mb:1},disabled:!l,control:e.jsx(We,{sx:{ml:.75,alignSelf:"flex-start"}}),label:e.jsx(g,{children:e.jsxs(g,{children:[e.jsx(A,{children:r}),e.jsx(A,{variant:"body2",color:"text.secondary",children:a})]})})},o))})]})}),qt=({type:t,environment:s,setEnvironment:n})=>{const{environments:o}=ee(),r=t===x.ADMIN?[{key:"*",label:"ALL"}]:o.map(a=>({key:a.name,label:`${a.name.concat(a.enabled?"":" - deprecated")}`,title:a.name,disabled:!1}));return e.jsxs(e.Fragment,{children:[e.jsx(oe,{children:"Which environment should the token have access to?"}),e.jsx(Ct,{disabled:t===x.ADMIN,options:r,value:s,onChange:n,label:"Environment",id:"api_key_environment",name:"environment",IconComponent:ze,fullWidth:!0})]})},wt=t=>t.map(s=>({...s.user,joinedAt:new Date(s.joinedAt),createdBy:s.createdBy})),Vt=t=>{const{data:s,error:n,mutate:o}=qe(te(`api/admin/groups/${t}`),St);return d.useMemo(()=>({group:s&&{...s,users:wt((s==null?void 0:s.users)??[])},loading:!n&&!s,refetchGroup:()=>o(),error:n}),[s,n,o])},St=t=>fetch(t).then(se("Group")).then(s=>s.json()),Xt=()=>{const{isEnterprise:t}=y(),{data:s,error:n,mutate:o}=Ve(t(),{serviceAccounts:[],rootRoles:[]},te("api/admin/service-account"),Et);return d.useMemo(()=>({serviceAccounts:(s==null?void 0:s.serviceAccounts)??[],roles:(s==null?void 0:s.rootRoles)??[],loading:!n&&!s,refetch:()=>o(),error:n}),[s,n,o])},Et=t=>fetch(t).then(se("Service Accounts")).then(s=>s.json()),Nt=c("div")(({theme:t})=>({display:"flex",flexDirection:"column",gap:t.spacing(.5),"& > *:not(:last-child)":{borderBottom:`1px solid ${t.palette.divider}`,paddingBottom:t.spacing(1)}})),It=c(Ye)(()=>({display:"block"})),Qt=({role:t,roles:s,value:n})=>{const{isEnterprise:o}=y();if(o()){const r=s||[t];return e.jsx(w,{children:e.jsx(Xe,{tooltip:e.jsx(Nt,{children:r.map(a=>e.jsx(Qe,{roleId:a,tooltip:!0},a))}),children:e.jsx(It,{children:n})})})}return e.jsx(w,{children:n})};export{_t as A,Ft as C,qt as E,Ht as R,oe as S,x as T,Ot as a,Kt as b,$t as c,Wt as d,zt as e,Gt as f,Xt as g,Vt as h,Qt as i,ne as j,wt as m,Mt as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,aU as O,i as I,u as N,r as C,ao as P,lr as ee,bf as te,cU as ae,aX as U,w as ne,s as M,cj as se,aN as re,ls as oe,f as ie,aQ as de,aT as ue,aR as le,K as k,h as q}from"./index-
|
|
1
|
+
import{j as e,aU as O,i as I,u as N,r as C,ao as P,lr as ee,bf as te,cU as ae,aX as U,w as ne,s as M,cj as se,aN as re,ls as oe,f as ie,aQ as de,aT as ue,aR as le,K as k,h as q}from"./index-C0tV9tYB.js";const ce=({isOpen:t,onConfirm:a,onClose:n,safeguardData:r,mode:s,safeguardType:d})=>{const{metricName:p}=r.impactMetric,g=d==="featureEnvironment"?"disables the environment":"pauses automation";return e.jsx(O,{title:"Request changes",open:t,secondaryButtonText:"Cancel",onClose:n,customButton:e.jsx(I,{color:"primary",variant:"contained",onClick:a,autoFocus:!0,children:"Add suggestion to draft"}),children:e.jsxs("p",{children:[s==="create"?"Add":"Update"," safeguard that an"," ",g," based on ",e.jsx("strong",{children:p})]})})},ge=()=>{const{makeRequest:t,createRequest:a,errors:n,loading:r}=N({propagateErrors:!0});return{createOrUpdateReleasePlanSafeguard:async({projectId:u,featureName:h,environment:i,planId:f,body:l})=>{const c="createOrUpdateReleasePlanSafeguard",m=`api/admin/projects/${u}/features/${h}/environments/${i}/release-plans/${f}/safeguards`,x=a(m,{method:"PUT",body:JSON.stringify(l)},c);await t(x.caller,x.id)},createOrUpdateFeatureEnvironmentSafeguard:async({projectId:u,featureName:h,environment:i,body:f})=>{const l="createOrUpdateFeatureEnvironmentSafeguard",c=`api/admin/projects/${u}/features/${h}/environments/${i}/safeguards`,m=a(c,{method:"PUT",body:JSON.stringify(f)},l);await t(m.caller,m.id)},deleteReleasePlanSafeguard:async({projectId:u,featureName:h,environment:i,planId:f,safeguardId:l})=>{const c="deleteReleasePlanSafeguard",m=`api/admin/projects/${u}/features/${h}/environments/${i}/release-plans/${f}/safeguards/${l}`,x=a(m,{method:"DELETE"},c);await t(x.caller,x.id)},deleteFeatureEnvironmentSafeguard:async({projectId:u,featureName:h,environment:i,safeguardId:f})=>{const l="deleteFeatureEnvironmentSafeguard",c=`api/admin/projects/${u}/features/${h}/environments/${i}/safeguards/${f}`,m=a(c,{method:"DELETE"},l);await t(m.caller,m.id)},errors:n,loading:r}},fe=({open:t,onClose:a,onConfirm:n,isDeleting:r=!1})=>e.jsxs(O,{title:"Remove safeguard?",open:t,primaryButtonText:r?"Removing...":"Remove safeguard",secondaryButtonText:"Cancel",onClick:n,onClose:a,disabledPrimaryButton:r,children:[e.jsx("p",{children:"You are about to remove the safeguard that pauses automation when conditions are met."}),e.jsx("br",{}),e.jsx("p",{children:"This action cannot be undone."})]}),R=M("div")(({theme:t})=>({display:"flex",padding:t.spacing(.25,.25),backgroundColor:se(t),borderTop:`1px solid ${t.palette.divider}`,borderBottom:`1px solid ${t.palette.divider}`,"& > form":{borderRadius:0,border:"none"}})),pe=M("div")(({theme:t})=>({display:"flex",alignItems:"center",gap:t.spacing(1),justifyContent:"space-between",width:"100%",paddingRight:t.spacing(2)})),he=({onSelect:t,releasePlan:a})=>{const[n,r]=C.useState(null),{trackEvent:s}=P();return e.jsxs(R,{children:[e.jsx(pe,{children:e.jsx(ee,{onClick:d=>{s("safeguards",{props:{eventType:"choose safeguard opened"}}),r(d.currentTarget)},color:"primary",startIcon:e.jsx(te,{}),sx:{m:2},children:"Add safeguard"})}),e.jsxs(ae,{anchorEl:n,open:!!n,onClose:()=>r(null),children:[e.jsx(U,{onClick:()=>{s("safeguards",{props:{eventType:"form opened",safeguardType:"featureEnvironment"}}),t("featureEnvironment"),r(null)},children:"Disable environment"}),e.jsx(ne,{title:a?"":"Add a release plan to use this safeguard",placement:"right",arrow:!0,children:e.jsx("span",{children:e.jsx(U,{disabled:!a,onClick:()=>{s("safeguards",{props:{eventType:"form opened",safeguardType:"releasePlan"}}),t("releasePlan"),r(null)},children:"Pause automation"})})})]})]})},me=({projectId:t,featureId:a,environmentName:n,safeguardType:r,releasePlan:s,safeguard:d,onSafeguardChange:p})=>{const{setToastData:g,setToastApiError:u}=ie(),{trackEvent:h}=P(),{addChange:i}=de(),{isChangeRequestConfigured:f}=ue(t),{data:l,refetch:c}=le(t),{createOrUpdateReleasePlanSafeguard:m,deleteReleasePlanSafeguard:x,createOrUpdateFeatureEnvironmentSafeguard:T,deleteFeatureEnvironmentSafeguard:L}=ge(),[J,A]=C.useState(!1),[K,F]=C.useState(!1),[Q,w]=C.useState(!1),[j,$]=C.useState(null),[y,E]=C.useState(!1),B=f(n),X=r==="releasePlan"&&s?o=>m({projectId:t,featureName:a,environment:n,planId:s.id,body:o}):o=>T({projectId:t,featureName:a,environment:n,body:o}),Y=r==="releasePlan"&&s?o=>x({projectId:t,featureName:a,environment:n,planId:s.id,safeguardId:o}):o=>L({projectId:t,featureName:a,environment:n,safeguardId:o}),_=async o=>{if(h("safeguards",{props:{eventType:"safeguard submitted",safeguardType:r}}),B){$(o),w(!0);return}try{await X(o),g({type:"success",text:"Safeguard added successfully"}),p()}catch(S){u(q(S))}},z=async()=>{if(j)try{if(r==="featureEnvironment")await i(t,n,{feature:a,action:"changeFeatureEnvSafeguard",payload:{safeguard:j}});else{if(!s)return;await i(t,n,{feature:a,action:"changeReleasePlanSafeguard",payload:{planId:s.id,safeguard:j}})}await c(),g({type:"success",text:"Added to draft"}),p()}catch(o){u(q(o))}finally{w(!1),$(null)}},G=()=>{d&&(B?F(!0):A(!0))},H=async()=>{if(!(!d||y)){E(!0);try{await Y(d.id),g({type:"success",text:"Safeguard deleted successfully"}),p()}catch(o){u(q(o))}finally{E(!1),A(!1)}}},V=async()=>{if(!(!d||y)){E(!0);try{if(r==="featureEnvironment")await i(t,n,{feature:a,action:"deleteFeatureEnvSafeguard",payload:{safeguardId:d.id}});else{if(!s)return;await i(t,n,{feature:a,action:"deleteReleasePlanSafeguard",payload:{planId:s.id,safeguardId:d.id}})}await c(),g({type:"success",text:"Added to draft"}),p()}catch(o){u(q(o))}finally{E(!1),F(!1)}}},W=o=>{var b;const S=(o.action==="changeReleasePlanSafeguard"||o.action==="deleteReleasePlanSafeguard")&&!!s&&((b=o.payload)==null?void 0:b.planId)===s.id,v=o.action==="changeFeatureEnvSafeguard"||o.action==="deleteFeatureEnvSafeguard";return S||v},Z=C.useMemo(()=>{if(!l)return null;for(const o of l){if(o.environment!==n)continue;const S=o.features.find(b=>b.name===a);if(!S)continue;const v=S.changes.find(W);if(v)return v.action}return null},[l,n,a,s==null?void 0:s.id]);return{handleSubmit:_,handleDeleteRequest:G,pendingSafeguardAction:Z,deleteDialog:{open:J,isDeleting:y,onConfirm:H,onClose:()=>{y||A(!1)}},deleteChangeRequestDialog:{open:K,isDeleting:y,onConfirm:V,onClose:()=>F(!1)},submitChangeRequestDialog:{open:Q,data:j,onConfirm:z,onClose:()=>{w(!1),$(null)}}}},D=({safeguardType:t,releasePlan:a,safeguard:n,environmentName:r,featureId:s,onSafeguardChange:d,onCancel:p})=>{const g=re("projectId"),{handleSubmit:u,handleDeleteRequest:h,pendingSafeguardAction:i,deleteDialog:f,deleteChangeRequestDialog:l,submitChangeRequestDialog:c}=me({projectId:g,featureId:s,environmentName:r,safeguardType:t,releasePlan:a,safeguard:n,onSafeguardChange:d}),T=i==="deleteReleasePlanSafeguard"||i==="deleteFeatureEnvSafeguard"?e.jsx(k,{color:"error",children:"Deleted in draft"}):i==="changeReleasePlanSafeguard"||i==="changeFeatureEnvSafeguard"?e.jsx(k,{color:"warning",children:"Modified in draft"}):void 0;return e.jsxs(e.Fragment,{children:[e.jsx(oe,{safeguard:n,onSubmit:u,onCancel:p,onDelete:n?h:void 0,environment:r,featureId:s,badge:T,safeguardType:t}),c.data&&e.jsx(ce,{isOpen:c.open,onConfirm:c.onConfirm,onClose:()=>{c.onClose(),p()},safeguardData:c.data,environment:r,mode:n?"edit":"create",safeguardType:t}),n&&e.jsx(fe,{open:f.open,onClose:f.onClose,onConfirm:f.onConfirm,isDeleting:f.isDeleting}),n&&e.jsx(O,{title:"Request changes",open:l.open,secondaryButtonText:"Cancel",onClose:l.onClose,primaryButtonText:"Add suggestion to draft",onClick:l.onConfirm,disabledPrimaryButton:l.isDeleting,children:e.jsxs("p",{children:[e.jsx("strong",{children:"Remove"})," safeguard",a&&e.jsxs(e.Fragment,{children:[" ","from release plan"," ",e.jsx("strong",{children:a.name})]})," ","for ",e.jsx("strong",{children:s})," in"," ",e.jsx("strong",{children:r})]})})]})},Ce=({featureEnvSafeguard:t,releasePlan:a,environmentName:n,featureId:r,onSafeguardChange:s})=>{var i;const d=(i=a==null?void 0:a.safeguards)==null?void 0:i[0],[p,g]=C.useState(null),u=()=>{g(null),s()};return t||d?e.jsxs(e.Fragment,{children:[t&&e.jsx(R,{children:e.jsx(D,{safeguardType:"featureEnvironment",safeguard:t,environmentName:n,featureId:r,onSafeguardChange:u,onCancel:()=>{}})}),d&&e.jsx(R,{children:e.jsx(D,{safeguardType:"releasePlan",releasePlan:a,safeguard:d,environmentName:n,featureId:r,onSafeguardChange:u,onCancel:()=>{}})})]}):p==="featureEnvironment"?e.jsx(R,{children:e.jsx(D,{safeguardType:"featureEnvironment",environmentName:n,featureId:r,onSafeguardChange:s,onCancel:()=>g(null)})}):p==="releasePlan"&&a?e.jsx(R,{children:e.jsx(D,{safeguardType:"releasePlan",releasePlan:a,environmentName:n,featureId:r,onSafeguardChange:s,onCancel:()=>g(null)})}):e.jsx(he,{onSelect:g,releasePlan:a})};export{he as AddSafeguard,Ce as Safeguard,Ce as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as n,aU as f,s as g,L as m,b6 as d,cp as y,r as p,ba as v,b8 as x,ao as b,b9 as k,cg as E,G as F}from"./index-
|
|
1
|
+
import{j as n,aU as f,s as g,L as m,b6 as d,cp as y,r as p,ba as v,b8 as x,ao as b,b9 as k,cg as E,G as F}from"./index-C0tV9tYB.js";const M=g(m)(({theme:a})=>({textDecoration:"none",color:a.palette.primary.main,fontWeight:a.fontWeight.bold})),U=({isOpen:a,onClose:s,features:e,project:t})=>n.jsxs(f,{title:"You can't archive a feature that other features depend on",open:a,primaryButtonText:"OK",onClick:s,children:[n.jsx("p",{children:"The following features depend on your feature:"}),n.jsx("ul",{children:e.map(r=>n.jsx("li",{children:n.jsx(M,{to:`/projects/${t}/features/${r}`,target:"_blank",rel:"noopener noreferrer",children:r})},r))})]}),L=d("api/admin/client-metrics/features"),j=(a,s)=>{const e=d(`api/admin/client-metrics/features/${a}/raw?hoursBack=${s}`),{data:t,error:r}=y(e,()=>R(e)),i=p.useCallback(()=>{v(L).catch(console.warn)},[]);return{featureMetrics:t==null?void 0:t.data,loading:!r&&!t,refetchFeatureMetrics:i,error:r}},R=a=>fetch(a).then(x("Features")).then(s=>s.json()).then(),w=48,$=({hoursBack:a,setHoursBack:s,label:e="Period"})=>{const{trackEvent:t}=b(),r=o=>{s(Number.parseInt(o,10)),t("feature-metrics",{props:{eventType:"change-period",hoursBack:o}})},{isEnterprise:i}=k(),h=E("extendedUsageMetrics"),l=i()&&h?[...u,...A]:u,c=l.map(o=>Number(o.key)).includes(a)?a:w;return p.useEffect(()=>{a!==c&&s(c)},[a]),n.jsx("div",{children:n.jsx(F,{name:"feature-metrics-period",label:e,id:"feature-metrics-period",options:l,value:String(c),onChange:r,fullWidth:!0})})},u=[{key:"1",label:"Last hour"},{key:"24",label:"Last 24 hours"},{key:"48",label:"Last 48 hours"}],A=[{key:`${7*24}`,label:"Last 7 days"},{key:`${30*24}`,label:"Last 30 days"},{key:`${90*24}`,label:"Last 90 days"}],C=a=>{const s=new Map;return a.forEach(e=>{let t=s.get(e.timestamp);if(t||(t={...e,yes:0,no:0,variants:{}},s.set(e.timestamp,t)),t.yes+=e.yes,t.no+=e.no,e.variants){t.variants=t.variants||{};for(const[r,i]of Object.entries(e.variants))t.variants[r]=(t.variants[r]||0)+i}}),Array.from(s.values()).map(e=>({...e,variants:e.variants&&Object.keys(e.variants).length===0?void 0:e.variants}))};export{U as F,w as a,C as b,$ as c,j as u};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{lg as ct,lx as E,ly as w,lz as p,lh as Q,lA as fe,lB as b,lC as ut,lD as ft,lE as D,lf as K,lc as he,lF as Ve,lG as Ce,lH as $e,la as B,le as X,lI as ht,lJ as _,lK as J,lL as Pe,lM as yt,ds as oe,lN as bt,lO as gt,lP as T,lQ as mt}from"./index-
|
|
1
|
+
import{lg as ct,lx as E,ly as w,lz as p,lh as Q,lA as fe,lB as b,lC as ut,lD as ft,lE as D,lf as K,lc as he,lF as Ve,lG as Ce,lH as $e,la as B,le as X,lI as ht,lJ as _,lK as J,lL as Pe,lM as yt,ds as oe,lN as bt,lO as gt,lP as T,lQ as mt}from"./index-C0tV9tYB.js";/*!
|
|
2
2
|
* chartjs-plugin-annotation v2.2.1
|
|
3
3
|
* https://www.chartjs.org/chartjs-plugin-annotation/index
|
|
4
4
|
* (c) 2023 chartjs-plugin-annotation Contributors
|