@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
@@ -17,8 +17,7 @@ import {
17
17
  ModalLayout,
18
18
  } from '@strapi/design-system';
19
19
  import { Breadcrumbs, Crumb } from '@strapi/design-system/v2';
20
- import { Form } from '@strapi/helper-plugin';
21
- import { Formik } from 'formik';
20
+ import { Form, Formik } from 'formik';
22
21
  import PropTypes from 'prop-types';
23
22
  import { useIntl } from 'react-intl';
24
23
 
@@ -1,4 +1,4 @@
1
- import produce from 'immer';
1
+ import { produce } from 'immer';
2
2
 
3
3
  const initialState = {
4
4
  collapses: [],
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable consistent-return */
2
- import produce from 'immer';
2
+ import { produce } from 'immer';
3
3
  import get from 'lodash/get';
4
4
  import set from 'lodash/set';
5
5
  import take from 'lodash/take';
@@ -1,15 +1,8 @@
1
- // NOTE TO PLUGINS DEVELOPERS:
2
- // If you modify this file by adding new options to the plugin entry point
3
- // Here's the file: strapi/docs/3.0.0-beta.x/plugin-development/frontend-field-api.md
4
- // Here's the file: strapi/docs/3.0.0-beta.x/guides/registering-a-field-in-admin.md
5
- // Also the strapi-generate-plugins/files/admin/src/index.js needs to be updated
6
- // IF THE DOC IS NOT UPDATED THE PULL REQUEST WILL NOT BE MERGED
7
- import { prefixPluginTranslations } from '@strapi/helper-plugin';
8
-
9
1
  import pluginPkg from '../../package.json';
10
2
 
11
3
  import { PERMISSIONS } from './constants';
12
4
  import getTrad from './utils/getTrad';
5
+ import { prefixPluginTranslations } from './utils/prefixPluginTranslations';
13
6
 
14
7
  const name = pluginPkg.strapi.name;
15
8
 
@@ -31,12 +24,8 @@ export default {
31
24
  defaultMessage: 'Roles',
32
25
  },
33
26
  id: 'roles',
34
- to: `/settings/users-permissions/roles`,
35
- async Component() {
36
- const component = await import('./pages/Roles');
37
-
38
- return component;
39
- },
27
+ to: `users-permissions/roles`,
28
+ Component: () => import('./pages/Roles'),
40
29
  permissions: PERMISSIONS.accessRoles,
41
30
  },
42
31
  {
@@ -45,12 +34,8 @@ export default {
45
34
  defaultMessage: 'Providers',
46
35
  },
47
36
  id: 'providers',
48
- to: `/settings/users-permissions/providers`,
49
- async Component() {
50
- const component = await import('./pages/Providers');
51
-
52
- return component;
53
- },
37
+ to: `users-permissions/providers`,
38
+ Component: () => import('./pages/Providers'),
54
39
  permissions: PERMISSIONS.readProviders,
55
40
  },
56
41
  {
@@ -59,12 +44,11 @@ export default {
59
44
  defaultMessage: 'Email templates',
60
45
  },
61
46
  id: 'email-templates',
62
- to: `/settings/users-permissions/email-templates`,
63
- async Component() {
64
- const component = await import('./pages/EmailTemplates');
65
-
66
- return component;
67
- },
47
+ to: `users-permissions/email-templates`,
48
+ Component: () =>
49
+ import('./pages/EmailTemplates').then((mod) => ({
50
+ default: mod.ProtectedEmailTemplatesPage,
51
+ })),
68
52
  permissions: PERMISSIONS.readEmailTemplates,
69
53
  },
70
54
  {
@@ -73,12 +57,11 @@ export default {
73
57
  defaultMessage: 'Advanced Settings',
74
58
  },
75
59
  id: 'advanced-settings',
76
- to: `/settings/users-permissions/advanced-settings`,
77
- async Component() {
78
- const component = await import('./pages/AdvancedSettings');
79
-
80
- return component;
81
- },
60
+ to: `users-permissions/advanced-settings`,
61
+ Component: () =>
62
+ import('./pages/AdvancedSettings').then((mod) => ({
63
+ default: mod.ProtectedAdvancedSettingsPage,
64
+ })),
82
65
  permissions: PERMISSIONS.readAdvancedSettings,
83
66
  },
