@strapi/plugin-users-permissions 5.0.0-alpha.0 → 5.0.0-alpha.2
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/index.js +1 -2
- package/admin/src/pages/AdvancedSettings/index.jsx +4 -6
- package/admin/src/pages/EmailTemplates/components/EmailTable.jsx +4 -5
- package/admin/src/pages/EmailTemplates/index.jsx +5 -7
- package/admin/src/pages/Providers/index.jsx +6 -18
- package/admin/src/pages/Roles/hooks/usePlugins.js +1 -2
- package/admin/src/pages/Roles/pages/CreatePage.jsx +1 -2
- package/admin/src/pages/Roles/pages/EditPage.jsx +7 -2
- package/admin/src/pages/Roles/pages/ListPage/components/TableBody.jsx +2 -3
- package/admin/src/pages/Roles/pages/ListPage/index.jsx +33 -6
- package/admin/src/utils/prefixPluginTranslations.js +13 -0
- package/dist/_chunks/{EditViewPage-xYzUSAwS-wpHlxdkC.js → EditViewPage-JFzIJClS-9jnyNYlZ.js} +181 -167
- package/dist/_chunks/{EditViewPage-xYzUSAwS-wpHlxdkC.js.map → EditViewPage-JFzIJClS-9jnyNYlZ.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-xYzUSAwS-5mOQ_-nB.mjs → EditViewPage-JFzIJClS-SluImrzz.mjs} +44 -32
- package/dist/_chunks/EditViewPage-JFzIJClS-SluImrzz.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-xOVa04T_-elahT0e9.js → ListViewPage-1VNVP9Rw-94jqnla4.js} +104 -105
- package/dist/_chunks/ListViewPage-1VNVP9Rw-94jqnla4.js.map +1 -0
- package/dist/_chunks/{ListViewPage-xOVa04T_-lbfb219V.mjs → ListViewPage-1VNVP9Rw-Ce-HkFp1.mjs} +9 -10
- package/dist/_chunks/ListViewPage-1VNVP9Rw-Ce-HkFp1.mjs.map +1 -0
- package/dist/_chunks/{ReviewWorkflowsColumn-FDxVKdto-IWfB3WVH.mjs → ReviewWorkflowsColumn-sPZxvFUd-Cd4JhTlj.mjs} +2 -2
- package/dist/_chunks/{ReviewWorkflowsColumn-FDxVKdto-IWfB3WVH.mjs.map → ReviewWorkflowsColumn-sPZxvFUd-Cd4JhTlj.mjs.map} +1 -1
- package/dist/_chunks/{ReviewWorkflowsColumn-FDxVKdto-m8hslkeI.js → ReviewWorkflowsColumn-sPZxvFUd-S2eFi9Dy.js} +5 -5
- package/dist/_chunks/{ReviewWorkflowsColumn-FDxVKdto-m8hslkeI.js.map → ReviewWorkflowsColumn-sPZxvFUd-S2eFi9Dy.js.map} +1 -1
- package/dist/_chunks/{constants-WjN6I3sL-7e3gpx4b.mjs → constants-0OGkpIzK-R5N7-OUr.mjs} +2 -2
- package/dist/_chunks/{constants-WjN6I3sL-7e3gpx4b.mjs.map → constants-0OGkpIzK-R5N7-OUr.mjs.map} +1 -1
- package/dist/_chunks/{constants-WjN6I3sL-cDZPE6ED.js → constants-0OGkpIzK-f_M9PDKN.js} +18 -18
- package/dist/_chunks/{constants-WjN6I3sL-cDZPE6ED.js.map → constants-0OGkpIzK-f_M9PDKN.js.map} +1 -1
- package/dist/_chunks/{index-VgvlwVA7.js → index-6X9XaLjS.js} +10 -11
- package/dist/_chunks/index-6X9XaLjS.js.map +1 -0
- package/dist/_chunks/{index-5ZvCaCyY-06DLg5eU.mjs → index-GIVuHJgC-_q6V7_2B.mjs} +2822 -2710
- package/dist/_chunks/index-GIVuHJgC-_q6V7_2B.mjs.map +1 -0
- package/dist/_chunks/{index-5ZvCaCyY-JgYo3Jws.js → index-GIVuHJgC-tj2acNbO.js} +2791 -2679
- package/dist/_chunks/index-GIVuHJgC-tj2acNbO.js.map +1 -0
- package/dist/_chunks/{index-TJUxOCtJ.js → index-Q5NQ4RI9.js} +20 -12
- package/dist/_chunks/index-Q5NQ4RI9.js.map +1 -0
- package/dist/_chunks/{index-MEUac_4V.js → index-RT4MW9Nr.js} +35 -37
- package/dist/_chunks/index-RT4MW9Nr.js.map +1 -0
- package/dist/_chunks/{index-A3oJlPcE.mjs → index-av_iGW-0.mjs} +31 -33
- package/dist/_chunks/index-av_iGW-0.mjs.map +1 -0
- package/dist/_chunks/{index-bRuKnVcH.js → index-heeE_h30.js} +8 -12
- package/dist/_chunks/index-heeE_h30.js.map +1 -0
- package/dist/_chunks/{index-53jX2hhF.mjs → index-iaIILeuQ.mjs} +19 -11
- package/dist/_chunks/index-iaIILeuQ.mjs.map +1 -0
- package/dist/_chunks/{index-vXywiVeM.mjs → index-pDvppjQG.mjs} +11 -12
- package/dist/_chunks/index-pDvppjQG.mjs.map +1 -0
- package/dist/_chunks/{index-mzJ2Vb5u.js → index-tFzYCM9l.js} +4 -5
- package/dist/_chunks/index-tFzYCM9l.js.map +1 -0
- package/dist/_chunks/{index-ee_14Ldw.mjs → index-vvcDunmb.mjs} +9 -13
- package/dist/_chunks/index-vvcDunmb.mjs.map +1 -0
- package/dist/_chunks/{index-N-GcFWtg.mjs → index-whB2wk2v.mjs} +6 -7
- package/dist/_chunks/index-whB2wk2v.mjs.map +1 -0
- package/dist/_chunks/{useSyncRbac-Kt8Li0Yf-Z54sMEPM.mjs → useSyncRbac-JNQibLFa-D0RzXrU4.mjs} +2 -2
- package/dist/_chunks/{useSyncRbac-Kt8Li0Yf-Z54sMEPM.mjs.map → useSyncRbac-JNQibLFa-D0RzXrU4.mjs.map} +1 -1
- package/dist/_chunks/{useSyncRbac-Kt8Li0Yf-h8HqtZ6y.js → useSyncRbac-JNQibLFa-G2N9BPgu.js} +7 -7
- package/dist/_chunks/{useSyncRbac-Kt8Li0Yf-h8HqtZ6y.js.map → useSyncRbac-JNQibLFa-G2N9BPgu.js.map} +1 -1
- package/dist/admin/index.js +1 -2
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +1 -2
- package/dist/admin/index.mjs.map +1 -1
- package/package.json +6 -6
- package/admin/src/pages/Roles/pages/ListPage/utils/api.js +0 -30
- package/dist/_chunks/EditViewPage-xYzUSAwS-5mOQ_-nB.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-xOVa04T_-elahT0e9.js.map +0 -1
- package/dist/_chunks/ListViewPage-xOVa04T_-lbfb219V.mjs.map +0 -1
- package/dist/_chunks/index-53jX2hhF.mjs.map +0 -1
- package/dist/_chunks/index-5ZvCaCyY-06DLg5eU.mjs.map +0 -1
- package/dist/_chunks/index-5ZvCaCyY-JgYo3Jws.js.map +0 -1
- package/dist/_chunks/index-A3oJlPcE.mjs.map +0 -1
- package/dist/_chunks/index-MEUac_4V.js.map +0 -1
- package/dist/_chunks/index-N-GcFWtg.mjs.map +0 -1
- package/dist/_chunks/index-TJUxOCtJ.js.map +0 -1
- package/dist/_chunks/index-VgvlwVA7.js.map +0 -1
- package/dist/_chunks/index-bRuKnVcH.js.map +0 -1
- package/dist/_chunks/index-ee_14Ldw.mjs.map +0 -1
- package/dist/_chunks/index-mzJ2Vb5u.js.map +0 -1
- package/dist/_chunks/index-vXywiVeM.mjs.map +0 -1
package/admin/src/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { prefixPluginTranslations } from '@strapi/helper-plugin';
|
|
2
|
-
|
|
3
1
|
import pluginPkg from '../../package.json';
|
|
4
2
|
|
|
5
3
|
import { PERMISSIONS } from './constants';
|
|
6
4
|
import getTrad from './utils/getTrad';
|
|
5
|
+
import { prefixPluginTranslations } from './utils/prefixPluginTranslations';
|
|
7
6
|
|
|
8
7
|
const name = pluginPkg.strapi.name;
|
|
9
8
|
|
|
@@ -8,11 +8,10 @@ import {
|
|
|
8
8
|
Grid,
|
|
9
9
|
GridItem,
|
|
10
10
|
HeaderLayout,
|
|
11
|
-
Main,
|
|
12
11
|
Typography,
|
|
13
12
|
useNotifyAT,
|
|
14
13
|
} from '@strapi/design-system';
|
|
15
|
-
import {
|
|
14
|
+
import { useRBAC } from '@strapi/helper-plugin';
|
|
16
15
|
import { Check } from '@strapi/icons';
|
|
17
16
|
import {
|
|
18
17
|
useAPIErrorHandler,
|
|
@@ -20,6 +19,7 @@ import {
|
|
|
20
19
|
Form,
|
|
21
20
|
InputRenderer,
|
|
22
21
|
useNotification,
|
|
22
|
+
useFetchClient,
|
|
23
23
|
} from '@strapi/strapi/admin';
|
|
24
24
|
import { Helmet } from 'react-helmet';
|
|
25
25
|
import { useIntl } from 'react-intl';
|
|
@@ -45,8 +45,6 @@ const AdvancedSettingsPage = () => {
|
|
|
45
45
|
const { get, put } = useFetchClient();
|
|
46
46
|
const { formatAPIError } = useAPIErrorHandler();
|
|
47
47
|
|
|
48
|
-
useFocusWhenNavigate();
|
|
49
|
-
|
|
50
48
|
const {
|
|
51
49
|
isLoading: isLoadingForPermissions,
|
|
52
50
|
allowedActions: { canUpdate },
|
|
@@ -119,7 +117,7 @@ const AdvancedSettingsPage = () => {
|
|
|
119
117
|
}
|
|
120
118
|
|
|
121
119
|
return (
|
|
122
|
-
<Main aria-busy={isSubmittingForm}>
|
|
120
|
+
<Page.Main aria-busy={isSubmittingForm}>
|
|
123
121
|
<Helmet
|
|
124
122
|
title={formatMessage(
|
|
125
123
|
{ id: 'Settings.PageTitle', defaultMessage: 'Settings - {name}' },
|
|
@@ -214,7 +212,7 @@ const AdvancedSettingsPage = () => {
|
|
|
214
212
|
);
|
|
215
213
|
}}
|
|
216
214
|
</Form>
|
|
217
|
-
</Main>
|
|
215
|
+
</Page.Main>
|
|
218
216
|
);
|
|
219
217
|
};
|
|
220
218
|
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
Typography,
|
|
13
13
|
VisuallyHidden,
|
|
14
14
|
} from '@strapi/design-system';
|
|
15
|
-
import { onRowClick, stopPropagation } from '@strapi/helper-plugin';
|
|
16
15
|
import { Check, Pencil, Refresh } from '@strapi/icons';
|
|
17
16
|
import PropTypes from 'prop-types';
|
|
18
17
|
import { useIntl } from 'react-intl';
|
|
@@ -53,7 +52,7 @@ const EmailTable = ({ canUpdate, onEditClick }) => {
|
|
|
53
52
|
</Tr>
|
|
54
53
|
</Thead>
|
|
55
54
|
<Tbody>
|
|
56
|
-
<Tr {
|
|
55
|
+
<Tr onClick={() => onEditClick('reset_password')}>
|
|
57
56
|
<Td>
|
|
58
57
|
<Icon>
|
|
59
58
|
<Refresh
|
|
@@ -72,7 +71,7 @@ const EmailTable = ({ canUpdate, onEditClick }) => {
|
|
|
72
71
|
})}
|
|
73
72
|
</Typography>
|
|
74
73
|
</Td>
|
|
75
|
-
<Td {
|
|
74
|
+
<Td onClick={(e) => e.stopPropagation()}>
|
|
76
75
|
<IconButton
|
|
77
76
|
onClick={() => onEditClick('reset_password')}
|
|
78
77
|
label={formatMessage({
|
|
@@ -84,7 +83,7 @@ const EmailTable = ({ canUpdate, onEditClick }) => {
|
|
|
84
83
|
/>
|
|
85
84
|
</Td>
|
|
86
85
|
</Tr>
|
|
87
|
-
<Tr {
|
|
86
|
+
<Tr onClick={() => onEditClick('email_confirmation')}>
|
|
88
87
|
<Td>
|
|
89
88
|
<Icon>
|
|
90
89
|
<Check
|
|
@@ -103,7 +102,7 @@ const EmailTable = ({ canUpdate, onEditClick }) => {
|
|
|
103
102
|
})}
|
|
104
103
|
</Typography>
|
|
105
104
|
</Td>
|
|
106
|
-
<Td {
|
|
105
|
+
<Td onClick={(e) => e.stopPropagation()}>
|
|
107
106
|
<IconButton
|
|
108
107
|
onClick={() => onEditClick('email_confirmation')}
|
|
109
108
|
label={formatMessage({
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
3
|
import { useTracking } from '@strapi/admin/strapi-admin';
|
|
4
|
-
import { ContentLayout, HeaderLayout,
|
|
5
|
-
import {
|
|
6
|
-
import { Page, useAPIErrorHandler, useNotification } from '@strapi/strapi/admin';
|
|
4
|
+
import { ContentLayout, HeaderLayout, useNotifyAT } from '@strapi/design-system';
|
|
5
|
+
import { useRBAC } from '@strapi/helper-plugin';
|
|
6
|
+
import { Page, useAPIErrorHandler, useNotification, useFetchClient } from '@strapi/strapi/admin';
|
|
7
7
|
import { Helmet } from 'react-helmet';
|
|
8
8
|
import { useIntl } from 'react-intl';
|
|
9
9
|
import { useMutation, useQuery, useQueryClient } from 'react-query';
|
|
@@ -28,8 +28,6 @@ const EmailTemplatesPage = () => {
|
|
|
28
28
|
const { get, put } = useFetchClient();
|
|
29
29
|
const { formatAPIError } = useAPIErrorHandler();
|
|
30
30
|
|
|
31
|
-
useFocusWhenNavigate();
|
|
32
|
-
|
|
33
31
|
const [isModalOpen, setIsModalOpen] = React.useState(false);
|
|
34
32
|
const [templateToEdit, setTemplateToEdit] = React.useState(null);
|
|
35
33
|
|
|
@@ -111,7 +109,7 @@ const EmailTemplatesPage = () => {
|
|
|
111
109
|
}
|
|
112
110
|
|
|
113
111
|
return (
|
|
114
|
-
<Main aria-busy={submitMutation.isLoading}>
|
|
112
|
+
<Page.Main aria-busy={submitMutation.isLoading}>
|
|
115
113
|
<Helmet
|
|
116
114
|
title={formatMessage(
|
|
117
115
|
{ id: 'Settings.PageTitle', defaultMessage: 'Settings - {name}' },
|
|
@@ -139,7 +137,7 @@ const EmailTemplatesPage = () => {
|
|
|
139
137
|
/>
|
|
140
138
|
)}
|
|
141
139
|
</ContentLayout>
|
|
142
|
-
</Main>
|
|
140
|
+
</Page.Main>
|
|
143
141
|
);
|
|
144
142
|
};
|
|
145
143
|
|
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
HeaderLayout,
|
|
7
7
|
IconButton,
|
|
8
8
|
Layout,
|
|
9
|
-
Main,
|
|
10
9
|
Table,
|
|
11
10
|
Tbody,
|
|
12
11
|
Td,
|
|
@@ -17,15 +16,9 @@ import {
|
|
|
17
16
|
VisuallyHidden,
|
|
18
17
|
useCollator,
|
|
19
18
|
} from '@strapi/design-system';
|
|
20
|
-
import {
|
|
21
|
-
onRowClick,
|
|
22
|
-
stopPropagation,
|
|
23
|
-
useFetchClient,
|
|
24
|
-
useFocusWhenNavigate,
|
|
25
|
-
useRBAC,
|
|
26
|
-
} from '@strapi/helper-plugin';
|
|
19
|
+
import { useRBAC } from '@strapi/helper-plugin';
|
|
27
20
|
import { Pencil } from '@strapi/icons';
|
|
28
|
-
import { Page, useAPIErrorHandler, useNotification } from '@strapi/strapi/admin';
|
|
21
|
+
import { Page, useAPIErrorHandler, useNotification, useFetchClient } from '@strapi/strapi/admin';
|
|
29
22
|
import upperFirst from 'lodash/upperFirst';
|
|
30
23
|
import { Helmet } from 'react-helmet';
|
|
31
24
|
import { useIntl } from 'react-intl';
|
|
@@ -50,8 +43,6 @@ export const ProvidersPage = () => {
|
|
|
50
43
|
sensitivity: 'base',
|
|
51
44
|
});
|
|
52
45
|
|
|
53
|
-
useFocusWhenNavigate();
|
|
54
|
-
|
|
55
46
|
const {
|
|
56
47
|
isLoading: isLoadingPermissions,
|
|
57
48
|
allowedActions: { canUpdate },
|
|
@@ -164,7 +155,7 @@ export const ProvidersPage = () => {
|
|
|
164
155
|
}
|
|
165
156
|
)}
|
|
166
157
|
/>
|
|
167
|
-
<Main>
|
|
158
|
+
<Page.Main>
|
|
168
159
|
<HeaderLayout
|
|
169
160
|
title={formatMessage({
|
|
170
161
|
id: getTrad('HeaderNav.link.providers'),
|
|
@@ -201,10 +192,7 @@ export const ProvidersPage = () => {
|
|
|
201
192
|
{providers.map((provider) => (
|
|
202
193
|
<Tr
|
|
203
194
|
key={provider.name}
|
|
204
|
-
{
|
|
205
|
-
fn: () => handleClickEdit(provider),
|
|
206
|
-
condition: canUpdate,
|
|
207
|
-
})}
|
|
195
|
+
onClick={() => (canUpdate ? handleClickEdit(provider) : undefined)}
|
|
208
196
|
>
|
|
209
197
|
<Td width="45%">
|
|
210
198
|
<Typography fontWeight="semiBold" textColor="neutral800">
|
|
@@ -227,7 +215,7 @@ export const ProvidersPage = () => {
|
|
|
227
215
|
})}
|
|
228
216
|
</Typography>
|
|
229
217
|
</Td>
|
|
230
|
-
<Td {
|
|
218
|
+
<Td onClick={(e) => e.stopPropagation()}>
|
|
231
219
|
{canUpdate && (
|
|
232
220
|
<IconButton
|
|
233
221
|
onClick={() => handleClickEdit(provider)}
|
|
@@ -242,7 +230,7 @@ export const ProvidersPage = () => {
|
|
|
242
230
|
</Tbody>
|
|
243
231
|
</Table>
|
|
244
232
|
</ContentLayout>
|
|
245
|
-
</Main>
|
|
233
|
+
</Page.Main>
|
|
246
234
|
<FormModal
|
|
247
235
|
initialData={data[providerToEditName]}
|
|
248
236
|
isOpen={isOpen}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
|
|
3
|
-
import { useFetchClient } from '@strapi/
|
|
4
|
-
import { useAPIErrorHandler, useNotification } from '@strapi/strapi/admin';
|
|
3
|
+
import { useAPIErrorHandler, useNotification, useFetchClient } from '@strapi/strapi/admin';
|
|
5
4
|
import { useQueries } from 'react-query';
|
|
6
5
|
|
|
7
6
|
import { cleanPermissions, getTrad } from '../../../utils';
|
|
@@ -12,9 +12,8 @@ import {
|
|
|
12
12
|
TextInput,
|
|
13
13
|
Typography,
|
|
14
14
|
} from '@strapi/design-system';
|
|
15
|
-
import { useFetchClient } from '@strapi/helper-plugin';
|
|
16
15
|
import { Check } from '@strapi/icons';
|
|
17
|
-
import { Page, useTracking, useNotification } from '@strapi/strapi/admin';
|
|
16
|
+
import { Page, useTracking, useNotification, useFetchClient } from '@strapi/strapi/admin';
|
|
18
17
|
import { Formik, Form } from 'formik';
|
|
19
18
|
import { Helmet } from 'react-helmet';
|
|
20
19
|
import { useIntl } from 'react-intl';
|
|
@@ -12,9 +12,14 @@ import {
|
|
|
12
12
|
GridItem,
|
|
13
13
|
Grid,
|
|
14
14
|
} from '@strapi/design-system';
|
|
15
|
-
import { useFetchClient } from '@strapi/helper-plugin';
|
|
16
15
|
import { Check } from '@strapi/icons';
|
|
17
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
Page,
|
|
18
|
+
BackButton,
|
|
19
|
+
useAPIErrorHandler,
|
|
20
|
+
useNotification,
|
|
21
|
+
useFetchClient,
|
|
22
|
+
} from '@strapi/strapi/admin';
|
|
18
23
|
import { Formik, Form } from 'formik';
|
|
19
24
|
import { Helmet } from 'react-helmet';
|
|
20
25
|
import { useIntl } from 'react-intl';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import { Flex, IconButton, Link, Tbody, Td, Tr, Typography } from '@strapi/design-system';
|
|
4
|
-
import { onRowClick, stopPropagation } from '@strapi/helper-plugin';
|
|
5
4
|
import { Pencil, Trash } from '@strapi/icons';
|
|
6
5
|
import PropTypes from 'prop-types';
|
|
7
6
|
import { useIntl } from 'react-intl';
|
|
@@ -51,7 +50,7 @@ const TableBody = ({ sortedRoles, canDelete, canUpdate, setRoleToDelete, onDelet
|
|
|
51
50
|
return (
|
|
52
51
|
<Tbody>
|
|
53
52
|
{sortedRoles?.map((role) => (
|
|
54
|
-
<Tr key={role.name} {
|
|
53
|
+
<Tr key={role.name} onClick={() => navigate(role.id.toString())}>
|
|
55
54
|
<Td width="20%">
|
|
56
55
|
<Typography>{role.name}</Typography>
|
|
57
56
|
</Td>
|
|
@@ -70,7 +69,7 @@ const TableBody = ({ sortedRoles, canDelete, canUpdate, setRoleToDelete, onDelet
|
|
|
70
69
|
</Typography>
|
|
71
70
|
</Td>
|
|
72
71
|
<Td>
|
|
73
|
-
<Flex justifyContent="end" {
|
|
72
|
+
<Flex justifyContent="end" onClick={(e) => e.stopPropagation()}>
|
|
74
73
|
{canUpdate ? (
|
|
75
74
|
<EditLink
|
|
76
75
|
to={role.id.toString()}
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
ContentLayout,
|
|
6
6
|
HeaderLayout,
|
|
7
7
|
Layout,
|
|
8
|
-
Main,
|
|
9
8
|
Table,
|
|
10
9
|
Th,
|
|
11
10
|
Thead,
|
|
@@ -18,7 +17,7 @@ import {
|
|
|
18
17
|
useFilter,
|
|
19
18
|
} from '@strapi/design-system';
|
|
20
19
|
import { LinkButton } from '@strapi/design-system/v2';
|
|
21
|
-
import {
|
|
20
|
+
import { useRBAC } from '@strapi/helper-plugin';
|
|
22
21
|
import { Plus } from '@strapi/icons';
|
|
23
22
|
import {
|
|
24
23
|
ConfirmDialog,
|
|
@@ -27,6 +26,8 @@ import {
|
|
|
27
26
|
SearchInput,
|
|
28
27
|
BackButton,
|
|
29
28
|
useNotification,
|
|
29
|
+
useQueryParams,
|
|
30
|
+
useFetchClient,
|
|
30
31
|
} from '@strapi/strapi/admin';
|
|
31
32
|
import { Helmet } from 'react-helmet';
|
|
32
33
|
import { useIntl } from 'react-intl';
|
|
@@ -37,7 +38,6 @@ import { PERMISSIONS } from '../../../../constants';
|
|
|
37
38
|
import { getTrad } from '../../../../utils';
|
|
38
39
|
|
|
39
40
|
import TableBody from './components/TableBody';
|
|
40
|
-
import { deleteData, fetchData } from './utils/api';
|
|
41
41
|
|
|
42
42
|
export const RolesListPage = () => {
|
|
43
43
|
const { trackUsage } = useTracking();
|
|
@@ -48,7 +48,7 @@ export const RolesListPage = () => {
|
|
|
48
48
|
const _q = query?._q || '';
|
|
49
49
|
const [showConfirmDelete, setShowConfirmDelete] = useState(false);
|
|
50
50
|
const [roleToDelete, setRoleToDelete] = useState();
|
|
51
|
-
|
|
51
|
+
const { del, get } = useFetchClient();
|
|
52
52
|
|
|
53
53
|
const {
|
|
54
54
|
isLoading: isLoadingForPermissions,
|
|
@@ -87,6 +87,33 @@ export const RolesListPage = () => {
|
|
|
87
87
|
setShowConfirmDelete(!showConfirmDelete);
|
|
88
88
|
};
|
|
89
89
|
|
|
90
|
+
const deleteData = async (id, formatMessage, toggleNotification) => {
|
|
91
|
+
try {
|
|
92
|
+
await del(`/users-permissions/roles/${id}`);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
toggleNotification({
|
|
95
|
+
type: 'danger',
|
|
96
|
+
message: formatMessage({ id: 'notification.error', defaultMessage: 'An error occured' }),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const fetchData = async (toggleNotification, formatMessage, notifyStatus) => {
|
|
102
|
+
try {
|
|
103
|
+
const { data } = await get('/users-permissions/roles');
|
|
104
|
+
notifyStatus('The roles have loaded successfully');
|
|
105
|
+
|
|
106
|
+
return data;
|
|
107
|
+
} catch (err) {
|
|
108
|
+
toggleNotification({
|
|
109
|
+
type: 'danger',
|
|
110
|
+
message: formatMessage({ id: 'notification.error' }),
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
throw new Error(err);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
90
117
|
const emptyLayout = {
|
|
91
118
|
roles: {
|
|
92
119
|
id: getTrad('Roles.empty'),
|
|
@@ -137,7 +164,7 @@ export const RolesListPage = () => {
|
|
|
137
164
|
{ name: pageTitle }
|
|
138
165
|
)}
|
|
139
166
|
/>
|
|
140
|
-
<Main
|
|
167
|
+
<Page.Main>
|
|
141
168
|
<HeaderLayout
|
|
142
169
|
title={formatMessage({
|
|
143
170
|
id: 'global.roles',
|
|
@@ -232,7 +259,7 @@ export const RolesListPage = () => {
|
|
|
232
259
|
onClose={handleShowConfirmDelete}
|
|
233
260
|
isOpen={showConfirmDelete}
|
|
234
261
|
/>
|
|
235
|
-
</Main>
|
|
262
|
+
</Page.Main>
|
|
236
263
|
</Layout>
|
|
237
264
|
);
|
|
238
265
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const prefixPluginTranslations = (trad, pluginId) => {
|
|
2
|
+
if (!pluginId) {
|
|
3
|
+
throw new TypeError("pluginId can't be empty");
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
return Object.keys(trad).reduce((acc, current) => {
|
|
7
|
+
acc[`${pluginId}.${current}`] = trad[current];
|
|
8
|
+
|
|
9
|
+
return acc;
|
|
10
|
+
}, {});
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { prefixPluginTranslations };
|