unleash-server
Version:
Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.
2 lines (1 loc) • 4.07 kB
JavaScript
import{bk as m,Q as f,s as a,bz as R,j as e,N as c,b_ as T,j7 as g,j8 as v,cV as P,j9 as u,C as h,W as p,L as x,iQ as B,iR as E,iS as I,iT as M,iU as k,iV as z,iW as N}from"./index-DEkgmbaI.js";import{B as $}from"./index-ZiL5S4gH.js";import{a as A}from"./formatTickValue-rCxDfz30.js";import{u as W,a as _,B as F,S as H,T as O,P as Q,c as V,g as Y}from"./useChartDataSelection-BHo-osxd.js";const j=53e6,G=j,J=()=>{const{isPro:s,isEnterprise:r,uiConfig:n}=m(),t=f("enterprise-payg");return s()?j:t&&r()&&n.billing==="pay-as-you-go"?G:0},y=a("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)})),S=a("h3")(({theme:s})=>({margin:0,fontSize:s.typography.body1.fontSize})),w=a("dl")(({theme:s})=>({display:"flex",flexDirection:"column",gap:s.spacing(2.5),padding:0,margin:0})),o=a("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}})),K=s=>{const r=n=>n.toLocaleString("en-US",{month:"short",year:"numeric"});if(s.grouping==="monthly"){const n=new Date,t=g(n,s.monthsBack),i=g(n,1);return`Average requests from ${r(t)} to ${r(i)}`}return`Incoming requests in ${r(v(s.month))}`},X=({period:s,usageTotal:r,includedTraffic:n})=>{const{locationSettings:t}=R();return e.jsxs(y,{children:[e.jsx(S,{children:"Number of requests to Unleash"}),e.jsxs(w,{children:[e.jsxs(o,{children:[e.jsx("dt",{children:K(s)}),e.jsx("dd",{children:e.jsxs(c,{color:n>0?r<=n?"success":"error":"neutral",children:[r.toLocaleString(t.locale??"en-US")," ","requests"]})})]}),n>0&&e.jsxs(o,{children:[e.jsx("dt",{children:"Included in your plan monthly"}),e.jsxs("dd",{children:[n.toLocaleString("en-US")," requests"]})]})]})]})},Z=({overages:s,overageCost:r,estimatedMonthlyCost:n})=>e.jsxs(y,{children:[e.jsx(S,{children:"Accrued traffic charges"}),e.jsxs(w,{children:[e.jsxs(o,{children:[e.jsxs("dt",{children:["Request overages this month (",e.jsx(T,{href:"https://www.getunleash.io/pricing",children:"pricing"}),")"]}),e.jsxs("dd",{children:[s.toLocaleString()," requests"]})]}),e.jsxs(o,{children:[e.jsx("dt",{children:"Accrued traffic charges"}),e.jsx("dd",{children:e.jsxs(c,{color:"secondary",children:[r," USD"]})})]}),n>0&&e.jsxs(o,{children:[e.jsx("dt",{children:"Estimated charges based on current usage"}),e.jsx("dd",{children:e.jsxs(c,{color:"secondary",children:[n," USD"]})})]})]})]}),ee=a("div")(({theme:s})=>({display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, max-content))",flex:1,gap:s.spacing(2,4)})),oe=()=>{P("Network - Data Usage");const s=f("estimateTrafficDataCost"),{isOss:r}=m(),n=J(),{chartDataSelection:t,setChartDataSelection:i,options:b}=W(n),{chartData:C,usageTotal:l,overageCost:d,estimatedMonthlyCost:q,requestSummaryUsage:L}=_(n,t),U=t.grouping==="daily"&&t.month===u&&n>0&&l-n>0&&s,D=(t.grouping==="monthly"||t.month===u)&&n>0&&d>0;return e.jsx(h,{condition:r(),show:e.jsx(p,{severity:"warning",children:"Not enabled."}),elseShow:e.jsxs(e.Fragment,{children:[e.jsx(h,{condition:D,show:e.jsxs(p,{severity:"warning",sx:{mb:4},children:[e.jsx(F,{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(x,{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(x,{to:"https://docs.getunleash.io/reference/unleash-edge",children:"Unleash Edge instance"})," ","in your own datacenter."]})}),e.jsxs(H,{children:[e.jsxs(O,{children:[e.jsxs(ee,{children:[e.jsx(X,{period:t,usageTotal:L,includedTraffic:n}),U&&e.jsx(Z,{overageCost:d,overages:l-n,estimatedMonthlyCost:q})]}),e.jsx(Q,{selectedPeriod:t,setPeriod:i})]}),e.jsx($,{data:C,plugins:[V()],options:b,"aria-label":Y(t)})]})]})})};B.register(A,E,I,M,k,z,N);export{oe as default};