84
67
  ]
@@ -8,27 +8,20 @@ import {
8
8
  Grid,
9
9
  GridItem,
10
10
  HeaderLayout,
11
- Main,
12
- Option,
13
- Select,
14
11
  Typography,
15
12
  useNotifyAT,
16
13
  } from '@strapi/design-system';
14
+ import { useRBAC } from '@strapi/helper-plugin';
15
+ import { Check } from '@strapi/icons';
17
16
  import {
18
- CheckPagePermissions,
19
- Form,
20
- GenericInput,
21
- LoadingIndicatorPage,
22
- SettingsPageTitle,
23
17
  useAPIErrorHandler,
24
- useFetchClient,
25
- useFocusWhenNavigate,
18
+ Page,
19
+ Form,
20
+ InputRenderer,
26
21
  useNotification,
27
- useOverlayBlocker,
28
- useRBAC,
29
- } from '@strapi/helper-plugin';
30
- import { Check } from '@strapi/icons';
31
- import { Formik } from 'formik';
22
+ useFetchClient,
23
+ } from '@strapi/strapi/admin';
24
+ import { Helmet } from 'react-helmet';
32
25
  import { useIntl } from 'react-intl';
33
26
  import { useMutation, useQuery, useQueryClient } from 'react-query';
34
27
 
@@ -39,22 +32,19 @@ import layout from './utils/layout';
39
32
  import schema from './utils/schema';
40
33
 
41
34
  const ProtectedAdvancedSettingsPage = () => (
42
- <CheckPagePermissions permissions={PERMISSIONS.readAdvancedSettings}>
35
+ <Page.Protect permissions={PERMISSIONS.readAdvancedSettings}>
43
36
  <AdvancedSettingsPage />
44
- </CheckPagePermissions>
37
+ </Page.Protect>
45
38
  );
46
39
 
47
40
  const AdvancedSettingsPage = () => {
48
41
  const { formatMessage } = useIntl();
49
- const toggleNotification = useNotification();
50
- const { lockApp, unlockApp } = useOverlayBlocker();
42
+ const { toggleNotification } = useNotification();
51
43
  const { notifyStatus } = useNotifyAT();
52
44
  const queryClient = useQueryClient();
53
45
  const { get, put } = useFetchClient();
54
46
  const { formatAPIError } = useAPIErrorHandler();
55
47
 
56
- useFocusWhenNavigate();
57
-
58
48
  const {
59
49
  isLoading: isLoadingForPermissions,
60
50
  allowedActions: { canUpdate },
@@ -78,8 +68,11 @@ const AdvancedSettingsPage = () => {
78
68
  },
79
69
  onError() {
80
70
  toggleNotification({
81
- type: 'warning',
82
- message: { id: getTrad('notification.error'), defaultMessage: 'An error occured' },
71
+ type: 'danger',
72
+ message: formatMessage({
73
+ id: getTrad('notification.error'),
74
+ defaultMessage: 'An error occured',
75
+ }),
83
76
  });
84
77
  },
85
78
  }
@@ -93,18 +86,17 @@ const AdvancedSettingsPage = () => {
93
86
 
94
87
  toggleNotification({
95
88
  type: 'success',
96
- message: { id: getTrad('notification.success.saved'), defaultMessage: 'Saved' },
89
+ message: formatMessage({
90
+ id: getTrad('notification.success.saved'),
91
+ defaultMessage: 'Saved',
92
+ }),
97
93
  });
98
-
99
- unlockApp();
100
94
  },
101
95
  onError(error) {
102
96
  toggleNotification({
103
- type: 'warning',
97
+ type: 'danger',
104
98
  message: formatAPIError(error),
105
99
  });
106
-
107
- unlockApp();
108
100
  },
109
101
  refetchActive: true,
110
102
  });
