@commercetools-frontend/application-shell 25.0.0 → 25.2.0
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/{application-entry-point-1b23fb6b.esm.js → application-entry-point-10a5e1a5.esm.js} +4 -6
- package/dist/{application-entry-point-74a06151.cjs.prod.js → application-entry-point-8c4b8e53.cjs.prod.js} +3 -4
- package/dist/{application-entry-point-18d8fba0.cjs.dev.js → application-entry-point-c87294b0.cjs.dev.js} +4 -7
- package/dist/commercetools-frontend-application-shell.cjs.dev.js +4 -5
- package/dist/commercetools-frontend-application-shell.cjs.prod.js +4 -5
- package/dist/commercetools-frontend-application-shell.esm.js +4 -5
- package/dist/{custom-view-dev-host-dc7f2835.cjs.dev.js → custom-view-dev-host-116479c1.cjs.dev.js} +10 -15
- package/dist/{custom-view-dev-host-d72f9ae0.cjs.prod.js → custom-view-dev-host-8dd01b96.cjs.prod.js} +10 -15
- package/dist/{custom-view-dev-host-98432fc5.esm.js → custom-view-dev-host-c47927c7.esm.js} +10 -14
- package/dist/{index-208c3cdd.cjs.dev.js → index-1bdcc336.cjs.dev.js} +108 -132
- package/dist/{index-52c724ed.cjs.prod.js → index-245e2980.cjs.prod.js} +2 -2
- package/dist/{index-25183095.cjs.dev.js → index-614accc4.cjs.dev.js} +2 -2
- package/dist/{index-5aaa33bb.esm.js → index-86039df7.esm.js} +2 -2
- package/dist/{index-af2cc053.cjs.prod.js → index-aa7211d5.cjs.prod.js} +108 -132
- package/dist/{index-75206fba.esm.js → index-b26c8745.esm.js} +108 -131
- package/dist/{navbar-0bad8bc8.esm.js → navbar-9a40ead9.esm.js} +89 -104
- package/dist/{navbar-d4189469.cjs.dev.js → navbar-c51e0607.cjs.dev.js} +89 -105
- package/dist/{navbar-7653417f.cjs.prod.js → navbar-e287ce25.cjs.prod.js} +89 -105
- package/dist/oidc-8827f9fe.cjs.dev.js +98 -0
- package/dist/oidc-b2520905.esm.js +84 -0
- package/dist/{oidc-callback-3f9e25bc.cjs.prod.js → oidc-callback-13f8e123.cjs.prod.js} +8 -10
- package/dist/{oidc-callback-b6584fe8.esm.js → oidc-callback-39ea9b04.esm.js} +8 -10
- package/dist/{oidc-callback-f2f37906.cjs.dev.js → oidc-callback-59160485.cjs.dev.js} +8 -10
- package/dist/oidc-d74e6aa2.cjs.prod.js +98 -0
- package/dist/{project-container-27db6a7e.cjs.dev.js → project-container-a6c01dbf.cjs.dev.js} +11 -14
- package/dist/{project-container-0c9ee557.cjs.prod.js → project-container-ad2b76c9.cjs.prod.js} +11 -14
- package/dist/{project-container-8f8e017f.esm.js → project-container-f874583d.esm.js} +11 -14
- package/dist/{project-expired-b35819a4.cjs.dev.js → project-expired-743bae82.cjs.dev.js} +5 -6
- package/dist/{project-expired-da5d431c.cjs.prod.js → project-expired-a52200df.cjs.prod.js} +5 -6
- package/dist/{project-expired-bfa29d75.esm.js → project-expired-d917372c.esm.js} +5 -6
- package/dist/{project-not-found-fdb50d15.cjs.dev.js → project-not-found-5f0b2a72.cjs.dev.js} +4 -5
- package/dist/{project-not-found-695fadf6.cjs.prod.js → project-not-found-e4f79d38.cjs.prod.js} +4 -5
- package/dist/{project-not-found-5fc657c1.esm.js → project-not-found-ee259f9b.esm.js} +4 -5
- package/dist/{project-not-initialized-06d78b62.cjs.dev.js → project-not-initialized-58002613.cjs.dev.js} +5 -6
- package/dist/{project-not-initialized-a3b358cc.esm.js → project-not-initialized-6a3a2473.esm.js} +5 -6
- package/dist/{project-not-initialized-1603b228.cjs.prod.js → project-not-initialized-cfbd7c01.cjs.prod.js} +5 -6
- package/dist/{project-suspended-324978bc.cjs.prod.js → project-suspended-18764104.cjs.prod.js} +4 -5
- package/dist/{project-suspended-7e2257ac.cjs.dev.js → project-suspended-9cc251b0.cjs.dev.js} +4 -5
- package/dist/{project-suspended-d85025fe.esm.js → project-suspended-befd6810.esm.js} +4 -5
- package/dist/{redirect-to-login-3e4a6434.cjs.prod.js → redirect-to-login-12f467b8.cjs.prod.js} +10 -13
- package/dist/{redirect-to-login-edbfacbc.esm.js → redirect-to-login-2944c890.esm.js} +10 -13
- package/dist/{redirect-to-login-66ea895a.cjs.dev.js → redirect-to-login-3bee13ba.cjs.dev.js} +10 -13
- package/dist/{redirect-to-logout-ab5d2b07.cjs.dev.js → redirect-to-logout-7a1fd867.cjs.dev.js} +6 -8
- package/dist/{redirect-to-logout-aea7e913.esm.js → redirect-to-logout-ace73e1b.esm.js} +6 -8
- package/dist/{redirect-to-logout-f96c0c4b.cjs.prod.js → redirect-to-logout-ba4a0b0b.cjs.prod.js} +6 -8
- package/dist/{redirector-c858d578.cjs.prod.js → redirector-0c72d0a4.cjs.prod.js} +3 -4
- package/dist/{redirector-0efdd994.cjs.dev.js → redirector-72ccfbc2.cjs.dev.js} +3 -4
- package/dist/{redirector-656c6ee7.esm.js → redirector-d856975f.esm.js} +3 -4
- package/dist/{requests-in-flight-loader-5f216050.esm.js → requests-in-flight-loader-78c4428e.esm.js} +4 -5
- package/dist/{requests-in-flight-loader-3ffee0c0.cjs.prod.js → requests-in-flight-loader-b7225f9e.cjs.prod.js} +4 -5
- package/dist/{requests-in-flight-loader-08ef339c.cjs.dev.js → requests-in-flight-loader-cbc5faa0.cjs.dev.js} +4 -5
- package/dist/{service-page-project-switcher-9c5c86df.cjs.dev.js → service-page-project-switcher-09e3adc9.cjs.dev.js} +1 -1
- package/dist/{service-page-project-switcher-99b35fc0.esm.js → service-page-project-switcher-9cac7971.esm.js} +1 -1
- package/dist/{service-page-project-switcher-b21619c0.cjs.prod.js → service-page-project-switcher-d8772801.cjs.prod.js} +1 -1
- package/dist/{use-applications-menu-21c7420b.cjs.prod.js → use-applications-menu-8984efa1.cjs.prod.js} +39 -47
- package/dist/{use-applications-menu-8ff2d130.esm.js → use-applications-menu-bc2b9a66.esm.js} +37 -44
- package/dist/{use-applications-menu-7a85c3ee.cjs.dev.js → use-applications-menu-bd718ac8.cjs.dev.js} +39 -47
- package/dist/{user-settings-menu-2d3bfa75.cjs.prod.js → user-settings-menu-013f0041.cjs.prod.js} +22 -29
- package/dist/{user-settings-menu-31e6bb38.esm.js → user-settings-menu-16e8d020.esm.js} +22 -29
- package/dist/{user-settings-menu-c37b343f.cjs.dev.js → user-settings-menu-dc598434.cjs.dev.js} +22 -29
- package/package.json +17 -17
- package/ssr/dist/commercetools-frontend-application-shell-ssr.cjs.dev.js +1 -2
- package/ssr/dist/commercetools-frontend-application-shell-ssr.cjs.prod.js +1 -2
- package/ssr/dist/commercetools-frontend-application-shell-ssr.esm.js +1 -2
- package/test-utils/dist/commercetools-frontend-application-shell-test-utils.cjs.dev.js +22 -26
- package/test-utils/dist/commercetools-frontend-application-shell-test-utils.cjs.prod.js +22 -26
- package/test-utils/dist/commercetools-frontend-application-shell-test-utils.esm.js +17 -20
- package/dist/oidc-258fc018.cjs.prod.js +0 -115
- package/dist/oidc-35e8e62a.esm.js +0 -100
- package/dist/oidc-87d116c1.cjs.dev.js +0 -115
package/dist/{use-applications-menu-8ff2d130.esm.js → use-applications-menu-bc2b9a66.esm.js}
RENAMED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
|
|
2
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
3
|
+
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
4
|
+
import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
|
|
1
5
|
import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
|
|
2
6
|
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
|
|
3
7
|
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
@@ -6,18 +10,13 @@ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/inst
|
|
|
6
10
|
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
|
|
7
11
|
import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
|
|
8
12
|
import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
|
|
9
|
-
import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
|
|
10
|
-
import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
11
|
-
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
12
|
-
import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
|
|
13
|
-
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
14
13
|
import { useState, useEffect } from 'react';
|
|
15
14
|
import { useApolloClient } from '@apollo/client';
|
|
16
15
|
import { useApplicationContext, useMcQuery } from '@commercetools-frontend/application-shell-connectors';
|
|
17
16
|
import { getSupportedLocales } from '@commercetools-frontend/l10n';
|
|
18
17
|
|
|
19
18
|
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; }
|
|
20
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
19
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
21
20
|
var FetchApplicationsMenu = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchApplicationsMenu" }, variableDefinitions: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "applicationsMenu" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "appBar" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "uriPath" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "labelAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "featureToggle" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "permissions" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "navBarGroups" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "items" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "uriPath" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "icon" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "labelAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "featureToggle" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "permissions" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "actionRights" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "group" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "dataFences" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "group" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "type" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "submenu" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "uriPath" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "labelAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "featureToggle" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "permissions" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "actionRights" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "group" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "dataFences" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "group" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "type" }, arguments: [], directives: [] }] } }] } }] } }] } }] } }] } }], loc: { start: 0, end: 891, source: { body: "query FetchApplicationsMenu {\n applicationsMenu {\n appBar {\n key\n uriPath\n labelAllLocales {\n locale\n value\n }\n featureToggle\n permissions\n }\n navBarGroups {\n key\n items {\n key\n uriPath\n icon\n labelAllLocales {\n locale\n value\n }\n featureToggle\n permissions\n actionRights {\n group\n name\n }\n dataFences {\n group\n name\n type\n }\n submenu {\n key\n uriPath\n labelAllLocales {\n locale\n value\n }\n featureToggle\n permissions\n actionRights {\n group\n name\n }\n dataFences {\n group\n name\n type\n }\n }\n }\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
22
21
|
const defaultApiUrl = window.location.origin;
|
|
23
22
|
const mapLabelAllLocalesWithDefaults = (labelAllLocales, defaultLabel) => {
|
|
@@ -47,11 +46,11 @@ const mapLabelAllLocalesWithDefaults = (labelAllLocales, defaultLabel) => {
|
|
|
47
46
|
* This is only needed for development.
|
|
48
47
|
*/
|
|
49
48
|
const mapApplicationMenuConfigToGraqhQLQueryResult = applicationConfig => {
|
|
50
|
-
var
|
|
49
|
+
var _context2;
|
|
51
50
|
const entryPointUriPath = applicationConfig.entryPointUriPath;
|
|
52
|
-
const menuLinks =
|
|
51
|
+
const menuLinks = applicationConfig.__DEVELOPMENT__?.menuLinks;
|
|
53
52
|
// @ts-expect-error: the `accountLinks` is not explicitly typed as it's only used by the account app.
|
|
54
|
-
const accountLinks =
|
|
53
|
+
const accountLinks = applicationConfig.__DEVELOPMENT__?.accountLinks ?? [];
|
|
55
54
|
return {
|
|
56
55
|
applicationsMenu: {
|
|
57
56
|
__typename: 'ApplicationsMenu',
|
|
@@ -66,45 +65,39 @@ const mapApplicationMenuConfigToGraqhQLQueryResult = applicationConfig => {
|
|
|
66
65
|
labelAllLocales: mapLabelAllLocalesWithDefaults(menuLinks.labelAllLocales, menuLinks.defaultLabel),
|
|
67
66
|
permissions: menuLinks.permissions,
|
|
68
67
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
69
|
-
featureToggle:
|
|
68
|
+
featureToggle: menuLinks.featureToggle ?? null,
|
|
70
69
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
71
|
-
menuVisibility:
|
|
70
|
+
menuVisibility: menuLinks.menuVisibility ?? null,
|
|
72
71
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
73
|
-
actionRights:
|
|
72
|
+
actionRights: menuLinks.actionRights ?? null,
|
|
74
73
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
75
|
-
dataFences:
|
|
76
|
-
submenu: _mapInstanceProperty(_context2 = menuLinks.submenuLinks).call(_context2, submenuLink => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
dataFences: (_submenuLink$dataFenc = submenuLink.dataFences) !== null && _submenuLink$dataFenc !== void 0 ? _submenuLink$dataFenc : null
|
|
92
|
-
};
|
|
93
|
-
})
|
|
74
|
+
dataFences: menuLinks.dataFences ?? null,
|
|
75
|
+
submenu: _mapInstanceProperty(_context2 = menuLinks.submenuLinks).call(_context2, submenuLink => ({
|
|
76
|
+
__typename: 'BaseMenu',
|
|
77
|
+
key: `${entryPointUriPath}-${submenuLink.uriPath}`,
|
|
78
|
+
uriPath: submenuLink.uriPath,
|
|
79
|
+
labelAllLocales: mapLabelAllLocalesWithDefaults(submenuLink.labelAllLocales, submenuLink.defaultLabel),
|
|
80
|
+
permissions: submenuLink.permissions,
|
|
81
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
82
|
+
featureToggle: submenuLink.featureToggle ?? null,
|
|
83
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
84
|
+
menuVisibility: submenuLink.menuVisibility ?? null,
|
|
85
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
86
|
+
actionRights: submenuLink.actionRights ?? null,
|
|
87
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
88
|
+
dataFences: submenuLink.dataFences ?? null
|
|
89
|
+
}))
|
|
94
90
|
}]
|
|
95
91
|
}] : [],
|
|
96
|
-
appBar: _mapInstanceProperty(accountLinks).call(accountLinks, menuLink => {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
featureToggle: (_menuLink$featureTogg = menuLink.featureToggle) !== null && _menuLink$featureTogg !== void 0 ? _menuLink$featureTogg : null
|
|
106
|
-
};
|
|
107
|
-
})
|
|
92
|
+
appBar: _mapInstanceProperty(accountLinks).call(accountLinks, menuLink => ({
|
|
93
|
+
__typename: 'BaseMenu',
|
|
94
|
+
key: menuLink.uriPath,
|
|
95
|
+
uriPath: menuLink.uriPath,
|
|
96
|
+
labelAllLocales: mapLabelAllLocalesWithDefaults(menuLink.labelAllLocales, menuLink.defaultLabel),
|
|
97
|
+
permissions: menuLink.permissions,
|
|
98
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
99
|
+
featureToggle: menuLink.featureToggle ?? null
|
|
100
|
+
}))
|
|
108
101
|
}
|
|
109
102
|
};
|
|
110
103
|
};
|
|
@@ -133,7 +126,7 @@ function useApplicationsMenu(menuKey, config) {
|
|
|
133
126
|
fetchPolicy: config.environment.servedByProxy ? 'cache-first' : 'cache-only',
|
|
134
127
|
context: {
|
|
135
128
|
// Allow to overwrite the API url from application config
|
|
136
|
-
uri:
|
|
129
|
+
uri: `${mcProxyApiUrl || defaultApiUrl}/api/graphql`,
|
|
137
130
|
skipGraphQlTargetCheck: true
|
|
138
131
|
}
|
|
139
132
|
}),
|
package/dist/{use-applications-menu-7a85c3ee.cjs.dev.js → use-applications-menu-bd718ac8.cjs.dev.js}
RENAMED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
4
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
5
|
+
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
6
|
+
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
3
7
|
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
4
8
|
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
5
9
|
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
@@ -8,11 +12,6 @@ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/in
|
|
|
8
12
|
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
9
13
|
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
10
14
|
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
11
|
-
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
12
|
-
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
13
|
-
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
14
|
-
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
15
|
-
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
16
15
|
var react = require('react');
|
|
17
16
|
var client = require('@apollo/client');
|
|
18
17
|
var applicationShellConnectors = require('@commercetools-frontend/application-shell-connectors');
|
|
@@ -20,6 +19,8 @@ var l10n = require('@commercetools-frontend/l10n');
|
|
|
20
19
|
|
|
21
20
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
22
21
|
|
|
22
|
+
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
23
|
+
var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
|
|
23
24
|
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
24
25
|
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
|
|
25
26
|
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
@@ -28,12 +29,9 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
|
|
|
28
29
|
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
29
30
|
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
30
31
|
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
31
|
-
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
32
|
-
var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
|
|
33
|
-
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
34
32
|
|
|
35
33
|
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; }
|
|
36
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
34
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
37
35
|
var FetchApplicationsMenu = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchApplicationsMenu" }, variableDefinitions: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "applicationsMenu" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "appBar" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "uriPath" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "labelAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "featureToggle" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "permissions" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "navBarGroups" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "items" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "uriPath" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "icon" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "labelAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "featureToggle" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "permissions" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "actionRights" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "group" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "dataFences" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "group" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "type" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "submenu" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "uriPath" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "labelAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "featureToggle" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "permissions" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "actionRights" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "group" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "dataFences" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "group" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "type" }, arguments: [], directives: [] }] } }] } }] } }] } }] } }] } }], loc: { start: 0, end: 891, source: { body: "query FetchApplicationsMenu {\n applicationsMenu {\n appBar {\n key\n uriPath\n labelAllLocales {\n locale\n value\n }\n featureToggle\n permissions\n }\n navBarGroups {\n key\n items {\n key\n uriPath\n icon\n labelAllLocales {\n locale\n value\n }\n featureToggle\n permissions\n actionRights {\n group\n name\n }\n dataFences {\n group\n name\n type\n }\n submenu {\n key\n uriPath\n labelAllLocales {\n locale\n value\n }\n featureToggle\n permissions\n actionRights {\n group\n name\n }\n dataFences {\n group\n name\n type\n }\n }\n }\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
38
36
|
const defaultApiUrl = window.location.origin;
|
|
39
37
|
const mapLabelAllLocalesWithDefaults = (labelAllLocales, defaultLabel) => {
|
|
@@ -63,11 +61,11 @@ const mapLabelAllLocalesWithDefaults = (labelAllLocales, defaultLabel) => {
|
|
|
63
61
|
* This is only needed for development.
|
|
64
62
|
*/
|
|
65
63
|
const mapApplicationMenuConfigToGraqhQLQueryResult = applicationConfig => {
|
|
66
|
-
var
|
|
64
|
+
var _context2;
|
|
67
65
|
const entryPointUriPath = applicationConfig.entryPointUriPath;
|
|
68
|
-
const menuLinks =
|
|
66
|
+
const menuLinks = applicationConfig.__DEVELOPMENT__?.menuLinks;
|
|
69
67
|
// @ts-expect-error: the `accountLinks` is not explicitly typed as it's only used by the account app.
|
|
70
|
-
const accountLinks =
|
|
68
|
+
const accountLinks = applicationConfig.__DEVELOPMENT__?.accountLinks ?? [];
|
|
71
69
|
return {
|
|
72
70
|
applicationsMenu: {
|
|
73
71
|
__typename: 'ApplicationsMenu',
|
|
@@ -82,45 +80,39 @@ const mapApplicationMenuConfigToGraqhQLQueryResult = applicationConfig => {
|
|
|
82
80
|
labelAllLocales: mapLabelAllLocalesWithDefaults(menuLinks.labelAllLocales, menuLinks.defaultLabel),
|
|
83
81
|
permissions: menuLinks.permissions,
|
|
84
82
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
85
|
-
featureToggle:
|
|
83
|
+
featureToggle: menuLinks.featureToggle ?? null,
|
|
86
84
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
87
|
-
menuVisibility:
|
|
85
|
+
menuVisibility: menuLinks.menuVisibility ?? null,
|
|
88
86
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
89
|
-
actionRights:
|
|
87
|
+
actionRights: menuLinks.actionRights ?? null,
|
|
90
88
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
91
|
-
dataFences:
|
|
92
|
-
submenu: _mapInstanceProperty__default["default"](_context2 = menuLinks.submenuLinks).call(_context2, submenuLink => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
dataFences: (_submenuLink$dataFenc = submenuLink.dataFences) !== null && _submenuLink$dataFenc !== void 0 ? _submenuLink$dataFenc : null
|
|
108
|
-
};
|
|
109
|
-
})
|
|
89
|
+
dataFences: menuLinks.dataFences ?? null,
|
|
90
|
+
submenu: _mapInstanceProperty__default["default"](_context2 = menuLinks.submenuLinks).call(_context2, submenuLink => ({
|
|
91
|
+
__typename: 'BaseMenu',
|
|
92
|
+
key: `${entryPointUriPath}-${submenuLink.uriPath}`,
|
|
93
|
+
uriPath: submenuLink.uriPath,
|
|
94
|
+
labelAllLocales: mapLabelAllLocalesWithDefaults(submenuLink.labelAllLocales, submenuLink.defaultLabel),
|
|
95
|
+
permissions: submenuLink.permissions,
|
|
96
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
97
|
+
featureToggle: submenuLink.featureToggle ?? null,
|
|
98
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
99
|
+
menuVisibility: submenuLink.menuVisibility ?? null,
|
|
100
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
101
|
+
actionRights: submenuLink.actionRights ?? null,
|
|
102
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
103
|
+
dataFences: submenuLink.dataFences ?? null
|
|
104
|
+
}))
|
|
110
105
|
}]
|
|
111
106
|
}] : [],
|
|
112
|
-
appBar: _mapInstanceProperty__default["default"](accountLinks).call(accountLinks, menuLink => {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
featureToggle: (_menuLink$featureTogg = menuLink.featureToggle) !== null && _menuLink$featureTogg !== void 0 ? _menuLink$featureTogg : null
|
|
122
|
-
};
|
|
123
|
-
})
|
|
107
|
+
appBar: _mapInstanceProperty__default["default"](accountLinks).call(accountLinks, menuLink => ({
|
|
108
|
+
__typename: 'BaseMenu',
|
|
109
|
+
key: menuLink.uriPath,
|
|
110
|
+
uriPath: menuLink.uriPath,
|
|
111
|
+
labelAllLocales: mapLabelAllLocalesWithDefaults(menuLink.labelAllLocales, menuLink.defaultLabel),
|
|
112
|
+
permissions: menuLink.permissions,
|
|
113
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
114
|
+
featureToggle: menuLink.featureToggle ?? null
|
|
115
|
+
}))
|
|
124
116
|
}
|
|
125
117
|
};
|
|
126
118
|
};
|
|
@@ -149,7 +141,7 @@ function useApplicationsMenu(menuKey, config) {
|
|
|
149
141
|
fetchPolicy: config.environment.servedByProxy ? 'cache-first' : 'cache-only',
|
|
150
142
|
context: {
|
|
151
143
|
// Allow to overwrite the API url from application config
|
|
152
|
-
uri:
|
|
144
|
+
uri: `${mcProxyApiUrl || defaultApiUrl}/api/graphql`,
|
|
153
145
|
skipGraphQlTargetCheck: true
|
|
154
146
|
}
|
|
155
147
|
}),
|
package/dist/{user-settings-menu-2d3bfa75.cjs.prod.js → user-settings-menu-013f0041.cjs.prod.js}
RENAMED
|
@@ -28,10 +28,9 @@ var Avatar = require('@commercetools-uikit/avatar');
|
|
|
28
28
|
var designSystem = require('@commercetools-uikit/design-system');
|
|
29
29
|
var Spacings = require('@commercetools-uikit/spacings');
|
|
30
30
|
var Text = require('@commercetools-uikit/text');
|
|
31
|
-
var oidc = require('./oidc-
|
|
32
|
-
var useApplicationsMenu = require('./use-applications-menu-
|
|
31
|
+
var oidc = require('./oidc-d74e6aa2.cjs.prod.js');
|
|
32
|
+
var useApplicationsMenu = require('./use-applications-menu-8984efa1.cjs.prod.js');
|
|
33
33
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
34
|
-
require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
35
34
|
require('@apollo/client');
|
|
36
35
|
require('@commercetools-frontend/l10n');
|
|
37
36
|
|
|
@@ -121,17 +120,15 @@ const UserAvatar = props => {
|
|
|
121
120
|
};
|
|
122
121
|
UserAvatar.displayName = 'UserAvatar';
|
|
123
122
|
function getIsFocusedElementInMenu() {
|
|
124
|
-
|
|
125
|
-
return Boolean((_document$activeEleme = document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.getAttribute('data-user-settings-menu'));
|
|
123
|
+
return Boolean(document.activeElement?.getAttribute('data-user-settings-menu'));
|
|
126
124
|
}
|
|
127
125
|
const stateReducer = (state, changes) => {
|
|
128
|
-
var _ref3;
|
|
129
126
|
switch (changes.type) {
|
|
130
127
|
// So in case the user wants to navigate with the tab button
|
|
131
128
|
// we need to make sure that the menu does not close
|
|
132
129
|
case Downshift__default["default"].stateChangeTypes.blurButton:
|
|
133
130
|
return _objectSpread(_objectSpread({}, changes), {}, {
|
|
134
|
-
isOpen: (
|
|
131
|
+
isOpen: (state.isOpen && getIsFocusedElementInMenu()) ?? false
|
|
135
132
|
});
|
|
136
133
|
default:
|
|
137
134
|
return changes;
|
|
@@ -178,14 +175,13 @@ const UserSettingsMenuBody = props => {
|
|
|
178
175
|
// Focus on a menu item when it's opened through keyboard
|
|
179
176
|
const menuElementRef = react.useRef(null);
|
|
180
177
|
react.useEffect(() => {
|
|
181
|
-
|
|
182
|
-
(_menuElementRef$curre = menuElementRef.current) === null || _menuElementRef$curre === void 0 || _menuElementRef$curre.focus();
|
|
178
|
+
menuElementRef.current?.focus();
|
|
183
179
|
}, []);
|
|
184
180
|
const environment = applicationShellConnectors.useApplicationContext(context => context.environment);
|
|
185
181
|
const applicationsAppBarMenu = useApplicationsMenu.useApplicationsMenu('appBar', {
|
|
186
182
|
environment
|
|
187
183
|
});
|
|
188
|
-
const accountMenuItems = applicationsAppBarMenu
|
|
184
|
+
const accountMenuItems = applicationsAppBarMenu ?? [];
|
|
189
185
|
return jsxRuntime.jsx("div", {
|
|
190
186
|
onKeyDown: event => {
|
|
191
187
|
if (event.key === 'Esc' || event.key === 'Tab' && !getIsFocusedElementInMenu()) {
|
|
@@ -217,30 +213,27 @@ const UserSettingsMenuBody = props => {
|
|
|
217
213
|
})
|
|
218
214
|
}), accountMenuItems.length > 0 ? jsxRuntime.jsx(MenuItem, {
|
|
219
215
|
hasDivider: true
|
|
220
|
-
}) : null, _mapInstanceProperty__default["default"](accountMenuItems).call(accountMenuItems, menu => {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
children: jsxRuntime.jsx(Text__default["default"].Body, {
|
|
233
|
-
children: renderLabel(menu, props.language)
|
|
234
|
-
})
|
|
216
|
+
}) : null, _mapInstanceProperty__default["default"](accountMenuItems).call(accountMenuItems, menu => jsxRuntime.jsx(OptionalFeatureToggle, {
|
|
217
|
+
featureToggle: menu.featureToggle ?? undefined,
|
|
218
|
+
children: jsxRuntime.jsx(reactRouterDom.Link, {
|
|
219
|
+
css: getUserSettingsMenuItemLinkStyles(),
|
|
220
|
+
to: `/account/${menu.uriPath}`,
|
|
221
|
+
onClick: () => props.downshiftProps.toggleMenu(),
|
|
222
|
+
"data-user-settings-menu": true,
|
|
223
|
+
ref: menuElementRef,
|
|
224
|
+
children: jsxRuntime.jsx(MenuItem, {
|
|
225
|
+
children: jsxRuntime.jsx(MenuItemLabel, {
|
|
226
|
+
children: jsxRuntime.jsx(Text__default["default"].Body, {
|
|
227
|
+
children: renderLabel(menu, props.language)
|
|
235
228
|
})
|
|
236
229
|
})
|
|
237
230
|
})
|
|
238
|
-
}
|
|
239
|
-
}), jsxRuntime.jsx(MenuItem, {
|
|
231
|
+
})
|
|
232
|
+
}, menu.key)), jsxRuntime.jsx(MenuItem, {
|
|
240
233
|
hasDivider: true
|
|
241
234
|
}), jsxRuntime.jsx("a", {
|
|
242
235
|
css: getUserSettingsMenuItemLinkStyles(),
|
|
243
|
-
href:
|
|
236
|
+
href: `https://commercetools.com/privacy#suppliers`,
|
|
244
237
|
target: "_blank",
|
|
245
238
|
rel: "noopener noreferrer",
|
|
246
239
|
onClick: () => props.downshiftProps.toggleMenu(),
|
|
@@ -274,7 +267,7 @@ const UserSettingsMenuBody = props => {
|
|
|
274
267
|
// NOTE: we want to redirect to a new page so that the
|
|
275
268
|
// server can remove things like cookie for access token.
|
|
276
269
|
,
|
|
277
|
-
href:
|
|
270
|
+
href: `/logout?reason=${constants.LOGOUT_REASONS.USER}`,
|
|
278
271
|
"data-test": "logout-button",
|
|
279
272
|
"data-user-settings-menu": true,
|
|
280
273
|
children: [jsxRuntime.jsx(MenuItem, {
|
|
@@ -26,10 +26,9 @@ import Avatar from '@commercetools-uikit/avatar';
|
|
|
26
26
|
import { designTokens } from '@commercetools-uikit/design-system';
|
|
27
27
|
import Spacings from '@commercetools-uikit/spacings';
|
|
28
28
|
import Text from '@commercetools-uikit/text';
|
|
29
|
-
import { D as DIMENSIONS } from './oidc-
|
|
30
|
-
import { u as useApplicationsMenu } from './use-applications-menu-
|
|
29
|
+
import { D as DIMENSIONS } from './oidc-b2520905.esm.js';
|
|
30
|
+
import { u as useApplicationsMenu } from './use-applications-menu-bc2b9a66.esm.js';
|
|
31
31
|
import { jsx, jsxs, Fragment } from '@emotion/react/jsx-runtime';
|
|
32
|
-
import '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
33
32
|
import '@apollo/client';
|
|
34
33
|
import '@commercetools-frontend/l10n';
|
|
35
34
|
|
|
@@ -99,17 +98,15 @@ const UserAvatar = props => {
|
|
|
99
98
|
};
|
|
100
99
|
UserAvatar.displayName = 'UserAvatar';
|
|
101
100
|
function getIsFocusedElementInMenu() {
|
|
102
|
-
|
|
103
|
-
return Boolean((_document$activeEleme = document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.getAttribute('data-user-settings-menu'));
|
|
101
|
+
return Boolean(document.activeElement?.getAttribute('data-user-settings-menu'));
|
|
104
102
|
}
|
|
105
103
|
const stateReducer = (state, changes) => {
|
|
106
|
-
var _ref3;
|
|
107
104
|
switch (changes.type) {
|
|
108
105
|
// So in case the user wants to navigate with the tab button
|
|
109
106
|
// we need to make sure that the menu does not close
|
|
110
107
|
case Downshift.stateChangeTypes.blurButton:
|
|
111
108
|
return _objectSpread(_objectSpread({}, changes), {}, {
|
|
112
|
-
isOpen: (
|
|
109
|
+
isOpen: (state.isOpen && getIsFocusedElementInMenu()) ?? false
|
|
113
110
|
});
|
|
114
111
|
default:
|
|
115
112
|
return changes;
|
|
@@ -163,14 +160,13 @@ const UserSettingsMenuBody = props => {
|
|
|
163
160
|
// Focus on a menu item when it's opened through keyboard
|
|
164
161
|
const menuElementRef = useRef(null);
|
|
165
162
|
useEffect(() => {
|
|
166
|
-
|
|
167
|
-
(_menuElementRef$curre = menuElementRef.current) === null || _menuElementRef$curre === void 0 || _menuElementRef$curre.focus();
|
|
163
|
+
menuElementRef.current?.focus();
|
|
168
164
|
}, []);
|
|
169
165
|
const environment = useApplicationContext(context => context.environment);
|
|
170
166
|
const applicationsAppBarMenu = useApplicationsMenu('appBar', {
|
|
171
167
|
environment
|
|
172
168
|
});
|
|
173
|
-
const accountMenuItems = applicationsAppBarMenu
|
|
169
|
+
const accountMenuItems = applicationsAppBarMenu ?? [];
|
|
174
170
|
return jsx("div", {
|
|
175
171
|
onKeyDown: event => {
|
|
176
172
|
if (event.key === 'Esc' || event.key === 'Tab' && !getIsFocusedElementInMenu()) {
|
|
@@ -202,30 +198,27 @@ const UserSettingsMenuBody = props => {
|
|
|
202
198
|
})
|
|
203
199
|
}), accountMenuItems.length > 0 ? jsx(MenuItem, {
|
|
204
200
|
hasDivider: true
|
|
205
|
-
}) : null, _mapInstanceProperty(accountMenuItems).call(accountMenuItems, menu => {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
children: jsx(Text.Body, {
|
|
218
|
-
children: renderLabel(menu, props.language)
|
|
219
|
-
})
|
|
201
|
+
}) : null, _mapInstanceProperty(accountMenuItems).call(accountMenuItems, menu => jsx(OptionalFeatureToggle, {
|
|
202
|
+
featureToggle: menu.featureToggle ?? undefined,
|
|
203
|
+
children: jsx(Link, {
|
|
204
|
+
css: getUserSettingsMenuItemLinkStyles(),
|
|
205
|
+
to: `/account/${menu.uriPath}`,
|
|
206
|
+
onClick: () => props.downshiftProps.toggleMenu(),
|
|
207
|
+
"data-user-settings-menu": true,
|
|
208
|
+
ref: menuElementRef,
|
|
209
|
+
children: jsx(MenuItem, {
|
|
210
|
+
children: jsx(MenuItemLabel, {
|
|
211
|
+
children: jsx(Text.Body, {
|
|
212
|
+
children: renderLabel(menu, props.language)
|
|
220
213
|
})
|
|
221
214
|
})
|
|
222
215
|
})
|
|
223
|
-
}
|
|
224
|
-
}), jsx(MenuItem, {
|
|
216
|
+
})
|
|
217
|
+
}, menu.key)), jsx(MenuItem, {
|
|
225
218
|
hasDivider: true
|
|
226
219
|
}), jsx("a", {
|
|
227
220
|
css: getUserSettingsMenuItemLinkStyles(),
|
|
228
|
-
href:
|
|
221
|
+
href: `https://commercetools.com/privacy#suppliers`,
|
|
229
222
|
target: "_blank",
|
|
230
223
|
rel: "noopener noreferrer",
|
|
231
224
|
onClick: () => props.downshiftProps.toggleMenu(),
|
|
@@ -259,7 +252,7 @@ const UserSettingsMenuBody = props => {
|
|
|
259
252
|
// NOTE: we want to redirect to a new page so that the
|
|
260
253
|
// server can remove things like cookie for access token.
|
|
261
254
|
,
|
|
262
|
-
href:
|
|
255
|
+
href: `/logout?reason=${LOGOUT_REASONS.USER}`,
|
|
263
256
|
"data-test": "logout-button",
|
|
264
257
|
"data-user-settings-menu": true,
|
|
265
258
|
children: [jsx(MenuItem, {
|
package/dist/{user-settings-menu-c37b343f.cjs.dev.js → user-settings-menu-dc598434.cjs.dev.js}
RENAMED
|
@@ -28,10 +28,9 @@ var Avatar = require('@commercetools-uikit/avatar');
|
|
|
28
28
|
var designSystem = require('@commercetools-uikit/design-system');
|
|
29
29
|
var Spacings = require('@commercetools-uikit/spacings');
|
|
30
30
|
var Text = require('@commercetools-uikit/text');
|
|
31
|
-
var oidc = require('./oidc-
|
|
32
|
-
var useApplicationsMenu = require('./use-applications-menu-
|
|
31
|
+
var oidc = require('./oidc-8827f9fe.cjs.dev.js');
|
|
32
|
+
var useApplicationsMenu = require('./use-applications-menu-bd718ac8.cjs.dev.js');
|
|
33
33
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
34
|
-
require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
35
34
|
require('@apollo/client');
|
|
36
35
|
require('@commercetools-frontend/l10n');
|
|
37
36
|
|
|
@@ -122,17 +121,15 @@ const UserAvatar = props => {
|
|
|
122
121
|
};
|
|
123
122
|
UserAvatar.displayName = 'UserAvatar';
|
|
124
123
|
function getIsFocusedElementInMenu() {
|
|
125
|
-
|
|
126
|
-
return Boolean((_document$activeEleme = document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.getAttribute('data-user-settings-menu'));
|
|
124
|
+
return Boolean(document.activeElement?.getAttribute('data-user-settings-menu'));
|
|
127
125
|
}
|
|
128
126
|
const stateReducer = (state, changes) => {
|
|
129
|
-
var _ref3;
|
|
130
127
|
switch (changes.type) {
|
|
131
128
|
// So in case the user wants to navigate with the tab button
|
|
132
129
|
// we need to make sure that the menu does not close
|
|
133
130
|
case Downshift__default["default"].stateChangeTypes.blurButton:
|
|
134
131
|
return _objectSpread(_objectSpread({}, changes), {}, {
|
|
135
|
-
isOpen: (
|
|
132
|
+
isOpen: (state.isOpen && getIsFocusedElementInMenu()) ?? false
|
|
136
133
|
});
|
|
137
134
|
default:
|
|
138
135
|
return changes;
|
|
@@ -186,14 +183,13 @@ const UserSettingsMenuBody = props => {
|
|
|
186
183
|
// Focus on a menu item when it's opened through keyboard
|
|
187
184
|
const menuElementRef = react.useRef(null);
|
|
188
185
|
react.useEffect(() => {
|
|
189
|
-
|
|
190
|
-
(_menuElementRef$curre = menuElementRef.current) === null || _menuElementRef$curre === void 0 || _menuElementRef$curre.focus();
|
|
186
|
+
menuElementRef.current?.focus();
|
|
191
187
|
}, []);
|
|
192
188
|
const environment = applicationShellConnectors.useApplicationContext(context => context.environment);
|
|
193
189
|
const applicationsAppBarMenu = useApplicationsMenu.useApplicationsMenu('appBar', {
|
|
194
190
|
environment
|
|
195
191
|
});
|
|
196
|
-
const accountMenuItems = applicationsAppBarMenu
|
|
192
|
+
const accountMenuItems = applicationsAppBarMenu ?? [];
|
|
197
193
|
return jsxRuntime.jsx("div", {
|
|
198
194
|
onKeyDown: event => {
|
|
199
195
|
if (event.key === 'Esc' || event.key === 'Tab' && !getIsFocusedElementInMenu()) {
|
|
@@ -225,30 +221,27 @@ const UserSettingsMenuBody = props => {
|
|
|
225
221
|
})
|
|
226
222
|
}), accountMenuItems.length > 0 ? jsxRuntime.jsx(MenuItem, {
|
|
227
223
|
hasDivider: true
|
|
228
|
-
}) : null, _mapInstanceProperty__default["default"](accountMenuItems).call(accountMenuItems, menu => {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
children: jsxRuntime.jsx(Text__default["default"].Body, {
|
|
241
|
-
children: renderLabel(menu, props.language)
|
|
242
|
-
})
|
|
224
|
+
}) : null, _mapInstanceProperty__default["default"](accountMenuItems).call(accountMenuItems, menu => jsxRuntime.jsx(OptionalFeatureToggle, {
|
|
225
|
+
featureToggle: menu.featureToggle ?? undefined,
|
|
226
|
+
children: jsxRuntime.jsx(reactRouterDom.Link, {
|
|
227
|
+
css: getUserSettingsMenuItemLinkStyles(),
|
|
228
|
+
to: `/account/${menu.uriPath}`,
|
|
229
|
+
onClick: () => props.downshiftProps.toggleMenu(),
|
|
230
|
+
"data-user-settings-menu": true,
|
|
231
|
+
ref: menuElementRef,
|
|
232
|
+
children: jsxRuntime.jsx(MenuItem, {
|
|
233
|
+
children: jsxRuntime.jsx(MenuItemLabel, {
|
|
234
|
+
children: jsxRuntime.jsx(Text__default["default"].Body, {
|
|
235
|
+
children: renderLabel(menu, props.language)
|
|
243
236
|
})
|
|
244
237
|
})
|
|
245
238
|
})
|
|
246
|
-
}
|
|
247
|
-
}), jsxRuntime.jsx(MenuItem, {
|
|
239
|
+
})
|
|
240
|
+
}, menu.key)), jsxRuntime.jsx(MenuItem, {
|
|
248
241
|
hasDivider: true
|
|
249
242
|
}), jsxRuntime.jsx("a", {
|
|
250
243
|
css: getUserSettingsMenuItemLinkStyles(),
|
|
251
|
-
href:
|
|
244
|
+
href: `https://commercetools.com/privacy#suppliers`,
|
|
252
245
|
target: "_blank",
|
|
253
246
|
rel: "noopener noreferrer",
|
|
254
247
|
onClick: () => props.downshiftProps.toggleMenu(),
|
|
@@ -282,7 +275,7 @@ const UserSettingsMenuBody = props => {
|
|
|
282
275
|
// NOTE: we want to redirect to a new page so that the
|
|
283
276
|
// server can remove things like cookie for access token.
|
|
284
277
|
,
|
|
285
|
-
href:
|
|
278
|
+
href: `/logout?reason=${constants.LOGOUT_REASONS.USER}`,
|
|
286
279
|
"data-test": "logout-button",
|
|
287
280
|
"data-user-settings-menu": true,
|
|
288
281
|
children: [jsxRuntime.jsx(MenuItem, {
|