@strapi/plugin-documentation 4.20.5 → 5.0.0-alpha.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/hooks/useDocumentation.js +9 -7
- package/admin/src/index.js +5 -19
- package/admin/src/pages/PluginPage/index.jsx +12 -28
- package/admin/src/pages/PluginPage/tests/index.test.jsx +13 -14
- package/admin/src/pages/SettingsPage/index.jsx +138 -146
- package/admin/src/pages/SettingsPage/tests/index.test.jsx +6 -13
- package/admin/src/utils/prefixPluginTranslations.js +13 -0
- package/dist/_chunks/EditViewPage-kgrZ8rEg-N3ylaYYT.mjs +84382 -0
- package/dist/_chunks/EditViewPage-kgrZ8rEg-N3ylaYYT.mjs.map +1 -0
- package/dist/_chunks/EditViewPage-kgrZ8rEg-QXBi74pP.js +84410 -0
- package/dist/_chunks/EditViewPage-kgrZ8rEg-QXBi74pP.js.map +1 -0
- package/dist/_chunks/ListViewPage-BNB0ptO7-Y0blKENS.js +1617 -0
- package/dist/_chunks/ListViewPage-BNB0ptO7-Y0blKENS.js.map +1 -0
- package/dist/_chunks/ListViewPage-BNB0ptO7-qPG-Y69A.mjs +1594 -0
- package/dist/_chunks/ListViewPage-BNB0ptO7-qPG-Y69A.mjs.map +1 -0
- package/dist/_chunks/ReviewWorkflowsColumn-56Z6l-FH-j4yjCkjD.js +33 -0
- package/dist/_chunks/ReviewWorkflowsColumn-56Z6l-FH-j4yjCkjD.js.map +1 -0
- package/dist/_chunks/ReviewWorkflowsColumn-56Z6l-FH-jOwjGO3o.mjs +33 -0
- package/dist/_chunks/ReviewWorkflowsColumn-56Z6l-FH-jOwjGO3o.mjs.map +1 -0
- package/dist/_chunks/constants-evLWZCaJ-Oxpg3z7Q.mjs +190 -0
- package/dist/_chunks/constants-evLWZCaJ-Oxpg3z7Q.mjs.map +1 -0
- package/dist/_chunks/constants-evLWZCaJ-ZpfIp8P_.js +209 -0
- package/dist/_chunks/constants-evLWZCaJ-ZpfIp8P_.js.map +1 -0
- package/dist/_chunks/{index-8QCog8RN.js → index-7OS1Qe_4.js} +15 -13
- package/dist/_chunks/index-7OS1Qe_4.js.map +1 -0
- package/dist/_chunks/{index-6c_gUVrM.mjs → index-JM6LA3Oe.mjs} +26 -24
- package/dist/_chunks/index-JM6LA3Oe.mjs.map +1 -0
- package/dist/_chunks/index-R7UT09YY.js +17934 -0
- package/dist/_chunks/index-R7UT09YY.js.map +1 -0
- package/dist/_chunks/index-lggLaJiY.mjs +17909 -0
- package/dist/_chunks/index-lggLaJiY.mjs.map +1 -0
- package/dist/_chunks/{index-r8UM9pKc.js → index-ri1exVbc.js} +29 -27
- package/dist/_chunks/index-ri1exVbc.js.map +1 -0
- package/dist/_chunks/{index-SdK6c8ae.mjs → index-ynnbYrP0.mjs} +12 -10
- package/dist/_chunks/index-ynnbYrP0.mjs.map +1 -0
- package/dist/_chunks/{useDocumentation-uuvchj5L.js → useDocumentation-GsX6iQVe.js} +15 -13
- package/dist/_chunks/useDocumentation-GsX6iQVe.js.map +1 -0
- package/dist/_chunks/{useDocumentation-DcjdYl47.mjs → useDocumentation-jTKQvwxD.mjs} +11 -9
- package/dist/_chunks/useDocumentation-jTKQvwxD.mjs.map +1 -0
- package/dist/_chunks/useSyncRbac-83vFRiaG-5ec8lrUQ.js +57 -0
- package/dist/_chunks/useSyncRbac-83vFRiaG-5ec8lrUQ.js.map +1 -0
- package/dist/_chunks/useSyncRbac-83vFRiaG-oJpvBKQE.mjs +39 -0
- package/dist/_chunks/useSyncRbac-83vFRiaG-oJpvBKQE.mjs.map +1 -0
- package/dist/admin/index.js +1 -2
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +1 -2
- package/dist/admin/index.mjs.map +1 -1
- package/dist/style.css +84 -0
- package/package.json +13 -13
- package/server/controllers/documentation.js +2 -2
- package/server/middlewares/restrict-access.js +1 -1
- package/server/services/__mocks__/mock-content-types.js +0 -5
- package/server/services/documentation.js +2 -3
- package/server/services/override.js +1 -1
- package/dist/_chunks/index-6c_gUVrM.mjs.map +0 -1
- package/dist/_chunks/index-8QCog8RN.js.map +0 -1
- package/dist/_chunks/index-SdK6c8ae.mjs.map +0 -1
- package/dist/_chunks/index-iIEENwT0.js +0 -169
- package/dist/_chunks/index-iIEENwT0.js.map +0 -1
- package/dist/_chunks/index-r8UM9pKc.js.map +0 -1
- package/dist/_chunks/index-uTcHJZnf.mjs +0 -167
- package/dist/_chunks/index-uTcHJZnf.mjs.map +0 -1
- package/dist/_chunks/useDocumentation-DcjdYl47.mjs.map +0 -1
- package/dist/_chunks/useDocumentation-uuvchj5L.js.map +0 -1
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { useAPIErrorHandler, useNotification, useFetchClient } from '@strapi/strapi/admin';
|
|
4
|
+
import { useIntl } from 'react-intl';
|
|
4
5
|
import { useMutation, useQuery } from 'react-query';
|
|
5
6
|
|
|
6
7
|
import pluginId from '../pluginId';
|
|
7
8
|
import getTrad from '../utils/getTrad';
|
|
8
9
|
|
|
9
10
|
export const useDocumentation = () => {
|
|
10
|
-
const toggleNotification = useNotification();
|
|
11
|
+
const { toggleNotification } = useNotification();
|
|
12
|
+
const { formatMessage } = useIntl();
|
|
11
13
|
const { del, post, put, get } = useFetchClient();
|
|
12
14
|
|
|
13
15
|
const { formatAPIError } = useAPIErrorHandler();
|
|
@@ -24,15 +26,15 @@ export const useDocumentation = () => {
|
|
|
24
26
|
useEffect(() => {
|
|
25
27
|
if (isError && error) {
|
|
26
28
|
toggleNotification({
|
|
27
|
-
type: '
|
|
28
|
-
message: error ? formatAPIError(error) : { id: 'notification.error' },
|
|
29
|
+
type: 'danger',
|
|
30
|
+
message: error ? formatAPIError(error) : formatMessage({ id: 'notification.error' }),
|
|
29
31
|
});
|
|
30
32
|
}
|
|
31
|
-
}, [isError, error, toggleNotification, formatAPIError]);
|
|
33
|
+
}, [isError, error, toggleNotification, formatAPIError, formatMessage]);
|
|
32
34
|
|
|
33
35
|
const handleError = (err) => {
|
|
34
36
|
toggleNotification({
|
|
35
|
-
type: '
|
|
37
|
+
type: 'danger',
|
|
36
38
|
message: formatAPIError(err),
|
|
37
39
|
});
|
|
38
40
|
};
|
|
@@ -41,7 +43,7 @@ export const useDocumentation = () => {
|
|
|
41
43
|
refetch();
|
|
42
44
|
toggleNotification({
|
|
43
45
|
type,
|
|
44
|
-
message: { id: getTrad(tradId), defaultMessage },
|
|
46
|
+
message: formatMessage({ id: getTrad(tradId), defaultMessage }),
|
|
45
47
|
});
|
|
46
48
|
};
|
|
47
49
|
|
package/admin/src/index.js
CHANGED
|
@@ -1,34 +1,24 @@
|
|
|
1
|
-
// NOTE TO PLUGINS DEVELOPERS:
|
|
2
|
-
// If you modify this file by adding new options to the plugin entry point
|
|
3
|
-
// Here's the file: strapi/docs/3.0.0-beta.x/plugin-development/frontend-field-api.md
|
|
4
|
-
// Here's the file: strapi/docs/3.0.0-beta.x/guides/registering-a-field-in-admin.md
|
|
5
|
-
// Also the strapi-generate-plugins/files/admin/src/index.js needs to be updated
|
|
6
|
-
// IF THE DOC IS NOT UPDATED THE PULL REQUEST WILL NOT BE MERGED
|
|
7
|
-
import { prefixPluginTranslations } from '@strapi/helper-plugin';
|
|
8
1
|
import { Information } from '@strapi/icons';
|
|
9
2
|
|
|
10
3
|
import pluginPkg from '../../package.json';
|
|
11
4
|
|
|
12
5
|
import { PERMISSIONS } from './constants';
|
|
13
6
|
import pluginId from './pluginId';
|
|
7
|
+
import { prefixPluginTranslations } from './utils/prefixPluginTranslations';
|
|
14
8
|
|
|
15
9
|
const name = pluginPkg.strapi.name;
|
|
16
10
|
|
|
17
11
|
export default {
|
|
18
12
|
register(app) {
|
|
19
13
|
app.addMenuLink({
|
|
20
|
-
to:
|
|
14
|
+
to: `plugins/${pluginId}`,
|
|
21
15
|
icon: Information,
|
|
22
16
|
intlLabel: {
|
|
23
17
|
id: `${pluginId}.plugin.name`,
|
|
24
18
|
defaultMessage: 'Documentation',
|
|
25
19
|
},
|
|
26
20
|
permissions: PERMISSIONS.main,
|
|
27
|
-
|
|
28
|
-
const component = await import('./pages/PluginPage');
|
|
29
|
-
|
|
30
|
-
return component;
|
|
31
|
-
},
|
|
21
|
+
Component: () => import('./pages/PluginPage'),
|
|
32
22
|
});
|
|
33
23
|
|
|
34
24
|
app.registerPlugin({
|
|
@@ -43,12 +33,8 @@ export default {
|
|
|
43
33
|
defaultMessage: 'Documentation',
|
|
44
34
|
},
|
|
45
35
|
id: 'documentation',
|
|
46
|
-
to:
|
|
47
|
-
|
|
48
|
-
const component = await import('./pages/SettingsPage');
|
|
49
|
-
|
|
50
|
-
return component;
|
|
51
|
-
},
|
|
36
|
+
to: pluginId,
|
|
37
|
+
Component: () => import('./pages/SettingsPage'),
|
|
52
38
|
permissions: PERMISSIONS.main,
|
|
53
39
|
});
|
|
54
40
|
},
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
|
|
3
|
+
import { ConfirmDialog } from '@strapi/admin/strapi-admin';
|
|
3
4
|
import {
|
|
4
|
-
Box,
|
|
5
5
|
LinkButton,
|
|
6
6
|
ContentLayout,
|
|
7
7
|
Flex,
|
|
8
8
|
HeaderLayout,
|
|
9
9
|
IconButton,
|
|
10
10
|
Layout,
|
|
11
|
-
Main,
|
|
12
11
|
Table,
|
|
13
12
|
Tbody,
|
|
14
13
|
Td,
|
|
@@ -16,16 +15,11 @@ import {
|
|
|
16
15
|
Thead,
|
|
17
16
|
Tr,
|
|
18
17
|
Typography,
|
|
19
|
-
} from '@strapi/design-system';
|
|
20
|
-
import {
|
|
21
|
-
AnErrorOccurred,
|
|
22
|
-
ConfirmDialog,
|
|
23
18
|
EmptyStateLayout,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
useRBAC,
|
|
27
|
-
} from '@strapi/helper-plugin';
|
|
19
|
+
} from '@strapi/design-system';
|
|
20
|
+
import { useRBAC } from '@strapi/helper-plugin';
|
|
28
21
|
import { Eye as Show, Refresh as Reload, Trash } from '@strapi/icons';
|
|
22
|
+
import { Page } from '@strapi/strapi/admin';
|
|
29
23
|
import { Helmet } from 'react-helmet';
|
|
30
24
|
import { useIntl } from 'react-intl';
|
|
31
25
|
import styled from 'styled-components';
|
|
@@ -35,11 +29,9 @@ import { useDocumentation } from '../../hooks/useDocumentation';
|
|
|
35
29
|
import { getTrad } from '../../utils';
|
|
36
30
|
|
|
37
31
|
const PluginPage = () => {
|
|
38
|
-
useFocusWhenNavigate();
|
|
39
32
|
const { formatMessage } = useIntl();
|
|
40
33
|
const { data, isLoading, isError, remove, regenerate } = useDocumentation();
|
|
41
34
|
const [showConfirmDelete, setShowConfirmDelete] = useState(false);
|
|
42
|
-
const [isConfirmButtonLoading, setIsConfirmButtonLoading] = useState(false);
|
|
43
35
|
const [versionToDelete, setVersionToDelete] = useState();
|
|
44
36
|
const { allowedActions } = useRBAC(PERMISSIONS);
|
|
45
37
|
|
|
@@ -55,10 +47,8 @@ const PluginPage = () => {
|
|
|
55
47
|
};
|
|
56
48
|
|
|
57
49
|
const handleConfirmDelete = async () => {
|
|
58
|
-
setIsConfirmButtonLoading(true);
|
|
59
50
|
await remove.mutateAsync({ prefix: data?.prefix, version: versionToDelete });
|
|
60
51
|
setShowConfirmDelete(!showConfirmDelete);
|
|
61
|
-
setIsConfirmButtonLoading(false);
|
|
62
52
|
};
|
|
63
53
|
|
|
64
54
|
const handleClickDelete = (version) => {
|
|
@@ -71,22 +61,18 @@ const PluginPage = () => {
|
|
|
71
61
|
defaultMessage: 'Documentation',
|
|
72
62
|
});
|
|
73
63
|
|
|
64
|
+
if (isLoading) {
|
|
65
|
+
return <Page.Loading />;
|
|
66
|
+
}
|
|
67
|
+
|
|
74
68
|
if (isError) {
|
|
75
|
-
return
|
|
76
|
-
<Layout>
|
|
77
|
-
<ContentLayout>
|
|
78
|
-
<Box paddingTop={8}>
|
|
79
|
-
<AnErrorOccurred />
|
|
80
|
-
</Box>
|
|
81
|
-
</ContentLayout>
|
|
82
|
-
</Layout>
|
|
83
|
-
);
|
|
69
|
+
return <Page.Error />;
|
|
84
70
|
}
|
|
85
71
|
|
|
86
72
|
return (
|
|
87
73
|
<Layout>
|
|
88
74
|
<Helmet title={title} />
|
|
89
|
-
<Main
|
|
75
|
+
<Page.Main>
|
|
90
76
|
<HeaderLayout
|
|
91
77
|
title={title}
|
|
92
78
|
subtitle={formatMessage({
|
|
@@ -107,7 +93,6 @@ const PluginPage = () => {
|
|
|
107
93
|
}
|
|
108
94
|
/>
|
|
109
95
|
<ContentLayout>
|
|
110
|
-
{isLoading && <LoadingIndicatorPage>Plugin is loading</LoadingIndicatorPage>}
|
|
111
96
|
{data?.docVersions.length ? (
|
|
112
97
|
<Table colCount={colCount} rowCount={rowCount}>
|
|
113
98
|
<Thead>
|
|
@@ -198,12 +183,11 @@ const PluginPage = () => {
|
|
|
198
183
|
)}
|
|
199
184
|
</ContentLayout>
|
|
200
185
|
<ConfirmDialog
|
|
201
|
-
isConfirmButtonLoading={isConfirmButtonLoading}
|
|
202
186
|
onConfirm={handleConfirmDelete}
|
|
203
|
-
|
|
187
|
+
onClose={handleShowConfirmDelete}
|
|
204
188
|
isOpen={showConfirmDelete}
|
|
205
189
|
/>
|
|
206
|
-
</Main>
|
|
190
|
+
</Page.Main>
|
|
207
191
|
</Layout>
|
|
208
192
|
);
|
|
209
193
|
};
|
|
@@ -2,7 +2,8 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import { fixtures } from '@strapi/admin-test-utils';
|
|
4
4
|
import { lightTheme, ThemeProvider } from '@strapi/design-system';
|
|
5
|
-
import {
|
|
5
|
+
import { RBACContext } from '@strapi/helper-plugin';
|
|
6
|
+
import { NotificationsProvider } from '@strapi/strapi/admin';
|
|
6
7
|
import { render as renderRTL, waitFor } from '@testing-library/react';
|
|
7
8
|
import userEvent from '@testing-library/user-event';
|
|
8
9
|
import { IntlProvider } from 'react-intl';
|
|
@@ -54,16 +55,15 @@ describe('PluginPage', () => {
|
|
|
54
55
|
it('render the plugin page correctly', async () => {
|
|
55
56
|
const { getByRole, queryByText, getByText } = render();
|
|
56
57
|
|
|
58
|
+
await waitFor(() => expect(queryByText('Loading content.')).not.toBeInTheDocument());
|
|
59
|
+
|
|
57
60
|
expect(getByRole('heading', { name: 'Documentation' })).toBeInTheDocument();
|
|
58
61
|
expect(getByText('Configure the documentation plugin')).toBeInTheDocument();
|
|
59
|
-
expect(queryByText('Plugin is loading')).toBeInTheDocument();
|
|
60
62
|
expect(getByRole('link', { name: 'Open Documentation' })).toHaveAttribute(
|
|
61
63
|
'aria-disabled',
|
|
62
|
-
'
|
|
64
|
+
'false'
|
|
63
65
|
);
|
|
64
66
|
|
|
65
|
-
await waitFor(() => expect(queryByText('Plugin is loading')).not.toBeInTheDocument());
|
|
66
|
-
|
|
67
67
|
expect(getByRole('heading', { name: 'Documentation' })).toBeInTheDocument();
|
|
68
68
|
expect(getByText('Configure the documentation plugin')).toBeInTheDocument();
|
|
69
69
|
expect(getByRole('link', { name: 'Open Documentation' })).toBeInTheDocument();
|
|
@@ -90,7 +90,7 @@ describe('PluginPage', () => {
|
|
|
90
90
|
it('should open the documentation', async () => {
|
|
91
91
|
const { getByRole, queryByText, user } = render();
|
|
92
92
|
|
|
93
|
-
await waitFor(() => expect(queryByText('
|
|
93
|
+
await waitFor(() => expect(queryByText('Loading content.')).not.toBeInTheDocument());
|
|
94
94
|
|
|
95
95
|
expect(getByRole('link', { name: 'Open Documentation' })).toHaveAttribute(
|
|
96
96
|
'href',
|
|
@@ -110,7 +110,7 @@ describe('PluginPage', () => {
|
|
|
110
110
|
it('should regenerate the documentation', async () => {
|
|
111
111
|
const { getByRole, queryByText, user, getByText } = render();
|
|
112
112
|
|
|
113
|
-
await waitFor(() => expect(queryByText('
|
|
113
|
+
await waitFor(() => expect(queryByText('Loading content.')).not.toBeInTheDocument());
|
|
114
114
|
|
|
115
115
|
expect(getByRole('button', { name: 'Regenerate 2.0.0' })).toBeInTheDocument();
|
|
116
116
|
|
|
@@ -122,7 +122,7 @@ describe('PluginPage', () => {
|
|
|
122
122
|
it('should delete the documentation', async () => {
|
|
123
123
|
const { getByRole, queryByText, user, getByText } = render();
|
|
124
124
|
|
|
125
|
-
await waitFor(() => expect(queryByText('
|
|
125
|
+
await waitFor(() => expect(queryByText('Loading content.')).not.toBeInTheDocument());
|
|
126
126
|
|
|
127
127
|
expect(getByRole('button', { name: 'Delete 2.0.0' })).toBeInTheDocument();
|
|
128
128
|
|
|
@@ -144,14 +144,13 @@ describe('PluginPage', () => {
|
|
|
144
144
|
permissions: [],
|
|
145
145
|
});
|
|
146
146
|
|
|
147
|
-
expect(queryByText('
|
|
147
|
+
await waitFor(() => expect(queryByText('Loading content.')).not.toBeInTheDocument());
|
|
148
|
+
|
|
148
149
|
expect(getByRole('link', { name: 'Open Documentation' })).toHaveAttribute(
|
|
149
150
|
'aria-disabled',
|
|
150
151
|
'true'
|
|
151
152
|
);
|
|
152
153
|
|
|
153
|
-
await waitFor(() => expect(queryByText('Plugin is loading')).not.toBeInTheDocument());
|
|
154
|
-
|
|
155
154
|
expect(getByRole('link', { name: 'Open Documentation' })).toHaveAttribute(
|
|
156
155
|
'aria-disabled',
|
|
157
156
|
'true'
|
|
@@ -163,7 +162,7 @@ describe('PluginPage', () => {
|
|
|
163
162
|
permissions: [],
|
|
164
163
|
});
|
|
165
164
|
|
|
166
|
-
await waitFor(() => expect(queryByText('
|
|
165
|
+
await waitFor(() => expect(queryByText('Loading content.')).not.toBeInTheDocument());
|
|
167
166
|
|
|
168
167
|
versions.forEach((version) => {
|
|
169
168
|
expect(getByRole('gridcell', { name: version })).toBeInTheDocument();
|
|
@@ -180,7 +179,7 @@ describe('PluginPage', () => {
|
|
|
180
179
|
permissions: [],
|
|
181
180
|
});
|
|
182
181
|
|
|
183
|
-
await waitFor(() => expect(queryByText('
|
|
182
|
+
await waitFor(() => expect(queryByText('Loading content.')).not.toBeInTheDocument());
|
|
184
183
|
|
|
185
184
|
versions.forEach((version) => {
|
|
186
185
|
expect(getByRole('gridcell', { name: version })).toBeInTheDocument();
|
|
@@ -194,7 +193,7 @@ describe('PluginPage', () => {
|
|
|
194
193
|
permissions: [],
|
|
195
194
|
});
|
|
196
195
|
|
|
197
|
-
await waitFor(() => expect(queryByText('
|
|
196
|
+
await waitFor(() => expect(queryByText('Loading content.')).not.toBeInTheDocument());
|
|
198
197
|
|
|
199
198
|
versions.forEach((version) => {
|
|
200
199
|
expect(getByRole('gridcell', { name: version })).toBeInTheDocument();
|
|
@@ -8,22 +8,15 @@ import {
|
|
|
8
8
|
Grid,
|
|
9
9
|
GridItem,
|
|
10
10
|
HeaderLayout,
|
|
11
|
-
Main,
|
|
12
11
|
TextInput,
|
|
13
12
|
ToggleInput,
|
|
14
13
|
Typography,
|
|
15
14
|
FieldAction,
|
|
16
15
|
} from '@strapi/design-system';
|
|
17
|
-
import {
|
|
18
|
-
Form,
|
|
19
|
-
LoadingIndicatorPage,
|
|
20
|
-
useFocusWhenNavigate,
|
|
21
|
-
translatedErrors,
|
|
22
|
-
useRBAC,
|
|
23
|
-
} from '@strapi/helper-plugin';
|
|
24
|
-
// Strapi Icons
|
|
16
|
+
import { useRBAC } from '@strapi/helper-plugin';
|
|
25
17
|
import { Check, Eye as Show, EyeStriked as Hide } from '@strapi/icons';
|
|
26
|
-
import {
|
|
18
|
+
import { translatedErrors, Page } from '@strapi/strapi/admin';
|
|
19
|
+
import { Form, Formik } from 'formik';
|
|
27
20
|
import { useIntl } from 'react-intl';
|
|
28
21
|
import styled from 'styled-components';
|
|
29
22
|
import * as yup from 'yup';
|
|
@@ -35,12 +28,11 @@ import { getTrad } from '../../utils';
|
|
|
35
28
|
const schema = yup.object().shape({
|
|
36
29
|
restrictedAccess: yup.boolean(),
|
|
37
30
|
password: yup.string().when('restrictedAccess', (value, initSchema) => {
|
|
38
|
-
return value ? initSchema.required(translatedErrors.required) : initSchema;
|
|
31
|
+
return value ? initSchema.required(translatedErrors.required.id) : initSchema;
|
|
39
32
|
}),
|
|
40
33
|
});
|
|
41
34
|
|
|
42
35
|
const SettingsPage = () => {
|
|
43
|
-
useFocusWhenNavigate();
|
|
44
36
|
const { formatMessage } = useIntl();
|
|
45
37
|
const { submit, data, isLoading } = useDocumentation();
|
|
46
38
|
const [passwordShown, setPasswordShown] = useState(false);
|
|
@@ -53,148 +45,148 @@ const SettingsPage = () => {
|
|
|
53
45
|
});
|
|
54
46
|
};
|
|
55
47
|
|
|
48
|
+
if (isLoading) {
|
|
49
|
+
return <Page.Loading />;
|
|
50
|
+
}
|
|
51
|
+
|
|
56
52
|
return (
|
|
57
|
-
<Main>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
53
|
+
<Page.Main>
|
|
54
|
+
<Formik
|
|
55
|
+
initialValues={{
|
|
56
|
+
restrictedAccess: data?.documentationAccess.restrictedAccess || false,
|
|
57
|
+
password: '',
|
|
58
|
+
}}
|
|
59
|
+
onSubmit={handleUpdateSettingsSubmit}
|
|
60
|
+
validationSchema={schema}
|
|
61
|
+
>
|
|
62
|
+
{({
|
|
63
|
+
handleSubmit,
|
|
64
|
+
values,
|
|
65
|
+
handleChange,
|
|
66
|
+
errors,
|
|
67
|
+
setFieldTouched,
|
|
68
|
+
setFieldValue,
|
|
69
|
+
dirty,
|
|
70
|
+
}) => {
|
|
71
|
+
return (
|
|
72
|
+
<Form noValidate onSubmit={handleSubmit}>
|
|
73
|
+
<HeaderLayout
|
|
74
|
+
title={formatMessage({
|
|
75
|
+
id: getTrad('plugin.name'),
|
|
76
|
+
defaultMessage: 'Documentation',
|
|
77
|
+
})}
|
|
78
|
+
subtitle={formatMessage({
|
|
79
|
+
id: getTrad('pages.SettingsPage.header.description'),
|
|
80
|
+
defaultMessage: 'Configure the documentation plugin',
|
|
81
|
+
})}
|
|
82
|
+
primaryAction={
|
|
83
|
+
<Button
|
|
84
|
+
type="submit"
|
|
85
|
+
startIcon={<Check />}
|
|
86
|
+
disabled={!dirty && allowedActions.canUpdate}
|
|
87
|
+
>
|
|
88
|
+
{formatMessage({
|
|
89
|
+
id: getTrad('pages.SettingsPage.Button.save'),
|
|
90
|
+
defaultMessage: 'Save',
|
|
91
|
+
})}
|
|
92
|
+
</Button>
|
|
93
|
+
}
|
|
94
|
+
/>
|
|
95
|
+
<ContentLayout>
|
|
96
|
+
<Box
|
|
97
|
+
background="neutral0"
|
|
98
|
+
hasRadius
|
|
99
|
+
shadow="filterShadow"
|
|
100
|
+
paddingTop={6}
|
|
101
|
+
paddingBottom={6}
|
|
102
|
+
paddingLeft={7}
|
|
103
|
+
paddingRight={7}
|
|
104
|
+
>
|
|
105
|
+
<Flex direction="column" alignItems="stretch" gap={4}>
|
|
106
|
+
<Typography variant="delta" as="h2">
|
|
95
107
|
{formatMessage({
|
|
96
|
-
id:
|
|
97
|
-
defaultMessage: '
|
|
108
|
+
id: 'global.settings',
|
|
109
|
+
defaultMessage: 'Settings',
|
|
98
110
|
})}
|
|
99
|
-
</
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
111
|
+
</Typography>
|
|
112
|
+
<Grid gap={4}>
|
|
113
|
+
<GridItem col={6} s={12}>
|
|
114
|
+
<ToggleInput
|
|
115
|
+
name="restrictedAccess"
|
|
116
|
+
label={formatMessage({
|
|
117
|
+
id: getTrad('pages.SettingsPage.toggle.label'),
|
|
118
|
+
defaultMessage: 'Restricted Access',
|
|
119
|
+
})}
|
|
120
|
+
hint={formatMessage({
|
|
121
|
+
id: getTrad('pages.SettingsPage.toggle.hint'),
|
|
122
|
+
defaultMessage: 'Make the documentation endpoint private',
|
|
123
|
+
})}
|
|
124
|
+
checked={values.restrictedAccess}
|
|
125
|
+
onChange={() => {
|
|
126
|
+
if (values.restrictedAccess === true) {
|
|
127
|
+
setFieldValue('password', '', false);
|
|
128
|
+
setFieldTouched('password', false, false);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
setFieldValue('restrictedAccess', !values.restrictedAccess, false);
|
|
132
|
+
}}
|
|
133
|
+
onLabel="On"
|
|
134
|
+
offLabel="Off"
|
|
135
|
+
/>
|
|
136
|
+
</GridItem>
|
|
137
|
+
{values.restrictedAccess && (
|
|
120
138
|
<GridItem col={6} s={12}>
|
|
121
|
-
<
|
|
122
|
-
name="restrictedAccess"
|
|
139
|
+
<TextInput
|
|
123
140
|
label={formatMessage({
|
|
124
|
-
id:
|
|
125
|
-
defaultMessage: '
|
|
141
|
+
id: 'global.password',
|
|
142
|
+
defaultMessage: 'Password',
|
|
126
143
|
})}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
144
|
+
name="password"
|
|
145
|
+
placeholder="**********"
|
|
146
|
+
type={passwordShown ? 'text' : 'password'}
|
|
147
|
+
value={values.password}
|
|
148
|
+
onChange={handleChange}
|
|
149
|
+
error={
|
|
150
|
+
errors.password
|
|
151
|
+
? formatMessage({
|
|
152
|
+
id: errors.password,
|
|
153
|
+
defaultMessage: 'Invalid value',
|
|
154
|
+
})
|
|
155
|
+
: null
|
|
156
|
+
}
|
|
157
|
+
endAction={
|
|
158
|
+
<FieldActionWrapper
|
|
159
|
+
onClick={(e) => {
|
|
160
|
+
e.stopPropagation();
|
|
161
|
+
setPasswordShown((prev) => !prev);
|
|
162
|
+
}}
|
|
163
|
+
label={formatMessage(
|
|
164
|
+
passwordShown
|
|
165
|
+
? {
|
|
166
|
+
id: 'Auth.form.password.show-password',
|
|
167
|
+
defaultMessage: 'Show password',
|
|
168
|
+
}
|
|
169
|
+
: {
|
|
170
|
+
id: 'Auth.form.password.hide-password',
|
|
171
|
+
defaultMessage: 'Hide password',
|
|
172
|
+
}
|
|
173
|
+
)}
|
|
174
|
+
>
|
|
175
|
+
{passwordShown ? <Show /> : <Hide />}
|
|
176
|
+
</FieldActionWrapper>
|
|
177
|
+
}
|
|
142
178
|
/>
|
|
143
179
|
</GridItem>
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
value={values.password}
|
|
155
|
-
onChange={handleChange}
|
|
156
|
-
error={
|
|
157
|
-
errors.password
|
|
158
|
-
? formatMessage({
|
|
159
|
-
id: errors.password,
|
|
160
|
-
defaultMessage: 'Invalid value',
|
|
161
|
-
})
|
|
162
|
-
: null
|
|
163
|
-
}
|
|
164
|
-
endAction={
|
|
165
|
-
<FieldActionWrapper
|
|
166
|
-
onClick={(e) => {
|
|
167
|
-
e.stopPropagation();
|
|
168
|
-
setPasswordShown((prev) => !prev);
|
|
169
|
-
}}
|
|
170
|
-
label={formatMessage(
|
|
171
|
-
passwordShown
|
|
172
|
-
? {
|
|
173
|
-
id: 'Auth.form.password.show-password',
|
|
174
|
-
defaultMessage: 'Show password',
|
|
175
|
-
}
|
|
176
|
-
: {
|
|
177
|
-
id: 'Auth.form.password.hide-password',
|
|
178
|
-
defaultMessage: 'Hide password',
|
|
179
|
-
}
|
|
180
|
-
)}
|
|
181
|
-
>
|
|
182
|
-
{passwordShown ? <Show /> : <Hide />}
|
|
183
|
-
</FieldActionWrapper>
|
|
184
|
-
}
|
|
185
|
-
/>
|
|
186
|
-
</GridItem>
|
|
187
|
-
)}
|
|
188
|
-
</Grid>
|
|
189
|
-
</Flex>
|
|
190
|
-
</Box>
|
|
191
|
-
</ContentLayout>
|
|
192
|
-
</Form>
|
|
193
|
-
);
|
|
194
|
-
}}
|
|
195
|
-
</Formik>
|
|
196
|
-
)}
|
|
197
|
-
</Main>
|
|
180
|
+
)}
|
|
181
|
+
</Grid>
|
|
182
|
+
</Flex>
|
|
183
|
+
</Box>
|
|
184
|
+
</ContentLayout>
|
|
185
|
+
</Form>
|
|
186
|
+
);
|
|
187
|
+
}}
|
|
188
|
+
</Formik>
|
|
189
|
+
</Page.Main>
|
|
198
190
|
);
|
|
199
191
|
};
|
|
200
192
|
|