@commercetools-frontend/application-shell 24.11.0 → 24.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/{application-entry-point-c87294b0.cjs.dev.js → application-entry-point-18d8fba0.cjs.dev.js} +7 -4
  2. package/dist/{application-entry-point-10a5e1a5.esm.js → application-entry-point-1b23fb6b.esm.js} +6 -4
  3. package/dist/{application-entry-point-8c4b8e53.cjs.prod.js → application-entry-point-74a06151.cjs.prod.js} +4 -3
  4. package/dist/commercetools-frontend-application-shell.cjs.dev.js +12 -11
  5. package/dist/commercetools-frontend-application-shell.cjs.prod.js +12 -11
  6. package/dist/commercetools-frontend-application-shell.esm.js +12 -11
  7. package/dist/{custom-view-dev-host-6091b78a.esm.js → custom-view-dev-host-091163ea.esm.js} +20 -16
  8. package/dist/{custom-view-dev-host-40b33836.cjs.dev.js → custom-view-dev-host-17daf42a.cjs.dev.js} +21 -16
  9. package/dist/{custom-view-dev-host-3a171a01.cjs.prod.js → custom-view-dev-host-a682a499.cjs.prod.js} +21 -16
  10. package/dist/{index-a57c8458.cjs.dev.js → index-1d1cc31f.cjs.dev.js} +212 -363
  11. package/dist/{index-67a5d8e8.esm.js → index-1dadca21.esm.js} +213 -362
  12. package/dist/{index-614accc4.cjs.dev.js → index-25183095.cjs.dev.js} +2 -2
  13. package/dist/{index-7bdde97c.cjs.prod.js → index-3cfc1f1e.cjs.prod.js} +200 -343
  14. package/dist/{index-245e2980.cjs.prod.js → index-52c724ed.cjs.prod.js} +2 -2
  15. package/dist/{index-86039df7.esm.js → index-5aaa33bb.esm.js} +2 -2
  16. package/dist/{navbar-022383bd.cjs.dev.js → navbar-586f7774.cjs.dev.js} +111 -92
  17. package/dist/{navbar-844d350d.esm.js → navbar-88e0fd1f.esm.js} +110 -92
  18. package/dist/{navbar-acc2cd1b.cjs.prod.js → navbar-93183a2d.cjs.prod.js} +111 -92
  19. package/dist/oidc-258fc018.cjs.prod.js +115 -0
  20. package/dist/oidc-35e8e62a.esm.js +100 -0
  21. package/dist/oidc-87d116c1.cjs.dev.js +115 -0
  22. package/dist/{oidc-callback-5f3d5280.esm.js → oidc-callback-019d623d.esm.js} +16 -14
  23. package/dist/{oidc-callback-e07f0c20.cjs.dev.js → oidc-callback-47743232.cjs.dev.js} +16 -14
  24. package/dist/{oidc-callback-ce8cbdfe.cjs.prod.js → oidc-callback-6bdb3c6f.cjs.prod.js} +16 -14
  25. package/dist/{project-container-a11a31ca.cjs.dev.js → project-container-2245f020.cjs.dev.js} +53 -19
  26. package/dist/{project-container-fba09841.esm.js → project-container-7fce9e66.esm.js} +52 -19
  27. package/dist/{project-container-2d3d027a.cjs.prod.js → project-container-954dbf0f.cjs.prod.js} +53 -19
  28. package/dist/{project-expired-ede4d485.esm.js → project-expired-1b0845c5.esm.js} +12 -11
  29. package/dist/{project-expired-9620dee4.cjs.dev.js → project-expired-c941b592.cjs.dev.js} +12 -11
  30. package/dist/{project-expired-f38a712a.cjs.prod.js → project-expired-ee8b232c.cjs.prod.js} +12 -11
  31. package/dist/{project-not-found-093ab795.esm.js → project-not-found-340217f6.esm.js} +11 -10
  32. package/dist/{project-not-found-05683f8e.cjs.dev.js → project-not-found-9b7cfe88.cjs.dev.js} +11 -10
  33. package/dist/{project-not-found-cfa934da.cjs.prod.js → project-not-found-9cee9625.cjs.prod.js} +11 -10
  34. package/dist/{project-not-initialized-1d934ae7.esm.js → project-not-initialized-55fd8df4.esm.js} +12 -11
  35. package/dist/{project-not-initialized-b5a1400f.cjs.prod.js → project-not-initialized-7a058b68.cjs.prod.js} +12 -11
  36. package/dist/{project-not-initialized-1ed56a00.cjs.dev.js → project-not-initialized-7b3843a3.cjs.dev.js} +12 -11
  37. package/dist/{project-suspended-8e15a452.cjs.prod.js → project-suspended-12618898.cjs.prod.js} +11 -10
  38. package/dist/{project-suspended-e0722654.esm.js → project-suspended-529b09d6.esm.js} +11 -10
  39. package/dist/{project-suspended-68e80299.cjs.dev.js → project-suspended-78e94b85.cjs.dev.js} +11 -10
  40. package/dist/{redirect-to-login-12f467b8.cjs.prod.js → redirect-to-login-3e4a6434.cjs.prod.js} +13 -10
  41. package/dist/{redirect-to-login-3bee13ba.cjs.dev.js → redirect-to-login-66ea895a.cjs.dev.js} +13 -10
  42. package/dist/{redirect-to-login-2944c890.esm.js → redirect-to-login-edbfacbc.esm.js} +13 -10
  43. package/dist/{redirect-to-logout-2802852c.cjs.prod.js → redirect-to-logout-52a7810f.cjs.prod.js} +14 -12
  44. package/dist/{redirect-to-logout-5db48f16.esm.js → redirect-to-logout-5d5fc361.esm.js} +14 -12
  45. package/dist/{redirect-to-logout-74b72fe8.cjs.dev.js → redirect-to-logout-b331b037.cjs.dev.js} +14 -12
  46. package/dist/{redirector-72ccfbc2.cjs.dev.js → redirector-0efdd994.cjs.dev.js} +4 -3
  47. package/dist/{redirector-d856975f.esm.js → redirector-656c6ee7.esm.js} +4 -3
  48. package/dist/{redirector-0c72d0a4.cjs.prod.js → redirector-c858d578.cjs.prod.js} +4 -3
  49. package/dist/{requests-in-flight-loader-e25f4c31.esm.js → requests-in-flight-loader-20021ccc.esm.js} +11 -10
  50. package/dist/{requests-in-flight-loader-877c1541.cjs.prod.js → requests-in-flight-loader-64d2e12d.cjs.prod.js} +11 -10
  51. package/dist/{requests-in-flight-loader-bc904171.cjs.dev.js → requests-in-flight-loader-83cab813.cjs.dev.js} +11 -10
  52. package/dist/{service-page-project-switcher-af044ac6.cjs.dev.js → service-page-project-switcher-49dabe13.cjs.dev.js} +1 -1
  53. package/dist/{service-page-project-switcher-f3eac18a.esm.js → service-page-project-switcher-6cdd506b.esm.js} +1 -1
  54. package/dist/{service-page-project-switcher-1dad9871.cjs.prod.js → service-page-project-switcher-f1b43eb7.cjs.prod.js} +1 -1
  55. package/dist/{use-applications-menu-14a5a1f4.cjs.prod.js → use-applications-menu-48d924bd.cjs.prod.js} +47 -39
  56. package/dist/{use-applications-menu-823a2492.cjs.dev.js → use-applications-menu-7f548a7a.cjs.dev.js} +47 -39
  57. package/dist/{use-applications-menu-1514af11.esm.js → use-applications-menu-b871849c.esm.js} +44 -37
  58. package/dist/{user-settings-menu-d75f4958.cjs.prod.js → user-settings-menu-6660f508.cjs.prod.js} +29 -22
  59. package/dist/{user-settings-menu-f98bea89.esm.js → user-settings-menu-afa82f2a.esm.js} +29 -22
  60. package/dist/{user-settings-menu-6113cdd3.cjs.dev.js → user-settings-menu-f5c74042.cjs.dev.js} +29 -22
  61. package/package.json +16 -16
  62. package/ssr/dist/commercetools-frontend-application-shell-ssr.cjs.dev.js +2 -1
  63. package/ssr/dist/commercetools-frontend-application-shell-ssr.cjs.prod.js +2 -1
  64. package/ssr/dist/commercetools-frontend-application-shell-ssr.esm.js +2 -1
  65. package/test-utils/dist/commercetools-frontend-application-shell-test-utils.cjs.dev.js +26 -22
  66. package/test-utils/dist/commercetools-frontend-application-shell-test-utils.cjs.prod.js +26 -22
  67. package/test-utils/dist/commercetools-frontend-application-shell-test-utils.esm.js +20 -17
  68. package/dist/oidc-8827f9fe.cjs.dev.js +0 -98
  69. package/dist/oidc-b2520905.esm.js +0 -84
  70. package/dist/oidc-d74e6aa2.cjs.prod.js +0 -98
  71. package/dist/quick-access-9dd197bb.cjs.prod.js +0 -1875
  72. package/dist/quick-access-a665bbb7.cjs.dev.js +0 -1893
  73. package/dist/quick-access-dfc1f8a9.esm.js +0 -1865
