@akemona-org/strapi-plugin-users-permissions 3.7.0
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/LICENSE +22 -0
- package/README.md +19 -0
- package/admin/src/assets/images/logo.svg +1 -0
- package/admin/src/components/BaselineAlignement/index.js +33 -0
- package/admin/src/components/Bloc/index.js +10 -0
- package/admin/src/components/BoundRoute/Components.js +78 -0
- package/admin/src/components/BoundRoute/index.js +56 -0
- package/admin/src/components/ContainerFluid/index.js +13 -0
- package/admin/src/components/FormBloc/index.js +61 -0
- package/admin/src/components/IntlInput/index.js +38 -0
- package/admin/src/components/ListBaselineAlignment/index.js +8 -0
- package/admin/src/components/ListRow/Components.js +74 -0
- package/admin/src/components/ListRow/index.js +35 -0
- package/admin/src/components/ModalForm/Wrapper.js +12 -0
- package/admin/src/components/ModalForm/index.js +59 -0
- package/admin/src/components/Permissions/ListWrapper.js +9 -0
- package/admin/src/components/Permissions/PermissionRow/BaselineAlignment.js +7 -0
- package/admin/src/components/Permissions/PermissionRow/CheckboxWrapper.js +37 -0
- package/admin/src/components/Permissions/PermissionRow/RowStyle.js +28 -0
- package/admin/src/components/Permissions/PermissionRow/SubCategory/ConditionsButtonWrapper.js +13 -0
- package/admin/src/components/Permissions/PermissionRow/SubCategory/PolicyWrapper.js +8 -0
- package/admin/src/components/Permissions/PermissionRow/SubCategory/SubCategoryWrapper.js +26 -0
- package/admin/src/components/Permissions/PermissionRow/SubCategory/index.js +116 -0
- package/admin/src/components/Permissions/PermissionRow/index.js +92 -0
- package/admin/src/components/Permissions/index.js +44 -0
- package/admin/src/components/Permissions/init.js +14 -0
- package/admin/src/components/Permissions/reducer.js +27 -0
- package/admin/src/components/Policies/Components.js +26 -0
- package/admin/src/components/Policies/index.js +61 -0
- package/admin/src/components/PrefixedIcon/index.js +27 -0
- package/admin/src/components/Roles/EmptyRole/BaselineAlignment.js +7 -0
- package/admin/src/components/Roles/EmptyRole/index.js +27 -0
- package/admin/src/components/Roles/RoleListWrapper/index.js +17 -0
- package/admin/src/components/Roles/RoleRow/RoleDescription.js +9 -0
- package/admin/src/components/Roles/RoleRow/index.js +45 -0
- package/admin/src/components/Roles/index.js +3 -0
- package/admin/src/components/SizedInput/index.js +24 -0
- package/admin/src/components/UsersPermissions/index.js +91 -0
- package/admin/src/components/UsersPermissions/init.js +11 -0
- package/admin/src/components/UsersPermissions/reducer.js +60 -0
- package/admin/src/containers/AdvancedSettings/index.js +218 -0
- package/admin/src/containers/AdvancedSettings/reducer.js +65 -0
- package/admin/src/containers/AdvancedSettings/utils/form.js +52 -0
- package/admin/src/containers/EmailTemplates/CustomTextInput.js +105 -0
- package/admin/src/containers/EmailTemplates/Wrapper.js +36 -0
- package/admin/src/containers/EmailTemplates/index.js +222 -0
- package/admin/src/containers/EmailTemplates/reducer.js +58 -0
- package/admin/src/containers/EmailTemplates/utils/forms.js +81 -0
- package/admin/src/containers/EmailTemplates/utils/schema.js +25 -0
- package/admin/src/containers/Providers/index.js +283 -0
- package/admin/src/containers/Providers/reducer.js +54 -0
- package/admin/src/containers/Providers/utils/createProvidersArray.js +21 -0
- package/admin/src/containers/Providers/utils/forms.js +205 -0
- package/admin/src/containers/Roles/CreatePage/index.js +167 -0
- package/admin/src/containers/Roles/CreatePage/utils/schema.js +9 -0
- package/admin/src/containers/Roles/EditPage/index.js +161 -0
- package/admin/src/containers/Roles/EditPage/utils/schema.js +9 -0
- package/admin/src/containers/Roles/ListPage/BaselineAlignment.js +8 -0
- package/admin/src/containers/Roles/ListPage/index.js +188 -0
- package/admin/src/containers/Roles/ProtectedCreatePage/index.js +12 -0
- package/admin/src/containers/Roles/ProtectedEditPage/index.js +12 -0
- package/admin/src/containers/Roles/ProtectedListPage/index.js +15 -0
- package/admin/src/containers/Roles/index.js +35 -0
- package/admin/src/contexts/EditPage/index.js +26 -0
- package/admin/src/contexts/HomePage/index.js +27 -0
- package/admin/src/contexts/UsersPermissionsContext/index.js +17 -0
- package/admin/src/hooks/index.js +5 -0
- package/admin/src/hooks/useFetchRole/index.js +55 -0
- package/admin/src/hooks/useFetchRole/reducer.js +31 -0
- package/admin/src/hooks/useForm/index.js +96 -0
- package/admin/src/hooks/useForm/reducer.js +59 -0
- package/admin/src/hooks/usePlugins/index.js +73 -0
- package/admin/src/hooks/usePlugins/init.js +5 -0
- package/admin/src/hooks/usePlugins/reducer.js +37 -0
- package/admin/src/hooks/useRolesList/index.js +62 -0
- package/admin/src/hooks/useRolesList/init.js +5 -0
- package/admin/src/hooks/useRolesList/reducer.js +31 -0
- package/admin/src/index.js +109 -0
- package/admin/src/permissions.js +33 -0
- package/admin/src/pluginId.js +5 -0
- package/admin/src/translations/ar.json +49 -0
- package/admin/src/translations/cs.json +55 -0
- package/admin/src/translations/de.json +68 -0
- package/admin/src/translations/dk.json +116 -0
- package/admin/src/translations/en.json +104 -0
- package/admin/src/translations/es.json +70 -0
- package/admin/src/translations/fr.json +55 -0
- package/admin/src/translations/id.json +69 -0
- package/admin/src/translations/index.js +55 -0
- package/admin/src/translations/it.json +68 -0
- package/admin/src/translations/ja.json +53 -0
- package/admin/src/translations/ko.json +55 -0
- package/admin/src/translations/ms.json +54 -0
- package/admin/src/translations/nl.json +53 -0
- package/admin/src/translations/pl.json +55 -0
- package/admin/src/translations/pt-BR.json +49 -0
- package/admin/src/translations/pt.json +53 -0
- package/admin/src/translations/ru.json +68 -0
- package/admin/src/translations/sk.json +57 -0
- package/admin/src/translations/sv.json +68 -0
- package/admin/src/translations/th.json +66 -0
- package/admin/src/translations/tr.json +53 -0
- package/admin/src/translations/uk.json +54 -0
- package/admin/src/translations/vi.json +55 -0
- package/admin/src/translations/zh-Hans.json +104 -0
- package/admin/src/translations/zh.json +53 -0
- package/admin/src/utils/cleanPermissions.js +25 -0
- package/admin/src/utils/formatPolicies.js +8 -0
- package/admin/src/utils/getRequestURL.js +5 -0
- package/admin/src/utils/getTrad.js +5 -0
- package/admin/src/utils/index.js +4 -0
- package/config/functions/bootstrap.js +234 -0
- package/config/layout.js +10 -0
- package/config/policies/isAuthenticated.js +9 -0
- package/config/policies/permissions.js +93 -0
- package/config/policies/rateLimit.js +33 -0
- package/config/request.json +6 -0
- package/config/routes.json +397 -0
- package/config/schema.graphql.js +280 -0
- package/config/security.json +5 -0
- package/config/users-permissions-actions.js +80 -0
- package/controllers/Auth.js +612 -0
- package/controllers/User.js +125 -0
- package/controllers/UsersPermissions.js +291 -0
- package/controllers/user/admin.js +224 -0
- package/controllers/user/api.js +173 -0
- package/controllers/validation/email-template.js +40 -0
- package/documentation/1.0.0/overrides/users-permissions-Role.json +281 -0
- package/documentation/1.0.0/overrides/users-permissions-User.json +325 -0
- package/middlewares/users-permissions/defaults.json +5 -0
- package/middlewares/users-permissions/index.js +40 -0
- package/models/Permission.js +7 -0
- package/models/Permission.settings.json +43 -0
- package/models/Role.js +7 -0
- package/models/Role.settings.json +42 -0
- package/models/User.config.js +15 -0
- package/models/User.js +7 -0
- package/models/User.settings.json +62 -0
- package/package.json +70 -0
- package/services/Jwt.js +65 -0
- package/services/Providers.js +596 -0
- package/services/User.js +167 -0
- package/services/UsersPermissions.js +416 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* eslint-disable consistent-return */
|
|
2
|
+
import produce from 'immer';
|
|
3
|
+
import { set, get, take } from 'lodash';
|
|
4
|
+
|
|
5
|
+
export const initialState = {
|
|
6
|
+
initialData: {},
|
|
7
|
+
modifiedData: {},
|
|
8
|
+
routes: {},
|
|
9
|
+
selectedAction: '',
|
|
10
|
+
policies: [],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const reducer = (state, action) =>
|
|
14
|
+
produce(state, draftState => {
|
|
15
|
+
switch (action.type) {
|
|
16
|
+
case 'ON_CHANGE': {
|
|
17
|
+
const keysLength = action.keys.length;
|
|
18
|
+
const isChangingCheckbox = action.keys[keysLength - 1] === 'enabled';
|
|
19
|
+
|
|
20
|
+
if (action.value && isChangingCheckbox) {
|
|
21
|
+
const selectedAction = take(action.keys, keysLength - 1).join('.');
|
|
22
|
+
draftState.selectedAction = selectedAction;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
set(draftState, ['modifiedData', ...action.keys], action.value);
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
case 'ON_CHANGE_SELECT_ALL': {
|
|
29
|
+
const pathToValue = ['modifiedData', ...action.keys];
|
|
30
|
+
const oldValues = get(state, pathToValue, {});
|
|
31
|
+
const updatedValues = Object.keys(oldValues).reduce((acc, current) => {
|
|
32
|
+
acc[current] = { ...oldValues[current], enabled: action.value };
|
|
33
|
+
|
|
34
|
+
return acc;
|
|
35
|
+
}, {});
|
|
36
|
+
|
|
37
|
+
set(draftState, pathToValue, updatedValues);
|
|
38
|
+
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
case 'ON_RESET': {
|
|
42
|
+
draftState.modifiedData = state.initialData;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
case 'ON_SUBMIT_SUCCEEDED': {
|
|
46
|
+
draftState.initialData = state.modifiedData;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
case 'SELECT_ACTION': {
|
|
51
|
+
const { actionToSelect } = action;
|
|
52
|
+
draftState.selectedAction = actionToSelect === state.selectedAction ? '' : actionToSelect;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
default:
|
|
56
|
+
return draftState;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export default reducer;
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { Header } from '@buffetjs/custom';
|
|
4
|
+
import { isEqual } from 'lodash';
|
|
5
|
+
import {
|
|
6
|
+
FormBloc,
|
|
7
|
+
PopUpWarning,
|
|
8
|
+
SettingsPageTitle,
|
|
9
|
+
SizedInput,
|
|
10
|
+
useUserPermissions,
|
|
11
|
+
request,
|
|
12
|
+
} from 'strapi-helper-plugin';
|
|
13
|
+
import pluginPermissions from '../../permissions';
|
|
14
|
+
import { getTrad, getRequestURL } from '../../utils';
|
|
15
|
+
import ListBaselineAlignment from '../../components/ListBaselineAlignment';
|
|
16
|
+
import form from './utils/form';
|
|
17
|
+
import reducer, { initialState } from './reducer';
|
|
18
|
+
|
|
19
|
+
const AdvancedSettingsPage = () => {
|
|
20
|
+
const { formatMessage } = useIntl();
|
|
21
|
+
const [showModalWarning, setShowModalWarning] = useState(false);
|
|
22
|
+
const pageTitle = formatMessage({
|
|
23
|
+
id: getTrad('HeaderNav.link.advancedSettings'),
|
|
24
|
+
defaultMessage: 'Advanced Settings',
|
|
25
|
+
});
|
|
26
|
+
const formTitle = formatMessage({
|
|
27
|
+
id: getTrad('Settings.advancedSettings.title'),
|
|
28
|
+
defaultMessage: 'Settings',
|
|
29
|
+
});
|
|
30
|
+
const updatePermissions = useMemo(() => {
|
|
31
|
+
return { update: pluginPermissions.updateAdvancedSettings };
|
|
32
|
+
}, []);
|
|
33
|
+
const {
|
|
34
|
+
isLoading: isLoadingForPermissions,
|
|
35
|
+
allowedActions: { canUpdate },
|
|
36
|
+
} = useUserPermissions(updatePermissions);
|
|
37
|
+
const [
|
|
38
|
+
{ initialData, isConfirmButtonLoading, isLoading, modifiedData, roles },
|
|
39
|
+
dispatch,
|
|
40
|
+
] = useReducer(reducer, initialState);
|
|
41
|
+
const isMounted = useRef(true);
|
|
42
|
+
const abortController = new AbortController();
|
|
43
|
+
const { signal } = abortController;
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
const getData = async () => {
|
|
47
|
+
try {
|
|
48
|
+
dispatch({
|
|
49
|
+
type: 'GET_DATA',
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const data = await request(getRequestURL('advanced'), { method: 'GET', signal });
|
|
53
|
+
|
|
54
|
+
dispatch({
|
|
55
|
+
type: 'GET_DATA_SUCCEEDED',
|
|
56
|
+
data,
|
|
57
|
+
});
|
|
58
|
+
} catch (err) {
|
|
59
|
+
if (isMounted.current) {
|
|
60
|
+
dispatch({
|
|
61
|
+
type: 'GET_DATA_ERROR',
|
|
62
|
+
});
|
|
63
|
+
console.error(err);
|
|
64
|
+
strapi.notification.toggle({
|
|
65
|
+
type: 'warning',
|
|
66
|
+
message: { id: 'notification.error' },
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
if (!isLoadingForPermissions) {
|
|
73
|
+
getData();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return () => {
|
|
77
|
+
abortController.abort();
|
|
78
|
+
isMounted.current = false;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
82
|
+
}, [isLoadingForPermissions]);
|
|
83
|
+
|
|
84
|
+
const handleChange = useCallback(({ target }) => {
|
|
85
|
+
dispatch({
|
|
86
|
+
type: 'ON_CHANGE',
|
|
87
|
+
keys: target.name,
|
|
88
|
+
value: target.value,
|
|
89
|
+
});
|
|
90
|
+
}, []);
|
|
91
|
+
|
|
92
|
+
const handleSubmit = useCallback(
|
|
93
|
+
async e => {
|
|
94
|
+
e.preventDefault();
|
|
95
|
+
|
|
96
|
+
try {
|
|
97
|
+
dispatch({
|
|
98
|
+
type: 'ON_SUBMIT',
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
strapi.lockAppWithOverlay();
|
|
102
|
+
await request(getRequestURL('advanced'), { method: 'PUT', body: modifiedData });
|
|
103
|
+
|
|
104
|
+
dispatch({
|
|
105
|
+
type: 'ON_SUBMIT_SUCCEEDED',
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
strapi.notification.toggle({
|
|
109
|
+
type: 'success',
|
|
110
|
+
message: { id: getTrad('notification.success.submit') },
|
|
111
|
+
});
|
|
112
|
+
} catch (err) {
|
|
113
|
+
dispatch({
|
|
114
|
+
type: 'ON_SUBMIT_ERROR',
|
|
115
|
+
});
|
|
116
|
+
console.error(err);
|
|
117
|
+
strapi.notification.toggle({
|
|
118
|
+
type: 'warning',
|
|
119
|
+
message: { id: 'notification.error' },
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
strapi.unlockApp();
|
|
124
|
+
},
|
|
125
|
+
[modifiedData]
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
const handleConfirmReset = useCallback(() => {
|
|
129
|
+
dispatch({
|
|
130
|
+
type: 'ON_RESET',
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
setShowModalWarning(false);
|
|
134
|
+
}, []);
|
|
135
|
+
|
|
136
|
+
const handleToggleModal = useCallback(() => {
|
|
137
|
+
setShowModalWarning(prev => !prev);
|
|
138
|
+
}, []);
|
|
139
|
+
|
|
140
|
+
const headerActions = useMemo(() => {
|
|
141
|
+
const isDisabled = isEqual(initialData, modifiedData);
|
|
142
|
+
|
|
143
|
+
return [
|
|
144
|
+
{
|
|
145
|
+
disabled: isDisabled,
|
|
146
|
+
onClick: () => {
|
|
147
|
+
handleToggleModal();
|
|
148
|
+
},
|
|
149
|
+
color: 'cancel',
|
|
150
|
+
label: formatMessage({
|
|
151
|
+
id: 'app.components.Button.reset',
|
|
152
|
+
}),
|
|
153
|
+
|
|
154
|
+
type: 'button',
|
|
155
|
+
style: {
|
|
156
|
+
paddingLeft: 15,
|
|
157
|
+
paddingRight: 15,
|
|
158
|
+
fontWeight: 600,
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
disabled: isDisabled,
|
|
163
|
+
color: 'success',
|
|
164
|
+
label: formatMessage({
|
|
165
|
+
id: 'app.components.Button.save',
|
|
166
|
+
}),
|
|
167
|
+
isLoading: isConfirmButtonLoading,
|
|
168
|
+
type: 'submit',
|
|
169
|
+
style: {
|
|
170
|
+
minWidth: 150,
|
|
171
|
+
fontWeight: 600,
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
];
|
|
175
|
+
}, [initialData, isConfirmButtonLoading, modifiedData, formatMessage, handleToggleModal]);
|
|
176
|
+
|
|
177
|
+
const showLoader = isLoadingForPermissions || isLoading;
|
|
178
|
+
|
|
179
|
+
return (
|
|
180
|
+
<>
|
|
181
|
+
<SettingsPageTitle name={pageTitle} />
|
|
182
|
+
<div>
|
|
183
|
+
<form onSubmit={handleSubmit}>
|
|
184
|
+
<Header actions={headerActions} title={{ label: pageTitle }} isLoading={showLoader} />
|
|
185
|
+
<ListBaselineAlignment />
|
|
186
|
+
<FormBloc title={formTitle} isLoading={showLoader}>
|
|
187
|
+
{form.map(input => {
|
|
188
|
+
return (
|
|
189
|
+
<SizedInput
|
|
190
|
+
key={input.name}
|
|
191
|
+
{...input}
|
|
192
|
+
disabled={!canUpdate}
|
|
193
|
+
onChange={handleChange}
|
|
194
|
+
options={roles}
|
|
195
|
+
value={modifiedData[input.name]}
|
|
196
|
+
/>
|
|
197
|
+
);
|
|
198
|
+
})}
|
|
199
|
+
</FormBloc>
|
|
200
|
+
</form>
|
|
201
|
+
</div>
|
|
202
|
+
<PopUpWarning
|
|
203
|
+
isOpen={showModalWarning}
|
|
204
|
+
toggleModal={handleToggleModal}
|
|
205
|
+
content={{
|
|
206
|
+
title: getTrad('popUpWarning.title'),
|
|
207
|
+
message: getTrad('popUpWarning.warning.cancel'),
|
|
208
|
+
cancel: getTrad('popUpWarning.button.cancel'),
|
|
209
|
+
confirm: getTrad('popUpWarning.button.confirm'),
|
|
210
|
+
}}
|
|
211
|
+
popUpWarningType="danger"
|
|
212
|
+
onConfirm={handleConfirmReset}
|
|
213
|
+
/>
|
|
214
|
+
</>
|
|
215
|
+
);
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
export default AdvancedSettingsPage;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import produce from 'immer';
|
|
2
|
+
import { set } from 'lodash';
|
|
3
|
+
|
|
4
|
+
const initialState = {
|
|
5
|
+
isLoading: true,
|
|
6
|
+
isConfirmButtonLoading: false,
|
|
7
|
+
initialData: {},
|
|
8
|
+
modifiedData: {},
|
|
9
|
+
roles: [],
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const reducer = (state, action) =>
|
|
13
|
+
// eslint-disable-next-line consistent-return
|
|
14
|
+
produce(state, draftState => {
|
|
15
|
+
switch (action.type) {
|
|
16
|
+
case 'GET_DATA': {
|
|
17
|
+
draftState.isLoading = true;
|
|
18
|
+
draftState.isConfirmButtonLoading = false;
|
|
19
|
+
draftState.initialData = {};
|
|
20
|
+
draftState.modifiedData = {};
|
|
21
|
+
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
case 'GET_DATA_SUCCEEDED': {
|
|
26
|
+
draftState.isLoading = false;
|
|
27
|
+
draftState.initialData = action.data.settings;
|
|
28
|
+
draftState.modifiedData = action.data.settings;
|
|
29
|
+
draftState.roles = action.data.roles.map(role => ({ label: role.name, value: role.type }));
|
|
30
|
+
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
case 'GET_DATA_ERROR': {
|
|
34
|
+
draftState.isLoading = true;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
case 'ON_CHANGE': {
|
|
38
|
+
set(draftState.modifiedData, action.keys.split('.'), action.value);
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
case 'ON_RESET': {
|
|
42
|
+
draftState.modifiedData = state.initialData;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
case 'ON_SUBMIT': {
|
|
46
|
+
draftState.isConfirmButtonLoading = true;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
case 'ON_SUBMIT_SUCCEEDED': {
|
|
50
|
+
draftState.initialData = state.modifiedData;
|
|
51
|
+
draftState.isConfirmButtonLoading = false;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
case 'ON_SUBMIT_ERROR': {
|
|
55
|
+
draftState.isConfirmButtonLoading = false;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
default: {
|
|
59
|
+
return draftState;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export default reducer;
|
|
65
|
+
export { initialState };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { getTrad } from '../../../utils';
|
|
2
|
+
|
|
3
|
+
const form = [
|
|
4
|
+
{
|
|
5
|
+
autoFocus: true,
|
|
6
|
+
description: getTrad('EditForm.inputSelect.description.role'),
|
|
7
|
+
label: getTrad('EditForm.inputSelect.label.role'),
|
|
8
|
+
name: 'default_role',
|
|
9
|
+
type: 'select',
|
|
10
|
+
size: { xs: 6 },
|
|
11
|
+
options: [],
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
description: getTrad('EditForm.inputToggle.description.email'),
|
|
15
|
+
label: getTrad('EditForm.inputToggle.label.email'),
|
|
16
|
+
name: 'unique_email',
|
|
17
|
+
type: 'bool',
|
|
18
|
+
size: { xs: 12 },
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
description: getTrad('EditForm.inputToggle.description.sign-up'),
|
|
22
|
+
label: getTrad('EditForm.inputToggle.label.sign-up'),
|
|
23
|
+
name: 'allow_register',
|
|
24
|
+
type: 'bool',
|
|
25
|
+
size: { xs: 12 },
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
description: getTrad('EditForm.inputToggle.description.email-reset-password'),
|
|
29
|
+
label: getTrad('EditForm.inputToggle.label.email-reset-password'),
|
|
30
|
+
name: 'email_reset_password',
|
|
31
|
+
type: 'text',
|
|
32
|
+
size: { xs: 6 },
|
|
33
|
+
placeholder: getTrad('EditForm.inputToggle.placeholder.email-reset-password'),
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
description: getTrad('EditForm.inputToggle.description.email-confirmation'),
|
|
37
|
+
label: getTrad('EditForm.inputToggle.label.email-confirmation'),
|
|
38
|
+
name: 'email_confirmation',
|
|
39
|
+
type: 'bool',
|
|
40
|
+
size: { xs: 12 },
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
description: getTrad('EditForm.inputToggle.description.email-confirmation-redirection'),
|
|
44
|
+
label: getTrad('EditForm.inputToggle.label.email-confirmation-redirection'),
|
|
45
|
+
name: 'email_confirmation_redirection',
|
|
46
|
+
type: 'text',
|
|
47
|
+
size: { xs: 6 },
|
|
48
|
+
placeholder: getTrad('EditForm.inputToggle.placeholder.email-confirmation-redirection'),
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
export default form;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* The input is made so we can handle a custom descritption
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import { Error, Label, InputText } from '@buffetjs/core';
|
|
10
|
+
import { FormattedMessage } from 'react-intl';
|
|
11
|
+
import { Description, ErrorMessage } from '@buffetjs/styles';
|
|
12
|
+
import { getTrad } from '../../utils';
|
|
13
|
+
import Wrapper from './Wrapper';
|
|
14
|
+
|
|
15
|
+
const CustomTextInput = ({
|
|
16
|
+
description,
|
|
17
|
+
error: inputError,
|
|
18
|
+
label,
|
|
19
|
+
name,
|
|
20
|
+
onChange,
|
|
21
|
+
validations,
|
|
22
|
+
value,
|
|
23
|
+
...rest
|
|
24
|
+
}) => {
|
|
25
|
+
const inputId = name;
|
|
26
|
+
const descriptionId = `description-${inputId}`;
|
|
27
|
+
const errorId = `error-${inputId}`;
|
|
28
|
+
|
|
29
|
+
const link = (
|
|
30
|
+
<a
|
|
31
|
+
href="https://strapi.akemona.com/documentation/developer-docs/latest/development/plugins/users-permissions.html#templating-emails"
|
|
32
|
+
target="_blank"
|
|
33
|
+
rel="noopener noreferrer"
|
|
34
|
+
>
|
|
35
|
+
<FormattedMessage id="users-permissions.PopUpForm.Email.link.documentation" />
|
|
36
|
+
</a>
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const descriptionCompo = (
|
|
40
|
+
<Description id={descriptionId}>
|
|
41
|
+
<FormattedMessage
|
|
42
|
+
id={getTrad('PopUpForm.Email.email_templates.inputDescription')}
|
|
43
|
+
values={{ link }}
|
|
44
|
+
/>
|
|
45
|
+
</Description>
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<Error inputError={inputError} name={name} type="text" validations={validations}>
|
|
50
|
+
{({ canCheck, onBlur, error, dispatch }) => (
|
|
51
|
+
<Wrapper error={error}>
|
|
52
|
+
<Label htmlFor={inputId}>{label}</Label>
|
|
53
|
+
<InputText
|
|
54
|
+
{...rest}
|
|
55
|
+
name={name}
|
|
56
|
+
id={inputId}
|
|
57
|
+
aria-invalid={error ? 'true' : 'false'}
|
|
58
|
+
onBlur={onBlur}
|
|
59
|
+
onChange={e => {
|
|
60
|
+
if (!canCheck) {
|
|
61
|
+
dispatch({
|
|
62
|
+
type: 'SET_CHECK',
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
dispatch({
|
|
67
|
+
type: 'SET_ERROR',
|
|
68
|
+
error: null,
|
|
69
|
+
});
|
|
70
|
+
onChange(e);
|
|
71
|
+
}}
|
|
72
|
+
value={value}
|
|
73
|
+
/>
|
|
74
|
+
{!error ? descriptionCompo : <ErrorMessage id={errorId}>{error}</ErrorMessage>}
|
|
75
|
+
</Wrapper>
|
|
76
|
+
)}
|
|
77
|
+
</Error>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
CustomTextInput.defaultProps = {
|
|
82
|
+
description: null,
|
|
83
|
+
id: null,
|
|
84
|
+
error: null,
|
|
85
|
+
label: null,
|
|
86
|
+
onBlur: null,
|
|
87
|
+
onChange: () => {},
|
|
88
|
+
validations: {},
|
|
89
|
+
value: '',
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
CustomTextInput.propTypes = {
|
|
93
|
+
description: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
94
|
+
error: PropTypes.string,
|
|
95
|
+
id: PropTypes.string,
|
|
96
|
+
label: PropTypes.string,
|
|
97
|
+
name: PropTypes.string.isRequired,
|
|
98
|
+
onBlur: PropTypes.func,
|
|
99
|
+
onChange: () => {},
|
|
100
|
+
|
|
101
|
+
validations: PropTypes.object,
|
|
102
|
+
value: PropTypes.any,
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export default CustomTextInput;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
import { colors, sizes } from '@buffetjs/styles';
|
|
3
|
+
|
|
4
|
+
/* eslint-disable indent */
|
|
5
|
+
const Wrapper = styled.div`
|
|
6
|
+
position: relative;
|
|
7
|
+
padding-bottom: ${sizes.margin * 2.7}px;
|
|
8
|
+
label {
|
|
9
|
+
display: block;
|
|
10
|
+
margin-bottom: 1rem;
|
|
11
|
+
}
|
|
12
|
+
> p {
|
|
13
|
+
width: 100%;
|
|
14
|
+
padding-top: 10px;
|
|
15
|
+
font-size: 13px;
|
|
16
|
+
line-height: normal;
|
|
17
|
+
white-space: nowrap;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
text-overflow: ellipsis;
|
|
20
|
+
margin-bottom: -8px;
|
|
21
|
+
}
|
|
22
|
+
input[type='checkbox'] {
|
|
23
|
+
margin-bottom: 13px;
|
|
24
|
+
}
|
|
25
|
+
${({ error }) =>
|
|
26
|
+
!!error &&
|
|
27
|
+
css`
|
|
28
|
+
input,
|
|
29
|
+
textarea,
|
|
30
|
+
select {
|
|
31
|
+
border-color: ${colors.darkOrange};
|
|
32
|
+
}
|
|
33
|
+
`}
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
export default Wrapper;
|