@strapi/plugin-users-permissions 0.0.0-4fc90398602f → 0.0.0-8581854cb3
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/components/BoundRoute/getMethodColor.js +1 -1
- package/admin/src/components/BoundRoute/index.js +1 -1
- package/admin/src/components/FormModal/Input/index.js +1 -1
- package/admin/src/components/FormModal/index.js +9 -7
- package/admin/src/components/Permissions/PermissionRow/CheckboxWrapper.js +3 -3
- package/admin/src/components/Permissions/PermissionRow/SubCategory.js +14 -10
- package/admin/src/components/Permissions/PermissionRow/index.js +1 -1
- package/admin/src/components/Permissions/index.js +2 -2
- package/admin/src/components/Permissions/init.js +1 -1
- package/admin/src/components/Permissions/reducer.js +1 -1
- package/admin/src/components/Policies/index.js +1 -1
- package/admin/src/components/UsersPermissions/index.js +5 -5
- package/admin/src/components/UsersPermissions/reducer.js +1 -1
- package/admin/src/hooks/useFetchRole/index.js +3 -3
- package/admin/src/hooks/useFetchRole/reducer.js +1 -1
- package/admin/src/hooks/useForm/index.js +1 -1
- package/admin/src/hooks/useForm/reducer.js +1 -1
- package/admin/src/hooks/usePlugins/index.js +1 -1
- package/admin/src/hooks/usePlugins/reducer.js +1 -1
- package/admin/src/hooks/useRolesList/reducer.js +1 -1
- package/admin/src/index.js +5 -5
- package/admin/src/pages/AdvancedSettings/index.js +10 -11
- package/admin/src/pages/AdvancedSettings/utils/api.js +1 -1
- package/admin/src/pages/AdvancedSettings/utils/schema.js +4 -2
- package/admin/src/pages/EmailTemplates/index.js +8 -8
- package/admin/src/pages/EmailTemplates/utils/api.js +1 -1
- package/admin/src/pages/EmailTemplates/utils/schema.js +4 -1
- package/admin/src/pages/Providers/index.js +22 -22
- package/admin/src/pages/Providers/reducer.js +1 -1
- package/admin/src/pages/Providers/utils/api.js +2 -2
- package/admin/src/pages/Providers/utils/createProvidersArray.js +1 -1
- package/admin/src/pages/Roles/CreatePage/index.js +1 -1
- package/admin/src/pages/Roles/EditPage/index.js +1 -1
- package/admin/src/pages/Roles/ListPage/components/TableBody.js +4 -5
- package/admin/src/pages/Roles/ListPage/index.js +2 -2
- package/admin/src/utils/axiosInstance.js +4 -4
- package/admin/src/utils/cleanPermissions.js +1 -1
- package/admin/src/utils/formatPolicies.js +1 -1
- package/admin/src/utils/getRequestURL.js +1 -1
- package/admin/src/utils/getTrad.js +1 -1
- package/jest.config.front.js +1 -1
- package/package.json +8 -5
- package/server/bootstrap/grant-config.js +1 -1
- package/server/bootstrap/index.js +39 -39
- package/server/controllers/auth.js +5 -2
- package/server/controllers/content-manager-user.js +12 -4
- package/server/controllers/settings.js +1 -1
- package/server/controllers/user.js +2 -2
- package/server/controllers/validation/auth.js +12 -3
- package/server/controllers/validation/email-template.js +2 -3
- package/server/controllers/validation/user.js +16 -4
- package/server/graphql/mutations/auth/change-password.js +4 -1
- package/server/graphql/mutations/auth/forgot-password.js +4 -1
- package/server/graphql/mutations/auth/login.js +4 -1
- package/server/graphql/mutations/auth/register.js +4 -1
- package/server/graphql/mutations/auth/reset-password.js +4 -1
- package/server/graphql/mutations/crud/role/create-role.js +4 -1
- package/server/graphql/mutations/crud/role/delete-role.js +4 -1
- package/server/graphql/mutations/crud/role/update-role.js +4 -1
- package/server/graphql/mutations/crud/user/create-user.js +4 -1
- package/server/graphql/mutations/crud/user/delete-user.js +4 -1
- package/server/graphql/mutations/crud/user/update-user.js +4 -1
- package/server/graphql/mutations/index.js +1 -1
- package/server/graphql/types/index.js +1 -1
- package/server/middlewares/rateLimit.js +25 -22
- package/server/register.js +4 -2
- package/server/services/jwt.js +9 -11
- package/server/services/providers-registry.js +42 -33
- package/server/services/providers.js +5 -5
- package/server/services/role.js +7 -7
- package/server/services/user.js +1 -1
- package/server/services/users-permissions.js +12 -12
- package/server/strategies/users-permissions.js +3 -3
- package/server/utils/index.js +1 -1
|
@@ -42,7 +42,7 @@ function BoundRoute({ route }) {
|
|
|
42
42
|
</Typography>
|
|
43
43
|
</MethodBox>
|
|
44
44
|
<Box paddingLeft={2} paddingRight={2}>
|
|
45
|
-
{map(formattedRoute,
|
|
45
|
+
{map(formattedRoute, value => (
|
|
46
46
|
<Typography key={value} textColor={value.includes(':') ? 'neutral600' : 'neutral900'}>
|
|
47
47
|
/{value}
|
|
48
48
|
</Typography>
|
|
@@ -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(
|
|
44
|
+
{headerBreadcrumbs.map(crumb => (
|
|
45
45
|
<Crumb key={crumb}>{crumb}</Crumb>
|
|
46
46
|
))}
|
|
47
47
|
</Breadcrumbs>
|
|
48
48
|
</ModalHeader>
|
|
49
49
|
<Formik
|
|
50
|
-
onSubmit={
|
|
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(
|
|
62
|
-
return row.map(
|
|
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,9 +86,11 @@ const FormModal = ({
|
|
|
86
86
|
</Button>
|
|
87
87
|
}
|
|
88
88
|
endActions={
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
<>
|
|
90
|
+
<Button type="submit" loading={isSubmiting}>
|
|
91
|
+
{formatMessage({ id: 'global.save', defaultMessage: 'Save' })}
|
|
92
|
+
</Button>
|
|
93
|
+
</>
|
|
92
94
|
}
|
|
93
95
|
/>
|
|
94
96
|
</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: ${
|
|
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: ${
|
|
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
|
-
${
|
|
24
|
+
${props => props.isActive && activeCheckboxWrapperStyles}
|
|
25
25
|
&:hover {
|
|
26
26
|
${activeCheckboxWrapperStyles}
|
|
27
27
|
}
|
|
@@ -20,20 +20,25 @@ const Border = styled.div`
|
|
|
20
20
|
|
|
21
21
|
const SubCategory = ({ subCategory }) => {
|
|
22
22
|
const { formatMessage } = useIntl();
|
|
23
|
-
const {
|
|
24
|
-
|
|
23
|
+
const {
|
|
24
|
+
onChange,
|
|
25
|
+
onChangeSelectAll,
|
|
26
|
+
onSelectedAction,
|
|
27
|
+
selectedAction,
|
|
28
|
+
modifiedData,
|
|
29
|
+
} = useUsersPermissions();
|
|
25
30
|
|
|
26
31
|
const currentScopedModifiedData = useMemo(() => {
|
|
27
32
|
return get(modifiedData, subCategory.name, {});
|
|
28
33
|
}, [modifiedData, subCategory]);
|
|
29
34
|
|
|
30
35
|
const hasAllActionsSelected = useMemo(() => {
|
|
31
|
-
return Object.values(currentScopedModifiedData).every(
|
|
36
|
+
return Object.values(currentScopedModifiedData).every(action => action.enabled === true);
|
|
32
37
|
}, [currentScopedModifiedData]);
|
|
33
38
|
|
|
34
39
|
const hasSomeActionsSelected = useMemo(() => {
|
|
35
40
|
return (
|
|
36
|
-
Object.values(currentScopedModifiedData).some(
|
|
41
|
+
Object.values(currentScopedModifiedData).some(action => action.enabled === true) &&
|
|
37
42
|
!hasAllActionsSelected
|
|
38
43
|
);
|
|
39
44
|
}, [currentScopedModifiedData, hasAllActionsSelected]);
|
|
@@ -46,7 +51,7 @@ const SubCategory = ({ subCategory }) => {
|
|
|
46
51
|
);
|
|
47
52
|
|
|
48
53
|
const isActionSelected = useCallback(
|
|
49
|
-
|
|
54
|
+
actionName => {
|
|
50
55
|
return selectedAction === actionName;
|
|
51
56
|
},
|
|
52
57
|
[selectedAction]
|
|
@@ -65,9 +70,8 @@ const SubCategory = ({ subCategory }) => {
|
|
|
65
70
|
<Checkbox
|
|
66
71
|
name={subCategory.name}
|
|
67
72
|
value={hasAllActionsSelected}
|
|
68
|
-
onValueChange={
|
|
69
|
-
handleChangeSelectAll({ target: { name: subCategory.name, value } })
|
|
70
|
-
}
|
|
73
|
+
onValueChange={value =>
|
|
74
|
+
handleChangeSelectAll({ target: { name: subCategory.name, value } })}
|
|
71
75
|
indeterminate={hasSomeActionsSelected}
|
|
72
76
|
>
|
|
73
77
|
{formatMessage({ id: 'app.utils.select-all', defaultMessage: 'Select all' })}
|
|
@@ -76,7 +80,7 @@ const SubCategory = ({ subCategory }) => {
|
|
|
76
80
|
</Flex>
|
|
77
81
|
<Flex paddingTop={6} paddingBottom={6}>
|
|
78
82
|
<Grid gap={2} style={{ flex: 1 }}>
|
|
79
|
-
{subCategory.actions.map(
|
|
83
|
+
{subCategory.actions.map(action => {
|
|
80
84
|
const name = `${action.name}.enabled`;
|
|
81
85
|
|
|
82
86
|
return (
|
|
@@ -85,7 +89,7 @@ const SubCategory = ({ subCategory }) => {
|
|
|
85
89
|
<Checkbox
|
|
86
90
|
value={get(modifiedData, name, false)}
|
|
87
91
|
name={name}
|
|
88
|
-
onValueChange={
|
|
92
|
+
onValueChange={value => onChange({ target: { name, value } })}
|
|
89
93
|
>
|
|
90
94
|
{action.label}
|
|
91
95
|
</Checkbox>
|
|
@@ -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,
|
|
15
|
+
const [{ collapses }, dispatch] = useReducer(reducer, initialState, state =>
|
|
16
16
|
init(state, modifiedData)
|
|
17
17
|
);
|
|
18
18
|
|
|
19
|
-
const handleToggle =
|
|
19
|
+
const handleToggle = index =>
|
|
20
20
|
dispatch({
|
|
21
21
|
type: 'TOGGLE_COLLAPSE',
|
|
22
22
|
index,
|
|
@@ -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,
|
|
9
|
+
produce(state, draftState => {
|
|
10
10
|
switch (action.type) {
|
|
11
11
|
case 'TOGGLE_COLLAPSE': {
|
|
12
12
|
draftState.collapses = state.collapses.map((collapse, index) => {
|
|
@@ -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,
|
|
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 =
|
|
48
|
+
const handleSelectedAction = actionToSelect =>
|
|
49
49
|
dispatch({
|
|
50
50
|
type: 'SELECT_ACTION',
|
|
51
51
|
actionToSelect,
|
|
@@ -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 =
|
|
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
|
|
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(
|
|
54
|
+
const handleSubmitSucceeded = useCallback(data => {
|
|
55
55
|
dispatch({
|
|
56
56
|
type: 'ON_SUBMIT_SUCCEEDED',
|
|
57
57
|
...data,
|
|
@@ -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(
|
|
54
|
+
const dispatchSubmitSucceeded = useCallback(data => {
|
|
55
55
|
dispatch({
|
|
56
56
|
type: 'ON_SUBMIT_SUCCEEDED',
|
|
57
57
|
data,
|
|
@@ -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
|
|
23
|
+
[`/${pluginId}/permissions`, `/${pluginId}/routes`].map(async endpoint => {
|
|
24
24
|
const res = await axiosInstance.get(endpoint);
|
|
25
25
|
|
|
26
26
|
return res.data;
|
package/admin/src/index.js
CHANGED
|
@@ -31,7 +31,7 @@ export default {
|
|
|
31
31
|
},
|
|
32
32
|
id: 'roles',
|
|
33
33
|
to: `/settings/${pluginId}/roles`,
|
|
34
|
-
async
|
|
34
|
+
Component: async () => {
|
|
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
|
-
async
|
|
50
|
+
Component: async () => {
|
|
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
|
-
async
|
|
66
|
+
Component: async () => {
|
|
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
|
-
async
|
|
82
|
+
Component: async () => {
|
|
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(
|
|
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(
|
|
75
|
-
async
|
|
74
|
+
const submitMutation = useMutation(body => putAdvancedSettings(body), {
|
|
75
|
+
onSuccess: async () => {
|
|
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
|
|
96
|
+
const handleSubmit = async body => {
|
|
97
97
|
lockApp();
|
|
98
98
|
|
|
99
99
|
const urlConfirmation = body.email_confirmation ? body.email_confirmation_redirection : '';
|
|
@@ -188,11 +188,10 @@ const AdvancedSettingsPage = () => {
|
|
|
188
188
|
defaultMessage:
|
|
189
189
|
'It will attach the new authenticated user to the selected role.',
|
|
190
190
|
})}
|
|
191
|
-
onChange={
|
|
192
|
-
handleChange({ target: { name: 'default_role', value: e } })
|
|
193
|
-
}
|
|
191
|
+
onChange={e =>
|
|
192
|
+
handleChange({ target: { name: 'default_role', value: e } })}
|
|
194
193
|
>
|
|
195
|
-
{data.roles.map(
|
|
194
|
+
{data.roles.map(role => {
|
|
196
195
|
return (
|
|
197
196
|
<Option key={role.type} value={role.type}>
|
|
198
197
|
{role.name}
|
|
@@ -201,7 +200,7 @@ const AdvancedSettingsPage = () => {
|
|
|
201
200
|
})}
|
|
202
201
|
</Select>
|
|
203
202
|
</GridItem>
|
|
204
|
-
{layout.map(
|
|
203
|
+
{layout.map(input => {
|
|
205
204
|
let value = values[input.name];
|
|
206
205
|
|
|
207
206
|
if (!value) {
|
|
@@ -1,13 +1,15 @@
|
|
|
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
|
|
5
4
|
const URL_REGEX = new RegExp('(^$)|((.+:\\/\\/.*)(d*)\\/?(.*))');
|
|
6
5
|
|
|
7
6
|
const schema = yup.object().shape({
|
|
8
7
|
email_confirmation_redirection: yup.mixed().when('email_confirmation', {
|
|
9
8
|
is: true,
|
|
10
|
-
then: yup
|
|
9
|
+
then: yup
|
|
10
|
+
.string()
|
|
11
|
+
.matches(URL_REGEX)
|
|
12
|
+
.required(),
|
|
11
13
|
otherwise: yup.string().nullable(),
|
|
12
14
|
}),
|
|
13
15
|
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(
|
|
71
|
+
setIsModalOpen(prev => !prev);
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
-
const handleEditClick =
|
|
74
|
+
const handleEditClick = template => {
|
|
75
75
|
setTemplateToEdit(template);
|
|
76
76
|
handleToggle();
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
const submitMutation = useMutation(
|
|
80
|
-
async
|
|
79
|
+
const submitMutation = useMutation(body => putEmailTemplate({ 'email-templates': body }), {
|
|
80
|
+
onSuccess: async () => {
|
|
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 =
|
|
104
|
+
const handleSubmit = body => {
|
|
105
105
|
lockApp();
|
|
106
106
|
trackUsageRef.current('willEditEmailTemplates');
|
|
107
107
|
|
|
@@ -9,7 +9,10 @@ const schema = yup.object().shape({
|
|
|
9
9
|
.object()
|
|
10
10
|
.shape({
|
|
11
11
|
name: yup.string().required(translatedErrors.required),
|
|
12
|
-
email: yup
|
|
12
|
+
email: yup
|
|
13
|
+
.string()
|
|
14
|
+
.email(translatedErrors.email)
|
|
15
|
+
.required(translatedErrors.required),
|
|
13
16
|
})
|
|
14
17
|
.required(),
|
|
15
18
|
response_email: yup.string().email(translatedErrors.email),
|