@strapi/admin 4.14.5 → 4.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/admin/src/StrapiApp.js +13 -12
- package/admin/src/components/AuthenticatedApp.tsx +187 -0
- package/admin/src/components/ConfigurationProvider.tsx +2 -1
- package/admin/src/components/GuidedTour/Homepage.tsx +111 -0
- package/admin/src/components/GuidedTour/Modal.tsx +303 -0
- package/admin/src/components/GuidedTour/Ornaments.tsx +74 -0
- package/admin/src/components/GuidedTour/Provider.tsx +253 -0
- package/admin/src/components/GuidedTour/{layout.js → constants.ts} +13 -3
- package/admin/src/components/LanguageProvider.tsx +1 -0
- package/admin/src/components/Providers.tsx +125 -0
- package/admin/src/components/RBACProvider.tsx +124 -0
- package/admin/src/components/Theme.tsx +4 -2
- package/admin/src/components/ThemeToggleProvider.tsx +23 -9
- package/admin/src/components/__mocks__/{LanguageProvider.js → LanguageProvider.ts} +2 -0
- package/admin/src/{constants.js → constants.ts} +48 -0
- package/admin/src/content-manager/components/BlocksEditor/Toolbar/index.js +75 -51
- package/admin/src/content-manager/components/BlocksEditor/hooks/useBlocksStore.js +72 -14
- package/admin/src/content-manager/pages/App/selectors.js +1 -1
- package/admin/src/content-manager/pages/App/useContentManagerInitData.js +3 -1
- package/admin/src/content-manager/pages/EditView/selectors.js +1 -1
- package/admin/src/content-manager/pages/EditViewLayoutManager/index.js +3 -1
- package/admin/src/content-manager/pages/ListView/components/Body/index.js +53 -56
- package/admin/src/content-manager/pages/ListView/components/BulkActionButtons/SelectedEntriesModal/index.js +5 -3
- package/admin/src/content-manager/pages/ListView/components/TableRows/index.js +1 -1
- package/admin/src/content-manager/pages/ListView/index.js +33 -50
- package/admin/src/content-manager/pages/ListView/selectors.js +1 -1
- package/admin/src/contexts/admin.ts +1 -0
- package/admin/src/contexts/apiTokenPermissions.tsx +64 -0
- package/admin/src/contexts/themeToggle.ts +3 -1
- package/admin/src/core/store/configure.ts +91 -0
- package/admin/src/core/store/hooks.ts +15 -0
- package/admin/src/hooks/index.js +0 -1
- package/admin/src/hooks/{useContentTypes/useContentTypes.js → useContentTypes.ts} +39 -16
- package/admin/src/hooks/useSettingsForm/index.js +14 -2
- package/admin/src/hooks/useSettingsMenu/constants.js +39 -0
- package/admin/src/index.js +2 -4
- package/admin/src/layouts/{AppLayout/index.js → AppLayout.tsx} +7 -10
- package/admin/src/layouts/UnauthenticatedLayout.tsx +77 -0
- package/admin/src/pages/Admin/index.js +11 -5
- package/admin/src/pages/App/index.js +7 -4
- package/admin/src/pages/App/selectors.js +1 -1
- package/admin/src/pages/AuthPage/components/ForgotPassword/index.js +2 -1
- package/admin/src/pages/AuthPage/components/ForgotPasswordSuccess/index.js +2 -1
- package/admin/src/pages/AuthPage/components/Login/index.js +1 -1
- package/admin/src/pages/AuthPage/components/Oops/index.js +2 -1
- package/admin/src/pages/AuthPage/components/Register/index.js +1 -1
- package/admin/src/pages/AuthPage/components/ResetPassword/index.js +2 -1
- package/admin/src/pages/AuthPage/index.js +2 -3
- package/admin/src/pages/HomePage/index.js +6 -3
- package/admin/src/pages/{InternalErrorPage/index.js → InternalErrorPage.tsx} +10 -6
- package/admin/src/pages/{NotFoundPage/index.js → NotFoundPage.tsx} +9 -7
- package/admin/src/pages/ProfilePage/components/Preferences/index.js +23 -9
- package/admin/src/pages/ProfilePage/index.js +1 -1
- package/admin/src/pages/SettingsPage/components/SettingsNav/index.js +20 -0
- package/admin/src/pages/SettingsPage/constants.js +33 -0
- package/admin/src/pages/SettingsPage/index.js +2 -2
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/ActionBoundRoutes/index.js +1 -1
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/CollapsableContentType/index.js +1 -1
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/Permissions/index.js +1 -1
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/index.js +2 -2
- package/admin/src/pages/SettingsPage/pages/AuditLogs/SalesPage.js +50 -0
- package/admin/src/pages/SettingsPage/pages/ReviewWorkflows/SalesPage.js +53 -0
- package/admin/src/pages/SettingsPage/pages/SingleSignOn/SalesPage.js +53 -0
- package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/index.js +1 -1
- package/admin/src/pages/SettingsPage/pages/Users/EditPage/index.js +2 -1
- package/admin/src/pages/SettingsPage/pages/Users/ListPage/DynamicTable/TableRows/index.js +1 -1
- package/admin/src/pages/{UseCasePage/index.js → UseCasePage.tsx} +10 -12
- package/admin/src/translations/en.json +5 -0
- package/admin/src/utils/createRoute.tsx +54 -0
- package/admin/src/utils/formatAPIErrors.ts +18 -0
- package/admin/src/utils/getFullName.ts +3 -0
- package/admin/src/utils/{uniqueAdminHash.js → hashAdminUserEmail.ts} +6 -3
- package/admin/src/utils/makeUniqueRoutes.ts +11 -0
- package/build/{1049.9236e785.chunk.js → 1049.ecc10c97.chunk.js} +1 -1
- package/build/1217.96155682.chunk.js +35 -0
- package/build/{1227.e0f7447b.chunk.js → 1227.947ceaf9.chunk.js} +1 -1
- package/build/1306.2699df52.chunk.js +79 -0
- package/build/{1386.07f2bbb3.chunk.js → 1386.eabd8a1e.chunk.js} +1 -1
- package/build/{2379.b0bc4013.chunk.js → 2379.7ce8e110.chunk.js} +1 -1
- package/build/{2395.d37b1025.chunk.js → 2395.acb961a8.chunk.js} +3 -3
- package/build/{2801.12522720.chunk.js → 2801.4711ea5a.chunk.js} +1 -1
- package/build/{3019.0d74d080.chunk.js → 3019.fde2e1be.chunk.js} +2 -2
- package/build/3460.8644e608.chunk.js +146 -0
- package/build/{3483.8f1b25f8.chunk.js → 3483.db8c1520.chunk.js} +1 -1
- package/build/{4174.2c4f958e.chunk.js → 4174.49cedb6a.chunk.js} +1 -1
- package/build/4732.149f5f8f.chunk.js +1 -0
- package/build/{502.b845473a.chunk.js → 502.f536f78b.chunk.js} +1 -1
- package/build/{7464.91341b4f.chunk.js → 7464.579564ac.chunk.js} +1 -1
- package/build/7811.fdbe09af.chunk.js +103 -0
- package/build/{7897.dffa5ad5.chunk.js → 7897.63ba0a00.chunk.js} +1 -1
- package/build/{8276.e9698944.chunk.js → 8276.9abe4679.chunk.js} +3 -3
- package/build/8773.ee67141c.chunk.js +48 -0
- package/build/9077.2cc01ac8.chunk.js +105 -0
- package/build/{9218.306ad178.chunk.js → 9218.b2d367f8.chunk.js} +1 -1
- package/build/Admin-authenticatedApp.059dc48f.chunk.js +79 -0
- package/build/Admin_InternalErrorPage.06eeef20.chunk.js +1 -0
- package/build/Admin_homePage.56b9eb3f.chunk.js +81 -0
- package/build/{Admin_marketplace.0db78604.chunk.js → Admin_marketplace.d693a435.chunk.js} +1 -1
- package/build/{Admin_pluginsPage.1083f7f0.chunk.js → Admin_pluginsPage.ae2c872a.chunk.js} +1 -1
- package/build/Admin_profilePage.89099d5b.chunk.js +13 -0
- package/build/Admin_settingsPage.88c45586.chunk.js +12 -0
- package/build/{Upload_ConfigureTheView.3cfeb108.chunk.js → Upload_ConfigureTheView.44f28145.chunk.js} +1 -1
- package/build/admin-app.990e112f.chunk.js +69 -0
- package/build/{admin-edit-roles-page.556fac52.chunk.js → admin-edit-roles-page.4e1eb4a9.chunk.js} +3 -3
- package/build/admin-edit-users.5b91404e.chunk.js +10 -0
- package/build/{admin-roles-list.15918328.chunk.js → admin-roles-list.89dd94fe.chunk.js} +1 -1
- package/build/{admin-users.74fddc87.chunk.js → admin-users.7be4fc5f.chunk.js} +2 -2
- package/build/{api-tokens-create-page.c08ae118.chunk.js → api-tokens-create-page.571920e5.chunk.js} +1 -1
- package/build/{api-tokens-edit-page.ce18efdc.chunk.js → api-tokens-edit-page.cbdc81b1.chunk.js} +1 -1
- package/build/{api-tokens-list-page.783b7569.chunk.js → api-tokens-list-page.de0c49e8.chunk.js} +2 -2
- package/build/audit-logs-sales-page.2955db88.chunk.js +1 -0
- package/build/{audit-logs-settings-page.12aeea8c.chunk.js → audit-logs-settings-page.b0cb5164.chunk.js} +1 -1
- package/build/content-manager.de7ae330.chunk.js +1241 -0
- package/build/{content-type-builder-list-view.38ed3935.chunk.js → content-type-builder-list-view.6c8d3213.chunk.js} +1 -1
- package/build/{content-type-builder-translation-en-json.43f9d7bc.chunk.js → content-type-builder-translation-en-json.74d80f18.chunk.js} +1 -1
- package/build/{content-type-builder.758a9d23.chunk.js → content-type-builder.0bc97051.chunk.js} +13 -23
- package/build/{email-settings-page.e08a587e.chunk.js → email-settings-page.07712efc.chunk.js} +1 -1
- package/build/en-json.5b907f67.chunk.js +1 -0
- package/build/{i18n-settings-page.3186e3e9.chunk.js → i18n-settings-page.5c34f012.chunk.js} +1 -1
- package/build/index.html +1 -1
- package/build/main.f84563f1.js +2665 -0
- package/build/review-workflows-sales-page.f46a8f00.chunk.js +1 -0
- package/build/{review-workflows-settings-create-view.5cdc4d64.chunk.js → review-workflows-settings-create-view.d0544fb0.chunk.js} +1 -1
- package/build/{review-workflows-settings-edit-view.53bf7865.chunk.js → review-workflows-settings-edit-view.aabf49ef.chunk.js} +1 -1
- package/build/review-workflows-settings-list-view.8b0525ab.chunk.js +56 -0
- package/build/runtime~main.270fd45f.js +2 -0
- package/build/sso-sales-page.ef22e469.chunk.js +1 -0
- package/build/sso-settings-page.21e16ae4.chunk.js +1 -0
- package/build/{transfer-tokens-create-page.2662d519.chunk.js → transfer-tokens-create-page.3366204d.chunk.js} +1 -1
- package/build/{transfer-tokens-edit-page.f64d8d8c.chunk.js → transfer-tokens-edit-page.15cf0f73.chunk.js} +1 -1
- package/build/{transfer-tokens-list-page.e6fd5f87.chunk.js → transfer-tokens-list-page.0bc0e682.chunk.js} +2 -2
- package/build/{upload-settings.450a1de0.chunk.js → upload-settings.1319dca0.chunk.js} +1 -1
- package/build/{upload.0d53e7a3.chunk.js → upload.1ced11be.chunk.js} +1 -1
- package/build/{users-advanced-settings-page.4a1f1f6d.chunk.js → users-advanced-settings-page.8e657084.chunk.js} +1 -1
- package/build/{users-email-settings-page.ea81fe82.chunk.js → users-email-settings-page.e57745e5.chunk.js} +1 -1
- package/build/{users-providers-settings-page.10280cdb.chunk.js → users-providers-settings-page.55796d13.chunk.js} +1 -1
- package/build/{users-roles-settings-page.4a7158be.chunk.js → users-roles-settings-page.57079245.chunk.js} +1 -1
- package/build/webhook-edit-page.3a28b2e7.chunk.js +33 -0
- package/build/{webhook-list-page.f57285ca.chunk.js → webhook-list-page.ee80767b.chunk.js} +1 -1
- package/ee/admin/pages/AuthPage/components/Login/index.js +1 -1
- package/ee/admin/pages/AuthPage/components/Providers/index.js +2 -1
- package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/selectors.js +1 -1
- package/ee/server/bootstrap.js +1 -1
- package/ee/server/controllers/admin.js +1 -1
- package/ee/server/controllers/user.js +1 -1
- package/ee/server/destroy.js +1 -1
- package/ee/server/register.js +1 -1
- package/ee/server/routes/utils.js +1 -1
- package/ee/server/services/audit-logs.js +1 -1
- package/ee/server/services/passport/sso.js +1 -1
- package/ee/server/services/passport.js +1 -1
- package/ee/server/services/seat-enforcement.js +1 -1
- package/ee/server/utils/sso-lock.js +1 -1
- package/ee/server/validation/role.js +1 -1
- package/ee/server/validation/user.js +1 -1
- package/package.json +15 -16
- package/server/controllers/admin.js +1 -1
- package/shared/entities.ts +1 -1
- package/shared/permissions.ts +35 -35
- package/shared/schema.ts +9 -0
- package/admin/src/components/AuthenticatedApp/index.js +0 -116
- package/admin/src/components/AuthenticatedApp/utils/api.js +0 -47
- package/admin/src/components/AuthenticatedApp/utils/checkLatestStrapiVersion.ts +0 -13
- package/admin/src/components/AuthenticatedApp/utils/fetchStrapiLatestRelease.ts +0 -19
- package/admin/src/components/GuidedTour/Homepage/components/Step.js +0 -61
- package/admin/src/components/GuidedTour/Homepage/components/Stepper.js +0 -61
- package/admin/src/components/GuidedTour/Homepage/index.js +0 -71
- package/admin/src/components/GuidedTour/Modal/components/Content.js +0 -66
- package/admin/src/components/GuidedTour/Modal/components/Modal.js +0 -72
- package/admin/src/components/GuidedTour/Modal/components/StepNumberWithPadding.js +0 -26
- package/admin/src/components/GuidedTour/Modal/components/Stepper.js +0 -118
- package/admin/src/components/GuidedTour/Modal/index.js +0 -94
- package/admin/src/components/GuidedTour/Modal/reducer.js +0 -29
- package/admin/src/components/GuidedTour/Stepper/StepLine.js +0 -29
- package/admin/src/components/GuidedTour/Stepper/StepNumber.js +0 -71
- package/admin/src/components/GuidedTour/constants.js +0 -3
- package/admin/src/components/GuidedTour/index.js +0 -102
- package/admin/src/components/GuidedTour/init.js +0 -37
- package/admin/src/components/GuidedTour/reducer.js +0 -50
- package/admin/src/components/GuidedTour/utils/arePreviousSectionsDone.js +0 -13
- package/admin/src/components/GuidedTour/utils/arePreviousStepsDone.js +0 -12
- package/admin/src/components/GuidedTour/utils/isGuidedTourCompleted.js +0 -6
- package/admin/src/components/GuidedTour/utils/persistStateToLocaleStorage.js +0 -34
- package/admin/src/components/Providers/index.js +0 -156
- package/admin/src/components/RBACProvider/actions.js +0 -10
- package/admin/src/components/RBACProvider/constants.js +0 -2
- package/admin/src/components/RBACProvider/index.js +0 -39
- package/admin/src/components/RBACProvider/reducer.js +0 -51
- package/admin/src/contexts/ApiTokenPermissions/index.js +0 -25
- package/admin/src/core/store/configureStore.js +0 -47
- package/admin/src/exposedHooks.js +0 -27
- package/admin/src/hooks/useContentTypes/index.js +0 -1
- package/admin/src/injectionZones.js +0 -25
- package/admin/src/layouts/UnauthenticatedLayout/LocaleToggle/index.js +0 -29
- package/admin/src/layouts/UnauthenticatedLayout/index.js +0 -55
- package/admin/src/reducers.js +0 -23
- package/admin/src/utils/checkFormValidity.js +0 -15
- package/admin/src/utils/createRoute.js +0 -50
- package/admin/src/utils/formatAPIErrors.js +0 -17
- package/admin/src/utils/getAttributesToDisplay.js +0 -19
- package/admin/src/utils/getExistingActions.js +0 -32
- package/admin/src/utils/getFullName.js +0 -9
- package/admin/src/utils/index.js +0 -9
- package/admin/src/utils/makeUniqueRoutes.js +0 -6
- package/admin/src/utils/sortLinks.js +0 -5
- package/build/1222.fe92c653.chunk.js +0 -35
- package/build/2225.a2147b8f.chunk.js +0 -79
- package/build/3021.33ad47fb.chunk.js +0 -103
- package/build/6373.1a21d665.chunk.js +0 -105
- package/build/8894.5ca4852a.chunk.js +0 -26
- package/build/9302.550cf5b7.chunk.js +0 -146
- package/build/Admin-authenticatedApp.e897fccb.chunk.js +0 -79
- package/build/Admin_InternalErrorPage.e2431a95.chunk.js +0 -1
- package/build/Admin_homePage.71ef8d06.chunk.js +0 -81
- package/build/Admin_profilePage.61704b7d.chunk.js +0 -13
- package/build/Admin_settingsPage.39cb9fca.chunk.js +0 -111
- package/build/admin-app.06f5e70a.chunk.js +0 -69
- package/build/admin-edit-users.64fd1318.chunk.js +0 -10
- package/build/content-manager.2e3f660b.chunk.js +0 -1220
- package/build/en-json.bd611a8e.chunk.js +0 -1
- package/build/main.00ea6f5a.js +0 -2665
- package/build/review-workflows-settings-list-view.b4a8aefb.chunk.js +0 -56
- package/build/runtime~main.e3bf3980.js +0 -2
- package/build/sso-settings-page.6a35d473.chunk.js +0 -1
- package/build/webhook-edit-page.65ac30ee.chunk.js +0 -33
- /package/admin/src/hooks/{useContentTypes/__mocks__/index.js → __mocks__/useContentTypes.ts} +0 -0
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { Flex, Icon, Typography } from '@strapi/design-system';
|
|
4
|
-
import { pxToRem } from '@strapi/helper-plugin';
|
|
5
|
-
import { Check } from '@strapi/icons';
|
|
6
|
-
import PropTypes from 'prop-types';
|
|
7
|
-
|
|
8
|
-
import { IS_ACTIVE, IS_DONE, IS_NOT_DONE } from '../constants';
|
|
9
|
-
|
|
10
|
-
const StepNumber = ({ type, number }) => {
|
|
11
|
-
if (type === IS_DONE) {
|
|
12
|
-
return (
|
|
13
|
-
<Flex
|
|
14
|
-
background="primary600"
|
|
15
|
-
padding={2}
|
|
16
|
-
borderRadius="50%"
|
|
17
|
-
width={pxToRem(30)}
|
|
18
|
-
height={pxToRem(30)}
|
|
19
|
-
justifyContent="center"
|
|
20
|
-
>
|
|
21
|
-
<Icon as={Check} aria-hidden width={pxToRem(16)} color="neutral0" />
|
|
22
|
-
</Flex>
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (type === IS_ACTIVE) {
|
|
27
|
-
return (
|
|
28
|
-
<Flex
|
|
29
|
-
background="primary600"
|
|
30
|
-
padding={2}
|
|
31
|
-
borderRadius="50%"
|
|
32
|
-
width={pxToRem(30)}
|
|
33
|
-
height={pxToRem(30)}
|
|
34
|
-
justifyContent="center"
|
|
35
|
-
>
|
|
36
|
-
<Typography fontWeight="semiBold" textColor="neutral0">
|
|
37
|
-
{number}
|
|
38
|
-
</Typography>
|
|
39
|
-
</Flex>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<Flex
|
|
45
|
-
borderColor="neutral500"
|
|
46
|
-
borderWidth="1px"
|
|
47
|
-
borderStyle="solid"
|
|
48
|
-
padding={2}
|
|
49
|
-
borderRadius="50%"
|
|
50
|
-
width={pxToRem(30)}
|
|
51
|
-
height={pxToRem(30)}
|
|
52
|
-
justifyContent="center"
|
|
53
|
-
>
|
|
54
|
-
<Typography fontWeight="semiBold" textColor="neutral600">
|
|
55
|
-
{number}
|
|
56
|
-
</Typography>
|
|
57
|
-
</Flex>
|
|
58
|
-
);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
StepNumber.defaultProps = {
|
|
62
|
-
number: undefined,
|
|
63
|
-
type: IS_NOT_DONE,
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
StepNumber.propTypes = {
|
|
67
|
-
number: PropTypes.number,
|
|
68
|
-
type: PropTypes.oneOf([IS_ACTIVE, IS_DONE, IS_NOT_DONE]),
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export default StepNumber;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import React, { useReducer } from 'react';
|
|
2
|
-
|
|
3
|
-
import { GuidedTourProvider } from '@strapi/helper-plugin';
|
|
4
|
-
import get from 'lodash/get';
|
|
5
|
-
import PropTypes from 'prop-types';
|
|
6
|
-
|
|
7
|
-
import init from './init';
|
|
8
|
-
import reducer, { initialState } from './reducer';
|
|
9
|
-
import arePreviousSectionsDone from './utils/arePreviousSectionsDone';
|
|
10
|
-
import arePreviousStepsDone from './utils/arePreviousStepsDone';
|
|
11
|
-
import persistStateToLocaleStorage from './utils/persistStateToLocaleStorage';
|
|
12
|
-
|
|
13
|
-
const GuidedTour = ({ children }) => {
|
|
14
|
-
const [{ currentStep, guidedTourState, isGuidedTourVisible, isSkipped }, dispatch] = useReducer(
|
|
15
|
-
reducer,
|
|
16
|
-
initialState,
|
|
17
|
-
init
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
const setCurrentStep = (step) => {
|
|
21
|
-
// if step is null it is intentional, we need to dispatch it
|
|
22
|
-
if (step !== null) {
|
|
23
|
-
const isStepAlreadyDone = get(guidedTourState, step);
|
|
24
|
-
const isStepToShow = arePreviousStepsDone(step, guidedTourState);
|
|
25
|
-
|
|
26
|
-
if (isStepAlreadyDone || isSkipped || !isStepToShow) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
persistStateToLocaleStorage.addCurrentStep(step);
|
|
32
|
-
|
|
33
|
-
return dispatch({
|
|
34
|
-
type: 'SET_CURRENT_STEP',
|
|
35
|
-
step,
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const setGuidedTourVisibility = (value) => {
|
|
40
|
-
dispatch({
|
|
41
|
-
type: 'SET_GUIDED_TOUR_VISIBILITY',
|
|
42
|
-
value,
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const setStepState = (currentStep, value) => {
|
|
47
|
-
persistStateToLocaleStorage.addCompletedStep(currentStep);
|
|
48
|
-
|
|
49
|
-
dispatch({
|
|
50
|
-
type: 'SET_STEP_STATE',
|
|
51
|
-
currentStep,
|
|
52
|
-
value,
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const startSection = (sectionName) => {
|
|
57
|
-
const sectionSteps = guidedTourState[sectionName];
|
|
58
|
-
|
|
59
|
-
if (sectionSteps) {
|
|
60
|
-
const isSectionToShow = arePreviousSectionsDone(sectionName, guidedTourState);
|
|
61
|
-
const firstStep = Object.keys(sectionSteps)[0];
|
|
62
|
-
const isFirstStepDone = sectionSteps[firstStep];
|
|
63
|
-
|
|
64
|
-
if (isSectionToShow && !currentStep && !isFirstStepDone) {
|
|
65
|
-
return setCurrentStep(`${sectionName}.${firstStep}`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return null;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const setSkipped = (value) => {
|
|
73
|
-
persistStateToLocaleStorage.setSkipped(value);
|
|
74
|
-
|
|
75
|
-
dispatch({
|
|
76
|
-
type: 'SET_SKIPPED',
|
|
77
|
-
value,
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
return (
|
|
82
|
-
<GuidedTourProvider
|
|
83
|
-
guidedTourState={guidedTourState}
|
|
84
|
-
currentStep={currentStep}
|
|
85
|
-
setCurrentStep={setCurrentStep}
|
|
86
|
-
setGuidedTourVisibility={setGuidedTourVisibility}
|
|
87
|
-
setSkipped={setSkipped}
|
|
88
|
-
setStepState={setStepState}
|
|
89
|
-
startSection={startSection}
|
|
90
|
-
isGuidedTourVisible={isGuidedTourVisible}
|
|
91
|
-
isSkipped={isSkipped}
|
|
92
|
-
>
|
|
93
|
-
{children}
|
|
94
|
-
</GuidedTourProvider>
|
|
95
|
-
);
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
GuidedTour.propTypes = {
|
|
99
|
-
children: PropTypes.element.isRequired,
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
export default GuidedTour;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import set from 'lodash/set';
|
|
2
|
-
|
|
3
|
-
import persistStateToLocaleStorage, {
|
|
4
|
-
COMPLETED_STEPS,
|
|
5
|
-
CURRENT_STEP,
|
|
6
|
-
SKIPPED,
|
|
7
|
-
} from './utils/persistStateToLocaleStorage';
|
|
8
|
-
|
|
9
|
-
const init = (initialState) => {
|
|
10
|
-
const copyInitialState = { ...initialState };
|
|
11
|
-
const guidedTourLocaleStorage = persistStateToLocaleStorage.get(COMPLETED_STEPS);
|
|
12
|
-
const currentStepLocaleStorage = persistStateToLocaleStorage.get(CURRENT_STEP);
|
|
13
|
-
const skippedLocaleStorage = persistStateToLocaleStorage.get(SKIPPED);
|
|
14
|
-
|
|
15
|
-
if (guidedTourLocaleStorage) {
|
|
16
|
-
guidedTourLocaleStorage.forEach((step) => {
|
|
17
|
-
const [sectionName, stepName] = step.split('.');
|
|
18
|
-
set(copyInitialState, ['guidedTourState', sectionName, stepName], true);
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// if current step when initializing mark it as done
|
|
23
|
-
if (currentStepLocaleStorage) {
|
|
24
|
-
const [sectionName, stepName] = currentStepLocaleStorage.split('.');
|
|
25
|
-
set(copyInitialState, ['guidedTourState', sectionName, stepName], true);
|
|
26
|
-
persistStateToLocaleStorage.addCompletedStep(currentStepLocaleStorage);
|
|
27
|
-
persistStateToLocaleStorage.addCurrentStep(null);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (skippedLocaleStorage !== null) {
|
|
31
|
-
set(copyInitialState, 'isSkipped', skippedLocaleStorage);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return copyInitialState;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export default init;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/* eslint-disable consistent-return */
|
|
2
|
-
import produce from 'immer';
|
|
3
|
-
|
|
4
|
-
export const initialState = {
|
|
5
|
-
currentStep: null,
|
|
6
|
-
guidedTourState: {
|
|
7
|
-
contentTypeBuilder: {
|
|
8
|
-
create: false,
|
|
9
|
-
success: false,
|
|
10
|
-
},
|
|
11
|
-
contentManager: {
|
|
12
|
-
create: false,
|
|
13
|
-
success: false,
|
|
14
|
-
},
|
|
15
|
-
apiTokens: {
|
|
16
|
-
create: false,
|
|
17
|
-
success: false,
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
isGuidedTourVisible: false,
|
|
21
|
-
isSkipped: true,
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const reducer = (state = initialState, action) =>
|
|
25
|
-
produce(state, (draftState) => {
|
|
26
|
-
switch (action.type) {
|
|
27
|
-
case 'SET_CURRENT_STEP': {
|
|
28
|
-
draftState.currentStep = action.step;
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
case 'SET_STEP_STATE': {
|
|
32
|
-
const [section, step] = action.currentStep.split('.');
|
|
33
|
-
draftState.guidedTourState[section][step] = action.value;
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
case 'SET_SKIPPED': {
|
|
37
|
-
draftState.isSkipped = action.value;
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
case 'SET_GUIDED_TOUR_VISIBILITY': {
|
|
41
|
-
draftState.isGuidedTourVisible = action.value;
|
|
42
|
-
break;
|
|
43
|
-
}
|
|
44
|
-
default: {
|
|
45
|
-
return draftState;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
export default reducer;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const arePreviousSectionsDone = (sectionName, guidedTourState) => {
|
|
2
|
-
const guidedTourArray = Object.entries(guidedTourState);
|
|
3
|
-
|
|
4
|
-
// Find current section position in the guidedTourArray
|
|
5
|
-
// Get only previous sections based on current section position
|
|
6
|
-
const currentSectionIndex = guidedTourArray.findIndex(([key]) => key === sectionName);
|
|
7
|
-
const previousSections = guidedTourArray.slice(0, currentSectionIndex);
|
|
8
|
-
|
|
9
|
-
// Check if every steps from previous section are done
|
|
10
|
-
return previousSections.every(([, sectionValue]) => Object.values(sectionValue).every(Boolean));
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default arePreviousSectionsDone;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const arePreviousStepsDone = (step, guidedTourState) => {
|
|
2
|
-
const stepSplit = step.split('.');
|
|
3
|
-
const stepName = stepSplit[1];
|
|
4
|
-
const sectionArray = Object.entries(guidedTourState[stepSplit[0]]);
|
|
5
|
-
|
|
6
|
-
const currentStepIndex = sectionArray.findIndex(([key]) => key === stepName);
|
|
7
|
-
const previousSteps = sectionArray.slice(0, currentStepIndex);
|
|
8
|
-
|
|
9
|
-
return previousSteps.every(([, sectionValue]) => sectionValue);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default arePreviousStepsDone;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export const CURRENT_STEP = 'GUIDED_TOUR_CURRENT_STEP';
|
|
2
|
-
export const COMPLETED_STEPS = 'GUIDED_TOUR_COMPLETED_STEPS';
|
|
3
|
-
export const SKIPPED = 'GUIDED_TOUR_SKIPPED';
|
|
4
|
-
const parse = JSON.parse;
|
|
5
|
-
const stringify = JSON.stringify;
|
|
6
|
-
|
|
7
|
-
const persistStateToLocaleStorage = {
|
|
8
|
-
clear() {
|
|
9
|
-
localStorage.removeItem(CURRENT_STEP);
|
|
10
|
-
localStorage.removeItem(COMPLETED_STEPS);
|
|
11
|
-
},
|
|
12
|
-
addCompletedStep(completedStep) {
|
|
13
|
-
const currentSteps = parse(localStorage.getItem(COMPLETED_STEPS))?.slice() || [];
|
|
14
|
-
const isAlreadyStored = currentSteps.includes(completedStep);
|
|
15
|
-
|
|
16
|
-
if (isAlreadyStored) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
currentSteps.push(completedStep);
|
|
21
|
-
localStorage.setItem(COMPLETED_STEPS, stringify(currentSteps));
|
|
22
|
-
},
|
|
23
|
-
addCurrentStep(currentStep) {
|
|
24
|
-
localStorage.setItem(CURRENT_STEP, stringify(currentStep));
|
|
25
|
-
},
|
|
26
|
-
setSkipped(value) {
|
|
27
|
-
localStorage.setItem(SKIPPED, stringify(value));
|
|
28
|
-
},
|
|
29
|
-
get(item) {
|
|
30
|
-
return parse(localStorage.getItem(item));
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export default persistStateToLocaleStorage;
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
AutoReloadOverlayBlockerProvider,
|
|
5
|
-
CustomFieldsProvider,
|
|
6
|
-
LibraryProvider,
|
|
7
|
-
NotificationsProvider,
|
|
8
|
-
OverlayBlockerProvider,
|
|
9
|
-
StrapiAppProvider,
|
|
10
|
-
} from '@strapi/helper-plugin';
|
|
11
|
-
import PropTypes from 'prop-types';
|
|
12
|
-
import { QueryClient, QueryClientProvider } from 'react-query';
|
|
13
|
-
import { Provider } from 'react-redux';
|
|
14
|
-
|
|
15
|
-
import { AdminContext } from '../../contexts/admin';
|
|
16
|
-
import { ConfigurationProvider } from '../ConfigurationProvider';
|
|
17
|
-
import GuidedTour from '../GuidedTour';
|
|
18
|
-
import { LanguageProvider } from '../LanguageProvider';
|
|
19
|
-
import { Theme } from '../Theme';
|
|
20
|
-
import { ThemeToggleProvider } from '../ThemeToggleProvider';
|
|
21
|
-
|
|
22
|
-
const queryClient = new QueryClient({
|
|
23
|
-
defaultOptions: {
|
|
24
|
-
queries: {
|
|
25
|
-
refetchOnWindowFocus: false,
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const Providers = ({
|
|
31
|
-
authLogo,
|
|
32
|
-
children,
|
|
33
|
-
components,
|
|
34
|
-
customFields,
|
|
35
|
-
fields,
|
|
36
|
-
getAdminInjectedComponents,
|
|
37
|
-
getPlugin,
|
|
38
|
-
localeNames,
|
|
39
|
-
menu,
|
|
40
|
-
menuLogo,
|
|
41
|
-
messages,
|
|
42
|
-
plugins,
|
|
43
|
-
runHookParallel,
|
|
44
|
-
runHookSeries,
|
|
45
|
-
runHookWaterfall,
|
|
46
|
-
settings,
|
|
47
|
-
showReleaseNotification,
|
|
48
|
-
showTutorials,
|
|
49
|
-
store,
|
|
50
|
-
themes,
|
|
51
|
-
}) => {
|
|
52
|
-
return (
|
|
53
|
-
<LanguageProvider messages={messages} localeNames={localeNames}>
|
|
54
|
-
<ThemeToggleProvider themes={themes}>
|
|
55
|
-
<Theme>
|
|
56
|
-
<QueryClientProvider client={queryClient}>
|
|
57
|
-
<Provider store={store}>
|
|
58
|
-
<AdminContext.Provider value={{ getAdminInjectedComponents }}>
|
|
59
|
-
<ConfigurationProvider
|
|
60
|
-
authLogo={authLogo}
|
|
61
|
-
menuLogo={menuLogo}
|
|
62
|
-
showReleaseNotification={showReleaseNotification}
|
|
63
|
-
showTutorials={showTutorials}
|
|
64
|
-
>
|
|
65
|
-
<StrapiAppProvider
|
|
66
|
-
getPlugin={getPlugin}
|
|
67
|
-
menu={menu}
|
|
68
|
-
plugins={plugins}
|
|
69
|
-
runHookParallel={runHookParallel}
|
|
70
|
-
runHookWaterfall={runHookWaterfall}
|
|
71
|
-
runHookSeries={runHookSeries}
|
|
72
|
-
settings={settings}
|
|
73
|
-
>
|
|
74
|
-
<LibraryProvider components={components} fields={fields}>
|
|
75
|
-
<CustomFieldsProvider customFields={customFields}>
|
|
76
|
-
<AutoReloadOverlayBlockerProvider>
|
|
77
|
-
<OverlayBlockerProvider>
|
|
78
|
-
<GuidedTour>
|
|
79
|
-
<NotificationsProvider>{children}</NotificationsProvider>
|
|
80
|
-
</GuidedTour>
|
|
81
|
-
</OverlayBlockerProvider>
|
|
82
|
-
</AutoReloadOverlayBlockerProvider>
|
|
83
|
-
</CustomFieldsProvider>
|
|
84
|
-
</LibraryProvider>
|
|
85
|
-
</StrapiAppProvider>
|
|
86
|
-
</ConfigurationProvider>
|
|
87
|
-
</AdminContext.Provider>
|
|
88
|
-
</Provider>
|
|
89
|
-
</QueryClientProvider>
|
|
90
|
-
</Theme>
|
|
91
|
-
</ThemeToggleProvider>
|
|
92
|
-
</LanguageProvider>
|
|
93
|
-
);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
Providers.propTypes = {
|
|
97
|
-
authLogo: PropTypes.oneOfType([PropTypes.string, PropTypes.any]).isRequired,
|
|
98
|
-
children: PropTypes.node.isRequired,
|
|
99
|
-
components: PropTypes.object.isRequired,
|
|
100
|
-
customFields: PropTypes.object.isRequired,
|
|
101
|
-
fields: PropTypes.object.isRequired,
|
|
102
|
-
getAdminInjectedComponents: PropTypes.func.isRequired,
|
|
103
|
-
getPlugin: PropTypes.func.isRequired,
|
|
104
|
-
localeNames: PropTypes.objectOf(PropTypes.string).isRequired,
|
|
105
|
-
menu: PropTypes.arrayOf(
|
|
106
|
-
PropTypes.shape({
|
|
107
|
-
to: PropTypes.string.isRequired,
|
|
108
|
-
icon: PropTypes.func.isRequired,
|
|
109
|
-
intlLabel: PropTypes.shape({
|
|
110
|
-
id: PropTypes.string.isRequired,
|
|
111
|
-
defaultMessage: PropTypes.string.isRequired,
|
|
112
|
-
}).isRequired,
|
|
113
|
-
permissions: PropTypes.array,
|
|
114
|
-
Component: PropTypes.func,
|
|
115
|
-
})
|
|
116
|
-
).isRequired,
|
|
117
|
-
menuLogo: PropTypes.oneOfType([PropTypes.string, PropTypes.any]).isRequired,
|
|
118
|
-
messages: PropTypes.object.isRequired,
|
|
119
|
-
plugins: PropTypes.object.isRequired,
|
|
120
|
-
runHookParallel: PropTypes.func.isRequired,
|
|
121
|
-
runHookWaterfall: PropTypes.func.isRequired,
|
|
122
|
-
runHookSeries: PropTypes.func.isRequired,
|
|
123
|
-
settings: PropTypes.object.isRequired,
|
|
124
|
-
showReleaseNotification: PropTypes.bool.isRequired,
|
|
125
|
-
showTutorials: PropTypes.bool.isRequired,
|
|
126
|
-
store: PropTypes.object.isRequired,
|
|
127
|
-
themes: PropTypes.shape({
|
|
128
|
-
light: PropTypes.shape({
|
|
129
|
-
colors: PropTypes.object.isRequired,
|
|
130
|
-
shadows: PropTypes.object.isRequired,
|
|
131
|
-
sizes: PropTypes.object.isRequired,
|
|
132
|
-
zIndices: PropTypes.array.isRequired,
|
|
133
|
-
spaces: PropTypes.array.isRequired,
|
|
134
|
-
borderRadius: PropTypes.string.isRequired,
|
|
135
|
-
mediaQueries: PropTypes.object.isRequired,
|
|
136
|
-
fontSizes: PropTypes.array.isRequired,
|
|
137
|
-
lineHeights: PropTypes.array.isRequired,
|
|
138
|
-
fontWeights: PropTypes.object.isRequired,
|
|
139
|
-
}).isRequired,
|
|
140
|
-
dark: PropTypes.shape({
|
|
141
|
-
colors: PropTypes.object.isRequired,
|
|
142
|
-
shadows: PropTypes.object.isRequired,
|
|
143
|
-
sizes: PropTypes.object.isRequired,
|
|
144
|
-
zIndices: PropTypes.array.isRequired,
|
|
145
|
-
spaces: PropTypes.array.isRequired,
|
|
146
|
-
borderRadius: PropTypes.string.isRequired,
|
|
147
|
-
mediaQueries: PropTypes.object.isRequired,
|
|
148
|
-
fontSizes: PropTypes.array.isRequired,
|
|
149
|
-
lineHeights: PropTypes.array.isRequired,
|
|
150
|
-
fontWeights: PropTypes.object.isRequired,
|
|
151
|
-
}).isRequired,
|
|
152
|
-
custom: PropTypes.object,
|
|
153
|
-
}).isRequired,
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
export default Providers;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
import { LoadingIndicatorPage, RBACProviderContext } from '@strapi/helper-plugin';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
import { useDispatch, useSelector } from 'react-redux';
|
|
6
|
-
|
|
7
|
-
import { resetStore, setPermissions } from './actions';
|
|
8
|
-
|
|
9
|
-
const RBACProvider = ({ children, permissions, refetchPermissions }) => {
|
|
10
|
-
const { allPermissions } = useSelector((state) => state.rbacProvider);
|
|
11
|
-
|
|
12
|
-
const dispatch = useDispatch();
|
|
13
|
-
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
dispatch(setPermissions(permissions));
|
|
16
|
-
|
|
17
|
-
return () => {
|
|
18
|
-
dispatch(resetStore());
|
|
19
|
-
};
|
|
20
|
-
}, [permissions, dispatch]);
|
|
21
|
-
|
|
22
|
-
if (!allPermissions) {
|
|
23
|
-
return <LoadingIndicatorPage />;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<RBACProviderContext.Provider value={{ allPermissions, refetchPermissions }}>
|
|
28
|
-
{children}
|
|
29
|
-
</RBACProviderContext.Provider>
|
|
30
|
-
);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
RBACProvider.propTypes = {
|
|
34
|
-
children: PropTypes.node.isRequired,
|
|
35
|
-
permissions: PropTypes.array.isRequired,
|
|
36
|
-
refetchPermissions: PropTypes.func.isRequired,
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export default RBACProvider;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
*
|
|
3
|
-
* RBACProvider reducer
|
|
4
|
-
* The goal of this reducer is to provide
|
|
5
|
-
* the plugins with an access to the user's permissions
|
|
6
|
-
* in our middleware system
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import produce from 'immer';
|
|
11
|
-
|
|
12
|
-
import { RESET_STORE, SET_PERMISSIONS } from './constants';
|
|
13
|
-
|
|
14
|
-
const initialState = {
|
|
15
|
-
allPermissions: null,
|
|
16
|
-
collectionTypesRelatedPermissions: {},
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const reducer = (state = initialState, action) =>
|
|
20
|
-
// eslint-disable-next-line consistent-return
|
|
21
|
-
produce(state, (draftState) => {
|
|
22
|
-
switch (action.type) {
|
|
23
|
-
case SET_PERMISSIONS: {
|
|
24
|
-
draftState.allPermissions = action.permissions;
|
|
25
|
-
draftState.collectionTypesRelatedPermissions = action.permissions
|
|
26
|
-
.filter((perm) => perm.subject)
|
|
27
|
-
.reduce((acc, current) => {
|
|
28
|
-
const { subject, action } = current;
|
|
29
|
-
|
|
30
|
-
if (!acc[subject]) {
|
|
31
|
-
acc[subject] = {};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
acc[subject] = acc[subject][action]
|
|
35
|
-
? { ...acc[subject], [action]: [...acc[subject][action], current] }
|
|
36
|
-
: { ...acc[subject], [action]: [current] };
|
|
37
|
-
|
|
38
|
-
return acc;
|
|
39
|
-
}, {});
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
case RESET_STORE: {
|
|
43
|
-
return initialState;
|
|
44
|
-
}
|
|
45
|
-
default:
|
|
46
|
-
return state;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
export default reducer;
|
|
51
|
-
export { initialState };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React, { createContext, useContext } from 'react';
|
|
2
|
-
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
|
|
5
|
-
const ApiTokenPermissionsContext = createContext({});
|
|
6
|
-
|
|
7
|
-
const ApiTokenPermissionsContextProvider = ({ children, ...rest }) => {
|
|
8
|
-
return (
|
|
9
|
-
<ApiTokenPermissionsContext.Provider value={rest}>
|
|
10
|
-
{children}
|
|
11
|
-
</ApiTokenPermissionsContext.Provider>
|
|
12
|
-
);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const useApiTokenPermissionsContext = () => useContext(ApiTokenPermissionsContext);
|
|
16
|
-
|
|
17
|
-
ApiTokenPermissionsContextProvider.propTypes = {
|
|
18
|
-
children: PropTypes.node.isRequired,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export {
|
|
22
|
-
ApiTokenPermissionsContext,
|
|
23
|
-
ApiTokenPermissionsContextProvider,
|
|
24
|
-
useApiTokenPermissionsContext,
|
|
25
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { applyMiddleware, combineReducers, compose, createStore } from 'redux';
|
|
2
|
-
|
|
3
|
-
const configureStore = (appMiddlewares, appReducers) => {
|
|
4
|
-
let composeEnhancers = compose;
|
|
5
|
-
|
|
6
|
-
const middlewares = [];
|
|
7
|
-
|
|
8
|
-
appMiddlewares.forEach((middleware) => {
|
|
9
|
-
middlewares.push(middleware());
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
// If Redux Dev Tools are installed, enable them
|
|
13
|
-
if (
|
|
14
|
-
process.env.NODE_ENV !== 'production' &&
|
|
15
|
-
typeof window === 'object' &&
|
|
16
|
-
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
|
17
|
-
) {
|
|
18
|
-
composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const store = createStore(
|
|
22
|
-
createReducer(appReducers, {}),
|
|
23
|
-
{},
|
|
24
|
-
composeEnhancers(applyMiddleware(...middlewares))
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
// Add a dictionary to keep track of the registered async reducers
|
|
28
|
-
store.asyncReducers = {};
|
|
29
|
-
|
|
30
|
-
// Create an inject reducer function
|
|
31
|
-
// This function adds the async reducer, and creates a new combined reducer
|
|
32
|
-
store.injectReducer = (key, asyncReducer) => {
|
|
33
|
-
store.asyncReducers[key] = asyncReducer;
|
|
34
|
-
store.replaceReducer(createReducer(appReducers, store.asyncReducers));
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
return store;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const createReducer = (appReducers, asyncReducers) => {
|
|
41
|
-
return combineReducers({
|
|
42
|
-
...appReducers,
|
|
43
|
-
...asyncReducers,
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export default configureStore;
|