@strapi/plugin-users-permissions 4.3.4 → 4.3.7

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 (75) hide show
  1. package/admin/src/components/BoundRoute/getMethodColor.js +1 -1
  2. package/admin/src/components/BoundRoute/index.js +1 -1
  3. package/admin/src/components/FormModal/Input/index.js +1 -1
  4. package/admin/src/components/FormModal/index.js +7 -9
  5. package/admin/src/components/Permissions/PermissionRow/CheckboxWrapper.js +3 -3
  6. package/admin/src/components/Permissions/PermissionRow/SubCategory.js +10 -14
  7. package/admin/src/components/Permissions/PermissionRow/index.js +1 -1
  8. package/admin/src/components/Permissions/index.js +2 -2
  9. package/admin/src/components/Permissions/init.js +1 -1
  10. package/admin/src/components/Permissions/reducer.js +1 -1
  11. package/admin/src/components/Policies/index.js +1 -1
  12. package/admin/src/components/UsersPermissions/index.js +5 -5
  13. package/admin/src/components/UsersPermissions/reducer.js +1 -1
  14. package/admin/src/hooks/useFetchRole/index.js +3 -3
  15. package/admin/src/hooks/useFetchRole/reducer.js +1 -1
  16. package/admin/src/hooks/useForm/index.js +1 -1
  17. package/admin/src/hooks/useForm/reducer.js +1 -1
  18. package/admin/src/hooks/usePlugins/index.js +1 -1
  19. package/admin/src/hooks/usePlugins/reducer.js +1 -1
  20. package/admin/src/hooks/useRolesList/reducer.js +1 -1
  21. package/admin/src/index.js +5 -5
  22. package/admin/src/pages/AdvancedSettings/index.js +12 -11
  23. package/admin/src/pages/AdvancedSettings/utils/api.js +1 -1
  24. package/admin/src/pages/AdvancedSettings/utils/schema.js +2 -4
  25. package/admin/src/pages/EmailTemplates/index.js +8 -8
  26. package/admin/src/pages/EmailTemplates/utils/api.js +1 -1
  27. package/admin/src/pages/EmailTemplates/utils/schema.js +1 -4
  28. package/admin/src/pages/Providers/index.js +22 -22
  29. package/admin/src/pages/Providers/reducer.js +1 -1
  30. package/admin/src/pages/Providers/utils/api.js +2 -2
  31. package/admin/src/pages/Providers/utils/createProvidersArray.js +1 -1
  32. package/admin/src/pages/Roles/CreatePage/index.js +1 -1
  33. package/admin/src/pages/Roles/EditPage/index.js +1 -1
  34. package/admin/src/pages/Roles/ListPage/components/TableBody.js +5 -4
  35. package/admin/src/pages/Roles/ListPage/index.js +3 -3
  36. package/admin/src/utils/axiosInstance.js +4 -4
  37. package/admin/src/utils/cleanPermissions.js +1 -1
  38. package/admin/src/utils/formatPolicies.js +1 -1
  39. package/admin/src/utils/getRequestURL.js +1 -1
  40. package/admin/src/utils/getTrad.js +1 -1
  41. package/documentation/content-api.yaml +54 -31
  42. package/jest.config.front.js +1 -1
  43. package/package.json +12 -7
  44. package/server/bootstrap/grant-config.js +1 -1
  45. package/server/bootstrap/index.js +39 -39
  46. package/server/controllers/auth.js +2 -5
  47. package/server/controllers/content-manager-user.js +4 -12
  48. package/server/controllers/settings.js +1 -1
  49. package/server/controllers/user.js +2 -2
  50. package/server/controllers/validation/auth.js +3 -12
  51. package/server/controllers/validation/email-template.js +3 -2
  52. package/server/controllers/validation/user.js +4 -16
  53. package/server/graphql/mutations/auth/change-password.js +1 -4
  54. package/server/graphql/mutations/auth/forgot-password.js +1 -4
  55. package/server/graphql/mutations/auth/login.js +1 -4
  56. package/server/graphql/mutations/auth/register.js +1 -4
  57. package/server/graphql/mutations/auth/reset-password.js +1 -4
  58. package/server/graphql/mutations/crud/role/create-role.js +1 -4
  59. package/server/graphql/mutations/crud/role/delete-role.js +1 -4
  60. package/server/graphql/mutations/crud/role/update-role.js +1 -4
  61. package/server/graphql/mutations/crud/user/create-user.js +1 -4
  62. package/server/graphql/mutations/crud/user/delete-user.js +1 -4
  63. package/server/graphql/mutations/crud/user/update-user.js +1 -4
  64. package/server/graphql/mutations/index.js +1 -1
  65. package/server/graphql/types/index.js +1 -1
  66. package/server/middlewares/rateLimit.js +22 -25
  67. package/server/register.js +2 -4
  68. package/server/services/jwt.js +11 -9
  69. package/server/services/providers-registry.js +33 -42
  70. package/server/services/providers.js +6 -6
  71. package/server/services/role.js +7 -7
  72. package/server/services/user.js +1 -1
  73. package/server/services/users-permissions.js +12 -12
  74. package/server/strategies/users-permissions.js +3 -3
  75. package/server/utils/index.js +1 -1
