@strapi/plugin-users-permissions 4.20.5 → 5.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/admin/src/components/FormModal/index.jsx +1 -2
  2. package/admin/src/components/Permissions/reducer.js +1 -1
  3. package/admin/src/components/UsersPermissions/reducer.js +1 -1
  4. package/admin/src/index.js +15 -32
  5. package/admin/src/pages/AdvancedSettings/index.jsx +72 -112
  6. package/admin/src/pages/AdvancedSettings/utils/layout.js +20 -35
  7. package/admin/src/pages/AdvancedSettings/utils/schema.js +5 -2
  8. package/admin/src/pages/EmailTemplates/components/EmailForm.jsx +47 -74
  9. package/admin/src/pages/EmailTemplates/components/EmailTable.jsx +4 -5
  10. package/admin/src/pages/EmailTemplates/index.jsx +25 -55
  11. package/admin/src/pages/EmailTemplates/utils/schema.js +18 -6
  12. package/admin/src/pages/Providers/index.jsx +91 -108
  13. package/admin/src/pages/Providers/utils/forms.js +11 -11
  14. package/admin/src/pages/Roles/constants.js +3 -3
  15. package/admin/src/pages/Roles/hooks/usePlugins.js +4 -4
  16. package/admin/src/pages/Roles/index.jsx +9 -18
  17. package/admin/src/pages/Roles/pages/CreatePage.jsx +20 -28
  18. package/admin/src/pages/Roles/pages/EditPage.jsx +25 -37
  19. package/admin/src/pages/Roles/pages/ListPage/components/TableBody.jsx +23 -28
  20. package/admin/src/pages/Roles/pages/ListPage/index.jsx +73 -42
  21. package/admin/src/translations/en.json +1 -1
  22. package/admin/src/utils/prefixPluginTranslations.js +13 -0
  23. package/dist/_chunks/EditViewPage-kgrZ8rEg-6k5dfk_x.js +84412 -0
  24. package/dist/_chunks/EditViewPage-kgrZ8rEg-6k5dfk_x.js.map +1 -0
  25. package/dist/_chunks/EditViewPage-kgrZ8rEg-GlayP0Uq.mjs +84382 -0
  26. package/dist/_chunks/EditViewPage-kgrZ8rEg-GlayP0Uq.mjs.map +1 -0
  27. package/dist/_chunks/Helmet-d9JljxUo.js +1010 -0
  28. package/dist/_chunks/Helmet-d9JljxUo.js.map +1 -0
  29. package/dist/_chunks/Helmet-kyJ1Zklj.mjs +1008 -0
  30. package/dist/_chunks/Helmet-kyJ1Zklj.mjs.map +1 -0
  31. package/dist/_chunks/ListViewPage-BNB0ptO7-TUQO_9Hj.js +1617 -0
  32. package/dist/_chunks/ListViewPage-BNB0ptO7-TUQO_9Hj.js.map +1 -0
  33. package/dist/_chunks/ListViewPage-BNB0ptO7-t1ra9JlI.mjs +1594 -0
  34. package/dist/_chunks/ListViewPage-BNB0ptO7-t1ra9JlI.mjs.map +1 -0
  35. package/dist/_chunks/ReviewWorkflowsColumn-56Z6l-FH-3Dq1lGu9.js +33 -0
  36. package/dist/_chunks/ReviewWorkflowsColumn-56Z6l-FH-3Dq1lGu9.js.map +1 -0
  37. package/dist/_chunks/ReviewWorkflowsColumn-56Z6l-FH-mpkuW-HV.mjs +33 -0
  38. package/dist/_chunks/ReviewWorkflowsColumn-56Z6l-FH-mpkuW-HV.mjs.map +1 -0
  39. package/dist/_chunks/constants-evLWZCaJ-0QLv9QPI.mjs +190 -0
  40. package/dist/_chunks/constants-evLWZCaJ-0QLv9QPI.mjs.map +1 -0
  41. package/dist/_chunks/constants-evLWZCaJ-dGs71EWl.js +209 -0
  42. package/dist/_chunks/constants-evLWZCaJ-dGs71EWl.js.map +1 -0
  43. package/dist/_chunks/{en-m608rMZx.js → en-TaNIVnDO.js} +2 -2
  44. package/dist/_chunks/en-TaNIVnDO.js.map +1 -0
  45. package/dist/_chunks/{en-CE3wEy_c.mjs → en-jvJ-d-Qq.mjs} +2 -2
  46. package/dist/_chunks/en-jvJ-d-Qq.mjs.map +1 -0
  47. package/dist/_chunks/{index-XqdaO5WZ.js → index-6E51D69B.js} +149 -149
  48. package/dist/_chunks/index-6E51D69B.js.map +1 -0
  49. package/dist/_chunks/index-BGIcvvEB.mjs +260 -0
  50. package/dist/_chunks/index-BGIcvvEB.mjs.map +1 -0
  51. package/dist/_chunks/{index-6Kdo3KXv.js → index-Bg2Rf_5y.js} +112 -154
  52. package/dist/_chunks/index-Bg2Rf_5y.js.map +1 -0
  53. package/dist/_chunks/index-LpFmy25n.js +279 -0
  54. package/dist/_chunks/index-LpFmy25n.js.map +1 -0
  55. package/dist/_chunks/{index-a9oKDd3C.mjs → index-R05CeNXG.mjs} +106 -148
  56. package/dist/_chunks/index-R05CeNXG.mjs.map +1 -0
  57. package/dist/_chunks/index-YFPS5vYF-ZGkR3L1g.js +16558 -0
  58. package/dist/_chunks/index-YFPS5vYF-ZGkR3L1g.js.map +1 -0
  59. package/dist/_chunks/index-YFPS5vYF-cugkJcLS.mjs +16533 -0
  60. package/dist/_chunks/index-YFPS5vYF-cugkJcLS.mjs.map +1 -0
  61. package/dist/_chunks/{index-ethhTEkj.mjs → index-aEKi1Qb9.mjs} +39 -36
  62. package/dist/_chunks/index-aEKi1Qb9.mjs.map +1 -0
  63. package/dist/_chunks/{index-rryiT0-Z.mjs → index-hG66XSuA.mjs} +131 -130
  64. package/dist/_chunks/index-hG66XSuA.mjs.map +1 -0
  65. package/dist/_chunks/{index-iNtwnT3f.mjs → index-xt3l4qU9.mjs} +35 -35
  66. package/dist/_chunks/index-xt3l4qU9.mjs.map +1 -0
  67. package/dist/_chunks/{index-O9AAUvyy.js → index-yKMi8hKt.js} +36 -36
  68. package/dist/_chunks/index-yKMi8hKt.js.map +1 -0
  69. package/dist/_chunks/{index-1uupZmu0.js → index-ylhaoJtw.js} +43 -40
  70. package/dist/_chunks/index-ylhaoJtw.js.map +1 -0
  71. package/dist/_chunks/useSyncRbac-83vFRiaG-YY4KQcAU.js +57 -0
  72. package/dist/_chunks/useSyncRbac-83vFRiaG-YY4KQcAU.js.map +1 -0
  73. package/dist/_chunks/useSyncRbac-83vFRiaG-ov11t-T1.mjs +39 -0
  74. package/dist/_chunks/useSyncRbac-83vFRiaG-ov11t-T1.mjs.map +1 -0
  75. package/dist/admin/index.js +1 -2
  76. package/dist/admin/index.js.map +1 -1
  77. package/dist/admin/index.mjs +1 -2
  78. package/dist/admin/index.mjs.map +1 -1
  79. package/dist/style.css +84 -0
  80. package/package.json +13 -13
  81. package/server/bootstrap/grant-config.js +9 -0
  82. package/server/bootstrap/index.js +2 -39
  83. package/server/content-types/user/index.js +0 -1
  84. package/server/controllers/auth.js +24 -53
  85. package/server/controllers/content-manager-user.js +24 -28
  86. package/server/controllers/role.js +1 -1
  87. package/server/controllers/user.js +5 -5
  88. package/server/middlewares/rateLimit.js +1 -1
  89. package/server/register.js +1 -1
  90. package/server/services/jwt.js +3 -3
  91. package/server/services/permission.js +3 -7
  92. package/server/services/providers-registry.js +15 -0
  93. package/server/services/providers.js +10 -5
  94. package/server/services/role.js +15 -13
  95. package/server/services/user.js +28 -14
  96. package/server/services/users-permissions.js +12 -10
  97. package/server/utils/sanitize/sanitizers.js +2 -2
  98. package/admin/src/pages/Roles/pages/ListPage/utils/api.js +0 -30
  99. package/dist/_chunks/en-CE3wEy_c.mjs.map +0 -1
  100. package/dist/_chunks/en-m608rMZx.js.map +0 -1
  101. package/dist/_chunks/index-1uupZmu0.js.map +0 -1
  102. package/dist/_chunks/index-6Kdo3KXv.js.map +0 -1
  103. package/dist/_chunks/index-O9AAUvyy.js.map +0 -1
  104. package/dist/_chunks/index-Un-J-cxQ.js +0 -320
  105. package/dist/_chunks/index-Un-J-cxQ.js.map +0 -1
  106. package/dist/_chunks/index-X0yw_GgN.mjs +0 -301
  107. package/dist/_chunks/index-X0yw_GgN.mjs.map +0 -1
  108. package/dist/_chunks/index-XqdaO5WZ.js.map +0 -1
  109. package/dist/_chunks/index-a9oKDd3C.mjs.map +0 -1
  110. package/dist/_chunks/index-ethhTEkj.mjs.map +0 -1
  111. package/dist/_chunks/index-iNtwnT3f.mjs.map +0 -1
  112. package/dist/_chunks/index-rryiT0-Z.mjs.map +0 -1