@@ -112,8 +104,6 @@ const AdvancedSettingsPage = () => {
112
104
  const { isLoading: isSubmittingForm } = submitMutation;
113
105
 
114
106
  const handleSubmit = async (body) => {
115
- lockApp();
116
-
117
107
  submitMutation.mutate({
118
108
  ...body,
119
109
  email_confirmation_redirection: body.email_confirmation
@@ -123,45 +113,26 @@ const AdvancedSettingsPage = () => {
123
113
  };
124
114
 
125
115
  if (isLoading) {
126
- return (
127
- <Main aria-busy="true">
128
- <SettingsPageTitle
129
- name={formatMessage({
130
- id: getTrad('HeaderNav.link.advancedSettings'),
131
- defaultMessage: 'Advanced Settings',
132
- })}
133
- />
134
- <HeaderLayout
135
- title={formatMessage({
136
- id: getTrad('HeaderNav.link.advancedSettings'),
137
- defaultMessage: 'Advanced Settings',
138
- })}
139
- />
140
- <ContentLayout>
141
- <LoadingIndicatorPage />
142
- </ContentLayout>
143
- </Main>
144
- );
116
+ return <Page.Loading />;
145
117
  }
146
118
 
147
119
  return (
148
- <Main aria-busy={isSubmittingForm}>
149
- <SettingsPageTitle
150
- name={formatMessage({
151
- id: getTrad('HeaderNav.link.advancedSettings'),
152
- defaultMessage: 'Advanced Settings',
153
- })}
120
+ <Page.Main aria-busy={isSubmittingForm}>
121
+ <Helmet
122
+ title={formatMessage(
123
+ { id: 'Settings.PageTitle', defaultMessage: 'Settings - {name}' },
124
+ {
125
+ name: formatMessage({
126
+ id: getTrad('HeaderNav.link.advancedSettings'),
127
+ defaultMessage: 'Advanced Settings',
128
+ }),
129
+ }
130
+ )}
154
131
  />
155
- <Formik
156
- onSubmit={handleSubmit}
157
- initialValues={data.settings}
158
- validateOnChange={false}
159
- validationSchema={schema}
160
- enableReinitialize
161
- >
162
- {({ errors, values, handleChange, isSubmitting, dirty }) => {
132
+ <Form onSubmit={handleSubmit} initialValues={data.settings} validationSchema={schema}>
133
+ {({ values, isSubmitting, modified }) => {
163
134
  return (
164
- <Form>
135
+ <>
165
136
  <HeaderLayout
166
137
  title={formatMessage({
167
138
  id: getTrad('HeaderNav.link.advancedSettings'),
@@ -171,7 +142,7 @@ const AdvancedSettingsPage = () => {
171
142
  <Button
172
143
  loading={isSubmitting}
173
144
  type="submit"
174
- disabled={canUpdate ? !dirty : !canUpdate}
145
+ disabled={!modified || !canUpdate}
175
146
  startIcon={<Check />}
176
147
  size="S"
177
148
  >
@@ -197,63 +168,52 @@ const AdvancedSettingsPage = () => {
197
168
  })}
198
169
  </Typography>
199
170
  <Grid gap={6}>
200
- <GridItem col={6} s={12}>
201
- <Select
202
- label={formatMessage({
171
+ {[
172
+ {
173
+ label: {
203
174
  id: getTrad('EditForm.inputSelect.label.role'),
204
175
  defaultMessage: 'Default role for authenticated users',
205
- })}
206
- value={values.default_role}
207
- hint={formatMessage({
176
+ },
177
+ hint: {
208
178
  id: getTrad('EditForm.inputSelect.description.role'),
209
179
  defaultMessage:
210
180
  'It will attach the new authenticated user to the selected role.',
211
- })}
212
- onChange={(e) =>
213
- handleChange({ target: { name: 'default_role', value: e } })
214
- }
215
- >
216
- {data.roles.map((role) => {
217
- return (
218
- <Option key={role.type} value={role.type}>
219
- {role.name}
220
- </Option>
221
- );
222
- })}
223
- </Select>
224
- </GridItem>
225
- {layout.map((input) => {
226
- let value = values[input.name];
227
-
228
- if (!value) {
229
- value = input.type === 'bool' ? false : '';
230
- }
231
-
232
- return (
233
- <GridItem key={input.name} {...input.size}>
234
- <GenericInput
235
- {...input}
236
- value={value}
237
- error={errors[input.name]}
238
- disabled={
239
- input.name === 'email_confirmation_redirection' &&
240
- values.email_confirmation === false
241
- }
242
- onChange={handleChange}
243
- />
244
- </GridItem>
245
- );
246
- })}
181
+ },
182
+ options: data.roles.map((role) => ({
183
+ label: role.name,
184
+ value: role.type,
185
+ })),
186
+ name: 'default_role',
187
+ size: 6,
188
+ type: 'enumeration',
189
+ },
190
+ ...layout,
191
+ ].map(({ size, ...field }) => (
192
+ <GridItem key={field.name} col={size}>
193
+ <InputRenderer
194
+ {...field}
195
+ disabled={
196
+ field.name === 'email_confirmation_redirection' &&
197
+ values.email_confirmation === false
198
+ }
199
+ label={formatMessage(field.label)}
200
+ hint={field.hint ? formatMessage(field.hint) : undefined}
201
+ placeholder={
202
+ field.placeholder ? formatMessage(field.placeholder) : undefined
203
+ }
204
+ />
205
+ </GridItem>
206
+ ))}
247
207
  </Grid>
248
208
  </Flex>
249
209
  </Box>
250
210
  </ContentLayout>
251
- </Form>
211
+ </>
252
212
  );
253
213
  }}
254
- </Formik>
255
- </Main>
214
+ </Form>
215
+ </Page.Main>
256
216
  );
257
217
  };
258
218
 
259
- export default ProtectedAdvancedSettingsPage;
219
+ export { ProtectedAdvancedSettingsPage, AdvancedSettingsPage };
@@ -2,45 +2,39 @@ import { getTrad } from '../../../utils';
2
2
 
3
3
  const layout = [
4
4
  {
5
- intlLabel: {
5
+ label: {
6
6
  id: getTrad('EditForm.inputToggle.label.email'),
7
7
  defaultMessage: 'One account per email address',
8
8
  },
9
- description: {
9
+ hint: {
10
10
  id: getTrad('EditForm.inputToggle.description.email'),
11
11
  defaultMessage:
12
12
  'Disallow the user to create multiple accounts using the same email address with different authentication providers.',
13
13
  },
14
14
  name: 'unique_email',
15
- type: 'bool',
16
- size: {
17
- col: 12,
18
- xs: 12,
19
- },
15
+ type: 'boolean',
16
+ size: 12,
20
17
  },
21
18
  {
22
- intlLabel: {
19
+ label: {
23
20
  id: getTrad('EditForm.inputToggle.label.sign-up'),
24
21
  defaultMessage: 'Enable sign-ups',
25
22
  },
26
- description: {
23
+ hint: {
27
24
  id: getTrad('EditForm.inputToggle.description.sign-up'),
28
25
  defaultMessage:
29
26
  'When disabled (OFF), the registration process is forbidden. No one can subscribe anymore no matter the used provider.',
30
27
  },
31
28
  name: 'allow_register',
32
- type: 'bool',
33
- size: {
34
- col: 12,
35
- xs: 12,
36
- },
29
+ type: 'boolean',
30
+ size: 12,
37
31
  },
38
32
  {
39
- intlLabel: {
33
+ label: {
40
34
  id: getTrad('EditForm.inputToggle.label.email-reset-password'),
41
35
  defaultMessage: 'Reset password page',
42
36
  },
43
- description: {
37
+ hint: {
44
38
  id: getTrad('EditForm.inputToggle.description.email-reset-password'),
45
39
  defaultMessage: "URL of your application's reset password page.",
46
40
  },
@@ -49,34 +43,28 @@ const layout = [
49
43
  defaultMessage: 'ex: https://youtfrontend.com/reset-password',
50
44
  },
51
45
  name: 'email_reset_password',
52
- type: 'text',
53
- size: {
54
- col: 6,
55
- xs: 12,
56
- },
46
+ type: 'string',
47
+ size: 12,
57
48
  },
58
49
  {
59
- intlLabel: {
50
+ label: {
60
51
  id: getTrad('EditForm.inputToggle.label.email-confirmation'),
61
52
  defaultMessage: 'Enable email confirmation',
62
53
  },
63
- description: {
54
+ hint: {
64
55
  id: getTrad('EditForm.inputToggle.description.email-confirmation'),
65
56
  defaultMessage: 'When enabled (ON), new registered users receive a confirmation email.',
66
57
  },
67
58
  name: 'email_confirmation',
68
- type: 'bool',
69
- size: {
70
- col: 12,
71
- xs: 12,
72
- },
59
+ type: 'boolean',
60
+ size: 12,
73
61
  },
74
62
  {
75
- intlLabel: {
63
+ label: {
76
64
  id: getTrad('EditForm.inputToggle.label.email-confirmation-redirection'),
77
65
  defaultMessage: 'Redirection url',
78
66
  },
79
- description: {
67
+ hint: {
80
68
  id: getTrad('EditForm.inputToggle.description.email-confirmation-redirection'),
81
69
  defaultMessage: 'After you confirmed your email, choose where you will be redirected.',
82
70
  },
@@ -85,11 +73,8 @@ const layout = [
85
73
  defaultMessage: 'ex: https://youtfrontend.com/email-confirmation',
86
74
  },
87
75
  name: 'email_confirmation_redirection',
88
- type: 'text',
89
- size: {
90
- col: 6,
91
- xs: 12,
92
- },
76
+ type: 'string',
77
+ size: 12,
93
78
  },
94
79
  ];
95
80
 
@@ -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
  // eslint-disable-next-line prefer-regex-literals
@@ -12,7 +12,10 @@ const schema = yup.object().shape({
12
12
  }),
13
13
  email_reset_password: yup
14
14
  .string(translatedErrors.string)
15
- .matches(URL_REGEX, translatedErrors.regex)
15
+ .matches(URL_REGEX, {
16
+ id: translatedErrors.regex.id,
17
+ defaultMessage: 'This is not a valid URL',
18
+ })
16
19
  .nullable(),
17
20
  });
18
21
 
@@ -8,11 +8,9 @@ import {
8
8
  ModalFooter,
9
9
  ModalHeader,
10
10
  ModalLayout,
11
- Textarea,
12
11
  } from '@strapi/design-system';
13
12
  import { Breadcrumbs, Crumb } from '@strapi/design-system/v2';
14
- import { Form, GenericInput } from '@strapi/helper-plugin';
15
- import { Formik } from 'formik';
13
+ import { Form, InputRenderer } from '@strapi/strapi/admin';
16
14
  import PropTypes from 'prop-types';
17
15
  import { useIntl } from 'react-intl';
18
16
 
@@ -51,88 +49,63 @@ const EmailForm = ({ template, onToggle, onSubmit }) => {
51
49
  </Crumb>
52
50
  </Breadcrumbs>
53
51
  </ModalHeader>
54
- <Formik
55
- onSubmit={onSubmit}
56
- initialValues={template}
57
- validateOnChange={false}
58
- validationSchema={schema}
59
- enableReinitialize
60
- >
61
- {({ errors, values, handleChange, isSubmitting }) => {
52
+ <Form onSubmit={onSubmit} initialValues={template} validationSchema={schema}>
53
+ {({ isSubmitting }) => {
62
54
  return (
63
- <Form>
55
+ <>
64
56
  <ModalBody>
65
57
  <Grid gap={5}>
66
- <GridItem col={6} s={12}>
67
- <GenericInput
68
- intlLabel={{
58
+ {[
59
+ {
60
+ label: formatMessage({
69
61
  id: getTrad('PopUpForm.Email.options.from.name.label'),
70
62
  defaultMessage: 'Shipper name',
71
- }}
72
- name="options.from.name"
73
- onChange={handleChange}
74
- value={values.options.from.name}
75
- error={errors?.options?.from?.name}
76
- type="text"
77
- />
78
- </GridItem>
79
- <GridItem col={6} s={12}>
80
- <GenericInput
81
- intlLabel={{
63
+ }),
64
+ name: 'options.from.name',
65
+ size: 6,
66
+ type: 'string',
67
+ },
68
+ {
69
+ label: formatMessage({
82
70
  id: getTrad('PopUpForm.Email.options.from.email.label'),
83
71
  defaultMessage: 'Shipper email',
84
- }}
85
- name="options.from.email"
86
- onChange={handleChange}
87
- value={values.options.from.email}
88
- error={errors?.options?.from?.email}
89
- type="text"
90
- />
91
- </GridItem>
92
- <GridItem col={6} s={12}>
93
- <GenericInput
94
- intlLabel={{
72
+ }),
73
+ name: 'options.from.email',
74
+ size: 6,
75
+ type: 'string',
76
+ },
77
+ {
78
+ label: formatMessage({
95
79
  id: getTrad('PopUpForm.Email.options.response_email.label'),
96
80
  defaultMessage: 'Response email',
97
- }}
98
- name="options.response_email"
99
- onChange={handleChange}
100
- value={values.options.response_email}
101
- error={errors?.options?.response_email}
102
- type="text"
103
- />
104
- </GridItem>
105
- <GridItem col={6} s={12}>
106
- <GenericInput
107
- intlLabel={{
81
+ }),
82
+ name: 'options.response_email',
83
+ size: 6,
84
+ type: 'string',
85
+ },
86
+ {
87
+ label: formatMessage({
108
88
  id: getTrad('PopUpForm.Email.options.object.label'),
109
89
  defaultMessage: 'Subject',
110
- }}
111
- name="options.object"
112
- onChange={handleChange}
113
- value={values.options.object}
114
- error={errors?.options?.object}
115
- type="text"
116
- />
117
- </GridItem>
118
- <GridItem col={12} s={12}>
119
- <Textarea
120
- label={formatMessage({
90
+ }),
91
+ name: 'options.object',
92
+ size: 6,
93
+ type: 'string',
94
+ },
95
+ {
96
+ label: formatMessage({
121
97
  id: getTrad('PopUpForm.Email.options.message.label'),
122
98
  defaultMessage: 'Message',
123
- })}
124
- id="options.message"
125
- onChange={handleChange}
126
- value={values.options.message}
127
- error={
128
- errors?.options?.message &&
129
- formatMessage({
130
- id: errors.options.message,
131
- defaultMessage: errors.options.message,
132
- })
133
- }
134
- />
135
- </GridItem>
99
+ }),
100
+ name: 'options.message',
101
+ size: 12,
102
+ type: 'text',
103
+ },
104
+ ].map(({ size, ...field }) => (
105
+ <GridItem key={field.name} col={size}>
106
+ <InputRenderer {...field} />
107
+ </GridItem>
108
+ ))}
136
109
  </Grid>
137
110
  </ModalBody>
138
111
  <ModalFooter
@@ -147,10 +120,10 @@ const EmailForm = ({ template, onToggle, onSubmit }) => {
147
120
  </Button>
148
121
  }
149
122
  />
150
- </Form>
123
+ </>
151
124
  );
152
125
  }}
153
- </Formik>
126
+ </Form>
154
127
  </ModalLayout>
155
128
  );
156
129
  };