@@ -1,4 +1,4 @@
1
- const getMethodColor = verb => {
1
+ const getMethodColor = (verb) => {
2
2
  switch (verb) {
3
3
  case 'POST': {
4
4
  return {
@@ -42,7 +42,7 @@ function BoundRoute({ route }) {
42
42
  </Typography>
43
43
  </MethodBox>
44
44
  <Box paddingLeft={2} paddingRight={2}>
45
- {map(formattedRoute, value => (
45
+ {map(formattedRoute, (value) => (
46
46
  <Typography key={value} textColor={value.includes(':') ? 'neutral600' : 'neutral900'}>
47
47
  /{value}
48
48
  </Typography>
@@ -54,7 +54,7 @@ const Input = ({
54
54
  id: 'app.components.ToggleCheckbox.on-label',
55
55
  defaultMessage: 'On',
56
56
  })}
57
- onChange={e => {
57
+ onChange={(e) => {
58
58
  onChange({ target: { name, value: e.target.checked } });
59
59
  }}
60
60
  />
@@ -41,13 +41,13 @@ const FormModal = ({
41
41
  <ModalLayout onClose={onToggle} labelledBy="title">
42
42
  <ModalHeader>
43
43
  <Breadcrumbs label={headerBreadcrumbs.join(', ')}>
44
- {headerBreadcrumbs.map(crumb => (
44
+ {headerBreadcrumbs.map((crumb) => (
45
45
  <Crumb key={crumb}>{crumb}</Crumb>
46
46
  ))}
47
47
  </Breadcrumbs>
48
48
  </ModalHeader>
49
49
  <Formik
50
- onSubmit={values => onSubmit(values)}
50
+ onSubmit={(values) => onSubmit(values)}
51
51
  initialValues={initialData}
52
52
  validationSchema={layout.schema}
53
53
  validateOnChange={false}
@@ -58,8 +58,8 @@ const FormModal = ({
58
58
  <ModalBody>
59
59
  <Stack spacing={1}>
60
60
  <Grid gap={5}>
61
- {layout.form.map(row => {
62
- return row.map(input => {
61
+ {layout.form.map((row) => {
62
+ return row.map((input) => {
63
63
  return (
64
64
  <GridItem key={input.name} col={input.size} xs={12}>
65
65
  <Input
@@ -86,11 +86,9 @@ const FormModal = ({
86
86
  </Button>
87
87
  }
88
88
  endActions={
89
- <>
90
- <Button type="submit" loading={isSubmiting}>
91
- {formatMessage({ id: 'global.save', defaultMessage: 'Save' })}
92
- </Button>
93
- </>
89
+ <Button type="submit" loading={isSubmiting}>
90
+ {formatMessage({ id: 'global.save', defaultMessage: 'Save' })}
91
+ </Button>
94
92
  }
95
93
  />
96
94
  </Form>
@@ -2,7 +2,7 @@ import styled, { css } from 'styled-components';
2
2
  import { Box } from '@strapi/design-system/Box';
3
3
 
4
4
  const activeCheckboxWrapperStyles = css`
5
- background: ${props => props.theme.colors.primary100};
5
+ background: ${(props) => props.theme.colors.primary100};
6
6
  svg {
7
7
  opacity: 1;
8
8
  }
@@ -16,12 +16,12 @@ const CheckboxWrapper = styled(Box)`
16
16
  svg {
17
17
  opacity: 0;
18
18
  path {
19
- fill: ${props => props.theme.colors.primary600};
19
+ fill: ${(props) => props.theme.colors.primary600};
20
20
  }
21
21
  }
22
22
 
23
23
  /* Show active style both on hover and when the action is selected */
24
- ${props => props.isActive && activeCheckboxWrapperStyles}
24
+ ${(props) => props.isActive && activeCheckboxWrapperStyles}
25
25
  &:hover {
26
26
  ${activeCheckboxWrapperStyles}
27
27
  }
@@ -20,25 +20,20 @@ const Border = styled.div`
20
20
 
21
21
  const SubCategory = ({ subCategory }) => {
22
22
  const { formatMessage } = useIntl();
23
- const {
24
- onChange,
25
- onChangeSelectAll,
26
- onSelectedAction,
27
- selectedAction,
28
- modifiedData,
29
- } = useUsersPermissions();
23
+ const { onChange, onChangeSelectAll, onSelectedAction, selectedAction, modifiedData } =
24
+ useUsersPermissions();
30
25
 
31
26
  const currentScopedModifiedData = useMemo(() => {
32
27
  return get(modifiedData, subCategory.name, {});
33
28
  }, [modifiedData, subCategory]);
34
29
 
35
30
  const hasAllActionsSelected = useMemo(() => {
36
- return Object.values(currentScopedModifiedData).every(action => action.enabled === true);
31
+ return Object.values(currentScopedModifiedData).every((action) => action.enabled === true);
37
32
  }, [currentScopedModifiedData]);
38
33
 
39
34
  const hasSomeActionsSelected = useMemo(() => {
40
35
  return (
41
- Object.values(currentScopedModifiedData).some(action => action.enabled === true) &&
36
+ Object.values(currentScopedModifiedData).some((action) => action.enabled === true) &&
42
37
  !hasAllActionsSelected
43
38
  );
44
39
  }, [currentScopedModifiedData, hasAllActionsSelected]);
@@ -51,7 +46,7 @@ const SubCategory = ({ subCategory }) => {
51
46
  );
52
47
 
53
48
  const isActionSelected = useCallback(
54
- actionName => {
49
+ (actionName) => {
55
50
  return selectedAction === actionName;
56
51
  },
57
52
  [selectedAction]
@@ -70,8 +65,9 @@ const SubCategory = ({ subCategory }) => {
70
65
  <Checkbox
71
66
  name={subCategory.name}
72
67
  value={hasAllActionsSelected}
73
- onValueChange={value =>
74
- handleChangeSelectAll({ target: { name: subCategory.name, value } })}
68
+ onValueChange={(value) =>
69
+ handleChangeSelectAll({ target: { name: subCategory.name, value } })
70
+ }
75
71
  indeterminate={hasSomeActionsSelected}
76
72
  >
77
73
  {formatMessage({ id: 'app.utils.select-all', defaultMessage: 'Select all' })}
@@ -80,7 +76,7 @@ const SubCategory = ({ subCategory }) => {
80
76
  </Flex>
81
77
  <Flex paddingTop={6} paddingBottom={6}>
82
78
  <Grid gap={2} style={{ flex: 1 }}>
83
- {subCategory.actions.map(action => {
79
+ {subCategory.actions.map((action) => {
84
80
  const name = `${action.name}.enabled`;
85
81
 
86
82
  return (
@@ -89,7 +85,7 @@ const SubCategory = ({ subCategory }) => {
89
85
  <Checkbox
90
86
  value={get(modifiedData, name, false)}
91
87
  name={name}
92
- onValueChange={value => onChange({ target: { name, value } })}
88
+ onValueChange={(value) => onChange({ target: { name, value } })}
93
89
  >
94
90
  {action.label}
95
91
  </Checkbox>
@@ -38,7 +38,7 @@ const PermissionRow = ({ name, permissions }) => {
38
38
 
39
39
  return (
40
40
  <Box padding={6}>
41
- {subCategories.map(subCategory => (
41
+ {subCategories.map((subCategory) => (
42
42
  <SubCategory key={subCategory.name} subCategory={subCategory} />
43
43
  ))}
44
44
  </Box>
@@ -12,11 +12,11 @@ import { initialState, reducer } from './reducer';
12
12
  const Permissions = () => {
13
13
  const { modifiedData } = useUsersPermissions();
14
14
  const { formatMessage } = useIntl();
15
- const [{ collapses }, dispatch] = useReducer(reducer, initialState, state =>
15
+ const [{ collapses }, dispatch] = useReducer(reducer, initialState, (state) =>
16
16
  init(state, modifiedData)
17
17
  );
18
18
 
19
- const handleToggle = index =>
19
+ const handleToggle = (index) =>
20
20
  dispatch({
21
21
  type: 'TOGGLE_COLLAPSE',
22
22
  index,
@@ -1,7 +1,7 @@
1
1
  const init = (initialState, permissions) => {
2
2
  const collapses = Object.keys(permissions)
3
3
  .sort()
4
- .map(name => ({ name, isOpen: false }));
4
+ .map((name) => ({ name, isOpen: false }));
5
5
 
6
6
  return { ...initialState, collapses };
7
7
  };
@@ -6,7 +6,7 @@ const initialState = {
6
6
 
7
7
  const reducer = (state, action) =>
8
8
  // eslint-disable-next-line consistent-return
9
- produce(state, draftState => {
9
+ produce(state, (draftState) => {
10
10
  switch (action.type) {
11
11
  case 'TOGGLE_COLLAPSE': {
12
12
  draftState.collapses = state.collapses.map((collapse, index) => {
@@ -17,7 +17,7 @@ const Policies = () => {
17
17
 
18
18
  const displayedRoutes = isEmpty(controllerRoutes)
19
19
  ? []
20
- : controllerRoutes.filter(o => o.handler.endsWith(pathResolved));
20
+ : controllerRoutes.filter((o) => o.handler.endsWith(pathResolved));
21
21
 
22
22
  return (
23
23
  <GridItem
@@ -13,20 +13,20 @@ import init from './init';
13
13
 
14
14
  const UsersPermissions = forwardRef(({ permissions, routes }, ref) => {
15
15
  const { formatMessage } = useIntl();
16
- const [state, dispatch] = useReducer(reducer, initialState, state =>
16
+ const [state, dispatch] = useReducer(reducer, initialState, (state) =>
17
17
  init(state, permissions, routes)
18
18
  );
19
19
 
20
20
  useImperativeHandle(ref, () => ({
21
- getPermissions: () => {
21
+ getPermissions() {
22
22
  return {
23
23
  permissions: state.modifiedData,
24
24
  };
25
25
  },
26
- resetForm: () => {
26
+ resetForm() {
27
27
  dispatch({ type: 'ON_RESET' });
28
28
  },
29
- setFormAfterSubmit: () => {
29
+ setFormAfterSubmit() {
30
30
  dispatch({ type: 'ON_SUBMIT_SUCCEEDED' });
31
31
  },
32
32
  }));
@@ -45,7 +45,7 @@ const UsersPermissions = forwardRef(({ permissions, routes }, ref) => {
45
45
  value,
46
46
  });
47
47
 
48
- const handleSelectedAction = actionToSelect =>
48
+ const handleSelectedAction = (actionToSelect) =>
49
49
  dispatch({
50
50
  type: 'SELECT_ACTION',
51
51
  actionToSelect,
@@ -11,7 +11,7 @@ export const initialState = {
11
11
  };
12
12
 
13
13
  const reducer = (state, action) =>
14
- produce(state, draftState => {
14
+ produce(state, (draftState) => {
15
15
  switch (action.type) {
16
16
  case 'ON_CHANGE': {
17
17
  const keysLength = action.keys.length;
@@ -4,7 +4,7 @@ import reducer, { initialState } from './reducer';
4
4
  import axiosIntance from '../../utils/axiosInstance';
5
5
  import pluginId from '../../pluginId';
6
6
 
7
- const useFetchRole = id => {
7
+ const useFetchRole = (id) => {
8
8
  const [state, dispatch] = useReducer(reducer, initialState);
9
9
  const toggleNotification = useNotification();
10
10
  const isMounted = useRef(null);
@@ -25,7 +25,7 @@ const useFetchRole = id => {
25
25
  // eslint-disable-next-line react-hooks/exhaustive-deps
26
26
  }, [id]);
27
27
 
28
- const fetchRole = async roleId => {
28
+ const fetchRole = async (roleId) => {
29
29
  try {
30
30
  const {
31
31
  data: { role },
@@ -51,7 +51,7 @@ const useFetchRole = id => {
51
51
  }
52
52
  };
53
53
 
54
- const handleSubmitSucceeded = useCallback(data => {
54
+ const handleSubmitSucceeded = useCallback((data) => {
55
55
  dispatch({
56
56
  type: 'ON_SUBMIT_SUCCEEDED',
57
57
  ...data,
@@ -7,7 +7,7 @@ export const initialState = {
7
7
  };
8
8
 
9
9
  const reducer = (state, action) =>
10
- produce(state, draftState => {
10
+ produce(state, (draftState) => {
11
11
  switch (action.type) {
12
12
  case 'GET_DATA_SUCCEEDED': {
13
13
  draftState.role = action.role;
@@ -51,7 +51,7 @@ const useUserForm = (endPoint, permissions) => {
51
51
  // eslint-disable-next-line react-hooks/exhaustive-deps
52
52
  }, [isLoadingForPermissions, endPoint]);
53
53
 
54
- const dispatchSubmitSucceeded = useCallback(data => {
54
+ const dispatchSubmitSucceeded = useCallback((data) => {
55
55
  dispatch({
56
56
  type: 'ON_SUBMIT_SUCCEEDED',
57
57
  data,
@@ -7,7 +7,7 @@ const initialState = {
7
7
 
8
8
  const reducer = (state, action) =>
9
9
  // eslint-disable-next-line consistent-return
10
- produce(state, draftState => {
10
+ produce(state, (draftState) => {
11
11
  switch (action.type) {
12
12
  case 'GET_DATA': {
13
13
  draftState.isLoading = true;
@@ -20,7 +20,7 @@ const usePlugins = (shouldFetchData = true) => {
20
20
  });
21
21
 
22
22
  const [{ permissions }, { routes }] = await Promise.all(
23
- [`/${pluginId}/permissions`, `/${pluginId}/routes`].map(async endpoint => {
23
+ [`/${pluginId}/permissions`, `/${pluginId}/routes`].map(async (endpoint) => {
24
24
  const res = await axiosInstance.get(endpoint);
25
25
 
26
26
  return res.data;
@@ -8,7 +8,7 @@ export const initialState = {
8
8
  };
9
9
 
10
10
  const reducer = (state, action) =>
11
- produce(state, draftState => {
11
+ produce(state, (draftState) => {
12
12
  switch (action.type) {
13
13
  case 'GET_DATA': {
14
14
  draftState.isLoading = true;
@@ -7,7 +7,7 @@ export const initialState = {
7
7
  };
8
8
 
9
9
  const reducer = (state, action) =>
10
- produce(state, draftState => {
10
+ produce(state, (draftState) => {
11
11
  switch (action.type) {
12
12
  case 'GET_DATA': {
13
13
  draftState.isLoading = true;
@@ -31,7 +31,7 @@ export default {
31
31
  },
32
32
  id: 'roles',
33
33
  to: `/settings/${pluginId}/roles`,
34
- Component: async () => {
34
+ async Component() {
35
35
  const component = await import(
36
36
  /* webpackChunkName: "users-roles-settings-page" */ './pages/Roles'
37
37
  );
@@ -47,7 +47,7 @@ export default {
47
47
  },
48
48
  id: 'providers',
49
49
  to: `/settings/${pluginId}/providers`,
50
- Component: async () => {
50
+ async Component() {
51
51
  const component = await import(
52
52
  /* webpackChunkName: "users-providers-settings-page" */ './pages/Providers'
53
53
  );
@@ -63,7 +63,7 @@ export default {
63
63
  },
64
64
  id: 'email-templates',
65
65
  to: `/settings/${pluginId}/email-templates`,
66
- Component: async () => {
66
+ async Component() {
67
67
  const component = await import(
68
68
  /* webpackChunkName: "users-email-settings-page" */ './pages/EmailTemplates'
69
69
  );
@@ -79,7 +79,7 @@ export default {
79
79
  },
80
80
  id: 'advanced-settings',
81
81
  to: `/settings/${pluginId}/advanced-settings`,
82
- Component: async () => {
82
+ async Component() {
83
83
  const component = await import(
84
84
  /* webpackChunkName: "users-advanced-settings-page" */ './pages/AdvancedSettings'
85
85
  );
@@ -99,7 +99,7 @@ export default {
99
99
  bootstrap() {},
100
100
  async registerTrads({ locales }) {
101
101
  const importedTrads = await Promise.all(
102
- locales.map(locale => {
102
+ locales.map((locale) => {
103
103
  return import(
104
104
  /* webpackChunkName: "users-permissions-translation-[request]" */ `./translations/${locale}.json`
105
105
  )
@@ -53,7 +53,7 @@ const AdvancedSettingsPage = () => {
53
53
  } = useRBAC(updatePermissions);
54
54
 
55
55
  const { status: isLoadingData, data } = useQuery('advanced', () => fetchData(), {
56
- onSuccess: () => {
56
+ onSuccess() {
57
57
  notifyStatus(
58
58
  formatMessage({
59
59
  id: getTrad('Form.advancedSettings.data.loaded'),
@@ -61,7 +61,7 @@ const AdvancedSettingsPage = () => {
61
61
  })
62
62
  );
63
63
  },
64
- onError: () => {
64
+ onError() {
65
65
  toggleNotification({
66
66
  type: 'warning',
67
67
  message: { id: getTrad('notification.error'), defaultMessage: 'An error occured' },
@@ -71,8 +71,8 @@ const AdvancedSettingsPage = () => {
71
71
 
72
72
  const isLoading = isLoadingForPermissions || isLoadingData !== 'success';
73
73
 
74
- const submitMutation = useMutation(body => putAdvancedSettings(body), {
75
- onSuccess: async () => {
74
+ const submitMutation = useMutation((body) => putAdvancedSettings(body), {
75
+ async onSuccess() {
76
76
  await queryClient.invalidateQueries('advanced');
77
77
  toggleNotification({
78
78
  type: 'success',
@@ -81,7 +81,7 @@ const AdvancedSettingsPage = () => {
81
81
 
82
82
  unlockApp();
83
83
  },
84
- onError: () => {
84
+ onError() {
85
85
  toggleNotification({
86
86
  type: 'warning',
87
87
  message: { id: getTrad('notification.error'), defaultMessage: 'An error occured' },
@@ -93,7 +93,7 @@ const AdvancedSettingsPage = () => {
93
93
 
94
94
  const { isLoading: isSubmittingForm } = submitMutation;
95
95
 
96
- const handleSubmit = async body => {
96
+ const handleSubmit = async (body) => {
97
97
  lockApp();
98
98
 
99
99
  const urlConfirmation = body.email_confirmation ? body.email_confirmation_redirection : '';
@@ -152,7 +152,7 @@ const AdvancedSettingsPage = () => {
152
152
  type="submit"
153
153
  disabled={!canUpdate}
154
154
  startIcon={<Check />}
155
- size="L"
155
+ size="S"
156
156
  >
157
157
  {formatMessage({ id: 'global.save', defaultMessage: 'Save' })}
158
158
  </Button>
@@ -188,10 +188,11 @@ const AdvancedSettingsPage = () => {
188
188
  defaultMessage:
189
189
  'It will attach the new authenticated user to the selected role.',
190
190
  })}
191
- onChange={e =>
192
- handleChange({ target: { name: 'default_role', value: e } })}
191
+ onChange={(e) =>
192
+ handleChange({ target: { name: 'default_role', value: e } })
193
+ }
193
194
  >
194
- {data.roles.map(role => {
195
+ {data.roles.map((role) => {
195
196
  return (
196
197
  <Option key={role.type} value={role.type}>
197
198
  {role.name}
@@ -200,7 +201,7 @@ const AdvancedSettingsPage = () => {
200
201
  })}
201
202
  </Select>
202
203
  </GridItem>
203
- {layout.map(input => {
204
+ {layout.map((input) => {
204
205
  let value = values[input.name];
205
206
 
206
207
  if (!value) {
@@ -6,7 +6,7 @@ const fetchData = async () => {
6
6
  return data;
7
7
  };
8
8
 
9
- const putAdvancedSettings = body => {
9
+ const putAdvancedSettings = (body) => {
10
10
  return axiosInstance.put(getRequestURL('advanced'), body);
11
11
  };
12
12
 
@@ -1,15 +1,13 @@
1
1
  import * as yup from 'yup';
2
2
  import { translatedErrors } from '@strapi/helper-plugin';
3
3
 
4
+ // eslint-disable-next-line prefer-regex-literals
4
5
  const URL_REGEX = new RegExp('(^$)|((.+:\\/\\/.*)(d*)\\/?(.*))');
5
6
 
6
7
  const schema = yup.object().shape({
7
8
  email_confirmation_redirection: yup.mixed().when('email_confirmation', {
8
9
  is: true,
9
- then: yup
10
- .string()
11
- .matches(URL_REGEX)
12
- .required(),
10
+ then: yup.string().matches(URL_REGEX).required(),
13
11
  otherwise: yup.string().nullable(),
14
12
  }),
15
13
  email_reset_password: yup
@@ -49,7 +49,7 @@ const EmailTemplatesPage = () => {
49
49
  } = useRBAC(updatePermissions);
50
50
 
51
51
  const { status: isLoadingData, data } = useQuery('email-templates', () => fetchData(), {
52
- onSuccess: () => {
52
+ onSuccess() {
53
53
  notifyStatus(
54
54
  formatMessage({
55
55
  id: getTrad('Email.template.data.loaded'),
@@ -57,7 +57,7 @@ const EmailTemplatesPage = () => {
57
57
  })
58
58
  );
59
59
  },
60
- onError: () => {
60
+ onError() {
61
61
  toggleNotification({
62
62
  type: 'warning',
63
63
  message: { id: 'notification.error', defaultMessage: 'An error occured' },
@@ -68,16 +68,16 @@ const EmailTemplatesPage = () => {
68
68
  const isLoading = isLoadingForPermissions || isLoadingData !== 'success';
69
69
 
70
70
  const handleToggle = () => {
71
- setIsModalOpen(prev => !prev);
71
+ setIsModalOpen((prev) => !prev);
72
72
  };
73
73
 
74
- const handleEditClick = template => {
74
+ const handleEditClick = (template) => {
75
75
  setTemplateToEdit(template);
76
76
  handleToggle();
77
77
  };
78
78
 
79
- const submitMutation = useMutation(body => putEmailTemplate({ 'email-templates': body }), {
80
- onSuccess: async () => {
79
+ const submitMutation = useMutation((body) => putEmailTemplate({ 'email-templates': body }), {
80
+ async onSuccess() {
81
81
  await queryClient.invalidateQueries('email-templates');
82
82
 
83
83
  toggleNotification({
@@ -90,7 +90,7 @@ const EmailTemplatesPage = () => {
90
90
  unlockApp();
91
91
  handleToggle();
92
92
  },
93
- onError: () => {
93
+ onError() {
94
94
  toggleNotification({
95
95
  type: 'warning',
96
96
  message: { id: 'notification.error', defaultMessage: 'An error occured' },
@@ -101,7 +101,7 @@ const EmailTemplatesPage = () => {
101
101
  });
102
102
  const { isLoading: isSubmittingForm } = submitMutation;
103
103
 
104
- const handleSubmit = body => {
104
+ const handleSubmit = (body) => {
105
105
  lockApp();
106
106
  trackUsageRef.current('willEditEmailTemplates');
107
107
 
@@ -6,7 +6,7 @@ const fetchData = async () => {
6
6
  return data;
7
7
  };
8
8
 
9
- const putEmailTemplate = body => {
9
+ const putEmailTemplate = (body) => {
10
10
  return axiosInstance.put(getRequestURL('email-templates'), body);
11
11
  };
12
12
 
@@ -9,10 +9,7 @@ const schema = yup.object().shape({
9
9
  .object()
10
10
  .shape({
11
11
  name: yup.string().required(translatedErrors.required),
12
- email: yup
13
- .string()
14
- .email(translatedErrors.email)
15
- .required(translatedErrors.required),
12
+ email: yup.string().email(translatedErrors.email).required(translatedErrors.required),
16
13
  })
17
14
  .required(),
18
15
  response_email: yup.string().email(translatedErrors.email),