@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.
Files changed (64) hide show
  1. package/admin/src/hooks/useDocumentation.js +9 -7
  2. package/admin/src/index.js +5 -19
  3. package/admin/src/pages/PluginPage/index.jsx +12 -28
  4. package/admin/src/pages/PluginPage/tests/index.test.jsx +13 -14
  5. package/admin/src/pages/SettingsPage/index.jsx +138 -146
  6. package/admin/src/pages/SettingsPage/tests/index.test.jsx +6 -13
  7. package/admin/src/utils/prefixPluginTranslations.js +13 -0
  8. package/dist/_chunks/EditViewPage-kgrZ8rEg-N3ylaYYT.mjs +84382 -0
  9. package/dist/_chunks/EditViewPage-kgrZ8rEg-N3ylaYYT.mjs.map +1 -0
  10. package/dist/_chunks/EditViewPage-kgrZ8rEg-QXBi74pP.js +84410 -0
  11. package/dist/_chunks/EditViewPage-kgrZ8rEg-QXBi74pP.js.map +1 -0
  12. package/dist/_chunks/ListViewPage-BNB0ptO7-Y0blKENS.js +1617 -0
  13. package/dist/_chunks/ListViewPage-BNB0ptO7-Y0blKENS.js.map +1 -0
  14. package/dist/_chunks/ListViewPage-BNB0ptO7-qPG-Y69A.mjs +1594 -0
  15. package/dist/_chunks/ListViewPage-BNB0ptO7-qPG-Y69A.mjs.map +1 -0
  16. package/dist/_chunks/ReviewWorkflowsColumn-56Z6l-FH-j4yjCkjD.js +33 -0
  17. package/dist/_chunks/ReviewWorkflowsColumn-56Z6l-FH-j4yjCkjD.js.map +1 -0
  18. package/dist/_chunks/ReviewWorkflowsColumn-56Z6l-FH-jOwjGO3o.mjs +33 -0
  19. package/dist/_chunks/ReviewWorkflowsColumn-56Z6l-FH-jOwjGO3o.mjs.map +1 -0
  20. package/dist/_chunks/constants-evLWZCaJ-Oxpg3z7Q.mjs +190 -0
  21. package/dist/_chunks/constants-evLWZCaJ-Oxpg3z7Q.mjs.map +1 -0
  22. package/dist/_chunks/constants-evLWZCaJ-ZpfIp8P_.js +209 -0
  23. package/dist/_chunks/constants-evLWZCaJ-ZpfIp8P_.js.map +1 -0
  24. package/dist/_chunks/{index-8QCog8RN.js → index-7OS1Qe_4.js} +15 -13
  25. package/dist/_chunks/index-7OS1Qe_4.js.map +1 -0
  26. package/dist/_chunks/{index-6c_gUVrM.mjs → index-JM6LA3Oe.mjs} +26 -24
  27. package/dist/_chunks/index-JM6LA3Oe.mjs.map +1 -0
  28. package/dist/_chunks/index-R7UT09YY.js +17934 -0
  29. package/dist/_chunks/index-R7UT09YY.js.map +1 -0
  30. package/dist/_chunks/index-lggLaJiY.mjs +17909 -0
  31. package/dist/_chunks/index-lggLaJiY.mjs.map +1 -0
  32. package/dist/_chunks/{index-r8UM9pKc.js → index-ri1exVbc.js} +29 -27
  33. package/dist/_chunks/index-ri1exVbc.js.map +1 -0
  34. package/dist/_chunks/{index-SdK6c8ae.mjs → index-ynnbYrP0.mjs} +12 -10
  35. package/dist/_chunks/index-ynnbYrP0.mjs.map +1 -0
  36. package/dist/_chunks/{useDocumentation-uuvchj5L.js → useDocumentation-GsX6iQVe.js} +15 -13
  37. package/dist/_chunks/useDocumentation-GsX6iQVe.js.map +1 -0
  38. package/dist/_chunks/{useDocumentation-DcjdYl47.mjs → useDocumentation-jTKQvwxD.mjs} +11 -9
  39. package/dist/_chunks/useDocumentation-jTKQvwxD.mjs.map +1 -0
  40. package/dist/_chunks/useSyncRbac-83vFRiaG-5ec8lrUQ.js +57 -0
  41. package/dist/_chunks/useSyncRbac-83vFRiaG-5ec8lrUQ.js.map +1 -0
  42. package/dist/_chunks/useSyncRbac-83vFRiaG-oJpvBKQE.mjs +39 -0
  43. package/dist/_chunks/useSyncRbac-83vFRiaG-oJpvBKQE.mjs.map +1 -0
  44. package/dist/admin/index.js +1 -2
  45. package/dist/admin/index.js.map +1 -1
  46. package/dist/admin/index.mjs +1 -2
  47. package/dist/admin/index.mjs.map +1 -1
  48. package/dist/style.css +84 -0
  49. package/package.json +13 -13
  50. package/server/controllers/documentation.js +2 -2
  51. package/server/middlewares/restrict-access.js +1 -1
  52. package/server/services/__mocks__/mock-content-types.js +0 -5
  53. package/server/services/documentation.js +2 -3
  54. package/server/services/override.js +1 -1
  55. package/dist/_chunks/index-6c_gUVrM.mjs.map +0 -1
  56. package/dist/_chunks/index-8QCog8RN.js.map +0 -1
  57. package/dist/_chunks/index-SdK6c8ae.mjs.map +0 -1
  58. package/dist/_chunks/index-iIEENwT0.js +0 -169
  59. package/dist/_chunks/index-iIEENwT0.js.map +0 -1
  60. package/dist/_chunks/index-r8UM9pKc.js.map +0 -1
  61. package/dist/_chunks/index-uTcHJZnf.mjs +0 -167
  62. package/dist/_chunks/index-uTcHJZnf.mjs.map +0 -1
  63. package/dist/_chunks/useDocumentation-DcjdYl47.mjs.map +0 -1
  64. package/dist/_chunks/useDocumentation-uuvchj5L.js.map +0 -1
