@strapi/plugin-documentation 4.0.0-next.8 → 4.0.2
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 +23 -11
- 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 +18 -25
- 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 -175
- package/admin/src/pages/HomePage/useHomePage.js +0 -56
- package/server/policies/index.js +0 -7
- package/server/services/utils/forms.json +0 -29
|
@@ -0,0 +1,612 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, waitFor, screen } from '@testing-library/react';
|
|
3
|
+
import { IntlProvider } from 'react-intl';
|
|
4
|
+
import { QueryClient, QueryClientProvider } from 'react-query';
|
|
5
|
+
import { ThemeProvider, lightTheme } from '@strapi/design-system';
|
|
6
|
+
import { Router } from 'react-router-dom';
|
|
7
|
+
import { createMemoryHistory } from 'history';
|
|
8
|
+
|
|
9
|
+
import SettingsPage from '../index';
|
|
10
|
+
import server from './server';
|
|
11
|
+
|
|
12
|
+
jest.mock('@strapi/helper-plugin', () => ({
|
|
13
|
+
...jest.requireActual('@strapi/helper-plugin'),
|
|
14
|
+
useNotification: jest.fn(),
|
|
15
|
+
CheckPermissions: jest.fn(({ children }) => children),
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
const client = new QueryClient({
|
|
19
|
+
defaultOptions: {
|
|
20
|
+
queries: {
|
|
21
|
+
retry: false,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const makeApp = history => (
|
|
27
|
+
<Router history={history}>
|
|
28
|
+
<ThemeProvider theme={lightTheme}>
|
|
29
|
+
<QueryClientProvider client={client}>
|
|
30
|
+
<IntlProvider locale="en" messages={{}} textComponent="span">
|
|
31
|
+
<SettingsPage />
|
|
32
|
+
</IntlProvider>
|
|
33
|
+
</QueryClientProvider>
|
|
34
|
+
</ThemeProvider>
|
|
35
|
+
</Router>
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
describe('Plugin | Documentation | SettingsPage', () => {
|
|
39
|
+
beforeAll(() => server.listen());
|
|
40
|
+
|
|
41
|
+
beforeEach(() => jest.clearAllMocks());
|
|
42
|
+
|
|
43
|
+
afterEach(() => server.resetHandlers());
|
|
44
|
+
|
|
45
|
+
afterAll(() => server.close());
|
|
46
|
+
|
|
47
|
+
it('renders and matches the snapshot', async () => {
|
|
48
|
+
const history = createMemoryHistory();
|
|
49
|
+
const App = makeApp(history);
|
|
50
|
+
const {
|
|
51
|
+
container: { firstChild },
|
|
52
|
+
} = render(App);
|
|
53
|
+
|
|
54
|
+
await waitFor(() => {
|
|
55
|
+
expect(screen.getByText('Make the documentation endpoint private')).toBeInTheDocument();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
expect(firstChild).toMatchInlineSnapshot(`
|
|
59
|
+
.c14 {
|
|
60
|
+
background: #ffffff;
|
|
61
|
+
padding-top: 24px;
|
|
62
|
+
padding-right: 32px;
|
|
63
|
+
padding-bottom: 24px;
|
|
64
|
+
padding-left: 32px;
|
|
65
|
+
border-radius: 4px;
|
|
66
|
+
box-shadow: 0px 1px 4px rgba(33,33,52,0.1);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.c11 {
|
|
70
|
+
font-weight: 600;
|
|
71
|
+
color: #32324d;
|
|
72
|
+
font-size: 0.75rem;
|
|
73
|
+
line-height: 1.33;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.c8 {
|
|
77
|
+
padding-right: 8px;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.c5 {
|
|
81
|
+
display: -webkit-box;
|
|
82
|
+
display: -webkit-flex;
|
|
83
|
+
display: -ms-flexbox;
|
|
84
|
+
display: flex;
|
|
85
|
+
cursor: pointer;
|
|
86
|
+
padding: 8px;
|
|
87
|
+
border-radius: 4px;
|
|
88
|
+
background: #ffffff;
|
|
89
|
+
border: 1px solid #dcdce4;
|
|
90
|
+
position: relative;
|
|
91
|
+
outline: none;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.c5 svg {
|
|
95
|
+
height: 12px;
|
|
96
|
+
width: 12px;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.c5 svg > g,
|
|
100
|
+
.c5 svg path {
|
|
101
|
+
fill: #ffffff;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.c5[aria-disabled='true'] {
|
|
105
|
+
pointer-events: none;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.c5:after {
|
|
109
|
+
-webkit-transition-property: all;
|
|
110
|
+
transition-property: all;
|
|
111
|
+
-webkit-transition-duration: 0.2s;
|
|
112
|
+
transition-duration: 0.2s;
|
|
113
|
+
border-radius: 8px;
|
|
114
|
+
content: '';
|
|
115
|
+
position: absolute;
|
|
116
|
+
top: -4px;
|
|
117
|
+
bottom: -4px;
|
|
118
|
+
left: -4px;
|
|
119
|
+
right: -4px;
|
|
120
|
+
border: 2px solid transparent;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.c5:focus-visible {
|
|
124
|
+
outline: none;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.c5:focus-visible:after {
|
|
128
|
+
border-radius: 8px;
|
|
129
|
+
content: '';
|
|
130
|
+
position: absolute;
|
|
131
|
+
top: -5px;
|
|
132
|
+
bottom: -5px;
|
|
133
|
+
left: -5px;
|
|
134
|
+
right: -5px;
|
|
135
|
+
border: 2px solid #4945ff;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.c9 {
|
|
139
|
+
height: 100%;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.c6 {
|
|
143
|
+
-webkit-align-items: center;
|
|
144
|
+
-webkit-box-align: center;
|
|
145
|
+
-ms-flex-align: center;
|
|
146
|
+
align-items: center;
|
|
147
|
+
padding: 8px 16px;
|
|
148
|
+
background: #4945ff;
|
|
149
|
+
border: none;
|
|
150
|
+
border: 1px solid #4945ff;
|
|
151
|
+
background: #4945ff;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.c6 .c7 {
|
|
155
|
+
display: -webkit-box;
|
|
156
|
+
display: -webkit-flex;
|
|
157
|
+
display: -ms-flexbox;
|
|
158
|
+
display: flex;
|
|
159
|
+
-webkit-align-items: center;
|
|
160
|
+
-webkit-box-align: center;
|
|
161
|
+
-ms-flex-align: center;
|
|
162
|
+
align-items: center;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.c6 .c10 {
|
|
166
|
+
color: #ffffff;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.c6[aria-disabled='true'] {
|
|
170
|
+
border: 1px solid #dcdce4;
|
|
171
|
+
background: #eaeaef;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.c6[aria-disabled='true'] .c10 {
|
|
175
|
+
color: #666687;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.c6[aria-disabled='true'] svg > g,
|
|
179
|
+
.c6[aria-disabled='true'] svg path {
|
|
180
|
+
fill: #666687;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.c6[aria-disabled='true']:active {
|
|
184
|
+
border: 1px solid #dcdce4;
|
|
185
|
+
background: #eaeaef;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.c6[aria-disabled='true']:active .c10 {
|
|
189
|
+
color: #666687;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.c6[aria-disabled='true']:active svg > g,
|
|
193
|
+
.c6[aria-disabled='true']:active svg path {
|
|
194
|
+
fill: #666687;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.c6:hover {
|
|
198
|
+
border: 1px solid #7b79ff;
|
|
199
|
+
background: #7b79ff;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.c6:active {
|
|
203
|
+
border: 1px solid #4945ff;
|
|
204
|
+
background: #4945ff;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.c15 {
|
|
208
|
+
display: -webkit-box;
|
|
209
|
+
display: -webkit-flex;
|
|
210
|
+
display: -ms-flexbox;
|
|
211
|
+
display: flex;
|
|
212
|
+
-webkit-flex-direction: column;
|
|
213
|
+
-ms-flex-direction: column;
|
|
214
|
+
flex-direction: column;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.c15 > * {
|
|
218
|
+
margin-top: 0;
|
|
219
|
+
margin-bottom: 0;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.c15 > * + * {
|
|
223
|
+
margin-top: 16px;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.c22 {
|
|
227
|
+
font-weight: 600;
|
|
228
|
+
color: #32324d;
|
|
229
|
+
font-size: 0.75rem;
|
|
230
|
+
line-height: 1.33;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.c29 {
|
|
234
|
+
font-weight: 600;
|
|
235
|
+
color: #b72b1a;
|
|
236
|
+
font-size: 0.75rem;
|
|
237
|
+
line-height: 1.33;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.c33 {
|
|
241
|
+
color: #666687;
|
|
242
|
+
font-size: 0.75rem;
|
|
243
|
+
line-height: 1.33;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.c25 {
|
|
247
|
+
background: #ffffff;
|
|
248
|
+
border-radius: 4px;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.c27 {
|
|
252
|
+
background: #fcecea;
|
|
253
|
+
padding-right: 32px;
|
|
254
|
+
padding-left: 32px;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.c30 {
|
|
258
|
+
background: #ffffff;
|
|
259
|
+
padding-right: 32px;
|
|
260
|
+
padding-left: 32px;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.c21 {
|
|
264
|
+
display: -webkit-box;
|
|
265
|
+
display: -webkit-flex;
|
|
266
|
+
display: -ms-flexbox;
|
|
267
|
+
display: flex;
|
|
268
|
+
-webkit-flex-direction: row;
|
|
269
|
+
-ms-flex-direction: row;
|
|
270
|
+
flex-direction: row;
|
|
271
|
+
-webkit-align-items: center;
|
|
272
|
+
-webkit-box-align: center;
|
|
273
|
+
-ms-flex-align: center;
|
|
274
|
+
align-items: center;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.c20 {
|
|
278
|
+
display: -webkit-box;
|
|
279
|
+
display: -webkit-flex;
|
|
280
|
+
display: -ms-flexbox;
|
|
281
|
+
display: flex;
|
|
282
|
+
-webkit-flex-direction: column;
|
|
283
|
+
-ms-flex-direction: column;
|
|
284
|
+
flex-direction: column;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.c20 > * {
|
|
288
|
+
margin-top: 0;
|
|
289
|
+
margin-bottom: 0;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.c20 > * + * {
|
|
293
|
+
margin-top: 4px;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.c24 {
|
|
297
|
+
border: 0;
|
|
298
|
+
-webkit-clip: rect(0 0 0 0);
|
|
299
|
+
clip: rect(0 0 0 0);
|
|
300
|
+
height: 1px;
|
|
301
|
+
margin: -1px;
|
|
302
|
+
overflow: hidden;
|
|
303
|
+
padding: 0;
|
|
304
|
+
position: absolute;
|
|
305
|
+
width: 1px;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.c23 {
|
|
309
|
+
position: relative;
|
|
310
|
+
display: inline-block;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.c26 {
|
|
314
|
+
height: 2.5rem;
|
|
315
|
+
border: 1px solid #dcdce4;
|
|
316
|
+
display: -webkit-inline-box;
|
|
317
|
+
display: -webkit-inline-flex;
|
|
318
|
+
display: -ms-inline-flexbox;
|
|
319
|
+
display: inline-flex;
|
|
320
|
+
overflow: hidden;
|
|
321
|
+
outline: none;
|
|
322
|
+
box-shadow: 0;
|
|
323
|
+
-webkit-transition-property: border-color,box-shadow,fill;
|
|
324
|
+
transition-property: border-color,box-shadow,fill;
|
|
325
|
+
-webkit-transition-duration: 0.2s;
|
|
326
|
+
transition-duration: 0.2s;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.c26:focus-within {
|
|
330
|
+
border: 1px solid #4945ff;
|
|
331
|
+
box-shadow: #4945ff 0px 0px 0px 2px;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.c31 {
|
|
335
|
+
text-transform: uppercase;
|
|
336
|
+
position: relative;
|
|
337
|
+
z-index: 2;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.c28 {
|
|
341
|
+
text-transform: uppercase;
|
|
342
|
+
border-right: 1px solid #dcdce4;
|
|
343
|
+
position: relative;
|
|
344
|
+
z-index: 2;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.c32 {
|
|
348
|
+
position: absolute;
|
|
349
|
+
z-index: 1;
|
|
350
|
+
left: 4px;
|
|
351
|
+
top: 4px;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
.c19 {
|
|
355
|
+
width: -webkit-fit-content;
|
|
356
|
+
width: -moz-fit-content;
|
|
357
|
+
width: fit-content;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
.c16 {
|
|
361
|
+
color: #32324d;
|
|
362
|
+
font-weight: 500;
|
|
363
|
+
font-size: 1rem;
|
|
364
|
+
line-height: 1.25;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
.c1 {
|
|
368
|
+
background: #f6f6f9;
|
|
369
|
+
padding-top: 40px;
|
|
370
|
+
padding-right: 56px;
|
|
371
|
+
padding-bottom: 40px;
|
|
372
|
+
padding-left: 56px;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
.c13 {
|
|
376
|
+
padding-right: 56px;
|
|
377
|
+
padding-left: 56px;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
.c2 {
|
|
381
|
+
display: -webkit-box;
|
|
382
|
+
display: -webkit-flex;
|
|
383
|
+
display: -ms-flexbox;
|
|
384
|
+
display: flex;
|
|
385
|
+
-webkit-flex-direction: row;
|
|
386
|
+
-ms-flex-direction: row;
|
|
387
|
+
flex-direction: row;
|
|
388
|
+
-webkit-box-pack: justify;
|
|
389
|
+
-webkit-justify-content: space-between;
|
|
390
|
+
-ms-flex-pack: justify;
|
|
391
|
+
justify-content: space-between;
|
|
392
|
+
-webkit-align-items: center;
|
|
393
|
+
-webkit-box-align: center;
|
|
394
|
+
-ms-flex-align: center;
|
|
395
|
+
align-items: center;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
.c3 {
|
|
399
|
+
display: -webkit-box;
|
|
400
|
+
display: -webkit-flex;
|
|
401
|
+
display: -ms-flexbox;
|
|
402
|
+
display: flex;
|
|
403
|
+
-webkit-flex-direction: row;
|
|
404
|
+
-ms-flex-direction: row;
|
|
405
|
+
flex-direction: row;
|
|
406
|
+
-webkit-align-items: center;
|
|
407
|
+
-webkit-box-align: center;
|
|
408
|
+
-ms-flex-align: center;
|
|
409
|
+
align-items: center;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
.c4 {
|
|
413
|
+
color: #32324d;
|
|
414
|
+
font-weight: 600;
|
|
415
|
+
font-size: 2rem;
|
|
416
|
+
line-height: 1.25;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
.c12 {
|
|
420
|
+
color: #666687;
|
|
421
|
+
font-size: 1rem;
|
|
422
|
+
line-height: 1.5;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
.c0:focus-visible {
|
|
426
|
+
outline: none;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
.c17 {
|
|
430
|
+
display: grid;
|
|
431
|
+
grid-template-columns: repeat(12,1fr);
|
|
432
|
+
gap: 16px;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
.c18 {
|
|
436
|
+
grid-column: span 6;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
@media (max-width:68.75rem) {
|
|
440
|
+
.c18 {
|
|
441
|
+
grid-column: span 12;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
@media (max-width:34.375rem) {
|
|
446
|
+
.c18 {
|
|
447
|
+
grid-column: span;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
<main
|
|
452
|
+
aria-labelledby="main-content-title"
|
|
453
|
+
class="c0"
|
|
454
|
+
id="main-content"
|
|
455
|
+
tabindex="-1"
|
|
456
|
+
>
|
|
457
|
+
<form
|
|
458
|
+
action="#"
|
|
459
|
+
novalidate=""
|
|
460
|
+
>
|
|
461
|
+
<div
|
|
462
|
+
style="height: 0px;"
|
|
463
|
+
>
|
|
464
|
+
<div
|
|
465
|
+
class="c1"
|
|
466
|
+
data-strapi-header="true"
|
|
467
|
+
>
|
|
468
|
+
<div
|
|
469
|
+
class="c2"
|
|
470
|
+
>
|
|
471
|
+
<div
|
|
472
|
+
class="c3"
|
|
473
|
+
>
|
|
474
|
+
<h1
|
|
475
|
+
class="c4"
|
|
476
|
+
>
|
|
477
|
+
Documentation
|
|
478
|
+
</h1>
|
|
479
|
+
</div>
|
|
480
|
+
<button
|
|
481
|
+
aria-disabled="false"
|
|
482
|
+
class="c5 c6"
|
|
483
|
+
type="submit"
|
|
484
|
+
>
|
|
485
|
+
<div
|
|
486
|
+
aria-hidden="true"
|
|
487
|
+
class="c7 c8 c9"
|
|
488
|
+
>
|
|
489
|
+
<svg
|
|
490
|
+
fill="none"
|
|
491
|
+
height="1em"
|
|
492
|
+
viewBox="0 0 24 24"
|
|
493
|
+
width="1em"
|
|
494
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
495
|
+
>
|
|
496
|
+
<path
|
|
497
|
+
d="M20.727 2.97a.2.2 0 01.286 0l2.85 2.89a.2.2 0 010 .28L9.554 20.854a.2.2 0 01-.285 0l-9.13-9.243a.2.2 0 010-.281l2.85-2.892a.2.2 0 01.284 0l6.14 6.209L20.726 2.97z"
|
|
498
|
+
fill="#212134"
|
|
499
|
+
/>
|
|
500
|
+
</svg>
|
|
501
|
+
</div>
|
|
502
|
+
<span
|
|
503
|
+
class="c10 c11"
|
|
504
|
+
>
|
|
505
|
+
Save
|
|
506
|
+
</span>
|
|
507
|
+
</button>
|
|
508
|
+
</div>
|
|
509
|
+
<p
|
|
510
|
+
class="c12"
|
|
511
|
+
>
|
|
512
|
+
Configure the documentation plugin
|
|
513
|
+
</p>
|
|
514
|
+
</div>
|
|
515
|
+
</div>
|
|
516
|
+
<div
|
|
517
|
+
class="c13"
|
|
518
|
+
>
|
|
519
|
+
<div
|
|
520
|
+
class="c14"
|
|
521
|
+
>
|
|
522
|
+
<div
|
|
523
|
+
class="c15"
|
|
524
|
+
>
|
|
525
|
+
<h2
|
|
526
|
+
class="c16"
|
|
527
|
+
>
|
|
528
|
+
Settings
|
|
529
|
+
</h2>
|
|
530
|
+
<div
|
|
531
|
+
class="c17"
|
|
532
|
+
>
|
|
533
|
+
<div
|
|
534
|
+
class="c18"
|
|
535
|
+
>
|
|
536
|
+
<div
|
|
537
|
+
class=""
|
|
538
|
+
>
|
|
539
|
+
<div
|
|
540
|
+
class="c19"
|
|
541
|
+
>
|
|
542
|
+
<div
|
|
543
|
+
class="c20"
|
|
544
|
+
>
|
|
545
|
+
<div
|
|
546
|
+
class="c21"
|
|
547
|
+
>
|
|
548
|
+
<label
|
|
549
|
+
class="c22"
|
|
550
|
+
for="field-1"
|
|
551
|
+
>
|
|
552
|
+
Restricted Access
|
|
553
|
+
</label>
|
|
554
|
+
</div>
|
|
555
|
+
<label
|
|
556
|
+
class="c23"
|
|
557
|
+
>
|
|
558
|
+
<div
|
|
559
|
+
class="c24"
|
|
560
|
+
>
|
|
561
|
+
Restricted Access
|
|
562
|
+
</div>
|
|
563
|
+
<div
|
|
564
|
+
class="c25 c26"
|
|
565
|
+
>
|
|
566
|
+
<div
|
|
567
|
+
aria-hidden="true"
|
|
568
|
+
class="c27 c21 c28"
|
|
569
|
+
>
|
|
570
|
+
<span
|
|
571
|
+
class="c29"
|
|
572
|
+
>
|
|
573
|
+
Off
|
|
574
|
+
</span>
|
|
575
|
+
</div>
|
|
576
|
+
<div
|
|
577
|
+
aria-hidden="true"
|
|
578
|
+
class="c30 c21 c31"
|
|
579
|
+
>
|
|
580
|
+
<span
|
|
581
|
+
class="c22"
|
|
582
|
+
>
|
|
583
|
+
On
|
|
584
|
+
</span>
|
|
585
|
+
</div>
|
|
586
|
+
<input
|
|
587
|
+
aria-disabled="false"
|
|
588
|
+
class="c32"
|
|
589
|
+
name="restrictedAccess"
|
|
590
|
+
type="checkbox"
|
|
591
|
+
/>
|
|
592
|
+
</div>
|
|
593
|
+
</label>
|
|
594
|
+
<p
|
|
595
|
+
class="c33"
|
|
596
|
+
id="field-1-hint"
|
|
597
|
+
>
|
|
598
|
+
Make the documentation endpoint private
|
|
599
|
+
</p>
|
|
600
|
+
</div>
|
|
601
|
+
</div>
|
|
602
|
+
</div>
|
|
603
|
+
</div>
|
|
604
|
+
</div>
|
|
605
|
+
</div>
|
|
606
|
+
</div>
|
|
607
|
+
</div>
|
|
608
|
+
</form>
|
|
609
|
+
</main>
|
|
610
|
+
`);
|
|
611
|
+
});
|
|
612
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
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(100),
|
|
8
|
+
ctx.status(200),
|
|
9
|
+
ctx.json({
|
|
10
|
+
documentationAccess: { restrictedAccess: false },
|
|
11
|
+
})
|
|
12
|
+
);
|
|
13
|
+
}),
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
const server = setupServer(...handlers);
|
|
17
|
+
|
|
18
|
+
export default server;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { request } from '@strapi/helper-plugin';
|
|
2
|
-
import pluginId from '
|
|
2
|
+
import pluginId from '../../pluginId';
|
|
3
3
|
|
|
4
4
|
const deleteDoc = ({ prefix, version }) => {
|
|
5
5
|
return request(`${prefix}/deleteDoc/${version}`, { method: 'DELETE' });
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const fetchDocumentationVersions = async toggleNotification => {
|
|
9
9
|
try {
|
|
10
10
|
const data = await request(`/${pluginId}/getInfos`, { method: 'GET' });
|
|
11
11
|
|
|
@@ -25,6 +25,7 @@ const regenerateDoc = ({ prefix, version }) => {
|
|
|
25
25
|
return request(`${prefix}/regenerateDoc`, { method: 'POST', body: { version } });
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
const
|
|
28
|
+
const updateSettings = ({ prefix, body }) =>
|
|
29
|
+
request(`${prefix}/updateSettings`, { method: 'PUT', body });
|
|
29
30
|
|
|
30
|
-
export { deleteDoc,
|
|
31
|
+
export { deleteDoc, fetchDocumentationVersions, regenerateDoc, updateSettings };
|
|
File without changes
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useQuery, useMutation, useQueryClient } from 'react-query';
|
|
2
|
+
import { useNotification } from '@strapi/helper-plugin';
|
|
3
|
+
import { fetchDocumentationVersions, deleteDoc, regenerateDoc, updateSettings } from './api';
|
|
4
|
+
import getTrad from '../../utils/getTrad';
|
|
5
|
+
|
|
6
|
+
const useReactQuery = () => {
|
|
7
|
+
const queryClient = useQueryClient();
|
|
8
|
+
const toggleNotification = useNotification();
|
|
9
|
+
const { isLoading, data } = useQuery('get-documentation', () =>
|
|
10
|
+
fetchDocumentationVersions(toggleNotification)
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
const handleError = err => {
|
|
14
|
+
toggleNotification({
|
|
15
|
+
type: 'warning',
|
|
16
|
+
message: err.response.payload.message,
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const handleSuccess = (type, tradId) => {
|
|
21
|
+
queryClient.invalidateQueries('get-documentation');
|
|
22
|
+
toggleNotification({
|
|
23
|
+
type,
|
|
24
|
+
message: { id: getTrad(tradId) },
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const deleteMutation = useMutation(deleteDoc, {
|
|
29
|
+
onSuccess: () => handleSuccess('info', 'notification.delete.success'),
|
|
30
|
+
onError: error => handleError(error),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const submitMutation = useMutation(updateSettings, {
|
|
34
|
+
onSuccess: () => handleSuccess('success', 'notification.update.success'),
|
|
35
|
+
onError: handleError,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const regenerateDocMutation = useMutation(regenerateDoc, {
|
|
39
|
+
onSuccess: () => handleSuccess('info', 'notification.generate.success'),
|
|
40
|
+
onError: error => handleError(error),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return { data, isLoading, deleteMutation, submitMutation, regenerateDocMutation };
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default useReactQuery;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"components.Row.generatedDate": "Last generation",
|
|
3
2
|
"components.Row.open": "Open",
|
|
4
3
|
"components.Row.regenerate": "Regenerate",
|
|
5
4
|
"containers.HomePage.Block.title": "Versions",
|
|
6
|
-
"containers.HomePage.Button.open": "Open the documentation",
|
|
7
5
|
"containers.HomePage.Button.update": "Update",
|
|
8
|
-
"containers.HomePage.PluginHeader.description": "Configure the documentation plugin",
|
|
9
6
|
"containers.HomePage.PluginHeader.title": "Documentation - Settings",
|
|
10
7
|
"containers.HomePage.PopUpWarning.confirm": "I understand",
|
|
11
8
|
"containers.HomePage.PopUpWarning.message": "Are you sure you want to delete this version?",
|