@strapi/plugin-documentation 4.12.0-beta.1 → 4.12.0-beta.4
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/hooks/useDocumentation.js +77 -0
- package/admin/src/index.js +2 -2
- package/admin/src/pages/PluginPage/index.js +59 -49
- package/admin/src/pages/PluginPage/tests/index.test.js +152 -807
- package/admin/src/pages/SettingsPage/index.js +36 -15
- package/admin/src/pages/SettingsPage/tests/index.test.js +86 -587
- package/jest.config.front.js +1 -0
- package/package.json +6 -12
- package/tests/server.js +37 -0
- package/tests/setup.js +15 -0
- package/admin/src/components/FieldActionWrapper/index.js +0 -14
- package/admin/src/components/PluginIcon/index.js +0 -13
- package/admin/src/pages/PluginPage/tests/server.js +0 -23
- package/admin/src/pages/SettingsPage/tests/server.js +0 -18
- package/admin/src/pages/utils/schema.js +0 -11
- package/admin/src/pages/utils/useReactQuery.js +0 -67
- package/admin/src/utils/openWithNewTab.js +0 -19
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
|
|
3
|
-
// Strapi Parts
|
|
4
3
|
import {
|
|
5
4
|
Box,
|
|
6
5
|
Button,
|
|
@@ -13,32 +12,42 @@ import {
|
|
|
13
12
|
TextInput,
|
|
14
13
|
ToggleInput,
|
|
15
14
|
Typography,
|
|
15
|
+
FieldAction,
|
|
16
16
|
} from '@strapi/design-system';
|
|
17
17
|
import {
|
|
18
|
-
CheckPermissions,
|
|
19
18
|
Form,
|
|
20
19
|
LoadingIndicatorPage,
|
|
21
20
|
useFocusWhenNavigate,
|
|
21
|
+
translatedErrors,
|
|
22
|
+
useRBAC,
|
|
22
23
|
} from '@strapi/helper-plugin';
|
|
23
24
|
// Strapi Icons
|
|
24
25
|
import { Check, Eye as Show, EyeStriked as Hide } from '@strapi/icons';
|
|
25
26
|
import { Formik } from 'formik';
|
|
26
27
|
import { useIntl } from 'react-intl';
|
|
28
|
+
import styled from 'styled-components';
|
|
29
|
+
import * as yup from 'yup';
|
|
27
30
|
|
|
28
|
-
import FieldActionWrapper from '../../components/FieldActionWrapper';
|
|
29
31
|
import { PERMISSIONS } from '../../constants';
|
|
32
|
+
import { useDocumentation } from '../../hooks/useDocumentation';
|
|
30
33
|
import { getTrad } from '../../utils';
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
|
|
35
|
+
const schema = yup.object().shape({
|
|
36
|
+
restrictedAccess: yup.boolean(),
|
|
37
|
+
password: yup.string().when('restrictedAccess', (value, initSchema) => {
|
|
38
|
+
return value ? initSchema.required(translatedErrors.required) : initSchema;
|
|
39
|
+
}),
|
|
40
|
+
});
|
|
33
41
|
|
|
34
42
|
const SettingsPage = () => {
|
|
35
43
|
useFocusWhenNavigate();
|
|
36
44
|
const { formatMessage } = useIntl();
|
|
37
|
-
const {
|
|
45
|
+
const { submit, data, isLoading } = useDocumentation();
|
|
38
46
|
const [passwordShown, setPasswordShown] = useState(false);
|
|
47
|
+
const { allowedActions } = useRBAC(PERMISSIONS);
|
|
39
48
|
|
|
40
49
|
const handleUpdateSettingsSubmit = (body) => {
|
|
41
|
-
|
|
50
|
+
submit.mutate({
|
|
42
51
|
prefix: data?.prefix,
|
|
43
52
|
body,
|
|
44
53
|
});
|
|
@@ -78,14 +87,16 @@ const SettingsPage = () => {
|
|
|
78
87
|
defaultMessage: 'Configure the documentation plugin',
|
|
79
88
|
})}
|
|
80
89
|
primaryAction={
|
|
81
|
-
<
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
<Button
|
|
91
|
+
type="submit"
|
|
92
|
+
startIcon={<Check />}
|
|
93
|
+
disabled={!dirty && allowedActions.canUpdate}
|
|
94
|
+
>
|
|
95
|
+
{formatMessage({
|
|
96
|
+
id: getTrad('pages.SettingsPage.Button.save'),
|
|
97
|
+
defaultMessage: 'Save',
|
|
98
|
+
})}
|
|
99
|
+
</Button>
|
|
89
100
|
}
|
|
90
101
|
/>
|
|
91
102
|
<ContentLayout>
|
|
@@ -187,4 +198,14 @@ const SettingsPage = () => {
|
|
|
187
198
|
);
|
|
188
199
|
};
|
|
189
200
|
|
|
201
|
+
const FieldActionWrapper = styled(FieldAction)`
|
|
202
|
+
svg {
|
|
203
|
+
height: 1rem;
|
|
204
|
+
width: 1rem;
|
|
205
|
+
path {
|
|
206
|
+
fill: ${({ theme }) => theme.colors.neutral600};
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
`;
|
|
210
|
+
|
|
190
211
|
export default SettingsPage;
|