@@ -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 {...onRowClick({ fn: () => onEditClick('reset_password') })}>
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 {...stopPropagation}>
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 {...onRowClick({ fn: () => onEditClick('email_confirmation') })}>
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 {...stopPropagation}>
105
+ <Td onClick={(e) => e.stopPropagation()}>
107
106
  <IconButton
108
107
  onClick={() => onEditClick('email_confirmation')}
109
108
  label={formatMessage({
@@ -1,18 +1,10 @@
1
1
  import * as React from 'react';
2
2
 
3
- import { ContentLayout, HeaderLayout, Main, useNotifyAT } from '@strapi/design-system';
4
- import {
5
- CheckPagePermissions,
6
- LoadingIndicatorPage,
7
- SettingsPageTitle,
8
- useAPIErrorHandler,
9
- useFetchClient,
10
- useFocusWhenNavigate,
11
- useNotification,
12
- useOverlayBlocker,
13
- useRBAC,
14
- useTracking,
15
- } from '@strapi/helper-plugin';
3
+ import { useTracking } from '@strapi/admin/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
+ import { Helmet } from 'react-helmet';
16
8
  import { useIntl } from 'react-intl';
17
9
  import { useMutation, useQuery, useQueryClient } from 'react-query';
18
10
 
@@ -23,23 +15,19 @@ import EmailForm from './components/EmailForm';
23
15
  import EmailTable from './components/EmailTable';
24
16
 
25
17
  const ProtectedEmailTemplatesPage = () => (
26
- <CheckPagePermissions permissions={PERMISSIONS.readEmailTemplates}>
18
+ <Page.Protect permissions={PERMISSIONS.readEmailTemplates}>
27
19
  <EmailTemplatesPage />
28
- </CheckPagePermissions>
20
+ </Page.Protect>
29
21
  );
30
-
31
22
  const EmailTemplatesPage = () => {
32
23
  const { formatMessage } = useIntl();
33
24
  const { trackUsage } = useTracking();
34
25
  const { notifyStatus } = useNotifyAT();
35
- const toggleNotification = useNotification();
36
- const { lockApp, unlockApp } = useOverlayBlocker();
26
+ const { toggleNotification } = useNotification();
37
27
  const queryClient = useQueryClient();
38
28
  const { get, put } = useFetchClient();
39
29
  const { formatAPIError } = useAPIErrorHandler();
40
30
 
41
- useFocusWhenNavigate();
42
-
43
31
  const [isModalOpen, setIsModalOpen] = React.useState(false);
44
32
  const [templateToEdit, setTemplateToEdit] = React.useState(null);
45
33
 
@@ -66,7 +54,7 @@ const EmailTemplatesPage = () => {
66
54
  },
67
55
  onError(error) {
68
56
  toggleNotification({
69
- type: 'warning',
57
+ type: 'danger',
70
58
  message: formatAPIError(error),
71
59
  });
72
60
  },
@@ -92,29 +80,24 @@ const EmailTemplatesPage = () => {
92
80
 
93
81
  toggleNotification({
94
82
  type: 'success',
95
- message: { id: 'notification.success.saved', defaultMessage: 'Saved' },
83
+ message: formatMessage({ id: 'notification.success.saved', defaultMessage: 'Saved' }),
96
84
  });
97
85
 
98
86
  trackUsage('didEditEmailTemplates');
99
87
 
100
- unlockApp();
101
88
  handleToggle();
102
89
  },
103
90
  onError(error) {
104
91
  toggleNotification({
105
- type: 'warning',
92
+ type: 'danger',
106
93
  message: formatAPIError(error),
107
94
  });
108
-
109
- unlockApp();
110
95
  },
111
96
  refetchActive: true,
112
97
  }
113
98
  );
114
99
 
115
100
  const handleSubmit = (body) => {
116
- lockApp();
117
-
118
101
  trackUsage('willEditEmailTemplates');
119
102
 
120
103
  const editedTemplates = { ...data, [templateToEdit]: body };
@@ -122,34 +105,21 @@ const EmailTemplatesPage = () => {
122
105
  };
123
106
 
124
107
  if (isLoading) {
125
- return (
126
- <Main aria-busy="true">
127
- <SettingsPageTitle
128
- name={formatMessage({
129
- id: getTrad('HeaderNav.link.emailTemplates'),
130
- defaultMessage: 'Email templates',
131
- })}
132
- />
133
- <HeaderLayout
134
- title={formatMessage({
135
- id: getTrad('HeaderNav.link.emailTemplates'),
136
- defaultMessage: 'Email templates',
137
- })}
138
- />
139
- <ContentLayout>
140
- <LoadingIndicatorPage />
141
- </ContentLayout>
142
- </Main>
143
- );
108
+ return <Page.Loading />;
144
109
  }
145
110
 
146
111
  return (
147
- <Main aria-busy={submitMutation.isLoading}>
148
- <SettingsPageTitle
149
- name={formatMessage({
150
- id: getTrad('HeaderNav.link.emailTemplates'),
151
- defaultMessage: 'Email templates',
152
- })}
112
+ <Page.Main aria-busy={submitMutation.isLoading}>
113
+ <Helmet
114
+ title={formatMessage(
115
+ { id: 'Settings.PageTitle', defaultMessage: 'Settings - {name}' },
116
+ {
117
+ name: formatMessage({
118
+ id: getTrad('HeaderNav.link.emailTemplates'),
119
+ defaultMessage: 'Email templates',
120
+ }),
121
+ }
122
+ )}
153
123
  />
154
124
  <HeaderLayout
155
125
  title={formatMessage({
@@ -167,8 +137,8 @@ const EmailTemplatesPage = () => {
167
137
  />
168
138
  )}
169
139
  </ContentLayout>
170
- </Main>
140
+ </Page.Main>
171
141
  );
172
142
  };
173
143
 
174
- export default ProtectedEmailTemplatesPage;
144
+ export { ProtectedEmailTemplatesPage, EmailTemplatesPage };
@@ -1,4 +1,4 @@
1
- import { translatedErrors } from '@strapi/helper-plugin';
1
+ import { translatedErrors } from '@strapi/strapi/admin';
2
2
  import * as yup from 'yup';
3
3
 
4
4
  const schema = yup.object().shape({
@@ -8,15 +8,27 @@ const schema = yup.object().shape({
8
8
  from: yup
9
9
  .object()
10
10
  .shape({
11
- name: yup.string().required(translatedErrors.required),
12
- email: yup.string().email(translatedErrors.email).required(translatedErrors.required),
11
+ name: yup.string().required({
12
+ id: translatedErrors.required.id,
13
+ defaultMessage: 'This field is required',
14
+ }),
15
+ email: yup.string().email(translatedErrors.email).required({
16
+ id: translatedErrors.required.id,
17
+ defaultMessage: 'This field is required',
18
+ }),
13
19
  })
14
20
  .required(),
15
21
  response_email: yup.string().email(translatedErrors.email),
16
- object: yup.string().required(translatedErrors.required),
17
- message: yup.string().required(translatedErrors.required),
22
+ object: yup.string().required({
23
+ id: translatedErrors.required.id,
24
+ defaultMessage: 'This field is required',
25
+ }),
26
+ message: yup.string().required({
27
+ id: translatedErrors.required.id,
28
+ defaultMessage: 'This field is required',
29
+ }),
18
30
  })
19
- .required(translatedErrors.required),
31
+ .required(translatedErrors.required.id),
20
32
  });
21
33
 
22
34
  export default schema;
@@ -1,11 +1,11 @@
1
1
  import * as React from 'react';
2
2
 
3
+ import { useTracking } from '@strapi/admin/strapi-admin';
3
4
  import {
4
5
  ContentLayout,
5
6
  HeaderLayout,
6
7
  IconButton,
7
8
  Layout,
8
- Main,
9
9
  Table,
10
10
  Tbody,
11
11
  Td,
@@ -14,24 +14,13 @@ import {
14
14
  Tr,
15
15
  Typography,
16
16
  VisuallyHidden,
17
- } from '@strapi/design-system';
18
- import {
19
- CheckPagePermissions,
20
- LoadingIndicatorPage,
21
- onRowClick,
22
- SettingsPageTitle,
23
- stopPropagation,
24
- useAPIErrorHandler,
25
17
  useCollator,
26
- useFetchClient,
27
- useFocusWhenNavigate,
28
- useNotification,
29
- useOverlayBlocker,
30
- useRBAC,
31
- useTracking,
32
- } from '@strapi/helper-plugin';
18
+ } from '@strapi/design-system';
19
+ import { useRBAC } from '@strapi/helper-plugin';
33
20
  import { Pencil } from '@strapi/icons';
21
+ import { Page, useAPIErrorHandler, useNotification, useFetchClient } from '@strapi/strapi/admin';
34
22
  import upperFirst from 'lodash/upperFirst';
23
+ import { Helmet } from 'react-helmet';
35
24
  import { useIntl } from 'react-intl';
36
25
  import { useMutation, useQuery, useQueryClient } from 'react-query';
37
26
 
@@ -47,16 +36,13 @@ export const ProvidersPage = () => {
47
36
  const { trackUsage } = useTracking();
48
37
  const [isOpen, setIsOpen] = React.useState(false);
49
38
  const [providerToEditName, setProviderToEditName] = React.useState(null);
50
- const toggleNotification = useNotification();
51
- const { lockApp, unlockApp } = useOverlayBlocker();
39
+ const { toggleNotification } = useNotification();
52
40
  const { get, put } = useFetchClient();
53
41
  const { formatAPIError } = useAPIErrorHandler();
54
42
  const formatter = useCollator(locale, {
55
43
  sensitivity: 'base',
56
44
  });
57
45
 
58
- useFocusWhenNavigate();
59
-
60
46
  const {
61
47
  isLoading: isLoadingPermissions,
62
48
  allowedActions: { canUpdate },
@@ -80,21 +66,18 @@ export const ProvidersPage = () => {
80
66
 
81
67
  toggleNotification({
82
68
  type: 'success',
83
- message: { id: getTrad('notification.success.submit') },
69
+ message: formatMessage({ id: getTrad('notification.success.submit') }),
84
70
  });
85
71
 
86
72
  trackUsage('didEditAuthenticationProvider');
87
73
 
88
74
  handleToggleModal();
89
- unlockApp();
90
75
  },
91
76
  onError(error) {
92
77
  toggleNotification({
93
- type: 'warning',
78
+ type: 'danger',
94
79
  message: formatAPIError(error),
95
80
  });
96
-
97
- unlockApp();
98
81
  },
99
82
  refetchActive: false,
100
83
  });
@@ -150,104 +133,104 @@ export const ProvidersPage = () => {
150
133
  };
151
134
 
152
135
  const handleSubmit = async (values) => {
153
- lockApp();
154
-
155
136
  trackUsage('willEditAuthenticationProvider');
156
137
 
157
138
  submitMutation.mutate({ providers: { ...data, [providerToEditName]: values } });
158
139
  };
159
140
 
141
+ if (isLoading) {
142
+ return <Page.Loading />;
143
+ }
144
+
160
145
  return (
161
146
  <Layout>
162
- <SettingsPageTitle
163
- name={formatMessage({
164
- id: getTrad('HeaderNav.link.providers'),
165
- defaultMessage: 'Providers',
166
- })}
147
+ <Helmet
148
+ title={formatMessage(
149
+ { id: 'Settings.PageTitle', defaultMessage: 'Settings - {name}' },
150
+ {
151
+ name: formatMessage({
152
+ id: getTrad('HeaderNav.link.providers'),
153
+ defaultMessage: 'Providers',
154
+ }),
155
+ }
156
+ )}
167
157
  />
168
- <Main>
158
+ <Page.Main>
169
159
  <HeaderLayout
170
160
  title={formatMessage({
171
161
  id: getTrad('HeaderNav.link.providers'),
172
162
  defaultMessage: 'Providers',
173
163
  })}
174
164
  />
175
- {isLoading ? (
176
- <LoadingIndicatorPage />
177
- ) : (
178
- <ContentLayout>
179
- <Table colCount={3} rowCount={providers.length + 1}>
180
- <Thead>
181
- <Tr>
182
- <Th>
183
- <Typography variant="sigma" textColor="neutral600">
184
- {formatMessage({ id: 'global.name', defaultMessage: 'Name' })}
165
+ <ContentLayout>
166
+ <Table colCount={3} rowCount={providers.length + 1}>
167
+ <Thead>
168
+ <Tr>
169
+ <Th>
170
+ <Typography variant="sigma" textColor="neutral600">
171
+ {formatMessage({ id: 'global.name', defaultMessage: 'Name' })}
172
+ </Typography>
173
+ </Th>
174
+ <Th>
175
+ <Typography variant="sigma" textColor="neutral600">
176
+ {formatMessage({ id: getTrad('Providers.status'), defaultMessage: 'Status' })}
177
+ </Typography>
178
+ </Th>
179
+ <Th>
180
+ <Typography variant="sigma">
181
+ <VisuallyHidden>
182
+ {formatMessage({
183
+ id: 'global.settings',
184
+ defaultMessage: 'Settings',
185
+ })}
186
+ </VisuallyHidden>
187
+ </Typography>
188
+ </Th>
189
+ </Tr>
190
+ </Thead>
191
+ <Tbody>
192
+ {providers.map((provider) => (
193
+ <Tr
194
+ key={provider.name}
195
+ onClick={() => (canUpdate ? handleClickEdit(provider) : undefined)}
196
+ >
197
+ <Td width="45%">
198
+ <Typography fontWeight="semiBold" textColor="neutral800">
199
+ {provider.name}
185
200
  </Typography>
186
- </Th>
187
- <Th>
188
- <Typography variant="sigma" textColor="neutral600">
189
- {formatMessage({ id: getTrad('Providers.status'), defaultMessage: 'Status' })}
201
+ </Td>
202
+ <Td width="65%">
203
+ <Typography
204
+ textColor={provider.enabled ? 'success600' : 'danger600'}
205
+ data-testid={`enable-${provider.name}`}
206
+ >
207
+ {provider.enabled
208
+ ? formatMessage({
209
+ id: 'global.enabled',
210
+ defaultMessage: 'Enabled',
211
+ })
212
+ : formatMessage({
213
+ id: 'global.disabled',
214
+ defaultMessage: 'Disabled',
215
+ })}
190
216
  </Typography>
191
- </Th>
192
- <Th>
193
- <Typography variant="sigma">
194
- <VisuallyHidden>
195
- {formatMessage({
196
- id: 'global.settings',
197
- defaultMessage: 'Settings',
198
- })}
199
- </VisuallyHidden>
200
- </Typography>
201
- </Th>
217
+ </Td>
218
+ <Td onClick={(e) => e.stopPropagation()}>
219
+ {canUpdate && (
220
+ <IconButton
221
+ onClick={() => handleClickEdit(provider)}
222
+ noBorder
223
+ icon={<Pencil />}
224
+ label="Edit"
225
+ />
226
+ )}
227
+ </Td>
202
228
  </Tr>
203
- </Thead>
204
- <Tbody>
205
- {providers.map((provider) => (
206
- <Tr
207
- key={provider.name}
208
- {...onRowClick({
209
- fn: () => handleClickEdit(provider),
210
- condition: canUpdate,
211
- })}
212
- >
213
- <Td width="45%">
214
- <Typography fontWeight="semiBold" textColor="neutral800">
215
- {provider.name}
216
- </Typography>
217
- </Td>
218
- <Td width="65%">
219
- <Typography
220
- textColor={provider.enabled ? 'success600' : 'danger600'}
221
- data-testid={`enable-${provider.name}`}
222
- >
223
- {provider.enabled
224
- ? formatMessage({
225
- id: 'global.enabled',
226
- defaultMessage: 'Enabled',
227
- })
228
- : formatMessage({
229
- id: 'global.disabled',
230
- defaultMessage: 'Disabled',
231
- })}
232
- </Typography>
233
- </Td>
234
- <Td {...stopPropagation}>
235
- {canUpdate && (
236
- <IconButton
237
- onClick={() => handleClickEdit(provider)}
238
- noBorder
239
- icon={<Pencil />}
240
- label="Edit"
241
- />
242
- )}
243
- </Td>
244
- </Tr>
245
- ))}
246
- </Tbody>
247
- </Table>
248
- </ContentLayout>
249
- )}
250
- </Main>
229
+ ))}
230
+ </Tbody>
231
+ </Table>
232
+ </ContentLayout>
233
+ </Page.Main>
251
234
  <FormModal
252
235
  initialData={data[providerToEditName]}
253
236
  isOpen={isOpen}
@@ -269,9 +252,9 @@ export const ProvidersPage = () => {
269
252
  };
270
253
 
271
254
  const ProtectedProvidersPage = () => (
272
- <CheckPagePermissions permissions={PERMISSIONS.readProviders}>
255
+ <Page.Protect permissions={PERMISSIONS.readProviders}>
273
256
  <ProvidersPage />
274
- </CheckPagePermissions>
257
+ </Page.Protect>
275
258
  );
276
259
 
277
260
  export default ProtectedProvidersPage;
@@ -1,4 +1,4 @@
1
- import { translatedErrors } from '@strapi/helper-plugin';
1
+ import { translatedErrors } from '@strapi/strapi/admin';
2
2
  import * as yup from 'yup';
3
3
 
4
4
  import { getTrad } from '../../../utils';
@@ -52,7 +52,7 @@ const forms = {
52
52
  ],
53
53
  ],
54
54
  schema: yup.object().shape({
55
- enabled: yup.bool().required(translatedErrors.required),
55
+ enabled: yup.bool().required(translatedErrors.required.id),
56
56
  }),
57
57
  },
58
58
  providers: {
@@ -117,20 +117,20 @@ const forms = {
117
117
  ],
118
118
  ],
119
119
  schema: yup.object().shape({
120
- enabled: yup.bool().required(translatedErrors.required),
120
+ enabled: yup.bool().required(translatedErrors.required.id),
121
121
  key: yup.string().when('enabled', {
122
122
  is: true,
123
- then: yup.string().required(translatedErrors.required),
123
+ then: yup.string().required(translatedErrors.required.id),
124
124
  otherwise: yup.string(),
125
125
  }),
126
126
  secret: yup.string().when('enabled', {
127
127
  is: true,
128
- then: yup.string().required(translatedErrors.required),
128
+ then: yup.string().required(translatedErrors.required.id),
129
129
  otherwise: yup.string(),
130
130
  }),
131
131
  callback: yup.string().when('enabled', {
132
132
  is: true,
133
- then: yup.string().required(translatedErrors.required),
133
+ then: yup.string().required(translatedErrors.required.id),
134
134
  otherwise: yup.string(),
135
135
  }),
136
136
  }),
@@ -231,25 +231,25 @@ const forms = {
231
231
  ],
232
232
  ],
233
233
  schema: yup.object().shape({
234
- enabled: yup.bool().required(translatedErrors.required),
234
+ enabled: yup.bool().required(translatedErrors.required.id),
235
235
  key: yup.string().when('enabled', {
236
236
  is: true,
237
- then: yup.string().required(translatedErrors.required),
237
+ then: yup.string().required(translatedErrors.required.id),
238
238
  otherwise: yup.string(),
239
239
  }),
240
240
  secret: yup.string().when('enabled', {
241
241
  is: true,
242
- then: yup.string().required(translatedErrors.required),
242
+ then: yup.string().required(translatedErrors.required.id),
243
243
  otherwise: yup.string(),
244
244
  }),
245
245
  subdomain: yup.string().when('enabled', {
246
246
  is: true,
247
- then: yup.string().required(translatedErrors.required),
247
+ then: yup.string().required(translatedErrors.required.id),
248
248
  otherwise: yup.string(),
249
249
  }),
250
250
  callback: yup.string().when('enabled', {
251
251
  is: true,
252
- then: yup.string().required(translatedErrors.required),
252
+ then: yup.string().required(translatedErrors.required.id),
253
253
  otherwise: yup.string(),
254
254
  }),
255
255
  }),
@@ -1,7 +1,7 @@
1
- import { translatedErrors } from '@strapi/helper-plugin';
1
+ import { translatedErrors } from '@strapi/strapi/admin';
2
2
  import * as yup from 'yup';
3
3
 
4
4
  export const createRoleSchema = yup.object().shape({
5
- name: yup.string().required(translatedErrors.required),
6
- description: yup.string().required(translatedErrors.required),
5
+ name: yup.string().required(translatedErrors.required.id),
6
+ description: yup.string().required(translatedErrors.required.id),
7
7
  });
@@ -1,12 +1,12 @@
1
1
  import { useEffect } from 'react';
2
2
 
3
- import { useNotification, useFetchClient, useAPIErrorHandler } from '@strapi/helper-plugin';
3
+ import { useAPIErrorHandler, useNotification, useFetchClient } from '@strapi/strapi/admin';
4
4
  import { useQueries } from 'react-query';
5
5
 
6
6
  import { cleanPermissions, getTrad } from '../../../utils';
7
7
 
8
8
  export const usePlugins = () => {
9
- const toggleNotification = useNotification();
9
+ const { toggleNotification } = useNotification();
10
10
  const { get } = useFetchClient();
11
11
  const { formatAPIError } = useAPIErrorHandler(getTrad);
12
12
 
@@ -48,7 +48,7 @@ export const usePlugins = () => {
48
48
  useEffect(() => {
49
49
  if (permissionsError) {
50
50
  toggleNotification({
51
- type: 'warning',
51
+ type: 'danger',
52
52
  message: formatAPIError(permissionsError),
53
53
  });
54
54
  }
@@ -57,7 +57,7 @@ export const usePlugins = () => {
57
57
  useEffect(() => {
58
58
  if (routesError) {
59
59
  toggleNotification({
60
- type: 'warning',
60
+ type: 'danger',
61
61
  message: formatAPIError(routesError),
62
62
  });
63
63
  }
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
 
3
- import { AnErrorOccurred, CheckPagePermissions } from '@strapi/helper-plugin';
4
- import { Route, Switch } from 'react-router-dom';
3
+ import { Page } from '@strapi/strapi/admin';
4
+ import { Route, Routes } from 'react-router-dom';
5
5
 
6
6
  import { PERMISSIONS } from '../../constants';
7
7
 
@@ -11,22 +11,13 @@ import { ProtectedRolesListPage } from './pages/ListPage';
11
11
 
12
12
  const Roles = () => {
13
13
  return (
14
- <CheckPagePermissions permissions={PERMISSIONS.accessRoles}>
15
- <Switch>
16
- <Route
17
- path="/settings/users-permissions/roles/new"
18
- component={ProtectedRolesCreatePage}
19
- exact
20
- />
21
- <Route
22
- path="/settings/users-permissions/roles/:id"
23
- component={ProtectedRolesEditPage}
24
- exact
25
- />
26
- <Route path="/settings/users-permissions/roles" component={ProtectedRolesListPage} exact />
27
- <Route path="" component={AnErrorOccurred} />
28
- </Switch>
29
- </CheckPagePermissions>
14
+ <Page.Protect permissions={PERMISSIONS.accessRoles}>
15
+ <Routes>
16
+ <Route index element={<ProtectedRolesListPage />} />
17
+ <Route path="new" element={<ProtectedRolesCreatePage />} />
18
+ <Route path=":id" element={<ProtectedRolesEditPage />} />
19
+ </Routes>
20
+ </Page.Protect>
30
21
  );
31
22
  };
32
23