@strapi/plugin-documentation 0.0.0-experimental.22e8a4f31c0b65da00cc6c524a94de53fabc7a28 → 0.0.0-experimental.2363945b79274c79e6505e5a6c3cdec876ed8cec

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 (29) hide show
  1. package/admin/src/pages/PluginPage/index.jsx +8 -19
  2. package/admin/src/pages/PluginPage/tests/index.test.jsx +11 -13
  3. package/admin/src/pages/SettingsPage/index.jsx +135 -140
  4. package/admin/src/pages/SettingsPage/tests/index.test.jsx +4 -12
  5. package/dist/_chunks/index-2LMgyEch.js +170 -0
  6. package/dist/_chunks/index-2LMgyEch.js.map +1 -0
  7. package/dist/_chunks/{index-GyR31RNk.js → index-WObd3DqQ.js} +9 -5
  8. package/dist/_chunks/index-WObd3DqQ.js.map +1 -0
  9. package/dist/_chunks/{index-9DUilJFu.js → index-cd8DFPBl.js} +10 -10
  10. package/dist/_chunks/{index-9DUilJFu.js.map → index-cd8DFPBl.js.map} +1 -1
  11. package/dist/_chunks/{index-r-_4ASdB.mjs → index-m7s9Z2Vc.mjs} +10 -10
  12. package/dist/_chunks/{index-r-_4ASdB.mjs.map → index-m7s9Z2Vc.mjs.map} +1 -1
  13. package/dist/_chunks/{index-V5rGhTJC.mjs → index-rlwPCjcU.mjs} +10 -6
  14. package/dist/_chunks/index-rlwPCjcU.mjs.map +1 -0
  15. package/dist/_chunks/index-yD22RZOw.mjs +168 -0
  16. package/dist/_chunks/index-yD22RZOw.mjs.map +1 -0
  17. package/dist/_chunks/{useDocumentation-K5JKrEFf.mjs → useDocumentation-LP41QCem.mjs} +2 -2
  18. package/dist/_chunks/{useDocumentation-K5JKrEFf.mjs.map → useDocumentation-LP41QCem.mjs.map} +1 -1
  19. package/dist/_chunks/{useDocumentation-Vbx8EBFR.js → useDocumentation-VA4HgTot.js} +2 -2
  20. package/dist/_chunks/{useDocumentation-Vbx8EBFR.js.map → useDocumentation-VA4HgTot.js.map} +1 -1
  21. package/dist/admin/index.js +1 -1
  22. package/dist/admin/index.mjs +1 -1
  23. package/package.json +8 -8
  24. package/dist/_chunks/index-AOIABJwm.js +0 -169
  25. package/dist/_chunks/index-AOIABJwm.js.map +0 -1
  26. package/dist/_chunks/index-GyR31RNk.js.map +0 -1
  27. package/dist/_chunks/index-V5rGhTJC.mjs.map +0 -1
  28. package/dist/_chunks/index-e9vseaY-.mjs +0 -167
  29. package/dist/_chunks/index-e9vseaY-.mjs.map +0 -1
@@ -1,7 +1,6 @@
1
1
  import React, { useState } from 'react';
2
2
 
