@strapi/plugin-users-permissions 4.12.5 → 4.12.6
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/Permissions/index.js +2 -4
- package/admin/src/index.js +7 -8
- package/admin/src/pages/AdvancedSettings/index.js +41 -24
- package/admin/src/pages/EmailTemplates/index.js +62 -47
- package/admin/src/pages/Providers/index.js +64 -58
- package/admin/src/{hooks → pages/Roles/hooks}/usePlugins.js +15 -8
- package/admin/src/pages/Roles/index.js +10 -7
- package/admin/src/pages/Roles/pages/CreatePage.js +190 -0
- package/admin/src/pages/Roles/pages/EditPage.js +211 -0
- package/admin/src/pages/Roles/{ListPage → pages/ListPage}/components/TableBody.js +41 -11
- package/admin/src/pages/Roles/{ListPage → pages/ListPage}/index.js +19 -15
- package/jest.config.front.js +1 -1
- package/package.json +4 -4
- package/admin/src/hooks/index.js +0 -5
- package/admin/src/hooks/useFetchRole/index.js +0 -67
- package/admin/src/hooks/useFetchRole/reducer.js +0 -31
- package/admin/src/hooks/useForm/index.js +0 -68
- package/admin/src/hooks/useForm/reducer.js +0 -40
- package/admin/src/hooks/useRolesList/index.js +0 -65
- package/admin/src/hooks/useRolesList/init.js +0 -5
- package/admin/src/hooks/useRolesList/reducer.js +0 -31
- package/admin/src/pages/AdvancedSettings/utils/api.js +0 -16
- package/admin/src/pages/EmailTemplates/utils/api.js +0 -16
- package/admin/src/pages/Providers/reducer.js +0 -54
- package/admin/src/pages/Providers/utils/api.js +0 -24
- package/admin/src/pages/Providers/utils/createProvidersArray.js +0 -21
- package/admin/src/pages/Roles/CreatePage.js +0 -185
- package/admin/src/pages/Roles/EditPage.js +0 -197
- package/admin/src/pages/Roles/ProtectedCreatePage.js +0 -15
- package/admin/src/pages/Roles/ProtectedEditPage.js +0 -15
- package/admin/src/pages/Roles/ProtectedListPage.js +0 -17
- /package/admin/src/pages/Roles/{ListPage → pages/ListPage}/utils/api.js +0 -0
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/* eslint-disable consistent-return */
|
|
2
|
-
import produce from 'immer';
|
|
3
|
-
|
|
4
|
-
export const initialState = {
|
|
5
|
-
role: {},
|
|
6
|
-
isLoading: true,
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const reducer = (state, action) =>
|
|
10
|
-
produce(state, (draftState) => {
|
|
11
|
-
switch (action.type) {
|
|
12
|
-
case 'GET_DATA_SUCCEEDED': {
|
|
13
|
-
draftState.role = action.role;
|
|
14
|
-
draftState.isLoading = false;
|
|
15
|
-
break;
|
|
16
|
-
}
|
|
17
|
-
case 'GET_DATA_ERROR': {
|
|
18
|
-
draftState.isLoading = false;
|
|
19
|
-
break;
|
|
20
|
-
}
|
|
21
|
-
case 'ON_SUBMIT_SUCCEEDED': {
|
|
22
|
-
draftState.role.name = action.name;
|
|
23
|
-
draftState.role.description = action.description;
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
default:
|
|
27
|
-
return draftState;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
export default reducer;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useReducer, useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import { useFetchClient, useNotification, useRBAC } from '@strapi/helper-plugin';
|
|
4
|
-
|
|
5
|
-
import reducer, { initialState } from './reducer';
|
|
6
|
-
|
|
7
|
-
const useUserForm = (endPoint, permissions) => {
|
|
8
|
-
const { isLoading: isLoadingForPermissions, allowedActions } = useRBAC(permissions);
|
|
9
|
-
const [{ isLoading, modifiedData }, dispatch] = useReducer(reducer, initialState);
|
|
10
|
-
const toggleNotification = useNotification();
|
|
11
|
-
const isMounted = useRef(true);
|
|
12
|
-
|
|
13
|
-
const { get } = useFetchClient();
|
|
14
|
-
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
const getData = async () => {
|
|
17
|
-
try {
|
|
18
|
-
dispatch({
|
|
19
|
-
type: 'GET_DATA',
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
const { data } = await get(`/users-permissions/${endPoint}`);
|
|
23
|
-
|
|
24
|
-
dispatch({
|
|
25
|
-
type: 'GET_DATA_SUCCEEDED',
|
|
26
|
-
data,
|
|
27
|
-
});
|
|
28
|
-
} catch (err) {
|
|
29
|
-
// The user aborted the request
|
|
30
|
-
if (isMounted.current) {
|
|
31
|
-
dispatch({
|
|
32
|
-
type: 'GET_DATA_ERROR',
|
|
33
|
-
});
|
|
34
|
-
console.error(err);
|
|
35
|
-
toggleNotification({
|
|
36
|
-
type: 'warning',
|
|
37
|
-
message: { id: 'notification.error' },
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
if (!isLoadingForPermissions) {
|
|
44
|
-
getData();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return () => {
|
|
48
|
-
isMounted.current = false;
|
|
49
|
-
};
|
|
50
|
-
}, [isLoadingForPermissions, endPoint, get, toggleNotification]);
|
|
51
|
-
|
|
52
|
-
const dispatchSubmitSucceeded = useCallback((data) => {
|
|
53
|
-
dispatch({
|
|
54
|
-
type: 'ON_SUBMIT_SUCCEEDED',
|
|
55
|
-
data,
|
|
56
|
-
});
|
|
57
|
-
}, []);
|
|
58
|
-
|
|
59
|
-
return {
|
|
60
|
-
allowedActions,
|
|
61
|
-
dispatchSubmitSucceeded,
|
|
62
|
-
isLoading,
|
|
63
|
-
isLoadingForPermissions,
|
|
64
|
-
modifiedData,
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export default useUserForm;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import produce from 'immer';
|
|
2
|
-
|
|
3
|
-
const initialState = {
|
|
4
|
-
isLoading: true,
|
|
5
|
-
modifiedData: {},
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
const reducer = (state, action) =>
|
|
9
|
-
// eslint-disable-next-line consistent-return
|
|
10
|
-
produce(state, (draftState) => {
|
|
11
|
-
switch (action.type) {
|
|
12
|
-
case 'GET_DATA': {
|
|
13
|
-
draftState.isLoading = true;
|
|
14
|
-
draftState.modifiedData = {};
|
|
15
|
-
|
|
16
|
-
break;
|
|
17
|
-
}
|
|
18
|
-
case 'GET_DATA_SUCCEEDED': {
|
|
19
|
-
draftState.isLoading = false;
|
|
20
|
-
draftState.modifiedData = action.data;
|
|
21
|
-
|
|
22
|
-
break;
|
|
23
|
-
}
|
|
24
|
-
case 'GET_DATA_ERROR': {
|
|
25
|
-
draftState.isLoading = true;
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
case 'ON_SUBMIT_SUCCEEDED': {
|
|
29
|
-
draftState.modifiedData = action.data;
|
|
30
|
-
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
default: {
|
|
34
|
-
return draftState;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
export default reducer;
|
|
40
|
-
export { initialState };
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useReducer, useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import { useFetchClient, useNotification } from '@strapi/helper-plugin';
|
|
4
|
-
import get from 'lodash/get';
|
|
5
|
-
|
|
6
|
-
import pluginId from '../../pluginId';
|
|
7
|
-
|
|
8
|
-
import init from './init';
|
|
9
|
-
import reducer, { initialState } from './reducer';
|
|
10
|
-
|
|
11
|
-
const useRolesList = (shouldFetchData = true) => {
|
|
12
|
-
const [{ roles, isLoading }, dispatch] = useReducer(reducer, initialState, () =>
|
|
13
|
-
init(initialState, shouldFetchData)
|
|
14
|
-
);
|
|
15
|
-
const toggleNotification = useNotification();
|
|
16
|
-
|
|
17
|
-
const isMounted = useRef(true);
|
|
18
|
-
const fetchClient = useFetchClient();
|
|
19
|
-
|
|
20
|
-
const fetchRolesList = useCallback(async () => {
|
|
21
|
-
try {
|
|
22
|
-
dispatch({
|
|
23
|
-
type: 'GET_DATA',
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const {
|
|
27
|
-
data: { roles },
|
|
28
|
-
} = await fetchClient.get(`/${pluginId}/roles`);
|
|
29
|
-
|
|
30
|
-
dispatch({
|
|
31
|
-
type: 'GET_DATA_SUCCEEDED',
|
|
32
|
-
data: roles,
|
|
33
|
-
});
|
|
34
|
-
} catch (err) {
|
|
35
|
-
const message = get(err, ['response', 'payload', 'message'], 'An error occured');
|
|
36
|
-
|
|
37
|
-
if (isMounted.current) {
|
|
38
|
-
dispatch({
|
|
39
|
-
type: 'GET_DATA_ERROR',
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
if (message !== 'Forbidden') {
|
|
43
|
-
toggleNotification({
|
|
44
|
-
type: 'warning',
|
|
45
|
-
message,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}, [fetchClient, toggleNotification]);
|
|
51
|
-
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
if (shouldFetchData) {
|
|
54
|
-
fetchRolesList();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return () => {
|
|
58
|
-
isMounted.current = false;
|
|
59
|
-
};
|
|
60
|
-
}, [shouldFetchData, fetchRolesList]);
|
|
61
|
-
|
|
62
|
-
return { roles, isLoading, getData: fetchRolesList };
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export default useRolesList;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/* eslint-disable consistent-return */
|
|
2
|
-
import produce from 'immer';
|
|
3
|
-
|
|
4
|
-
export const initialState = {
|
|
5
|
-
roles: [],
|
|
6
|
-
isLoading: true,
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const reducer = (state, action) =>
|
|
10
|
-
produce(state, (draftState) => {
|
|
11
|
-
switch (action.type) {
|
|
12
|
-
case 'GET_DATA': {
|
|
13
|
-
draftState.isLoading = true;
|
|
14
|
-
draftState.roles = [];
|
|
15
|
-
break;
|
|
16
|
-
}
|
|
17
|
-
case 'GET_DATA_SUCCEEDED': {
|
|
18
|
-
draftState.roles = action.data;
|
|
19
|
-
draftState.isLoading = false;
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
case 'GET_DATA_ERROR': {
|
|
23
|
-
draftState.isLoading = false;
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
default:
|
|
27
|
-
return draftState;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
export default reducer;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { getFetchClient } from '@strapi/helper-plugin';
|
|
2
|
-
|
|
3
|
-
const fetchData = async () => {
|
|
4
|
-
const { get } = getFetchClient();
|
|
5
|
-
const { data } = await get('/users-permissions/advanced');
|
|
6
|
-
|
|
7
|
-
return data;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const putAdvancedSettings = (body) => {
|
|
11
|
-
const { put } = getFetchClient();
|
|
12
|
-
|
|
13
|
-
return put('/users-permissions/advanced', body);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export { fetchData, putAdvancedSettings };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { getFetchClient } from '@strapi/helper-plugin';
|
|
2
|
-
|
|
3
|
-
const fetchData = async () => {
|
|
4
|
-
const { get } = getFetchClient();
|
|
5
|
-
const { data } = await get('/users-permissions/email-templates');
|
|
6
|
-
|
|
7
|
-
return data;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const putEmailTemplate = (body) => {
|
|
11
|
-
const { put } = getFetchClient();
|
|
12
|
-
|
|
13
|
-
return put('/users-permissions/email-templates', body);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export { fetchData, putEmailTemplate };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import produce from 'immer';
|
|
2
|
-
import set from 'lodash/set';
|
|
3
|
-
|
|
4
|
-
const initialState = {
|
|
5
|
-
formErrors: {},
|
|
6
|
-
isLoading: true,
|
|
7
|
-
initialData: {},
|
|
8
|
-
modifiedData: {},
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const reducer = (state, action) =>
|
|
12
|
-
// eslint-disable-next-line consistent-return
|
|
13
|
-
produce(state, (draftState) => {
|
|
14
|
-
switch (action.type) {
|
|
15
|
-
case 'GET_DATA': {
|
|
16
|
-
draftState.isLoading = true;
|
|
17
|
-
draftState.initialData = {};
|
|
18
|
-
draftState.modifiedData = {};
|
|
19
|
-
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
case 'GET_DATA_SUCCEEDED': {
|
|
24
|
-
draftState.isLoading = false;
|
|
25
|
-
draftState.initialData = action.data;
|
|
26
|
-
draftState.modifiedData = action.data;
|
|
27
|
-
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
case 'GET_DATA_ERROR': {
|
|
31
|
-
draftState.isLoading = true;
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
case 'ON_CHANGE': {
|
|
35
|
-
set(draftState, ['modifiedData', ...action.keys.split('.')], action.value);
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
case 'RESET_FORM': {
|
|
39
|
-
draftState.modifiedData = state.initialData;
|
|
40
|
-
draftState.formErrors = {};
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
case 'SET_ERRORS': {
|
|
44
|
-
draftState.formErrors = action.errors;
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
default: {
|
|
48
|
-
return draftState;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
export default reducer;
|
|
54
|
-
export { initialState };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { getFetchClient } from '@strapi/helper-plugin';
|
|
2
|
-
|
|
3
|
-
// eslint-disable-next-line import/prefer-default-export
|
|
4
|
-
export const fetchData = async (toggleNotification) => {
|
|
5
|
-
try {
|
|
6
|
-
const { get } = getFetchClient();
|
|
7
|
-
const { data } = await get('/users-permissions/providers');
|
|
8
|
-
|
|
9
|
-
return data;
|
|
10
|
-
} catch (err) {
|
|
11
|
-
toggleNotification({
|
|
12
|
-
type: 'warning',
|
|
13
|
-
message: { id: 'notification.error' },
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
throw new Error('error');
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const putProvider = (body) => {
|
|
21
|
-
const { put } = getFetchClient();
|
|
22
|
-
|
|
23
|
-
return put('/users-permissions/providers', body);
|
|
24
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import sortBy from 'lodash/sortBy';
|
|
2
|
-
|
|
3
|
-
const createProvidersArray = (data) => {
|
|
4
|
-
return sortBy(
|
|
5
|
-
Object.keys(data).reduce((acc, current) => {
|
|
6
|
-
const { icon: iconName, enabled, subdomain } = data[current];
|
|
7
|
-
const icon = iconName === 'envelope' ? ['fas', 'envelope'] : ['fab', iconName];
|
|
8
|
-
|
|
9
|
-
if (subdomain !== undefined) {
|
|
10
|
-
acc.push({ name: current, icon, enabled, subdomain });
|
|
11
|
-
} else {
|
|
12
|
-
acc.push({ name: current, icon, enabled });
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return acc;
|
|
16
|
-
}, []),
|
|
17
|
-
'name'
|
|
18
|
-
);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default createProvidersArray;
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
Box,
|
|
5
|
-
Button,
|
|
6
|
-
ContentLayout,
|
|
7
|
-
Flex,
|
|
8
|
-
Grid,
|
|
9
|
-
GridItem,
|
|
10
|
-
HeaderLayout,
|
|
11
|
-
Main,
|
|
12
|
-
Textarea,
|
|
13
|
-
TextInput,
|
|
14
|
-
Typography,
|
|
15
|
-
} from '@strapi/design-system';
|
|
16
|
-
import {
|
|
17
|
-
Form,
|
|
18
|
-
SettingsPageTitle,
|
|
19
|
-
useFetchClient,
|
|
20
|
-
useNotification,
|
|
21
|
-
useOverlayBlocker,
|
|
22
|
-
useTracking,
|
|
23
|
-
} from '@strapi/helper-plugin';
|
|
24
|
-
import { Check } from '@strapi/icons';
|
|
25
|
-
import { Formik } from 'formik';
|
|
26
|
-
import { useIntl } from 'react-intl';
|
|
27
|
-
import { useHistory } from 'react-router-dom';
|
|
28
|
-
|
|
29
|
-
import UsersPermissions from '../../components/UsersPermissions';
|
|
30
|
-
import { usePlugins } from '../../hooks';
|
|
31
|
-
import pluginId from '../../pluginId';
|
|
32
|
-
import getTrad from '../../utils/getTrad';
|
|
33
|
-
|
|
34
|
-
import { createRoleSchema } from './constants';
|
|
35
|
-
|
|
36
|
-
const CreatePage = () => {
|
|
37
|
-
const { formatMessage } = useIntl();
|
|
38
|
-
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
39
|
-
const toggleNotification = useNotification();
|
|
40
|
-
const { goBack } = useHistory();
|
|
41
|
-
const { lockApp, unlockApp } = useOverlayBlocker();
|
|
42
|
-
const { isLoading: isLoadingPlugins, permissions, routes } = usePlugins();
|
|
43
|
-
const { trackUsage } = useTracking();
|
|
44
|
-
const permissionsRef = useRef();
|
|
45
|
-
const { post } = useFetchClient();
|
|
46
|
-
|
|
47
|
-
const handleCreateRoleSubmit = async (data) => {
|
|
48
|
-
// Set loading state
|
|
49
|
-
lockApp();
|
|
50
|
-
setIsSubmitting(true);
|
|
51
|
-
try {
|
|
52
|
-
const permissions = permissionsRef.current.getPermissions();
|
|
53
|
-
// Update role in Strapi
|
|
54
|
-
await post(`/${pluginId}/roles`, { ...data, ...permissions, users: [] });
|
|
55
|
-
// Notify success
|
|
56
|
-
trackUsage('didCreateRole');
|
|
57
|
-
toggleNotification({
|
|
58
|
-
type: 'success',
|
|
59
|
-
message: {
|
|
60
|
-
id: getTrad('Settings.roles.created'),
|
|
61
|
-
defaultMessage: 'Role created',
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
// Forcing redirecting since we don't have the id in the response
|
|
65
|
-
goBack();
|
|
66
|
-
} catch (err) {
|
|
67
|
-
console.error(err);
|
|
68
|
-
toggleNotification({
|
|
69
|
-
type: 'warning',
|
|
70
|
-
message: {
|
|
71
|
-
id: 'notification.error',
|
|
72
|
-
defaultMessage: 'An error occurred',
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
// Unset loading state
|
|
77
|
-
setIsSubmitting(false);
|
|
78
|
-
unlockApp();
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
return (
|
|
82
|
-
<Main>
|
|
83
|
-
<SettingsPageTitle name="Roles" />
|
|
84
|
-
<Formik
|
|
85
|
-
enableReinitialize
|
|
86
|
-
initialValues={{ name: '', description: '' }}
|
|
87
|
-
onSubmit={handleCreateRoleSubmit}
|
|
88
|
-
validationSchema={createRoleSchema}
|
|
89
|
-
>
|
|
90
|
-
{({ handleSubmit, values, handleChange, errors }) => (
|
|
91
|
-
<Form noValidate onSubmit={handleSubmit}>
|
|
92
|
-
<HeaderLayout
|
|
93
|
-
primaryAction={
|
|
94
|
-
!isLoadingPlugins && (
|
|
95
|
-
<Button type="submit" loading={isSubmitting} startIcon={<Check />}>
|
|
96
|
-
{formatMessage({
|
|
97
|
-
id: 'global.save',
|
|
98
|
-
defaultMessage: 'Save',
|
|
99
|
-
})}
|
|
100
|
-
</Button>
|
|
101
|
-
)
|
|
102
|
-
}
|
|
103
|
-
title={formatMessage({
|
|
104
|
-
id: 'Settings.roles.create.title',
|
|
105
|
-
defaultMessage: 'Create a role',
|
|
106
|
-
})}
|
|
107
|
-
subtitle={formatMessage({
|
|
108
|
-
id: 'Settings.roles.create.description',
|
|
109
|
-
defaultMessage: 'Define the rights given to the role',
|
|
110
|
-
})}
|
|
111
|
-
/>
|
|
112
|
-
<ContentLayout>
|
|
113
|
-
<Flex direction="column" alignItems="stretch" gap={7}>
|
|
114
|
-
<Box
|
|
115
|
-
background="neutral0"
|
|
116
|
-
hasRadius
|
|
117
|
-
shadow="filterShadow"
|
|
118
|
-
paddingTop={6}
|
|
119
|
-
paddingBottom={6}
|
|
120
|
-
paddingLeft={7}
|
|
121
|
-
paddingRight={7}
|
|
122
|
-
>
|
|
123
|
-
<Flex direction="column" alignItems="stretch" gap={4}>
|
|
124
|
-
<Typography variant="delta" as="h2">
|
|
125
|
-
{formatMessage({
|
|
126
|
-
id: getTrad('EditPage.form.roles'),
|
|
127
|
-
defaultMessage: 'Role details',
|
|
128
|
-
})}
|
|
129
|
-
</Typography>
|
|
130
|
-
<Grid gap={4}>
|
|
131
|
-
<GridItem col={6}>
|
|
132
|
-
<TextInput
|
|
133
|
-
name="name"
|
|
134
|
-
value={values.name || ''}
|
|
135
|
-
onChange={handleChange}
|
|
136
|
-
label={formatMessage({
|
|
137
|
-
id: 'global.name',
|
|
138
|
-
defaultMessage: 'Name',
|
|
139
|
-
})}
|
|
140
|
-
error={
|
|
141
|
-
errors.name
|
|
142
|
-
? formatMessage({ id: errors.name, defaultMessage: 'Invalid value' })
|
|
143
|
-
: null
|
|
144
|
-
}
|
|
145
|
-
/>
|
|
146
|
-
</GridItem>
|
|
147
|
-
<GridItem col={6}>
|
|
148
|
-
<Textarea
|
|
149
|
-
id="description"
|
|
150
|
-
value={values.description || ''}
|
|
151
|
-
onChange={handleChange}
|
|
152
|
-
label={formatMessage({
|
|
153
|
-
id: 'global.description',
|
|
154
|
-
defaultMessage: 'Description',
|
|
155
|
-
})}
|
|
156
|
-
error={
|
|
157
|
-
errors.description
|
|
158
|
-
? formatMessage({
|
|
159
|
-
id: errors.description,
|
|
160
|
-
defaultMessage: 'Invalid value',
|
|
161
|
-
})
|
|
162
|
-
: null
|
|
163
|
-
}
|
|
164
|
-
/>
|
|
165
|
-
</GridItem>
|
|
166
|
-
</Grid>
|
|
167
|
-
</Flex>
|
|
168
|
-
</Box>
|
|
169
|
-
{!isLoadingPlugins && (
|
|
170
|
-
<UsersPermissions
|
|
171
|
-
ref={permissionsRef}
|
|
172
|
-
permissions={permissions}
|
|
173
|
-
routes={routes}
|
|
174
|
-
/>
|
|
175
|
-
)}
|
|
176
|
-
</Flex>
|
|
177
|
-
</ContentLayout>
|
|
178
|
-
</Form>
|
|
179
|
-
)}
|
|
180
|
-
</Formik>
|
|
181
|
-
</Main>
|
|
182
|
-
);
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
export default CreatePage;
|