@strapi/plugin-documentation 4.0.0-next.7 → 4.0.1
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/FieldActionWrapper/index.js +14 -0
- package/admin/src/components/PluginIcon/index.js +12 -0
- package/admin/src/index.js +27 -12
- package/admin/src/pages/PluginPage/index.js +199 -0
- package/admin/src/pages/PluginPage/tests/index.test.js +873 -0
- package/admin/src/pages/PluginPage/tests/server.js +23 -0
- package/admin/src/pages/SettingsPage/index.js +181 -0
- package/admin/src/pages/SettingsPage/tests/index.test.js +612 -0
- package/admin/src/pages/SettingsPage/tests/server.js +18 -0
- package/admin/src/pages/{HomePage/utils → utils}/api.js +5 -4
- package/admin/src/pages/{HomePage/utils → utils}/schema.js +0 -0
- package/admin/src/pages/utils/useReactQuery.js +46 -0
- package/admin/src/translations/ar.json +0 -3
- package/admin/src/translations/cs.json +0 -3
- package/admin/src/translations/de.json +0 -3
- package/admin/src/translations/en.json +14 -3
- package/admin/src/translations/es.json +0 -3
- package/admin/src/translations/fr.json +0 -3
- package/admin/src/translations/id.json +0 -3
- package/admin/src/translations/it.json +0 -3
- package/admin/src/translations/ko.json +41 -22
- package/admin/src/translations/ms.json +0 -3
- package/admin/src/translations/nl.json +0 -3
- package/admin/src/translations/pl.json +0 -3
- package/admin/src/translations/pt-BR.json +0 -3
- package/admin/src/translations/pt.json +0 -3
- package/admin/src/translations/ru.json +0 -3
- package/admin/src/translations/sk.json +0 -3
- package/admin/src/translations/th.json +0 -3
- package/admin/src/translations/tr.json +0 -3
- package/admin/src/translations/uk.json +0 -3
- package/admin/src/translations/vi.json +0 -3
- package/admin/src/translations/zh-Hans.json +3 -6
- package/admin/src/translations/zh.json +0 -3
- package/package.json +32 -47
- package/server/bootstrap.js +19 -105
- package/server/config/default-config.js +12 -15
- package/server/config/index.js +10 -2
- package/server/controllers/documentation.js +61 -127
- package/server/index.js +17 -0
- package/server/middlewares/documentation.js +18 -41
- package/server/{policies/index-policy.js → middlewares/restrict-access.js} +5 -16
- package/{public → server/public}/index.html +0 -0
- package/{public → server/public}/login.html +0 -0
- package/server/register.js +11 -0
- package/server/routes/index.js +81 -3
- package/server/services/documentation.js +125 -1835
- package/server/utils/builders/build-api-endpoint-path.js +174 -0
- package/server/utils/builders/build-api-requests.js +41 -0
- package/server/utils/builders/build-api-responses.js +108 -0
- package/server/utils/builders/index.js +11 -0
- package/server/utils/clean-schema-attributes.js +205 -0
- package/server/utils/error-response.js +22 -0
- package/server/utils/get-schema-data.js +32 -0
- package/server/utils/query-params.js +84 -0
- package/strapi-admin.js +3 -0
- package/strapi-server.js +1 -19
- package/admin/src/assets/images/logo.svg +0 -1
- package/admin/src/components/Block/components.js +0 -26
- package/admin/src/components/Block/index.js +0 -39
- package/admin/src/components/Copy/index.js +0 -36
- package/admin/src/components/Header/index.js +0 -72
- package/admin/src/components/Row/ButtonContainer.js +0 -67
- package/admin/src/components/Row/components.js +0 -83
- package/admin/src/components/Row/index.js +0 -51
- package/admin/src/pages/App/index.js +0 -21
- package/admin/src/pages/HomePage/components.js +0 -59
- package/admin/src/pages/HomePage/index.js +0 -168
- package/admin/src/pages/HomePage/useHomePage.js +0 -56
- package/server/policies/index.js +0 -7
- package/server/routes/routes.json +0 -74
- package/server/services/utils/forms.json +0 -29
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { setupServer } from 'msw/node';
|
|
2
|
+
import { rest } from 'msw';
|
|
3
|
+
|
|
4
|
+
const handlers = [
|
|
5
|
+
rest.get('*/getInfos', (req, res, ctx) => {
|
|
6
|
+
return res(
|
|
7
|
+
ctx.delay(1000),
|
|
8
|
+
ctx.status(200),
|
|
9
|
+
ctx.json({
|
|
10
|
+
currentVersion: '1.0.0',
|
|
11
|
+
docVersions: [
|
|
12
|
+
{ version: '1.0.0', generatedDoc: '10/05/2021 2:52:44 PM' },
|
|
13
|
+
{ version: '1.2.0', generatedDoc: '11/05/2021 3:00:00 PM' },
|
|
14
|
+
],
|
|
15
|
+
prefix: '/documentation',
|
|
16
|
+
})
|
|
17
|
+
);
|
|
18
|
+
}),
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
const server = setupServer(...handlers);
|
|
22
|
+
|
|
23
|
+
export default server;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { Formik } from 'formik';
|
|
4
|
+
import {
|
|
5
|
+
CheckPermissions,
|
|
6
|
+
Form,
|
|
7
|
+
LoadingIndicatorPage,
|
|
8
|
+
useFocusWhenNavigate,
|
|
9
|
+
} from '@strapi/helper-plugin';
|
|
10
|
+
|
|
11
|
+
// Strapi Parts
|
|
12
|
+
import { ContentLayout, HeaderLayout } from '@strapi/design-system/Layout';
|
|
13
|
+
import { Main } from '@strapi/design-system/Main';
|
|
14
|
+
import { Button } from '@strapi/design-system/Button';
|
|
15
|
+
import { Box } from '@strapi/design-system/Box';
|
|
16
|
+
import { Stack } from '@strapi/design-system/Stack';
|
|
17
|
+
import { Typography } from '@strapi/design-system/Typography';
|
|
18
|
+
import { ToggleInput } from '@strapi/design-system/ToggleInput';
|
|
19
|
+
import { TextInput } from '@strapi/design-system/TextInput';
|
|
20
|
+
import { Grid, GridItem } from '@strapi/design-system/Grid';
|
|
21
|
+
|
|
22
|
+
// Strapi Icons
|
|
23
|
+
import Show from '@strapi/icons/Eye';
|
|
24
|
+
import Hide from '@strapi/icons/EyeStriked';
|
|
25
|
+
import Check from '@strapi/icons/Check';
|
|
26
|
+
|
|
27
|
+
import permissions from '../../permissions';
|
|
28
|
+
import { getTrad } from '../../utils';
|
|
29
|
+
import useReactQuery from '../utils/useReactQuery';
|
|
30
|
+
import FieldActionWrapper from '../../components/FieldActionWrapper';
|
|
31
|
+
import schema from '../utils/schema';
|
|
32
|
+
|
|
33
|
+
const SettingsPage = () => {
|
|
34
|
+
useFocusWhenNavigate();
|
|
35
|
+
const { formatMessage } = useIntl();
|
|
36
|
+
const { submitMutation, data, isLoading } = useReactQuery();
|
|
37
|
+
const [passwordShown, setPasswordShown] = useState(false);
|
|
38
|
+
|
|
39
|
+
const handleUpdateSettingsSubmit = body => {
|
|
40
|
+
submitMutation.mutate({
|
|
41
|
+
prefix: data?.prefix,
|
|
42
|
+
body,
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<Main>
|
|
48
|
+
{isLoading ? (
|
|
49
|
+
<LoadingIndicatorPage>Plugin settings are loading</LoadingIndicatorPage>
|
|
50
|
+
) : (
|
|
51
|
+
<Formik
|
|
52
|
+
initialValues={{
|
|
53
|
+
restrictedAccess: data?.documentationAccess.restrictedAccess || false,
|
|
54
|
+
password: '',
|
|
55
|
+
}}
|
|
56
|
+
onSubmit={handleUpdateSettingsSubmit}
|
|
57
|
+
validationSchema={schema}
|
|
58
|
+
>
|
|
59
|
+
{({ handleSubmit, values, handleChange, errors, setFieldTouched, setFieldValue }) => {
|
|
60
|
+
return (
|
|
61
|
+
<Form noValidate onSubmit={handleSubmit}>
|
|
62
|
+
<HeaderLayout
|
|
63
|
+
title={formatMessage({
|
|
64
|
+
id: getTrad('plugin.name'),
|
|
65
|
+
defaultMessage: 'Documentation',
|
|
66
|
+
})}
|
|
67
|
+
subtitle={formatMessage({
|
|
68
|
+
id: getTrad('pages.SettingsPage.header.description'),
|
|
69
|
+
defaultMessage: 'Configure the documentation plugin',
|
|
70
|
+
})}
|
|
71
|
+
primaryAction={
|
|
72
|
+
<CheckPermissions permissions={permissions.update}>
|
|
73
|
+
<Button type="submit" startIcon={<Check />}>
|
|
74
|
+
{formatMessage({
|
|
75
|
+
id: getTrad('pages.SettingsPage.Button.save'),
|
|
76
|
+
defaultMessage: 'Save',
|
|
77
|
+
})}
|
|
78
|
+
</Button>
|
|
79
|
+
</CheckPermissions>
|
|
80
|
+
}
|
|
81
|
+
/>
|
|
82
|
+
<ContentLayout>
|
|
83
|
+
<Box
|
|
84
|
+
background="neutral0"
|
|
85
|
+
hasRadius
|
|
86
|
+
shadow="filterShadow"
|
|
87
|
+
paddingTop={6}
|
|
88
|
+
paddingBottom={6}
|
|
89
|
+
paddingLeft={7}
|
|
90
|
+
paddingRight={7}
|
|
91
|
+
>
|
|
92
|
+
<Stack size={4}>
|
|
93
|
+
<Typography variant="delta" as="h2">
|
|
94
|
+
{formatMessage({
|
|
95
|
+
id: getTrad('pages.SettingsPage.title'),
|
|
96
|
+
defaultMessage: 'Settings',
|
|
97
|
+
})}
|
|
98
|
+
</Typography>
|
|
99
|
+
<Grid gap={4}>
|
|
100
|
+
<GridItem col={6} s={12}>
|
|
101
|
+
<ToggleInput
|
|
102
|
+
name="restrictedAccess"
|
|
103
|
+
label={formatMessage({
|
|
104
|
+
id: getTrad('pages.SettingsPage.toggle.label'),
|
|
105
|
+
defaultMessage: 'Restricted Access',
|
|
106
|
+
})}
|
|
107
|
+
hint={formatMessage({
|
|
108
|
+
id: getTrad('pages.SettingsPage.toggle.hint'),
|
|
109
|
+
defaultMessage: 'Make the documentation endpoint private',
|
|
110
|
+
})}
|
|
111
|
+
checked={values.restrictedAccess}
|
|
112
|
+
onChange={() => {
|
|
113
|
+
if (values.restrictedAccess === true) {
|
|
114
|
+
setFieldValue('password', '', false);
|
|
115
|
+
setFieldTouched('password', false, false);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
setFieldValue('restrictedAccess', !values.restrictedAccess, false);
|
|
119
|
+
}}
|
|
120
|
+
onLabel="On"
|
|
121
|
+
offLabel="Off"
|
|
122
|
+
/>
|
|
123
|
+
</GridItem>
|
|
124
|
+
{values.restrictedAccess && (
|
|
125
|
+
<GridItem col={6} s={12}>
|
|
126
|
+
<TextInput
|
|
127
|
+
label={formatMessage({
|
|
128
|
+
id: getTrad('pages.SettingsPage.password.label'),
|
|
129
|
+
defaultMessage: 'Password',
|
|
130
|
+
})}
|
|
131
|
+
name="password"
|
|
132
|
+
placeholder="**********"
|
|
133
|
+
type={passwordShown ? 'text' : 'password'}
|
|
134
|
+
value={values.password}
|
|
135
|
+
onChange={handleChange}
|
|
136
|
+
error={
|
|
137
|
+
errors.password
|
|
138
|
+
? formatMessage({
|
|
139
|
+
id: errors.password,
|
|
140
|
+
defaultMessage: 'Invalid value',
|
|
141
|
+
})
|
|
142
|
+
: null
|
|
143
|
+
}
|
|
144
|
+
endAction={
|
|
145
|
+
<FieldActionWrapper
|
|
146
|
+
onClick={e => {
|
|
147
|
+
e.stopPropagation();
|
|
148
|
+
setPasswordShown(prev => !prev);
|
|
149
|
+
}}
|
|
150
|
+
label={formatMessage(
|
|
151
|
+
passwordShown
|
|
152
|
+
? {
|
|
153
|
+
id: 'Auth.form.password.show-password',
|
|
154
|
+
defaultMessage: 'Show password',
|
|
155
|
+
}
|
|
156
|
+
: {
|
|
157
|
+
id: 'Auth.form.password.hide-password',
|
|
158
|
+
defaultMessage: 'Hide password',
|
|
159
|
+
}
|
|
160
|
+
)}
|
|
161
|
+
>
|
|
162
|
+
{passwordShown ? <Show /> : <Hide />}
|
|
163
|
+
</FieldActionWrapper>
|
|
164
|
+
}
|
|
165
|
+
/>
|
|
166
|
+
</GridItem>
|
|
167
|
+
)}
|
|
168
|
+
</Grid>
|
|
169
|
+
</Stack>
|
|
170
|
+
</Box>
|
|
171
|
+
</ContentLayout>
|
|
172
|
+
</Form>
|
|
173
|
+
);
|
|
174
|
+
}}
|
|
175
|
+
</Formik>
|
|
176
|
+
)}
|
|
177
|
+
</Main>
|
|
178
|
+
);
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export default SettingsPage;
|