3
3
  import {
4
- Box,
5
4
  LinkButton,
6
5
  ContentLayout,
7
6
  Flex,
@@ -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 { ConfirmDialog, useFocusWhenNavigate, 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';
@@ -71,16 +65,12 @@ const PluginPage = () => {
71
65
  defaultMessage: 'Documentation',
72
66
  });
73
67
 
68
+ if (isLoading) {
69
+ return <Page.Loading />;
70
+ }
71
+
74
72
  if (isError) {
75
- return (
76
- <Layout>
77
- <ContentLayout>
78
- <Box paddingTop={8}>
79
- <AnErrorOccurred />
80
- </Box>
81
- </ContentLayout>
82
- </Layout>
83
- );
73
+ return <Page.Error />;
84
74
  }
85
75
 
86
76
  return (
@@ -107,7 +97,6 @@ const PluginPage = () => {
107
97
  }
108
98
  />
109
99
  <ContentLayout>
110
- {isLoading && <LoadingIndicatorPage>Plugin is loading</LoadingIndicatorPage>}
111
100
  {data?.docVersions.length ? (
112
101
  <Table colCount={colCount} rowCount={rowCount}>
113
102
  <Thead>
@@ -54,16 +54,15 @@ describe('PluginPage', () => {
54
54
  it('render the plugin page correctly', async () => {
55
55
  const { getByRole, queryByText, getByText } = render();
56
56
 
57
+ await waitFor(() => expect(queryByText('Loading content.')).not.toBeInTheDocument());
58
+
57
59
  expect(getByRole('heading', { name: 'Documentation' })).toBeInTheDocument();
58
60
  expect(getByText('Configure the documentation plugin')).toBeInTheDocument();
59
- expect(queryByText('Plugin is loading')).toBeInTheDocument();
60
61
  expect(getByRole('link', { name: 'Open Documentation' })).toHaveAttribute(
61
62
  'aria-disabled',
62
- 'true'
63
+ 'false'
63
64
  );
64
65
 
65
- await waitFor(() => expect(queryByText('Plugin is loading')).not.toBeInTheDocument());
66
-
67
66
  expect(getByRole('heading', { name: 'Documentation' })).toBeInTheDocument();
68
67
  expect(getByText('Configure the documentation plugin')).toBeInTheDocument();
69
68
  expect(getByRole('link', { name: 'Open Documentation' })).toBeInTheDocument();
@@ -90,7 +89,7 @@ describe('PluginPage', () => {
90
89
  it('should open the documentation', async () => {
91
90
  const { getByRole, queryByText, user } = render();
92
91
 
93
- await waitFor(() => expect(queryByText('Plugin is loading')).not.toBeInTheDocument());
92
+ await waitFor(() => expect(queryByText('Loading content.')).not.toBeInTheDocument());
94
93
 
95
94
  expect(getByRole('link', { name: 'Open Documentation' })).toHaveAttribute(
96
95
  'href',
@@ -110,7 +109,7 @@ describe('PluginPage', () => {
110
109
  it('should regenerate the documentation', async () => {
111
110
  const { getByRole, queryByText, user, getByText } = render();
112
111
 
113
- await waitFor(() => expect(queryByText('Plugin is loading')).not.toBeInTheDocument());
112
+ await waitFor(() => expect(queryByText('Loading content.')).not.toBeInTheDocument());
114
113
 
115
114
  expect(getByRole('button', { name: 'Regenerate 2.0.0' })).toBeInTheDocument();
116
115
 
@@ -122,7 +121,7 @@ describe('PluginPage', () => {
122
121
  it('should delete the documentation', async () => {
123
122
  const { getByRole, queryByText, user, getByText } = render();
124
123
 
125
- await waitFor(() => expect(queryByText('Plugin is loading')).not.toBeInTheDocument());
124
+ await waitFor(() => expect(queryByText('Loading content.')).not.toBeInTheDocument());
126
125
 
127
126
  expect(getByRole('button', { name: 'Delete 2.0.0' })).toBeInTheDocument();
128
127
 
@@ -144,14 +143,13 @@ describe('PluginPage', () => {
144
143
  permissions: [],
145
144
  });
146
145
 
147
- expect(queryByText('Plugin is loading')).toBeInTheDocument();
146
+ await waitFor(() => expect(queryByText('Loading content.')).not.toBeInTheDocument());
147
+
148
148
  expect(getByRole('link', { name: 'Open Documentation' })).toHaveAttribute(
149
149
  'aria-disabled',
150
150
  'true'
151
151
  );
152
152
 
153
- await waitFor(() => expect(queryByText('Plugin is loading')).not.toBeInTheDocument());
154
-
155
153
  expect(getByRole('link', { name: 'Open Documentation' })).toHaveAttribute(
156
154
  'aria-disabled',
157
155
  'true'
@@ -163,7 +161,7 @@ describe('PluginPage', () => {
163
161
  permissions: [],
164
162
  });
165
163
 
166
- await waitFor(() => expect(queryByText('Plugin is loading')).not.toBeInTheDocument());
164
+ await waitFor(() => expect(queryByText('Loading content.')).not.toBeInTheDocument());
167
165
 
168
166
  versions.forEach((version) => {
169
167
  expect(getByRole('gridcell', { name: version })).toBeInTheDocument();
@@ -180,7 +178,7 @@ describe('PluginPage', () => {
180
178
  permissions: [],
181
179
  });
182
180
 
183
- await waitFor(() => expect(queryByText('Plugin is loading')).not.toBeInTheDocument());
181
+ await waitFor(() => expect(queryByText('Loading content.')).not.toBeInTheDocument());
184
182
 
185
183
  versions.forEach((version) => {
186
184
  expect(getByRole('gridcell', { name: version })).toBeInTheDocument();
@@ -194,7 +192,7 @@ describe('PluginPage', () => {
194
192
  permissions: [],
195
193
  });
196
194
 
197
- await waitFor(() => expect(queryByText('Plugin is loading')).not.toBeInTheDocument());
195
+ await waitFor(() => expect(queryByText('Loading content.')).not.toBeInTheDocument());
198
196
 
199
197
  versions.forEach((version) => {
200
198
  expect(getByRole('gridcell', { name: version })).toBeInTheDocument();
@@ -14,16 +14,11 @@ import {
14
14
  Typography,
15
15
  FieldAction,
16
16
  } from '@strapi/design-system';
17
- import {
18
- Form,
19
- LoadingIndicatorPage,
20
- useFocusWhenNavigate,
21
- translatedErrors,
22
- useRBAC,
23
- } from '@strapi/helper-plugin';
17
+ import { useFocusWhenNavigate, translatedErrors, useRBAC } from '@strapi/helper-plugin';
24
18
  // Strapi Icons
25
19
  import { Check, Eye as Show, EyeStriked as Hide } from '@strapi/icons';
26
- import { Formik } from 'formik';
20
+ import { Page } from '@strapi/strapi/admin';
21
+ import { Form, Formik } from 'formik';
27
22
  import { useIntl } from 'react-intl';
28
23
  import styled from 'styled-components';
29
24
  import * as yup from 'yup';
@@ -53,147 +48,147 @@ const SettingsPage = () => {
53
48
  });
54
49
  };
55
50
 
51
+ if (isLoading) {
52
+ return <Page.Loading />;
53
+ }
54
+
56
55
  return (
57
56
  <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
- >
57
+ <Formik
58
+ initialValues={{
59
+ restrictedAccess: data?.documentationAccess.restrictedAccess || false,
60
+ password: '',
61
+ }}
62
+ onSubmit={handleUpdateSettingsSubmit}
63
+ validationSchema={schema}
64
+ >
65
+ {({
66
+ handleSubmit,
67
+ values,
68
+ handleChange,
69
+ errors,
70
+ setFieldTouched,
71
+ setFieldValue,
72
+ dirty,
73
+ }) => {
74
+ return (
75
+ <Form noValidate onSubmit={handleSubmit}>
76
+ <HeaderLayout
77
+ title={formatMessage({
78
+ id: getTrad('plugin.name'),
79
+ defaultMessage: 'Documentation',
80
+ })}
81
+ subtitle={formatMessage({
82
+ id: getTrad('pages.SettingsPage.header.description'),
83
+ defaultMessage: 'Configure the documentation plugin',
84
+ })}
85
+ primaryAction={
86
+ <Button
87
+ type="submit"
88
+ startIcon={<Check />}
89
+ disabled={!dirty && allowedActions.canUpdate}
90
+ >
91
+ {formatMessage({
92
+ id: getTrad('pages.SettingsPage.Button.save'),
93
+ defaultMessage: 'Save',
94
+ })}
95
+ </Button>
96
+ }
97
+ />
98
+ <ContentLayout>
99
+ <Box
100
+ background="neutral0"
101
+ hasRadius
102
+ shadow="filterShadow"
103
+ paddingTop={6}
104
+ paddingBottom={6}
105
+ paddingLeft={7}
106
+ paddingRight={7}
107
+ >
108
+ <Flex direction="column" alignItems="stretch" gap={4}>
109
+ <Typography variant="delta" as="h2">
95
110
  {formatMessage({
96
- id: getTrad('pages.SettingsPage.Button.save'),
97
- defaultMessage: 'Save',
111
+ id: 'global.settings',
112
+ defaultMessage: 'Settings',
98
113
  })}
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}>
114
+ </Typography>
115
+ <Grid gap={4}>
116
+ <GridItem col={6} s={12}>
117
+ <ToggleInput
118
+ name="restrictedAccess"
119
+ label={formatMessage({
120
+ id: getTrad('pages.SettingsPage.toggle.label'),
121
+ defaultMessage: 'Restricted Access',
122
+ })}
123
+ hint={formatMessage({
124
+ id: getTrad('pages.SettingsPage.toggle.hint'),
125
+ defaultMessage: 'Make the documentation endpoint private',
126
+ })}
127
+ checked={values.restrictedAccess}
128
+ onChange={() => {
129
+ if (values.restrictedAccess === true) {
130
+ setFieldValue('password', '', false);
131
+ setFieldTouched('password', false, false);
132
+ }
133
+
134
+ setFieldValue('restrictedAccess', !values.restrictedAccess, false);
135
+ }}
136
+ onLabel="On"
137
+ offLabel="Off"
138
+ />
139
+ </GridItem>
140
+ {values.restrictedAccess && (
120
141
  <GridItem col={6} s={12}>
121
- <ToggleInput
122
- name="restrictedAccess"
142
+ <TextInput
123
143
  label={formatMessage({
124
- id: getTrad('pages.SettingsPage.toggle.label'),
125
- defaultMessage: 'Restricted Access',
144
+ id: 'global.password',
145
+ defaultMessage: 'Password',
126
146
  })}
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"
147
+ name="password"
148
+ placeholder="**********"
149
+ type={passwordShown ? 'text' : 'password'}
150
+ value={values.password}
151
+ onChange={handleChange}
152
+ error={
153
+ errors.password
154
+ ? formatMessage({
155
+ id: errors.password,
156
+ defaultMessage: 'Invalid value',
157
+ })
158
+ : null
159
+ }
160
+ endAction={
161
+ <FieldActionWrapper
162
+ onClick={(e) => {
163
+ e.stopPropagation();
164
+ setPasswordShown((prev) => !prev);
165
+ }}
166
+ label={formatMessage(
167
+ passwordShown
168
+ ? {
169
+ id: 'Auth.form.password.show-password',
170
+ defaultMessage: 'Show password',
171
+ }
172
+ : {
173
+ id: 'Auth.form.password.hide-password',
174
+ defaultMessage: 'Hide password',
175
+ }
176
+ )}
177
+ >
178
+ {passwordShown ? <Show /> : <Hide />}
179
+ </FieldActionWrapper>
180
+ }
142
181
  />
143
182
  </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
- )}
183
+ )}
184
+ </Grid>
185
+ </Flex>
186
+ </Box>
187
+ </ContentLayout>
188
+ </Form>
189
+ );
190
+ }}
191
+ </Formik>
197
192
  </Main>
198
193
  );
199
194
  };
@@ -54,9 +54,7 @@ describe('SettingsPage', () => {
54
54
  it('renders the setting page correctly', async () => {
55
55
  const { getByRole, queryByText, getByText } = render();
56
56
 
57
- expect(queryByText('Plugin settings are loading')).toBeInTheDocument();
58
-
59
- await waitFor(() => expect(queryByText('Plugin settings are loading')).not.toBeInTheDocument());
57
+ await waitFor(() => expect(queryByText('Loading content.')).not.toBeInTheDocument());
60
58
 
61
59
  expect(getByRole('heading', { name: 'Documentation' })).toBeInTheDocument();
62
60
  expect(getByText('Configure the documentation plugin')).toBeInTheDocument();
@@ -81,9 +79,7 @@ describe('SettingsPage', () => {
81
79
 
82
80
  const { getByLabelText, queryByText } = render();
83
81
 
84
- expect(queryByText('Plugin settings are loading')).toBeInTheDocument();
85
-
86
- await waitFor(() => expect(queryByText('Plugin settings are loading')).not.toBeInTheDocument());
82
+ await waitFor(() => expect(queryByText('Loading content.')).not.toBeInTheDocument());
87
83
 
88
84
  expect(getByLabelText('Password')).toBeInTheDocument();
89
85
 
@@ -93,9 +89,7 @@ describe('SettingsPage', () => {
93
89
  it('should render the password field when the Restricted Access checkbox is checked', async () => {
94
90
  const { getByRole, getByLabelText, queryByText } = render();
95
91
 
96
- expect(queryByText('Plugin settings are loading')).toBeInTheDocument();
97
-
98
- await waitFor(() => expect(queryByText('Plugin settings are loading')).not.toBeInTheDocument());
92
+ await waitFor(() => expect(queryByText('Loading content.')).not.toBeInTheDocument());
99
93
 
100
94
  fireEvent.click(getByRole('checkbox', { name: 'Restricted Access' }));
101
95
 
@@ -107,9 +101,7 @@ describe('SettingsPage', () => {
107
101
  it('should allow me to type a password and save that settings change successfully', async () => {
108
102
  const { getByRole, getByLabelText, queryByText, user, getByText } = render();
109
103
 
110
- expect(queryByText('Plugin settings are loading')).toBeInTheDocument();
111
-
112
- await waitFor(() => expect(queryByText('Plugin settings are loading')).not.toBeInTheDocument());
104
+ await waitFor(() => expect(queryByText('Loading content.')).not.toBeInTheDocument());
113
105
 
114
106
  fireEvent.click(getByRole('checkbox', { name: 'Restricted Access' }));
115
107
 
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const react = require("react");
5
+ const designSystem = require("@strapi/design-system");
6
+ const helperPlugin = require("@strapi/helper-plugin");
7
+ const icons = require("@strapi/icons");
8
+ const admin = require("@strapi/strapi/admin");
9
+ const reactHelmet = require("react-helmet");
10
+ const reactIntl = require("react-intl");
11
+ const styled = require("styled-components");
12
+ const index = require("./index-cd8DFPBl.js");
13
+ const useDocumentation = require("./useDocumentation-VA4HgTot.js");
14
+ require("react-query");
15
+ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
16
+ const styled__default = /* @__PURE__ */ _interopDefault(styled);
17
+ const PluginPage = () => {
18
+ helperPlugin.useFocusWhenNavigate();
19
+ const { formatMessage } = reactIntl.useIntl();
20
+ const { data, isLoading, isError, remove, regenerate } = useDocumentation.useDocumentation();
21
+ const [showConfirmDelete, setShowConfirmDelete] = react.useState(false);
22
+ const [isConfirmButtonLoading, setIsConfirmButtonLoading] = react.useState(false);
23
+ const [versionToDelete, setVersionToDelete] = react.useState();
24
+ const { allowedActions } = helperPlugin.useRBAC(index.PERMISSIONS);
25
+ const colCount = 4;
26
+ const rowCount = (data?.docVersions?.length || 0) + 1;
27
+ const handleRegenerateDoc = (version) => {
28
+ regenerate.mutate({ version, prefix: data?.prefix });
29
+ };
30
+ const handleShowConfirmDelete = () => {
31
+ setShowConfirmDelete(!showConfirmDelete);
32
+ };
33
+ const handleConfirmDelete = async () => {
34
+ setIsConfirmButtonLoading(true);
35
+ await remove.mutateAsync({ prefix: data?.prefix, version: versionToDelete });
36
+ setShowConfirmDelete(!showConfirmDelete);
37
+ setIsConfirmButtonLoading(false);
38
+ };
39
+ const handleClickDelete = (version) => {
40
+ setVersionToDelete(version);
41
+ setShowConfirmDelete(!showConfirmDelete);
42
+ };
43
+ const title = formatMessage({
44
+ id: useDocumentation.getTrad("plugin.name"),
45
+ defaultMessage: "Documentation"
46
+ });
47
+ if (isLoading) {
48
+ return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Loading, {});
49
+ }
50
+ if (isError) {
51
+ return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Error, {});
52
+ }
53
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Layout, { children: [
54
+ /* @__PURE__ */ jsxRuntime.jsx(reactHelmet.Helmet, { title }),
55
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Main, { "aria-busy": isLoading, children: [
56
+ /* @__PURE__ */ jsxRuntime.jsx(
57
+ designSystem.HeaderLayout,
58
+ {
59
+ title,
60
+ subtitle: formatMessage({
61
+ id: useDocumentation.getTrad("pages.PluginPage.header.description"),
62
+ defaultMessage: "Configure the documentation plugin"
63
+ }),
64
+ primaryAction: /* @__PURE__ */ jsxRuntime.jsx(
65
+ OpenDocLink,
66
+ {
67
+ disabled: !allowedActions.canOpen || !data?.currentVersion || !data?.prefix,
68
+ href: createDocumentationHref(`${data?.prefix}/v${data?.currentVersion}`),
69
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Eye, {}),
70
+ children: formatMessage({
71
+ id: useDocumentation.getTrad("pages.PluginPage.Button.open"),
72
+ defaultMessage: "Open Documentation"
73
+ })
74
+ }
75
+ )
76
+ }
77
+ ),
78
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.ContentLayout, { children: data?.docVersions.length ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount, rowCount, children: [
79
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
80
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: formatMessage({
81
+ id: useDocumentation.getTrad("pages.PluginPage.table.version"),
82
+ defaultMessage: "Version"
83
+ }) }) }),
84
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: formatMessage({
85
+ id: useDocumentation.getTrad("pages.PluginPage.table.generated"),
86
+ defaultMessage: "Last Generated"
87
+ }) }) })
88
+ ] }) }),
89
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: data.docVersions.sort((a, b) => a.generatedDate < b.generatedDate ? 1 : -1).map((doc) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
90
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { width: "50%", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: doc.version }) }),
91
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { width: "50%", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: doc.generatedDate }) }),
92
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "end", onClick: (e) => e.stopPropagation(), children: [
93
+ /* @__PURE__ */ jsxRuntime.jsx(
94
+ designSystem.IconButton,
95
+ {
96
+ forwardedAs: "a",
97
+ disabled: !allowedActions.canOpen,
98
+ href: createDocumentationHref(`${data.prefix}/v${doc.version}`),
99
+ noBorder: true,
100
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Eye, {}),
101
+ target: "_blank",
102
+ rel: "noopener noreferrer",
103
+ label: formatMessage(
104
+ {
105
+ id: useDocumentation.getTrad("pages.PluginPage.table.icon.show"),
106
+ defaultMessage: "Open {target}"
107
+ },
108
+ { target: `${doc.version}` }
109
+ )
110
+ }
111
+ ),
112
+ allowedActions.canRegenerate ? /* @__PURE__ */ jsxRuntime.jsx(
113
+ designSystem.IconButton,
114
+ {
115
+ onClick: () => handleRegenerateDoc(doc.version),
116
+ noBorder: true,
117
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Refresh, {}),
118
+ label: formatMessage(
119
+ {
120
+ id: useDocumentation.getTrad("pages.PluginPage.table.icon.regenerate"),
121
+ defaultMessage: "Regenerate {target}"
122
+ },
123
+ { target: `${doc.version}` }
124
+ )
125
+ }
126
+ ) : null,
127
+ allowedActions.canUpdate && doc.version !== data.currentVersion ? /* @__PURE__ */ jsxRuntime.jsx(
128
+ designSystem.IconButton,
129
+ {
130
+ onClick: () => handleClickDelete(doc.version),
131
+ noBorder: true,
132
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {}),
133
+ label: formatMessage(
134
+ {
135
+ id: "global.delete-target",
136
+ defaultMessage: "Delete {target}"
137
+ },
138
+ { target: `${doc.version}` }
139
+ )
140
+ }
141
+ ) : null
142
+ ] }) })
143
+ ] }, doc.version)) })
144
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.EmptyStateLayout, {}) }),
145
+ /* @__PURE__ */ jsxRuntime.jsx(
146
+ helperPlugin.ConfirmDialog,
147
+ {
148
+ isConfirmButtonLoading,
149
+ onConfirm: handleConfirmDelete,
150
+ onToggleDialog: handleShowConfirmDelete,
151
+ isOpen: showConfirmDelete
152
+ }
153
+ )
154
+ ] })
155
+ ] });
156
+ };
157
+ const OpenDocLink = styled__default.default(designSystem.LinkButton)`
158
+ text-decoration: none;
159
+ `;
160
+ const createDocumentationHref = (path) => {
161
+ if (path.startsWith("http")) {
162
+ return path;
163
+ }
164
+ if (path.startsWith("/")) {
165
+ return `${window.strapi.backendURL}${path}`;
166
+ }
167
+ return `${window.strapi.backendURL}/${path}`;
168
+ };
169
+ exports.default = PluginPage;
170
+ //# sourceMappingURL=index-2LMgyEch.js.map