@commercetools-frontend/staff-bar 0.0.6 → 0.0.7
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/commercetools-frontend-staff-bar.cjs.dev.js +2 -3
- package/dist/commercetools-frontend-staff-bar.cjs.prod.js +2 -3
- package/dist/commercetools-frontend-staff-bar.esm.js +2 -3
- package/dist/environments.config.json +67 -0
- package/dist/{staff-bar-f2b25039.esm.js → staff-bar-22ec7327.esm.js} +39 -58
- package/dist/{staff-bar-484a6be2.cjs.dev.js → staff-bar-35cc1d60.cjs.dev.js} +39 -60
- package/dist/{staff-bar-72bd9500.cjs.prod.js → staff-bar-890962e7.cjs.prod.js} +39 -60
- package/package.json +8 -8
|
@@ -72,10 +72,9 @@ let ErrorBoundary = /*#__PURE__*/function (_Component) {
|
|
|
72
72
|
|
|
73
73
|
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
74
74
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
75
|
-
const StaffBarComponent = /*#__PURE__*/react.lazy(() => Promise.resolve().then(function () { return require('./staff-bar-
|
|
75
|
+
const StaffBarComponent = /*#__PURE__*/react.lazy(() => Promise.resolve().then(function () { return require('./staff-bar-35cc1d60.cjs.dev.js'); }));
|
|
76
76
|
function StaffBar(props) {
|
|
77
|
-
|
|
78
|
-
if (process.env.NODE_ENV === 'test' || window.Cypress && !((_window$sessionStorag = window.sessionStorage) !== null && _window$sessionStorag !== void 0 && _window$sessionStorag.enableStaffBarForCypress)) {
|
|
77
|
+
if (process.env.NODE_ENV === 'test' || window.Cypress && !window.sessionStorage?.enableStaffBarForCypress) {
|
|
79
78
|
return null;
|
|
80
79
|
}
|
|
81
80
|
return jsxRuntime.jsx(ErrorBoundary, {
|
|
@@ -72,10 +72,9 @@ let ErrorBoundary = /*#__PURE__*/function (_Component) {
|
|
|
72
72
|
|
|
73
73
|
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
74
74
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
75
|
-
const StaffBarComponent = /*#__PURE__*/react.lazy(() => Promise.resolve().then(function () { return require('./staff-bar-
|
|
75
|
+
const StaffBarComponent = /*#__PURE__*/react.lazy(() => Promise.resolve().then(function () { return require('./staff-bar-890962e7.cjs.prod.js'); }));
|
|
76
76
|
function StaffBar(props) {
|
|
77
|
-
|
|
78
|
-
if (window.Cypress && !((_window$sessionStorag = window.sessionStorage) !== null && _window$sessionStorag !== void 0 && _window$sessionStorag.enableStaffBarForCypress)) {
|
|
77
|
+
if (window.Cypress && !window.sessionStorage?.enableStaffBarForCypress) {
|
|
79
78
|
return null;
|
|
80
79
|
}
|
|
81
80
|
return jsxRuntime.jsx(ErrorBoundary, {
|
|
@@ -56,10 +56,9 @@ let ErrorBoundary = /*#__PURE__*/function (_Component) {
|
|
|
56
56
|
|
|
57
57
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
58
58
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
59
|
-
const StaffBarComponent = /*#__PURE__*/lazy(() => import('./staff-bar-
|
|
59
|
+
const StaffBarComponent = /*#__PURE__*/lazy(() => import('./staff-bar-22ec7327.esm.js'));
|
|
60
60
|
function StaffBar(props) {
|
|
61
|
-
|
|
62
|
-
if (process.env.NODE_ENV === 'test' || window.Cypress && !((_window$sessionStorag = window.sessionStorage) !== null && _window$sessionStorag !== void 0 && _window$sessionStorag.enableStaffBarForCypress)) {
|
|
61
|
+
if (process.env.NODE_ENV === 'test' || window.Cypress && !window.sessionStorage?.enableStaffBarForCypress) {
|
|
63
62
|
return null;
|
|
64
63
|
}
|
|
65
64
|
return jsx(ErrorBoundary, {
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"AmazonWebServicesATT": {
|
|
3
|
+
"MerchantCenterFrontend": {
|
|
4
|
+
"url": "https://mc.att.us-east-1.aws.commercetools.com"
|
|
5
|
+
}
|
|
6
|
+
},
|
|
7
|
+
"AmazonWebServicesChina": {
|
|
8
|
+
"MerchantCenterFrontend": {
|
|
9
|
+
"url": "https://mc.cn-northwest-1.aws.commercetools.cn"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"AmazonWebServicesChinaStaging": {
|
|
13
|
+
"MerchantCenterFrontend": {
|
|
14
|
+
"url": "https://mc.cn-northwest-1.aws.commercetoolscn.cn"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"AmazonWebServicesFrankfurt": {
|
|
18
|
+
"MerchantCenterFrontend": {
|
|
19
|
+
"url": "https://mc.eu-central-1.aws.commercetools.com"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"AmazonWebServicesOhio": {
|
|
23
|
+
"MerchantCenterFrontend": {
|
|
24
|
+
"url": "https://mc.us-east-2.aws.commercetools.com"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"AmazonWebServicesVolkswagen": {
|
|
28
|
+
"MerchantCenterFrontend": {
|
|
29
|
+
"url": "https://mc.vw.eu-central-1.aws.commercetools.com"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"AmazonWebServicesVolkswagenStaging": {
|
|
33
|
+
"MerchantCenterFrontend": {
|
|
34
|
+
"url": "https://mc.vw-stage.eu-central-1.aws.commercetools.com"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"AzureEuropeStaging": {
|
|
38
|
+
"MerchantCenterFrontend": {
|
|
39
|
+
"url": "https://mc.northeurope.azure.escemo.com"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"AzureUnitedStates": {
|
|
43
|
+
"MerchantCenterFrontend": {
|
|
44
|
+
"url": "https://mc.eastus.azure.commercetools.com"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"GoogleCloudPlatformAustralia": {
|
|
48
|
+
"MerchantCenterFrontend": {
|
|
49
|
+
"url": "https://mc.australia-southeast1.gcp.commercetools.com"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"GoogleCloudPlatformEurope": {
|
|
53
|
+
"MerchantCenterFrontend": {
|
|
54
|
+
"url": "https://mc.europe-west1.gcp.commercetools.com"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"GoogleCloudPlatformEuropeStaging": {
|
|
58
|
+
"MerchantCenterFrontend": {
|
|
59
|
+
"url": "https://mc.europe-west1.gcp.escemo.com"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"GoogleCloudPlatformUnitedStates": {
|
|
63
|
+
"MerchantCenterFrontend": {
|
|
64
|
+
"url": "https://mc.us-central1.gcp.commercetools.com"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -23,10 +23,8 @@ import isEqual from 'lodash/isEqual';
|
|
|
23
23
|
import { useModalState, InfoDialog } from '@commercetools-frontend/application-components';
|
|
24
24
|
import { useMcQuery } from '@commercetools-frontend/application-shell';
|
|
25
25
|
import { GRAPHQL_TARGETS } from '@commercetools-frontend/constants';
|
|
26
|
-
import _someInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/some';
|
|
27
26
|
import { useApplicationContext } from '@commercetools-frontend/application-shell-connectors';
|
|
28
27
|
import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
|
|
29
|
-
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
30
28
|
import '@babel/runtime-corejs3/core-js-stable/reflect/construct';
|
|
31
29
|
import '@babel/runtime-corejs3/helpers/classCallCheck';
|
|
32
30
|
import '@babel/runtime-corejs3/helpers/createClass';
|
|
@@ -160,27 +158,24 @@ const EnvironmentSwitcher = () => {
|
|
|
160
158
|
value = _useState2[0],
|
|
161
159
|
setValue = _useState2[1];
|
|
162
160
|
useEffect(() => {
|
|
163
|
-
|
|
164
|
-
const currentURL = (_window = window) === null || _window === void 0 || (_window = _window.location) === null || _window === void 0 ? void 0 : _window.origin;
|
|
161
|
+
const currentURL = window?.location?.origin;
|
|
165
162
|
if (currentURL === LOCAL_ENV.value) {
|
|
166
|
-
|
|
167
|
-
(_ENV$ = ENV[0]) === null || _ENV$ === void 0 || _ENV$.options.unshift(LOCAL_ENV);
|
|
163
|
+
ENV[0]?.options.unshift(LOCAL_ENV);
|
|
168
164
|
}
|
|
169
165
|
if (_includesInstanceProperty(currentURL).call(currentURL, 'preview')) {
|
|
170
|
-
|
|
171
|
-
(_ENV$2 = ENV[0]) === null || _ENV$2 === void 0 || _ENV$2.options.unshift(PREVIEW_BRANCH);
|
|
166
|
+
ENV[0]?.options.unshift(PREVIEW_BRANCH);
|
|
172
167
|
}
|
|
173
168
|
if (_includesInstanceProperty(currentURL).call(currentURL, 'preview')) {
|
|
174
169
|
setValue('');
|
|
175
170
|
} else {
|
|
176
|
-
var
|
|
177
|
-
setValue(
|
|
171
|
+
var _context, _context2;
|
|
172
|
+
setValue(_findInstanceProperty(_context = _flatInstanceProperty(_context2 = _mapInstanceProperty(ENV).call(ENV, _ref2 => {
|
|
178
173
|
let options = _ref2.options;
|
|
179
174
|
return options;
|
|
180
175
|
})).call(_context2)).call(_context, _ref3 => {
|
|
181
176
|
let value = _ref3.value;
|
|
182
177
|
return value === currentURL;
|
|
183
|
-
})
|
|
178
|
+
})?.value);
|
|
184
179
|
}
|
|
185
180
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
186
181
|
}, []);
|
|
@@ -220,7 +215,6 @@ const USER_ROLES_WITH_ALLOWED_ACCESS = ['Engineer', 'ProductProjectManagerOrOwne
|
|
|
220
215
|
|
|
221
216
|
var FetchStaffBarUser = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchStaffBarUser" }, variableDefinitions: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", alias: { kind: "Name", value: "user" }, name: { kind: "Name", value: "me" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "launchdarklyTrackingGroup" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "launchdarklyTrackingSubgroup" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "businessRole" }, arguments: [], directives: [] }] } }] } }], loc: { start: 0, end: 132, source: { body: "query FetchStaffBarUser {\n user: me {\n id\n launchdarklyTrackingGroup\n launchdarklyTrackingSubgroup\n businessRole\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
222
217
|
const useStaffBarUser = () => {
|
|
223
|
-
var _data$user, _data$user2, _data$user3;
|
|
224
218
|
const _useMcQuery = useMcQuery(FetchStaffBarUser, {
|
|
225
219
|
context: {
|
|
226
220
|
target: GRAPHQL_TARGETS.MERCHANT_CENTER_BACKEND
|
|
@@ -231,9 +225,9 @@ const useStaffBarUser = () => {
|
|
|
231
225
|
data = _useMcQuery.data,
|
|
232
226
|
error = _useMcQuery.error;
|
|
233
227
|
return {
|
|
234
|
-
userId: data
|
|
235
|
-
isStaffMember:
|
|
236
|
-
isDevMember: _includesInstanceProperty(USER_ROLES_WITH_ALLOWED_ACCESS).call(USER_ROLES_WITH_ALLOWED_ACCESS, data
|
|
228
|
+
userId: data?.user?.id,
|
|
229
|
+
isStaffMember: data?.user?.launchdarklyTrackingGroup === 'commercetools',
|
|
230
|
+
isDevMember: _includesInstanceProperty(USER_ROLES_WITH_ALLOWED_ACCESS).call(USER_ROLES_WITH_ALLOWED_ACCESS, data?.user?.businessRole),
|
|
237
231
|
error
|
|
238
232
|
};
|
|
239
233
|
};
|
|
@@ -249,15 +243,11 @@ const defaultTeam = {
|
|
|
249
243
|
};
|
|
250
244
|
const onlyTeamsWithMembership = function (userId) {
|
|
251
245
|
let teams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
252
|
-
return teams.length ? _filterInstanceProperty(teams).call(teams, team =>
|
|
253
|
-
var _team$membersRef;
|
|
254
|
-
return (_team$membersRef = team.membersRef) === null || _team$membersRef === void 0 ? void 0 : _someInstanceProperty(_team$membersRef).call(_team$membersRef, memberRef => memberRef.id === userId);
|
|
255
|
-
}) : [];
|
|
246
|
+
return teams.length ? _filterInstanceProperty(teams).call(teams, team => team.membersRef?.some(memberRef => memberRef.id === userId)) : [];
|
|
256
247
|
};
|
|
257
248
|
const getAdminTeamId = function () {
|
|
258
|
-
var _teams$find;
|
|
259
249
|
let teams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
260
|
-
return
|
|
250
|
+
return _findInstanceProperty(teams).call(teams, team => team.name === 'Administrators')?.id;
|
|
261
251
|
};
|
|
262
252
|
const getStoredTeamId = function (storedId) {
|
|
263
253
|
let teams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
@@ -267,8 +257,8 @@ const transformTeamsToOptions = function () {
|
|
|
267
257
|
let teams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
268
258
|
const hasAdminTeam = Boolean(getAdminTeamId(teams));
|
|
269
259
|
const options = _mapInstanceProperty(teams).call(teams, team => ({
|
|
270
|
-
label: team
|
|
271
|
-
value: team
|
|
260
|
+
label: team?.name,
|
|
261
|
+
value: team?.id
|
|
272
262
|
}));
|
|
273
263
|
if (hasAdminTeam) {
|
|
274
264
|
return options;
|
|
@@ -279,17 +269,13 @@ const transformTeamsToOptions = function () {
|
|
|
279
269
|
}
|
|
280
270
|
};
|
|
281
271
|
const useTeams = () => {
|
|
282
|
-
|
|
283
|
-
const projectKey = useApplicationContext(applicationContext => {
|
|
284
|
-
var _applicationContext$p;
|
|
285
|
-
return (_applicationContext$p = applicationContext.project) === null || _applicationContext$p === void 0 ? void 0 : _applicationContext$p.key;
|
|
286
|
-
});
|
|
272
|
+
const projectKey = useApplicationContext(applicationContext => applicationContext.project?.key);
|
|
287
273
|
const _useStaffBarUser = useStaffBarUser(),
|
|
288
274
|
userId = _useStaffBarUser.userId;
|
|
289
275
|
const _useMcQuery = useMcQuery(FetchTeamsByProjectQuery, {
|
|
290
276
|
skip: !projectKey,
|
|
291
277
|
variables: {
|
|
292
|
-
where:
|
|
278
|
+
where: `key="${projectKey}"`
|
|
293
279
|
},
|
|
294
280
|
context: {
|
|
295
281
|
target: GRAPHQL_TARGETS.ADMINISTRATION_SERVICE
|
|
@@ -298,7 +284,7 @@ const useTeams = () => {
|
|
|
298
284
|
data = _useMcQuery.data,
|
|
299
285
|
error = _useMcQuery.error,
|
|
300
286
|
loading = _useMcQuery.loading;
|
|
301
|
-
const teams = data
|
|
287
|
+
const teams = data?.myProjects?.results?.[0]?.owner?.teams;
|
|
302
288
|
useEffect(() => {
|
|
303
289
|
if (loading) {
|
|
304
290
|
return;
|
|
@@ -315,7 +301,7 @@ const useTeams = () => {
|
|
|
315
301
|
const options = transformTeamsToOptions(onlyTeamsWithMembership(userId || '', teams));
|
|
316
302
|
const adminTeamId = getAdminTeamId(onlyTeamsWithMembership(userId || '', teams));
|
|
317
303
|
const storedId = getActiveTeamId();
|
|
318
|
-
const activeTeamId =
|
|
304
|
+
const activeTeamId = storedId ?? adminTeamId ?? defaultTeam.value;
|
|
319
305
|
return {
|
|
320
306
|
data,
|
|
321
307
|
options,
|
|
@@ -326,22 +312,21 @@ const useTeams = () => {
|
|
|
326
312
|
};
|
|
327
313
|
};
|
|
328
314
|
|
|
329
|
-
|
|
330
|
-
const launchdarklyAdapter = (_window$__flopflip__ = window.__flopflip__) === null || _window$__flopflip__ === void 0 ? void 0 : _window$__flopflip__.launchdarkly;
|
|
315
|
+
const launchdarklyAdapter = window.__flopflip__?.launchdarkly;
|
|
331
316
|
function getFlagValue(flag, defaultValue) {
|
|
332
317
|
// @ts-expect-error: getFlag exists not on all adapters and hence
|
|
333
318
|
// not the generic type. For ours it exists.
|
|
334
|
-
const result = launchdarklyAdapter
|
|
319
|
+
const result = launchdarklyAdapter?.getFlag(flag);
|
|
335
320
|
if (typeof result === 'boolean') {
|
|
336
321
|
return result;
|
|
337
|
-
} else if (typeof
|
|
322
|
+
} else if (typeof result?.value === 'boolean') {
|
|
338
323
|
return result;
|
|
339
324
|
}
|
|
340
325
|
return defaultValue;
|
|
341
326
|
}
|
|
342
327
|
function setFlag(flagName, flagValue) {
|
|
343
328
|
let lockFlags = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
344
|
-
launchdarklyAdapter
|
|
329
|
+
launchdarklyAdapter?.updateFlags({
|
|
345
330
|
[flagName]: flagValue
|
|
346
331
|
}, {
|
|
347
332
|
lockFlags
|
|
@@ -394,7 +379,7 @@ function toggleFeatureFlag(flag, value) {
|
|
|
394
379
|
setFlag(flag, value);
|
|
395
380
|
}
|
|
396
381
|
const FeatureFlagToggler = props => {
|
|
397
|
-
var _context
|
|
382
|
+
var _context;
|
|
398
383
|
const modalState = useModalState();
|
|
399
384
|
const _useState = useState(false),
|
|
400
385
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -403,29 +388,27 @@ const FeatureFlagToggler = props => {
|
|
|
403
388
|
const cachedFeatureFlag = getFromSessionStorage(FEATURE_FLAG_KEY);
|
|
404
389
|
const _useStaffBarUser = useStaffBarUser(),
|
|
405
390
|
isDevMember = _useStaffBarUser.isDevMember;
|
|
406
|
-
const _useState3 = useState(_mapInstanceProperty(_context = _Object$entries(
|
|
407
|
-
var _cachedFeatureFlag$fe;
|
|
391
|
+
const _useState3 = useState(_mapInstanceProperty(_context = _Object$entries(props.featureFlags ?? {})).call(_context, _ref => {
|
|
408
392
|
let _ref2 = _slicedToArray(_ref, 2),
|
|
409
393
|
featureName = _ref2[0],
|
|
410
394
|
toggleValue = _ref2[1];
|
|
411
395
|
return {
|
|
412
396
|
featureName,
|
|
413
|
-
toggleValue:
|
|
397
|
+
toggleValue: cachedFeatureFlag[featureName] ?? getFlagValue(featureName, toggleValue)
|
|
414
398
|
};
|
|
415
399
|
})),
|
|
416
400
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
417
401
|
options = _useState4[0],
|
|
418
402
|
setOptions = _useState4[1];
|
|
419
403
|
const originalValues = useMemo(() => {
|
|
420
|
-
var _context2
|
|
421
|
-
return _mapInstanceProperty(_context2 = _Object$entries(
|
|
422
|
-
var _getFlagValue;
|
|
404
|
+
var _context2;
|
|
405
|
+
return _mapInstanceProperty(_context2 = _Object$entries(props.featureFlags ?? {})).call(_context2, _ref3 => {
|
|
423
406
|
let _ref4 = _slicedToArray(_ref3, 2),
|
|
424
407
|
featureName = _ref4[0],
|
|
425
408
|
toggleValue = _ref4[1];
|
|
426
409
|
return {
|
|
427
410
|
featureName,
|
|
428
|
-
toggleValue:
|
|
411
|
+
toggleValue: getFlagValue(featureName, toggleValue) ?? 'false'
|
|
429
412
|
};
|
|
430
413
|
});
|
|
431
414
|
},
|
|
@@ -471,11 +454,11 @@ const FeatureFlagToggler = props => {
|
|
|
471
454
|
});
|
|
472
455
|
} else {
|
|
473
456
|
toggleFeatureFlag(featureName, {
|
|
474
|
-
value: !
|
|
457
|
+
value: !toggleValue?.value
|
|
475
458
|
});
|
|
476
459
|
newOptions[index] = _objectSpread$1(_objectSpread$1({}, newOptions[index]), {}, {
|
|
477
460
|
toggleValue: {
|
|
478
|
-
value: !
|
|
461
|
+
value: !toggleValue?.value
|
|
479
462
|
}
|
|
480
463
|
});
|
|
481
464
|
}
|
|
@@ -594,7 +577,7 @@ const FeatureFlagToggler = props => {
|
|
|
594
577
|
};
|
|
595
578
|
|
|
596
579
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
597
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
580
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
598
581
|
var GitHubIcon = function GitHubIcon(props) {
|
|
599
582
|
return jsx("svg", _objectSpread(_objectSpread({}, props), {}, {
|
|
600
583
|
children: jsx("path", {
|
|
@@ -616,8 +599,7 @@ function GitHubPullRequestLink() {
|
|
|
616
599
|
label: "GitHub Pull Request",
|
|
617
600
|
icon: jsx(GitHubIcon, {}),
|
|
618
601
|
onClick: () => {
|
|
619
|
-
|
|
620
|
-
window.open(_concatInstanceProperty(_context = "".concat(GITHUB_PR_URL)).call(_context, PRNumber));
|
|
602
|
+
window.open(`${GITHUB_PR_URL}${PRNumber}`);
|
|
621
603
|
}
|
|
622
604
|
});
|
|
623
605
|
}
|
|
@@ -646,7 +628,7 @@ const TeamSwitcher = () => {
|
|
|
646
628
|
options = _useTeams.options,
|
|
647
629
|
activeTeamId = _useTeams.activeTeamId,
|
|
648
630
|
isLimitedPermission = _useTeams.isLimitedPermission;
|
|
649
|
-
if (!
|
|
631
|
+
if (!options?.length) {
|
|
650
632
|
return null;
|
|
651
633
|
}
|
|
652
634
|
const bottomOption = {
|
|
@@ -812,7 +794,7 @@ const DeploymentTracker = () => {
|
|
|
812
794
|
return;
|
|
813
795
|
}
|
|
814
796
|
try {
|
|
815
|
-
const response = await fetch(
|
|
797
|
+
const response = await fetch(`${URL}/versions`, {
|
|
816
798
|
signal: abortController.signal
|
|
817
799
|
});
|
|
818
800
|
let versions;
|
|
@@ -820,7 +802,7 @@ const DeploymentTracker = () => {
|
|
|
820
802
|
versions = await response.json();
|
|
821
803
|
setVersions(sortBy(versions, version => version.app));
|
|
822
804
|
} else {
|
|
823
|
-
const errorMessage =
|
|
805
|
+
const errorMessage = `Fetching the versions returned a ${response.status} HTTP status code.`;
|
|
824
806
|
// eslint-disable-next-line no-console
|
|
825
807
|
console.error(errorMessage);
|
|
826
808
|
}
|
|
@@ -835,8 +817,7 @@ const DeploymentTracker = () => {
|
|
|
835
817
|
};
|
|
836
818
|
}, []);
|
|
837
819
|
const getLastUpdate = application => {
|
|
838
|
-
|
|
839
|
-
const deployedAt = (_versions$find = _findInstanceProperty(versions).call(versions, version => version.app === application)) === null || _versions$find === void 0 || (_versions$find = _versions$find.build) === null || _versions$find === void 0 ? void 0 : _versions$find.deployedAt;
|
|
820
|
+
const deployedAt = _findInstanceProperty(versions).call(versions, version => version.app === application)?.build?.deployedAt;
|
|
840
821
|
if (!deployedAt) {
|
|
841
822
|
return {
|
|
842
823
|
value: 0,
|
|
@@ -850,17 +831,17 @@ const DeploymentTracker = () => {
|
|
|
850
831
|
const minutes = getDurationBetween('minutes', deployedAt);
|
|
851
832
|
return {
|
|
852
833
|
value: Number(minutes.toFixed(0)),
|
|
853
|
-
text:
|
|
834
|
+
text: `${minutes.toFixed(0)} minutes ago`
|
|
854
835
|
};
|
|
855
836
|
}
|
|
856
837
|
return {
|
|
857
838
|
value: Number(hours.toFixed(0)),
|
|
858
|
-
text:
|
|
839
|
+
text: `${hours.toFixed(0)} hours ago`
|
|
859
840
|
};
|
|
860
841
|
}
|
|
861
842
|
return {
|
|
862
843
|
value: Number(days.toFixed(0)),
|
|
863
|
-
text:
|
|
844
|
+
text: `${days.toFixed(0)} days ago`
|
|
864
845
|
};
|
|
865
846
|
};
|
|
866
847
|
const getTone = _ref3 => {
|
|
@@ -872,7 +853,7 @@ const DeploymentTracker = () => {
|
|
|
872
853
|
}
|
|
873
854
|
return 'primary';
|
|
874
855
|
};
|
|
875
|
-
if (!
|
|
856
|
+
if (!versions?.length) return null;
|
|
876
857
|
return jsxs("div", {
|
|
877
858
|
css: _ref2$1,
|
|
878
859
|
children: [jsxs(Stamp, {
|
|
@@ -25,10 +25,8 @@ var isEqual = require('lodash/isEqual');
|
|
|
25
25
|
var applicationComponents = require('@commercetools-frontend/application-components');
|
|
26
26
|
var applicationShell = require('@commercetools-frontend/application-shell');
|
|
27
27
|
var constants = require('@commercetools-frontend/constants');
|
|
28
|
-
var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
29
28
|
var applicationShellConnectors = require('@commercetools-frontend/application-shell-connectors');
|
|
30
29
|
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
31
|
-
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
32
30
|
require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
|
|
33
31
|
require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
34
32
|
require('@babel/runtime-corejs3/helpers/createClass');
|
|
@@ -57,9 +55,7 @@ var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
|
57
55
|
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
58
56
|
var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
|
|
59
57
|
var isEqual__default = /*#__PURE__*/_interopDefault(isEqual);
|
|
60
|
-
var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
|
|
61
58
|
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
62
|
-
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
63
59
|
var _URLSearchParams__default = /*#__PURE__*/_interopDefault(_URLSearchParams);
|
|
64
60
|
var sortBy__default = /*#__PURE__*/_interopDefault(sortBy);
|
|
65
61
|
|
|
@@ -186,27 +182,24 @@ const EnvironmentSwitcher = () => {
|
|
|
186
182
|
value = _useState2[0],
|
|
187
183
|
setValue = _useState2[1];
|
|
188
184
|
react.useEffect(() => {
|
|
189
|
-
|
|
190
|
-
const currentURL = (_window = window) === null || _window === void 0 || (_window = _window.location) === null || _window === void 0 ? void 0 : _window.origin;
|
|
185
|
+
const currentURL = window?.location?.origin;
|
|
191
186
|
if (currentURL === LOCAL_ENV.value) {
|
|
192
|
-
|
|
193
|
-
(_ENV$ = ENV[0]) === null || _ENV$ === void 0 || _ENV$.options.unshift(LOCAL_ENV);
|
|
187
|
+
ENV[0]?.options.unshift(LOCAL_ENV);
|
|
194
188
|
}
|
|
195
189
|
if (_includesInstanceProperty__default["default"](currentURL).call(currentURL, 'preview')) {
|
|
196
|
-
|
|
197
|
-
(_ENV$2 = ENV[0]) === null || _ENV$2 === void 0 || _ENV$2.options.unshift(PREVIEW_BRANCH);
|
|
190
|
+
ENV[0]?.options.unshift(PREVIEW_BRANCH);
|
|
198
191
|
}
|
|
199
192
|
if (_includesInstanceProperty__default["default"](currentURL).call(currentURL, 'preview')) {
|
|
200
193
|
setValue('');
|
|
201
194
|
} else {
|
|
202
|
-
var
|
|
203
|
-
setValue(
|
|
195
|
+
var _context, _context2;
|
|
196
|
+
setValue(_findInstanceProperty__default["default"](_context = _flatInstanceProperty__default["default"](_context2 = _mapInstanceProperty__default["default"](ENV).call(ENV, _ref2 => {
|
|
204
197
|
let options = _ref2.options;
|
|
205
198
|
return options;
|
|
206
199
|
})).call(_context2)).call(_context, _ref3 => {
|
|
207
200
|
let value = _ref3.value;
|
|
208
201
|
return value === currentURL;
|
|
209
|
-
})
|
|
202
|
+
})?.value);
|
|
210
203
|
}
|
|
211
204
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
212
205
|
}, []);
|
|
@@ -246,7 +239,6 @@ const USER_ROLES_WITH_ALLOWED_ACCESS = ['Engineer', 'ProductProjectManagerOrOwne
|
|
|
246
239
|
|
|
247
240
|
var FetchStaffBarUser = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchStaffBarUser" }, variableDefinitions: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", alias: { kind: "Name", value: "user" }, name: { kind: "Name", value: "me" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "launchdarklyTrackingGroup" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "launchdarklyTrackingSubgroup" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "businessRole" }, arguments: [], directives: [] }] } }] } }], loc: { start: 0, end: 132, source: { body: "query FetchStaffBarUser {\n user: me {\n id\n launchdarklyTrackingGroup\n launchdarklyTrackingSubgroup\n businessRole\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
248
241
|
const useStaffBarUser = () => {
|
|
249
|
-
var _data$user, _data$user2, _data$user3;
|
|
250
242
|
const _useMcQuery = applicationShell.useMcQuery(FetchStaffBarUser, {
|
|
251
243
|
context: {
|
|
252
244
|
target: constants.GRAPHQL_TARGETS.MERCHANT_CENTER_BACKEND
|
|
@@ -257,9 +249,9 @@ const useStaffBarUser = () => {
|
|
|
257
249
|
data = _useMcQuery.data,
|
|
258
250
|
error = _useMcQuery.error;
|
|
259
251
|
return {
|
|
260
|
-
userId: data
|
|
261
|
-
isStaffMember:
|
|
262
|
-
isDevMember: _includesInstanceProperty__default["default"](USER_ROLES_WITH_ALLOWED_ACCESS).call(USER_ROLES_WITH_ALLOWED_ACCESS, data
|
|
252
|
+
userId: data?.user?.id,
|
|
253
|
+
isStaffMember: data?.user?.launchdarklyTrackingGroup === 'commercetools',
|
|
254
|
+
isDevMember: _includesInstanceProperty__default["default"](USER_ROLES_WITH_ALLOWED_ACCESS).call(USER_ROLES_WITH_ALLOWED_ACCESS, data?.user?.businessRole),
|
|
263
255
|
error
|
|
264
256
|
};
|
|
265
257
|
};
|
|
@@ -275,15 +267,11 @@ const defaultTeam = {
|
|
|
275
267
|
};
|
|
276
268
|
const onlyTeamsWithMembership = function (userId) {
|
|
277
269
|
let teams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
278
|
-
return teams.length ? _filterInstanceProperty__default["default"](teams).call(teams, team =>
|
|
279
|
-
var _team$membersRef;
|
|
280
|
-
return (_team$membersRef = team.membersRef) === null || _team$membersRef === void 0 ? void 0 : _someInstanceProperty__default["default"](_team$membersRef).call(_team$membersRef, memberRef => memberRef.id === userId);
|
|
281
|
-
}) : [];
|
|
270
|
+
return teams.length ? _filterInstanceProperty__default["default"](teams).call(teams, team => team.membersRef?.some(memberRef => memberRef.id === userId)) : [];
|
|
282
271
|
};
|
|
283
272
|
const getAdminTeamId = function () {
|
|
284
|
-
var _teams$find;
|
|
285
273
|
let teams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
286
|
-
return
|
|
274
|
+
return _findInstanceProperty__default["default"](teams).call(teams, team => team.name === 'Administrators')?.id;
|
|
287
275
|
};
|
|
288
276
|
const getStoredTeamId = function (storedId) {
|
|
289
277
|
let teams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
@@ -293,8 +281,8 @@ const transformTeamsToOptions = function () {
|
|
|
293
281
|
let teams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
294
282
|
const hasAdminTeam = Boolean(getAdminTeamId(teams));
|
|
295
283
|
const options = _mapInstanceProperty__default["default"](teams).call(teams, team => ({
|
|
296
|
-
label: team
|
|
297
|
-
value: team
|
|
284
|
+
label: team?.name,
|
|
285
|
+
value: team?.id
|
|
298
286
|
}));
|
|
299
287
|
if (hasAdminTeam) {
|
|
300
288
|
return options;
|
|
@@ -305,17 +293,13 @@ const transformTeamsToOptions = function () {
|
|
|
305
293
|
}
|
|
306
294
|
};
|
|
307
295
|
const useTeams = () => {
|
|
308
|
-
|
|
309
|
-
const projectKey = applicationShellConnectors.useApplicationContext(applicationContext => {
|
|
310
|
-
var _applicationContext$p;
|
|
311
|
-
return (_applicationContext$p = applicationContext.project) === null || _applicationContext$p === void 0 ? void 0 : _applicationContext$p.key;
|
|
312
|
-
});
|
|
296
|
+
const projectKey = applicationShellConnectors.useApplicationContext(applicationContext => applicationContext.project?.key);
|
|
313
297
|
const _useStaffBarUser = useStaffBarUser(),
|
|
314
298
|
userId = _useStaffBarUser.userId;
|
|
315
299
|
const _useMcQuery = applicationShell.useMcQuery(FetchTeamsByProjectQuery, {
|
|
316
300
|
skip: !projectKey,
|
|
317
301
|
variables: {
|
|
318
|
-
where:
|
|
302
|
+
where: `key="${projectKey}"`
|
|
319
303
|
},
|
|
320
304
|
context: {
|
|
321
305
|
target: constants.GRAPHQL_TARGETS.ADMINISTRATION_SERVICE
|
|
@@ -324,7 +308,7 @@ const useTeams = () => {
|
|
|
324
308
|
data = _useMcQuery.data,
|
|
325
309
|
error = _useMcQuery.error,
|
|
326
310
|
loading = _useMcQuery.loading;
|
|
327
|
-
const teams = data
|
|
311
|
+
const teams = data?.myProjects?.results?.[0]?.owner?.teams;
|
|
328
312
|
react.useEffect(() => {
|
|
329
313
|
if (loading) {
|
|
330
314
|
return;
|
|
@@ -341,7 +325,7 @@ const useTeams = () => {
|
|
|
341
325
|
const options = transformTeamsToOptions(onlyTeamsWithMembership(userId || '', teams));
|
|
342
326
|
const adminTeamId = getAdminTeamId(onlyTeamsWithMembership(userId || '', teams));
|
|
343
327
|
const storedId = getActiveTeamId();
|
|
344
|
-
const activeTeamId =
|
|
328
|
+
const activeTeamId = storedId ?? adminTeamId ?? defaultTeam.value;
|
|
345
329
|
return {
|
|
346
330
|
data,
|
|
347
331
|
options,
|
|
@@ -352,22 +336,21 @@ const useTeams = () => {
|
|
|
352
336
|
};
|
|
353
337
|
};
|
|
354
338
|
|
|
355
|
-
|
|
356
|
-
const launchdarklyAdapter = (_window$__flopflip__ = window.__flopflip__) === null || _window$__flopflip__ === void 0 ? void 0 : _window$__flopflip__.launchdarkly;
|
|
339
|
+
const launchdarklyAdapter = window.__flopflip__?.launchdarkly;
|
|
357
340
|
function getFlagValue(flag, defaultValue) {
|
|
358
341
|
// @ts-expect-error: getFlag exists not on all adapters and hence
|
|
359
342
|
// not the generic type. For ours it exists.
|
|
360
|
-
const result = launchdarklyAdapter
|
|
343
|
+
const result = launchdarklyAdapter?.getFlag(flag);
|
|
361
344
|
if (typeof result === 'boolean') {
|
|
362
345
|
return result;
|
|
363
|
-
} else if (typeof
|
|
346
|
+
} else if (typeof result?.value === 'boolean') {
|
|
364
347
|
return result;
|
|
365
348
|
}
|
|
366
349
|
return defaultValue;
|
|
367
350
|
}
|
|
368
351
|
function setFlag(flagName, flagValue) {
|
|
369
352
|
let lockFlags = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
370
|
-
launchdarklyAdapter
|
|
353
|
+
launchdarklyAdapter?.updateFlags({
|
|
371
354
|
[flagName]: flagValue
|
|
372
355
|
}, {
|
|
373
356
|
lockFlags
|
|
@@ -420,7 +403,7 @@ function toggleFeatureFlag(flag, value) {
|
|
|
420
403
|
setFlag(flag, value);
|
|
421
404
|
}
|
|
422
405
|
const FeatureFlagToggler = props => {
|
|
423
|
-
var _context
|
|
406
|
+
var _context;
|
|
424
407
|
const modalState = applicationComponents.useModalState();
|
|
425
408
|
const _useState = react.useState(false),
|
|
426
409
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -429,29 +412,27 @@ const FeatureFlagToggler = props => {
|
|
|
429
412
|
const cachedFeatureFlag = getFromSessionStorage(FEATURE_FLAG_KEY);
|
|
430
413
|
const _useStaffBarUser = useStaffBarUser(),
|
|
431
414
|
isDevMember = _useStaffBarUser.isDevMember;
|
|
432
|
-
const _useState3 = react.useState(_mapInstanceProperty__default["default"](_context = _Object$entries__default["default"](
|
|
433
|
-
var _cachedFeatureFlag$fe;
|
|
415
|
+
const _useState3 = react.useState(_mapInstanceProperty__default["default"](_context = _Object$entries__default["default"](props.featureFlags ?? {})).call(_context, _ref => {
|
|
434
416
|
let _ref2 = _slicedToArray(_ref, 2),
|
|
435
417
|
featureName = _ref2[0],
|
|
436
418
|
toggleValue = _ref2[1];
|
|
437
419
|
return {
|
|
438
420
|
featureName,
|
|
439
|
-
toggleValue:
|
|
421
|
+
toggleValue: cachedFeatureFlag[featureName] ?? getFlagValue(featureName, toggleValue)
|
|
440
422
|
};
|
|
441
423
|
})),
|
|
442
424
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
443
425
|
options = _useState4[0],
|
|
444
426
|
setOptions = _useState4[1];
|
|
445
427
|
const originalValues = react.useMemo(() => {
|
|
446
|
-
var _context2
|
|
447
|
-
return _mapInstanceProperty__default["default"](_context2 = _Object$entries__default["default"](
|
|
448
|
-
var _getFlagValue;
|
|
428
|
+
var _context2;
|
|
429
|
+
return _mapInstanceProperty__default["default"](_context2 = _Object$entries__default["default"](props.featureFlags ?? {})).call(_context2, _ref3 => {
|
|
449
430
|
let _ref4 = _slicedToArray(_ref3, 2),
|
|
450
431
|
featureName = _ref4[0],
|
|
451
432
|
toggleValue = _ref4[1];
|
|
452
433
|
return {
|
|
453
434
|
featureName,
|
|
454
|
-
toggleValue:
|
|
435
|
+
toggleValue: getFlagValue(featureName, toggleValue) ?? 'false'
|
|
455
436
|
};
|
|
456
437
|
});
|
|
457
438
|
},
|
|
@@ -497,11 +478,11 @@ const FeatureFlagToggler = props => {
|
|
|
497
478
|
});
|
|
498
479
|
} else {
|
|
499
480
|
toggleFeatureFlag(featureName, {
|
|
500
|
-
value: !
|
|
481
|
+
value: !toggleValue?.value
|
|
501
482
|
});
|
|
502
483
|
newOptions[index] = _objectSpread$1(_objectSpread$1({}, newOptions[index]), {}, {
|
|
503
484
|
toggleValue: {
|
|
504
|
-
value: !
|
|
485
|
+
value: !toggleValue?.value
|
|
505
486
|
}
|
|
506
487
|
});
|
|
507
488
|
}
|
|
@@ -620,7 +601,7 @@ const FeatureFlagToggler = props => {
|
|
|
620
601
|
};
|
|
621
602
|
|
|
622
603
|
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
623
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
604
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
624
605
|
var GitHubIcon = function GitHubIcon(props) {
|
|
625
606
|
return jsxRuntime.jsx("svg", _objectSpread(_objectSpread({}, props), {}, {
|
|
626
607
|
children: jsxRuntime.jsx("path", {
|
|
@@ -642,8 +623,7 @@ function GitHubPullRequestLink() {
|
|
|
642
623
|
label: "GitHub Pull Request",
|
|
643
624
|
icon: jsxRuntime.jsx(GitHubIcon, {}),
|
|
644
625
|
onClick: () => {
|
|
645
|
-
|
|
646
|
-
window.open(_concatInstanceProperty__default["default"](_context = "".concat(GITHUB_PR_URL)).call(_context, PRNumber));
|
|
626
|
+
window.open(`${GITHUB_PR_URL}${PRNumber}`);
|
|
647
627
|
}
|
|
648
628
|
});
|
|
649
629
|
}
|
|
@@ -672,7 +652,7 @@ const TeamSwitcher = () => {
|
|
|
672
652
|
options = _useTeams.options,
|
|
673
653
|
activeTeamId = _useTeams.activeTeamId,
|
|
674
654
|
isLimitedPermission = _useTeams.isLimitedPermission;
|
|
675
|
-
if (!
|
|
655
|
+
if (!options?.length) {
|
|
676
656
|
return null;
|
|
677
657
|
}
|
|
678
658
|
const bottomOption = {
|
|
@@ -838,7 +818,7 @@ const DeploymentTracker = () => {
|
|
|
838
818
|
return;
|
|
839
819
|
}
|
|
840
820
|
try {
|
|
841
|
-
const response = await fetch(
|
|
821
|
+
const response = await fetch(`${URL}/versions`, {
|
|
842
822
|
signal: abortController.signal
|
|
843
823
|
});
|
|
844
824
|
let versions;
|
|
@@ -846,7 +826,7 @@ const DeploymentTracker = () => {
|
|
|
846
826
|
versions = await response.json();
|
|
847
827
|
setVersions(sortBy__default["default"](versions, version => version.app));
|
|
848
828
|
} else {
|
|
849
|
-
const errorMessage =
|
|
829
|
+
const errorMessage = `Fetching the versions returned a ${response.status} HTTP status code.`;
|
|
850
830
|
// eslint-disable-next-line no-console
|
|
851
831
|
console.error(errorMessage);
|
|
852
832
|
}
|
|
@@ -861,8 +841,7 @@ const DeploymentTracker = () => {
|
|
|
861
841
|
};
|
|
862
842
|
}, []);
|
|
863
843
|
const getLastUpdate = application => {
|
|
864
|
-
|
|
865
|
-
const deployedAt = (_versions$find = _findInstanceProperty__default["default"](versions).call(versions, version => version.app === application)) === null || _versions$find === void 0 || (_versions$find = _versions$find.build) === null || _versions$find === void 0 ? void 0 : _versions$find.deployedAt;
|
|
844
|
+
const deployedAt = _findInstanceProperty__default["default"](versions).call(versions, version => version.app === application)?.build?.deployedAt;
|
|
866
845
|
if (!deployedAt) {
|
|
867
846
|
return {
|
|
868
847
|
value: 0,
|
|
@@ -876,17 +855,17 @@ const DeploymentTracker = () => {
|
|
|
876
855
|
const minutes = getDurationBetween('minutes', deployedAt);
|
|
877
856
|
return {
|
|
878
857
|
value: Number(minutes.toFixed(0)),
|
|
879
|
-
text:
|
|
858
|
+
text: `${minutes.toFixed(0)} minutes ago`
|
|
880
859
|
};
|
|
881
860
|
}
|
|
882
861
|
return {
|
|
883
862
|
value: Number(hours.toFixed(0)),
|
|
884
|
-
text:
|
|
863
|
+
text: `${hours.toFixed(0)} hours ago`
|
|
885
864
|
};
|
|
886
865
|
}
|
|
887
866
|
return {
|
|
888
867
|
value: Number(days.toFixed(0)),
|
|
889
|
-
text:
|
|
868
|
+
text: `${days.toFixed(0)} days ago`
|
|
890
869
|
};
|
|
891
870
|
};
|
|
892
871
|
const getTone = _ref3 => {
|
|
@@ -898,7 +877,7 @@ const DeploymentTracker = () => {
|
|
|
898
877
|
}
|
|
899
878
|
return 'primary';
|
|
900
879
|
};
|
|
901
|
-
if (!
|
|
880
|
+
if (!versions?.length) return null;
|
|
902
881
|
return jsxRuntime.jsxs("div", {
|
|
903
882
|
css: _ref2$1,
|
|
904
883
|
children: [jsxRuntime.jsxs(uiKit.Stamp, {
|
|
@@ -25,10 +25,8 @@ var isEqual = require('lodash/isEqual');
|
|
|
25
25
|
var applicationComponents = require('@commercetools-frontend/application-components');
|
|
26
26
|
var applicationShell = require('@commercetools-frontend/application-shell');
|
|
27
27
|
var constants = require('@commercetools-frontend/constants');
|
|
28
|
-
var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
29
28
|
var applicationShellConnectors = require('@commercetools-frontend/application-shell-connectors');
|
|
30
29
|
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
31
|
-
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
32
30
|
require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
|
|
33
31
|
require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
34
32
|
require('@babel/runtime-corejs3/helpers/createClass');
|
|
@@ -57,9 +55,7 @@ var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
|
57
55
|
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
58
56
|
var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
|
|
59
57
|
var isEqual__default = /*#__PURE__*/_interopDefault(isEqual);
|
|
60
|
-
var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
|
|
61
58
|
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
62
|
-
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
63
59
|
var _URLSearchParams__default = /*#__PURE__*/_interopDefault(_URLSearchParams);
|
|
64
60
|
var sortBy__default = /*#__PURE__*/_interopDefault(sortBy);
|
|
65
61
|
|
|
@@ -180,27 +176,24 @@ const EnvironmentSwitcher = () => {
|
|
|
180
176
|
value = _useState2[0],
|
|
181
177
|
setValue = _useState2[1];
|
|
182
178
|
react.useEffect(() => {
|
|
183
|
-
|
|
184
|
-
const currentURL = (_window = window) === null || _window === void 0 || (_window = _window.location) === null || _window === void 0 ? void 0 : _window.origin;
|
|
179
|
+
const currentURL = window?.location?.origin;
|
|
185
180
|
if (currentURL === LOCAL_ENV.value) {
|
|
186
|
-
|
|
187
|
-
(_ENV$ = ENV[0]) === null || _ENV$ === void 0 || _ENV$.options.unshift(LOCAL_ENV);
|
|
181
|
+
ENV[0]?.options.unshift(LOCAL_ENV);
|
|
188
182
|
}
|
|
189
183
|
if (_includesInstanceProperty__default["default"](currentURL).call(currentURL, 'preview')) {
|
|
190
|
-
|
|
191
|
-
(_ENV$2 = ENV[0]) === null || _ENV$2 === void 0 || _ENV$2.options.unshift(PREVIEW_BRANCH);
|
|
184
|
+
ENV[0]?.options.unshift(PREVIEW_BRANCH);
|
|
192
185
|
}
|
|
193
186
|
if (_includesInstanceProperty__default["default"](currentURL).call(currentURL, 'preview')) {
|
|
194
187
|
setValue('');
|
|
195
188
|
} else {
|
|
196
|
-
var
|
|
197
|
-
setValue(
|
|
189
|
+
var _context, _context2;
|
|
190
|
+
setValue(_findInstanceProperty__default["default"](_context = _flatInstanceProperty__default["default"](_context2 = _mapInstanceProperty__default["default"](ENV).call(ENV, _ref2 => {
|
|
198
191
|
let options = _ref2.options;
|
|
199
192
|
return options;
|
|
200
193
|
})).call(_context2)).call(_context, _ref3 => {
|
|
201
194
|
let value = _ref3.value;
|
|
202
195
|
return value === currentURL;
|
|
203
|
-
})
|
|
196
|
+
})?.value);
|
|
204
197
|
}
|
|
205
198
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
206
199
|
}, []);
|
|
@@ -240,7 +233,6 @@ const USER_ROLES_WITH_ALLOWED_ACCESS = ['Engineer', 'ProductProjectManagerOrOwne
|
|
|
240
233
|
|
|
241
234
|
var FetchStaffBarUser = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchStaffBarUser" }, variableDefinitions: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", alias: { kind: "Name", value: "user" }, name: { kind: "Name", value: "me" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "launchdarklyTrackingGroup" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "launchdarklyTrackingSubgroup" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "businessRole" }, arguments: [], directives: [] }] } }] } }], loc: { start: 0, end: 132, source: { body: "query FetchStaffBarUser {\n user: me {\n id\n launchdarklyTrackingGroup\n launchdarklyTrackingSubgroup\n businessRole\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
242
235
|
const useStaffBarUser = () => {
|
|
243
|
-
var _data$user, _data$user2, _data$user3;
|
|
244
236
|
const _useMcQuery = applicationShell.useMcQuery(FetchStaffBarUser, {
|
|
245
237
|
context: {
|
|
246
238
|
target: constants.GRAPHQL_TARGETS.MERCHANT_CENTER_BACKEND
|
|
@@ -251,9 +243,9 @@ const useStaffBarUser = () => {
|
|
|
251
243
|
data = _useMcQuery.data,
|
|
252
244
|
error = _useMcQuery.error;
|
|
253
245
|
return {
|
|
254
|
-
userId: data
|
|
255
|
-
isStaffMember:
|
|
256
|
-
isDevMember: _includesInstanceProperty__default["default"](USER_ROLES_WITH_ALLOWED_ACCESS).call(USER_ROLES_WITH_ALLOWED_ACCESS, data
|
|
246
|
+
userId: data?.user?.id,
|
|
247
|
+
isStaffMember: data?.user?.launchdarklyTrackingGroup === 'commercetools',
|
|
248
|
+
isDevMember: _includesInstanceProperty__default["default"](USER_ROLES_WITH_ALLOWED_ACCESS).call(USER_ROLES_WITH_ALLOWED_ACCESS, data?.user?.businessRole),
|
|
257
249
|
error
|
|
258
250
|
};
|
|
259
251
|
};
|
|
@@ -269,15 +261,11 @@ const defaultTeam = {
|
|
|
269
261
|
};
|
|
270
262
|
const onlyTeamsWithMembership = function (userId) {
|
|
271
263
|
let teams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
272
|
-
return teams.length ? _filterInstanceProperty__default["default"](teams).call(teams, team =>
|
|
273
|
-
var _team$membersRef;
|
|
274
|
-
return (_team$membersRef = team.membersRef) === null || _team$membersRef === void 0 ? void 0 : _someInstanceProperty__default["default"](_team$membersRef).call(_team$membersRef, memberRef => memberRef.id === userId);
|
|
275
|
-
}) : [];
|
|
264
|
+
return teams.length ? _filterInstanceProperty__default["default"](teams).call(teams, team => team.membersRef?.some(memberRef => memberRef.id === userId)) : [];
|
|
276
265
|
};
|
|
277
266
|
const getAdminTeamId = function () {
|
|
278
|
-
var _teams$find;
|
|
279
267
|
let teams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
280
|
-
return
|
|
268
|
+
return _findInstanceProperty__default["default"](teams).call(teams, team => team.name === 'Administrators')?.id;
|
|
281
269
|
};
|
|
282
270
|
const getStoredTeamId = function (storedId) {
|
|
283
271
|
let teams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
@@ -287,8 +275,8 @@ const transformTeamsToOptions = function () {
|
|
|
287
275
|
let teams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
288
276
|
const hasAdminTeam = Boolean(getAdminTeamId(teams));
|
|
289
277
|
const options = _mapInstanceProperty__default["default"](teams).call(teams, team => ({
|
|
290
|
-
label: team
|
|
291
|
-
value: team
|
|
278
|
+
label: team?.name,
|
|
279
|
+
value: team?.id
|
|
292
280
|
}));
|
|
293
281
|
if (hasAdminTeam) {
|
|
294
282
|
return options;
|
|
@@ -299,17 +287,13 @@ const transformTeamsToOptions = function () {
|
|
|
299
287
|
}
|
|
300
288
|
};
|
|
301
289
|
const useTeams = () => {
|
|
302
|
-
|
|
303
|
-
const projectKey = applicationShellConnectors.useApplicationContext(applicationContext => {
|
|
304
|
-
var _applicationContext$p;
|
|
305
|
-
return (_applicationContext$p = applicationContext.project) === null || _applicationContext$p === void 0 ? void 0 : _applicationContext$p.key;
|
|
306
|
-
});
|
|
290
|
+
const projectKey = applicationShellConnectors.useApplicationContext(applicationContext => applicationContext.project?.key);
|
|
307
291
|
const _useStaffBarUser = useStaffBarUser(),
|
|
308
292
|
userId = _useStaffBarUser.userId;
|
|
309
293
|
const _useMcQuery = applicationShell.useMcQuery(FetchTeamsByProjectQuery, {
|
|
310
294
|
skip: !projectKey,
|
|
311
295
|
variables: {
|
|
312
|
-
where:
|
|
296
|
+
where: `key="${projectKey}"`
|
|
313
297
|
},
|
|
314
298
|
context: {
|
|
315
299
|
target: constants.GRAPHQL_TARGETS.ADMINISTRATION_SERVICE
|
|
@@ -318,7 +302,7 @@ const useTeams = () => {
|
|
|
318
302
|
data = _useMcQuery.data,
|
|
319
303
|
error = _useMcQuery.error,
|
|
320
304
|
loading = _useMcQuery.loading;
|
|
321
|
-
const teams = data
|
|
305
|
+
const teams = data?.myProjects?.results?.[0]?.owner?.teams;
|
|
322
306
|
react.useEffect(() => {
|
|
323
307
|
if (loading) {
|
|
324
308
|
return;
|
|
@@ -335,7 +319,7 @@ const useTeams = () => {
|
|
|
335
319
|
const options = transformTeamsToOptions(onlyTeamsWithMembership(userId || '', teams));
|
|
336
320
|
const adminTeamId = getAdminTeamId(onlyTeamsWithMembership(userId || '', teams));
|
|
337
321
|
const storedId = getActiveTeamId();
|
|
338
|
-
const activeTeamId =
|
|
322
|
+
const activeTeamId = storedId ?? adminTeamId ?? defaultTeam.value;
|
|
339
323
|
return {
|
|
340
324
|
data,
|
|
341
325
|
options,
|
|
@@ -346,22 +330,21 @@ const useTeams = () => {
|
|
|
346
330
|
};
|
|
347
331
|
};
|
|
348
332
|
|
|
349
|
-
|
|
350
|
-
const launchdarklyAdapter = (_window$__flopflip__ = window.__flopflip__) === null || _window$__flopflip__ === void 0 ? void 0 : _window$__flopflip__.launchdarkly;
|
|
333
|
+
const launchdarklyAdapter = window.__flopflip__?.launchdarkly;
|
|
351
334
|
function getFlagValue(flag, defaultValue) {
|
|
352
335
|
// @ts-expect-error: getFlag exists not on all adapters and hence
|
|
353
336
|
// not the generic type. For ours it exists.
|
|
354
|
-
const result = launchdarklyAdapter
|
|
337
|
+
const result = launchdarklyAdapter?.getFlag(flag);
|
|
355
338
|
if (typeof result === 'boolean') {
|
|
356
339
|
return result;
|
|
357
|
-
} else if (typeof
|
|
340
|
+
} else if (typeof result?.value === 'boolean') {
|
|
358
341
|
return result;
|
|
359
342
|
}
|
|
360
343
|
return defaultValue;
|
|
361
344
|
}
|
|
362
345
|
function setFlag(flagName, flagValue) {
|
|
363
346
|
let lockFlags = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
364
|
-
launchdarklyAdapter
|
|
347
|
+
launchdarklyAdapter?.updateFlags({
|
|
365
348
|
[flagName]: flagValue
|
|
366
349
|
}, {
|
|
367
350
|
lockFlags
|
|
@@ -408,7 +391,7 @@ function toggleFeatureFlag(flag, value) {
|
|
|
408
391
|
setFlag(flag, value);
|
|
409
392
|
}
|
|
410
393
|
const FeatureFlagToggler = props => {
|
|
411
|
-
var _context
|
|
394
|
+
var _context;
|
|
412
395
|
const modalState = applicationComponents.useModalState();
|
|
413
396
|
const _useState = react.useState(false),
|
|
414
397
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -417,29 +400,27 @@ const FeatureFlagToggler = props => {
|
|
|
417
400
|
const cachedFeatureFlag = getFromSessionStorage(FEATURE_FLAG_KEY);
|
|
418
401
|
const _useStaffBarUser = useStaffBarUser(),
|
|
419
402
|
isDevMember = _useStaffBarUser.isDevMember;
|
|
420
|
-
const _useState3 = react.useState(_mapInstanceProperty__default["default"](_context = _Object$entries__default["default"](
|
|
421
|
-
var _cachedFeatureFlag$fe;
|
|
403
|
+
const _useState3 = react.useState(_mapInstanceProperty__default["default"](_context = _Object$entries__default["default"](props.featureFlags ?? {})).call(_context, _ref => {
|
|
422
404
|
let _ref2 = _slicedToArray(_ref, 2),
|
|
423
405
|
featureName = _ref2[0],
|
|
424
406
|
toggleValue = _ref2[1];
|
|
425
407
|
return {
|
|
426
408
|
featureName,
|
|
427
|
-
toggleValue:
|
|
409
|
+
toggleValue: cachedFeatureFlag[featureName] ?? getFlagValue(featureName, toggleValue)
|
|
428
410
|
};
|
|
429
411
|
})),
|
|
430
412
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
431
413
|
options = _useState4[0],
|
|
432
414
|
setOptions = _useState4[1];
|
|
433
415
|
const originalValues = react.useMemo(() => {
|
|
434
|
-
var _context2
|
|
435
|
-
return _mapInstanceProperty__default["default"](_context2 = _Object$entries__default["default"](
|
|
436
|
-
var _getFlagValue;
|
|
416
|
+
var _context2;
|
|
417
|
+
return _mapInstanceProperty__default["default"](_context2 = _Object$entries__default["default"](props.featureFlags ?? {})).call(_context2, _ref3 => {
|
|
437
418
|
let _ref4 = _slicedToArray(_ref3, 2),
|
|
438
419
|
featureName = _ref4[0],
|
|
439
420
|
toggleValue = _ref4[1];
|
|
440
421
|
return {
|
|
441
422
|
featureName,
|
|
442
|
-
toggleValue:
|
|
423
|
+
toggleValue: getFlagValue(featureName, toggleValue) ?? 'false'
|
|
443
424
|
};
|
|
444
425
|
});
|
|
445
426
|
},
|
|
@@ -485,11 +466,11 @@ const FeatureFlagToggler = props => {
|
|
|
485
466
|
});
|
|
486
467
|
} else {
|
|
487
468
|
toggleFeatureFlag(featureName, {
|
|
488
|
-
value: !
|
|
469
|
+
value: !toggleValue?.value
|
|
489
470
|
});
|
|
490
471
|
newOptions[index] = _objectSpread$1(_objectSpread$1({}, newOptions[index]), {}, {
|
|
491
472
|
toggleValue: {
|
|
492
|
-
value: !
|
|
473
|
+
value: !toggleValue?.value
|
|
493
474
|
}
|
|
494
475
|
});
|
|
495
476
|
}
|
|
@@ -608,7 +589,7 @@ const FeatureFlagToggler = props => {
|
|
|
608
589
|
};
|
|
609
590
|
|
|
610
591
|
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
611
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
592
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
612
593
|
var GitHubIcon = function GitHubIcon(props) {
|
|
613
594
|
return jsxRuntime.jsx("svg", _objectSpread(_objectSpread({}, props), {}, {
|
|
614
595
|
children: jsxRuntime.jsx("path", {
|
|
@@ -630,8 +611,7 @@ function GitHubPullRequestLink() {
|
|
|
630
611
|
label: "GitHub Pull Request",
|
|
631
612
|
icon: jsxRuntime.jsx(GitHubIcon, {}),
|
|
632
613
|
onClick: () => {
|
|
633
|
-
|
|
634
|
-
window.open(_concatInstanceProperty__default["default"](_context = "".concat(GITHUB_PR_URL)).call(_context, PRNumber));
|
|
614
|
+
window.open(`${GITHUB_PR_URL}${PRNumber}`);
|
|
635
615
|
}
|
|
636
616
|
});
|
|
637
617
|
}
|
|
@@ -649,7 +629,7 @@ const TeamSwitcher = () => {
|
|
|
649
629
|
options = _useTeams.options,
|
|
650
630
|
activeTeamId = _useTeams.activeTeamId,
|
|
651
631
|
isLimitedPermission = _useTeams.isLimitedPermission;
|
|
652
|
-
if (!
|
|
632
|
+
if (!options?.length) {
|
|
653
633
|
return null;
|
|
654
634
|
}
|
|
655
635
|
const bottomOption = {
|
|
@@ -804,7 +784,7 @@ const DeploymentTracker = () => {
|
|
|
804
784
|
return;
|
|
805
785
|
}
|
|
806
786
|
try {
|
|
807
|
-
const response = await fetch(
|
|
787
|
+
const response = await fetch(`${URL}/versions`, {
|
|
808
788
|
signal: abortController.signal
|
|
809
789
|
});
|
|
810
790
|
let versions;
|
|
@@ -812,7 +792,7 @@ const DeploymentTracker = () => {
|
|
|
812
792
|
versions = await response.json();
|
|
813
793
|
setVersions(sortBy__default["default"](versions, version => version.app));
|
|
814
794
|
} else {
|
|
815
|
-
const errorMessage =
|
|
795
|
+
const errorMessage = `Fetching the versions returned a ${response.status} HTTP status code.`;
|
|
816
796
|
// eslint-disable-next-line no-console
|
|
817
797
|
console.error(errorMessage);
|
|
818
798
|
}
|
|
@@ -827,8 +807,7 @@ const DeploymentTracker = () => {
|
|
|
827
807
|
};
|
|
828
808
|
}, []);
|
|
829
809
|
const getLastUpdate = application => {
|
|
830
|
-
|
|
831
|
-
const deployedAt = (_versions$find = _findInstanceProperty__default["default"](versions).call(versions, version => version.app === application)) === null || _versions$find === void 0 || (_versions$find = _versions$find.build) === null || _versions$find === void 0 ? void 0 : _versions$find.deployedAt;
|
|
810
|
+
const deployedAt = _findInstanceProperty__default["default"](versions).call(versions, version => version.app === application)?.build?.deployedAt;
|
|
832
811
|
if (!deployedAt) {
|
|
833
812
|
return {
|
|
834
813
|
value: 0,
|
|
@@ -842,17 +821,17 @@ const DeploymentTracker = () => {
|
|
|
842
821
|
const minutes = getDurationBetween('minutes', deployedAt);
|
|
843
822
|
return {
|
|
844
823
|
value: Number(minutes.toFixed(0)),
|
|
845
|
-
text:
|
|
824
|
+
text: `${minutes.toFixed(0)} minutes ago`
|
|
846
825
|
};
|
|
847
826
|
}
|
|
848
827
|
return {
|
|
849
828
|
value: Number(hours.toFixed(0)),
|
|
850
|
-
text:
|
|
829
|
+
text: `${hours.toFixed(0)} hours ago`
|
|
851
830
|
};
|
|
852
831
|
}
|
|
853
832
|
return {
|
|
854
833
|
value: Number(days.toFixed(0)),
|
|
855
|
-
text:
|
|
834
|
+
text: `${days.toFixed(0)} days ago`
|
|
856
835
|
};
|
|
857
836
|
};
|
|
858
837
|
const getTone = _ref3 => {
|
|
@@ -864,7 +843,7 @@ const DeploymentTracker = () => {
|
|
|
864
843
|
}
|
|
865
844
|
return 'primary';
|
|
866
845
|
};
|
|
867
|
-
if (!
|
|
846
|
+
if (!versions?.length) return null;
|
|
868
847
|
return jsxRuntime.jsxs("div", {
|
|
869
848
|
css: _ref2$1,
|
|
870
849
|
children: [jsxRuntime.jsxs(uiKit.Stamp, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/staff-bar",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Toolbar that makes testing inside Merchant Center easier",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/commercetools-frontend-staff-bar.cjs.js",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"@babel/core": "^7.22.11",
|
|
18
18
|
"@babel/runtime": "^7.21.0",
|
|
19
19
|
"@babel/runtime-corejs3": "^7.21.0",
|
|
20
|
-
"@commercetools-frontend/application-components": "22.
|
|
21
|
-
"@commercetools-frontend/application-shell": "22.
|
|
22
|
-
"@commercetools-frontend/ui-kit": "19.
|
|
20
|
+
"@commercetools-frontend/application-components": "npm:@commercetools-frontend/application-components@^22.30.3",
|
|
21
|
+
"@commercetools-frontend/application-shell": "npm:@commercetools-frontend/application-shell@^22.30.3",
|
|
22
|
+
"@commercetools-frontend/ui-kit": "npm:@commercetools-frontend/ui-kit@^19.9.0",
|
|
23
23
|
"@flopflip/types": "14.0.1",
|
|
24
24
|
"lodash": "4.17.21",
|
|
25
25
|
"prop-types": "15.8.1",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"typescript": "5.2.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@commercetools-frontend/application-shell-connectors": "22.
|
|
32
|
-
"@commercetools-frontend/constants": "22.
|
|
31
|
+
"@commercetools-frontend/application-shell-connectors": "22.30.3",
|
|
32
|
+
"@commercetools-frontend/constants": "22.30.3",
|
|
33
33
|
"@emotion/react": "^11.11.1",
|
|
34
34
|
"@manypkg/find-root": "2.2.2",
|
|
35
35
|
"@types/react": "17.0.80",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"react": "17.0.2"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@commercetools-frontend/application-shell-connectors": "22.
|
|
44
|
-
"@commercetools-frontend/constants": "22.
|
|
43
|
+
"@commercetools-frontend/application-shell-connectors": "^22.30.3",
|
|
44
|
+
"@commercetools-frontend/constants": "^22.30.3",
|
|
45
45
|
"@emotion/react": "11.x",
|
|
46
46
|
"react": "17.x"
|
|
47
47
|
},
|