@strapi/admin 4.14.4 → 4.14.6
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/.eslintrc.js +12 -0
- package/admin/custom.d.ts +20 -0
- package/admin/src/StrapiApp.js +14 -16
- package/admin/src/components/AuthenticatedApp/index.js +4 -4
- package/admin/src/components/ConfigurationProvider.tsx +67 -0
- package/admin/src/components/LanguageProvider.tsx +129 -0
- package/admin/src/components/{LeftMenu/index.js → LeftMenu.tsx} +23 -18
- package/admin/src/components/{NpsSurvey/index.js → NpsSurvey.tsx} +68 -21
- package/admin/src/components/PluginsInitializer.tsx +124 -0
- package/admin/src/components/Providers/index.js +6 -6
- package/admin/src/components/UnauthenticatedLogo.tsx +2 -2
- package/admin/src/components/{LocalesProvider/__mocks__/useLocalesProvider.js → __mocks__/LanguageProvider.js} +1 -1
- package/admin/src/content-manager/components/BlocksEditor/BlocksInput/index.js +48 -8
- package/admin/src/content-manager/components/BlocksEditor/Toolbar/index.js +146 -68
- package/admin/src/content-manager/components/BlocksEditor/hooks/useBlocksStore.js +50 -47
- package/admin/src/content-manager/components/BlocksEditor/hooks/useModifiersStore.js +11 -9
- package/admin/src/content-manager/components/BlocksEditor/index.js +1 -14
- package/admin/src/contexts/admin.ts +18 -0
- package/admin/src/contexts/configuration.ts +14 -4
- package/admin/src/hooks/__mocks__/useConfigurations.ts +2 -2
- package/admin/src/hooks/index.js +0 -3
- package/admin/src/hooks/{useAdminRoles/index.js → useAdminRoles.ts} +26 -10
- package/admin/src/hooks/useAdminUsers.ts +64 -0
- package/admin/src/hooks/useConfiguration.ts +5 -0
- package/admin/src/hooks/{useEnterprise/useEnterprise.js → useEnterprise.ts} +15 -5
- package/admin/src/hooks/useMenu.ts +153 -0
- package/admin/src/index.js +5 -2
- package/admin/src/layouts/UnauthenticatedLayout/LocaleToggle/index.js +2 -2
- package/admin/src/pages/Admin/index.js +4 -3
- package/admin/src/pages/App/index.js +5 -3
- package/admin/src/pages/AuthPage/components/Register/index.js +28 -33
- package/admin/src/pages/AuthPage/index.js +2 -2
- package/admin/src/pages/ProfilePage/index.js +2 -2
- package/admin/src/pages/SettingsPage/components/Tokens/Table/index.js +119 -87
- package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/CustomizationInfos/index.js +2 -2
- package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/index.js +2 -2
- package/admin/src/pages/SettingsPage/pages/Roles/CreatePage/index.js +1 -1
- package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/ConditionsModal/index.js +1 -1
- package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/ContentTypeCollapse/Collapse/index.js +1 -1
- package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/ContentTypeCollapse/CollapsePropertyMatrix/ActionRow/index.js +1 -1
- package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/ContentTypeCollapse/CollapsePropertyMatrix/SubActionRow/index.js +1 -1
- package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/GlobalActions/index.js +1 -1
- package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/PermissionsDataManagerProvider/index.js +1 -1
- package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/PluginsAndSettings/SubCategory/index.js +1 -1
- package/admin/src/pages/SettingsPage/pages/Roles/EditPage/hooks/usePermissionsDataManager.ts +28 -0
- package/admin/src/pages/SettingsPage/pages/Roles/EditPage/index.js +1 -1
- package/admin/src/{hooks/useAdminRolePermissions/index.js → pages/SettingsPage/pages/Roles/hooks/useAdminRolePermissions.ts} +13 -6
- package/admin/src/pages/SettingsPage/pages/TransferTokens/ListView/index.js +3 -5
- package/admin/src/shared/hooks/index.js +0 -1
- package/admin/src/shared/hooks/useInjectionZone/index.js +2 -2
- package/admin/src/types/adminAPI.ts +29 -0
- package/admin/src/utils/createRoute.js +4 -1
- package/admin/tsconfig.build.json +4 -0
- package/admin/tsconfig.json +7 -1
- package/build/{1049.f7aed23d.chunk.js → 1049.9236e785.chunk.js} +1 -1
- package/build/1222.fe92c653.chunk.js +35 -0
- package/build/{1227.f9c74718.chunk.js → 1227.e0f7447b.chunk.js} +1 -1
- package/build/135.ad267b59.chunk.js +1 -0
- package/build/{1386.6b8819c6.chunk.js → 1386.07f2bbb3.chunk.js} +1 -1
- package/build/1835.eaa696ba.chunk.js +1 -0
- package/build/{2225.d1bcf7e3.chunk.js → 2225.a2147b8f.chunk.js} +2 -2
- package/build/2325.d705b39a.chunk.js +1 -0
- package/build/2379.b0bc4013.chunk.js +1 -0
- package/build/{2395.aca6ce66.chunk.js → 2395.d37b1025.chunk.js} +1 -1
- package/build/2421.79e5b3d0.chunk.js +1 -0
- package/build/267.073a3bcb.chunk.js +1 -0
- package/build/2801.12522720.chunk.js +1 -0
- package/build/2878.145ebf7c.chunk.js +1 -0
- package/build/2950.216f2e89.chunk.js +1 -0
- package/build/2953.284a63c0.chunk.js +1 -0
- package/build/{8743.31c921b1.chunk.js → 3019.0d74d080.chunk.js} +123 -139
- package/build/3021.33ad47fb.chunk.js +103 -0
- package/build/{3483.5df8e010.chunk.js → 3483.8f1b25f8.chunk.js} +1 -1
- package/build/3911.488fbde3.chunk.js +95 -0
- package/build/{4174.df9aa09a.chunk.js → 4174.2c4f958e.chunk.js} +1 -1
- package/build/4429.7f044dc7.chunk.js +1 -0
- package/build/4555.c883d697.chunk.js +1 -0
- package/build/4663.b906cc10.chunk.js +1 -0
- package/build/4916.480053a6.chunk.js +1 -0
- package/build/4996.d285c30b.chunk.js +1 -0
- package/build/502.b845473a.chunk.js +1 -0
- package/build/5858.493b31ec.chunk.js +1 -0
- package/build/6345.334e7678.chunk.js +1 -0
- package/build/6373.1a21d665.chunk.js +105 -0
- package/build/6453.4160b5b7.chunk.js +1 -0
- package/build/7448.6fd14dd3.chunk.js +1 -0
- package/build/7464.91341b4f.chunk.js +1 -0
- package/build/7735.9e7c9fdd.chunk.js +10 -0
- package/build/782.7243b183.chunk.js +1 -0
- package/build/7849.2a500ed8.chunk.js +1 -0
- package/build/7897.dffa5ad5.chunk.js +6 -0
- package/build/8162.7d1100a0.chunk.js +1 -0
- package/build/{8276.d4426fd8.chunk.js → 8276.e9698944.chunk.js} +2 -2
- package/build/8894.5ca4852a.chunk.js +26 -0
- package/build/8980.f0045cc1.chunk.js +1 -0
- package/build/9153.42c1428a.chunk.js +1 -0
- package/build/{9218.8bc01ab9.chunk.js → 9218.306ad178.chunk.js} +1 -1
- package/build/9285.5f174057.chunk.js +1 -0
- package/build/9302.550cf5b7.chunk.js +146 -0
- package/build/9547.62987774.chunk.js +1 -0
- package/build/9754.b4e73779.chunk.js +1 -0
- package/build/Admin-authenticatedApp.e0bf203f.chunk.js +79 -0
- package/build/{Admin_InternalErrorPage.b66ee9c1.chunk.js → Admin_InternalErrorPage.e2431a95.chunk.js} +1 -1
- package/build/Admin_homePage.71ef8d06.chunk.js +81 -0
- package/build/{Admin_marketplace.31b962b8.chunk.js → Admin_marketplace.0db78604.chunk.js} +1 -1
- package/build/{Admin_pluginsPage.9217101d.chunk.js → Admin_pluginsPage.1083f7f0.chunk.js} +1 -1
- package/build/{Admin_profilePage.680123d9.chunk.js → Admin_profilePage.61704b7d.chunk.js} +2 -2
- package/build/Admin_settingsPage.39cb9fca.chunk.js +111 -0
- package/build/{Upload_ConfigureTheView.b40eea4d.chunk.js → Upload_ConfigureTheView.3cfeb108.chunk.js} +1 -1
- package/build/admin-app.06f5e70a.chunk.js +69 -0
- package/build/admin-edit-roles-page.556fac52.chunk.js +267 -0
- package/build/admin-edit-users.64fd1318.chunk.js +10 -0
- package/build/admin-roles-list.15918328.chunk.js +22 -0
- package/build/admin-users.74fddc87.chunk.js +11 -0
- package/build/{api-tokens-create-page.0dd63e91.chunk.js → api-tokens-create-page.c08ae118.chunk.js} +1 -1
- package/build/{api-tokens-edit-page.78d877f8.chunk.js → api-tokens-edit-page.ce18efdc.chunk.js} +1 -1
- package/build/api-tokens-list-page.783b7569.chunk.js +16 -0
- package/build/audit-logs-settings-page.12aeea8c.chunk.js +1 -0
- package/build/content-manager.2e3f660b.chunk.js +1220 -0
- package/build/{content-type-builder-list-view.3fffae65.chunk.js → content-type-builder-list-view.38ed3935.chunk.js} +7 -7
- package/build/{content-type-builder.98c71164.chunk.js → content-type-builder.758a9d23.chunk.js} +4 -4
- package/build/email-settings-page.e08a587e.chunk.js +11 -0
- package/build/{i18n-settings-page.a9708926.chunk.js → i18n-settings-page.3186e3e9.chunk.js} +1 -1
- package/build/index.html +1 -1
- package/build/main.00ea6f5a.js +2665 -0
- package/build/{review-workflows-settings-create-view.b7b0c6c5.chunk.js → review-workflows-settings-create-view.5cdc4d64.chunk.js} +1 -1
- package/build/{review-workflows-settings-edit-view.c331b3fe.chunk.js → review-workflows-settings-edit-view.53bf7865.chunk.js} +1 -1
- package/build/review-workflows-settings-list-view.b4a8aefb.chunk.js +56 -0
- package/build/runtime~main.be0e0649.js +2 -0
- package/build/sso-settings-page.6a35d473.chunk.js +1 -0
- package/build/{transfer-tokens-create-page.e7f541d3.chunk.js → transfer-tokens-create-page.2662d519.chunk.js} +1 -1
- package/build/{transfer-tokens-edit-page.bd1276c2.chunk.js → transfer-tokens-edit-page.f64d8d8c.chunk.js} +1 -1
- package/build/transfer-tokens-list-page.e6fd5f87.chunk.js +16 -0
- package/build/{upload-settings.97ef4c92.chunk.js → upload-settings.450a1de0.chunk.js} +1 -1
- package/build/{upload.f08715a1.chunk.js → upload.0d53e7a3.chunk.js} +1 -1
- package/build/{users-advanced-settings-page.36a3c363.chunk.js → users-advanced-settings-page.4a1f1f6d.chunk.js} +1 -1
- package/build/users-email-settings-page.ea81fe82.chunk.js +9 -0
- package/build/users-providers-settings-page.10280cdb.chunk.js +14 -0
- package/build/{users-roles-settings-page.d5a8e8a1.chunk.js → users-roles-settings-page.4a7158be.chunk.js} +1 -1
- package/build/{webhook-edit-page.87456194.chunk.js → webhook-edit-page.65ac30ee.chunk.js} +2 -2
- package/build/{webhook-list-page.c88a382b.chunk.js → webhook-list-page.f57285ca.chunk.js} +1 -1
- package/jest.config.front.js +4 -0
- package/package.json +23 -17
- package/scripts/build.js +1 -1
- package/server/controllers/admin.js +3 -2
- package/shared/entities.ts +33 -0
- package/shared/permissions.ts +52 -0
- package/admin/src/components/ConfigurationsProvider/index.js +0 -66
- package/admin/src/components/ConfigurationsProvider/reducer.js +0 -29
- package/admin/src/components/LanguageProvider/index.js +0 -54
- package/admin/src/components/LanguageProvider/init.js +0 -13
- package/admin/src/components/LanguageProvider/reducer.js +0 -30
- package/admin/src/components/LanguageProvider/utils/localStorageKey.js +0 -3
- package/admin/src/components/LocalesProvider/context.js +0 -5
- package/admin/src/components/LocalesProvider/index.js +0 -21
- package/admin/src/components/LocalesProvider/useLocalesProvider.js +0 -11
- package/admin/src/components/NpsSurvey/hooks/useNpsSurveySettings.js +0 -17
- package/admin/src/components/PluginsInitializer/index.js +0 -68
- package/admin/src/components/PluginsInitializer/init.js +0 -11
- package/admin/src/components/PluginsInitializer/reducer.js +0 -22
- package/admin/src/contexts/Admin/index.js +0 -5
- package/admin/src/contexts/MarketPlace/index.js +0 -18
- package/admin/src/contexts/PermisssionsDataManagerContext/index.js +0 -5
- package/admin/src/contexts/index.js +0 -3
- package/admin/src/hooks/useAdminRoles/__mocks__/index.js +0 -5
- package/admin/src/hooks/useAdminUsers/index.js +0 -1
- package/admin/src/hooks/useAdminUsers/useAdminUsers.js +0 -47
- package/admin/src/hooks/useConfigurations.ts +0 -5
- package/admin/src/hooks/useEnterprise/index.js +0 -1
- package/admin/src/hooks/useMenu/index.js +0 -86
- package/admin/src/hooks/useMenu/utils/checkPermissions.js +0 -13
- package/admin/src/hooks/useMenu/utils/getGeneralLinks.js +0 -31
- package/admin/src/hooks/useMenu/utils/getPluginSectionLinks.js +0 -17
- package/admin/src/hooks/usePermissionsDataManager/index.js +0 -7
- package/admin/src/shared/hooks/useAdminProvider/index.js +0 -11
- package/build/2224.8af54440.chunk.js +0 -138
- package/build/2379.f0baf826.chunk.js +0 -1
- package/build/2421.a478ba24.chunk.js +0 -105
- package/build/2801.c49f88a1.chunk.js +0 -1
- package/build/3911.d4fada48.chunk.js +0 -95
- package/build/412.72afdf0c.chunk.js +0 -689
- package/build/502.8666bbef.chunk.js +0 -25
- package/build/5702.5b433d50.chunk.js +0 -1
- package/build/6186.c33ce082.chunk.js +0 -116
- package/build/6715.48e37308.chunk.js +0 -1
- package/build/6812.00ef5b0d.chunk.js +0 -26
- package/build/7464.43a4527c.chunk.js +0 -1
- package/build/7818.d2196a53.chunk.js +0 -29
- package/build/7897.5c03247b.chunk.js +0 -25
- package/build/8690.33243bba.chunk.js +0 -38
- package/build/Admin-authenticatedApp.27545a1b.chunk.js +0 -112
- package/build/Admin_homePage.a6281dd6.chunk.js +0 -124
- package/build/Admin_settingsPage.33378310.chunk.js +0 -111
- package/build/admin-app.e8c52c37.chunk.js +0 -36
- package/build/admin-edit-roles-page.fcf056bf.chunk.js +0 -275
- package/build/admin-edit-users.89efe3c4.chunk.js +0 -10
- package/build/admin-roles-list.8b77704a.chunk.js +0 -22
- package/build/admin-users.e3f1be14.chunk.js +0 -19
- package/build/api-tokens-list-page.ae13346c.chunk.js +0 -16
- package/build/audit-logs-settings-page.e9c92a75.chunk.js +0 -9
- package/build/content-manager.5849dbe3.chunk.js +0 -1226
- package/build/email-settings-page.ecfec9b3.chunk.js +0 -11
- package/build/email-translation-ar-json.88304564.chunk.js +0 -1
- package/build/email-translation-cs-json.6eaeec6a.chunk.js +0 -1
- package/build/email-translation-de-json.1b334230.chunk.js +0 -1
- package/build/email-translation-dk-json.85402492.chunk.js +0 -1
- package/build/email-translation-en-json.4211d4d0.chunk.js +0 -1
- package/build/email-translation-es-json.0b6b1006.chunk.js +0 -1
- package/build/email-translation-fr-json.78be2787.chunk.js +0 -1
- package/build/email-translation-id-json.c97239fe.chunk.js +0 -1
- package/build/email-translation-it-json.a2ed8c78.chunk.js +0 -1
- package/build/email-translation-ja-json.63eebd02.chunk.js +0 -1
- package/build/email-translation-ko-json.4de49b23.chunk.js +0 -1
- package/build/email-translation-ms-json.7390477e.chunk.js +0 -1
- package/build/email-translation-nl-json.377bdd9f.chunk.js +0 -1
- package/build/email-translation-pl-json.97d0db97.chunk.js +0 -1
- package/build/email-translation-pt-BR-json.81cca553.chunk.js +0 -1
- package/build/email-translation-pt-json.2a2a0643.chunk.js +0 -1
- package/build/email-translation-ru-json.6bce37dd.chunk.js +0 -1
- package/build/email-translation-sk-json.53da2fcd.chunk.js +0 -1
- package/build/email-translation-th-json.660fa9a8.chunk.js +0 -1
- package/build/email-translation-tr-json.e6c0f8fc.chunk.js +0 -1
- package/build/email-translation-uk-json.bd1fb6bf.chunk.js +0 -1
- package/build/email-translation-vi-json.9fb7e6d7.chunk.js +0 -1
- package/build/email-translation-zh-Hans-json.c6841563.chunk.js +0 -1
- package/build/email-translation-zh-json.7a2232ea.chunk.js +0 -1
- package/build/main.3abb6f34.js +0 -3278
- package/build/review-workflows-settings-list-view.70218dc1.chunk.js +0 -75
- package/build/runtime~main.450561b1.js +0 -2
- package/build/sso-settings-page.1a9e7f8f.chunk.js +0 -1
- package/build/transfer-tokens-list-page.5de6bb9f.chunk.js +0 -16
- package/build/users-email-settings-page.47b47962.chunk.js +0 -149
- package/build/users-providers-settings-page.1e0c8376.chunk.js +0 -154
- /package/admin/src/hooks/{useAdminUsers/__mocks__/index.js → __mocks__/useAdminUsers.ts} +0 -0
- /package/admin/src/{hooks/useAdminRolePermissions/__mocks__/index.js → pages/SettingsPage/pages/Roles/hooks/__mocks__/useAdminRolePermissions.ts} +0 -0
package/admin/src/index.js
CHANGED
|
@@ -23,6 +23,9 @@ window.strapi = {
|
|
|
23
23
|
REVIEW_WORKFLOWS: 'review-workflows',
|
|
24
24
|
},
|
|
25
25
|
projectType: 'Community',
|
|
26
|
+
flags: {
|
|
27
|
+
nps: false,
|
|
28
|
+
},
|
|
26
29
|
};
|
|
27
30
|
|
|
28
31
|
const customConfig = appCustomisations;
|
|
@@ -41,16 +44,16 @@ const run = async () => {
|
|
|
41
44
|
try {
|
|
42
45
|
const {
|
|
43
46
|
data: {
|
|
44
|
-
data: { isEE, features },
|
|
47
|
+
data: { isEE, features, flags },
|
|
45
48
|
},
|
|
46
49
|
} = await get('/admin/project-type');
|
|
47
50
|
|
|
48
51
|
window.strapi.isEE = isEE;
|
|
52
|
+
window.strapi.flags = flags;
|
|
49
53
|
window.strapi.features = {
|
|
50
54
|
...window.strapi.features,
|
|
51
55
|
isEnabled: (featureName) => features.some((feature) => feature.name === featureName),
|
|
52
56
|
};
|
|
53
|
-
|
|
54
57
|
window.strapi.projectType = isEE ? 'Enterprise' : 'Community';
|
|
55
58
|
} catch (err) {
|
|
56
59
|
console.error(err);
|
|
@@ -9,10 +9,10 @@ import React from 'react';
|
|
|
9
9
|
import { SingleSelect, SingleSelectOption } from '@strapi/design-system';
|
|
10
10
|
import { useIntl } from 'react-intl';
|
|
11
11
|
|
|
12
|
-
import
|
|
12
|
+
import { useLocales } from '../../../components/LanguageProvider';
|
|
13
13
|
|
|
14
14
|
const LocaleToggle = () => {
|
|
15
|
-
const { changeLocale, localeNames } =
|
|
15
|
+
const { changeLocale, localeNames } = useLocales();
|
|
16
16
|
const { locale } = useIntl();
|
|
17
17
|
|
|
18
18
|
return (
|
|
@@ -13,8 +13,9 @@ import { useDispatch, useSelector } from 'react-redux';
|
|
|
13
13
|
import { Route, Switch } from 'react-router-dom';
|
|
14
14
|
|
|
15
15
|
import GuidedTourModal from '../../components/GuidedTour/Modal';
|
|
16
|
-
import LeftMenu from '../../components/LeftMenu';
|
|
17
|
-
import {
|
|
16
|
+
import { LeftMenu } from '../../components/LeftMenu';
|
|
17
|
+
import { useConfiguration } from '../../hooks/useConfiguration';
|
|
18
|
+
import { useMenu } from '../../hooks/useMenu';
|
|
18
19
|
import AppLayout from '../../layouts/AppLayout';
|
|
19
20
|
import { createRoute } from '../../utils';
|
|
20
21
|
import { SET_APP_RUNTIME_STATUS } from '../App/constants';
|
|
@@ -73,7 +74,7 @@ const Admin = () => {
|
|
|
73
74
|
useTrackUsage();
|
|
74
75
|
const { isLoading, generalSectionLinks, pluginsSectionLinks } = useMenu();
|
|
75
76
|
const { menu } = useStrapiApp();
|
|
76
|
-
const { showTutorials } =
|
|
77
|
+
const { showTutorials } = useConfiguration();
|
|
77
78
|
|
|
78
79
|
const routes = useMemo(() => {
|
|
79
80
|
return menu
|
|
@@ -23,7 +23,7 @@ import { Route, Switch } from 'react-router-dom';
|
|
|
23
23
|
|
|
24
24
|
import { PrivateRoute } from '../../components/PrivateRoute';
|
|
25
25
|
import { ADMIN_PERMISSIONS_CE } from '../../constants';
|
|
26
|
-
import {
|
|
26
|
+
import { useConfiguration } from '../../hooks/useConfiguration';
|
|
27
27
|
import { useEnterprise } from '../../hooks/useEnterprise';
|
|
28
28
|
import { createRoute, makeUniqueRoutes } from '../../utils';
|
|
29
29
|
import AuthPage from '../AuthPage';
|
|
@@ -57,7 +57,7 @@ function App() {
|
|
|
57
57
|
}
|
|
58
58
|
);
|
|
59
59
|
const toggleNotification = useNotification();
|
|
60
|
-
const { updateProjectSettings } =
|
|
60
|
+
const { updateProjectSettings } = useConfiguration();
|
|
61
61
|
const { formatMessage } = useIntl();
|
|
62
62
|
const [{ isLoading, hasAdmin, uuid, deviceId }, setState] = useState({
|
|
63
63
|
isLoading: true,
|
|
@@ -180,7 +180,9 @@ function App() {
|
|
|
180
180
|
|
|
181
181
|
return (
|
|
182
182
|
<Suspense fallback={<LoadingIndicatorPage />}>
|
|
183
|
-
<SkipToContent>
|
|
183
|
+
<SkipToContent>
|
|
184
|
+
{formatMessage({ id: 'skipToContent', defaultMessage: 'Skip to content' })}
|
|
185
|
+
</SkipToContent>
|
|
184
186
|
<TrackingProvider value={trackingInfo}>
|
|
185
187
|
<Switch>
|
|
186
188
|
{authRoutes}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
Box,
|
|
@@ -26,10 +26,11 @@ import { Formik } from 'formik';
|
|
|
26
26
|
import omit from 'lodash/omit';
|
|
27
27
|
import PropTypes from 'prop-types';
|
|
28
28
|
import { useIntl } from 'react-intl';
|
|
29
|
+
import { useQuery as useReactQuery } from 'react-query';
|
|
29
30
|
import { useHistory } from 'react-router-dom';
|
|
30
31
|
import styled from 'styled-components';
|
|
31
32
|
|
|
32
|
-
import { useNpsSurveySettings } from '../../../../components/NpsSurvey
|
|
33
|
+
import { useNpsSurveySettings } from '../../../../components/NpsSurvey';
|
|
33
34
|
import { Logo } from '../../../../components/UnauthenticatedLogo';
|
|
34
35
|
import UnauthenticatedLayout, { LayoutContent } from '../../../../layouts/UnauthenticatedLayout';
|
|
35
36
|
import FieldActionWrapper from '../FieldActionWrapper';
|
|
@@ -50,7 +51,6 @@ const Register = ({ authType, fieldsToDisable, noSignin, onSubmit, schema }) =>
|
|
|
50
51
|
const [passwordShown, setPasswordShown] = useState(false);
|
|
51
52
|
const [confirmPasswordShown, setConfirmPasswordShown] = useState(false);
|
|
52
53
|
const [submitCount, setSubmitCount] = useState(0);
|
|
53
|
-
const [userInfo, setUserInfo] = useState({});
|
|
54
54
|
const { trackUsage } = useTracking();
|
|
55
55
|
const { formatMessage } = useIntl();
|
|
56
56
|
const query = useQuery();
|
|
@@ -60,39 +60,34 @@ const Register = ({ authType, fieldsToDisable, noSignin, onSubmit, schema }) =>
|
|
|
60
60
|
|
|
61
61
|
const registrationToken = query.get('registrationToken');
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
});
|
|
63
|
+
const { data: userInfo } = useReactQuery({
|
|
64
|
+
queryKey: ['admin', 'registration-info', registrationToken],
|
|
65
|
+
async queryFn() {
|
|
66
|
+
const {
|
|
67
|
+
data: { data },
|
|
68
|
+
} = await get(`/admin/registration-info`, {
|
|
69
|
+
params: {
|
|
70
|
+
registrationToken,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
74
73
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
return data;
|
|
75
|
+
},
|
|
76
|
+
enabled: !!registrationToken,
|
|
77
|
+
initialData: {},
|
|
78
|
+
onError(err) {
|
|
79
|
+
const message = formatAPIError(err);
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
toggleNotification({
|
|
82
|
+
type: 'warning',
|
|
83
|
+
message,
|
|
84
|
+
});
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
getData();
|
|
93
|
-
}
|
|
94
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
95
|
-
}, [registrationToken]);
|
|
86
|
+
// Redirect to the oops page in case of an invalid token
|
|
87
|
+
// @alexandrebodin @JAB I am not sure it is the wanted behavior
|
|
88
|
+
push(`/auth/oops?info=${encodeURIComponent(message)}`);
|
|
89
|
+
},
|
|
90
|
+
});
|
|
96
91
|
|
|
97
92
|
function normalizeData(data) {
|
|
98
93
|
return Object.entries(data).reduce((acc, [key, value]) => {
|
|
@@ -9,7 +9,7 @@ import PropTypes from 'prop-types';
|
|
|
9
9
|
import { Redirect, useHistory, useRouteMatch } from 'react-router-dom';
|
|
10
10
|
|
|
11
11
|
import persistStateToLocaleStorage from '../../components/GuidedTour/utils/persistStateToLocaleStorage';
|
|
12
|
-
import
|
|
12
|
+
import { useLocales } from '../../components/LanguageProvider';
|
|
13
13
|
import { useEnterprise } from '../../hooks/useEnterprise';
|
|
14
14
|
import formatAPIErrors from '../../utils/formatAPIErrors';
|
|
15
15
|
|
|
@@ -23,7 +23,7 @@ const AuthPage = ({ hasAdmin, setHasAdmin }) => {
|
|
|
23
23
|
push,
|
|
24
24
|
location: { search },
|
|
25
25
|
} = useHistory();
|
|
26
|
-
const { changeLocale } =
|
|
26
|
+
const { changeLocale } = useLocales();
|
|
27
27
|
const { setSkipped } = useGuidedTour();
|
|
28
28
|
const { trackUsage } = useTracking();
|
|
29
29
|
const {
|
|
@@ -26,7 +26,7 @@ import { Helmet } from 'react-helmet';
|
|
|
26
26
|
import { useIntl } from 'react-intl';
|
|
27
27
|
import { useMutation, useQuery, useQueryClient } from 'react-query';
|
|
28
28
|
|
|
29
|
-
import
|
|
29
|
+
import { useLocales } from '../../components/LanguageProvider';
|
|
30
30
|
import { useThemeToggle } from '../../hooks/useThemeToggle';
|
|
31
31
|
import { getFullName } from '../../utils';
|
|
32
32
|
|
|
@@ -36,7 +36,7 @@ import UserInfo from './components/UserInfo';
|
|
|
36
36
|
import schema from './utils/schema';
|
|
37
37
|
|
|
38
38
|
const ProfilePage = () => {
|
|
39
|
-
const { changeLocale, localeNames } =
|
|
39
|
+
const { changeLocale, localeNames } = useLocales();
|
|
40
40
|
const { setUserDisplayName } = useAppInfo();
|
|
41
41
|
const queryClient = useQueryClient();
|
|
42
42
|
const { formatMessage } = useIntl();
|
|
@@ -27,102 +27,24 @@ const Table = ({
|
|
|
27
27
|
tokenType,
|
|
28
28
|
}) => {
|
|
29
29
|
const { canDelete, canUpdate, canRead } = permissions;
|
|
30
|
-
const withBulkActions = canDelete || canUpdate || canRead;
|
|
31
|
-
const [{ query }] = useQueryParams();
|
|
32
|
-
const { formatMessage } = useIntl();
|
|
33
|
-
const [, sortOrder] = query ? query.sort.split(':') : 'ASC';
|
|
34
|
-
const {
|
|
35
|
-
push,
|
|
36
|
-
location: { pathname },
|
|
37
|
-
} = useHistory();
|
|
38
|
-
const { trackUsage } = useTracking();
|
|
39
|
-
|
|
40
|
-
const sortedTokens = tokens.sort((a, b) => {
|
|
41
|
-
const comparison = a.name.localeCompare(b.name);
|
|
42
|
-
|
|
43
|
-
return sortOrder === 'DESC' ? -comparison : comparison;
|
|
44
|
-
});
|
|
45
30
|
|
|
31
|
+
/**
|
|
32
|
+
* TODO: This needs refactoring to the new `Table` component.
|
|
33
|
+
*/
|
|
46
34
|
return (
|
|
47
35
|
<DynamicTable
|
|
48
36
|
headers={headers}
|
|
49
37
|
contentType={contentType}
|
|
50
38
|
rows={tokens}
|
|
51
|
-
withBulkActions={
|
|
39
|
+
withBulkActions={canDelete || canUpdate || canRead}
|
|
52
40
|
isLoading={isLoading}
|
|
53
41
|
onConfirmDelete={onConfirmDelete}
|
|
54
42
|
>
|
|
55
|
-
<
|
|
56
|
-
{
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
{...onRowClick({
|
|
61
|
-
fn() {
|
|
62
|
-
trackUsage('willEditTokenFromList', {
|
|
63
|
-
tokenType,
|
|
64
|
-
});
|
|
65
|
-
push(`${pathname}/${token.id}`);
|
|
66
|
-
},
|
|
67
|
-
condition: canUpdate,
|
|
68
|
-
})}
|
|
69
|
-
>
|
|
70
|
-
<Td maxWidth={pxToRem(250)}>
|
|
71
|
-
<Typography textColor="neutral800" fontWeight="bold" ellipsis>
|
|
72
|
-
{token.name}
|
|
73
|
-
</Typography>
|
|
74
|
-
</Td>
|
|
75
|
-
<Td maxWidth={pxToRem(250)}>
|
|
76
|
-
<Typography textColor="neutral800" ellipsis>
|
|
77
|
-
{token.description}
|
|
78
|
-
</Typography>
|
|
79
|
-
</Td>
|
|
80
|
-
<Td>
|
|
81
|
-
<Typography textColor="neutral800">
|
|
82
|
-
<RelativeTime timestamp={new Date(token.createdAt)} />
|
|
83
|
-
</Typography>
|
|
84
|
-
</Td>
|
|
85
|
-
<Td>
|
|
86
|
-
{token.lastUsedAt && (
|
|
87
|
-
<Typography textColor="neutral800">
|
|
88
|
-
<RelativeTime
|
|
89
|
-
timestamp={new Date(token.lastUsedAt)}
|
|
90
|
-
customIntervals={[
|
|
91
|
-
{
|
|
92
|
-
unit: 'hours',
|
|
93
|
-
threshold: 1,
|
|
94
|
-
text: formatMessage({
|
|
95
|
-
id: 'Settings.apiTokens.lastHour',
|
|
96
|
-
defaultMessage: 'last hour',
|
|
97
|
-
}),
|
|
98
|
-
},
|
|
99
|
-
]}
|
|
100
|
-
/>
|
|
101
|
-
</Typography>
|
|
102
|
-
)}
|
|
103
|
-
</Td>
|
|
104
|
-
|
|
105
|
-
{withBulkActions && (
|
|
106
|
-
<Td>
|
|
107
|
-
<Flex justifyContent="end">
|
|
108
|
-
{canUpdate && <UpdateButton tokenName={token.name} tokenId={token.id} />}
|
|
109
|
-
{!canUpdate && canRead && (
|
|
110
|
-
<ReadButton tokenName={token.name} tokenId={token.id} />
|
|
111
|
-
)}
|
|
112
|
-
{canDelete && (
|
|
113
|
-
<DeleteButton
|
|
114
|
-
tokenName={token.name}
|
|
115
|
-
onClickDelete={() => onConfirmDelete(token.id)}
|
|
116
|
-
tokenType={tokenType}
|
|
117
|
-
/>
|
|
118
|
-
)}
|
|
119
|
-
</Flex>
|
|
120
|
-
</Td>
|
|
121
|
-
)}
|
|
122
|
-
</Tr>
|
|
123
|
-
);
|
|
124
|
-
})}
|
|
125
|
-
</Tbody>
|
|
43
|
+
<TableRows
|
|
44
|
+
tokenType={tokenType}
|
|
45
|
+
permissions={permissions}
|
|
46
|
+
onConfirmDelete={onConfirmDelete}
|
|
47
|
+
/>
|
|
126
48
|
</DynamicTable>
|
|
127
49
|
);
|
|
128
50
|
};
|
|
@@ -159,3 +81,113 @@ Table.defaultProps = {
|
|
|
159
81
|
};
|
|
160
82
|
|
|
161
83
|
export default Table;
|
|
84
|
+
|
|
85
|
+
const TableRows = ({ tokenType, permissions, rows, withBulkActions, onConfirmDelete }) => {
|
|
86
|
+
const { canDelete, canUpdate, canRead } = permissions;
|
|
87
|
+
|
|
88
|
+
const [{ query }] = useQueryParams();
|
|
89
|
+
const { formatMessage } = useIntl();
|
|
90
|
+
const [, sortOrder] = query ? query.sort.split(':') : 'ASC';
|
|
91
|
+
const {
|
|
92
|
+
push,
|
|
93
|
+
location: { pathname },
|
|
94
|
+
} = useHistory();
|
|
95
|
+
const { trackUsage } = useTracking();
|
|
96
|
+
|
|
97
|
+
const sortedTokens = rows.sort((a, b) => {
|
|
98
|
+
const comparison = a.name.localeCompare(b.name);
|
|
99
|
+
|
|
100
|
+
return sortOrder === 'DESC' ? -comparison : comparison;
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<Tbody>
|
|
105
|
+
{sortedTokens.map((token) => {
|
|
106
|
+
return (
|
|
107
|
+
<Tr
|
|
108
|
+
key={token.id}
|
|
109
|
+
{...onRowClick({
|
|
110
|
+
fn() {
|
|
111
|
+
trackUsage('willEditTokenFromList', {
|
|
112
|
+
tokenType,
|
|
113
|
+
});
|
|
114
|
+
push(`${pathname}/${token.id}`);
|
|
115
|
+
},
|
|
116
|
+
condition: canUpdate,
|
|
117
|
+
})}
|
|
118
|
+
>
|
|
119
|
+
<Td maxWidth={pxToRem(250)}>
|
|
120
|
+
<Typography textColor="neutral800" fontWeight="bold" ellipsis>
|
|
121
|
+
{token.name}
|
|
122
|
+
</Typography>
|
|
123
|
+
</Td>
|
|
124
|
+
<Td maxWidth={pxToRem(250)}>
|
|
125
|
+
<Typography textColor="neutral800" ellipsis>
|
|
126
|
+
{token.description}
|
|
127
|
+
</Typography>
|
|
128
|
+
</Td>
|
|
129
|
+
<Td>
|
|
130
|
+
<Typography textColor="neutral800">
|
|
131
|
+
<RelativeTime timestamp={new Date(token.createdAt)} />
|
|
132
|
+
</Typography>
|
|
133
|
+
</Td>
|
|
134
|
+
<Td>
|
|
135
|
+
{token.lastUsedAt && (
|
|
136
|
+
<Typography textColor="neutral800">
|
|
137
|
+
<RelativeTime
|
|
138
|
+
timestamp={new Date(token.lastUsedAt)}
|
|
139
|
+
customIntervals={[
|
|
140
|
+
{
|
|
141
|
+
unit: 'hours',
|
|
142
|
+
threshold: 1,
|
|
143
|
+
text: formatMessage({
|
|
144
|
+
id: 'Settings.apiTokens.lastHour',
|
|
145
|
+
defaultMessage: 'last hour',
|
|
146
|
+
}),
|
|
147
|
+
},
|
|
148
|
+
]}
|
|
149
|
+
/>
|
|
150
|
+
</Typography>
|
|
151
|
+
)}
|
|
152
|
+
</Td>
|
|
153
|
+
|
|
154
|
+
{withBulkActions && (
|
|
155
|
+
<Td>
|
|
156
|
+
<Flex justifyContent="end">
|
|
157
|
+
{canUpdate && <UpdateButton tokenName={token.name} tokenId={token.id} />}
|
|
158
|
+
{!canUpdate && canRead && (
|
|
159
|
+
<ReadButton tokenName={token.name} tokenId={token.id} />
|
|
160
|
+
)}
|
|
161
|
+
{canDelete && (
|
|
162
|
+
<DeleteButton
|
|
163
|
+
tokenName={token.name}
|
|
164
|
+
onClickDelete={() => onConfirmDelete(token.id)}
|
|
165
|
+
tokenType={tokenType}
|
|
166
|
+
/>
|
|
167
|
+
)}
|
|
168
|
+
</Flex>
|
|
169
|
+
</Td>
|
|
170
|
+
)}
|
|
171
|
+
</Tr>
|
|
172
|
+
);
|
|
173
|
+
})}
|
|
174
|
+
</Tbody>
|
|
175
|
+
);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
TableRows.defaultProps = {
|
|
179
|
+
rows: [],
|
|
180
|
+
withBulkActions: false,
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
TableRows.propTypes = {
|
|
184
|
+
rows: PropTypes.array,
|
|
185
|
+
permissions: PropTypes.shape({
|
|
186
|
+
canRead: PropTypes.bool,
|
|
187
|
+
canDelete: PropTypes.bool,
|
|
188
|
+
canUpdate: PropTypes.bool,
|
|
189
|
+
}).isRequired,
|
|
190
|
+
onConfirmDelete: PropTypes.func.isRequired,
|
|
191
|
+
tokenType: PropTypes.string.isRequired,
|
|
192
|
+
withBulkActions: PropTypes.bool,
|
|
193
|
+
};
|
|
@@ -5,7 +5,7 @@ import { useTracking } from '@strapi/helper-plugin';
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { useIntl } from 'react-intl';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { useConfiguration } from '../../../../../../hooks/useConfiguration';
|
|
9
9
|
import { DIMENSION, SIZE } from '../../utils/constants';
|
|
10
10
|
import LogoInput from '../LogoInput';
|
|
11
11
|
|
|
@@ -17,7 +17,7 @@ const CustomizationInfos = forwardRef(({ canUpdate, projectSettingsStored }, ref
|
|
|
17
17
|
const { trackUsage } = useTracking();
|
|
18
18
|
const {
|
|
19
19
|
logos: { menu, auth },
|
|
20
|
-
} =
|
|
20
|
+
} = useConfiguration();
|
|
21
21
|
const [{ menuLogo, authLogo }, dispatch] = useReducer(reducer, initialState, () =>
|
|
22
22
|
init(initialState, projectSettingsStored)
|
|
23
23
|
);
|
|
@@ -29,7 +29,7 @@ import { useIntl } from 'react-intl';
|
|
|
29
29
|
import { useMutation, useQuery } from 'react-query';
|
|
30
30
|
import { useSelector } from 'react-redux';
|
|
31
31
|
|
|
32
|
-
import {
|
|
32
|
+
import { useConfiguration } from '../../../../hooks/useConfiguration';
|
|
33
33
|
import { useEnterprise } from '../../../../hooks/useEnterprise';
|
|
34
34
|
import { selectAdminPermissions } from '../../../App/selectors';
|
|
35
35
|
|
|
@@ -44,7 +44,7 @@ const ApplicationInfosPage = () => {
|
|
|
44
44
|
const { trackUsage } = useTracking();
|
|
45
45
|
const { formatMessage } = useIntl();
|
|
46
46
|
const { get, post } = useFetchClient();
|
|
47
|
-
const { updateProjectSettings } =
|
|
47
|
+
const { updateProjectSettings } = useConfiguration();
|
|
48
48
|
const permissions = useSelector(selectAdminPermissions);
|
|
49
49
|
const { formatAPIError } = useAPIErrorHandler();
|
|
50
50
|
|
|
@@ -33,10 +33,10 @@ import { useSelector } from 'react-redux';
|
|
|
33
33
|
import { useHistory, useRouteMatch } from 'react-router-dom';
|
|
34
34
|
import styled from 'styled-components';
|
|
35
35
|
|
|
36
|
-
import { useAdminRolePermissions } from '../../../../../hooks/useAdminRolePermissions';
|
|
37
36
|
import { selectAdminPermissions } from '../../../../App/selectors';
|
|
38
37
|
import Permissions from '../EditPage/components/Permissions';
|
|
39
38
|
import { useAdminRolePermissionLayout } from '../hooks/useAdminRolePermissionLayout';
|
|
39
|
+
import { useAdminRolePermissions } from '../hooks/useAdminRolePermissions';
|
|
40
40
|
|
|
41
41
|
import schema from './utils/schema';
|
|
42
42
|
|
package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/ConditionsModal/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import upperFirst from 'lodash/upperFirst';
|
|
|
16
16
|
import PropTypes from 'prop-types';
|
|
17
17
|
import { useIntl } from 'react-intl';
|
|
18
18
|
|
|
19
|
-
import { usePermissionsDataManager } from '
|
|
19
|
+
import { usePermissionsDataManager } from '../../hooks/usePermissionsDataManager';
|
|
20
20
|
|
|
21
21
|
import ActionRow from './ActionRow';
|
|
22
22
|
import createDefaultConditionsForm from './utils/createDefaultConditionsForm';
|
|
@@ -8,7 +8,7 @@ import PropTypes from 'prop-types';
|
|
|
8
8
|
import { useIntl } from 'react-intl';
|
|
9
9
|
import styled from 'styled-components';
|
|
10
10
|
|
|
11
|
-
import { usePermissionsDataManager } from '
|
|
11
|
+
import { usePermissionsDataManager } from '../../../hooks/usePermissionsDataManager';
|
|
12
12
|
import ConditionsButton from '../../ConditionsButton';
|
|
13
13
|
import ConditionsModal from '../../ConditionsModal';
|
|
14
14
|
import HiddenAction from '../../HiddenAction';
|
|
@@ -6,7 +6,7 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import { useIntl } from 'react-intl';
|
|
7
7
|
import styled from 'styled-components';
|
|
8
8
|
|
|
9
|
-
import { usePermissionsDataManager } from '
|
|
9
|
+
import { usePermissionsDataManager } from '../../../../hooks/usePermissionsDataManager';
|
|
10
10
|
import HiddenAction from '../../../HiddenAction';
|
|
11
11
|
import { cellWidth, rowHeight } from '../../../Permissions/utils/constants';
|
|
12
12
|
import RequiredSign from '../../../RequiredSign';
|
|
@@ -7,7 +7,7 @@ import PropTypes from 'prop-types';
|
|
|
7
7
|
import { useIntl } from 'react-intl';
|
|
8
8
|
import styled from 'styled-components';
|
|
9
9
|
|
|
10
|
-
import { usePermissionsDataManager } from '
|
|
10
|
+
import { usePermissionsDataManager } from '../../../../hooks/usePermissionsDataManager';
|
|
11
11
|
import CollapseLabel from '../../../CollapseLabel';
|
|
12
12
|
import Curve from '../../../Curve';
|
|
13
13
|
import HiddenAction from '../../../HiddenAction';
|
|
@@ -6,7 +6,7 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import { useIntl } from 'react-intl';
|
|
7
7
|
import styled from 'styled-components';
|
|
8
8
|
|
|
9
|
-
import { usePermissionsDataManager } from '
|
|
9
|
+
import { usePermissionsDataManager } from '../../hooks/usePermissionsDataManager';
|
|
10
10
|
import { cellWidth, firstRowWidth } from '../Permissions/utils/constants';
|
|
11
11
|
|
|
12
12
|
import { findDisplayedActions, getCheckboxesState } from './utils';
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
|
|
5
|
-
import { PermissionsDataManagerContext } from '
|
|
5
|
+
import { PermissionsDataManagerContext } from '../../hooks/usePermissionsDataManager';
|
|
6
6
|
|
|
7
7
|
const PermissionsDataManagerProvider = ({ children, value }) => {
|
|
8
8
|
return (
|
|
@@ -6,7 +6,7 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import { useIntl } from 'react-intl';
|
|
7
7
|
import styled from 'styled-components';
|
|
8
8
|
|
|
9
|
-
import { usePermissionsDataManager } from '
|
|
9
|
+
import { usePermissionsDataManager } from '../../../hooks/usePermissionsDataManager';
|
|
10
10
|
import ConditionsButton from '../../ConditionsButton';
|
|
11
11
|
import ConditionsModal from '../../ConditionsModal';
|
|
12
12
|
import { getCheckboxState, removeConditionKeyFromData } from '../../utils';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
// Note: I had to guess most of these types based on the name and usage, but I actually don't
|
|
4
|
+
// know if they are correct, because the usage is very generic. Feel free to correct them if
|
|
5
|
+
// they create problems.
|
|
6
|
+
export interface PermissionsDataManagerContextValue {
|
|
7
|
+
availableConditions: unknown[];
|
|
8
|
+
modifiedData: object;
|
|
9
|
+
onChangeCollectionTypeLeftActionRowCheckbox: (
|
|
10
|
+
pathToData: string,
|
|
11
|
+
propertyName: string,
|
|
12
|
+
nam: string,
|
|
13
|
+
value: unknown
|
|
14
|
+
) => void;
|
|
15
|
+
onChangeConditions: (conditions: object) => void;
|
|
16
|
+
onChangeSimpleCheckbox: (target: { name: string; value: unknown }) => void;
|
|
17
|
+
onChangeParentCheckbox: (target: { name: string; value: unknown }) => void;
|
|
18
|
+
onChangeCollectionTypeGlobalActionCheckbox: (
|
|
19
|
+
kind: string,
|
|
20
|
+
actionId: string,
|
|
21
|
+
value: unknown
|
|
22
|
+
) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const PermissionsDataManagerContext =
|
|
26
|
+
React.createContext<PermissionsDataManagerContextValue | null>(null);
|
|
27
|
+
|
|
28
|
+
export const usePermissionsDataManager = () => React.useContext(PermissionsDataManagerContext);
|
|
@@ -16,9 +16,9 @@ import { Formik } from 'formik';
|
|
|
16
16
|
import { useIntl } from 'react-intl';
|
|
17
17
|
import { useRouteMatch } from 'react-router-dom';
|
|
18
18
|
|
|
19
|
-
import { useAdminRolePermissions } from '../../../../../hooks/useAdminRolePermissions';
|
|
20
19
|
import { useAdminRoles } from '../../../../../hooks/useAdminRoles';
|
|
21
20
|
import { useAdminRolePermissionLayout } from '../hooks/useAdminRolePermissionLayout';
|
|
21
|
+
import { useAdminRolePermissions } from '../hooks/useAdminRolePermissions';
|
|
22
22
|
|
|
23
23
|
import { Permissions, RoleForm } from './components';
|
|
24
24
|
import schema from './utils/schema';
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import { useFetchClient } from '@strapi/helper-plugin';
|
|
2
|
+
import { Entity } from '@strapi/types';
|
|
2
3
|
import { useQuery } from 'react-query';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
import { RolePermissions } from '../../../../../../../shared/permissions';
|
|
6
|
+
import { APIBaseParams, APIResponse } from '../../../../../types/adminAPI';
|
|
7
|
+
|
|
8
|
+
export interface APIRolePermissionsQueryParams extends APIBaseParams {
|
|
9
|
+
id: null | Entity.ID;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const useAdminRolePermissions = (
|
|
13
|
+
params: APIRolePermissionsQueryParams = { id: null },
|
|
14
|
+
queryOptions = {}
|
|
15
|
+
) => {
|
|
5
16
|
const { id, ...queryParams } = params;
|
|
6
17
|
|
|
7
18
|
const { get } = useFetchClient();
|
|
8
19
|
|
|
9
|
-
if (!id && (queryOptions?.enabled === undefined || !!queryOptions?.enabled === true)) {
|
|
10
|
-
throw new Error('"id" is a required argument');
|
|
11
|
-
}
|
|
12
|
-
|
|
13
20
|
const {
|
|
14
21
|
data: permissions,
|
|
15
22
|
error,
|
|
@@ -21,7 +28,7 @@ export const useAdminRolePermissions = (params = {}, queryOptions = {}) => {
|
|
|
21
28
|
async () => {
|
|
22
29
|
const {
|
|
23
30
|
data: { data },
|
|
24
|
-
} = await get(`/admin/roles/${id}/permissions`, {
|
|
31
|
+
} = await get<APIResponse<RolePermissions>>(`/admin/roles/${id}/permissions`, {
|
|
25
32
|
params: queryParams,
|
|
26
33
|
});
|
|
27
34
|
|