@@ -1,13 +1,15 @@
1
1
  import { useEffect } from 'react';
2
2
 
3
- import { useFetchClient, useNotification, useAPIErrorHandler } from '@strapi/helper-plugin';
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: 'warning',
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: 'warning',
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
 
@@ -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: `/plugins/${pluginId}`,
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
- async Component() {
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: `/settings/${pluginId}`,
47
- async Component() {
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
- LoadingIndicatorPage,
25
- useFocusWhenNavigate,
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 aria-busy={isLoading}>
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
- onToggleDialog={handleShowConfirmDelete}
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 { NotificationsProvider, RBACContext } from '@strapi/helper-plugin';
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
- 'true'
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('Plugin is loading')).not.toBeInTheDocument());
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('Plugin is loading')).not.toBeInTheDocument());
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('Plugin is loading')).not.toBeInTheDocument());
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('Plugin is loading')).toBeInTheDocument();
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('Plugin is loading')).not.toBeInTheDocument());
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('Plugin is loading')).not.toBeInTheDocument());
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('Plugin is loading')).not.toBeInTheDocument());
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 { Formik } from 'formik';
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
- {isLoading ? (
59
- <LoadingIndicatorPage>Plugin settings are loading</LoadingIndicatorPage>
60
- ) : (
61
- <Formik
62
- initialValues={{
63
- restrictedAccess: data?.documentationAccess.restrictedAccess || false,
64
- password: '',
65
- }}
66
- onSubmit={handleUpdateSettingsSubmit}
67
- validationSchema={schema}
68
- >
69
- {({
70
- handleSubmit,
71
- values,
72
- handleChange,
73
- errors,
74
- setFieldTouched,
75
- setFieldValue,
76
- dirty,
77
- }) => {
78
- return (
79
- <Form noValidate onSubmit={handleSubmit}>
80
- <HeaderLayout
81
- title={formatMessage({
82
- id: getTrad('plugin.name'),
83
- defaultMessage: 'Documentation',
84
- })}
85
- subtitle={formatMessage({
86
- id: getTrad('pages.SettingsPage.header.description'),
87
- defaultMessage: 'Configure the documentation plugin',
88
- })}
89
- primaryAction={
90
- <Button
91
- type="submit"
92
- startIcon={<Check />}
93
- disabled={!dirty && allowedActions.canUpdate}
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: getTrad('pages.SettingsPage.Button.save'),
97
- defaultMessage: 'Save',
108
+ id: 'global.settings',
109
+ defaultMessage: 'Settings',
98
110
  })}
99
- </Button>
100
- }
101
- />
102
- <ContentLayout>
103
- <Box
104
- background="neutral0"
105
- hasRadius
106
- shadow="filterShadow"
107
- paddingTop={6}
108
- paddingBottom={6}
109
- paddingLeft={7}
110
- paddingRight={7}
111
- >
112
- <Flex direction="column" alignItems="stretch" gap={4}>
113
- <Typography variant="delta" as="h2">
114
- {formatMessage({
115
- id: 'global.settings',
116
- defaultMessage: 'Settings',
117
- })}
118
- </Typography>
119
- <Grid gap={4}>
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
- <ToggleInput
122
- name="restrictedAccess"
139
+ <TextInput
123
140
  label={formatMessage({
124
- id: getTrad('pages.SettingsPage.toggle.label'),
125
- defaultMessage: 'Restricted Access',
141
+ id: 'global.password',
142
+ defaultMessage: 'Password',
126
143
  })}
127
- hint={formatMessage({
128
- id: getTrad('pages.SettingsPage.toggle.hint'),
129
- defaultMessage: 'Make the documentation endpoint private',
130
- })}
131
- checked={values.restrictedAccess}
132
- onChange={() => {
133
- if (values.restrictedAccess === true) {
134
- setFieldValue('password', '', false);
135
- setFieldTouched('password', false, false);
136
- }
137
-
138
- setFieldValue('restrictedAccess', !values.restrictedAccess, false);
139
- }}
140
- onLabel="On"
141
- offLabel="Off"
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
- {values.restrictedAccess && (
145
- <GridItem col={6} s={12}>
146
- <TextInput
147
- label={formatMessage({
148
- id: 'global.password',
149
- defaultMessage: 'Password',
150
- })}
151
- name="password"
152
- placeholder="**********"
153
- type={passwordShown ? 'text' : 'password'}
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