@@ -1,1875 +0,0 @@
1
- 'use strict';
2
-
3
- var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
4
- var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
5
- var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
6
- var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
7
- var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
8
- var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
9
- var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
10
- var react$1 = require('react');
11
- var react$2 = require('@apollo/client/react');
12
- var reactBroadcast = require('@flopflip/react-broadcast');
13
- var commonTags = require('common-tags');
14
- var debounce = require('debounce-async');
15
- var reactIntl = require('react-intl');
16
- var reactRouterDom = require('react-router-dom');
17
- var applicationShellConnectors = require('@commercetools-frontend/application-shell-connectors');
18
- var constants = require('@commercetools-frontend/constants');
19
- var permissions$1 = require('@commercetools-frontend/permissions');
20
- var sdk = require('@commercetools-frontend/sdk');
21
- var location = require('./location-537e0660.cjs.prod.js');
22
- var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
23
- var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
24
- var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
25
- var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
26
- var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
27
- var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
28
- var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
29
- var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
30
- var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
31
- var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
32
- var _findIndexInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find-index');
33
- var react = require('@emotion/react');
34
- var Fuse = require('fuse.js');
35
- var last = require('lodash/last');
36
- var designSystem = require('@commercetools-uikit/design-system');
37
- var icons = require('@commercetools-uikit/icons');
38
- var LoadingSpinner = require('@commercetools-uikit/loading-spinner');
39
- var jsxRuntime = require('@emotion/react/jsx-runtime');
40
- var dist_commercetoolsFrontendApplicationShell = require('./index-7bdde97c.cjs.prod.js');
41
- var _Promise = require('@babel/runtime-corejs3/core-js-stable/promise');
42
- var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
43
- var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
44
- require('./index-245e2980.cjs.prod.js');
45
- require('@babel/runtime-corejs3/core-js-stable/object/entries');
46
- require('@babel/runtime-corejs3/core-js-stable/instance/concat');
47
- require('@babel/runtime-corejs3/core-js-stable/reflect/has');
48
- require('@reduxjs/toolkit');
49
- require('lodash/mapValues');
50
- require('omit-empty-es');
51
- require('redux');
52
- require('redux-thunk');
53
- require('@commercetools-frontend/notifications');
54
- require('@babel/runtime-corejs3/core-js-stable/instance/index-of');
55
- require('@commercetools-frontend/sentry');
56
- require('@commercetools-frontend/react-notifications');
57
- require('redux-logger');
58
- require('@emotion/styled/base');
59
- require('@commercetools-frontend/application-components');
60
- require('@commercetools-frontend/i18n');
61
- require('./oidc-d74e6aa2.cjs.prod.js');
62
- require('@babel/runtime-corejs3/core-js-stable/url');
63
- require('@commercetools-uikit/spacings');
64
- require('@commercetools-uikit/flat-button');
65
- require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
66
- require('memoize-one');
67
- require('react-select');
68
- require('@commercetools-uikit/accessible-hidden');
69
- require('@commercetools-uikit/select-input');
70
- require('@commercetools-uikit/text');
71
- require('@commercetools-frontend/assets/images/ct-logo.svg');
72
- require('@commercetools-frontend/browser-history');
73
- require('@commercetools-frontend/l10n');
74
- require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
75
- require('@babel/runtime-corejs3/helpers/classCallCheck');
76
- require('@babel/runtime-corejs3/helpers/createClass');
77
- require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
78
- require('@babel/runtime-corejs3/helpers/getPrototypeOf');
79
- require('@babel/runtime-corejs3/helpers/inherits');
80
- require('@babel/runtime-corejs3/core-js-stable/object/from-entries');
81
- require('@babel/runtime-corejs3/core-js-stable/instance/flags');
82
- require('@flopflip/combine-adapters');
83
- require('@flopflip/http-adapter');
84
- require('@flopflip/launchdarkly-adapter');
85
- require('@flopflip/types');
86
- require('react-redux');
87
- require('@commercetools-uikit/design-system/materials/resets.css');
88
- require('@commercetools-frontend/application-config/ssr');
89
- require('@flopflip/memory-adapter');
90
- require('@babel/runtime-corejs3/core-js-stable/instance/some');
91
- require('@commercetools-frontend/actions-global');
92
-
93
- function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
94
-
95
- var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
96
- var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
97
- var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
98
- var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
99
- var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
100
- var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
101
- var debounce__default = /*#__PURE__*/_interopDefault(debounce);
102
- var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
103
- var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
104
- var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
105
- var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
106
- var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
107
- var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
108
- var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
109
- var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
110
- var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
111
- var _findIndexInstanceProperty__default = /*#__PURE__*/_interopDefault(_findIndexInstanceProperty);
112
- var Fuse__default = /*#__PURE__*/_interopDefault(Fuse);
113
- var last__default = /*#__PURE__*/_interopDefault(last);
114
- var LoadingSpinner__default = /*#__PURE__*/_interopDefault(LoadingSpinner);
115
- var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
116
- var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
117
- var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
118
-
119
- var _ref$1 = {
120
- name: "13n9jnb",
121
- styles: "align-self:center;>*{display:block;}"
122
- } ;
123
- var _ref2 = {
124
- name: "lhzw0z",
125
- styles: "flex:1 auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis"
126
- } ;
127
- const ButlerCommand = props => jsxRuntime.jsxs("div", {
128
- "data-testid": `quick-access-result(${props.command.id})`,
129
- "aria-current": props.isSelected === true ? 'true' : 'false',
130
- css: /*#__PURE__*/react.css("display:flex;padding:0 ", designSystem.customProperties.spacingM, ";height:36px;font-size:16px;font-weight:200;line-height:36px;cursor:default;", props.isSelected === true ? `
131
- background: ${designSystem.customProperties.colorAccent};
132
- color: ${designSystem.customProperties.colorSurface};
133
- ` : '', ";" + ("" ), "" ),
134
- onMouseEnter: props.onMouseEnter,
135
- onClick: props.onClick,
136
- children: [jsxRuntime.jsx("div", {
137
- css: _ref2,
138
- children: props.command.text
139
- }), (_Array$isArray__default["default"](props.command.subCommands) && props.command.subCommands.length > 0 || typeof props.command.subCommands === 'function') && jsxRuntime.jsx("div", {
140
- css: _ref$1,
141
- children: jsxRuntime.jsx(icons.AngleThinRightIcon, {
142
- size: "medium",
143
- color: props.isSelected ? 'surface' : 'neutral60'
144
- })
145
- })]
146
- }, props.command.id);
147
- ButlerCommand.displayName = 'ButlerCommand';
148
-
149
- var messages = reactIntl.defineMessages({
150
- inputPlacehoder: {
151
- id: 'QuickAccess.inputPlaceholder',
152
- defaultMessage: 'Go to...'
153
- },
154
- offline: {
155
- id: 'QuickAccess.offline',
156
- defaultMessage: 'Offline'
157
- },
158
- noResults: {
159
- id: 'QuickAccess.noResults',
160
- defaultMessage: 'No results found'
161
- },
162
- // create-commands
163
- setResourceLanguage: {
164
- id: 'QuickAccess.setResourceLanguage',
165
- defaultMessage: 'Set Resource Language'
166
- },
167
- openDashboard: {
168
- id: 'QuickAccess.openDashboard',
169
- defaultMessage: 'Open Dashboard'
170
- },
171
- openProducts: {
172
- id: 'QuickAccess.openProducts',
173
- defaultMessage: 'Open Products'
174
- },
175
- openProductList: {
176
- id: 'QuickAccess.openProductList',
177
- defaultMessage: 'Open Product List'
178
- },
179
- openProductVariantGeneral: {
180
- id: 'QuickAccess.openProductVariantGeneral',
181
- defaultMessage: 'General'
182
- },
183
- openProductVariantList: {
184
- id: 'QuickAccess.openProductVariantList',
185
- defaultMessage: 'Variants'
186
- },
187
- openProductVariantSearch: {
188
- id: 'QuickAccess.openProductVariantSearch',
189
- defaultMessage: 'Int. / Ext. Search'
190
- },
191
- openModifiedProducts: {
192
- id: 'QuickAccess.openModifiedProducts',
193
- defaultMessage: 'Open Review Modified Products'
194
- },
195
- openPimSearch: {
196
- id: 'QuickAccess.openPimSearch',
197
- defaultMessage: 'Open PIM Search'
198
- },
199
- openAddProducts: {
200
- id: 'QuickAccess.openAddProducts',
201
- defaultMessage: 'Open Add Products'
202
- },
203
- openCategories: {
204
- id: 'QuickAccess.openCategories',
205
- defaultMessage: 'Open Categories'
206
- },
207
- openCategoriesList: {
208
- id: 'QuickAccess.openCategoriesList',
209
- defaultMessage: 'Open Categories List'
210
- },
211
- openCategoriesSearch: {
212
- id: 'QuickAccess.openCategoriesSearch',
213
- defaultMessage: 'Open Categories Search'
214
- },
215
- openAddCategory: {
216
- id: 'QuickAccess.openAddCategory',
217
- defaultMessage: 'Open Add Category'
218
- },
219
- openCustomers: {
220
- id: 'QuickAccess.openCustomers',
221
- defaultMessage: 'Open Customers'
222
- },
223
- openCustomersList: {
224
- id: 'QuickAccess.openCustomersList',
225
- defaultMessage: 'Open Customers List'
226
- },
227
- openAddCustomer: {
228
- id: 'QuickAccess.openAddCustomer',
229
- defaultMessage: 'Open Add Customer'
230
- },
231
- openCustomerGroupsList: {
232
- id: 'QuickAccess.openCustomerGroupsList',
233
- defaultMessage: 'Open Customer Groups List'
234
- },
235
- openAddCustomerGroup: {
236
- id: 'QuickAccess.openAddCustomerGroup',
237
- defaultMessage: 'Open Add Customer Group'
238
- },
239
- openOrders: {
240
- id: 'QuickAccess.openOrders',
241
- defaultMessage: 'Open Orders'
242
- },
243
- openOrdersList: {
244
- id: 'QuickAccess.openOrdersList',
245
- defaultMessage: 'Open Orders List'
246
- },
247
- openAddOrder: {
248
- id: 'QuickAccess.openAddOrder',
249
- defaultMessage: 'Open Add Order'
250
- },
251
- openDiscounts: {
252
- id: 'QuickAccess.openDiscounts',
253
- defaultMessage: 'Open Discounts'
254
- },
255
- openProductDiscountsList: {
256
- id: 'QuickAccess.openProductDiscountsList',
257
- defaultMessage: 'Open Product Discounts List'
258
- },
259
- openCartDiscountsList: {
260
- id: 'QuickAccess.openCartDiscountsList',
261
- defaultMessage: 'Open Cart Discounts List'
262
- },
263
- openDiscountCodesList: {
264
- id: 'QuickAccess.openDiscountCodesList',
265
- defaultMessage: 'Open Discount Codes List'
266
- },
267
- openAddDiscount: {
268
- id: 'QuickAccess.openAddDiscount',
269
- defaultMessage: 'Open Add Discount'
270
- },
271
- openAddProductDiscount: {
272
- id: 'QuickAccess.openAddProductDiscount',
273
- defaultMessage: 'Open Add Product Discount'
274
- },
275
- openAddCartDiscount: {
276
- id: 'QuickAccess.openAddCartDiscount',
277
- defaultMessage: 'Open Add Cart Discount'
278
- },
279
- openAddDiscountCode: {
280
- id: 'QuickAccess.openAddDiscountCode',
281
- defaultMessage: 'Open Add Discount Code'
282
- },
283
- openSettings: {
284
- id: 'QuickAccess.openSettings',
285
- defaultMessage: 'Open Settings'
286
- },
287
- openProjectSettings: {
288
- id: 'QuickAccess.openProjectSettings',
289
- defaultMessage: 'Open Project Settings'
290
- },
291
- openProjectSettingsInternationalTab: {
292
- id: 'QuickAccess.openProjectSettingsInternationalTab',
293
- defaultMessage: 'Open Project Settings • International'
294
- },
295
- openProjectSettingsTaxesTab: {
296
- id: 'QuickAccess.openProjectSettingsTaxesTab',
297
- defaultMessage: 'Open Project Settings • Taxes'
298
- },
299
- openProjectSettingsShippingMethodsTab: {
300
- id: 'QuickAccess.openProjectSettingsShippingMethodsTab',
301
- defaultMessage: 'Open Project Settings • Shipping Methods'
302
- },
303
- openProjectSettingsChannelsTab: {
304
- id: 'QuickAccess.openProjectSettingsChannelsTab',
305
- defaultMessage: 'Open Project Settings • Channels'
306
- },
307
- openProjectSettingsStoresTab: {
308
- id: 'QuickAccess.openProjectSettingsStoresTab',
309
- defaultMessage: 'Open Project Settings • Stores'
310
- },
311
- openProductTypesSettings: {
312
- id: 'QuickAccess.openProductTypesSettings',
313
- defaultMessage: 'Open Product Types Settings'
314
- },
315
- openDeveloperSettings: {
316
- id: 'QuickAccess.openDeveloperSettings',
317
- defaultMessage: 'Open Developer Settings'
318
- },
319
- openCustomApplicationsSettings: {
320
- id: 'QuickAccess.openCustomApplicationsSettings',
321
- defaultMessage: 'Open Custom Applications Settings'
322
- },
323
- openApiClientsList: {
324
- id: 'QuickAccess.openApiClientsList',
325
- defaultMessage: 'Open API Clients'
326
- },
327
- openAddApiClient: {
328
- id: 'QuickAccess.openAddApiClient',
329
- defaultMessage: 'Open Add API Client'
330
- },
331
- openSupport: {
332
- id: 'QuickAccess.openSupport',
333
- defaultMessage: 'Open Support'
334
- },
335
- openMyProfile: {
336
- id: 'QuickAccess.openMyProfile',
337
- defaultMessage: 'Open My Profile'
338
- },
339
- showPrivacyPolicy: {
340
- id: 'QuickAccess.showPrivacyPolicy',
341
- defaultMessage: 'Show Privacy Policy'
342
- },
343
- logout: {
344
- id: 'QuickAccess.logout',
345
- defaultMessage: 'Logout'
346
- },
347
- useProject: {
348
- id: 'QuickAccess.useProject',
349
- defaultMessage: 'Switch to project "{projectName}"'
350
- },
351
- openManageProjects: {
352
- id: 'QuickAccess.openManageProject',
353
- defaultMessage: 'Open Manage Projects'
354
- },
355
- openManageOrganizations: {
356
- id: 'QuickAccess.openManageOrganizations',
357
- defaultMessage: 'Open Manage Organizations'
358
- },
359
- // subcommands
360
- openVariantById: {
361
- id: 'QuickAccess.openVariantById',
362
- defaultMessage: 'Open Variant "{id}" (id)'
363
- },
364
- openVariantByKey: {
365
- id: 'QuickAccess.openVariantByKey',
366
- defaultMessage: 'Open Variant "{key}" (key)'
367
- },
368
- openVariantBySku: {
369
- id: 'QuickAccess.openVariantBySku',
370
- defaultMessage: 'Open Variant "{sku}" (sku)'
371
- },
372
- showProduct: {
373
- id: 'QuickAccess.showProduct',
374
- defaultMessage: 'Show Product "{productName}"'
375
- },
376
- showProductVariant: {
377
- id: 'QuickAccess.showProductVariant',
378
- defaultMessage: 'Show Product Variant "{variantName}"'
379
- },
380
- showProductVariantAttributes: {
381
- id: 'QuickAccess.showProductVariantAttributes',
382
- defaultMessage: 'Show Attributes'
383
- },
384
- showProductVariantImages: {
385
- id: 'QuickAccess.showProductVariantImages',
386
- defaultMessage: 'Show Images'
387
- },
388
- showProductVariantPrices: {
389
- id: 'QuickAccess.showProductVariantPrices',
390
- defaultMessage: 'Show Prices'
391
- },
392
- showProductVariantInventory: {
393
- id: 'QuickAccess.showProductVariantInventory',
394
- defaultMessage: 'Show Inventory'
395
- }
396
- });
397
-
398
- function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
399
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context10, _context11; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context10 = ownKeys(Object(t), !0)).call(_context10, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context11 = ownKeys(Object(t))).call(_context11, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
400
- const isSelectAllCombo = event => event.key === 'a' && event.metaKey && !event.ctrlKey && !event.altKey && !event.shiftKey;
401
- const isCloseCombo = event => event.key === 'Escape' && !event.metaKey && !event.ctrlKey && !event.altKey && !event.shiftKey;
402
- const getPlatform = () => {
403
- var _context, _context2, _context3, _context4;
404
- if (_includesInstanceProperty__default["default"](_context = navigator.appVersion).call(_context, 'Win')) return 'windows';
405
- if (_includesInstanceProperty__default["default"](_context2 = navigator.appVersion).call(_context2, 'Mac')) return 'macos';
406
- if (_includesInstanceProperty__default["default"](_context3 = navigator.appVersion).call(_context3, 'X11')) return 'unix';
407
- if (_includesInstanceProperty__default["default"](_context4 = navigator.appVersion).call(_context4, 'Linux')) return 'linux';
408
- return null;
409
- };
410
- const hasNewWindowModifier = event => {
411
- const platform = getPlatform();
412
- switch (platform) {
413
- case 'macos':
414
- return event.metaKey;
415
- default:
416
- return event.ctrlKey;
417
- }
418
- };
419
- const shakeAnimation = react.keyframes`
420
- from,
421
- to {
422
- transform: translate3d(0, 0, 0);
423
- }
424
-
425
- 14%,
426
- 42%,
427
- 70% {
428
- transform: translate3d(-3px, 0, 0);
429
- }
430
-
431
- 28%,
432
- 56%,
433
- 84% {
434
- transform: translate3d(3px, 0, 0);
435
- }
436
- `;
437
- const initialState = {
438
- hasNetworkError: false,
439
- isLoading: false,
440
- searchText: '',
441
- selectedResult: -1,
442
- // Used for UX when browsing through history
443
- enableHistory: true,
444
- results: [],
445
- stack: []
446
- };
447
- const reducer = function () {
448
- var _context5;
449
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
450
- let action = arguments.length > 1 ? arguments[1] : undefined;
451
- switch (action.type) {
452
- case 'networkError':
453
- return _objectSpread(_objectSpread({}, state), {}, {
454
- hasNetworkError: action.payload
455
- });
456
- case 'loading':
457
- return _objectSpread(_objectSpread({}, state), {}, {
458
- isLoading: action.payload
459
- });
460
- case 'selectedResult':
461
- return _objectSpread(_objectSpread({}, state), {}, {
462
- selectedResult: action.payload
463
- });
464
- case 'incrementSelectedResult':
465
- return _objectSpread(_objectSpread({}, state), {}, {
466
- selectedResult: state.selectedResult === state.results.length - 1 ? 0 : state.selectedResult + 1,
467
- enableHistory: false
468
- });
469
- case 'decrementSelectedResult':
470
- return _objectSpread(_objectSpread({}, state), {}, {
471
- selectedResult: state.selectedResult < 1 ? state.results.length - 1 : state.selectedResult - 1,
472
- enableHistory: false
473
- });
474
- case 'pickCommandFromHistory':
475
- return _objectSpread(_objectSpread({}, state), {}, {
476
- selectedResult: 0,
477
- searchText: action.payload.searchText,
478
- results: action.payload.results,
479
- stack: []
480
- // The history does not get changed here, it will be changed along
481
- // with the regular flow.
482
- });
483
- case 'setNextCommands':
484
- return _objectSpread(_objectSpread({}, state), {}, {
485
- stack: [...state.stack, {
486
- searchText: state.searchText,
487
- results: state.results,
488
- selectedResult: state.selectedResult
489
- }],
490
- selectedResult: 0,
491
- enableHistory: false,
492
- results: action.payload.results
493
- });
494
- case 'setPrevCommands':
495
- return _objectSpread(_objectSpread({}, state), {}, {
496
- searchText: action.payload.searchText,
497
- results: action.payload.results,
498
- selectedResult: 0,
499
- enableHistory: false,
500
- // omit last item
501
- stack: _sliceInstanceProperty__default["default"](_context5 = state.stack).call(_context5, 0, -1)
502
- });
503
- case 'searchText':
504
- return _objectSpread(_objectSpread({}, state), {}, {
505
- searchText: action.payload,
506
- // clear network error when search text is cleared, so that users
507
- // are tempted to retry
508
- hasNetworkError: action.payload.length > 0 && state.hasNetworkError
509
- });
510
- case 'setSearchTextResults':
511
- return _objectSpread(_objectSpread({}, state), {}, {
512
- results: action.payload,
513
- selectedResult: action.payload.length > 0 ? 0 : -1,
514
- enableHistory: true,
515
- stack: []
516
- });
517
- case 'resetSearchText':
518
- return _objectSpread(_objectSpread({}, state), {}, {
519
- searchText: '',
520
- results: [],
521
- selectedResult: -1
522
- });
523
- case 'resetResultsWhenClosing':
524
- return _objectSpread(_objectSpread({}, state), {}, {
525
- selectedResult: -1,
526
- enableHistory: true
527
- });
528
- case 'reset':
529
- return initialState;
530
- default:
531
- return state;
532
- }
533
- };
534
- var _ref = {
535
- name: "zjik7",
536
- styles: "display:flex"
537
- } ;
538
- const Butler = props => {
539
- const intl = reactIntl.useIntl();
540
- const _useReducer = react$1.useReducer(reducer, initialState),
541
- _useReducer2 = _slicedToArray(_useReducer, 2),
542
- state = _useReducer2[0],
543
- dispatch = _useReducer2[1];
544
- const shouldSelectFieldText = react$1.useRef(false);
545
- const isNewWindowCombo = react$1.useRef(false);
546
- const skipNextSelection = react$1.useRef(false);
547
- const searchContainerRef = react$1.useRef(null);
548
- const searchInputRef = react$1.useRef(null);
549
- const setHasNetworkError = react$1.useCallback(() => {
550
- dispatch({
551
- type: 'networkError',
552
- payload: true
553
- });
554
- }, []);
555
- const unsetHasNetworkError = react$1.useCallback(() => {
556
- dispatch({
557
- type: 'networkError',
558
- payload: false
559
- });
560
- }, []);
561
- const setIsLoading = react$1.useCallback(() => {
562
- dispatch({
563
- type: 'loading',
564
- payload: true
565
- });
566
- }, []);
567
- const unsetIsLoading = react$1.useCallback(() => {
568
- dispatch({
569
- type: 'loading',
570
- payload: false
571
- });
572
- }, []);
573
-
574
- // Destructure functions from props to reference them in the hook dependency list
575
- const searchFromParent = props.search,
576
- onCloseFromParent = props.onClose,
577
- executeCommandFromParent = props.executeCommand,
578
- onHistoryEntriesChangeFromParent = props.onHistoryEntriesChange,
579
- getNextCommandsFromParent = props.getNextCommands;
580
- const shake = react$1.useCallback(() => {
581
- if (searchContainerRef.current) {
582
- searchContainerRef.current.classList.remove(props.classNameShakeAnimation);
583
- // -> triggering reflow
584
- // eslint-disable-next-line no-void
585
- void searchContainerRef.current.offsetWidth;
586
- searchContainerRef.current.classList.add(props.classNameShakeAnimation);
587
- }
588
- }, [props.classNameShakeAnimation]);
589
- const execute = react$1.useCallback((command, meta) => {
590
- var _context6;
591
- // Only main entries get added to history, so when a subcommand is executed,
592
- // we add the main command of it to the history (the top-level command).
593
- //
594
- // The key to identify history entries by is always the searchText
595
- // There will never be two history entries with the same searchText
596
- const entry = state.stack.length === 0 ?
597
- // The stack is empty, so we are executing a top-level command
598
- {
599
- searchText: state.searchText,
600
- results: state.results
601
- } :
602
- // We are executing a subcommand, so we get the top-level command for it,
603
- // which is at the bottom of the stack.
604
- {
605
- searchText: state.stack[0].searchText,
606
- results: state.stack[0].results
607
- };
608
-
609
- // Add the entry to the history, while excluding any earlier history entry
610
- // with the same search text. This effectively "moves" that entry to the
611
- // top of the history (with the most recent results), or appends a new entry
612
- // when it didn't exist before.
613
- onHistoryEntriesChangeFromParent([..._filterInstanceProperty__default["default"](_context6 = props.historyEntries).call(_context6, command => command.searchText !== entry.searchText), entry]);
614
- dispatch({
615
- type: 'resetSearchText'
616
- });
617
- onCloseFromParent();
618
- executeCommandFromParent(command, meta);
619
- }, [executeCommandFromParent, onCloseFromParent, onHistoryEntriesChangeFromParent, props.historyEntries, state.results, state.searchText, state.stack]);
620
- const handleKeyDown = react$1.useCallback(event => {
621
- // Preventing cursor jumps can only happen in onKeyDown, but not in onKeyUp
622
- event.persist();
623
-
624
- // We want to know when the user presses cmd+enter (cmd being a meta key).
625
- // We are only told about this in keyDown, but not in keyUp, so we need
626
- // to handle it here
627
- if (event.key === 'Enter' && hasNewWindowModifier(event)) {
628
- isNewWindowCombo.current = true;
629
- return;
630
- }
631
-
632
- // Avoid selecting the whole page when user selectes everything with
633
- // a keyboard shortcut. There is probably a better way to do this though.
634
- // This prevents the whole page from being selected in case the user
635
- // 1) opens the search box
636
- // 2) types into it
637
- // 3) selects all text using cmd+a
638
- // 4) closes the search box with esc
639
- // Without this handling, the whole page would now be selected
640
- if (isSelectAllCombo(event)) {
641
- // This stops the browser from selecting anything
642
- event.preventDefault();
643
- if (searchInputRef.current) {
644
- // This selects the text in the search input
645
- searchInputRef.current.setSelectionRange(0, state.searchText.length);
646
- }
647
- return;
648
- }
649
-
650
- // avoid interfering with other key combinations using modifier keys
651
- if (event.ctrlKey || event.altKey || event.shiftKey || event.metaKey) return;
652
- if (isCloseCombo(event)) return;
653
-
654
- // skip next mouseEnter to avoid setting selectedResult when cursor just
655
- // happens to be where the results will pop up
656
- skipNextSelection.current = true;
657
- if (event.key === 'ArrowDown') {
658
- // prevent cursor from jumping to end of text input
659
- event.preventDefault();
660
- dispatch({
661
- type: 'incrementSelectedResult'
662
- });
663
- return;
664
- }
665
- if (event.key === 'ArrowUp') {
666
- // browse through history
667
- if (state.searchText.length === 0 || state.selectedResult < 1 && state.enableHistory) {
668
- var _context7;
669
- shouldSelectFieldText.current = true;
670
- const selectedIndex = state.searchText.length === 0 ?
671
- // When going back the first step
672
- -1 :
673
- // When going back more than one step
674
- _findIndexInstanceProperty__default["default"](_context7 = props.historyEntries).call(_context7, command => command.searchText === state.searchText);
675
- // Pick the previous command from the history
676
- const prevCommand = selectedIndex === -1 ?
677
- // previous command on top of the history when going back on
678
- // first step
679
- last__default["default"](props.historyEntries) :
680
- // previous command is deeper down
681
- // When the history does not exist (negative index), then
682
- // this implicitly returns undefined
683
- props.historyEntries[selectedIndex - 1];
684
- // Skip when no previous entry exists in the history
685
- if (!prevCommand) return;
686
- dispatch({
687
- type: 'pickCommandFromHistory',
688
- payload: {
689
- searchText: prevCommand.searchText,
690
- results: prevCommand.results
691
- }
692
- });
693
- return;
694
- }
695
- // prevent cursor from jumping to beginning of text input
696
- event.preventDefault();
697
- dispatch({
698
- type: 'decrementSelectedResult'
699
- });
700
- return;
701
- }
702
- if (state.selectedResult > -1) {
703
- if (event.key === 'ArrowRight') {
704
- const command = state.results[state.selectedResult];
705
- const searchText = state.searchText;
706
- const isCursorAtEnd = searchInputRef.current && state.searchText.length === searchInputRef.current.selectionStart;
707
- const isEverythingSelected = searchInputRef.current && searchInputRef.current.selectionStart === 0 && state.searchText.length === searchInputRef.current.selectionEnd;
708
-
709
- // only allow diving in when cursor is at end of input or when
710
- // the complete text is selected (when browsing through history)
711
- if (!isCursorAtEnd && !isEverythingSelected) return;
712
- unsetHasNetworkError();
713
-
714
- // NOTE: since we need to fetch the "next command", which is an async operation,
715
- // we use a IIFE to process that and eventually update the state.
716
- (async () => {
717
- if (command) {
718
- const nextCommands = await getNextCommandsFromParent(command);
719
- // avoid moving cursor when there are sub-options
720
- if (nextCommands.length > 0) {
721
- // Ensure the search text has not changed while we were loading
722
- // the next results, otherwise we'd interrupt the user.
723
- // Throw away the results in case the search text has changed.
724
- if (state.searchText === searchText) {
725
- dispatch({
726
- type: 'setNextCommands',
727
- payload: {
728
- results: nextCommands
729
- }
730
- });
731
- }
732
- return;
733
- }
734
- }
735
- shake();
736
- })();
737
- return;
738
- }
739
- if (event.key === 'ArrowLeft') {
740
- // go left in stack
741
- const prevCommand = last__default["default"](state.stack);
742
-
743
- // do nothing when we can't go left anymore
744
- if (!prevCommand) return;
745
-
746
- // prevent cursor from jumping a char to the left in text input
747
- event.preventDefault();
748
- dispatch({
749
- type: 'setPrevCommands',
750
- payload: {
751
- searchText: prevCommand.searchText,
752
- results: prevCommand.results
753
- }
754
- });
755
- return;
756
- }
757
- }
758
- }, [getNextCommandsFromParent, props.historyEntries, shake, state, unsetHasNetworkError]);
759
- const handleKeyUp = react$1.useCallback(event => {
760
- // setting the selection can only happen in onKeyUp
761
- if (shouldSelectFieldText.current) {
762
- const input = event.target;
763
- input.focus();
764
- input.select();
765
- shouldSelectFieldText.current = false;
766
- }
767
- if (event.key !== 'Enter' && !isNewWindowCombo.current) return true;
768
-
769
- // User just triggered the search
770
- if (state.selectedResult === -1) return true;
771
-
772
- // User had something selected and wants to go there
773
- execute(state.results[state.selectedResult], {
774
- openInNewTab: isNewWindowCombo.current
775
- });
776
- isNewWindowCombo.current = false;
777
- return true;
778
- }, [execute, state.results, state.selectedResult]);
779
- const handleChange = react$1.useCallback(event => {
780
- const searchText = event.target.value;
781
- if (_trimInstanceProperty__default["default"](searchText).call(searchText).length === 0) {
782
- dispatch({
783
- type: 'reset'
784
- });
785
- return;
786
- }
787
- dispatch({
788
- type: 'searchText',
789
- payload: searchText
790
- });
791
-
792
- // A search via network is only triggered when there
793
- // are more than three characters. So no false loading
794
- // indication is given.
795
- if (_trimInstanceProperty__default["default"](searchText).call(searchText).length > 3) {
796
- setIsLoading();
797
- }
798
- searchFromParent(searchText).then(asyncResults => {
799
- var _context8, _context9;
800
- unsetHasNetworkError();
801
- unsetIsLoading();
802
- const fuse = new Fuse__default["default"](asyncResults, {
803
- keys: [{
804
- name: 'text',
805
- weight: 0.6
806
- }, {
807
- name: 'keywords',
808
- weight: 0.4
809
- }],
810
- minMatchCharLength: 2,
811
- includeScore: true
812
- });
813
- const searchResults = _sliceInstanceProperty__default["default"](_context8 = _filterInstanceProperty__default["default"](_context9 = fuse.search(searchText)
814
- // Filter out results with a matching score over 0.75
815
- ).call(_context9, result => result.score ? result.score < 0.75 : false)
816
- // Keep a maximal of 9 results
817
- ).call(_context8, 0, 9);
818
- dispatch({
819
- type: 'setSearchTextResults',
820
- payload: _mapInstanceProperty__default["default"](searchResults).call(searchResults, result => result.item)
821
- });
822
- }, error => {
823
- unsetIsLoading();
824
- setHasNetworkError();
825
- });
826
- }, [searchFromParent, setHasNetworkError, setIsLoading, unsetHasNetworkError, unsetIsLoading]);
827
- const handleContainerClick = react$1.useCallback(() => {
828
- dispatch({
829
- type: 'resetResultsWhenClosing'
830
- });
831
- onCloseFromParent();
832
- }, [onCloseFromParent]);
833
- const createCommandMouseEnterHandler = react$1.useCallback(index => () => {
834
- // In case the cursor happened to be in a location where a
835
- // result would appear, it would trigger onMouseEnter and the
836
- // result would be selected immediately. This is not something
837
- // a user would expect, hence we prevent it from happening.
838
- // The user has to move the cursor to an option explicitly for
839
- // it to become active. However, the user can always click and
840
- // that action will be triggered.
841
- if (skipNextSelection.current) {
842
- skipNextSelection.current = false;
843
- return;
844
- }
845
-
846
- // sets the selected result, mainly for the hover effect
847
- dispatch({
848
- type: 'selectedResult',
849
- payload: index
850
- });
851
- }, []);
852
- const createCommandClickHandler = react$1.useCallback(command => event => {
853
- execute(command, {
854
- openInNewTab: hasNewWindowModifier(event)
855
- });
856
- }, [execute]);
857
- return jsxRuntime.jsx(dist_commercetoolsFrontendApplicationShell.ButlerContainer, {
858
- onClick: handleContainerClick,
859
- "data-testid": "quick-access",
860
- tabIndex: -1,
861
- children: jsxRuntime.jsxs("div", {
862
- ref: searchContainerRef,
863
- css: /*#__PURE__*/react.css("background-color:", designSystem.designTokens.colorSurface, ";border:0;border-radius:", designSystem.designTokens.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.designTokens.spacingS, ";" + ("" ), "" ),
864
- onClick: event => {
865
- // Avoid closing when the searchContainer itself is clicked
866
- // If we don't do this, then the overlay will close when e.g.
867
- // the search input is clicked.
868
- event.stopPropagation();
869
- event.preventDefault();
870
- },
871
- children: [jsxRuntime.jsxs("div", {
872
- css: _ref,
873
- children: [jsxRuntime.jsx("label", {
874
- htmlFor: "quick-access-search-input",
875
- css: /*#__PURE__*/react.css("align-self:center;padding-left:", designSystem.designTokens.spacingM, ";margin-top:", designSystem.designTokens.spacingS, ";" + ("" ), "" ),
876
- children: jsxRuntime.jsx(icons.SearchIcon, {
877
- color: "neutral60"
878
- })
879
- }), jsxRuntime.jsx("input", {
880
- id: "quick-access-search-input",
881
- ref: searchInputRef,
882
- placeholder: intl.formatMessage(messages.inputPlacehoder),
883
- type: "text",
884
- css: /*#__PURE__*/react.css("width:100%;border:0;outline:0;font-size:22px;font-weight:300;padding:", designSystem.designTokens.spacingM, " ", designSystem.designTokens.spacingM, " ", designSystem.designTokens.spacingS, " ", designSystem.designTokens.spacingS, ";&::placeholder{color:", designSystem.designTokens.colorNeutral60, ";}" + ("" ), "" ),
885
- value: state.searchText,
886
- onChange: handleChange,
887
- onKeyDown: handleKeyDown,
888
- onKeyUp: handleKeyUp,
889
- autoFocus: true,
890
- autoComplete: "off",
891
- "data-testid": "quick-access-search-input"
892
- }), state.isLoading && jsxRuntime.jsx("div", {
893
- css: /*#__PURE__*/react.css("align-self:center;margin-top:", designSystem.designTokens.spacingS, ";margin-right:", designSystem.designTokens.spacingS, ";" + ("" ), "" ),
894
- children: jsxRuntime.jsx(LoadingSpinner__default["default"], {})
895
- })]
896
- }), ((_context0, _context1) => {
897
- if (state.hasNetworkError) return jsxRuntime.jsx("div", {
898
- css: /*#__PURE__*/react.css("overflow:hidden;white-space:nowrap;cursor:default;background:", designSystem.designTokens.colorError, ";text-align:center;text-transform:uppercase;color:", designSystem.designTokens.colorSurface, ";font-size:", designSystem.designTokens.fontSize20, ";padding:", designSystem.designTokens.spacingXs, ";" + ("" ), "" ),
899
- children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread({}, messages.offline))
900
- });
901
- if (state.results.length === 0 && _trimInstanceProperty__default["default"](_context0 = state.searchText).call(_context0).length > 0) return jsxRuntime.jsx("div", {
902
- css: /*#__PURE__*/react.css("overflow:hidden;white-space:nowrap;cursor:default;background:", designSystem.designTokens.colorNeutral, ";color:", designSystem.designTokens.colorSolid, ";text-align:center;text-transform:uppercase;font-size:", designSystem.designTokens.fontSize20, ";padding:", designSystem.designTokens.spacingXs, ";" + ("" ), "" ),
903
- children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread({}, messages.noResults))
904
- });
905
- return _mapInstanceProperty__default["default"](_context1 = state.results).call(_context1, (command, index) => jsxRuntime.jsx(ButlerCommand, {
906
- command: command,
907
- isSelected: state.selectedResult === index,
908
- onMouseEnter: createCommandMouseEnterHandler(index),
909
- onClick: createCommandClickHandler(command)
910
- }, command.id));
911
- })()]
912
- })
913
- });
914
- };
915
- Butler.displayName = 'Butler';
916
- const ButlerWithAnimation = props => jsxRuntime.jsx(react.ClassNames, {
917
- children: _ref2 => {
918
- let css = _ref2.css;
919
- return jsxRuntime.jsx(Butler, _objectSpread(_objectSpread({}, props), {}, {
920
- classNameShakeAnimation: css`
921
- animation-duration: 0.45s;
922
- animation-fill-mode: both;
923
- animation-name: ${shakeAnimation};
924
- `
925
- }));
926
- }
927
- });
928
-
929
- // eslint-disable-next-line import/prefer-default-export
930
-
931
- const permissions = {
932
- ViewOrders: 'ViewOrders',
933
- ManageOrders: 'ManageOrders',
934
- ViewProducts: 'ViewProducts',
935
- ManageProducts: 'ManageProducts',
936
- ViewCategories: 'ViewCategories',
937
- ManageCategories: 'ManageCategories',
938
- ViewCustomers: 'ViewCustomers',
939
- ManageCustomers: 'ManageCustomers',
940
- ViewCustomerGroups: 'ViewCustomerGroups',
941
- ManageCustomerGroups: 'ManageCustomerGroups',
942
- ViewProductDiscounts: 'ViewProductDiscounts',
943
- ManageProductDiscounts: 'ManageProductDiscounts',
944
- ViewDiscountCodes: 'ViewDiscountCodes',
945
- ManageDiscountCodes: 'ManageDiscountCodes',
946
- ViewCartDiscounts: 'ViewCartDiscounts',
947
- ManageCartDiscounts: 'ManageCartDiscounts',
948
- ViewProjectSettings: 'ViewProjectSettings',
949
- ManageProjectSettings: 'ManageProjectSettings',
950
- ViewDeveloperSettings: 'ViewDeveloperSettings',
951
- ManageDeveloperSettings: 'ManageDeveloperSettings',
952
- ViewProductTypes: 'ViewProductTypes',
953
- ManageProductTypes: 'ManageProductTypes'
954
- };
955
-
956
- const actionTypes = {
957
- go: 'go'
958
- };
959
-
960
- function nonNullable(value) {
961
- return value !== null && value !== undefined && typeof value !== 'boolean';
962
- }
963
- const createCommands = _ref => {
964
- var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context0, _context11;
965
- let intl = _ref.intl,
966
- applicationContext = _ref.applicationContext,
967
- featureToggles = _ref.featureToggles,
968
- changeProjectDataLocale = _ref.changeProjectDataLocale;
969
- return _filterInstanceProperty__default["default"](_context = [applicationContext.project && applicationContext.permissions && featureToggles.canViewDashboard && permissions$1.hasSomePermissions([permissions.ViewOrders], applicationContext.permissions) && {
970
- id: 'go/dashboard',
971
- text: intl.formatMessage(messages.openDashboard),
972
- keywords: ['Go to Dashboard'],
973
- action: {
974
- type: actionTypes.go,
975
- to: `/${applicationContext.project.key}/dashboard`
976
- }
977
- }, applicationContext.project && applicationContext.permissions && permissions$1.hasSomePermissions([permissions.ViewProducts], applicationContext.permissions) && {
978
- id: 'go/products',
979
- text: intl.formatMessage(messages.openProducts),
980
- keywords: ['Go to Products'],
981
- action: {
982
- type: actionTypes.go,
983
- to: `/${applicationContext.project.key}/products`
984
- },
985
- subCommands: _filterInstanceProperty__default["default"](_context2 = [permissions$1.hasSomePermissions([permissions.ViewProducts], applicationContext.permissions) && {
986
- id: 'go/products/list',
987
- text: intl.formatMessage(messages.openProductList),
988
- action: {
989
- type: actionTypes.go,
990
- to: `/${applicationContext.project.key}/products`
991
- }
992
- }, permissions$1.hasSomePermissions([permissions.ViewProducts], applicationContext.permissions) && {
993
- id: 'go/products/modified',
994
- text: intl.formatMessage(messages.openModifiedProducts),
995
- action: {
996
- type: actionTypes.go,
997
- to: `/${applicationContext.project.key}/products/modified`
998
- }
999
- }, permissions$1.hasSomePermissions([permissions.ViewProducts], applicationContext.permissions) && featureToggles.pimSearch && {
1000
- id: 'go/products/pim-search',
1001
- text: intl.formatMessage(messages.openPimSearch),
1002
- action: {
1003
- type: actionTypes.go,
1004
- to: `/${applicationContext.project.key}/products`
1005
- }
1006
- }, permissions$1.hasSomePermissions([permissions.ManageProducts], applicationContext.permissions) && {
1007
- id: 'go/products/add',
1008
- text: intl.formatMessage(messages.openAddProducts),
1009
- action: {
1010
- type: actionTypes.go,
1011
- to: `/${applicationContext.project.key}/products/new`
1012
- }
1013
- }]).call(_context2, nonNullable)
1014
- }, applicationContext.project && applicationContext.permissions && permissions$1.hasSomePermissions([permissions.ViewCategories], applicationContext.permissions) && {
1015
- id: 'go/categories',
1016
- text: intl.formatMessage(messages.openCategories),
1017
- keywords: ['Go to Categories'],
1018
- action: {
1019
- type: actionTypes.go,
1020
- to: `/${applicationContext.project.key}/categories`
1021
- },
1022
- subCommands: _filterInstanceProperty__default["default"](_context3 = [permissions$1.hasSomePermissions([permissions.ViewCategories], applicationContext.permissions) && {
1023
- id: 'go/categories/list',
1024
- text: intl.formatMessage(messages.openCategoriesList),
1025
- action: {
1026
- type: actionTypes.go,
1027
- to: `/${applicationContext.project.key}/categories?mode=list`
1028
- }
1029
- }, permissions$1.hasSomePermissions([permissions.ViewCategories], applicationContext.permissions) && {
1030
- id: 'go/categories/search',
1031
- text: intl.formatMessage(messages.openCategoriesSearch),
1032
- action: {
1033
- type: actionTypes.go,
1034
- to: `/${applicationContext.project.key}/categories?mode=search`
1035
- }
1036
- }, permissions$1.hasSomePermissions([permissions.ManageCategories], applicationContext.permissions) && {
1037
- id: 'go/categories/add',
1038
- text: intl.formatMessage(messages.openAddCategory),
1039
- action: {
1040
- type: actionTypes.go,
1041
- to: `/${applicationContext.project.key}/categories/new`
1042
- }
1043
- }]).call(_context3, nonNullable)
1044
- }, applicationContext.project && applicationContext.permissions && permissions$1.hasSomePermissions([permissions.ViewCustomers, permissions.ViewCustomerGroups], applicationContext.permissions) && {
1045
- id: 'go/customers',
1046
- text: intl.formatMessage(messages.openCustomers),
1047
- keywords: ['Go to Customers'],
1048
- action: {
1049
- type: actionTypes.go,
1050
- to: `/${applicationContext.project.key}/customers`
1051
- },
1052
- subCommands: _filterInstanceProperty__default["default"](_context4 = [permissions$1.hasSomePermissions([permissions.ViewCustomers], applicationContext.permissions) && {
1053
- id: 'go/customers/list',
1054
- text: intl.formatMessage(messages.openCustomersList),
1055
- action: {
1056
- type: actionTypes.go,
1057
- to: `/${applicationContext.project.key}/customers`
1058
- }
1059
- }, permissions$1.hasSomePermissions([permissions.ManageCustomers], applicationContext.permissions) && {
1060
- id: 'go/customers/new',
1061
- text: intl.formatMessage(messages.openAddCustomer),
1062
- action: {
1063
- type: actionTypes.go,
1064
- to: `/${applicationContext.project.key}/customers/new`
1065
- }
1066
- }, permissions$1.hasSomePermissions([permissions.ViewCustomerGroups], applicationContext.permissions) && {
1067
- id: 'go/customer/customer-groups',
1068
- text: intl.formatMessage(messages.openCustomerGroupsList),
1069
- action: {
1070
- type: actionTypes.go,
1071
- to: `/${applicationContext.project.key}/customers/customer-groups`
1072
- }
1073
- }, permissions$1.hasSomePermissions([permissions.ManageCustomerGroups], applicationContext.permissions) && {
1074
- id: 'go/customers/customer-groups/add',
1075
- text: intl.formatMessage(messages.openAddCustomerGroup),
1076
- action: {
1077
- type: actionTypes.go,
1078
- to: `/${applicationContext.project.key}/customers/customer-groups/new`
1079
- }
1080
- }]).call(_context4, nonNullable)
1081
- }, applicationContext.project && applicationContext.permissions && permissions$1.hasSomePermissions([permissions.ViewOrders], applicationContext.permissions) && {
1082
- id: 'go/orders',
1083
- text: intl.formatMessage(messages.openOrders),
1084
- keywords: ['Go to Orders'],
1085
- action: {
1086
- type: actionTypes.go,
1087
- to: `/${applicationContext.project.key}/orders`
1088
- },
1089
- subCommands: _filterInstanceProperty__default["default"](_context5 = [permissions$1.hasSomePermissions([permissions.ViewOrders], applicationContext.permissions) && {
1090
- id: 'go/orders/list',
1091
- text: intl.formatMessage(messages.openOrdersList),
1092
- action: {
1093
- type: actionTypes.go,
1094
- to: `/${applicationContext.project.key}/orders`
1095
- }
1096
- }, permissions$1.hasSomePermissions([permissions.ManageOrders], applicationContext.permissions) && {
1097
- id: 'go/orders/add',
1098
- text: intl.formatMessage(messages.openAddOrder),
1099
- action: {
1100
- type: actionTypes.go,
1101
- to: `/${applicationContext.project.key}/orders/new`
1102
- }
1103
- }]).call(_context5, nonNullable)
1104
- }, applicationContext.project && applicationContext.permissions && permissions$1.hasSomePermissions([permissions.ViewDiscountCodes, permissions.ViewProductDiscounts, permissions.ViewCartDiscounts], applicationContext.permissions) && {
1105
- id: 'go/discounts',
1106
- text: intl.formatMessage(messages.openDiscounts),
1107
- keywords: ['Go to Discounts'],
1108
- action: {
1109
- type: actionTypes.go,
1110
- to: `/${applicationContext.project.key}/discounts`
1111
- },
1112
- subCommands: _filterInstanceProperty__default["default"](_context6 = [permissions$1.hasSomePermissions([permissions.ViewProductDiscounts], applicationContext.permissions) && {
1113
- id: 'go/discounts/products/list',
1114
- text: intl.formatMessage(messages.openProductDiscountsList),
1115
- action: {
1116
- type: actionTypes.go,
1117
- to: `/${applicationContext.project.key}/discounts/products`
1118
- }
1119
- }, permissions$1.hasSomePermissions([permissions.ViewCartDiscounts], applicationContext.permissions) && {
1120
- id: 'go/discounts/carts/list',
1121
- text: intl.formatMessage(messages.openCartDiscountsList),
1122
- action: {
1123
- type: actionTypes.go,
1124
- to: `/${applicationContext.project.key}/discounts/carts`
1125
- }
1126
- }, permissions$1.hasSomePermissions([permissions.ViewDiscountCodes], applicationContext.permissions) && {
1127
- id: 'go/discounts/codes/list',
1128
- text: intl.formatMessage(messages.openDiscountCodesList),
1129
- action: {
1130
- type: actionTypes.go,
1131
- to: `/${applicationContext.project.key}/discounts/codes`
1132
- }
1133
- }, permissions$1.hasSomePermissions([permissions.ManageProductDiscounts, permissions.ManageDiscountCodes, permissions.ManageCartDiscounts], applicationContext.permissions) && {
1134
- id: 'go/discounts/add',
1135
- text: intl.formatMessage(messages.openAddDiscount),
1136
- action: {
1137
- type: actionTypes.go,
1138
- to: `/${applicationContext.project.key}/discounts/new`
1139
- },
1140
- subCommands: _filterInstanceProperty__default["default"](_context7 = [permissions$1.hasSomePermissions([permissions.ManageProductDiscounts], applicationContext.permissions) && {
1141
- id: 'go/discounts/product/add',
1142
- text: intl.formatMessage(messages.openAddProductDiscount),
1143
- action: {
1144
- type: actionTypes.go,
1145
- to: `/${applicationContext.project.key}/discounts/products/new`
1146
- }
1147
- }, permissions$1.hasSomePermissions([permissions.ManageCartDiscounts], applicationContext.permissions) && {
1148
- id: 'go/discounts/cart/add',
1149
- text: intl.formatMessage(messages.openAddCartDiscount),
1150
- action: {
1151
- type: actionTypes.go,
1152
- to: `/${applicationContext.project.key}/discounts/carts/new`
1153
- }
1154
- }, permissions$1.hasSomePermissions([permissions.ManageDiscountCodes], applicationContext.permissions) && {
1155
- id: 'go/discounts/code/add',
1156
- text: intl.formatMessage(messages.openAddCartDiscount),
1157
- action: {
1158
- type: actionTypes.go,
1159
- to: `/${applicationContext.project.key}/discounts/codes/new`
1160
- }
1161
- }]).call(_context7, nonNullable)
1162
- }]).call(_context6, nonNullable)
1163
- }, applicationContext.project && applicationContext.permissions && permissions$1.hasSomePermissions([permissions.ViewProjectSettings, permissions.ViewDeveloperSettings, permissions.ViewProductTypes], applicationContext.permissions) && {
1164
- id: 'go/settings',
1165
- text: intl.formatMessage(messages.openSettings),
1166
- keywords: ['Go to Settings'],
1167
- action: {
1168
- type: actionTypes.go,
1169
- to: `/${applicationContext.project.key}/settings/project`
1170
- },
1171
- subCommands: _filterInstanceProperty__default["default"](_context8 = [permissions$1.hasSomePermissions([permissions.ViewProjectSettings, permissions.ManageProjectSettings], applicationContext.permissions) && {
1172
- id: 'go/settings/project',
1173
- text: intl.formatMessage(messages.openProjectSettings),
1174
- action: {
1175
- type: actionTypes.go,
1176
- to: `/${applicationContext.project.key}/settings/project`
1177
- },
1178
- subCommands: _filterInstanceProperty__default["default"](_context9 = [{
1179
- id: 'go/settings/project/international',
1180
- text: intl.formatMessage(messages.openProjectSettingsInternationalTab),
1181
- action: {
1182
- type: actionTypes.go,
1183
- to: `/${applicationContext.project.key}/settings/project/international`
1184
- }
1185
- }, {
1186
- id: 'go/settings/project/taxes',
1187
- text: intl.formatMessage(messages.openProjectSettingsTaxesTab),
1188
- action: {
1189
- type: actionTypes.go,
1190
- to: `/${applicationContext.project.key}/settings/project/taxes`
1191
- }
1192
- }, {
1193
- id: 'go/settings/project/shipping-methods',
1194
- text: intl.formatMessage(messages.openProjectSettingsShippingMethodsTab),
1195
- action: {
1196
- type: actionTypes.go,
1197
- to: `/${applicationContext.project.key}/settings/project/shipping-methods`
1198
- }
1199
- }, {
1200
- id: 'go/settings/project/channels',
1201
- text: intl.formatMessage(messages.openProjectSettingsChannelsTab),
1202
- action: {
1203
- type: actionTypes.go,
1204
- to: `/${applicationContext.project.key}/settings/project/channels`
1205
- }
1206
- }, {
1207
- id: 'go/settings/project/stores',
1208
- text: intl.formatMessage(messages.openProjectSettingsStoresTab),
1209
- action: {
1210
- type: actionTypes.go,
1211
- to: `/${applicationContext.project.key}/settings/project/stores`
1212
- }
1213
- }]).call(_context9, nonNullable)
1214
- }, permissions$1.hasSomePermissions([permissions.ViewProductTypes], applicationContext.permissions) && {
1215
- id: 'go/settings/product-types',
1216
- text: intl.formatMessage(messages.openProductTypesSettings),
1217
- action: {
1218
- type: actionTypes.go,
1219
- to: `/${applicationContext.project.key}/settings/product-types`
1220
- }
1221
- }, permissions$1.hasSomePermissions([permissions.ViewDeveloperSettings], applicationContext.permissions) && {
1222
- id: 'go/settings/developer',
1223
- text: intl.formatMessage(messages.openDeveloperSettings),
1224
- action: {
1225
- type: actionTypes.go,
1226
- to: `/${applicationContext.project.key}/settings/developer`
1227
- },
1228
- subCommands: _filterInstanceProperty__default["default"](_context0 = [permissions$1.hasSomePermissions([permissions.ViewDeveloperSettings], applicationContext.permissions) && {
1229
- id: 'go/settings/developer/api-clients/list',
1230
- text: intl.formatMessage(messages.openApiClientsList),
1231
- action: {
1232
- type: actionTypes.go,
1233
- to: `/${applicationContext.project.key}/settings/developer/api-clients`
1234
- }
1235
- }, permissions$1.hasSomePermissions([permissions.ManageDeveloperSettings], applicationContext.permissions) && {
1236
- id: 'go/settings/developer/api-clients/add',
1237
- text: intl.formatMessage(messages.openAddApiClient),
1238
- action: {
1239
- type: actionTypes.go,
1240
- to: `/${applicationContext.project.key}/settings/developer/api-clients/new`
1241
- }
1242
- }]).call(_context0, nonNullable)
1243
- }, featureToggles.customApplications && permissions$1.hasSomePermissions([permissions.ManageProjectSettings], applicationContext.permissions) && {
1244
- id: 'go/settings/custom-applications',
1245
- text: intl.formatMessage(messages.openCustomApplicationsSettings),
1246
- action: {
1247
- type: actionTypes.go,
1248
- to: `/${applicationContext.project.key}/settings/custom-applications`
1249
- }
1250
- }]).call(_context8, nonNullable)
1251
- }, applicationContext.project && applicationContext.project.languages && applicationContext.project.languages.length > 1 && {
1252
- id: 'action/set-resource-language',
1253
- text: intl.formatMessage(messages.setResourceLanguage),
1254
- keywords: ['set resource locale', 'set project data language', 'set project data locale'],
1255
- action: () => void 0,
1256
- // We would know these statically, but we define them here as we don't
1257
- // want to include them in the top-level search results
1258
- subCommands: () => {
1259
- var _context1, _context10;
1260
- return _Promise__default["default"].resolve(_filterInstanceProperty__default["default"](_context1 = _mapInstanceProperty__default["default"](_context10 = applicationContext.project ? applicationContext.project.languages : []).call(_context10, language => changeProjectDataLocale && {
1261
- id: `action/set-resource-language/${language}`,
1262
- text: commonTags.oneLineTrim`
1263
- ${language}
1264
- ${language === applicationContext.dataLocale ? ' (active)' : ''}
1265
- `,
1266
- action: () => {
1267
- changeProjectDataLocale(language);
1268
-
1269
- // We reload, since ProjectDataLocale is written in a way where
1270
- // only the tree under the parent container reloads, but
1271
- // not all of them reload.
1272
- // So this action would seem like it had not effect, unless we
1273
- // reload
1274
- location.location.reload();
1275
- }
1276
- })).call(_context1, nonNullable));
1277
- }
1278
- }, {
1279
- id: 'go/support',
1280
- text: intl.formatMessage(messages.openSupport),
1281
- keywords: ['Go to support'],
1282
- action: {
1283
- type: actionTypes.go,
1284
- to: constants.SUPPORT_PORTAL_URL
1285
- }
1286
- }, {
1287
- id: 'go/account-profile',
1288
- text: intl.formatMessage(messages.openMyProfile),
1289
- keywords: ['Go to user account', 'Go to profile', 'Open profile'],
1290
- action: {
1291
- type: actionTypes.go,
1292
- to: `/account/profile`
1293
- }
1294
- }, {
1295
- id: 'go/privacy-policy',
1296
- text: intl.formatMessage(messages.showPrivacyPolicy),
1297
- keywords: ['Open Privacy Policy'],
1298
- action: {
1299
- type: actionTypes.go,
1300
- to: 'https://commercetools.com/privacy#suppliers'
1301
- }
1302
- }, {
1303
- id: 'go/logout',
1304
- text: intl.formatMessage(messages.logout),
1305
- keywords: ['Sign out'],
1306
- action: {
1307
- type: actionTypes.go,
1308
- to: `/logout?reason=${constants.LOGOUT_REASONS.USER}`
1309
- }
1310
- }, {
1311
- id: 'go/manage-projects',
1312
- text: intl.formatMessage(messages.openManageProjects),
1313
- keywords: ['Go to manage projects', 'Go to projects', 'Open projects list'],
1314
- action: {
1315
- type: actionTypes.go,
1316
- to: `/account/projects`
1317
- }
1318
- }, {
1319
- id: 'go/manage-organizations',
1320
- text: intl.formatMessage(messages.openManageOrganizations),
1321
- keywords: ['Go to manage organizations', 'Go to organizations', 'Open organizations list'],
1322
- action: {
1323
- type: actionTypes.go,
1324
- to: `/account/organizations`
1325
- }
1326
- }, ...(applicationContext.user ? _mapInstanceProperty__default["default"](_context11 = applicationContext.user.projects.results).call(_context11, userProject => ({
1327
- id: `go/project(${userProject.key})`,
1328
- text: intl.formatMessage(messages.useProject, {
1329
- projectName: userProject.name
1330
- }),
1331
- keywords: [userProject.key],
1332
- action: () => {
1333
- // Switching projects needs a full redirect so that
1334
- // the feature flags are reloaded (and things caches get destroyed)
1335
- window.location.href = `/${userProject.key}`;
1336
- }
1337
- })) : [])]).call(_context, nonNullable);
1338
- };
1339
-
1340
- const STORAGE_KEY = 'quickAccessHistoryEntries';
1341
- const saveHistoryEntries = historyEntries => {
1342
- try {
1343
- window.sessionStorage.setItem(STORAGE_KEY, _JSON$stringify__default["default"](historyEntries));
1344
- return true;
1345
- } catch (error) {
1346
- return false;
1347
- }
1348
- };
1349
- const loadHistoryEntries = () => {
1350
- try {
1351
- const value = sessionStorage.getItem(STORAGE_KEY);
1352
- return value ? JSON.parse(value) : [];
1353
- } catch (error) {
1354
- return [];
1355
- }
1356
- };
1357
-
1358
- 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 } } } };
1359
- const createProductVariantSubCommands = _ref => {
1360
- let intl = _ref.intl,
1361
- applicationContext = _ref.applicationContext,
1362
- productId = _ref.productId,
1363
- variantId = _ref.variantId;
1364
- const canViewProducts = permissions$1.hasSomePermissions([permissions.ViewProducts], applicationContext.permissions);
1365
- if (!canViewProducts || !applicationContext.project) return [];
1366
- return [{
1367
- id: `go/product(${productId})/variant(${variantId})/attributes`,
1368
- text: intl.formatMessage(messages.showProductVariantAttributes),
1369
- action: {
1370
- type: actionTypes.go,
1371
- to: commonTags.oneLineTrim`
1372
- /${applicationContext.project.key}
1373
- /products
1374
- /${productId}
1375
- /variants
1376
- /${variantId}
1377
- /attributes
1378
- `
1379
- }
1380
- }, {
1381
- id: `go/product(${productId})/variant${variantId}/images`,
1382
- text: intl.formatMessage(messages.showProductVariantImages),
1383
- action: {
1384
- type: actionTypes.go,
1385
- to: commonTags.oneLineTrim`
1386
- /${applicationContext.project.key}
1387
- /products
1388
- /${productId}
1389
- /variants
1390
- /${variantId}
1391
- /images
1392
- `
1393
- }
1394
- }, {
1395
- id: `go/product(${productId})/variant(${variantId})/prices`,
1396
- text: intl.formatMessage(messages.showProductVariantPrices),
1397
- action: {
1398
- type: actionTypes.go,
1399
- to: commonTags.oneLineTrim`
1400
- /${applicationContext.project.key}
1401
- /products
1402
- /${productId}
1403
- /variants
1404
- /${variantId}
1405
- /prices
1406
- `
1407
- }
1408
- }, {
1409
- id: `go/product(${productId})/variant(${variantId})/inventory`,
1410
- text: intl.formatMessage(messages.showProductVariantInventory),
1411
- action: {
1412
- type: actionTypes.go,
1413
- to: commonTags.oneLineTrim`
1414
- /${applicationContext.project.key}
1415
- /products
1416
- /${productId}
1417
- /variants
1418
- /${variantId}
1419
- /inventory
1420
- `
1421
- }
1422
- }];
1423
- };
1424
- const formatVariantMessage = (variant, intl) => {
1425
- if (variant.sku) return intl.formatMessage(messages.openVariantBySku, {
1426
- sku: variant.sku
1427
- });
1428
- if (variant.key) return intl.formatMessage(messages.openVariantByKey, {
1429
- key: variant.key
1430
- });
1431
- return intl.formatMessage(messages.openVariantById, {
1432
- id: variant.id
1433
- });
1434
- };
1435
- const createProductVariantListSubCommands = async _ref2 => {
1436
- let intl = _ref2.intl,
1437
- applicationContext = _ref2.applicationContext,
1438
- productId = _ref2.productId,
1439
- execQuery = _ref2.execQuery;
1440
- const canViewProducts = permissions$1.hasSomePermissions([permissions.ViewProducts], applicationContext.permissions);
1441
- if (!canViewProducts) return [];
1442
- const data = await execQuery(QuickAccessProductQuery, {
1443
- productId
1444
- }, {
1445
- target: constants.GRAPHQL_TARGETS.COMMERCETOOLS_PLATFORM
1446
- });
1447
- if (data && data.product && data.product.masterData && data.product.masterData.staged && applicationContext.project) {
1448
- var _context;
1449
- const projectKey = applicationContext.project.key;
1450
- return _mapInstanceProperty__default["default"](_context = data.product.masterData.staged.allVariants).call(_context, variant => ({
1451
- id: `go/product(${productId})/variant(${variant.id})`,
1452
- text: formatVariantMessage(variant, intl),
1453
- subCommands: createProductVariantSubCommands({
1454
- intl,
1455
- applicationContext,
1456
- productId,
1457
- variantId: variant.id
1458
- }),
1459
- action: {
1460
- type: actionTypes.go,
1461
- to: commonTags.oneLineTrim`
1462
- /${projectKey}
1463
- /products
1464
- /${productId}
1465
- /variants
1466
- /${variant.id}
1467
- `
1468
- }
1469
- }));
1470
- }
1471
- return [];
1472
- };
1473
- const createProductTabsSubCommands = _ref3 => {
1474
- let intl = _ref3.intl,
1475
- applicationContext = _ref3.applicationContext,
1476
- productId = _ref3.productId;
1477
- const canViewProducts = permissions$1.hasSomePermissions([permissions.ViewProducts], applicationContext.permissions);
1478
- if (!canViewProducts || !applicationContext.project) return [];
1479
- return [{
1480
- id: `go/product(${productId})/general`,
1481
- text: intl.formatMessage(messages.openProductVariantGeneral),
1482
- action: {
1483
- type: actionTypes.go,
1484
- to: commonTags.oneLineTrim`
1485
- /${applicationContext.project.key}
1486
- /products
1487
- /${productId}
1488
- /general
1489
- `
1490
- }
1491
- }, {
1492
- id: `go/product(${productId})/variants`,
1493
- text: intl.formatMessage(messages.openProductVariantList),
1494
- action: {
1495
- type: actionTypes.go,
1496
- to: commonTags.oneLineTrim`
1497
- /${applicationContext.project.key}
1498
- /products
1499
- /${productId}
1500
- /variants
1501
- `
1502
- },
1503
- subCommands: execQuery => createProductVariantListSubCommands({
1504
- intl,
1505
- applicationContext,
1506
- productId,
1507
- execQuery
1508
- })
1509
- }, {
1510
- id: `go/product(${productId})/search`,
1511
- text: intl.formatMessage(messages.openProductVariantSearch),
1512
- action: {
1513
- type: actionTypes.go,
1514
- to: commonTags.oneLineTrim`
1515
- /${applicationContext.project.key}
1516
- /products
1517
- /${productId}
1518
- /search
1519
- `
1520
- }
1521
- }];
1522
- };
1523
-
1524
- const sanitize = param => param
1525
- // Replace all \ with \\ (to prevent generate escape characters)
1526
- .replace(/\\/g, '\\\\')
1527
- // Replace all " with \"
1528
- .replace(/"/g, '\\"');
1529
- const flattenCommands = async (results, execQuery) => {
1530
- async function flatten(commands) {
1531
- return _reduceInstanceProperty__default["default"](commands).call(commands, async (prevPromise, command) => {
1532
- const prevResults = await prevPromise;
1533
- if (command.subCommands) {
1534
- if (typeof command.subCommands === 'function') {
1535
- const subCommands = await command.subCommands(execQuery);
1536
- const flattenSubCommands = await flatten(subCommands);
1537
- return [...prevResults, command, ...flattenSubCommands];
1538
- }
1539
- const flattenSubCommands = await flatten(command.subCommands);
1540
- return [...prevResults, command, ...flattenSubCommands];
1541
- }
1542
- return [...prevResults, command];
1543
- }, _Promise__default["default"].resolve([]));
1544
- }
1545
- return await flatten(results);
1546
- };
1547
-
1548
- // Once ui-kit exposes its fallback mechanism, we can use the same one here
1549
- const translate = (nameAllLocales, projectDataLocale) => {
1550
- const matchedTranslation = _findInstanceProperty__default["default"](nameAllLocales).call(nameAllLocales, translation => translation.locale === projectDataLocale && translation.value);
1551
- if (matchedTranslation) return matchedTranslation.value;
1552
-
1553
- // Fall back to the first available locale
1554
- if (nameAllLocales.length > 0) return nameAllLocales[0].value;
1555
- return '';
1556
- };
1557
-
1558
- 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 } } } };
1559
- const searchProductIdsAction = (searchText, projectKey, dataLocale) => sdk.actions.post({
1560
- uri: `/${projectKey}/search/products`,
1561
- mcApiProxyTarget: constants.MC_API_PROXY_TARGETS.PIM_SEARCH,
1562
- payload: {
1563
- query: {
1564
- fullText: {
1565
- field: 'name',
1566
- language: dataLocale,
1567
- value: searchText
1568
- }
1569
- },
1570
- sort: [{
1571
- field: 'name',
1572
- language: dataLocale,
1573
- order: 'desc'
1574
- }],
1575
- limit: 9,
1576
- offset: 0
1577
- }
1578
- });
1579
- const pimIndexerStatusAction = (projectKey, dataLocale) =>
1580
- // TODO this should be sdkActions.head()
1581
- // and then we should check whether the response code is
1582
- // - 200 meaning the project is indexed
1583
- // - 404 meaning the project is not indexed
1584
- //
1585
- // But there is a problem in tne node-sdk client as it tries to
1586
- // .json()-parse the response to HEAD requests which results in an
1587
- // error, so we send a regular request for now and limit to no results
1588
- // instead to keep the payload minimal
1589
- sdk.actions.post({
1590
- uri: `/${projectKey}/search/products`,
1591
- mcApiProxyTarget: constants.MC_API_PROXY_TARGETS.PIM_SEARCH,
1592
- payload: {
1593
- query: {
1594
- fullText: {
1595
- field: 'name',
1596
- language: dataLocale,
1597
- value: 'availability-check'
1598
- }
1599
- },
1600
- limit: 0,
1601
- offset: 0
1602
- }
1603
- });
1604
- const QuickAccess = props => {
1605
- const _useState = react$1.useState(loadHistoryEntries()),
1606
- _useState2 = _slicedToArray(_useState, 2),
1607
- historyEntries = _useState2[0],
1608
- setHistoryEntries = _useState2[1];
1609
- const handleHistoryEntriesChange = react$1.useCallback(entries => {
1610
- // Keep the history in sync with the session storage
1611
- saveHistoryEntries(entries);
1612
- setHistoryEntries(entries);
1613
- }, []);
1614
- const history = reactRouterDom.useHistory();
1615
- const apolloClient = react$2.useApolloClient();
1616
- const intl = reactIntl.useIntl();
1617
- const _useFeatureToggles = reactBroadcast.useFeatureToggles({
1618
- pimSearch: true,
1619
- customApplications: true,
1620
- canViewDashboard: true
1621
- }),
1622
- _useFeatureToggles2 = _slicedToArray(_useFeatureToggles, 3),
1623
- isPimSearchEnabled = _useFeatureToggles2[0],
1624
- isCustomApplicationsEnabled = _useFeatureToggles2[1],
1625
- isCanViewDashboardEnabled = _useFeatureToggles2[2];
1626
- const applicationContext = applicationShellConnectors.useApplicationContext();
1627
-
1628
- // Destructure functions from props to reference them in the hook dependency list
1629
- const onPimIndexerStateChangeFromParent = props.onPimIndexerStateChange;
1630
- const dispatchFetchProductIds = sdk.useAsyncDispatch();
1631
- const fetchPimSearchProductIds = react$1.useCallback(async searchText => {
1632
- if (applicationContext.project && applicationContext.dataLocale) {
1633
- var _context;
1634
- const result = await dispatchFetchProductIds(searchProductIdsAction(searchText, applicationContext.project.key, applicationContext.dataLocale));
1635
- return result && result.hits ? _mapInstanceProperty__default["default"](_context = result.hits).call(_context, hit => hit.id) : [];
1636
- }
1637
- return [];
1638
- }, [applicationContext.dataLocale, applicationContext.project, dispatchFetchProductIds]);
1639
- const dispatchFetchPimIndexerStatus = sdk.useAsyncDispatch();
1640
- const fetchPimIndexerStatus = react$1.useCallback(async () => {
1641
- if (applicationContext.project && applicationContext.dataLocale) {
1642
- try {
1643
- dispatchFetchPimIndexerStatus(pimIndexerStatusAction(applicationContext.project.key, applicationContext.dataLocale));
1644
- return dist_commercetoolsFrontendApplicationShell.pimIndexerStates.INDEXED;
1645
- } catch (error) {
1646
- // project is not using pim-indexer when response error code is 404,
1647
- // but we treat all errors as non-indexed as a safe guard, so we're
1648
- // not checking the response error code at all
1649
- return dist_commercetoolsFrontendApplicationShell.pimIndexerStates.NOT_INDEXED;
1650
- }
1651
- }
1652
- return dist_commercetoolsFrontendApplicationShell.pimIndexerStates.NOT_INDEXED;
1653
- }, [applicationContext.dataLocale, applicationContext.project, dispatchFetchPimIndexerStatus]);
1654
- const getProjectIndexStatus = react$1.useCallback(async () => {
1655
- // skip when there is no project
1656
- if (!applicationContext.project) return dist_commercetoolsFrontendApplicationShell.pimIndexerStates.NOT_INDEXED;
1657
- const canViewProducts = permissions$1.hasSomePermissions([permissions.ViewProducts], applicationContext.permissions);
1658
-
1659
- // skip checking when user can't view products anyways
1660
- if (!canViewProducts) return dist_commercetoolsFrontendApplicationShell.pimIndexerStates.NOT_INDEXED;
1661
- return await fetchPimIndexerStatus();
1662
- }, [applicationContext.permissions, applicationContext.project, fetchPimIndexerStatus]);
1663
- react$1.useEffect(() => {
1664
- if (props.pimIndexerState === dist_commercetoolsFrontendApplicationShell.pimIndexerStates.UNCHECKED) {
1665
- getProjectIndexStatus().then(status => {
1666
- onPimIndexerStateChangeFromParent(status);
1667
- });
1668
- }
1669
- // eslint-disable-next-line react-hooks/exhaustive-deps
1670
- }, []); // <-- run only once, when component mounts
1671
-
1672
- const execQuery = react$1.useCallback((Query, variables, context) => apolloClient.query({
1673
- query: Query,
1674
- errorPolicy: 'ignore',
1675
- variables,
1676
- context
1677
- }).then(response => response.data), [apolloClient]);
1678
- const getNextCommands = react$1.useCallback(async command => {
1679
- if (!command.subCommands) return [];
1680
- if (_Array$isArray__default["default"](command.subCommands)) return command.subCommands;
1681
- return await command.subCommands(execQuery);
1682
- }, [execQuery]);
1683
- const getProjectCommands = react$1.useCallback(async searchText => {
1684
- const idsOfProductsMatchingSearchText = props.pimIndexerState === dist_commercetoolsFrontendApplicationShell.pimIndexerStates.INDEXED ? await fetchPimSearchProductIds(searchText) : [];
1685
- const canViewProducts = permissions$1.hasSomePermissions([permissions.ViewProducts], applicationContext.permissions);
1686
- const data = await execQuery(QuickAccessQuery, {
1687
- searchText: sanitize(searchText),
1688
- // Pass conditional arguments to disable some of the queries
1689
- canViewProducts,
1690
- productsWhereClause: `id in (${_mapInstanceProperty__default["default"](idsOfProductsMatchingSearchText).call(idsOfProductsMatchingSearchText, id => _JSON$stringify__default["default"](id)).join(', ')})`,
1691
- includeProductsByIds: Boolean(canViewProducts && idsOfProductsMatchingSearchText.length > 0)
1692
- }, {
1693
- target: constants.GRAPHQL_TARGETS.COMMERCETOOLS_PLATFORM
1694
- });
1695
- const commands = [];
1696
- if (data && data.productByVariantKey && data.productByVariantKey.masterData && data.productByVariantKey.masterData.staged && data.productByVariantKey.masterData.staged.variant && applicationContext.project && applicationContext.dataLocale) {
1697
- const productId = data.productByVariantKey.id;
1698
- const variantId = data.productByVariantKey.masterData.staged.variant.id;
1699
- const variantKey = data.productByVariantKey.masterData.staged.variant.key;
1700
- commands.push({
1701
- id: `go/product-variant-by-key/product(${productId}/variant(${variantId})`,
1702
- text: intl.formatMessage(messages.showProductVariant, {
1703
- variantName: translate(data.productByVariantKey.masterData.staged.nameAllLocales, applicationContext.dataLocale)
1704
- }),
1705
- keywords: variantKey ? [variantKey] : undefined,
1706
- action: {
1707
- type: actionTypes.go,
1708
- to: commonTags.oneLineTrim`
1709
- /${applicationContext.project.key}
1710
- /products
1711
- /${productId}
1712
- /variants
1713
- /${variantId}
1714
- `
1715
- },
1716
- subCommands: createProductVariantSubCommands({
1717
- intl,
1718
- applicationContext,
1719
- productId,
1720
- variantId
1721
- })
1722
- });
1723
- }
1724
- if (data && data.productByVariantSku && data.productByVariantSku.masterData && data.productByVariantSku.masterData.staged && data.productByVariantSku.masterData.staged.variant && applicationContext.project && applicationContext.dataLocale) {
1725
- const productId = data.productByVariantSku.id;
1726
- const variantId = data.productByVariantSku.masterData.staged.variant.id;
1727
- commands.push({
1728
- id: `go/product-variant-by-sku/product(${productId})/variant(${variantId})`,
1729
- text: intl.formatMessage(messages.showProductVariant, {
1730
- variantName: data.productByVariantSku.masterData.staged.variant.sku
1731
- }),
1732
- action: {
1733
- type: actionTypes.go,
1734
- to: commonTags.oneLineTrim`
1735
- /${applicationContext.project.key}
1736
- /products
1737
- /${productId}
1738
- /variants
1739
- /${variantId}
1740
- `
1741
- },
1742
- subCommands: createProductVariantSubCommands({
1743
- intl,
1744
- applicationContext,
1745
- productId,
1746
- variantId
1747
- })
1748
- });
1749
- }
1750
- if (data && data.productById && data.productById.masterData && data.productById.masterData.staged && data.productById.masterData.staged.nameAllLocales && applicationContext.project && applicationContext.dataLocale) {
1751
- const productId = data.productById.id;
1752
- commands.push({
1753
- id: `go/product-by-id/product(${productId})`,
1754
- text: intl.formatMessage(messages.showProduct, {
1755
- productName: translate(data.productById.masterData.staged.nameAllLocales, applicationContext.dataLocale)
1756
- }),
1757
- keywords: [productId],
1758
- action: {
1759
- type: actionTypes.go,
1760
- to: `/${applicationContext.project.key}/products/${productId}`
1761
- },
1762
- subCommands: createProductTabsSubCommands({
1763
- intl,
1764
- applicationContext,
1765
- productId
1766
- })
1767
- });
1768
- }
1769
- if (data && data.productsByIds && data.productsByIds.results) {
1770
- var _context2;
1771
- _forEachInstanceProperty__default["default"](_context2 = data.productsByIds.results).call(_context2, product => {
1772
- if (product.masterData.staged && applicationContext.project && applicationContext.dataLocale) {
1773
- commands.push({
1774
- id: `go/product-by-search-text/product(${product.id})`,
1775
- text: intl.formatMessage(messages.showProduct, {
1776
- productName: translate(product.masterData.staged.nameAllLocales, applicationContext.dataLocale)
1777
- }),
1778
- keywords: [product.id],
1779
- action: {
1780
- type: actionTypes.go,
1781
- to: `/${applicationContext.project.key}/products/${product.id}`
1782
- },
1783
- subCommands: createProductTabsSubCommands({
1784
- intl,
1785
- applicationContext,
1786
- productId: product.id
1787
- })
1788
- });
1789
- }
1790
- });
1791
- }
1792
- if (data && data.productByKey && applicationContext.project && applicationContext.dataLocale) {
1793
- const productId = data.productByKey.id;
1794
- commands.push({
1795
- id: `go/product-by-key/product(${productId})`,
1796
- text: intl.formatMessage(messages.showProduct, {
1797
- productName: searchText
1798
- }),
1799
- action: {
1800
- type: actionTypes.go,
1801
- to: `/${applicationContext.project.key}/products/${productId}`
1802
- },
1803
- subCommands: createProductTabsSubCommands({
1804
- intl,
1805
- applicationContext,
1806
- productId
1807
- })
1808
- });
1809
- }
1810
- return commands;
1811
- }, [applicationContext, execQuery, fetchPimSearchProductIds, intl, props.pimIndexerState]);
1812
- const debouncedGetProjectCommands = debounce__default["default"](getProjectCommands, 200, {
1813
- cancelObj: 'canceled'
1814
- });
1815
- const search = react$1.useCallback(async searchText => {
1816
- const generalCommands = createCommands({
1817
- applicationContext,
1818
- changeProjectDataLocale: props.onChangeProjectDataLocale,
1819
- intl,
1820
- featureToggles: {
1821
- pimSearch: isPimSearchEnabled,
1822
- customApplications: isCustomApplicationsEnabled,
1823
- canViewDashboard: isCanViewDashboardEnabled
1824
- }
1825
- });
1826
- if (!applicationContext.project) return generalCommands;
1827
-
1828
- // Avoid searching for short texts, as we won't get any good results
1829
- // anyways. This results in commands popping up immediately when the user
1830
- // starts typing, which gives the whole search a much more repsonsive
1831
- // feeling.
1832
- if (_trimInstanceProperty__default["default"](searchText).call(searchText).length < 3) return generalCommands;
1833
- try {
1834
- const projectCommands = await debouncedGetProjectCommands(searchText);
1835
- const allCommands = [...generalCommands, ...projectCommands];
1836
- return await flattenCommands(allCommands, execQuery);
1837
- } catch (error) {
1838
- // When the debounced search is canceled, it throws with "canceled"
1839
- // In that case we know that another search is going to happen
1840
- // and we just resolve with the general commands.
1841
- if (error === 'canceled') return generalCommands;
1842
- throw error;
1843
- }
1844
- }, [applicationContext, debouncedGetProjectCommands, execQuery, intl, isCanViewDashboardEnabled, isCustomApplicationsEnabled, isPimSearchEnabled, props.onChangeProjectDataLocale]);
1845
- const executeCommand = react$1.useCallback((command, meta) => {
1846
- var _context3;
1847
- if (typeof command.action === 'function') {
1848
- // Idea: We could handle these errors and set them on status bar of Butler
1849
- // We can also handle sync/async commands by checking command.action.then
1850
- command.action();
1851
- return;
1852
- }
1853
- // open in new window
1854
- // and always open other pages in a new window
1855
- if (meta.openInNewTab || !_startsWithInstanceProperty__default["default"](_context3 = command.action.to).call(_context3, '/')) {
1856
- // eslint-disable-next-line no-restricted-globals
1857
- open(command.action.to, '_blank');
1858
- } else if (applicationContext.environment.useFullRedirectsForLinks) {
1859
- location.location.replace(command.action.to);
1860
- } else {
1861
- history.push(command.action.to);
1862
- }
1863
- }, [applicationContext.environment.useFullRedirectsForLinks, history]);
1864
- return jsxRuntime.jsx(ButlerWithAnimation, {
1865
- historyEntries: historyEntries,
1866
- onHistoryEntriesChange: handleHistoryEntriesChange,
1867
- search: search,
1868
- executeCommand: executeCommand,
1869
- onClose: props.onClose,
1870
- getNextCommands: getNextCommands
1871
- });
1872
- };
1873
- QuickAccess.displayName = 'QuickAccess';
1874
-
1875
- exports["default"] = QuickAccess;