unleash-server 5.1.1 → 5.1.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/app.js +2 -0
- package/dist/lib/app.js.map +1 -1
- package/dist/lib/middleware/reject-double-slashes-in-path.d.ts +2 -0
- package/dist/lib/middleware/reject-double-slashes-in-path.js +14 -0
- package/dist/lib/middleware/reject-double-slashes-in-path.js.map +1 -0
- package/dist/test/e2e/api/auth/leading-slashes-are-stripped.e2e.test.d.ts +1 -0
- package/dist/test/e2e/api/auth/leading-slashes-are-stripped.e2e.test.js +55 -0
- package/dist/test/e2e/api/auth/leading-slashes-are-stripped.e2e.test.js.map +1 -0
- package/frontend/build/index.html +1 -1
- package/frontend/build/static/{CreateProject-3c093214.js → CreateProject-217f67b6.js} +1 -1
- package/frontend/build/static/{Error-10dff66c.js → Error-5606eccd.js} +1 -1
- package/frontend/build/static/FeatureArchiveDialog-c311c641.js +4 -0
- package/frontend/build/static/{FeatureMetricsChart-d5c6311d.js → FeatureMetricsChart-1c6bb078.js} +1 -1
- package/frontend/build/static/{FeatureViewLazyExport-e52ae7b0.js → FeatureViewLazyExport-06cf4baa.js} +2 -2
- package/frontend/build/static/{LazyAdminExport-2554e446.js → LazyAdminExport-04c8032d.js} +2 -2
- package/frontend/build/static/{LazyProjectExport-682e75c0.js → LazyProjectExport-d9663a8c.js} +1 -1
- package/frontend/build/static/{NetworkOverview-4653e26c.js → NetworkOverview-2bce4916.js} +1 -1
- package/frontend/build/static/{NetworkTraffic-4332556b.js → NetworkTraffic-7db94d86.js} +1 -1
- package/frontend/build/static/{Playground-130e9113.js → Playground-6602cb1a.js} +1 -1
- package/frontend/build/static/{StrategyItemContainer-893b13f0.js → StrategyItemContainer-0140b94f.js} +1 -1
- package/frontend/build/static/{chartjs-adapter-date-fns.esm-23b8f0d9.js → chartjs-adapter-date-fns.esm-c75aa905.js} +1 -1
- package/frontend/build/static/{index-66ec1ba9.js → index-1f392976.js} +2 -2
- package/frontend/build/static/{index-4d0a5ffb.js → index-b3def5eb.js} +1 -1
- package/frontend/build/static/{index-e7efdb59.js → index-f8439975.js} +1 -1
- package/frontend/build/static/{unknownify-6ed6e58e.js → unknownify-6683037a.js} +1 -1
- package/frontend/build/static/{useProjectRole-ce09b03e.js → useProjectRole-122ac4bb.js} +1 -1
- package/package.json +1 -1
- package/frontend/build/static/FeatureArchiveDialog-365cb2af.js +0 -4
package/dist/lib/app.js
CHANGED
|
@@ -28,6 +28,7 @@ const maintenance_middleware_1 = __importDefault(require("./middleware/maintenan
|
|
|
28
28
|
const unless_middleware_1 = require("./middleware/unless-middleware");
|
|
29
29
|
const catch_all_error_handler_1 = require("./middleware/catch-all-error-handler");
|
|
30
30
|
const notfound_error_1 = __importDefault(require("./error/notfound-error"));
|
|
31
|
+
const reject_double_slashes_in_path_1 = require("./middleware/reject-double-slashes-in-path");
|
|
31
32
|
async function getApp(config, stores, services, unleashSession, db) {
|
|
32
33
|
const app = (0, express_1.default)();
|
|
33
34
|
const baseUriPath = config.server.baseUriPath || '';
|
|
@@ -62,6 +63,7 @@ async function getApp(config, stores, services, unleashSession, db) {
|
|
|
62
63
|
if (config.enableOAS && services.openApiService) {
|
|
63
64
|
services.openApiService.useDocs(app);
|
|
64
65
|
}
|
|
66
|
+
app.use(`${baseUriPath}/`, reject_double_slashes_in_path_1.rejectDoubleSlashesInPath);
|
|
65
67
|
// Support CORS preflight requests for the frontend endpoints.
|
|
66
68
|
// Preflight requests should not have Authorization headers,
|
|
67
69
|
// so this must be handled before the API token middleware.
|
package/dist/lib/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/lib/app.ts"],"names":[],"mappings":";;;;;AAAA,sDAA+D;AAC/D,8DAAsC;AACtC,kEAAoC;AACpC,kEAAyC;AACzC,gDAAwB;AACxB,gEAAwC;AACxC,8EAAyE;AACzE,gFAA2E;AAC3E,mFAA0D;AAC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AG,EAAE,EAAE;QACnC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,sBAAsB;IACtB,GAAG,CAAC,GAAG,CAAC,GAAG,WAAW,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACvC,MAAM,KAAK,GAAG,IAAI,wBAAa,CAC3B,kCAAkC,WAAW,OAAO,GAAG,CAAC,IAAI,qBAAqB,CACpF,CAAC;QACF,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzC,OAAO;IACX,CAAC,CAAC,CAAC;IAEH,GAAG,CAAC,GAAG,CAAC,GAAG,WAAW,IAAI,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACrC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACf,CAAC;AAxKD,yBAwKC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rejectDoubleSlashesInPath = void 0;
|
|
4
|
+
const MULTIPLE_SLASHES = /\/\/+/;
|
|
5
|
+
const rejectDoubleSlashesInPath = (req, res, next) => {
|
|
6
|
+
if (req.path.match(MULTIPLE_SLASHES)) {
|
|
7
|
+
res.status(404).send();
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
next();
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
exports.rejectDoubleSlashesInPath = rejectDoubleSlashesInPath;
|
|
14
|
+
//# sourceMappingURL=reject-double-slashes-in-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reject-double-slashes-in-path.js","sourceRoot":"","sources":["../../../src/lib/middleware/reject-double-slashes-in-path.ts"],"names":[],"mappings":";;;AAEA,MAAM,gBAAgB,GAAG,OAAO,CAAC;AAE1B,MAAM,yBAAyB,GAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;IACxE,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE;QAClC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;KAC1B;SAAM;QACH,IAAI,EAAE,CAAC;KACV;AACL,CAAC,CAAC;AANW,QAAA,yBAAyB,6BAMpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const no_logger_1 = __importDefault(require("../../../fixtures/no-logger"));
|
|
7
|
+
const database_init_1 = __importDefault(require("../../helpers/database-init"));
|
|
8
|
+
const test_helper_1 = require("../../helpers/test-helper");
|
|
9
|
+
const types_1 = require("../../../../lib/types");
|
|
10
|
+
const api_token_1 = require("../../../../lib/types/models/api-token");
|
|
11
|
+
let app;
|
|
12
|
+
let appWithBaseUrl;
|
|
13
|
+
let stores;
|
|
14
|
+
let db;
|
|
15
|
+
beforeAll(async () => {
|
|
16
|
+
db = await (0, database_init_1.default)('multiple_leading_slashes_are_still_authed_serial', no_logger_1.default);
|
|
17
|
+
stores = db.stores;
|
|
18
|
+
app = await (0, test_helper_1.setupAppWithAuth)(stores, {
|
|
19
|
+
authentication: { enableApiToken: true, type: types_1.IAuthType.DEMO },
|
|
20
|
+
});
|
|
21
|
+
appWithBaseUrl = await (0, test_helper_1.setupAppWithAuth)(stores, {
|
|
22
|
+
server: { baseUriPath: '/demo' },
|
|
23
|
+
authentication: { enableApiToken: true, type: types_1.IAuthType.DEMO },
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
afterAll(async () => {
|
|
27
|
+
await app.destroy();
|
|
28
|
+
await db.destroy();
|
|
29
|
+
});
|
|
30
|
+
test('Access to /api/client/features are refused no matter how many leading slashes', async () => {
|
|
31
|
+
await app.request.get('/api/client/features').expect(401);
|
|
32
|
+
await app.request.get('/////api/client/features').expect(404);
|
|
33
|
+
await app.request.get('//api/client/features').expect(404);
|
|
34
|
+
});
|
|
35
|
+
test('Multiple slashes anywhere in the path is not a URL that exists', async () => {
|
|
36
|
+
await app.request.get('/api/admin///projects/default/features').expect(404);
|
|
37
|
+
await app.request.get('/api/client///features').expect(404);
|
|
38
|
+
});
|
|
39
|
+
test('multiple slashes after base path is also rejected with 404', async () => {
|
|
40
|
+
await appWithBaseUrl.request.get('/demo///api/client/features').expect(404);
|
|
41
|
+
await appWithBaseUrl.request.get('/demo/api/client/features').expect(401);
|
|
42
|
+
});
|
|
43
|
+
test(`Access with API token is granted`, async () => {
|
|
44
|
+
let token = await app.services.apiTokenService.createApiTokenWithProjects({
|
|
45
|
+
environment: 'default',
|
|
46
|
+
projects: ['default'],
|
|
47
|
+
tokenName: 'test',
|
|
48
|
+
type: api_token_1.ApiTokenType.CLIENT,
|
|
49
|
+
});
|
|
50
|
+
await app.request
|
|
51
|
+
.get('/api/client/features')
|
|
52
|
+
.set('Authorization', token.secret)
|
|
53
|
+
.expect(200);
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=leading-slashes-are-stripped.e2e.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leading-slashes-are-stripped.e2e.test.js","sourceRoot":"","sources":["../../../../../src/test/e2e/api/auth/leading-slashes-are-stripped.e2e.test.ts"],"names":[],"mappings":";;;;;AAAA,4EAAoD;AACpD,gFAA8D;AAC9D,2DAA2E;AAC3E,iDAAkE;AAClE,sEAAsE;AAEtE,IAAI,GAAiB,CAAC;AACtB,IAAI,cAA4B,CAAC;AACjC,IAAI,MAAsB,CAAC;AAC3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AAC;IAC5E,MAAM,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAChE,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,4DAA4D,EAAE,KAAK,IAAI,EAAE;IAC1E,MAAM,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5E,MAAM,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC9E,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;IAChD,IAAI,KAAK,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,eAAe,CAAC,0BAA0B,CAAC;QACtE,WAAW,EAAE,SAAS;QACtB,QAAQ,EAAE,CAAC,SAAS,CAAC;QACrB,SAAS,EAAE,MAAM;QACjB,IAAI,EAAE,wBAAY,CAAC,MAAM;KAC5B,CAAC,CAAC;IACH,MAAM,GAAG,CAAC,OAAO;SACZ,GAAG,CAAC,sBAAsB,CAAC;SAC3B,GAAG,CAAC,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC;SAClC,MAAM,CAAC,GAAG,CAAC,CAAC;AACrB,CAAC,CAAC,CAAC"}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
href="https://fonts.googleapis.com/css2?family=Sen:wght@400;700;800&display=swap"
|
|
17
17
|
rel="stylesheet"
|
|
18
18
|
/>
|
|
19
|
-
<script type="module" crossorigin src="/static/index-
|
|
19
|
+
<script type="module" crossorigin src="/static/index-1f392976.js"></script>
|
|
20
20
|
<link rel="stylesheet" href="/static/index-66c635eb.css">
|
|
21
21
|
</head>
|
|
22
22
|
<body>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a2 as k,an as R,H as w,ao as O,ap as U,aq as D,ar as J,j as e,as as b,at as x,au as B,av as F,aw as L,a4 as K,ax as $}from"./index-
|
|
1
|
+
import{a2 as k,an as R,H as w,ao as O,ap as U,aq as D,ar as J,j as e,as as b,at as x,au as B,av as F,aw as L,a4 as K,ax as $}from"./index-1f392976.js";const q="CREATE_PROJECT_BTN",Y=()=>{const{setToastData:n,setToastApiError:i}=k(),{refetchUser:d}=R(),{uiConfig:l}=w(),t=O(),{trackEvent:u}=U(),{projectId:a,projectName:p,projectMode:j,projectDesc:m,setProjectId:P,setProjectName:C,setProjectDesc:T,getProjectPayload:o,clearErrors:r,validateProjectId:s,validateName:h,setProjectStickiness:E,setProjectMode:f,projectStickiness:c,errors:g}=D(),{createProject:A,loading:_}=J();return e(b,{loading:_,title:"Create project",description:"Projects allows you to group feature toggles together in the management UI.",documentationLink:"https://docs.getunleash.io/reference/projects",documentationLinkLabel:"Projects documentation",formatApiCode:()=>`curl --location --request POST '${l.unleashUrl}/api/admin/projects' \\
|
|
2
2
|
--header 'Authorization: INSERT_API_KEY' \\
|
|
3
3
|
--header 'Content-Type: application/json' \\
|
|
4
4
|
--data-raw '${JSON.stringify(o(),void 0,2)}'`,children:e(x,{errors:g,handleSubmit:async N=>{N.preventDefault(),r();const v=h(),S=await s();if(v&&S){const y=o();try{await A(y),d(),t(`/projects/${a}`),n({title:"Project created",text:"Now you can add toggles to this project",confetti:!0,type:"success"}),c!==L&&u("project_stickiness_set")}catch(I){i(K(I))}}},handleCancel:()=>{t($)},projectId:a,setProjectId:P,projectName:p,projectMode:j,projectStickiness:c,setProjectStickiness:E,setProjectMode:f,setProjectName:C,projectDesc:m,setProjectDesc:T,mode:"Create",clearErrors:r,validateProjectId:s,children:e(B,{name:"project",permission:F,"data-testid":q})})})};export{Y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as r,j as o}from"./index-
|
|
1
|
+
import{c as r,j as o}from"./index-1f392976.js";const a=r(o("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"}),"Error");export{a as E};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{c as se,j as n,u as ne,aF as U,aX as M,f as b,b8 as q,C as _,A as pe,T as w,c5 as fe,e_ as ee,r as v,eT as ye,e$ as me,aZ as Te,aW as re,a2 as $,H as oe,ao as ie,aG as K,a$ as ce,ap as le,fe as be,ff as Ee,as as ve,aY as Ce,fg as Se,fh as Ae,fi as Re,fj as we,b0 as ue,b9 as xe,a4 as x,fk as ke,s as I,bm as H,F as Y,aK as te,a as Pe,dY as _e,bN as N,fl as Oe,dT as Fe,fm as De,fn as qe,fo as $e,bb as Be,bc as Le,bd as Ue,ad as de,ac as ge,bQ as Ie,c7 as Ye,d5 as Ve,w as ze,fp as We,d4 as je,Z as Ge,bL as Je,aR as Ke,aP as He,aQ as Me,ar as Ne}from"./index-1f392976.js";const Qe=se(n("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96z"}),"Cloud"),yt=se(n("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"),mt=({enabled:t,className:s})=>{const e=ne(),o=t?"Environment enabled":"Environment disabled",a={backgroundColor:t?e.palette.primary.light:e.palette.neutral.border,borderRadius:"50%",width:"28px",height:"28px",minWidth:"28px",display:"flex",alignItems:"center",justifyContent:"center",marginRight:e.spacing(1)},r={fill:e.palette.common.white,width:"16px",height:"16px"};return n("div",{style:a,className:s,children:n(Qe,{style:r,titleAccess:o})})},Ze=({isOpen:t,onConfirm:s,onClose:e,showBanner:o,environment:a,messageComponent:r})=>{const i=U("projectId"),{data:p}=M(i),{changeRequestInReviewOrApproved:l,alert:d}=fe(p),g=l(a||"");return b(q,{open:t,primaryButtonText:g?"Add to existing change request":"Add suggestion to draft",secondaryButtonText:"Cancel",onClick:s,onClose:e,title:"Request changes",fullWidth:!0,children:[n(_,{condition:g,show:d}),n(_,{condition:!!o,show:b(pe,{severity:"info",sx:{mb:2},children:["Change requests feature is enabled for ",a,". 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."]})}),n(w,{variant:"body2",color:"text.secondary",children:"Your suggestion:"}),r]})},Tt="UPDATE_FEATURE_STRATEGY",bt="DELETE_FEATURE_STRATEGY",Et="UPDATE_PROJECT",vt="READ_PROJECT_API_TOKEN",Ct="CREATE_PROJECT_API_TOKEN",St="DELETE_PROJECT_API_TOKEN",Xe=(t,s)=>{const e={};return s.parameters.forEach(o=>{e[o.name]=et(t,o)}),{name:s.name,constraints:[],parameters:e}},et=(t,s)=>s.name==="rollout"||s.name==="percentage"||s.type==="percentage"?"50":s.name==="stickiness"?"":s.name==="groupId"?t:s.type==="boolean"?"false":"",At=()=>{const t=U("projectId"),s=U("featureId"),e=ee("environmentId"),o=ee("strategyName"),[a,r]=v.useState({}),[i,p]=v.useState([]),{strategyDefinition:l}=ye(o),d=me(),{addStrategyToFeature:g,loading:T}=Te(),{addChange:c}=re(),{setToastData:u,setToastApiError:f}=$(),{uiConfig:h}=oe(),{unleashUrl:E}=h,C=ie(),{feature:S,refetchFeature:A}=K(t,s),y=v.useRef(S),{isChangeRequestConfigured:B}=ce(t),{refetch:V}=M(t),{trackEvent:O}=le(),{data:k,staleDataNotification:F,forceRefreshCache:z}=be({unleashGetter:K,params:[t,s],dataKey:"feature",refetchFunctionKey:"refetchFeature",options:{}},S,{afterSubmitAction:A},ke);v.useEffect(()=>{y.current.name===""&&S.name&&(z(S),y.current=S)},[S.name]),v.useEffect(()=>{l&&r(Xe(s,l))},[s,l]);const W=async R=>{await g(t,s,e,R),u({title:"Strategy created",type:"success",confetti:!0})},j=async R=>{await c(t,e,{action:"addStrategy",feature:s,payload:R}),u({title:"Strategy added to draft",type:"success",confetti:!0}),V()},D=Ee(a,i),L=async()=>{O("strategyTitle",{props:{hasTitle:!!a.title,on:"create"}});try{B(e)?await j(D):await W(D),A(),C(xe(t,s))}catch(R){f(x(R))}};return!k||!k.project?null:b(ve,{modal:!0,title:Ce(o),description:Se,documentationLink:Ae,documentationLinkLabel:Re,formatApiCode:()=>at(t,s,e,D,E),children:[n(we,{projectId:t,feature:k,strategy:a,setStrategy:r,segments:i,setSegments:p,environmentId:e,onSubmit:L,loading:T,permission:ue,errors:d,isChangeRequest:B(e)}),F]})},tt=(t,s,e,o)=>{const a=new URLSearchParams({environmentId:e,strategyName:o});return`/projects/${t}/features/${s}/strategies/create?${a}`},at=(t,s,e,o,a)=>{if(!a)return"";const r=`${a}/api/admin/projects/${t}/features/${s}/environments/${e}/strategies`,i=JSON.stringify(o,void 0,2);return`curl --location --request POST '${r}' \\
|
|
2
|
+
--header 'Authorization: INSERT_API_KEY' \\
|
|
3
|
+
--header 'Content-Type: application/json' \\
|
|
4
|
+
--data-raw '${i}'`},ae=I("p")(({theme:t})=>({marginBottom:t.spacing(.5),fontSize:t.fontSizes.bodySize})),Rt=({open:t,environmentName:s,featureId:e,projectId:o,onClose:a})=>{const r=ie(),i=tt(o,e,s,"default");return b(q,{open:t,maxWidth:"sm",onClose:()=>a(),title:"You need to add a strategy to your toggle",primaryButtonText:"Take me directly to add strategy",permissionButton:n(H,{type:"button",permission:ue,projectId:o,environmentId:s,onClick:()=>{a(),r(i)},children:"Take me directly to add strategy"}),secondaryButtonText:"Cancel",children:[n(ae,{children:"Before you can enable the toggle in the environment, you need to add an activation strategy."}),n(ae,{children:"You can add the activation strategy by selecting the toggle, open the environment accordion and add the activation strategy."})]})},st="You can not enable the environment before it has strategies",nt=t=>{const{setToastData:s,setToastApiError:e}=$(),{addChange:o}=re(),{refetch:a}=M(t),[r,i]=v.useState({isOpen:!1}),p=v.useCallback((g,T,c,u)=>{i({featureName:g,environment:T,enabled:c,shouldActivateDisabledStrategies:u,isOpen:!0})},[]),l=v.useCallback(()=>{i(g=>({...g,isOpen:!1}))},[]),d=v.useCallback(async()=>{try{await o(t,r.environment,{feature:r.featureName,action:"updateEnabled",payload:{enabled:!!r.enabled,shouldActivateDisabledStrategies:!!r.shouldActivateDisabledStrategies}}),a(),i(g=>({...g,isOpen:!1})),s({type:"success",title:"Changes added to the draft!"})}catch(g){e(x(g)),i(T=>({...T,isOpen:!1}))}},[o]);return{onChangeRequestToggle:p,onChangeRequestToggleClose:l,onChangeRequestToggleConfirm:d,changeRequestDialogDetails:r}},rt=({isOpen:t,onAddDefaultStrategy:s,onActivateDisabledStrategies:e,onClose:o,environment:a,disabledStrategiesCount:r=0})=>{const i=U("projectId");return b(q,{open:t,secondaryButtonText:"Cancel",permissionButton:b(Y,{children:[n(H,{type:"button",permission:te,projectId:i,environmentId:a,onClick:s,children:"Add default strategy"}),n(H,{type:"button",variant:"text",permission:te,projectId:i,environmentId:a,onClick:e,children:"Enable all strategies"})]}),onClose:o,title:"Enable feature toggle",fullWidth:!0,children:[b(w,{variant:"body1",color:"text.primary",sx:{mb:p=>p.spacing(2)},children:["The feature toggle has ",r," disabled",r===1?" strategy":" strategies","."]}),n(w,{variant:"body1",color:"text.primary",children:"You can choose to enable all the disabled strategies or you can add the default strategy to enable this feature toggle."})]})},ot=({enabled:t,featureName:s,environment:e})=>b(w,{"data-testid":"update-enabled-message",children:[n("strong",{children:t?"Enable":"Disable"})," feature toggle"," ",n("strong",{children:s})," in ",n("strong",{children:e})]}),it=I(Pe)(()=>({mx:"auto",..._e})),wt=({projectId:t,featureId:s,environmentName:e,value:o,onToggle:a,onError:r})=>{var R;const{toggleFeatureEnvironmentOn:i,toggleFeatureEnvironmentOff:p}=N(),{setToastData:l,setToastApiError:d}=$(),{isChangeRequestConfigured:g}=ce(t),{onChangeRequestToggle:T,onChangeRequestToggleClose:c,onChangeRequestToggleConfirm:u,changeRequestDialogDetails:f}=nt(t),[h,E,C]=Oe(o),[S,A]=v.useState(!1),{feature:y}=K(t,s),B=((R=y==null?void 0:y.environments.find(m=>m.name===e))==null?void 0:R.strategies.filter(m=>m.disabled).length)??0,{uiConfig:V}=oe(),O=!!V.flags.strategyImprovements,{trackEvent:k}=le(),F=async(m=!1)=>{try{E(!h),await i(t,y.name,e,m),l({type:"success",title:`Available in ${e}`,text:`${y.name} is now available in ${e} based on its defined strategies.`}),a==null||a(t,y.name,e,!h)}catch(P){P instanceof Error&&P.message===st?r==null||r():d(x(P)),C()}},z=async()=>{try{E(!h),await p(t,y.name,e),l({type:"success",title:`Unavailable in ${e}`,text:`${y.name} is unavailable in ${e} and its strategies will no longer have any effect.`}),a==null||a(t,y.name,e,!h)}catch(m){d(x(m)),C()}},W=async m=>{if(g(e)){m.preventDefault(),L()&&O?A(!0):T(y.name,e,!h,!1);return}if(h){await z();return}L()&&O?A(!0):await F()},j=async()=>{await k("strategyImprovements",{props:{eventType:"activate disabled strategies"}}),g(e)?T(y.name,e,!h,!0):await F(!0),A(!1)},D=async()=>{await k("strategyImprovements",{props:{eventType:"add default strategy"}}),g(e)?T(y.name,e,!h,!1):await F(),A(!1)},L=()=>{var P,Z,X;const m=(P=y==null?void 0:y.environments)==null?void 0:P.find(J=>J.name===e);return(m==null?void 0:m.strategies)&&((Z=m==null?void 0:m.strategies)==null?void 0:Z.length)>0&&((X=m==null?void 0:m.strategies)==null?void 0:X.every(J=>J.disabled))},G=`${y.name}-${e}`;return b(Y,{children:[n(it,{"data-testid":`TOGGLE-${G}`,children:n(Fe,{tooltip:h?`Disable feature in ${e}`:`Enable feature in ${e}`,checked:h,environmentId:e,projectId:t,permission:De,inputProps:{"aria-label":e},onClick:W})},G),O&&n(rt,{isOpen:S,onClose:()=>A(!1),environment:e,disabledStrategiesCount:B,onActivateDisabledStrategies:j,onAddDefaultStrategy:D}),n(Ze,{isOpen:f.isOpen,onClose:c,environment:f==null?void 0:f.environment,onConfirm:u,messageComponent:n(ot,{enabled:f==null?void 0:f.enabled,featureName:f==null?void 0:f.featureName,environment:f.environment})})]})},ct=I(qe)(({theme:t})=>({color:t.palette.warning.main,fontSize:t.fontSizes.bodySize})),xt=()=>n($e,{arrow:!0,title:b(Y,{children:["This environment has no variants enabled. If you check this feature's variants in this environment, you will get the"," ",n("a",{href:"https://docs.getunleash.io/reference/feature-toggle-variants#the-disabled-variant",target:"_blank",rel:"noreferrer",children:"disabled variant"}),"."]}),children:n(ct,{})});var Q={},lt=Le;Object.defineProperty(Q,"__esModule",{value:!0});var he=Q.default=void 0,ut=lt(Be()),dt=Ue,gt=(0,ut.default)((0,dt.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");he=Q.default=gt;const ht=We(),kt=({options:t,selectedOptions:s,indeterminateOptions:e,tagType:o,existingTags:a,disabled:r=!1,onChange:i})=>{const p=n(je,{fontSize:"small"});return n(de,{multiple:!0,id:"checkboxes-tag",sx:{marginTop:c=>c.spacing(2),width:500},disableCloseOnSelect:!0,placeholder:"Select Values",options:t,value:s,renderTags:(c,u)=>c.map((f,h)=>a.some(C=>C.value===f.title&&C.type===o.name)&&e===void 0?null:n(ze,{...u({index:h}),label:f.title})),isOptionEqualToValue:(c,u)=>u.inputValue&&u.inputValue!==""?c.title===u.inputValue:c.title===u.title,getOptionLabel:c=>c.inputValue?c.inputValue:c.title,renderOption:(c,u,{selected:f})=>{const h=(e==null?void 0:e.some(E=>E.title===u.title))??!1;return b("li",{...c,children:[n(_,{condition:!!u.inputValue,show:n(Ie,{sx:{mr:E=>E.spacing(.5)}}),elseShow:n(Ye,{icon:p,checkedIcon:n(Ve,{fontSize:"small"}),indeterminateIcon:n(he,{fontSize:"small"}),sx:{mr:E=>E.spacing(.5)},checked:f&&!h,indeterminate:h})}),u.title]})},filterOptions:(c,u)=>{const f=ht(c,u),{inputValue:h}=u,E=c.some(C=>h===C.title);return h!==""&&!E&&f.push({inputValue:h,title:`Create new value "${h}"`}),f},ListboxProps:{style:{maxHeight:200,overflow:"auto"}},onChange:i,renderInput:c=>n(ge,{...c,label:"Select values",placeholder:"Select values"}),disabled:r})},pt=I("li")({flexDirection:"column"}),Pt=({options:t,value:s,disabled:e=!1,onChange:o})=>{const a=ne();return n(de,{disablePortal:!0,disabled:e,id:"tag-type-select",sx:{marginTop:r=>r.spacing(2),width:500},options:t,disableClearable:!0,value:s,getOptionLabel:r=>r.name,renderOption:(r,i)=>b(pt,{...r,style:{alignItems:"flex-start",gap:a.spacing(.5)},children:[n(w,{variant:"body1",children:i.name}),n(w,{variant:"caption",children:i.description})]}),renderInput:r=>n(ge,{...r,label:"Tag type",value:s}),onChange:o,ListboxProps:{style:{maxHeight:200,overflow:"auto"}}})},_t=()=>{const{makeRequest:t,createRequest:s,errors:e,loading:o}=Ge({propagateErrors:!0});return{createTag:async i=>{const l=s("api/admin/tags",{method:"POST",body:JSON.stringify(i)});try{return await t(l.caller,l.id)}catch(d){throw d}},bulkUpdateTags:async i=>{const l=s("api/admin/tags/features",{method:"PUT",body:JSON.stringify(i)});try{return await t(l.caller,l.id)}catch(d){throw d}},errors:e,loading:o}},Ot=(t,s={})=>{const e=async()=>{const d=He(`api/admin/tags/${t}`);return(await fetch(d,{method:"GET"}).then(Me("Tags"))).json()},o=`api/admin/tags/${t}`,{data:a,error:r}=Je(!!t,{tags:[]},o,e,s),[i,p]=v.useState(!r&&!a),l=()=>{Ke(o)};return v.useEffect(()=>{p(!r&&!a)},[a,r]),{tags:(a==null?void 0:a.tags)||[],error:r,loading:i,refetch:l}},Ft=({isStale:t,isOpen:s,projectId:e,featureId:o,onClose:a})=>{const{setToastData:r,setToastApiError:i}=$(),{patchFeatureToggle:p}=N(),l=n(w,{children:"Setting a toggle to stale marks it for cleanup"}),d=n(w,{children:"Setting a toggle to active marks it as in active use"}),g=t?"active":"stale",T=async c=>{c.stopPropagation();try{await p(e,o,[{op:"replace",path:"/stale",value:!t}]),a()}catch(u){i(x(u))}r(t?{type:"success",title:"And we're back!",text:"The toggle is no longer marked as stale."}:{type:"success",title:"A job well done.",text:"The toggle has been marked as stale."})};return n(q,{open:s,secondaryButtonText:"Cancel",primaryButtonText:`Flip to ${g}`,title:`Set feature state to ${g}`,onClick:T,onClose:a,children:n(_,{condition:t,show:d,elseShow:l})})},Dt=({isOpen:t,onClose:s,onConfirm:e,projectId:o,featureIds:a})=>{const{archiveFeatureToggle:r}=N(),{archiveFeatures:i}=Ne(),{setToastData:p,setToastApiError:l}=$(),d=(a==null?void 0:a.length)>1;return n(q,{onClick:d?async()=>{try{await i(o,a),p({text:"Selected feature toggles have been archived",type:"success",title:"Feature toggles archived"}),e(),s()}catch(c){l(x(c)),s()}}:async()=>{try{await r(o,a[0]),p({text:"Your feature toggle has been archived",type:"success",title:"Feature archived"}),e(),s()}catch(c){l(x(c)),s()}},open:t,onClose:s,primaryButtonText:d?"Archive toggles":"Archive toggle",secondaryButtonText:"Cancel",title:d?"Archive feature toggles":"Archive feature toggle",children:n(_,{condition:d,show:b(Y,{children:[b("p",{children:["Are you sure you want to archive"," ",n("strong",{children:a==null?void 0:a.length})," feature toggles?"]}),n(_,{condition:(a==null?void 0:a.length)<=5,show:n("ul",{children:a==null?void 0:a.map(c=>n("li",{children:c},c))})})]}),elseShow:n("p",{children:"Are you sure you want to archive these feature toggles?"})})})};export{Ze as C,bt as D,mt as E,wt as F,vt as R,Pt as T,Tt as U,xt as V,yt as W,Rt as a,Ot as b,kt as c,At as d,Dt as e,tt as f,Ft as g,nt as h,ot as i,Et as j,St as k,Ct as l,_t as u};
|
package/frontend/build/static/{FeatureMetricsChart-d5c6311d.js → FeatureMetricsChart-1c6bb078.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{fu as c,u as m,bF as g,r as d,j as u}from"./index-
|
|
1
|
+
import{fu as c,u as m,bF as g,r as d,j as u}from"./index-1f392976.js";import{d as b,L as x,C as f,a as C,b as v,P as S,c as h,T as q,p as k,e as M,f as L}from"./chartjs-adapter-date-fns.esm-c75aa905.js";import"./index-b3def5eb.js";import"./index-f8439975.js";const $=(e,s,n)=>{const a={label:"Total requests",borderColor:e.palette.primary.main,backgroundColor:e.palette.primary.main,data:p(s,n,o=>o.yes+o.no),elements:{point:{radius:6,pointStyle:"circle"},line:{borderDash:[8,4]}}},t={label:"Exposed",borderColor:e.palette.success.main,backgroundColor:e.palette.success.main,data:p(s,n,o=>o.yes),elements:{point:{radius:6,pointStyle:"triangle"}}},r={label:"Not exposed",borderColor:e.palette.error.main,backgroundColor:e.palette.error.main,data:p(s,n,o=>o.no),elements:{point:{radius:6,pointStyle:"triangle",pointRotation:180}}};return{datasets:[t,r,a]}},p=(e,s,n)=>e.map(a=>({x:a.timestamp,y:n(a),variants:a.variants})),E=(e,s)=>{if(s===0)return"";const[n,a]=e,t=Math.floor(Number(a)/s*100);return`${a} (${t}%) - ${n}`},P=(e,s,n,a)=>({locale:a.locale,responsive:!0,maintainAspectRatio:!1,interaction:{mode:"index",intersect:!1},color:e.palette.text.secondary,plugins:{tooltip:{backgroundColor:e.palette.background.paper,bodyColor:e.palette.text.primary,titleColor:e.palette.text.secondary,borderColor:e.palette.primary.main,borderWidth:1,padding:10,boxPadding:5,usePointStyle:!0,itemSort:(t,r)=>{const o=["Total requests","Exposed","Not exposed"],l=o.indexOf(t.dataset.label),i=o.indexOf(r.dataset.label);return l-i},callbacks:{label:t=>`${t.formattedValue} - ${t.dataset.label}`,afterLabel:t=>{const r=t.dataset.data[t.dataIndex];if(t.dataset.label!=="Exposed"||r.variants===void 0)return"";const{disabled:o,...l}=r.variants;return Object.entries(l).map(i=>E(i,r.y)).join(`
|
|
2
2
|
`)},title:t=>`Time: ${c(t[0].parsed.x,a.locale)}`}},legend:{position:"top",align:"end",labels:{boxWidth:10,boxHeight:10,usePointStyle:!0}},title:{text:T(n),position:"top",align:"start",display:!0,font:{size:16,weight:"400"},color:e.palette.text.primary}},scales:{y:{type:"linear",title:{display:!0,text:"Number of requests",color:e.palette.text.secondary},suggestedMin:0,ticks:{precision:0,color:e.palette.text.secondary},grid:{color:e.palette.divider,borderColor:e.palette.divider}},x:{type:"time",time:{unit:"hour"},grid:{display:!1},ticks:{callback:(t,r,o)=>c(o[r].value,a.locale),color:e.palette.text.secondary}}}}),T=e=>e===1?"Requests in the last hour":`Requests in the last ${e} hours`;b.font={...b.font,family:"Sen",size:13,weight:"400"};const _=({metrics:e,hoursBack:s,statsSectionId:n})=>{const a=m(),{locationSettings:t}=g(),r=d.useMemo(()=>[...e].sort((i,y)=>i.timestamp.localeCompare(y.timestamp)),[e]),o=d.useMemo(()=>P(a,r,s,t),[a,r,s,t]),l=d.useMemo(()=>$(a,r,t),[a,r,t]);return u("div",{style:{height:400},children:u(x,{options:o,data:l,"aria-label":"A feature metrics line chart, with three lines: all requests, positive requests, and negative requests.","aria-describedby":n})})};f.register(C,v,S,h,q,k,M,L);export{_ as FeatureMetricsChart,_ as default};
|