@commercetools-frontend/application-shell 21.23.10 → 21.24.1
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-47d5c548.cjs.dev.js +116 -0
- package/dist/application-entry-point-5619d5aa.cjs.prod.js +99 -0
- package/dist/application-entry-point-dc726674.esm.js +101 -0
- package/dist/{box-dd9e7e68.esm.js → box-4395623b.esm.js} +1 -3
- package/dist/{box-fdb2ccb6.cjs.dev.js → box-6b5be9a9.cjs.dev.js} +1 -3
- package/dist/{box-d849ea03.cjs.prod.js → box-8850277f.cjs.prod.js} +1 -3
- package/dist/{cart-ad0aba9b.cjs.prod.js → cart-0698b97d.cjs.prod.js} +1 -3
- package/dist/{cart-b92f3a8e.cjs.dev.js → cart-41f0b7bc.cjs.dev.js} +1 -3
- package/dist/{cart-167fea3b.esm.js → cart-a49faf67.esm.js} +1 -3
- package/dist/commercetools-frontend-application-shell.cjs.dev.js +49 -68
- package/dist/commercetools-frontend-application-shell.cjs.prod.js +49 -68
- package/dist/commercetools-frontend-application-shell.esm.js +39 -58
- package/dist/configure-apollo-942ef373.cjs.prod.js +922 -0
- package/dist/configure-apollo-a6f03ff8.cjs.dev.js +930 -0
- package/dist/configure-apollo-cc0b1668.esm.js +873 -0
- package/dist/{connected-square-4743b7de.esm.js → connected-square-3cac6bd7.esm.js} +1 -3
- package/dist/connected-square-47233754.cjs.dev.js +32 -0
- package/dist/connected-square-b2e25621.cjs.prod.js +32 -0
- package/dist/{constants-69249abd.esm.js → constants-7f04db3f.esm.js} +9 -9
- package/dist/{constants-88fb9ef8.cjs.prod.js → constants-e6409334.cjs.prod.js} +8 -8
- package/dist/{constants-c2d56f3d.cjs.dev.js → constants-e6f058e5.cjs.dev.js} +8 -8
- package/dist/declarations/src/apollo-links/utils.d.ts +2 -2
- package/dist/declarations/src/components/application-entry-point/application-entry-point.d.ts +4 -4
- package/dist/declarations/src/components/application-shell/application-shell.d.ts +7 -15
- package/dist/declarations/src/components/application-shell-authenticated/application-shell-authenticated.d.ts +21 -0
- package/dist/declarations/src/components/application-shell-provider/application-shell-provider.d.ts +6 -7
- package/dist/declarations/src/components/application-shell-provider/use-coerced-environment-values.d.ts +1 -23
- package/dist/declarations/src/components/authenticated/authenticated.d.ts +2 -2
- package/dist/declarations/src/components/authenticated/oidc-callback.async.d.ts +6 -0
- package/dist/declarations/src/components/authenticated/oidc-callback.d.ts +2 -2
- package/dist/declarations/src/components/configure-intl-provider/configure-intl-provider.d.ts +1 -1
- package/dist/declarations/src/components/error-apologizer/index.d.ts +6 -1
- package/dist/declarations/src/components/fetch-project/fetch-project.d.ts +4 -4
- package/dist/declarations/src/components/fetch-user/fetch-user.d.ts +3 -3
- package/dist/declarations/src/components/inject-reducers/inject-reducers.d.ts +1 -1
- package/dist/declarations/src/components/navbar/index.d.ts +100 -1
- package/dist/declarations/src/components/navbar/loading-navbar.d.ts +5 -0
- package/dist/declarations/src/components/navbar/menu-items.d.ts +99 -0
- package/dist/declarations/src/components/navbar/navbar.d.ts +6 -15
- package/dist/declarations/src/components/project-container/index.d.ts +78 -1
- package/dist/declarations/src/components/project-container/project-container.d.ts +6 -8
- package/dist/declarations/src/components/quick-access/butler-command/butler-command.d.ts +1 -1
- package/dist/declarations/src/components/quick-access/index.d.ts +2 -2
- package/dist/declarations/src/components/quick-access/types.d.ts +1 -1
- package/dist/declarations/src/components/redirect-to-login/index.d.ts +6 -0
- package/dist/declarations/src/components/redirect-to-logout/index.d.ts +5 -0
- package/dist/declarations/src/components/redirect-to-project-create/index.d.ts +6 -1
- package/dist/declarations/src/components/requests-in-flight-loader/index.d.ts +6 -1
- package/dist/declarations/src/components/route-catch-all/index.d.ts +3 -1
- package/dist/declarations/src/components/setup-flop-flip-provider/setup-flop-flip-provider.d.ts +3 -3
- package/dist/declarations/src/components/suspended-route/suspended-route.d.ts +1 -1
- package/dist/declarations/src/components/user-settings-menu/index.d.ts +12 -1
- package/dist/declarations/src/components/version-tracker/index.d.ts +6 -1
- package/dist/declarations/src/hooks/apollo-hooks/apollo-hooks.d.ts +1 -1
- package/dist/declarations/src/test-utils/test-utils.d.ts +2 -2
- package/dist/declarations/src/types/generated/mc.d.ts +3 -3
- package/dist/declarations/src/utils/get-mc-origin/get-mc-origin.d.ts +2 -0
- package/dist/declarations/src/utils/get-mc-origin/index.d.ts +1 -0
- package/dist/error-apologizer-c336db61.cjs.dev.js +56 -0
- package/dist/error-apologizer-c55ec6f7.cjs.prod.js +56 -0
- package/dist/error-apologizer-f8772b68.esm.js +42 -0
- package/dist/gear-2890f7fb.cjs.prod.js +32 -0
- package/dist/{gear-8418cd46.esm.js → gear-300dd24c.esm.js} +1 -3
- package/dist/gear-e8014c5a.cjs.dev.js +32 -0
- package/dist/get-mc-origin-314b77a2.cjs.dev.js +57 -0
- package/dist/get-mc-origin-5df60933.esm.js +50 -0
- package/dist/get-mc-origin-7968e04f.cjs.prod.js +57 -0
- package/dist/heart-000a023d.cjs.prod.js +32 -0
- package/dist/{heart-48c28091.esm.js → heart-dded66b4.esm.js} +1 -3
- package/dist/heart-f21b7d39.cjs.dev.js +32 -0
- package/dist/index-3765c4c9.cjs.prod.js +2870 -0
- package/dist/index-3fdf5681.esm.js +2970 -0
- package/dist/index-b9b8b690.cjs.dev.js +3054 -0
- package/dist/{list-with-search-c154a56e.esm.js → list-with-search-a3302710.esm.js} +1 -3
- package/dist/list-with-search-a5b72b33.cjs.prod.js +32 -0
- package/dist/list-with-search-ee796e9e.cjs.dev.js +32 -0
- package/dist/navbar-08a76df9.cjs.dev.js +670 -0
- package/dist/navbar-5384b0c3.esm.js +650 -0
- package/dist/navbar-c02843fb.cjs.prod.js +649 -0
- package/dist/oidc-0638d0c8.cjs.dev.js +67 -0
- package/dist/oidc-10fa96f0.esm.js +59 -0
- package/dist/oidc-540a091a.cjs.prod.js +67 -0
- package/dist/oidc-callback-152dc622.esm.js +240 -0
- package/dist/oidc-callback-784c3a39.cjs.prod.js +251 -0
- package/dist/oidc-callback-dc8682c0.cjs.dev.js +254 -0
- package/dist/paperclip-23d1e69c.cjs.prod.js +32 -0
- package/dist/{paperclip-18785dda.esm.js → paperclip-a61112e8.esm.js} +1 -3
- package/dist/paperclip-d653c134.cjs.dev.js +32 -0
- package/dist/plugin-0ee6aee4.cjs.dev.js +32 -0
- package/dist/{plugin-53c047bb.esm.js → plugin-3d353a5b.esm.js} +1 -3
- package/dist/plugin-7e57f237.cjs.prod.js +32 -0
- package/dist/project-container-6f0ea904.cjs.dev.js +387 -0
- package/dist/project-container-b6b2f6b2.esm.js +368 -0
- package/dist/project-container-bf8678e2.cjs.prod.js +369 -0
- package/dist/{project-expired-d8eaa253.esm.js → project-expired-6b9b6feb.esm.js} +47 -68
- package/dist/{project-expired-adce523b.cjs.dev.js → project-expired-9d71c314.cjs.dev.js} +47 -68
- package/dist/{project-expired-576a8329.cjs.prod.js → project-expired-d75d9e84.cjs.prod.js} +47 -68
- package/dist/{project-not-found-9a9753f2.cjs.dev.js → project-not-found-4b5b9479.cjs.prod.js} +42 -61
- package/dist/{project-not-found-8208c8f1.esm.js → project-not-found-c4634d60.esm.js} +42 -61
- package/dist/{project-not-found-daa5200b.cjs.prod.js → project-not-found-c977dbb0.cjs.dev.js} +42 -61
- package/dist/{project-not-initialized-4aeafe19.cjs.dev.js → project-not-initialized-4d0badf3.cjs.prod.js} +47 -68
- package/dist/{project-not-initialized-3408e87f.esm.js → project-not-initialized-a2f7b46e.esm.js} +47 -68
- package/dist/{project-not-initialized-5b416bcf.cjs.prod.js → project-not-initialized-e1533577.cjs.dev.js} +47 -68
- package/dist/{project-suspended-d3a6001d.cjs.dev.js → project-suspended-9027fc60.cjs.prod.js} +44 -63
- package/dist/{project-suspended-dc9ace34.cjs.prod.js → project-suspended-9e084c21.cjs.dev.js} +44 -63
- package/dist/{project-suspended-a7edc962.esm.js → project-suspended-f3d78447.esm.js} +44 -63
- package/dist/{quick-access-f42a8e0a.cjs.prod.js → quick-access-517ad7e1.cjs.prod.js} +573 -957
- package/dist/quick-access-82e1c9aa.esm.js +1907 -0
- package/dist/quick-access-8b2b678f.cjs.dev.js +1937 -0
- package/dist/redirect-to-login-1b892ab5.esm.js +147 -0
- package/dist/redirect-to-login-2be0e5db.cjs.prod.js +149 -0
- package/dist/redirect-to-login-64230f67.cjs.dev.js +149 -0
- package/dist/redirect-to-logout-15810ffb.cjs.dev.js +151 -0
- package/dist/redirect-to-logout-17e4ba2c.cjs.prod.js +151 -0
- package/dist/redirect-to-logout-80e772d1.esm.js +138 -0
- package/dist/redirect-to-project-create-048efa71.cjs.prod.js +61 -0
- package/dist/redirect-to-project-create-052f293e.esm.js +52 -0
- package/dist/redirect-to-project-create-f0e7b35e.cjs.dev.js +61 -0
- package/dist/{gear-28ff4f04.cjs.dev.js → redirector-0d98f9df.cjs.dev.js} +44 -5
- package/dist/redirector-47a6be71.esm.js +58 -0
- package/dist/{gear-6f8c30e3.cjs.prod.js → redirector-77ce2f5c.cjs.prod.js} +44 -5
- package/dist/requests-in-flight-loader-5329586b.esm.js +129 -0
- package/dist/requests-in-flight-loader-88f14402.cjs.dev.js +144 -0
- package/dist/requests-in-flight-loader-a7bc4e12.cjs.prod.js +144 -0
- package/dist/rocket-3e3f0a98.cjs.prod.js +32 -0
- package/dist/{rocket-ba116b5e.esm.js → rocket-4b088727.esm.js} +1 -3
- package/dist/rocket-95b6858d.cjs.dev.js +32 -0
- package/dist/route-catch-all-01cf0095.esm.js +41 -0
- package/dist/route-catch-all-3b490df1.cjs.prod.js +43 -0
- package/dist/route-catch-all-9ac99936.cjs.dev.js +43 -0
- package/dist/{service-page-project-switcher-49afafeb.cjs.prod.js → service-page-project-switcher-39dcfee8.cjs.prod.js} +5 -7
- package/dist/{service-page-project-switcher-866b2139.cjs.dev.js → service-page-project-switcher-7698339b.cjs.dev.js} +6 -8
- package/dist/{service-page-project-switcher-365c4c10.esm.js → service-page-project-switcher-fd30959b.esm.js} +6 -8
- package/dist/{speedometer-c1b94505.esm.js → speedometer-08a11d5a.esm.js} +1 -3
- package/dist/speedometer-2881cef6.cjs.prod.js +32 -0
- package/dist/speedometer-54f872f2.cjs.dev.js +32 -0
- package/dist/{star-da9123e0.esm.js → star-15244db1.esm.js} +1 -3
- package/dist/star-52bf7a64.cjs.dev.js +32 -0
- package/dist/star-f8502efb.cjs.prod.js +32 -0
- package/dist/tag-multi-1d1553b6.cjs.dev.js +32 -0
- package/dist/{tag-multi-c650b738.esm.js → tag-multi-3be995ac.esm.js} +1 -3
- package/dist/tag-multi-f9acb1c2.cjs.prod.js +32 -0
- package/dist/tree-structure-4650688d.cjs.dev.js +32 -0
- package/dist/{tree-structure-6af6fc3a.esm.js → tree-structure-c8753526.esm.js} +1 -3
- package/dist/tree-structure-f24ee3f6.cjs.prod.js +32 -0
- package/dist/use-applications-menu-4abb5796.esm.js +172 -0
- package/dist/use-applications-menu-68d83733.cjs.dev.js +188 -0
- package/dist/use-applications-menu-6b872b83.cjs.prod.js +188 -0
- package/dist/use-is-served-by-proxy-2b4916e5.cjs.dev.js +42 -0
- package/dist/use-is-served-by-proxy-499bfa16.esm.js +39 -0
- package/dist/use-is-served-by-proxy-51e76976.cjs.prod.js +42 -0
- package/dist/{user-filled-41729d77.esm.js → user-filled-2dc4e79e.esm.js} +1 -3
- package/dist/user-filled-2e6cb25e.cjs.dev.js +32 -0
- package/dist/user-filled-815b49a0.cjs.prod.js +32 -0
- package/dist/user-settings-menu-79d4cb1e.cjs.dev.js +523 -0
- package/dist/user-settings-menu-7bf6f146.cjs.prod.js +496 -0
- package/dist/user-settings-menu-ad7c27f0.esm.js +497 -0
- package/dist/version-tracker-20bb239d.esm.js +101 -0
- package/dist/version-tracker-69607d15.cjs.dev.js +107 -0
- package/dist/version-tracker-80e0f8f6.cjs.prod.js +107 -0
- package/dist/world-973090a5.cjs.dev.js +32 -0
- package/dist/{world-d91df1ee.esm.js → world-c5ea311a.esm.js} +1 -3
- package/dist/world-e1f9dbf8.cjs.prod.js +32 -0
- package/package.json +27 -27
- package/ssr/dist/commercetools-frontend-application-shell-ssr.cjs.dev.js +2 -3
- package/ssr/dist/commercetools-frontend-application-shell-ssr.cjs.prod.js +2 -3
- package/ssr/dist/commercetools-frontend-application-shell-ssr.esm.js +2 -3
- package/test-utils/dist/commercetools-frontend-application-shell-test-utils.cjs.dev.js +182 -215
- package/test-utils/dist/commercetools-frontend-application-shell-test-utils.cjs.prod.js +182 -215
- package/test-utils/dist/commercetools-frontend-application-shell-test-utils.esm.js +173 -206
- package/dist/application-entry-point-307baa50.cjs.prod.js +0 -1225
- package/dist/application-entry-point-3e14d46d.cjs.dev.js +0 -1250
- package/dist/application-entry-point-8d923438.esm.js +0 -1180
- package/dist/connected-square-abf36852.cjs.prod.js +0 -34
- package/dist/connected-square-ac52014f.cjs.dev.js +0 -34
- package/dist/declarations/src/components/application-shell/helpers.d.ts +0 -1
- package/dist/heart-33cd94c6.cjs.prod.js +0 -34
- package/dist/heart-fb31cf30.cjs.dev.js +0 -34
- package/dist/index-284fb405.esm.js +0 -4809
- package/dist/index-37414a3f.cjs.prod.js +0 -4643
- package/dist/index-ea32a85e.cjs.dev.js +0 -4888
- package/dist/list-with-search-34cd926c.cjs.dev.js +0 -34
- package/dist/list-with-search-a0b22169.cjs.prod.js +0 -34
- package/dist/oidc-1c91f5ee.cjs.prod.js +0 -67
- package/dist/oidc-5b2e4f8f.cjs.dev.js +0 -67
- package/dist/oidc-77749f1b.esm.js +0 -59
- package/dist/paperclip-2cd45b86.cjs.dev.js +0 -34
- package/dist/paperclip-b1b806ab.cjs.prod.js +0 -34
- package/dist/plugin-7cb7827e.cjs.dev.js +0 -34
- package/dist/plugin-e97ae3e6.cjs.prod.js +0 -34
- package/dist/quick-access-457a9f41.esm.js +0 -2290
- package/dist/quick-access-d553524e.cjs.dev.js +0 -2321
- package/dist/rocket-37c1aa11.cjs.dev.js +0 -34
- package/dist/rocket-b2dbda7f.cjs.prod.js +0 -34
- package/dist/speedometer-13b393fb.cjs.dev.js +0 -34
- package/dist/speedometer-1e69fd13.cjs.prod.js +0 -34
- package/dist/star-ab4be629.cjs.prod.js +0 -34
- package/dist/star-e165111e.cjs.dev.js +0 -34
- package/dist/tag-multi-5f498a7d.cjs.dev.js +0 -34
- package/dist/tag-multi-fb817131.cjs.prod.js +0 -34
- package/dist/tree-structure-779fcc36.cjs.prod.js +0 -34
- package/dist/tree-structure-ed6cdff8.cjs.dev.js +0 -34
- package/dist/user-filled-384a2eaf.cjs.prod.js +0 -34
- package/dist/user-filled-53d2eae0.cjs.dev.js +0 -34
- package/dist/world-12528632.cjs.prod.js +0 -34
- package/dist/world-6471d9f6.cjs.dev.js +0 -34
- /package/dist/declarations/src/components/{application-shell → redirect-to-login}/redirect-to-login.d.ts +0 -0
- /package/dist/declarations/src/components/{application-shell → redirect-to-logout}/redirect-to-logout.d.ts +0 -0
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
|
|
4
3
|
var _taggedTemplateLiteral = require('@babel/runtime-corejs3/helpers/taggedTemplateLiteral');
|
|
5
|
-
var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
|
|
6
4
|
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
7
5
|
require('prop-types');
|
|
8
|
-
var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
9
6
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
10
7
|
var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
|
|
11
8
|
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
@@ -14,17 +11,17 @@ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/in
|
|
|
14
11
|
var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
|
|
15
12
|
var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
|
|
16
13
|
var react$1 = require('react');
|
|
17
|
-
var reactIntl = require('react-intl');
|
|
18
|
-
var reactBroadcast = require('@flopflip/react-broadcast');
|
|
19
14
|
var react$2 = require('@apollo/client/react');
|
|
20
|
-
var
|
|
21
|
-
var sdk = require('@commercetools-frontend/sdk');
|
|
15
|
+
var reactBroadcast = require('@flopflip/react-broadcast');
|
|
22
16
|
var commonTags = require('common-tags');
|
|
23
17
|
var debounce = require('debounce-async');
|
|
18
|
+
var reactIntl = require('react-intl');
|
|
19
|
+
var reactRouterDom = require('react-router-dom');
|
|
20
|
+
var applicationShellConnectors = require('@commercetools-frontend/application-shell-connectors');
|
|
24
21
|
var constants = require('@commercetools-frontend/constants');
|
|
25
22
|
var permissions$1 = require('@commercetools-frontend/permissions');
|
|
26
|
-
var
|
|
27
|
-
var
|
|
23
|
+
var sdk = require('@commercetools-frontend/sdk');
|
|
24
|
+
var useIsServedByProxy = require('./use-is-served-by-proxy-51e76976.cjs.prod.js');
|
|
28
25
|
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
29
26
|
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
30
27
|
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
@@ -36,37 +33,33 @@ var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/i
|
|
|
36
33
|
var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
|
|
37
34
|
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
38
35
|
var _findIndexInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find-index');
|
|
36
|
+
var react = require('@emotion/react');
|
|
39
37
|
var Fuse = require('fuse.js');
|
|
40
38
|
var last = require('lodash/last');
|
|
41
|
-
var react = require('@emotion/react');
|
|
42
|
-
var LoadingSpinner = require('@commercetools-uikit/loading-spinner');
|
|
43
|
-
var icons = require('@commercetools-uikit/icons');
|
|
44
39
|
var designSystem = require('@commercetools-uikit/design-system');
|
|
40
|
+
var icons = require('@commercetools-uikit/icons');
|
|
41
|
+
var LoadingSpinner = require('@commercetools-uikit/loading-spinner');
|
|
45
42
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
46
|
-
var dist_commercetoolsFrontendApplicationShell = require('./index-
|
|
43
|
+
var dist_commercetoolsFrontendApplicationShell = require('./index-3765c4c9.cjs.prod.js');
|
|
47
44
|
var _Promise = require('@babel/runtime-corejs3/core-js-stable/promise');
|
|
48
45
|
var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
49
46
|
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
47
|
+
require('./configure-apollo-942ef373.cjs.prod.js');
|
|
50
48
|
require('@babel/runtime-corejs3/core-js-stable/object/entries');
|
|
51
49
|
require('@babel/runtime-corejs3/core-js-stable/reflect/has');
|
|
52
|
-
require('lodash/mapValues');
|
|
53
50
|
require('@reduxjs/toolkit');
|
|
54
|
-
require('
|
|
51
|
+
require('lodash/mapValues');
|
|
55
52
|
require('omit-empty-es');
|
|
53
|
+
require('redux-thunk');
|
|
56
54
|
require('@commercetools-frontend/notifications');
|
|
57
|
-
require('./constants-88fb9ef8.cjs.prod.js');
|
|
58
|
-
require('@commercetools-frontend/react-notifications');
|
|
59
|
-
require('redux-logger');
|
|
60
|
-
require('react-dom');
|
|
61
|
-
require('react-redux');
|
|
62
55
|
require('@babel/runtime-corejs3/core-js-stable/instance/index-of');
|
|
63
56
|
require('@commercetools-frontend/sentry');
|
|
57
|
+
require('./constants-e6409334.cjs.prod.js');
|
|
58
|
+
require('@commercetools-frontend/react-notifications');
|
|
59
|
+
require('redux-logger');
|
|
64
60
|
require('@babel/runtime-corejs3/core-js-stable/url');
|
|
65
61
|
require('@apollo/client');
|
|
66
62
|
require('apollo-link-logger');
|
|
67
|
-
require('@babel/runtime-corejs3/core-js-stable/array/from');
|
|
68
|
-
require('@babel/runtime-corejs3/core-js-stable/symbol');
|
|
69
|
-
require('@babel/runtime-corejs3/core-js/get-iterator-method');
|
|
70
63
|
require('@apollo/client/link/error');
|
|
71
64
|
require('@commercetools-frontend/browser-history');
|
|
72
65
|
require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
@@ -82,53 +75,41 @@ require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
|
|
|
82
75
|
require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
83
76
|
require('@babel/runtime-corejs3/helpers/wrapNativeSuper');
|
|
84
77
|
require('@apollo/client/link/retry');
|
|
85
|
-
require('tiny-invariant');
|
|
86
|
-
require('@commercetools-frontend/application-components');
|
|
87
|
-
require('@commercetools-frontend/application-config/ssr');
|
|
88
78
|
require('@emotion/styled/base');
|
|
79
|
+
require('@commercetools-frontend/application-components');
|
|
89
80
|
require('@commercetools-frontend/i18n');
|
|
90
|
-
require('
|
|
91
|
-
require('@babel/runtime-corejs3/core-js-stable/instance/reverse');
|
|
92
|
-
require('lodash/camelCase');
|
|
93
|
-
require('./oidc-1c91f5ee.cjs.prod.js');
|
|
94
|
-
require('qss');
|
|
95
|
-
require('jwt-decode');
|
|
96
|
-
require('@commercetools-frontend/assets/images/locked-diamond.svg');
|
|
97
|
-
require('@commercetools-uikit/notifications');
|
|
81
|
+
require('@commercetools-frontend/assets/images/logo.svg');
|
|
98
82
|
require('@commercetools-uikit/spacings');
|
|
99
|
-
require('@commercetools-uikit/constraints');
|
|
100
|
-
require('@commercetools-uikit/card');
|
|
101
|
-
require('@commercetools-uikit/text');
|
|
102
83
|
require('@commercetools-uikit/flat-button');
|
|
103
|
-
require('lodash/upperFirst');
|
|
104
|
-
require('@commercetools-frontend/assets/images/ct-logo.svg');
|
|
105
|
-
require('@commercetools-frontend/assets/images/icecream.svg');
|
|
106
|
-
require('@commercetools-frontend/l10n');
|
|
107
|
-
require('@commercetools-frontend/assets/images/logo.svg');
|
|
108
|
-
require('downshift');
|
|
109
|
-
require('@commercetools-uikit/avatar');
|
|
110
|
-
require('@commercetools-uikit/accessible-hidden');
|
|
111
84
|
require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
112
85
|
require('memoize-one');
|
|
86
|
+
require('@commercetools-uikit/accessible-hidden');
|
|
113
87
|
require('@commercetools-uikit/select-input');
|
|
88
|
+
require('@commercetools-frontend/assets/images/ct-logo.svg');
|
|
89
|
+
require('@commercetools-frontend/l10n');
|
|
90
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/reverse');
|
|
91
|
+
require('lodash/camelCase');
|
|
92
|
+
require('@babel/runtime-corejs3/core-js-stable/array/from');
|
|
93
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/every');
|
|
94
|
+
require('classnames');
|
|
95
|
+
require('@commercetools-frontend/assets/images/diagonal-line.svg');
|
|
96
|
+
require('@commercetools-uikit/icons/inline-svg');
|
|
114
97
|
require('lodash/isNil');
|
|
115
98
|
require('@babel/runtime-corejs3/core-js-stable/object/from-entries');
|
|
116
99
|
require('@babel/runtime-corejs3/core-js-stable/instance/flags');
|
|
117
|
-
require('@flopflip/launchdarkly-adapter');
|
|
118
|
-
require('@flopflip/http-adapter');
|
|
119
100
|
require('@flopflip/combine-adapters');
|
|
120
|
-
require('@
|
|
121
|
-
require('
|
|
122
|
-
require('
|
|
123
|
-
require('
|
|
124
|
-
require('lodash/
|
|
125
|
-
require('
|
|
101
|
+
require('@flopflip/http-adapter');
|
|
102
|
+
require('@flopflip/launchdarkly-adapter');
|
|
103
|
+
require('perfume.js');
|
|
104
|
+
require('react-redux');
|
|
105
|
+
require('lodash/upperFirst');
|
|
106
|
+
require('./oidc-540a091a.cjs.prod.js');
|
|
126
107
|
require('@commercetools-uikit/design-system/materials/resets.css');
|
|
127
108
|
require('@commercetools-frontend/actions-global');
|
|
109
|
+
require('@commercetools-frontend/application-config/ssr');
|
|
128
110
|
|
|
129
111
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
130
112
|
|
|
131
|
-
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefault(_regeneratorRuntime);
|
|
132
113
|
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
133
114
|
var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
|
|
134
115
|
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
@@ -164,7 +145,7 @@ var _ref2 = {
|
|
|
164
145
|
styles: "flex:1 auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis"
|
|
165
146
|
} ;
|
|
166
147
|
|
|
167
|
-
|
|
148
|
+
const ButlerCommand = props => {
|
|
168
149
|
var _context;
|
|
169
150
|
|
|
170
151
|
return jsxRuntime.jsxs("div", {
|
|
@@ -442,17 +423,13 @@ var _templateObject$3, _templateObject2$2;
|
|
|
442
423
|
|
|
443
424
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
444
425
|
|
|
445
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
|
426
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context12, _context13; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context12 = ownKeys(Object(source), !0)).call(_context12, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context13 = ownKeys(Object(source))).call(_context13, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
446
427
|
|
|
447
|
-
|
|
448
|
-
return event.key === 'a' && event.metaKey && !event.ctrlKey && !event.altKey && !event.shiftKey;
|
|
449
|
-
};
|
|
428
|
+
const isSelectAllCombo = event => event.key === 'a' && event.metaKey && !event.ctrlKey && !event.altKey && !event.shiftKey;
|
|
450
429
|
|
|
451
|
-
|
|
452
|
-
return event.key === 'Escape' && !event.metaKey && !event.ctrlKey && !event.altKey && !event.shiftKey;
|
|
453
|
-
};
|
|
430
|
+
const isCloseCombo = event => event.key === 'Escape' && !event.metaKey && !event.ctrlKey && !event.altKey && !event.shiftKey;
|
|
454
431
|
|
|
455
|
-
|
|
432
|
+
const getPlatform = () => {
|
|
456
433
|
var _context, _context2, _context3, _context4;
|
|
457
434
|
|
|
458
435
|
if (_includesInstanceProperty__default["default"](_context = navigator.appVersion).call(_context, 'Win')) return 'windows';
|
|
@@ -462,8 +439,8 @@ var getPlatform = function getPlatform() {
|
|
|
462
439
|
return null;
|
|
463
440
|
};
|
|
464
441
|
|
|
465
|
-
|
|
466
|
-
|
|
442
|
+
const hasNewWindowModifier = event => {
|
|
443
|
+
const platform = getPlatform();
|
|
467
444
|
|
|
468
445
|
switch (platform) {
|
|
469
446
|
case 'macos':
|
|
@@ -474,8 +451,8 @@ var hasNewWindowModifier = function hasNewWindowModifier(event) {
|
|
|
474
451
|
}
|
|
475
452
|
};
|
|
476
453
|
|
|
477
|
-
|
|
478
|
-
|
|
454
|
+
const shakeAnimation = react.keyframes(_templateObject$3 || (_templateObject$3 = _taggedTemplateLiteral(["\n from,\n to {\n transform: translate3d(0, 0, 0);\n }\n\n 14%,\n 42%,\n 70% {\n transform: translate3d(-3px, 0, 0);\n }\n\n 28%,\n 56%,\n 84% {\n transform: translate3d(3px, 0, 0);\n }\n"])));
|
|
455
|
+
const initialState = {
|
|
479
456
|
hasNetworkError: false,
|
|
480
457
|
isLoading: false,
|
|
481
458
|
searchText: '',
|
|
@@ -486,11 +463,11 @@ var initialState = {
|
|
|
486
463
|
stack: []
|
|
487
464
|
};
|
|
488
465
|
|
|
489
|
-
|
|
490
|
-
var _context5
|
|
466
|
+
const reducer = function () {
|
|
467
|
+
var _context5;
|
|
491
468
|
|
|
492
|
-
|
|
493
|
-
|
|
469
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
|
|
470
|
+
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
494
471
|
|
|
495
472
|
switch (action.type) {
|
|
496
473
|
case 'networkError':
|
|
@@ -532,11 +509,11 @@ var reducer = function reducer() {
|
|
|
532
509
|
|
|
533
510
|
case 'setNextCommands':
|
|
534
511
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
535
|
-
stack:
|
|
512
|
+
stack: [...state.stack, {
|
|
536
513
|
searchText: state.searchText,
|
|
537
514
|
results: state.results,
|
|
538
515
|
selectedResult: state.selectedResult
|
|
539
|
-
}]
|
|
516
|
+
}],
|
|
540
517
|
selectedResult: 0,
|
|
541
518
|
enableHistory: false,
|
|
542
519
|
results: action.payload.results
|
|
@@ -549,7 +526,7 @@ var reducer = function reducer() {
|
|
|
549
526
|
selectedResult: 0,
|
|
550
527
|
enableHistory: false,
|
|
551
528
|
// omit last item
|
|
552
|
-
stack: _sliceInstanceProperty__default["default"](
|
|
529
|
+
stack: _sliceInstanceProperty__default["default"](_context5 = state.stack).call(_context5, 0, -1)
|
|
553
530
|
});
|
|
554
531
|
|
|
555
532
|
case 'searchText':
|
|
@@ -594,50 +571,50 @@ var _ref = {
|
|
|
594
571
|
styles: "display:flex"
|
|
595
572
|
} ;
|
|
596
573
|
|
|
597
|
-
|
|
598
|
-
|
|
574
|
+
const Butler = props => {
|
|
575
|
+
const intl = reactIntl.useIntl();
|
|
599
576
|
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
577
|
+
const _useReducer = react$1.useReducer(reducer, initialState),
|
|
578
|
+
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
579
|
+
state = _useReducer2[0],
|
|
580
|
+
dispatch = _useReducer2[1];
|
|
604
581
|
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
582
|
+
const shouldSelectFieldText = react$1.useRef(false);
|
|
583
|
+
const isNewWindowCombo = react$1.useRef(false);
|
|
584
|
+
const skipNextSelection = react$1.useRef(false);
|
|
585
|
+
const searchContainerRef = react$1.useRef(null);
|
|
586
|
+
const searchInputRef = react$1.useRef(null);
|
|
587
|
+
const setHasNetworkError = react$1.useCallback(() => {
|
|
611
588
|
dispatch({
|
|
612
589
|
type: 'networkError',
|
|
613
590
|
payload: true
|
|
614
591
|
});
|
|
615
592
|
}, []);
|
|
616
|
-
|
|
593
|
+
const unsetHasNetworkError = react$1.useCallback(() => {
|
|
617
594
|
dispatch({
|
|
618
595
|
type: 'networkError',
|
|
619
596
|
payload: false
|
|
620
597
|
});
|
|
621
598
|
}, []);
|
|
622
|
-
|
|
599
|
+
const setIsLoading = react$1.useCallback(() => {
|
|
623
600
|
dispatch({
|
|
624
601
|
type: 'loading',
|
|
625
602
|
payload: true
|
|
626
603
|
});
|
|
627
604
|
}, []);
|
|
628
|
-
|
|
605
|
+
const unsetIsLoading = react$1.useCallback(() => {
|
|
629
606
|
dispatch({
|
|
630
607
|
type: 'loading',
|
|
631
608
|
payload: false
|
|
632
609
|
});
|
|
633
610
|
}, []); // Destructure functions from props to reference them in the hook dependency list
|
|
634
611
|
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
612
|
+
const searchFromParent = props.search,
|
|
613
|
+
onCloseFromParent = props.onClose,
|
|
614
|
+
executeCommandFromParent = props.executeCommand,
|
|
615
|
+
onHistoryEntriesChangeFromParent = props.onHistoryEntriesChange,
|
|
616
|
+
getNextCommandsFromParent = props.getNextCommands;
|
|
617
|
+
const shake = react$1.useCallback(() => {
|
|
641
618
|
if (searchContainerRef.current) {
|
|
642
619
|
searchContainerRef.current.classList.remove(props.classNameShakeAnimation); // -> triggering reflow
|
|
643
620
|
// eslint-disable-next-line no-void
|
|
@@ -646,15 +623,15 @@ var Butler = function Butler(props) {
|
|
|
646
623
|
searchContainerRef.current.classList.add(props.classNameShakeAnimation);
|
|
647
624
|
}
|
|
648
625
|
}, [props.classNameShakeAnimation]);
|
|
649
|
-
|
|
650
|
-
var
|
|
626
|
+
const execute = react$1.useCallback((command, meta) => {
|
|
627
|
+
var _context6;
|
|
651
628
|
|
|
652
629
|
// Only main entries get added to history, so when a subcommand is executed,
|
|
653
630
|
// we add the main command of it to the history (the top-level command).
|
|
654
631
|
//
|
|
655
632
|
// The key to identify history entries by is always the searchText
|
|
656
633
|
// There will never be two history entries with the same searchText
|
|
657
|
-
|
|
634
|
+
const entry = state.stack.length === 0 ? // The stack is empty, so we are executing a top-level command
|
|
658
635
|
{
|
|
659
636
|
searchText: state.searchText,
|
|
660
637
|
results: state.results
|
|
@@ -668,16 +645,14 @@ var Butler = function Butler(props) {
|
|
|
668
645
|
// top of the history (with the most recent results), or appends a new entry
|
|
669
646
|
// when it didn't exist before.
|
|
670
647
|
|
|
671
|
-
onHistoryEntriesChangeFromParent(
|
|
672
|
-
return command.searchText !== entry.searchText;
|
|
673
|
-
})), [entry]));
|
|
648
|
+
onHistoryEntriesChangeFromParent([..._filterInstanceProperty__default["default"](_context6 = props.historyEntries).call(_context6, command => command.searchText !== entry.searchText), entry]);
|
|
674
649
|
dispatch({
|
|
675
650
|
type: 'resetSearchText'
|
|
676
651
|
});
|
|
677
652
|
onCloseFromParent();
|
|
678
653
|
executeCommandFromParent(command, meta);
|
|
679
654
|
}, [executeCommandFromParent, onCloseFromParent, onHistoryEntriesChangeFromParent, props.historyEntries, state.results, state.searchText, state.stack]);
|
|
680
|
-
|
|
655
|
+
const handleKeyDown = react$1.useCallback(event => {
|
|
681
656
|
// Preventing cursor jumps can only happen in onKeyDown, but not in onKeyUp
|
|
682
657
|
event.persist(); // We want to know when the user presses cmd+enter (cmd being a meta key).
|
|
683
658
|
// We are only told about this in keyDown, but not in keyUp, so we need
|
|
@@ -727,16 +702,14 @@ var Butler = function Butler(props) {
|
|
|
727
702
|
if (event.key === 'ArrowUp') {
|
|
728
703
|
// browse through history
|
|
729
704
|
if (state.searchText.length === 0 || state.selectedResult < 1 && state.enableHistory) {
|
|
730
|
-
var
|
|
705
|
+
var _context7;
|
|
731
706
|
|
|
732
707
|
shouldSelectFieldText.current = true;
|
|
733
|
-
|
|
708
|
+
const selectedIndex = state.searchText.length === 0 ? // When going back the first step
|
|
734
709
|
-1 : // When going back more than one step
|
|
735
|
-
_findIndexInstanceProperty__default["default"](
|
|
736
|
-
return command.searchText === state.searchText;
|
|
737
|
-
}); // Pick the previous command from the history
|
|
710
|
+
_findIndexInstanceProperty__default["default"](_context7 = props.historyEntries).call(_context7, command => command.searchText === state.searchText); // Pick the previous command from the history
|
|
738
711
|
|
|
739
|
-
|
|
712
|
+
const prevCommand = selectedIndex === -1 ? // previous command on top of the history when going back on
|
|
740
713
|
// first step
|
|
741
714
|
last__default["default"](props.historyEntries) : // previous command is deeper down
|
|
742
715
|
// When the history does not exist (negative index), then
|
|
@@ -764,89 +737,65 @@ var Butler = function Butler(props) {
|
|
|
764
737
|
|
|
765
738
|
if (state.selectedResult > -1) {
|
|
766
739
|
if (event.key === 'ArrowRight') {
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
740
|
+
const command = state.results[state.selectedResult];
|
|
741
|
+
const searchText = state.searchText;
|
|
742
|
+
const isCursorAtEnd = searchInputRef.current && state.searchText.length === searchInputRef.current.selectionStart;
|
|
743
|
+
const isEverythingSelected = searchInputRef.current && searchInputRef.current.selectionStart === 0 && state.searchText.length === searchInputRef.current.selectionEnd; // only allow diving in when cursor is at end of input or when
|
|
771
744
|
// the complete text is selected (when browsing through history)
|
|
772
745
|
|
|
773
746
|
if (!isCursorAtEnd && !isEverythingSelected) return;
|
|
774
747
|
unsetHasNetworkError(); // NOTE: since we need to fetch the "next command", which is an async operation,
|
|
775
748
|
// we use a IIFE to process that and eventually update the state.
|
|
776
749
|
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
case 3:
|
|
792
|
-
nextCommands = _context10.sent;
|
|
793
|
-
|
|
794
|
-
if (!(nextCommands.length > 0)) {
|
|
795
|
-
_context10.next = 7;
|
|
796
|
-
break;
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
// Ensure the search text has not changed while we were loading
|
|
800
|
-
// the next results, otherwise we'd interrupt the user.
|
|
801
|
-
// Throw away the results in case the search text has changed.
|
|
802
|
-
if (state.searchText === _searchText) {
|
|
803
|
-
dispatch({
|
|
804
|
-
type: 'setNextCommands',
|
|
805
|
-
payload: {
|
|
806
|
-
results: nextCommands
|
|
807
|
-
}
|
|
808
|
-
});
|
|
750
|
+
(async () => {
|
|
751
|
+
if (command) {
|
|
752
|
+
const nextCommands = await getNextCommandsFromParent(command); // avoid moving cursor when there are sub-options
|
|
753
|
+
|
|
754
|
+
if (nextCommands.length > 0) {
|
|
755
|
+
// Ensure the search text has not changed while we were loading
|
|
756
|
+
// the next results, otherwise we'd interrupt the user.
|
|
757
|
+
// Throw away the results in case the search text has changed.
|
|
758
|
+
if (state.searchText === searchText) {
|
|
759
|
+
dispatch({
|
|
760
|
+
type: 'setNextCommands',
|
|
761
|
+
payload: {
|
|
762
|
+
results: nextCommands
|
|
809
763
|
}
|
|
810
|
-
|
|
811
|
-
return _context10.abrupt("return");
|
|
812
|
-
|
|
813
|
-
case 7:
|
|
814
|
-
shake();
|
|
815
|
-
|
|
816
|
-
case 8:
|
|
817
|
-
case "end":
|
|
818
|
-
return _context10.stop();
|
|
764
|
+
});
|
|
819
765
|
}
|
|
766
|
+
|
|
767
|
+
return;
|
|
820
768
|
}
|
|
821
|
-
}
|
|
822
|
-
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
shake();
|
|
772
|
+
})();
|
|
823
773
|
|
|
824
774
|
return;
|
|
825
775
|
}
|
|
826
776
|
|
|
827
777
|
if (event.key === 'ArrowLeft') {
|
|
828
778
|
// go left in stack
|
|
829
|
-
|
|
830
|
-
|
|
779
|
+
const prevCommand = last__default["default"](state.stack); // do nothing when we can't go left anymore
|
|
831
780
|
|
|
832
|
-
if (!
|
|
781
|
+
if (!prevCommand) return; // prevent cursor from jumping a char to the left in text input
|
|
833
782
|
|
|
834
783
|
event.preventDefault();
|
|
835
784
|
dispatch({
|
|
836
785
|
type: 'setPrevCommands',
|
|
837
786
|
payload: {
|
|
838
|
-
searchText:
|
|
839
|
-
results:
|
|
787
|
+
searchText: prevCommand.searchText,
|
|
788
|
+
results: prevCommand.results
|
|
840
789
|
}
|
|
841
790
|
});
|
|
842
791
|
return;
|
|
843
792
|
}
|
|
844
793
|
}
|
|
845
794
|
}, [getNextCommandsFromParent, props.historyEntries, shake, state, unsetHasNetworkError]);
|
|
846
|
-
|
|
795
|
+
const handleKeyUp = react$1.useCallback(event => {
|
|
847
796
|
// setting the selection can only happen in onKeyUp
|
|
848
797
|
if (shouldSelectFieldText.current) {
|
|
849
|
-
|
|
798
|
+
const input = event.target;
|
|
850
799
|
input.focus();
|
|
851
800
|
input.select();
|
|
852
801
|
shouldSelectFieldText.current = false;
|
|
@@ -862,8 +811,8 @@ var Butler = function Butler(props) {
|
|
|
862
811
|
isNewWindowCombo.current = false;
|
|
863
812
|
return true;
|
|
864
813
|
}, [execute, state.results, state.selectedResult]);
|
|
865
|
-
|
|
866
|
-
|
|
814
|
+
const handleChange = react$1.useCallback(event => {
|
|
815
|
+
const searchText = event.target.value;
|
|
867
816
|
|
|
868
817
|
if (_trimInstanceProperty__default["default"](searchText).call(searchText).length === 0) {
|
|
869
818
|
dispatch({
|
|
@@ -883,12 +832,12 @@ var Butler = function Butler(props) {
|
|
|
883
832
|
setIsLoading();
|
|
884
833
|
}
|
|
885
834
|
|
|
886
|
-
searchFromParent(searchText).then(
|
|
887
|
-
var
|
|
835
|
+
searchFromParent(searchText).then(asyncResults => {
|
|
836
|
+
var _context8, _context9;
|
|
888
837
|
|
|
889
838
|
unsetHasNetworkError();
|
|
890
839
|
unsetIsLoading();
|
|
891
|
-
|
|
840
|
+
const fuse = new Fuse__default["default"](asyncResults, {
|
|
892
841
|
keys: [{
|
|
893
842
|
name: 'text',
|
|
894
843
|
weight: 0.6
|
|
@@ -900,56 +849,48 @@ var Butler = function Butler(props) {
|
|
|
900
849
|
includeScore: true
|
|
901
850
|
});
|
|
902
851
|
|
|
903
|
-
|
|
904
|
-
).call(
|
|
905
|
-
|
|
906
|
-
}) // Keep a maximal of 9 results
|
|
907
|
-
).call(_context11, 0, 9);
|
|
852
|
+
const searchResults = _sliceInstanceProperty__default["default"](_context8 = _filterInstanceProperty__default["default"](_context9 = fuse.search(searchText) // Filter out results with a matching score over 0.75
|
|
853
|
+
).call(_context9, result => result.score ? result.score < 0.75 : false) // Keep a maximal of 9 results
|
|
854
|
+
).call(_context8, 0, 9);
|
|
908
855
|
|
|
909
856
|
dispatch({
|
|
910
857
|
type: 'setSearchTextResults',
|
|
911
|
-
payload: _mapInstanceProperty__default["default"](searchResults).call(searchResults,
|
|
912
|
-
return result.item;
|
|
913
|
-
})
|
|
858
|
+
payload: _mapInstanceProperty__default["default"](searchResults).call(searchResults, result => result.item)
|
|
914
859
|
});
|
|
915
|
-
},
|
|
860
|
+
}, error => {
|
|
916
861
|
unsetIsLoading();
|
|
917
862
|
setHasNetworkError();
|
|
918
863
|
});
|
|
919
864
|
}, [searchFromParent, setHasNetworkError, setIsLoading, unsetHasNetworkError, unsetIsLoading]);
|
|
920
|
-
|
|
865
|
+
const handleContainerClick = react$1.useCallback(() => {
|
|
921
866
|
dispatch({
|
|
922
867
|
type: 'resetResultsWhenClosing'
|
|
923
868
|
});
|
|
924
869
|
onCloseFromParent();
|
|
925
870
|
}, [onCloseFromParent]);
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
} // sets the selected result, mainly for the hover effect
|
|
871
|
+
const createCommandMouseEnterHandler = react$1.useCallback(index => () => {
|
|
872
|
+
// In case the cursor happened to be in a location where a
|
|
873
|
+
// result would appear, it would trigger onMouseEnter and the
|
|
874
|
+
// result would be selected immediately. This is not something
|
|
875
|
+
// a user would expect, hence we prevent it from happening.
|
|
876
|
+
// The user has to move the cursor to an option explicitly for
|
|
877
|
+
// it to become active. However, the user can always click and
|
|
878
|
+
// that action will be triggered.
|
|
879
|
+
if (skipNextSelection.current) {
|
|
880
|
+
skipNextSelection.current = false;
|
|
881
|
+
return;
|
|
882
|
+
} // sets the selected result, mainly for the hover effect
|
|
939
883
|
|
|
940
884
|
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
};
|
|
885
|
+
dispatch({
|
|
886
|
+
type: 'selectedResult',
|
|
887
|
+
payload: index
|
|
888
|
+
});
|
|
946
889
|
}, []);
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
});
|
|
952
|
-
};
|
|
890
|
+
const createCommandClickHandler = react$1.useCallback(command => event => {
|
|
891
|
+
execute(command, {
|
|
892
|
+
openInNewTab: hasNewWindowModifier(event)
|
|
893
|
+
});
|
|
953
894
|
}, [execute]);
|
|
954
895
|
return jsxRuntime.jsx(dist_commercetoolsFrontendApplicationShell.ButlerContainer, {
|
|
955
896
|
onClick: handleContainerClick,
|
|
@@ -958,7 +899,7 @@ var Butler = function Butler(props) {
|
|
|
958
899
|
children: jsxRuntime.jsxs("div", {
|
|
959
900
|
ref: searchContainerRef,
|
|
960
901
|
css: /*#__PURE__*/react.css("background-color:", designSystem.customProperties.colorSurface, ";border:0;border-radius:", designSystem.customProperties.borderRadius4, ";min-height:40px;z-index:20002;width:400px;margin:40px auto;overflow:hidden;-webkit-box-shadow:0 10px 30px -8px rgba(0, 0, 0, 0.75);-moz-box-shadow:0 10px 30px -8px rgba(0, 0, 0, 0.75);box-shadow:0 10px 30px -8px rgba(0, 0, 0, 0.75);padding-bottom:", state.hasNetworkError ? '0' : designSystem.customProperties.spacingS, ";" + ("" ), "" ),
|
|
961
|
-
onClick:
|
|
902
|
+
onClick: event => {
|
|
962
903
|
// Avoid closing when the searchContainer itself is clicked
|
|
963
904
|
// If we don't do this, then the overlay will close when e.g.
|
|
964
905
|
// the search input is clicked.
|
|
@@ -990,26 +931,24 @@ var Butler = function Butler(props) {
|
|
|
990
931
|
css: /*#__PURE__*/react.css("align-self:center;margin-top:", designSystem.customProperties.spacingS, ";margin-right:", designSystem.customProperties.spacingS, ";" + ("" ), "" ),
|
|
991
932
|
children: jsxRuntime.jsx(LoadingSpinner__default["default"], {})
|
|
992
933
|
})]
|
|
993
|
-
}),
|
|
994
|
-
var
|
|
934
|
+
}), (() => {
|
|
935
|
+
var _context10, _context11;
|
|
995
936
|
|
|
996
937
|
if (state.hasNetworkError) return jsxRuntime.jsx("div", {
|
|
997
938
|
css: /*#__PURE__*/react.css("overflow:hidden;white-space:nowrap;cursor:default;background:", designSystem.customProperties.colorError, ";text-align:center;text-transform:uppercase;color:", designSystem.customProperties.colorSurface, ";font-size:", designSystem.customProperties.fontSizeSmall, ";padding:", designSystem.customProperties.spacingXs, ";" + ("" ), "" ),
|
|
998
939
|
children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread({}, messages.offline))
|
|
999
940
|
});
|
|
1000
|
-
if (state.results.length === 0 && _trimInstanceProperty__default["default"](
|
|
941
|
+
if (state.results.length === 0 && _trimInstanceProperty__default["default"](_context10 = state.searchText).call(_context10).length > 0) return jsxRuntime.jsx("div", {
|
|
1001
942
|
css: /*#__PURE__*/react.css("overflow:hidden;white-space:nowrap;cursor:default;background:", designSystem.customProperties.colorNeutral, ";color:", designSystem.customProperties.colorSolid, ";text-align:center;text-transform:uppercase;font-size:", designSystem.customProperties.fontSizeSmall, ";padding:", designSystem.customProperties.spacingXs, ";" + ("" ), "" ),
|
|
1002
943
|
children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread({}, messages.noResults))
|
|
1003
944
|
});
|
|
1004
|
-
return _mapInstanceProperty__default["default"](
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
});
|
|
1012
|
-
}()]
|
|
945
|
+
return _mapInstanceProperty__default["default"](_context11 = state.results).call(_context11, (command, index) => jsxRuntime.jsx(ButlerCommand, {
|
|
946
|
+
command: command,
|
|
947
|
+
isSelected: state.selectedResult === index,
|
|
948
|
+
onMouseEnter: createCommandMouseEnterHandler(index),
|
|
949
|
+
onClick: createCommandClickHandler(command)
|
|
950
|
+
}, command.id));
|
|
951
|
+
})()]
|
|
1013
952
|
})
|
|
1014
953
|
});
|
|
1015
954
|
};
|
|
@@ -1017,19 +956,17 @@ var Butler = function Butler(props) {
|
|
|
1017
956
|
Butler.propTypes = {};
|
|
1018
957
|
Butler.displayName = 'Butler';
|
|
1019
958
|
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
});
|
|
1029
|
-
};
|
|
959
|
+
const ButlerWithAnimation = props => jsxRuntime.jsx(react.ClassNames, {
|
|
960
|
+
children: _ref2 => {
|
|
961
|
+
let css = _ref2.css;
|
|
962
|
+
return jsxRuntime.jsx(Butler, _objectSpread(_objectSpread({}, props), {}, {
|
|
963
|
+
classNameShakeAnimation: css(_templateObject2$2 || (_templateObject2$2 = _taggedTemplateLiteral(["\n animation-duration: 0.45s;\n animation-fill-mode: both;\n animation-name: ", ";\n "])), shakeAnimation)
|
|
964
|
+
}));
|
|
965
|
+
}
|
|
966
|
+
});
|
|
1030
967
|
|
|
1031
968
|
// eslint-disable-next-line import/prefer-default-export
|
|
1032
|
-
|
|
969
|
+
const permissions = {
|
|
1033
970
|
ViewOrders: 'ViewOrders',
|
|
1034
971
|
ManageOrders: 'ManageOrders',
|
|
1035
972
|
ViewProducts: 'ViewProducts',
|
|
@@ -1054,7 +991,7 @@ var permissions = {
|
|
|
1054
991
|
ManageProductTypes: 'ManageProductTypes'
|
|
1055
992
|
};
|
|
1056
993
|
|
|
1057
|
-
|
|
994
|
+
const actionTypes = {
|
|
1058
995
|
go: 'go'
|
|
1059
996
|
};
|
|
1060
997
|
|
|
@@ -1064,14 +1001,14 @@ function nonNullable(value) {
|
|
|
1064
1001
|
return value !== null && value !== undefined && typeof value !== 'boolean';
|
|
1065
1002
|
}
|
|
1066
1003
|
|
|
1067
|
-
|
|
1068
|
-
var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context10,
|
|
1004
|
+
const createCommands = _ref => {
|
|
1005
|
+
var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context10, _context13;
|
|
1069
1006
|
|
|
1070
|
-
|
|
1007
|
+
let intl = _ref.intl,
|
|
1071
1008
|
applicationContext = _ref.applicationContext,
|
|
1072
1009
|
featureToggles = _ref.featureToggles,
|
|
1073
1010
|
changeProjectDataLocale = _ref.changeProjectDataLocale;
|
|
1074
|
-
return _filterInstanceProperty__default["default"](_context =
|
|
1011
|
+
return _filterInstanceProperty__default["default"](_context = [applicationContext.project && applicationContext.permissions && featureToggles.canViewDashboard && permissions$1.hasSomePermissions([permissions.ViewOrders], applicationContext.permissions) && {
|
|
1075
1012
|
id: 'go/dashboard',
|
|
1076
1013
|
text: intl.formatMessage(messages.openDashboard),
|
|
1077
1014
|
keywords: ['Go to Dashboard'],
|
|
@@ -1087,7 +1024,7 @@ var createCommands = function createCommands(_ref) {
|
|
|
1087
1024
|
type: actionTypes.go,
|
|
1088
1025
|
to: "/".concat(applicationContext.project.key, "/products")
|
|
1089
1026
|
},
|
|
1090
|
-
subCommands: _filterInstanceProperty__default["default"](
|
|
1027
|
+
subCommands: _filterInstanceProperty__default["default"](_context2 = [permissions$1.hasSomePermissions([permissions.ViewProducts], applicationContext.permissions) && {
|
|
1091
1028
|
id: 'go/products/list',
|
|
1092
1029
|
text: intl.formatMessage(messages.openProductList),
|
|
1093
1030
|
action: {
|
|
@@ -1115,7 +1052,7 @@ var createCommands = function createCommands(_ref) {
|
|
|
1115
1052
|
type: actionTypes.go,
|
|
1116
1053
|
to: "/".concat(applicationContext.project.key, "/products/new")
|
|
1117
1054
|
}
|
|
1118
|
-
}]).call(
|
|
1055
|
+
}]).call(_context2, nonNullable)
|
|
1119
1056
|
}, applicationContext.project && applicationContext.permissions && permissions$1.hasSomePermissions([permissions.ViewCategories], applicationContext.permissions) && {
|
|
1120
1057
|
id: 'go/categories',
|
|
1121
1058
|
text: intl.formatMessage(messages.openCategories),
|
|
@@ -1124,7 +1061,7 @@ var createCommands = function createCommands(_ref) {
|
|
|
1124
1061
|
type: actionTypes.go,
|
|
1125
1062
|
to: "/".concat(applicationContext.project.key, "/categories")
|
|
1126
1063
|
},
|
|
1127
|
-
subCommands: _filterInstanceProperty__default["default"](
|
|
1064
|
+
subCommands: _filterInstanceProperty__default["default"](_context3 = [permissions$1.hasSomePermissions([permissions.ViewCategories], applicationContext.permissions) && {
|
|
1128
1065
|
id: 'go/categories/list',
|
|
1129
1066
|
text: intl.formatMessage(messages.openCategoriesList),
|
|
1130
1067
|
action: {
|
|
@@ -1145,7 +1082,7 @@ var createCommands = function createCommands(_ref) {
|
|
|
1145
1082
|
type: actionTypes.go,
|
|
1146
1083
|
to: "/".concat(applicationContext.project.key, "/categories/new")
|
|
1147
1084
|
}
|
|
1148
|
-
}]).call(
|
|
1085
|
+
}]).call(_context3, nonNullable)
|
|
1149
1086
|
}, applicationContext.project && applicationContext.permissions && permissions$1.hasSomePermissions([permissions.ViewCustomers, permissions.ViewCustomerGroups], applicationContext.permissions) && {
|
|
1150
1087
|
id: 'go/customers',
|
|
1151
1088
|
text: intl.formatMessage(messages.openCustomers),
|
|
@@ -1154,7 +1091,7 @@ var createCommands = function createCommands(_ref) {
|
|
|
1154
1091
|
type: actionTypes.go,
|
|
1155
1092
|
to: "/".concat(applicationContext.project.key, "/customers")
|
|
1156
1093
|
},
|
|
1157
|
-
subCommands: _filterInstanceProperty__default["default"](
|
|
1094
|
+
subCommands: _filterInstanceProperty__default["default"](_context4 = [permissions$1.hasSomePermissions([permissions.ViewCustomers], applicationContext.permissions) && {
|
|
1158
1095
|
id: 'go/customers/list',
|
|
1159
1096
|
text: intl.formatMessage(messages.openCustomersList),
|
|
1160
1097
|
action: {
|
|
@@ -1182,7 +1119,7 @@ var createCommands = function createCommands(_ref) {
|
|
|
1182
1119
|
type: actionTypes.go,
|
|
1183
1120
|
to: "/".concat(applicationContext.project.key, "/customers/customer-groups/new")
|
|
1184
1121
|
}
|
|
1185
|
-
}]).call(
|
|
1122
|
+
}]).call(_context4, nonNullable)
|
|
1186
1123
|
}, applicationContext.project && applicationContext.permissions && permissions$1.hasSomePermissions([permissions.ViewOrders], applicationContext.permissions) && {
|
|
1187
1124
|
id: 'go/orders',
|
|
1188
1125
|
text: intl.formatMessage(messages.openOrders),
|
|
@@ -1191,7 +1128,7 @@ var createCommands = function createCommands(_ref) {
|
|
|
1191
1128
|
type: actionTypes.go,
|
|
1192
1129
|
to: "/".concat(applicationContext.project.key, "/orders")
|
|
1193
1130
|
},
|
|
1194
|
-
subCommands: _filterInstanceProperty__default["default"](
|
|
1131
|
+
subCommands: _filterInstanceProperty__default["default"](_context5 = [permissions$1.hasSomePermissions([permissions.ViewOrders], applicationContext.permissions) && {
|
|
1195
1132
|
id: 'go/orders/list',
|
|
1196
1133
|
text: intl.formatMessage(messages.openOrdersList),
|
|
1197
1134
|
action: {
|
|
@@ -1205,7 +1142,7 @@ var createCommands = function createCommands(_ref) {
|
|
|
1205
1142
|
type: actionTypes.go,
|
|
1206
1143
|
to: "/".concat(applicationContext.project.key, "/orders/new")
|
|
1207
1144
|
}
|
|
1208
|
-
}]).call(
|
|
1145
|
+
}]).call(_context5, nonNullable)
|
|
1209
1146
|
}, applicationContext.project && applicationContext.permissions && permissions$1.hasSomePermissions([permissions.ViewDiscountCodes, permissions.ViewProductDiscounts, permissions.ViewCartDiscounts], applicationContext.permissions) && {
|
|
1210
1147
|
id: 'go/discounts',
|
|
1211
1148
|
text: intl.formatMessage(messages.openDiscounts),
|
|
@@ -1214,7 +1151,7 @@ var createCommands = function createCommands(_ref) {
|
|
|
1214
1151
|
type: actionTypes.go,
|
|
1215
1152
|
to: "/".concat(applicationContext.project.key, "/discounts")
|
|
1216
1153
|
},
|
|
1217
|
-
subCommands: _filterInstanceProperty__default["default"](
|
|
1154
|
+
subCommands: _filterInstanceProperty__default["default"](_context6 = [permissions$1.hasSomePermissions([permissions.ViewProductDiscounts], applicationContext.permissions) && {
|
|
1218
1155
|
id: 'go/discounts/products/list',
|
|
1219
1156
|
text: intl.formatMessage(messages.openProductDiscountsList),
|
|
1220
1157
|
action: {
|
|
@@ -1242,7 +1179,7 @@ var createCommands = function createCommands(_ref) {
|
|
|
1242
1179
|
type: actionTypes.go,
|
|
1243
1180
|
to: "/".concat(applicationContext.project.key, "/discounts/new")
|
|
1244
1181
|
},
|
|
1245
|
-
subCommands: _filterInstanceProperty__default["default"](
|
|
1182
|
+
subCommands: _filterInstanceProperty__default["default"](_context7 = [permissions$1.hasSomePermissions([permissions.ManageProductDiscounts], applicationContext.permissions) && {
|
|
1246
1183
|
id: 'go/discounts/product/add',
|
|
1247
1184
|
text: intl.formatMessage(messages.openAddProductDiscount),
|
|
1248
1185
|
action: {
|
|
@@ -1263,8 +1200,8 @@ var createCommands = function createCommands(_ref) {
|
|
|
1263
1200
|
type: actionTypes.go,
|
|
1264
1201
|
to: "/".concat(applicationContext.project.key, "/discounts/codes/new")
|
|
1265
1202
|
}
|
|
1266
|
-
}]).call(
|
|
1267
|
-
}]).call(
|
|
1203
|
+
}]).call(_context7, nonNullable)
|
|
1204
|
+
}]).call(_context6, nonNullable)
|
|
1268
1205
|
}, applicationContext.project && applicationContext.permissions && permissions$1.hasSomePermissions([permissions.ViewProjectSettings, permissions.ViewDeveloperSettings, permissions.ViewProductTypes], applicationContext.permissions) && {
|
|
1269
1206
|
id: 'go/settings',
|
|
1270
1207
|
text: intl.formatMessage(messages.openSettings),
|
|
@@ -1273,14 +1210,14 @@ var createCommands = function createCommands(_ref) {
|
|
|
1273
1210
|
type: actionTypes.go,
|
|
1274
1211
|
to: "/".concat(applicationContext.project.key, "/settings/project")
|
|
1275
1212
|
},
|
|
1276
|
-
subCommands: _filterInstanceProperty__default["default"](
|
|
1213
|
+
subCommands: _filterInstanceProperty__default["default"](_context8 = [permissions$1.hasSomePermissions([permissions.ViewProjectSettings, permissions.ManageProjectSettings], applicationContext.permissions) && {
|
|
1277
1214
|
id: 'go/settings/project',
|
|
1278
1215
|
text: intl.formatMessage(messages.openProjectSettings),
|
|
1279
1216
|
action: {
|
|
1280
1217
|
type: actionTypes.go,
|
|
1281
1218
|
to: "/".concat(applicationContext.project.key, "/settings/project")
|
|
1282
1219
|
},
|
|
1283
|
-
subCommands: _filterInstanceProperty__default["default"](
|
|
1220
|
+
subCommands: _filterInstanceProperty__default["default"](_context9 = [{
|
|
1284
1221
|
id: 'go/settings/project/international',
|
|
1285
1222
|
text: intl.formatMessage(messages.openProjectSettingsInternationalTab),
|
|
1286
1223
|
action: {
|
|
@@ -1315,7 +1252,7 @@ var createCommands = function createCommands(_ref) {
|
|
|
1315
1252
|
type: actionTypes.go,
|
|
1316
1253
|
to: "/".concat(applicationContext.project.key, "/settings/project/stores")
|
|
1317
1254
|
}
|
|
1318
|
-
}]).call(
|
|
1255
|
+
}]).call(_context9, nonNullable)
|
|
1319
1256
|
}, permissions$1.hasSomePermissions([permissions.ViewProductTypes], applicationContext.permissions) && {
|
|
1320
1257
|
id: 'go/settings/product-types',
|
|
1321
1258
|
text: intl.formatMessage(messages.openProductTypesSettings),
|
|
@@ -1330,7 +1267,7 @@ var createCommands = function createCommands(_ref) {
|
|
|
1330
1267
|
type: actionTypes.go,
|
|
1331
1268
|
to: "/".concat(applicationContext.project.key, "/settings/developer")
|
|
1332
1269
|
},
|
|
1333
|
-
subCommands: _filterInstanceProperty__default["default"](
|
|
1270
|
+
subCommands: _filterInstanceProperty__default["default"](_context10 = [permissions$1.hasSomePermissions([permissions.ViewDeveloperSettings], applicationContext.permissions) && {
|
|
1334
1271
|
id: 'go/settings/developer/api-clients/list',
|
|
1335
1272
|
text: intl.formatMessage(messages.openApiClientsList),
|
|
1336
1273
|
action: {
|
|
@@ -1344,7 +1281,7 @@ var createCommands = function createCommands(_ref) {
|
|
|
1344
1281
|
type: actionTypes.go,
|
|
1345
1282
|
to: "/".concat(applicationContext.project.key, "/settings/developer/api-clients/new")
|
|
1346
1283
|
}
|
|
1347
|
-
}]).call(
|
|
1284
|
+
}]).call(_context10, nonNullable)
|
|
1348
1285
|
}, featureToggles.customApplications && permissions$1.hasSomePermissions([permissions.ManageProjectSettings], applicationContext.permissions) && {
|
|
1349
1286
|
id: 'go/settings/custom-applications',
|
|
1350
1287
|
text: intl.formatMessage(messages.openCustomApplicationsSettings),
|
|
@@ -1352,34 +1289,30 @@ var createCommands = function createCommands(_ref) {
|
|
|
1352
1289
|
type: actionTypes.go,
|
|
1353
1290
|
to: "/".concat(applicationContext.project.key, "/settings/custom-applications")
|
|
1354
1291
|
}
|
|
1355
|
-
}]).call(
|
|
1292
|
+
}]).call(_context8, nonNullable)
|
|
1356
1293
|
}, applicationContext.project && applicationContext.project.languages && applicationContext.project.languages.length > 1 && {
|
|
1357
1294
|
id: 'action/set-resource-language',
|
|
1358
1295
|
text: intl.formatMessage(messages.setResourceLanguage),
|
|
1359
1296
|
keywords: ['set resource locale', 'set project data language', 'set project data locale'],
|
|
1360
|
-
action:
|
|
1361
|
-
return void 0;
|
|
1362
|
-
},
|
|
1297
|
+
action: () => void 0,
|
|
1363
1298
|
// We would know these statically, but we define them here as we don't
|
|
1364
1299
|
// want to include them in the top-level search results
|
|
1365
|
-
subCommands:
|
|
1366
|
-
var
|
|
1367
|
-
|
|
1368
|
-
return _Promise__default["default"].resolve(_filterInstanceProperty__default["default"](
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
};
|
|
1382
|
-
})).call(_context12, nonNullable));
|
|
1300
|
+
subCommands: () => {
|
|
1301
|
+
var _context11, _context12;
|
|
1302
|
+
|
|
1303
|
+
return _Promise__default["default"].resolve(_filterInstanceProperty__default["default"](_context11 = _mapInstanceProperty__default["default"](_context12 = applicationContext.project ? applicationContext.project.languages : []).call(_context12, language => changeProjectDataLocale && {
|
|
1304
|
+
id: "action/set-resource-language/".concat(language),
|
|
1305
|
+
text: commonTags.oneLineTrim(_templateObject$2 || (_templateObject$2 = _taggedTemplateLiteral(["\n ", "\n ", "\n "])), language, language === applicationContext.dataLocale ? ' (active)' : ''),
|
|
1306
|
+
action: () => {
|
|
1307
|
+
changeProjectDataLocale(language); // We reload, since ProjectDataLocale is written in a way where
|
|
1308
|
+
// only the tree under the parent container reloads, but
|
|
1309
|
+
// not all of them reload.
|
|
1310
|
+
// So this action would seem like it had not effect, unless we
|
|
1311
|
+
// reload
|
|
1312
|
+
|
|
1313
|
+
useIsServedByProxy.location.reload();
|
|
1314
|
+
}
|
|
1315
|
+
})).call(_context11, nonNullable));
|
|
1383
1316
|
}
|
|
1384
1317
|
}, {
|
|
1385
1318
|
id: 'go/support',
|
|
@@ -1429,157 +1362,48 @@ var createCommands = function createCommands(_ref) {
|
|
|
1429
1362
|
type: actionTypes.go,
|
|
1430
1363
|
to: "/account/organizations"
|
|
1431
1364
|
}
|
|
1432
|
-
}
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
};
|
|
1445
|
-
}) : []))).call(_context, nonNullable);
|
|
1365
|
+
}, ...(applicationContext.user ? _mapInstanceProperty__default["default"](_context13 = applicationContext.user.projects.results).call(_context13, userProject => ({
|
|
1366
|
+
id: "go/project(".concat(userProject.key, ")"),
|
|
1367
|
+
text: intl.formatMessage(messages.useProject, {
|
|
1368
|
+
projectName: userProject.name
|
|
1369
|
+
}),
|
|
1370
|
+
keywords: [userProject.key],
|
|
1371
|
+
action: () => {
|
|
1372
|
+
// Switching projects needs a full redirect so that
|
|
1373
|
+
// the feature flags are reloaded (and things caches get destroyed)
|
|
1374
|
+
window.location.href = "/".concat(userProject.key);
|
|
1375
|
+
}
|
|
1376
|
+
})) : [])]).call(_context, nonNullable);
|
|
1446
1377
|
};
|
|
1447
1378
|
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1379
|
+
const STORAGE_KEY = 'quickAccessHistoryEntries';
|
|
1380
|
+
const saveHistoryEntries = historyEntries => {
|
|
1381
|
+
try {
|
|
1382
|
+
window.sessionStorage.setItem(STORAGE_KEY, _JSON$stringify__default["default"](historyEntries));
|
|
1383
|
+
return true;
|
|
1384
|
+
} catch (error) {
|
|
1385
|
+
return false;
|
|
1386
|
+
}
|
|
1452
1387
|
};
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
case 0:
|
|
1461
|
-
_flatten = function _flatten3() {
|
|
1462
|
-
_flatten = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(commands) {
|
|
1463
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context5) {
|
|
1464
|
-
while (1) {
|
|
1465
|
-
switch (_context5.prev = _context5.next) {
|
|
1466
|
-
case 0:
|
|
1467
|
-
return _context5.abrupt("return", _reduceInstanceProperty__default["default"](commands).call(commands, /*#__PURE__*/function () {
|
|
1468
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(prevPromise, command) {
|
|
1469
|
-
var _context3;
|
|
1470
|
-
|
|
1471
|
-
var prevResults, _context2, _context, subCommands, _flattenSubCommands, flattenSubCommands;
|
|
1472
|
-
|
|
1473
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context4) {
|
|
1474
|
-
while (1) {
|
|
1475
|
-
switch (_context4.prev = _context4.next) {
|
|
1476
|
-
case 0:
|
|
1477
|
-
_context4.next = 2;
|
|
1478
|
-
return prevPromise;
|
|
1479
|
-
|
|
1480
|
-
case 2:
|
|
1481
|
-
prevResults = _context4.sent;
|
|
1482
|
-
|
|
1483
|
-
if (!command.subCommands) {
|
|
1484
|
-
_context4.next = 16;
|
|
1485
|
-
break;
|
|
1486
|
-
}
|
|
1487
|
-
|
|
1488
|
-
if (!(typeof command.subCommands === 'function')) {
|
|
1489
|
-
_context4.next = 12;
|
|
1490
|
-
break;
|
|
1491
|
-
}
|
|
1492
|
-
|
|
1493
|
-
_context4.next = 7;
|
|
1494
|
-
return command.subCommands(execQuery);
|
|
1495
|
-
|
|
1496
|
-
case 7:
|
|
1497
|
-
subCommands = _context4.sent;
|
|
1498
|
-
_context4.next = 10;
|
|
1499
|
-
return flatten(subCommands);
|
|
1500
|
-
|
|
1501
|
-
case 10:
|
|
1502
|
-
_flattenSubCommands = _context4.sent;
|
|
1503
|
-
return _context4.abrupt("return", _concatInstanceProperty__default["default"](_context = []).call(_context, _toConsumableArray(prevResults), [command], _toConsumableArray(_flattenSubCommands)));
|
|
1504
|
-
|
|
1505
|
-
case 12:
|
|
1506
|
-
_context4.next = 14;
|
|
1507
|
-
return flatten(command.subCommands);
|
|
1508
|
-
|
|
1509
|
-
case 14:
|
|
1510
|
-
flattenSubCommands = _context4.sent;
|
|
1511
|
-
return _context4.abrupt("return", _concatInstanceProperty__default["default"](_context2 = []).call(_context2, _toConsumableArray(prevResults), [command], _toConsumableArray(flattenSubCommands)));
|
|
1512
|
-
|
|
1513
|
-
case 16:
|
|
1514
|
-
return _context4.abrupt("return", _concatInstanceProperty__default["default"](_context3 = []).call(_context3, _toConsumableArray(prevResults), [command]));
|
|
1515
|
-
|
|
1516
|
-
case 17:
|
|
1517
|
-
case "end":
|
|
1518
|
-
return _context4.stop();
|
|
1519
|
-
}
|
|
1520
|
-
}
|
|
1521
|
-
}, _callee);
|
|
1522
|
-
}));
|
|
1523
|
-
|
|
1524
|
-
return function (_x4, _x5) {
|
|
1525
|
-
return _ref2.apply(this, arguments);
|
|
1526
|
-
};
|
|
1527
|
-
}(), _Promise__default["default"].resolve([])));
|
|
1528
|
-
|
|
1529
|
-
case 1:
|
|
1530
|
-
case "end":
|
|
1531
|
-
return _context5.stop();
|
|
1532
|
-
}
|
|
1533
|
-
}
|
|
1534
|
-
}, _callee2);
|
|
1535
|
-
}));
|
|
1536
|
-
return _flatten.apply(this, arguments);
|
|
1537
|
-
};
|
|
1538
|
-
|
|
1539
|
-
flatten = function _flatten2(_x3) {
|
|
1540
|
-
return _flatten.apply(this, arguments);
|
|
1541
|
-
};
|
|
1542
|
-
|
|
1543
|
-
_context6.next = 4;
|
|
1544
|
-
return flatten(results);
|
|
1545
|
-
|
|
1546
|
-
case 4:
|
|
1547
|
-
return _context6.abrupt("return", _context6.sent);
|
|
1548
|
-
|
|
1549
|
-
case 5:
|
|
1550
|
-
case "end":
|
|
1551
|
-
return _context6.stop();
|
|
1552
|
-
}
|
|
1553
|
-
}
|
|
1554
|
-
}, _callee3);
|
|
1555
|
-
}));
|
|
1556
|
-
|
|
1557
|
-
return function flattenCommands(_x, _x2) {
|
|
1558
|
-
return _ref.apply(this, arguments);
|
|
1559
|
-
};
|
|
1560
|
-
}(); // Once ui-kit exposes its fallback mechanism, we can use the same one here
|
|
1561
|
-
|
|
1562
|
-
var translate = function translate(nameAllLocales, projectDataLocale) {
|
|
1563
|
-
var matchedTranslation = _findInstanceProperty__default["default"](nameAllLocales).call(nameAllLocales, function (translation) {
|
|
1564
|
-
return translation.locale === projectDataLocale && translation.value;
|
|
1565
|
-
});
|
|
1566
|
-
|
|
1567
|
-
if (matchedTranslation) return matchedTranslation.value; // Fall back to the first available locale
|
|
1568
|
-
|
|
1569
|
-
if (nameAllLocales.length > 0) return nameAllLocales[0].value;
|
|
1570
|
-
return '';
|
|
1388
|
+
const loadHistoryEntries = () => {
|
|
1389
|
+
try {
|
|
1390
|
+
const value = sessionStorage.getItem(STORAGE_KEY);
|
|
1391
|
+
return value ? JSON.parse(value) : [];
|
|
1392
|
+
} catch (error) {
|
|
1393
|
+
return [];
|
|
1394
|
+
}
|
|
1571
1395
|
};
|
|
1572
1396
|
|
|
1573
1397
|
var _templateObject$1, _templateObject2$1, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
|
|
1574
1398
|
var QuickAccessProductQuery = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "QuickAccessProduct" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "productId" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "product" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "id" }, value: { kind: "Variable", name: { kind: "Name", value: "productId" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "masterData" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "staged" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "allVariants" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "sku" }, arguments: [], directives: [] }] } }] } }] } }] } }] } }], loc: { start: 0, end: 208, source: { body: "query QuickAccessProduct($productId: String!) {\n product(id: $productId) {\n id\n masterData {\n staged {\n allVariants {\n id\n key\n sku\n }\n }\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
1575
|
-
|
|
1399
|
+
const createProductVariantSubCommands = _ref => {
|
|
1576
1400
|
var _context, _context2, _context3, _context4;
|
|
1577
1401
|
|
|
1578
|
-
|
|
1402
|
+
let intl = _ref.intl,
|
|
1579
1403
|
applicationContext = _ref.applicationContext,
|
|
1580
1404
|
productId = _ref.productId,
|
|
1581
1405
|
variantId = _ref.variantId;
|
|
1582
|
-
|
|
1406
|
+
const canViewProducts = permissions$1.hasSomePermissions([permissions.ViewProducts], applicationContext.permissions);
|
|
1583
1407
|
if (!canViewProducts || !applicationContext.project) return [];
|
|
1584
1408
|
return [{
|
|
1585
1409
|
id: _concatInstanceProperty__default["default"](_context = "go/product(".concat(productId, ")/variant(")).call(_context, variantId, ")/attributes"),
|
|
@@ -1612,7 +1436,7 @@ var createProductVariantSubCommands = function createProductVariantSubCommands(_
|
|
|
1612
1436
|
}];
|
|
1613
1437
|
};
|
|
1614
1438
|
|
|
1615
|
-
|
|
1439
|
+
const formatVariantMessage = (variant, intl) => {
|
|
1616
1440
|
if (variant.sku) return intl.formatMessage(messages.openVariantBySku, {
|
|
1617
1441
|
sku: variant.sku
|
|
1618
1442
|
});
|
|
@@ -1624,81 +1448,51 @@ var formatVariantMessage = function formatVariantMessage(variant, intl) {
|
|
|
1624
1448
|
});
|
|
1625
1449
|
};
|
|
1626
1450
|
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
_context7.next = 4;
|
|
1640
|
-
break;
|
|
1641
|
-
}
|
|
1642
|
-
|
|
1643
|
-
return _context7.abrupt("return", []);
|
|
1644
|
-
|
|
1645
|
-
case 4:
|
|
1646
|
-
_context7.next = 6;
|
|
1647
|
-
return execQuery(QuickAccessProductQuery, {
|
|
1648
|
-
productId: productId
|
|
1649
|
-
}, {
|
|
1650
|
-
target: constants.GRAPHQL_TARGETS.COMMERCETOOLS_PLATFORM
|
|
1651
|
-
});
|
|
1451
|
+
const createProductVariantListSubCommands = async _ref2 => {
|
|
1452
|
+
let intl = _ref2.intl,
|
|
1453
|
+
applicationContext = _ref2.applicationContext,
|
|
1454
|
+
productId = _ref2.productId,
|
|
1455
|
+
execQuery = _ref2.execQuery;
|
|
1456
|
+
const canViewProducts = permissions$1.hasSomePermissions([permissions.ViewProducts], applicationContext.permissions);
|
|
1457
|
+
if (!canViewProducts) return [];
|
|
1458
|
+
const data = await execQuery(QuickAccessProductQuery, {
|
|
1459
|
+
productId
|
|
1460
|
+
}, {
|
|
1461
|
+
target: constants.GRAPHQL_TARGETS.COMMERCETOOLS_PLATFORM
|
|
1462
|
+
});
|
|
1652
1463
|
|
|
1653
|
-
|
|
1654
|
-
|
|
1464
|
+
if (data && data.product && data.product.masterData && data.product.masterData.staged && applicationContext.project) {
|
|
1465
|
+
var _context5;
|
|
1466
|
+
|
|
1467
|
+
const projectKey = applicationContext.project.key;
|
|
1468
|
+
return _mapInstanceProperty__default["default"](_context5 = data.product.masterData.staged.allVariants).call(_context5, variant => {
|
|
1469
|
+
var _context6;
|
|
1470
|
+
|
|
1471
|
+
return {
|
|
1472
|
+
id: _concatInstanceProperty__default["default"](_context6 = "go/product(".concat(productId, ")/variant(")).call(_context6, variant.id, ")"),
|
|
1473
|
+
text: formatVariantMessage(variant, intl),
|
|
1474
|
+
subCommands: createProductVariantSubCommands({
|
|
1475
|
+
intl,
|
|
1476
|
+
applicationContext,
|
|
1477
|
+
productId,
|
|
1478
|
+
variantId: variant.id
|
|
1479
|
+
}),
|
|
1480
|
+
action: {
|
|
1481
|
+
type: actionTypes.go,
|
|
1482
|
+
to: commonTags.oneLineTrim(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n /", "\n /products\n /", "\n /variants\n /", "\n "])), projectKey, productId, variant.id)
|
|
1483
|
+
}
|
|
1484
|
+
};
|
|
1485
|
+
});
|
|
1486
|
+
}
|
|
1655
1487
|
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
break;
|
|
1659
|
-
}
|
|
1488
|
+
return [];
|
|
1489
|
+
};
|
|
1660
1490
|
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
id: _concatInstanceProperty__default["default"](_context6 = "go/product(".concat(productId, ")/variant(")).call(_context6, variant.id, ")"),
|
|
1667
|
-
text: formatVariantMessage(variant, intl),
|
|
1668
|
-
subCommands: createProductVariantSubCommands({
|
|
1669
|
-
intl: intl,
|
|
1670
|
-
applicationContext: applicationContext,
|
|
1671
|
-
productId: productId,
|
|
1672
|
-
variantId: variant.id
|
|
1673
|
-
}),
|
|
1674
|
-
action: {
|
|
1675
|
-
type: actionTypes.go,
|
|
1676
|
-
to: commonTags.oneLineTrim(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n /", "\n /products\n /", "\n /variants\n /", "\n "])), projectKey, productId, variant.id)
|
|
1677
|
-
}
|
|
1678
|
-
};
|
|
1679
|
-
}));
|
|
1680
|
-
|
|
1681
|
-
case 10:
|
|
1682
|
-
return _context7.abrupt("return", []);
|
|
1683
|
-
|
|
1684
|
-
case 11:
|
|
1685
|
-
case "end":
|
|
1686
|
-
return _context7.stop();
|
|
1687
|
-
}
|
|
1688
|
-
}
|
|
1689
|
-
}, _callee);
|
|
1690
|
-
}));
|
|
1691
|
-
|
|
1692
|
-
return function createProductVariantListSubCommands(_x) {
|
|
1693
|
-
return _ref3.apply(this, arguments);
|
|
1694
|
-
};
|
|
1695
|
-
}();
|
|
1696
|
-
|
|
1697
|
-
var createProductTabsSubCommands = function createProductTabsSubCommands(_ref4) {
|
|
1698
|
-
var intl = _ref4.intl,
|
|
1699
|
-
applicationContext = _ref4.applicationContext,
|
|
1700
|
-
productId = _ref4.productId;
|
|
1701
|
-
var canViewProducts = permissions$1.hasSomePermissions([permissions.ViewProducts], applicationContext.permissions);
|
|
1491
|
+
const createProductTabsSubCommands = _ref3 => {
|
|
1492
|
+
let intl = _ref3.intl,
|
|
1493
|
+
applicationContext = _ref3.applicationContext,
|
|
1494
|
+
productId = _ref3.productId;
|
|
1495
|
+
const canViewProducts = permissions$1.hasSomePermissions([permissions.ViewProducts], applicationContext.permissions);
|
|
1702
1496
|
if (!canViewProducts || !applicationContext.project) return [];
|
|
1703
1497
|
return [{
|
|
1704
1498
|
id: "go/product(".concat(productId, ")/general"),
|
|
@@ -1714,14 +1508,12 @@ var createProductTabsSubCommands = function createProductTabsSubCommands(_ref4)
|
|
|
1714
1508
|
type: actionTypes.go,
|
|
1715
1509
|
to: commonTags.oneLineTrim(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n /", "\n /products\n /", "\n /variants\n "])), applicationContext.project.key, productId)
|
|
1716
1510
|
},
|
|
1717
|
-
subCommands:
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
});
|
|
1724
|
-
}
|
|
1511
|
+
subCommands: execQuery => createProductVariantListSubCommands({
|
|
1512
|
+
intl,
|
|
1513
|
+
applicationContext,
|
|
1514
|
+
productId,
|
|
1515
|
+
execQuery
|
|
1516
|
+
})
|
|
1725
1517
|
}, {
|
|
1726
1518
|
id: "go/product(".concat(productId, ")/search"),
|
|
1727
1519
|
text: intl.formatMessage(messages.openProductVariantSearch),
|
|
@@ -1732,518 +1524,342 @@ var createProductTabsSubCommands = function createProductTabsSubCommands(_ref4)
|
|
|
1732
1524
|
}];
|
|
1733
1525
|
};
|
|
1734
1526
|
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1527
|
+
const sanitize = param => param // Replace all \ with \\ (to prevent generate escape characters)
|
|
1528
|
+
.replace(/\\/g, '\\\\') // Replace all " with \"
|
|
1529
|
+
.replace(/"/g, '\\"');
|
|
1530
|
+
const flattenCommands = async (results, execQuery) => {
|
|
1531
|
+
async function flatten(commands) {
|
|
1532
|
+
return _reduceInstanceProperty__default["default"](commands).call(commands, async (prevPromise, command) => {
|
|
1533
|
+
const prevResults = await prevPromise;
|
|
1534
|
+
|
|
1535
|
+
if (command.subCommands) {
|
|
1536
|
+
if (typeof command.subCommands === 'function') {
|
|
1537
|
+
const subCommands = await command.subCommands(execQuery);
|
|
1538
|
+
const flattenSubCommands = await flatten(subCommands);
|
|
1539
|
+
return [...prevResults, command, ...flattenSubCommands];
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
const flattenSubCommands = await flatten(command.subCommands);
|
|
1543
|
+
return [...prevResults, command, ...flattenSubCommands];
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
return [...prevResults, command];
|
|
1547
|
+
}, _Promise__default["default"].resolve([]));
|
|
1750
1548
|
}
|
|
1549
|
+
|
|
1550
|
+
return await flatten(results);
|
|
1551
|
+
}; // Once ui-kit exposes its fallback mechanism, we can use the same one here
|
|
1552
|
+
|
|
1553
|
+
const translate = (nameAllLocales, projectDataLocale) => {
|
|
1554
|
+
const matchedTranslation = _findInstanceProperty__default["default"](nameAllLocales).call(nameAllLocales, translation => translation.locale === projectDataLocale && translation.value);
|
|
1555
|
+
|
|
1556
|
+
if (matchedTranslation) return matchedTranslation.value; // Fall back to the first available locale
|
|
1557
|
+
|
|
1558
|
+
if (nameAllLocales.length > 0) return nameAllLocales[0].value;
|
|
1559
|
+
return '';
|
|
1751
1560
|
};
|
|
1752
1561
|
|
|
1753
1562
|
var _templateObject, _templateObject2;
|
|
1754
1563
|
var QuickAccessQuery = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "QuickAccess" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "searchText" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "canViewProducts" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "productsWhereClause" } }, type: { kind: "NamedType", name: { kind: "Name", value: "String" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "includeProductsByIds" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", alias: { kind: "Name", value: "productsByIds" }, name: { kind: "Name", value: "products" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "where" }, value: { kind: "Variable", name: { kind: "Name", value: "productsWhereClause" } } }], directives: [{ kind: "Directive", name: { kind: "Name", value: "include" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "if" }, value: { kind: "Variable", name: { kind: "Name", value: "includeProductsByIds" } } }] }], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "results" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "masterData" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "staged" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, 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", alias: { kind: "Name", value: "productById" }, name: { kind: "Name", value: "product" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "id" }, value: { kind: "Variable", name: { kind: "Name", value: "searchText" } } }], directives: [{ kind: "Directive", name: { kind: "Name", value: "include" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "if" }, value: { kind: "Variable", name: { kind: "Name", value: "canViewProducts" } } }] }], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "masterData" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "staged" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, 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", alias: { kind: "Name", value: "productByKey" }, name: { kind: "Name", value: "product" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "key" }, value: { kind: "Variable", name: { kind: "Name", value: "searchText" } } }], directives: [{ kind: "Directive", name: { kind: "Name", value: "include" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "if" }, value: { kind: "Variable", name: { kind: "Name", value: "canViewProducts" } } }] }], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "masterData" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "staged" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, 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", alias: { kind: "Name", value: "productByVariantSku" }, name: { kind: "Name", value: "product" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "sku" }, value: { kind: "Variable", name: { kind: "Name", value: "searchText" } } }], directives: [{ kind: "Directive", name: { kind: "Name", value: "include" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "if" }, value: { kind: "Variable", name: { kind: "Name", value: "canViewProducts" } } }] }], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "masterData" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "staged" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, 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: "variant" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "sku" }, value: { kind: "Variable", name: { kind: "Name", value: "searchText" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "sku" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }] } }] } }] } }, { kind: "Field", alias: { kind: "Name", value: "productByVariantKey" }, name: { kind: "Name", value: "product" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "variantKey" }, value: { kind: "Variable", name: { kind: "Name", value: "searchText" } } }], directives: [{ kind: "Directive", name: { kind: "Name", value: "include" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "if" }, value: { kind: "Variable", name: { kind: "Name", value: "canViewProducts" } } }] }], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "masterData" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "staged" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, 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: "variant" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "key" }, value: { kind: "Variable", name: { kind: "Name", value: "searchText" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "sku" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }] } }] } }] } }] } }], loc: { start: 0, end: 1407, source: { body: "query QuickAccess(\n $searchText: String!\n $canViewProducts: Boolean!\n $productsWhereClause: String\n $includeProductsByIds: Boolean!\n) {\n productsByIds: products(where: $productsWhereClause)\n @include(if: $includeProductsByIds) {\n results {\n id\n masterData {\n staged {\n nameAllLocales {\n locale\n value\n }\n }\n }\n }\n }\n\n productById: product(id: $searchText) @include(if: $canViewProducts) {\n id\n masterData {\n staged {\n nameAllLocales {\n locale\n value\n }\n }\n }\n }\n\n productByKey: product(key: $searchText) @include(if: $canViewProducts) {\n id\n masterData {\n staged {\n nameAllLocales {\n locale\n value\n }\n }\n }\n }\n\n productByVariantSku: product(sku: $searchText)\n @include(if: $canViewProducts) {\n id\n masterData {\n staged {\n nameAllLocales {\n locale\n value\n }\n variant(sku: $searchText) {\n sku\n key\n id\n }\n }\n }\n }\n\n productByVariantKey: product(variantKey: $searchText)\n @include(if: $canViewProducts) {\n id\n masterData {\n staged {\n nameAllLocales {\n locale\n value\n }\n variant(key: $searchText) {\n sku\n key\n id\n }\n }\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
1755
1564
|
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
fullText: {
|
|
1763
|
-
field: 'name',
|
|
1764
|
-
language: dataLocale,
|
|
1765
|
-
value: searchText
|
|
1766
|
-
}
|
|
1767
|
-
},
|
|
1768
|
-
sort: [{
|
|
1565
|
+
const searchProductIdsAction = (searchText, projectKey, dataLocale) => sdk.actions.post({
|
|
1566
|
+
uri: "/".concat(projectKey, "/search/products"),
|
|
1567
|
+
mcApiProxyTarget: constants.MC_API_PROXY_TARGETS.PIM_SEARCH,
|
|
1568
|
+
payload: {
|
|
1569
|
+
query: {
|
|
1570
|
+
fullText: {
|
|
1769
1571
|
field: 'name',
|
|
1770
1572
|
language: dataLocale,
|
|
1771
|
-
|
|
1772
|
-
}
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1573
|
+
value: searchText
|
|
1574
|
+
}
|
|
1575
|
+
},
|
|
1576
|
+
sort: [{
|
|
1577
|
+
field: 'name',
|
|
1578
|
+
language: dataLocale,
|
|
1579
|
+
order: 'desc'
|
|
1580
|
+
}],
|
|
1581
|
+
limit: 9,
|
|
1582
|
+
offset: 0
|
|
1583
|
+
}
|
|
1584
|
+
});
|
|
1778
1585
|
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
value: 'availability-check'
|
|
1798
|
-
}
|
|
1799
|
-
},
|
|
1800
|
-
limit: 0,
|
|
1801
|
-
offset: 0
|
|
1586
|
+
const pimIndexerStatusAction = (projectKey, dataLocale) => // TODO this should be sdkActions.head()
|
|
1587
|
+
// and then we should check whether the response code is
|
|
1588
|
+
// - 200 meaning the project is indexed
|
|
1589
|
+
// - 404 meaning the project is not indexed
|
|
1590
|
+
//
|
|
1591
|
+
// But there is a problem in tne node-sdk client as it tries to
|
|
1592
|
+
// .json()-parse the response to HEAD requests which results in an
|
|
1593
|
+
// error, so we send a regular request for now and limit to no results
|
|
1594
|
+
// instead to keep the payload minimal
|
|
1595
|
+
sdk.actions.post({
|
|
1596
|
+
uri: "/".concat(projectKey, "/search/products"),
|
|
1597
|
+
mcApiProxyTarget: constants.MC_API_PROXY_TARGETS.PIM_SEARCH,
|
|
1598
|
+
payload: {
|
|
1599
|
+
query: {
|
|
1600
|
+
fullText: {
|
|
1601
|
+
field: 'name',
|
|
1602
|
+
language: dataLocale,
|
|
1603
|
+
value: 'availability-check'
|
|
1802
1604
|
}
|
|
1803
|
-
}
|
|
1804
|
-
|
|
1805
|
-
|
|
1605
|
+
},
|
|
1606
|
+
limit: 0,
|
|
1607
|
+
offset: 0
|
|
1608
|
+
}
|
|
1609
|
+
});
|
|
1806
1610
|
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1611
|
+
const QuickAccess = props => {
|
|
1612
|
+
const _useState = react$1.useState(loadHistoryEntries()),
|
|
1613
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1614
|
+
historyEntries = _useState2[0],
|
|
1615
|
+
setHistoryEntries = _useState2[1];
|
|
1812
1616
|
|
|
1813
|
-
|
|
1617
|
+
const handleHistoryEntriesChange = react$1.useCallback(entries => {
|
|
1814
1618
|
// Keep the history in sync with the session storage
|
|
1815
1619
|
saveHistoryEntries(entries);
|
|
1816
1620
|
setHistoryEntries(entries);
|
|
1817
1621
|
}, []);
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1622
|
+
const history = reactRouterDom.useHistory();
|
|
1623
|
+
const apolloClient = react$2.useApolloClient();
|
|
1624
|
+
const intl = reactIntl.useIntl();
|
|
1821
1625
|
|
|
1822
|
-
|
|
1626
|
+
const _useFeatureToggles = reactBroadcast.useFeatureToggles({
|
|
1823
1627
|
pimSearch: true,
|
|
1824
1628
|
customApplications: true,
|
|
1825
1629
|
canViewDashboard: true
|
|
1826
1630
|
}),
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
var applicationContext = applicationShellConnectors.useApplicationContext(); // Destructure functions from props to reference them in the hook dependency list
|
|
1833
|
-
|
|
1834
|
-
var onPimIndexerStateChangeFromParent = props.onPimIndexerStateChange;
|
|
1835
|
-
var dispatchFetchProductIds = sdk.useAsyncDispatch();
|
|
1836
|
-
var fetchPimSearchProductIds = react$1.useCallback( /*#__PURE__*/function () {
|
|
1837
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(searchText) {
|
|
1838
|
-
var _context, result;
|
|
1839
|
-
|
|
1840
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context2) {
|
|
1841
|
-
while (1) {
|
|
1842
|
-
switch (_context2.prev = _context2.next) {
|
|
1843
|
-
case 0:
|
|
1844
|
-
if (!(applicationContext.project && applicationContext.dataLocale)) {
|
|
1845
|
-
_context2.next = 5;
|
|
1846
|
-
break;
|
|
1847
|
-
}
|
|
1848
|
-
|
|
1849
|
-
_context2.next = 3;
|
|
1850
|
-
return dispatchFetchProductIds(searchProductIdsAction(searchText, applicationContext.project.key, applicationContext.dataLocale));
|
|
1631
|
+
_useFeatureToggles2 = _slicedToArray(_useFeatureToggles, 3),
|
|
1632
|
+
isPimSearchEnabled = _useFeatureToggles2[0],
|
|
1633
|
+
isCustomApplicationsEnabled = _useFeatureToggles2[1],
|
|
1634
|
+
isCanViewDashboardEnabled = _useFeatureToggles2[2];
|
|
1851
1635
|
|
|
1852
|
-
|
|
1853
|
-
result = _context2.sent;
|
|
1854
|
-
return _context2.abrupt("return", result && result.hits ? _mapInstanceProperty__default["default"](_context = result.hits).call(_context, function (hit) {
|
|
1855
|
-
return hit.id;
|
|
1856
|
-
}) : []);
|
|
1636
|
+
const applicationContext = applicationShellConnectors.useApplicationContext(); // Destructure functions from props to reference them in the hook dependency list
|
|
1857
1637
|
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
return _context2.stop();
|
|
1864
|
-
}
|
|
1865
|
-
}
|
|
1866
|
-
}, _callee);
|
|
1867
|
-
}));
|
|
1638
|
+
const onPimIndexerStateChangeFromParent = props.onPimIndexerStateChange;
|
|
1639
|
+
const dispatchFetchProductIds = sdk.useAsyncDispatch();
|
|
1640
|
+
const fetchPimSearchProductIds = react$1.useCallback(async searchText => {
|
|
1641
|
+
if (applicationContext.project && applicationContext.dataLocale) {
|
|
1642
|
+
var _context;
|
|
1868
1643
|
|
|
1869
|
-
|
|
1870
|
-
return
|
|
1871
|
-
}
|
|
1872
|
-
}(), [applicationContext.dataLocale, applicationContext.project, dispatchFetchProductIds]);
|
|
1873
|
-
var dispatchFetchPimIndexerStatus = sdk.useAsyncDispatch();
|
|
1874
|
-
var fetchPimIndexerStatus = react$1.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2() {
|
|
1875
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context3) {
|
|
1876
|
-
while (1) {
|
|
1877
|
-
switch (_context3.prev = _context3.next) {
|
|
1878
|
-
case 0:
|
|
1879
|
-
if (!(applicationContext.project && applicationContext.dataLocale)) {
|
|
1880
|
-
_context3.next = 10;
|
|
1881
|
-
break;
|
|
1882
|
-
}
|
|
1883
|
-
|
|
1884
|
-
_context3.prev = 1;
|
|
1885
|
-
dispatchFetchPimIndexerStatus(pimIndexerStatusAction(applicationContext.project.key, applicationContext.dataLocale));
|
|
1886
|
-
return _context3.abrupt("return", dist_commercetoolsFrontendApplicationShell.pimIndexerStates.INDEXED);
|
|
1887
|
-
|
|
1888
|
-
case 6:
|
|
1889
|
-
_context3.prev = 6;
|
|
1890
|
-
_context3.t0 = _context3["catch"](1);
|
|
1891
|
-
// but we treat all errors as non-indexed as a safe guard, so we're
|
|
1892
|
-
// not checking the response error code at all
|
|
1893
|
-
|
|
1894
|
-
return _context3.abrupt("return", dist_commercetoolsFrontendApplicationShell.pimIndexerStates.NOT_INDEXED);
|
|
1895
|
-
|
|
1896
|
-
case 10:
|
|
1897
|
-
return _context3.abrupt("return", dist_commercetoolsFrontendApplicationShell.pimIndexerStates.NOT_INDEXED);
|
|
1644
|
+
const result = await dispatchFetchProductIds(searchProductIdsAction(searchText, applicationContext.project.key, applicationContext.dataLocale));
|
|
1645
|
+
return result && result.hits ? _mapInstanceProperty__default["default"](_context = result.hits).call(_context, hit => hit.id) : [];
|
|
1646
|
+
}
|
|
1898
1647
|
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1648
|
+
return [];
|
|
1649
|
+
}, [applicationContext.dataLocale, applicationContext.project, dispatchFetchProductIds]);
|
|
1650
|
+
const dispatchFetchPimIndexerStatus = sdk.useAsyncDispatch();
|
|
1651
|
+
const fetchPimIndexerStatus = react$1.useCallback(async () => {
|
|
1652
|
+
if (applicationContext.project && applicationContext.dataLocale) {
|
|
1653
|
+
try {
|
|
1654
|
+
dispatchFetchPimIndexerStatus(pimIndexerStatusAction(applicationContext.project.key, applicationContext.dataLocale));
|
|
1655
|
+
return dist_commercetoolsFrontendApplicationShell.pimIndexerStates.INDEXED;
|
|
1656
|
+
} catch (error) {
|
|
1657
|
+
// but we treat all errors as non-indexed as a safe guard, so we're
|
|
1658
|
+
// not checking the response error code at all
|
|
1659
|
+
|
|
1660
|
+
return dist_commercetoolsFrontendApplicationShell.pimIndexerStates.NOT_INDEXED;
|
|
1903
1661
|
}
|
|
1904
|
-
}
|
|
1905
|
-
})), [applicationContext.dataLocale, applicationContext.project, dispatchFetchPimIndexerStatus]);
|
|
1906
|
-
var getProjectIndexStatus = react$1.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3() {
|
|
1907
|
-
var canViewProducts;
|
|
1908
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context4) {
|
|
1909
|
-
while (1) {
|
|
1910
|
-
switch (_context4.prev = _context4.next) {
|
|
1911
|
-
case 0:
|
|
1912
|
-
if (applicationContext.project) {
|
|
1913
|
-
_context4.next = 2;
|
|
1914
|
-
break;
|
|
1915
|
-
}
|
|
1916
|
-
|
|
1917
|
-
return _context4.abrupt("return", dist_commercetoolsFrontendApplicationShell.pimIndexerStates.NOT_INDEXED);
|
|
1918
|
-
|
|
1919
|
-
case 2:
|
|
1920
|
-
canViewProducts = permissions$1.hasSomePermissions([permissions.ViewProducts], applicationContext.permissions); // skip checking when user can't view products anyways
|
|
1921
|
-
|
|
1922
|
-
if (canViewProducts) {
|
|
1923
|
-
_context4.next = 5;
|
|
1924
|
-
break;
|
|
1925
|
-
}
|
|
1926
|
-
|
|
1927
|
-
return _context4.abrupt("return", dist_commercetoolsFrontendApplicationShell.pimIndexerStates.NOT_INDEXED);
|
|
1928
|
-
|
|
1929
|
-
case 5:
|
|
1930
|
-
_context4.next = 7;
|
|
1931
|
-
return fetchPimIndexerStatus();
|
|
1932
|
-
|
|
1933
|
-
case 7:
|
|
1934
|
-
return _context4.abrupt("return", _context4.sent);
|
|
1662
|
+
}
|
|
1935
1663
|
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1664
|
+
return dist_commercetoolsFrontendApplicationShell.pimIndexerStates.NOT_INDEXED;
|
|
1665
|
+
}, [applicationContext.dataLocale, applicationContext.project, dispatchFetchPimIndexerStatus]);
|
|
1666
|
+
const getProjectIndexStatus = react$1.useCallback(async () => {
|
|
1667
|
+
// skip when there is no project
|
|
1668
|
+
if (!applicationContext.project) return dist_commercetoolsFrontendApplicationShell.pimIndexerStates.NOT_INDEXED;
|
|
1669
|
+
const canViewProducts = permissions$1.hasSomePermissions([permissions.ViewProducts], applicationContext.permissions); // skip checking when user can't view products anyways
|
|
1670
|
+
|
|
1671
|
+
if (!canViewProducts) return dist_commercetoolsFrontendApplicationShell.pimIndexerStates.NOT_INDEXED;
|
|
1672
|
+
return await fetchPimIndexerStatus();
|
|
1673
|
+
}, [applicationContext.permissions, applicationContext.project, fetchPimIndexerStatus]);
|
|
1674
|
+
react$1.useEffect(() => {
|
|
1944
1675
|
if (props.pimIndexerState === dist_commercetoolsFrontendApplicationShell.pimIndexerStates.UNCHECKED) {
|
|
1945
|
-
getProjectIndexStatus().then(
|
|
1676
|
+
getProjectIndexStatus().then(status => {
|
|
1946
1677
|
onPimIndexerStateChangeFromParent(status);
|
|
1947
1678
|
});
|
|
1948
1679
|
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1949
1680
|
|
|
1950
1681
|
}, []); // <-- run only once, when component mounts
|
|
1951
1682
|
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1683
|
+
const execQuery = react$1.useCallback((Query, variables, context) => apolloClient.query({
|
|
1684
|
+
query: Query,
|
|
1685
|
+
errorPolicy: 'ignore',
|
|
1686
|
+
variables,
|
|
1687
|
+
context
|
|
1688
|
+
}).then(response => response.data), [apolloClient]);
|
|
1689
|
+
const getNextCommands = react$1.useCallback(async command => {
|
|
1690
|
+
if (!command.subCommands) return [];
|
|
1691
|
+
if (_Array$isArray__default["default"](command.subCommands)) return command.subCommands;
|
|
1692
|
+
return await command.subCommands(execQuery);
|
|
1693
|
+
}, [execQuery]);
|
|
1694
|
+
const getProjectCommands = react$1.useCallback(async searchText => {
|
|
1695
|
+
const idsOfProductsMatchingSearchText = props.pimIndexerState === dist_commercetoolsFrontendApplicationShell.pimIndexerStates.INDEXED ? await fetchPimSearchProductIds(searchText) : [];
|
|
1696
|
+
const canViewProducts = permissions$1.hasSomePermissions([permissions.ViewProducts], applicationContext.permissions);
|
|
1697
|
+
const data = await execQuery(QuickAccessQuery, {
|
|
1698
|
+
searchText: sanitize(searchText),
|
|
1699
|
+
// Pass conditional arguments to disable some of the queries
|
|
1700
|
+
canViewProducts,
|
|
1701
|
+
productsWhereClause: "id in (".concat(_mapInstanceProperty__default["default"](idsOfProductsMatchingSearchText).call(idsOfProductsMatchingSearchText, id => _JSON$stringify__default["default"](id)).join(', '), ")"),
|
|
1702
|
+
includeProductsByIds: Boolean(canViewProducts && idsOfProductsMatchingSearchText.length > 0)
|
|
1703
|
+
}, {
|
|
1704
|
+
target: constants.GRAPHQL_TARGETS.COMMERCETOOLS_PLATFORM
|
|
1960
1705
|
});
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1706
|
+
const commands = [];
|
|
1707
|
+
|
|
1708
|
+
if (data && data.productByVariantKey && data.productByVariantKey.masterData && data.productByVariantKey.masterData.staged && data.productByVariantKey.masterData.staged.variant && applicationContext.project && applicationContext.dataLocale) {
|
|
1709
|
+
var _context2;
|
|
1710
|
+
|
|
1711
|
+
const productId = data.productByVariantKey.id;
|
|
1712
|
+
const variantId = data.productByVariantKey.masterData.staged.variant.id;
|
|
1713
|
+
const variantKey = data.productByVariantKey.masterData.staged.variant.key;
|
|
1714
|
+
commands.push({
|
|
1715
|
+
id: _concatInstanceProperty__default["default"](_context2 = "go/product-variant-by-key/product(".concat(productId, "/variant(")).call(_context2, variantId, ")"),
|
|
1716
|
+
text: intl.formatMessage(messages.showProductVariant, {
|
|
1717
|
+
variantName: translate(data.productByVariantKey.masterData.staged.nameAllLocales, applicationContext.dataLocale)
|
|
1718
|
+
}),
|
|
1719
|
+
keywords: variantKey ? [variantKey] : undefined,
|
|
1720
|
+
action: {
|
|
1721
|
+
type: actionTypes.go,
|
|
1722
|
+
to: commonTags.oneLineTrim(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n /", "\n /products\n /", "\n /variants\n /", "\n "])), applicationContext.project.key, productId, variantId)
|
|
1723
|
+
},
|
|
1724
|
+
subCommands: createProductVariantSubCommands({
|
|
1725
|
+
intl,
|
|
1726
|
+
applicationContext,
|
|
1727
|
+
productId,
|
|
1728
|
+
variantId
|
|
1729
|
+
})
|
|
1730
|
+
});
|
|
1731
|
+
}
|
|
1974
1732
|
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
_context5.next = 4;
|
|
1978
|
-
break;
|
|
1979
|
-
}
|
|
1733
|
+
if (data && data.productByVariantSku && data.productByVariantSku.masterData && data.productByVariantSku.masterData.staged && data.productByVariantSku.masterData.staged.variant && applicationContext.project && applicationContext.dataLocale) {
|
|
1734
|
+
var _context3;
|
|
1980
1735
|
|
|
1981
|
-
|
|
1736
|
+
const productId = data.productByVariantSku.id;
|
|
1737
|
+
const variantId = data.productByVariantSku.masterData.staged.variant.id;
|
|
1738
|
+
commands.push({
|
|
1739
|
+
id: _concatInstanceProperty__default["default"](_context3 = "go/product-variant-by-sku/product(".concat(productId, ")/variant(")).call(_context3, variantId, ")"),
|
|
1740
|
+
text: intl.formatMessage(messages.showProductVariant, {
|
|
1741
|
+
variantName: data.productByVariantSku.masterData.staged.variant.sku
|
|
1742
|
+
}),
|
|
1743
|
+
action: {
|
|
1744
|
+
type: actionTypes.go,
|
|
1745
|
+
to: commonTags.oneLineTrim(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n /", "\n /products\n /", "\n /variants\n /", "\n "])), applicationContext.project.key, productId, variantId)
|
|
1746
|
+
},
|
|
1747
|
+
subCommands: createProductVariantSubCommands({
|
|
1748
|
+
intl,
|
|
1749
|
+
applicationContext,
|
|
1750
|
+
productId,
|
|
1751
|
+
variantId
|
|
1752
|
+
})
|
|
1753
|
+
});
|
|
1754
|
+
}
|
|
1982
1755
|
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
return command.subCommands(execQuery);
|
|
1756
|
+
if (data && data.productById && data.productById.masterData && data.productById.masterData.staged && data.productById.masterData.staged.nameAllLocales && applicationContext.project && applicationContext.dataLocale) {
|
|
1757
|
+
var _context4;
|
|
1986
1758
|
|
|
1987
|
-
|
|
1988
|
-
|
|
1759
|
+
const productId = data.productById.id;
|
|
1760
|
+
commands.push({
|
|
1761
|
+
id: "go/product-by-id/product(".concat(productId, ")"),
|
|
1762
|
+
text: intl.formatMessage(messages.showProduct, {
|
|
1763
|
+
productName: translate(data.productById.masterData.staged.nameAllLocales, applicationContext.dataLocale)
|
|
1764
|
+
}),
|
|
1765
|
+
keywords: [productId],
|
|
1766
|
+
action: {
|
|
1767
|
+
type: actionTypes.go,
|
|
1768
|
+
to: _concatInstanceProperty__default["default"](_context4 = "/".concat(applicationContext.project.key, "/products/")).call(_context4, productId)
|
|
1769
|
+
},
|
|
1770
|
+
subCommands: createProductTabsSubCommands({
|
|
1771
|
+
intl,
|
|
1772
|
+
applicationContext,
|
|
1773
|
+
productId
|
|
1774
|
+
})
|
|
1775
|
+
});
|
|
1776
|
+
}
|
|
1989
1777
|
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1778
|
+
if (data && data.productsByIds && data.productsByIds.results) {
|
|
1779
|
+
var _context5;
|
|
1780
|
+
|
|
1781
|
+
_forEachInstanceProperty__default["default"](_context5 = data.productsByIds.results).call(_context5, product => {
|
|
1782
|
+
if (product.masterData.staged && applicationContext.project && applicationContext.dataLocale) {
|
|
1783
|
+
var _context6;
|
|
1784
|
+
|
|
1785
|
+
commands.push({
|
|
1786
|
+
id: "go/product-by-search-text/product(".concat(product.id, ")"),
|
|
1787
|
+
text: intl.formatMessage(messages.showProduct, {
|
|
1788
|
+
productName: translate(product.masterData.staged.nameAllLocales, applicationContext.dataLocale)
|
|
1789
|
+
}),
|
|
1790
|
+
keywords: [product.id],
|
|
1791
|
+
action: {
|
|
1792
|
+
type: actionTypes.go,
|
|
1793
|
+
to: _concatInstanceProperty__default["default"](_context6 = "/".concat(applicationContext.project.key, "/products/")).call(_context6, product.id)
|
|
1794
|
+
},
|
|
1795
|
+
subCommands: createProductTabsSubCommands({
|
|
1796
|
+
intl,
|
|
1797
|
+
applicationContext,
|
|
1798
|
+
productId: product.id
|
|
1799
|
+
})
|
|
1800
|
+
});
|
|
1994
1801
|
}
|
|
1995
|
-
}
|
|
1996
|
-
}
|
|
1997
|
-
|
|
1998
|
-
return function (_x2) {
|
|
1999
|
-
return _ref4.apply(this, arguments);
|
|
2000
|
-
};
|
|
2001
|
-
}(), [execQuery]);
|
|
2002
|
-
var getProjectCommands = react$1.useCallback( /*#__PURE__*/function () {
|
|
2003
|
-
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee5(searchText) {
|
|
2004
|
-
var idsOfProductsMatchingSearchText, canViewProducts, data, commands, _context6, productId, variantId, variantKey, _context7, _productId, _variantId, _context8, _productId2, _context9, _context11, _productId3;
|
|
2005
|
-
|
|
2006
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee5$(_context12) {
|
|
2007
|
-
while (1) {
|
|
2008
|
-
switch (_context12.prev = _context12.next) {
|
|
2009
|
-
case 0:
|
|
2010
|
-
if (!(props.pimIndexerState === dist_commercetoolsFrontendApplicationShell.pimIndexerStates.INDEXED)) {
|
|
2011
|
-
_context12.next = 6;
|
|
2012
|
-
break;
|
|
2013
|
-
}
|
|
2014
|
-
|
|
2015
|
-
_context12.next = 3;
|
|
2016
|
-
return fetchPimSearchProductIds(searchText);
|
|
2017
|
-
|
|
2018
|
-
case 3:
|
|
2019
|
-
_context12.t0 = _context12.sent;
|
|
2020
|
-
_context12.next = 7;
|
|
2021
|
-
break;
|
|
2022
|
-
|
|
2023
|
-
case 6:
|
|
2024
|
-
_context12.t0 = [];
|
|
2025
|
-
|
|
2026
|
-
case 7:
|
|
2027
|
-
idsOfProductsMatchingSearchText = _context12.t0;
|
|
2028
|
-
canViewProducts = permissions$1.hasSomePermissions([permissions.ViewProducts], applicationContext.permissions);
|
|
2029
|
-
_context12.next = 11;
|
|
2030
|
-
return execQuery(QuickAccessQuery, {
|
|
2031
|
-
searchText: sanitize(searchText),
|
|
2032
|
-
// Pass conditional arguments to disable some of the queries
|
|
2033
|
-
canViewProducts: canViewProducts,
|
|
2034
|
-
productsWhereClause: "id in (".concat(_mapInstanceProperty__default["default"](idsOfProductsMatchingSearchText).call(idsOfProductsMatchingSearchText, function (id) {
|
|
2035
|
-
return _JSON$stringify__default["default"](id);
|
|
2036
|
-
}).join(', '), ")"),
|
|
2037
|
-
includeProductsByIds: Boolean(canViewProducts && idsOfProductsMatchingSearchText.length > 0)
|
|
2038
|
-
}, {
|
|
2039
|
-
target: constants.GRAPHQL_TARGETS.COMMERCETOOLS_PLATFORM
|
|
2040
|
-
});
|
|
2041
|
-
|
|
2042
|
-
case 11:
|
|
2043
|
-
data = _context12.sent;
|
|
2044
|
-
commands = [];
|
|
2045
|
-
|
|
2046
|
-
if (data && data.productByVariantKey && data.productByVariantKey.masterData && data.productByVariantKey.masterData.staged && data.productByVariantKey.masterData.staged.variant && applicationContext.project && applicationContext.dataLocale) {
|
|
2047
|
-
productId = data.productByVariantKey.id;
|
|
2048
|
-
variantId = data.productByVariantKey.masterData.staged.variant.id;
|
|
2049
|
-
variantKey = data.productByVariantKey.masterData.staged.variant.key;
|
|
2050
|
-
commands.push({
|
|
2051
|
-
id: _concatInstanceProperty__default["default"](_context6 = "go/product-variant-by-key/product(".concat(productId, "/variant(")).call(_context6, variantId, ")"),
|
|
2052
|
-
text: intl.formatMessage(messages.showProductVariant, {
|
|
2053
|
-
variantName: translate(data.productByVariantKey.masterData.staged.nameAllLocales, applicationContext.dataLocale)
|
|
2054
|
-
}),
|
|
2055
|
-
keywords: variantKey ? [variantKey] : undefined,
|
|
2056
|
-
action: {
|
|
2057
|
-
type: actionTypes.go,
|
|
2058
|
-
to: commonTags.oneLineTrim(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n /", "\n /products\n /", "\n /variants\n /", "\n "])), applicationContext.project.key, productId, variantId)
|
|
2059
|
-
},
|
|
2060
|
-
subCommands: createProductVariantSubCommands({
|
|
2061
|
-
intl: intl,
|
|
2062
|
-
applicationContext: applicationContext,
|
|
2063
|
-
productId: productId,
|
|
2064
|
-
variantId: variantId
|
|
2065
|
-
})
|
|
2066
|
-
});
|
|
2067
|
-
}
|
|
2068
|
-
|
|
2069
|
-
if (data && data.productByVariantSku && data.productByVariantSku.masterData && data.productByVariantSku.masterData.staged && data.productByVariantSku.masterData.staged.variant && applicationContext.project && applicationContext.dataLocale) {
|
|
2070
|
-
_productId = data.productByVariantSku.id;
|
|
2071
|
-
_variantId = data.productByVariantSku.masterData.staged.variant.id;
|
|
2072
|
-
commands.push({
|
|
2073
|
-
id: _concatInstanceProperty__default["default"](_context7 = "go/product-variant-by-sku/product(".concat(_productId, ")/variant(")).call(_context7, _variantId, ")"),
|
|
2074
|
-
text: intl.formatMessage(messages.showProductVariant, {
|
|
2075
|
-
variantName: data.productByVariantSku.masterData.staged.variant.sku
|
|
2076
|
-
}),
|
|
2077
|
-
action: {
|
|
2078
|
-
type: actionTypes.go,
|
|
2079
|
-
to: commonTags.oneLineTrim(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n /", "\n /products\n /", "\n /variants\n /", "\n "])), applicationContext.project.key, _productId, _variantId)
|
|
2080
|
-
},
|
|
2081
|
-
subCommands: createProductVariantSubCommands({
|
|
2082
|
-
intl: intl,
|
|
2083
|
-
applicationContext: applicationContext,
|
|
2084
|
-
productId: _productId,
|
|
2085
|
-
variantId: _variantId
|
|
2086
|
-
})
|
|
2087
|
-
});
|
|
2088
|
-
}
|
|
2089
|
-
|
|
2090
|
-
if (data && data.productById && data.productById.masterData && data.productById.masterData.staged && data.productById.masterData.staged.nameAllLocales && applicationContext.project && applicationContext.dataLocale) {
|
|
2091
|
-
_productId2 = data.productById.id;
|
|
2092
|
-
commands.push({
|
|
2093
|
-
id: "go/product-by-id/product(".concat(_productId2, ")"),
|
|
2094
|
-
text: intl.formatMessage(messages.showProduct, {
|
|
2095
|
-
productName: translate(data.productById.masterData.staged.nameAllLocales, applicationContext.dataLocale)
|
|
2096
|
-
}),
|
|
2097
|
-
keywords: [_productId2],
|
|
2098
|
-
action: {
|
|
2099
|
-
type: actionTypes.go,
|
|
2100
|
-
to: _concatInstanceProperty__default["default"](_context8 = "/".concat(applicationContext.project.key, "/products/")).call(_context8, _productId2)
|
|
2101
|
-
},
|
|
2102
|
-
subCommands: createProductTabsSubCommands({
|
|
2103
|
-
intl: intl,
|
|
2104
|
-
applicationContext: applicationContext,
|
|
2105
|
-
productId: _productId2
|
|
2106
|
-
})
|
|
2107
|
-
});
|
|
2108
|
-
}
|
|
2109
|
-
|
|
2110
|
-
if (data && data.productsByIds && data.productsByIds.results) {
|
|
2111
|
-
_forEachInstanceProperty__default["default"](_context9 = data.productsByIds.results).call(_context9, function (product) {
|
|
2112
|
-
if (product.masterData.staged && applicationContext.project && applicationContext.dataLocale) {
|
|
2113
|
-
var _context10;
|
|
2114
|
-
|
|
2115
|
-
commands.push({
|
|
2116
|
-
id: "go/product-by-search-text/product(".concat(product.id, ")"),
|
|
2117
|
-
text: intl.formatMessage(messages.showProduct, {
|
|
2118
|
-
productName: translate(product.masterData.staged.nameAllLocales, applicationContext.dataLocale)
|
|
2119
|
-
}),
|
|
2120
|
-
keywords: [product.id],
|
|
2121
|
-
action: {
|
|
2122
|
-
type: actionTypes.go,
|
|
2123
|
-
to: _concatInstanceProperty__default["default"](_context10 = "/".concat(applicationContext.project.key, "/products/")).call(_context10, product.id)
|
|
2124
|
-
},
|
|
2125
|
-
subCommands: createProductTabsSubCommands({
|
|
2126
|
-
intl: intl,
|
|
2127
|
-
applicationContext: applicationContext,
|
|
2128
|
-
productId: product.id
|
|
2129
|
-
})
|
|
2130
|
-
});
|
|
2131
|
-
}
|
|
2132
|
-
});
|
|
2133
|
-
}
|
|
2134
|
-
|
|
2135
|
-
if (data && data.productByKey && applicationContext.project && applicationContext.dataLocale) {
|
|
2136
|
-
_productId3 = data.productByKey.id;
|
|
2137
|
-
commands.push({
|
|
2138
|
-
id: "go/product-by-key/product(".concat(_productId3, ")"),
|
|
2139
|
-
text: intl.formatMessage(messages.showProduct, {
|
|
2140
|
-
productName: searchText
|
|
2141
|
-
}),
|
|
2142
|
-
action: {
|
|
2143
|
-
type: actionTypes.go,
|
|
2144
|
-
to: _concatInstanceProperty__default["default"](_context11 = "/".concat(applicationContext.project.key, "/products/")).call(_context11, _productId3)
|
|
2145
|
-
},
|
|
2146
|
-
subCommands: createProductTabsSubCommands({
|
|
2147
|
-
intl: intl,
|
|
2148
|
-
applicationContext: applicationContext,
|
|
2149
|
-
productId: _productId3
|
|
2150
|
-
})
|
|
2151
|
-
});
|
|
2152
|
-
}
|
|
1802
|
+
});
|
|
1803
|
+
}
|
|
2153
1804
|
|
|
2154
|
-
|
|
1805
|
+
if (data && data.productByKey && applicationContext.project && applicationContext.dataLocale) {
|
|
1806
|
+
var _context7;
|
|
2155
1807
|
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
1808
|
+
const productId = data.productByKey.id;
|
|
1809
|
+
commands.push({
|
|
1810
|
+
id: "go/product-by-key/product(".concat(productId, ")"),
|
|
1811
|
+
text: intl.formatMessage(messages.showProduct, {
|
|
1812
|
+
productName: searchText
|
|
1813
|
+
}),
|
|
1814
|
+
action: {
|
|
1815
|
+
type: actionTypes.go,
|
|
1816
|
+
to: _concatInstanceProperty__default["default"](_context7 = "/".concat(applicationContext.project.key, "/products/")).call(_context7, productId)
|
|
1817
|
+
},
|
|
1818
|
+
subCommands: createProductTabsSubCommands({
|
|
1819
|
+
intl,
|
|
1820
|
+
applicationContext,
|
|
1821
|
+
productId
|
|
1822
|
+
})
|
|
1823
|
+
});
|
|
1824
|
+
}
|
|
2163
1825
|
|
|
2164
|
-
return
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
}(), [applicationContext, execQuery, fetchPimSearchProductIds, intl, props.pimIndexerState]);
|
|
2168
|
-
var debouncedGetProjectCommands = debounce__default["default"](getProjectCommands, 200, {
|
|
1826
|
+
return commands;
|
|
1827
|
+
}, [applicationContext, execQuery, fetchPimSearchProductIds, intl, props.pimIndexerState]);
|
|
1828
|
+
const debouncedGetProjectCommands = debounce__default["default"](getProjectCommands, 200, {
|
|
2169
1829
|
cancelObj: 'canceled'
|
|
2170
1830
|
});
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
return _context14.abrupt("return", generalCommands);
|
|
2204
|
-
|
|
2205
|
-
case 5:
|
|
2206
|
-
_context14.prev = 5;
|
|
2207
|
-
_context14.next = 8;
|
|
2208
|
-
return debouncedGetProjectCommands(searchText);
|
|
2209
|
-
|
|
2210
|
-
case 8:
|
|
2211
|
-
projectCommands = _context14.sent;
|
|
2212
|
-
allCommands = _concatInstanceProperty__default["default"](_context13 = []).call(_context13, _toConsumableArray(generalCommands), _toConsumableArray(projectCommands));
|
|
2213
|
-
_context14.next = 12;
|
|
2214
|
-
return flattenCommands(allCommands, execQuery);
|
|
2215
|
-
|
|
2216
|
-
case 12:
|
|
2217
|
-
return _context14.abrupt("return", _context14.sent);
|
|
2218
|
-
|
|
2219
|
-
case 15:
|
|
2220
|
-
_context14.prev = 15;
|
|
2221
|
-
_context14.t0 = _context14["catch"](5);
|
|
2222
|
-
|
|
2223
|
-
if (!(_context14.t0 === 'canceled')) {
|
|
2224
|
-
_context14.next = 19;
|
|
2225
|
-
break;
|
|
2226
|
-
}
|
|
2227
|
-
|
|
2228
|
-
return _context14.abrupt("return", generalCommands);
|
|
2229
|
-
|
|
2230
|
-
case 19:
|
|
2231
|
-
throw _context14.t0;
|
|
2232
|
-
|
|
2233
|
-
case 20:
|
|
2234
|
-
case "end":
|
|
2235
|
-
return _context14.stop();
|
|
2236
|
-
}
|
|
2237
|
-
}
|
|
2238
|
-
}, _callee6, null, [[5, 15]]);
|
|
2239
|
-
}));
|
|
2240
|
-
|
|
2241
|
-
return function (_x4) {
|
|
2242
|
-
return _ref6.apply(this, arguments);
|
|
2243
|
-
};
|
|
2244
|
-
}(), [applicationContext, debouncedGetProjectCommands, execQuery, intl, isCanViewDashboardEnabled, isCustomApplicationsEnabled, isPimSearchEnabled, props.onChangeProjectDataLocale]);
|
|
2245
|
-
var executeCommand = react$1.useCallback(function (command, meta) {
|
|
2246
|
-
var _context15;
|
|
1831
|
+
const search = react$1.useCallback(async searchText => {
|
|
1832
|
+
const generalCommands = createCommands({
|
|
1833
|
+
applicationContext,
|
|
1834
|
+
changeProjectDataLocale: props.onChangeProjectDataLocale,
|
|
1835
|
+
intl,
|
|
1836
|
+
featureToggles: {
|
|
1837
|
+
pimSearch: isPimSearchEnabled,
|
|
1838
|
+
customApplications: isCustomApplicationsEnabled,
|
|
1839
|
+
canViewDashboard: isCanViewDashboardEnabled
|
|
1840
|
+
}
|
|
1841
|
+
});
|
|
1842
|
+
if (!applicationContext.project) return generalCommands; // Avoid searching for short texts, as we won't get any good results
|
|
1843
|
+
// anyways. This results in commands popping up immediately when the user
|
|
1844
|
+
// starts typing, which gives the whole search a much more repsonsive
|
|
1845
|
+
// feeling.
|
|
1846
|
+
|
|
1847
|
+
if (_trimInstanceProperty__default["default"](searchText).call(searchText).length < 3) return generalCommands;
|
|
1848
|
+
|
|
1849
|
+
try {
|
|
1850
|
+
const projectCommands = await debouncedGetProjectCommands(searchText);
|
|
1851
|
+
const allCommands = [...generalCommands, ...projectCommands];
|
|
1852
|
+
return await flattenCommands(allCommands, execQuery);
|
|
1853
|
+
} catch (error) {
|
|
1854
|
+
// When the debounced search is canceled, it throws with "canceled"
|
|
1855
|
+
// In that case we know that another search is going to happen
|
|
1856
|
+
// and we just resolve with the general commands.
|
|
1857
|
+
if (error === 'canceled') return generalCommands;
|
|
1858
|
+
throw error;
|
|
1859
|
+
}
|
|
1860
|
+
}, [applicationContext, debouncedGetProjectCommands, execQuery, intl, isCanViewDashboardEnabled, isCustomApplicationsEnabled, isPimSearchEnabled, props.onChangeProjectDataLocale]);
|
|
1861
|
+
const executeCommand = react$1.useCallback((command, meta) => {
|
|
1862
|
+
var _context8;
|
|
2247
1863
|
|
|
2248
1864
|
if (typeof command.action === 'function') {
|
|
2249
1865
|
// Idea: We could handle these errors and set them on status bar of Butler
|
|
@@ -2254,11 +1870,11 @@ var QuickAccess = function QuickAccess(props) {
|
|
|
2254
1870
|
// and always open other pages in a new window
|
|
2255
1871
|
|
|
2256
1872
|
|
|
2257
|
-
if (meta.openInNewTab || !_startsWithInstanceProperty__default["default"](
|
|
1873
|
+
if (meta.openInNewTab || !_startsWithInstanceProperty__default["default"](_context8 = command.action.to).call(_context8, '/')) {
|
|
2258
1874
|
// eslint-disable-next-line no-restricted-globals
|
|
2259
1875
|
open(command.action.to, '_blank');
|
|
2260
1876
|
} else if (applicationContext.environment.useFullRedirectsForLinks) {
|
|
2261
|
-
|
|
1877
|
+
useIsServedByProxy.location.replace(command.action.to);
|
|
2262
1878
|
} else {
|
|
2263
1879
|
history.push(command.action.to);
|
|
2264
1880
|
}
|