@strapi/content-manager 0.0.0-experimental.25e22c6cc9bc6b35392bb55d09f641a0a65e7403 → 0.0.0-experimental.312e2942332daff7ae98a4f357d1913a4ae5e1ef
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/LICENSE +18 -3
- package/dist/_chunks/{ComponentConfigurationPage-WRPUXGd6.js → ComponentConfigurationPage-BfOUhLa9.js} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-WRPUXGd6.js.map → ComponentConfigurationPage-BfOUhLa9.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-gdUj_t-O.mjs → ComponentConfigurationPage-DgDrdk-k.mjs} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-gdUj_t-O.mjs.map → ComponentConfigurationPage-DgDrdk-k.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-C1vjMBgy.js → EditConfigurationPage-BcXQLYY9.js} +3 -3
- package/dist/_chunks/{EditConfigurationPage-C1vjMBgy.js.map → EditConfigurationPage-BcXQLYY9.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-BwuIPOJG.mjs → EditConfigurationPage-CjV1kPAw.mjs} +3 -3
- package/dist/_chunks/{EditConfigurationPage-BwuIPOJG.mjs.map → EditConfigurationPage-CjV1kPAw.mjs.map} +1 -1
- package/dist/_chunks/{EditViewPage-DbcGfyqK.js → EditViewPage-BOeuvemd.js} +19 -8
- package/dist/_chunks/EditViewPage-BOeuvemd.js.map +1 -0
- package/dist/_chunks/{EditViewPage-0MiFkXa8.mjs → EditViewPage-s_bjnR0M.mjs} +19 -8
- package/dist/_chunks/EditViewPage-s_bjnR0M.mjs.map +1 -0
- package/dist/_chunks/{Field-BG1xu38N.js → Field-CvfOxLel.js} +465 -145
- package/dist/_chunks/Field-CvfOxLel.js.map +1 -0
- package/dist/_chunks/{Field-BDMSCcy5.mjs → Field-D9nHkdjy.mjs} +463 -143
- package/dist/_chunks/Field-D9nHkdjy.mjs.map +1 -0
- package/dist/_chunks/{Form-9BnFyUjy.js → Form-BKnDhP2B.js} +39 -17
- package/dist/_chunks/Form-BKnDhP2B.js.map +1 -0
- package/dist/_chunks/{Form-CPVWavB8.mjs → Form-G4C35wJ4.mjs} +39 -17
- package/dist/_chunks/Form-G4C35wJ4.mjs.map +1 -0
- package/dist/_chunks/{History-BWWxLt2Z.js → History-BIYOzHws.js} +44 -19
- package/dist/_chunks/History-BIYOzHws.js.map +1 -0
- package/dist/_chunks/{History-BVpd8LP3.mjs → History-FWwaCNUD.mjs} +44 -19
- package/dist/_chunks/History-FWwaCNUD.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-DozVMKcR.mjs → ListConfigurationPage-BbOp66T2.mjs} +20 -8
- package/dist/_chunks/ListConfigurationPage-BbOp66T2.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-6swzjdAZ.js → ListConfigurationPage-N7prXhOp.js} +20 -8
- package/dist/_chunks/ListConfigurationPage-N7prXhOp.js.map +1 -0
- package/dist/_chunks/{ListViewPage-Ds0ulgfG.mjs → ListViewPage-DTSW3r3X.mjs} +58 -40
- package/dist/_chunks/ListViewPage-DTSW3r3X.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-BlzfjS2Q.js → ListViewPage-Djc5M_c0.js} +60 -42
- package/dist/_chunks/ListViewPage-Djc5M_c0.js.map +1 -0
- package/dist/_chunks/{NoContentTypePage-BH11kaKt.mjs → NoContentTypePage-A-6Pk0le.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-BH11kaKt.mjs.map → NoContentTypePage-A-6Pk0le.mjs.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-D2nCCWEl.js → NoContentTypePage-DCX-hEMB.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-D2nCCWEl.js.map → NoContentTypePage-DCX-hEMB.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-BT2Tn0D_.mjs → NoPermissionsPage-B0vWytDx.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-BT2Tn0D_.mjs.map → NoPermissionsPage-B0vWytDx.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-DN_JlsU2.js → NoPermissionsPage-PfJfspJV.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-DN_JlsU2.js.map → NoPermissionsPage-PfJfspJV.js.map} +1 -1
- package/dist/_chunks/{Relations-CcgFTcWo.js → Relations--9jwQ8HV.js} +4 -4
- package/dist/_chunks/Relations--9jwQ8HV.js.map +1 -0
- package/dist/_chunks/{Relations-Dnag3fhV.mjs → Relations-Ccdfw1dU.mjs} +4 -4
- package/dist/_chunks/Relations-Ccdfw1dU.mjs.map +1 -0
- package/dist/_chunks/{en-fbKQxLGn.js → en-BVzUkPxZ.js} +10 -8
- package/dist/_chunks/{en-fbKQxLGn.js.map → en-BVzUkPxZ.js.map} +1 -1
- package/dist/_chunks/{en-Ux26r5pl.mjs → en-CPTj6CjC.mjs} +10 -8
- package/dist/_chunks/{en-Ux26r5pl.mjs.map → en-CPTj6CjC.mjs.map} +1 -1
- package/dist/_chunks/{index-JNNNKUHs.mjs → index-BwqXeHiv.mjs} +464 -196
- package/dist/_chunks/index-BwqXeHiv.mjs.map +1 -0
- package/dist/_chunks/{index-CWpLBSt0.js → index-jun-ZqyN.js} +457 -189
- package/dist/_chunks/index-jun-ZqyN.js.map +1 -0
- package/dist/_chunks/{layout-DC503LnF.mjs → layout-BV5oiZQ9.mjs} +27 -14
- package/dist/_chunks/layout-BV5oiZQ9.mjs.map +1 -0
- package/dist/_chunks/{layout--iHdZzRk.js → layout-T2xBqmuZ.js} +25 -12
- package/dist/_chunks/layout-T2xBqmuZ.js.map +1 -0
- package/dist/_chunks/{relations-BbHizA5K.js → relations-D8jegO_8.js} +2 -2
- package/dist/_chunks/{relations-BbHizA5K.js.map → relations-D8jegO_8.js.map} +1 -1
- package/dist/_chunks/{relations-CTje5t-a.mjs → relations-wAeF76DP.mjs} +2 -2
- package/dist/_chunks/{relations-CTje5t-a.mjs.map → relations-wAeF76DP.mjs.map} +1 -1
- package/dist/_chunks/{usePrev-B9w_-eYc.js → useDebounce-CtcjDB3L.js} +14 -1
- package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -0
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs +29 -0
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/history/index.d.ts +3 -0
- package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
- package/dist/admin/src/index.d.ts +1 -0
- package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +1 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +4 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +20 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +4 -48
- package/dist/admin/src/pages/EditView/components/Header.d.ts +10 -11
- package/dist/admin/src/services/api.d.ts +1 -1
- package/dist/admin/src/services/components.d.ts +2 -2
- package/dist/admin/src/services/contentTypes.d.ts +3 -3
- package/dist/admin/src/services/documents.d.ts +19 -17
- package/dist/admin/src/services/init.d.ts +1 -1
- package/dist/admin/src/services/relations.d.ts +2 -2
- package/dist/admin/src/services/uid.d.ts +3 -3
- package/dist/admin/src/utils/validation.d.ts +4 -1
- package/dist/server/index.js +184 -112
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +185 -113
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
- package/dist/server/src/controllers/relations.d.ts.map +1 -1
- package/dist/server/src/controllers/uid.d.ts.map +1 -1
- package/dist/server/src/controllers/validation/dimensions.d.ts +4 -2
- package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -1
- package/dist/server/src/history/services/history.d.ts.map +1 -1
- package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
- package/dist/server/src/history/services/utils.d.ts +2 -1
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
- package/dist/server/src/services/document-manager.d.ts.map +1 -1
- package/dist/server/src/services/document-metadata.d.ts.map +1 -1
- package/dist/server/src/services/permission-checker.d.ts.map +1 -1
- package/dist/server/src/services/utils/populate.d.ts.map +1 -1
- package/dist/shared/contracts/collection-types.d.ts +3 -1
- package/dist/shared/contracts/collection-types.d.ts.map +1 -1
- package/package.json +9 -9
- package/dist/_chunks/EditViewPage-0MiFkXa8.mjs.map +0 -1
- package/dist/_chunks/EditViewPage-DbcGfyqK.js.map +0 -1
- package/dist/_chunks/Field-BDMSCcy5.mjs.map +0 -1
- package/dist/_chunks/Field-BG1xu38N.js.map +0 -1
- package/dist/_chunks/Form-9BnFyUjy.js.map +0 -1
- package/dist/_chunks/Form-CPVWavB8.mjs.map +0 -1
- package/dist/_chunks/History-BVpd8LP3.mjs.map +0 -1
- package/dist/_chunks/History-BWWxLt2Z.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-6swzjdAZ.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-DozVMKcR.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-BlzfjS2Q.js.map +0 -1
- package/dist/_chunks/ListViewPage-Ds0ulgfG.mjs.map +0 -1
- package/dist/_chunks/Relations-CcgFTcWo.js.map +0 -1
- package/dist/_chunks/Relations-Dnag3fhV.mjs.map +0 -1
- package/dist/_chunks/index-CWpLBSt0.js.map +0 -1
- package/dist/_chunks/index-JNNNKUHs.mjs.map +0 -1
- package/dist/_chunks/layout--iHdZzRk.js.map +0 -1
- package/dist/_chunks/layout-DC503LnF.mjs.map +0 -1
- package/dist/_chunks/usePrev-B9w_-eYc.js.map +0 -1
- package/dist/_chunks/usePrev-DH6iah0A.mjs +0 -16
- package/dist/_chunks/usePrev-DH6iah0A.mjs.map +0 -1
@@ -2,15 +2,15 @@
|
|
2
2
|
const Icons = require("@strapi/icons");
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
4
4
|
const strapiAdmin = require("@strapi/admin/strapi-admin");
|
5
|
-
const qs = require("qs");
|
6
|
-
const reactIntl = require("react-intl");
|
7
|
-
const reactRouterDom = require("react-router-dom");
|
8
5
|
const React = require("react");
|
9
6
|
const designSystem = require("@strapi/design-system");
|
10
|
-
const
|
7
|
+
const reactIntl = require("react-intl");
|
8
|
+
const reactRouterDom = require("react-router-dom");
|
11
9
|
const yup = require("yup");
|
12
10
|
const pipe = require("lodash/fp/pipe");
|
13
11
|
const dateFns = require("date-fns");
|
12
|
+
const styledComponents = require("styled-components");
|
13
|
+
const qs = require("qs");
|
14
14
|
const toolkit = require("@reduxjs/toolkit");
|
15
15
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
16
16
|
function _interopNamespace(e) {
|
@@ -70,42 +70,6 @@ const useInjectionZone = (area) => {
|
|
70
70
|
const [page, position] = area.split(".");
|
71
71
|
return contentManagerPlugin.getInjectedComponents(page, position);
|
72
72
|
};
|
73
|
-
const HistoryAction = ({ model, document }) => {
|
74
|
-
const { formatMessage } = reactIntl.useIntl();
|
75
|
-
const [{ query }] = strapiAdmin.useQueryParams();
|
76
|
-
const navigate = reactRouterDom.useNavigate();
|
77
|
-
const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
|
78
|
-
if (!window.strapi.features.isEnabled("cms-content-history")) {
|
79
|
-
return null;
|
80
|
-
}
|
81
|
-
return {
|
82
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
|
83
|
-
label: formatMessage({
|
84
|
-
id: "content-manager.history.document-action",
|
85
|
-
defaultMessage: "Content History"
|
86
|
-
}),
|
87
|
-
onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
|
88
|
-
disabled: (
|
89
|
-
/**
|
90
|
-
* The user is creating a new document.
|
91
|
-
* It hasn't been saved yet, so there's no history to go to
|
92
|
-
*/
|
93
|
-
!document || /**
|
94
|
-
* The document has been created but the current dimension has never been saved.
|
95
|
-
* For example, the user is creating a new locale in an existing document,
|
96
|
-
* so there's no history for the document in that locale
|
97
|
-
*/
|
98
|
-
!document.id || /**
|
99
|
-
* History is only available for content types created by the user.
|
100
|
-
* These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
|
101
|
-
* which start with `admin::` or `plugin::`
|
102
|
-
*/
|
103
|
-
!model.startsWith("api::")
|
104
|
-
),
|
105
|
-
position: "header"
|
106
|
-
};
|
107
|
-
};
|
108
|
-
HistoryAction.type = "history";
|
109
73
|
const ID = "id";
|
110
74
|
const CREATED_BY_ATTRIBUTE_NAME = "createdBy";
|
111
75
|
const UPDATED_BY_ATTRIBUTE_NAME = "updatedBy";
|
@@ -215,10 +179,12 @@ const contentManagerApi = strapiAdmin.adminApi.enhanceEndpoints({
|
|
215
179
|
"Document",
|
216
180
|
"InitialData",
|
217
181
|
"HistoryVersion",
|
218
|
-
"Relations"
|
182
|
+
"Relations",
|
183
|
+
"UidAvailability"
|
219
184
|
]
|
220
185
|
});
|
221
186
|
const documentApi = contentManagerApi.injectEndpoints({
|
187
|
+
overrideExisting: true,
|
222
188
|
endpoints: (builder) => ({
|
223
189
|
autoCloneDocument: builder.mutation({
|
224
190
|
query: ({ model, sourceId, query }) => ({
|
@@ -228,7 +194,12 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
228
194
|
params: query
|
229
195
|
}
|
230
196
|
}),
|
231
|
-
invalidatesTags: (_result,
|
197
|
+
invalidatesTags: (_result, error, { model }) => {
|
198
|
+
if (error) {
|
199
|
+
return [];
|
200
|
+
}
|
201
|
+
return [{ type: "Document", id: `${model}_LIST` }];
|
202
|
+
}
|
232
203
|
}),
|
233
204
|
cloneDocument: builder.mutation({
|
234
205
|
query: ({ model, sourceId, data, params }) => ({
|
@@ -239,7 +210,10 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
239
210
|
params
|
240
211
|
}
|
241
212
|
}),
|
242
|
-
invalidatesTags: (_result, _error, { model }) => [
|
213
|
+
invalidatesTags: (_result, _error, { model }) => [
|
214
|
+
{ type: "Document", id: `${model}_LIST` },
|
215
|
+
{ type: "UidAvailability", id: model }
|
216
|
+
]
|
243
217
|
}),
|
244
218
|
/**
|
245
219
|
* Creates a new collection-type document. This should ONLY be used for collection-types.
|
@@ -256,7 +230,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
256
230
|
}),
|
257
231
|
invalidatesTags: (result, _error, { model }) => [
|
258
232
|
{ type: "Document", id: `${model}_LIST` },
|
259
|
-
"Relations"
|
233
|
+
"Relations",
|
234
|
+
{ type: "UidAvailability", id: model }
|
260
235
|
]
|
261
236
|
}),
|
262
237
|
deleteDocument: builder.mutation({
|
@@ -297,7 +272,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
297
272
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
298
273
|
},
|
299
274
|
{ type: "Document", id: `${model}_LIST` },
|
300
|
-
"Relations"
|
275
|
+
"Relations",
|
276
|
+
{ type: "UidAvailability", id: model }
|
301
277
|
];
|
302
278
|
}
|
303
279
|
}),
|
@@ -315,6 +291,7 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
315
291
|
}),
|
316
292
|
providesTags: (result, _error, arg) => {
|
317
293
|
return [
|
294
|
+
{ type: "Document", id: `ALL_LIST` },
|
318
295
|
{ type: "Document", id: `${arg.model}_LIST` },
|
319
296
|
...result?.results.map(({ documentId }) => ({
|
320
297
|
type: "Document",
|
@@ -353,6 +330,11 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
353
330
|
{
|
354
331
|
type: "Document",
|
355
332
|
id: collectionType !== SINGLE_TYPES ? `${model}_${result && "documentId" in result ? result.documentId : documentId}` : model
|
333
|
+
},
|
334
|
+
// Make it easy to invalidate all individual documents queries for a model
|
335
|
+
{
|
336
|
+
type: "Document",
|
337
|
+
id: `${model}_ALL_ITEMS`
|
356
338
|
}
|
357
339
|
];
|
358
340
|
}
|
@@ -416,8 +398,21 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
416
398
|
type: "Document",
|
417
399
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
418
400
|
},
|
419
|
-
"Relations"
|
401
|
+
"Relations",
|
402
|
+
{ type: "UidAvailability", id: model }
|
420
403
|
];
|
404
|
+
},
|
405
|
+
async onQueryStarted({ data, ...patch }, { dispatch, queryFulfilled }) {
|
406
|
+
const patchResult = dispatch(
|
407
|
+
documentApi.util.updateQueryData("getDocument", patch, (draft) => {
|
408
|
+
Object.assign(draft.data, data);
|
409
|
+
})
|
410
|
+
);
|
411
|
+
try {
|
412
|
+
await queryFulfilled;
|
413
|
+
} catch {
|
414
|
+
patchResult.undo();
|
415
|
+
}
|
421
416
|
}
|
422
417
|
}),
|
423
418
|
unpublishDocument: builder.mutation({
|
@@ -487,7 +482,7 @@ const buildValidParams = (query) => {
|
|
487
482
|
const isBaseQueryError = (error) => {
|
488
483
|
return error.name !== void 0;
|
489
484
|
};
|
490
|
-
const createYupSchema = (attributes = {}, components = {}) => {
|
485
|
+
const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
|
491
486
|
const createModelSchema = (attributes2) => yup__namespace.object().shape(
|
492
487
|
Object.entries(attributes2).reduce((acc, [name, attribute]) => {
|
493
488
|
if (DOCUMENT_META_FIELDS.includes(name)) {
|
@@ -500,7 +495,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
500
495
|
addMinValidation,
|
501
496
|
addMaxValidation,
|
502
497
|
addRegexValidation
|
503
|
-
].map((fn) => fn(attribute));
|
498
|
+
].map((fn) => fn(attribute, options));
|
504
499
|
const transformSchema = pipe__default.default(...validations);
|
505
500
|
switch (attribute.type) {
|
506
501
|
case "component": {
|
@@ -601,6 +596,14 @@ const createAttributeSchema = (attribute) => {
|
|
601
596
|
if (!value || typeof value === "string" && value.length === 0) {
|
602
597
|
return true;
|
603
598
|
}
|
599
|
+
if (typeof value === "object") {
|
600
|
+
try {
|
601
|
+
JSON.stringify(value);
|
602
|
+
return true;
|
603
|
+
} catch (err) {
|
604
|
+
return false;
|
605
|
+
}
|
606
|
+
}
|
604
607
|
try {
|
605
608
|
JSON.parse(value);
|
606
609
|
return true;
|
@@ -619,13 +622,7 @@ const createAttributeSchema = (attribute) => {
|
|
619
622
|
return yup__namespace.mixed();
|
620
623
|
}
|
621
624
|
};
|
622
|
-
const
|
623
|
-
if (attribute.required) {
|
624
|
-
return schema.required({
|
625
|
-
id: strapiAdmin.translatedErrors.required.id,
|
626
|
-
defaultMessage: "This field is required."
|
627
|
-
});
|
628
|
-
}
|
625
|
+
const nullableSchema = (schema) => {
|
629
626
|
return schema?.nullable ? schema.nullable() : (
|
630
627
|
// In some cases '.nullable' will not be available on the schema.
|
631
628
|
// e.g. when the schema has been built using yup.lazy (e.g. for relations).
|
@@ -633,7 +630,22 @@ const addRequiredValidation = (attribute) => (schema) => {
|
|
633
630
|
schema
|
634
631
|
);
|
635
632
|
};
|
636
|
-
const
|
633
|
+
const addRequiredValidation = (attribute, options) => (schema) => {
|
634
|
+
if (options.status === "draft") {
|
635
|
+
return nullableSchema(schema);
|
636
|
+
}
|
637
|
+
if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
|
638
|
+
return schema.min(1, strapiAdmin.translatedErrors.required);
|
639
|
+
}
|
640
|
+
if (attribute.required && attribute.type !== "relation") {
|
641
|
+
return schema.required(strapiAdmin.translatedErrors.required);
|
642
|
+
}
|
643
|
+
return nullableSchema(schema);
|
644
|
+
};
|
645
|
+
const addMinLengthValidation = (attribute, options) => (schema) => {
|
646
|
+
if (options.status === "draft") {
|
647
|
+
return schema;
|
648
|
+
}
|
637
649
|
if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
|
638
650
|
return schema.min(attribute.minLength, {
|
639
651
|
...strapiAdmin.translatedErrors.minLength,
|
@@ -655,9 +667,31 @@ const addMaxLengthValidation = (attribute) => (schema) => {
|
|
655
667
|
}
|
656
668
|
return schema;
|
657
669
|
};
|
658
|
-
const addMinValidation = (attribute) => (schema) => {
|
670
|
+
const addMinValidation = (attribute, options) => (schema) => {
|
659
671
|
if ("min" in attribute) {
|
660
672
|
const min = toInteger(attribute.min);
|
673
|
+
if (attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") {
|
674
|
+
if (options.status !== "draft" && !attribute.required && "test" in schema && min) {
|
675
|
+
return schema.test(
|
676
|
+
"custom-min",
|
677
|
+
{
|
678
|
+
...strapiAdmin.translatedErrors.min,
|
679
|
+
values: {
|
680
|
+
min: attribute.min
|
681
|
+
}
|
682
|
+
},
|
683
|
+
(value) => {
|
684
|
+
if (!value) {
|
685
|
+
return true;
|
686
|
+
}
|
687
|
+
if (Array.isArray(value) && value.length === 0) {
|
688
|
+
return true;
|
689
|
+
}
|
690
|
+
return value.length >= min;
|
691
|
+
}
|
692
|
+
);
|
693
|
+
}
|
694
|
+
}
|
661
695
|
if ("min" in schema && min) {
|
662
696
|
return schema.min(min, {
|
663
697
|
...strapiAdmin.translatedErrors.min,
|
@@ -784,7 +818,10 @@ const useDocument = (args, opts) => {
|
|
784
818
|
isLoading: isLoadingDocument,
|
785
819
|
isFetching: isFetchingDocument,
|
786
820
|
error
|
787
|
-
} = useGetDocumentQuery(args,
|
821
|
+
} = useGetDocumentQuery(args, {
|
822
|
+
...opts,
|
823
|
+
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
824
|
+
});
|
788
825
|
const { components, schema, isLoading: isLoadingSchema } = useContentTypeSchema(args.model);
|
789
826
|
React__namespace.useEffect(() => {
|
790
827
|
if (error) {
|
@@ -870,6 +907,8 @@ const useDocumentActions = () => {
|
|
870
907
|
const { formatMessage } = reactIntl.useIntl();
|
871
908
|
const { trackUsage } = strapiAdmin.useTracking();
|
872
909
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
910
|
+
const navigate = reactRouterDom.useNavigate();
|
911
|
+
const setCurrentStep = strapiAdmin.useGuidedTour("useDocumentActions", (state) => state.setCurrentStep);
|
873
912
|
const [deleteDocument] = useDeleteDocumentMutation();
|
874
913
|
const _delete = React__namespace.useCallback(
|
875
914
|
async ({ collectionType, model, documentId, params }, trackerProperty) => {
|
@@ -1184,6 +1223,7 @@ const useDocumentActions = () => {
|
|
1184
1223
|
defaultMessage: "Saved document"
|
1185
1224
|
})
|
1186
1225
|
});
|
1226
|
+
setCurrentStep("contentManager.success");
|
1187
1227
|
return res.data;
|
1188
1228
|
} catch (err) {
|
1189
1229
|
toggleNotification({
|
@@ -1205,7 +1245,6 @@ const useDocumentActions = () => {
|
|
1205
1245
|
sourceId
|
1206
1246
|
});
|
1207
1247
|
if ("error" in res) {
|
1208
|
-
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1209
1248
|
return { error: res.error };
|
1210
1249
|
}
|
1211
1250
|
toggleNotification({
|
@@ -1224,7 +1263,7 @@ const useDocumentActions = () => {
|
|
1224
1263
|
throw err;
|
1225
1264
|
}
|
1226
1265
|
},
|
1227
|
-
[autoCloneDocument,
|
1266
|
+
[autoCloneDocument, formatMessage, toggleNotification]
|
1228
1267
|
);
|
1229
1268
|
const [cloneDocument] = useCloneDocumentMutation();
|
1230
1269
|
const clone = React__namespace.useCallback(
|
@@ -1250,6 +1289,7 @@ const useDocumentActions = () => {
|
|
1250
1289
|
defaultMessage: "Cloned document"
|
1251
1290
|
})
|
1252
1291
|
});
|
1292
|
+
navigate(`../../${res.data.data.documentId}`, { relative: "path" });
|
1253
1293
|
return res.data;
|
1254
1294
|
} catch (err) {
|
1255
1295
|
toggleNotification({
|
@@ -1260,7 +1300,7 @@ const useDocumentActions = () => {
|
|
1260
1300
|
throw err;
|
1261
1301
|
}
|
1262
1302
|
},
|
1263
|
-
[cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError]
|
1303
|
+
[cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError, navigate]
|
1264
1304
|
);
|
1265
1305
|
const [getDoc] = useLazyGetDocumentQuery();
|
1266
1306
|
const getDocument = React__namespace.useCallback(
|
@@ -1286,7 +1326,7 @@ const useDocumentActions = () => {
|
|
1286
1326
|
};
|
1287
1327
|
};
|
1288
1328
|
const ProtectedHistoryPage = React.lazy(
|
1289
|
-
() => Promise.resolve().then(() => require("./History-
|
1329
|
+
() => Promise.resolve().then(() => require("./History-BIYOzHws.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
|
1290
1330
|
);
|
1291
1331
|
const routes$1 = [
|
1292
1332
|
{
|
@@ -1299,31 +1339,31 @@ const routes$1 = [
|
|
1299
1339
|
}
|
1300
1340
|
];
|
1301
1341
|
const ProtectedEditViewPage = React.lazy(
|
1302
|
-
() => Promise.resolve().then(() => require("./EditViewPage-
|
1342
|
+
() => Promise.resolve().then(() => require("./EditViewPage-BOeuvemd.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
|
1303
1343
|
);
|
1304
1344
|
const ProtectedListViewPage = React.lazy(
|
1305
|
-
() => Promise.resolve().then(() => require("./ListViewPage-
|
1345
|
+
() => Promise.resolve().then(() => require("./ListViewPage-Djc5M_c0.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
|
1306
1346
|
);
|
1307
1347
|
const ProtectedListConfiguration = React.lazy(
|
1308
|
-
() => Promise.resolve().then(() => require("./ListConfigurationPage-
|
1348
|
+
() => Promise.resolve().then(() => require("./ListConfigurationPage-N7prXhOp.js")).then((mod) => ({
|
1309
1349
|
default: mod.ProtectedListConfiguration
|
1310
1350
|
}))
|
1311
1351
|
);
|
1312
1352
|
const ProtectedEditConfigurationPage = React.lazy(
|
1313
|
-
() => Promise.resolve().then(() => require("./EditConfigurationPage-
|
1353
|
+
() => Promise.resolve().then(() => require("./EditConfigurationPage-BcXQLYY9.js")).then((mod) => ({
|
1314
1354
|
default: mod.ProtectedEditConfigurationPage
|
1315
1355
|
}))
|
1316
1356
|
);
|
1317
1357
|
const ProtectedComponentConfigurationPage = React.lazy(
|
1318
|
-
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-
|
1358
|
+
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-BfOUhLa9.js")).then((mod) => ({
|
1319
1359
|
default: mod.ProtectedComponentConfigurationPage
|
1320
1360
|
}))
|
1321
1361
|
);
|
1322
1362
|
const NoPermissions = React.lazy(
|
1323
|
-
() => Promise.resolve().then(() => require("./NoPermissionsPage-
|
1363
|
+
() => Promise.resolve().then(() => require("./NoPermissionsPage-PfJfspJV.js")).then((mod) => ({ default: mod.NoPermissions }))
|
1324
1364
|
);
|
1325
1365
|
const NoContentType = React.lazy(
|
1326
|
-
() => Promise.resolve().then(() => require("./NoContentTypePage-
|
1366
|
+
() => Promise.resolve().then(() => require("./NoContentTypePage-DCX-hEMB.js")).then((mod) => ({ default: mod.NoContentType }))
|
1327
1367
|
);
|
1328
1368
|
const CollectionTypePages = () => {
|
1329
1369
|
const { collectionType } = reactRouterDom.useParams();
|
@@ -1437,12 +1477,14 @@ const DocumentActionButton = (action) => {
|
|
1437
1477
|
/* @__PURE__ */ jsxRuntime.jsx(
|
1438
1478
|
designSystem.Button,
|
1439
1479
|
{
|
1440
|
-
flex:
|
1480
|
+
flex: "auto",
|
1441
1481
|
startIcon: action.icon,
|
1442
1482
|
disabled: action.disabled,
|
1443
1483
|
onClick: handleClick(action),
|
1444
1484
|
justifyContent: "center",
|
1445
1485
|
variant: action.variant || "default",
|
1486
|
+
paddingTop: "7px",
|
1487
|
+
paddingBottom: "7px",
|
1446
1488
|
children: action.label
|
1447
1489
|
}
|
1448
1490
|
),
|
@@ -1450,7 +1492,7 @@ const DocumentActionButton = (action) => {
|
|
1450
1492
|
DocumentActionConfirmDialog,
|
1451
1493
|
{
|
1452
1494
|
...action.dialog,
|
1453
|
-
variant: action.variant,
|
1495
|
+
variant: action.dialog?.variant ?? action.variant,
|
1454
1496
|
isOpen: dialogId === action.id,
|
1455
1497
|
onClose: handleClose
|
1456
1498
|
}
|
@@ -1507,9 +1549,9 @@ const DocumentActionsMenu = ({
|
|
1507
1549
|
disabled: isDisabled,
|
1508
1550
|
size: "S",
|
1509
1551
|
endIcon: null,
|
1510
|
-
paddingTop: "
|
1511
|
-
paddingLeft: "
|
1512
|
-
paddingRight: "
|
1552
|
+
paddingTop: "4px",
|
1553
|
+
paddingLeft: "7px",
|
1554
|
+
paddingRight: "7px",
|
1513
1555
|
variant,
|
1514
1556
|
children: [
|
1515
1557
|
/* @__PURE__ */ jsxRuntime.jsx(Icons.More, { "aria-hidden": true, focusable: false }),
|
@@ -1520,7 +1562,7 @@ const DocumentActionsMenu = ({
|
|
1520
1562
|
]
|
1521
1563
|
}
|
1522
1564
|
),
|
1523
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, {
|
1565
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
|
1524
1566
|
actions2.map((action) => {
|
1525
1567
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
1526
1568
|
designSystem.Menu.Item,
|
@@ -1529,10 +1571,25 @@ const DocumentActionsMenu = ({
|
|
1529
1571
|
onSelect: handleClick(action),
|
1530
1572
|
display: "block",
|
1531
1573
|
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: [
|
1532
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1574
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
1575
|
+
designSystem.Flex,
|
1576
|
+
{
|
1577
|
+
color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
|
1578
|
+
gap: 2,
|
1579
|
+
tag: "span",
|
1580
|
+
children: [
|
1581
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
1582
|
+
designSystem.Flex,
|
1583
|
+
{
|
1584
|
+
tag: "span",
|
1585
|
+
color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
|
1586
|
+
children: action.icon
|
1587
|
+
}
|
1588
|
+
),
|
1589
|
+
action.label
|
1590
|
+
]
|
1591
|
+
}
|
1592
|
+
),
|
1536
1593
|
action.id.startsWith("HistoryAction") && /* @__PURE__ */ jsxRuntime.jsx(
|
1537
1594
|
designSystem.Flex,
|
1538
1595
|
{
|
@@ -1591,6 +1648,18 @@ const convertActionVariantToColor = (variant = "secondary") => {
|
|
1591
1648
|
return "primary600";
|
1592
1649
|
}
|
1593
1650
|
};
|
1651
|
+
const convertActionVariantToIconColor = (variant = "secondary") => {
|
1652
|
+
switch (variant) {
|
1653
|
+
case "danger":
|
1654
|
+
return "danger600";
|
1655
|
+
case "secondary":
|
1656
|
+
return "neutral500";
|
1657
|
+
case "success":
|
1658
|
+
return "success600";
|
1659
|
+
default:
|
1660
|
+
return "primary600";
|
1661
|
+
}
|
1662
|
+
};
|
1594
1663
|
const DocumentActionConfirmDialog = ({
|
1595
1664
|
onClose,
|
1596
1665
|
onCancel,
|
@@ -1617,11 +1686,11 @@ const DocumentActionConfirmDialog = ({
|
|
1617
1686
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
|
1618
1687
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: content }),
|
1619
1688
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
|
1620
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: formatMessage({
|
1689
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", fullWidth: true, children: formatMessage({
|
1621
1690
|
id: "app.components.Button.cancel",
|
1622
1691
|
defaultMessage: "Cancel"
|
1623
1692
|
}) }) }),
|
1624
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, children: formatMessage({
|
1693
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, fullWidth: true, children: formatMessage({
|
1625
1694
|
id: "app.components.Button.confirm",
|
1626
1695
|
defaultMessage: "Confirm"
|
1627
1696
|
}) })
|
@@ -1660,13 +1729,17 @@ const PublishAction$1 = ({
|
|
1660
1729
|
const navigate = reactRouterDom.useNavigate();
|
1661
1730
|
const { toggleNotification } = strapiAdmin.useNotification();
|
1662
1731
|
const { _unstableFormatValidationErrors: formatValidationErrors } = strapiAdmin.useAPIErrorHandler();
|
1732
|
+
const isListView = reactRouterDom.useMatch(LIST_PATH) !== null;
|
1663
1733
|
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
1664
1734
|
const { formatMessage } = reactIntl.useIntl();
|
1665
|
-
const { canPublish
|
1666
|
-
"PublishAction",
|
1667
|
-
({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
|
1668
|
-
);
|
1735
|
+
const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
|
1669
1736
|
const { publish } = useDocumentActions();
|
1737
|
+
const [
|
1738
|
+
countDraftRelations,
|
1739
|
+
{ isLoading: isLoadingDraftRelations, isError: isErrorDraftRelations }
|
1740
|
+
] = useLazyGetDraftRelationCountQuery();
|
1741
|
+
const [localCountOfDraftRelations, setLocalCountOfDraftRelations] = React__namespace.useState(0);
|
1742
|
+
const [serverCountOfDraftRelations, setServerCountOfDraftRelations] = React__namespace.useState(0);
|
1670
1743
|
const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
|
1671
1744
|
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
1672
1745
|
const modified = strapiAdmin.useForm("PublishAction", ({ modified: modified2 }) => modified2);
|
@@ -1675,10 +1748,103 @@ const PublishAction$1 = ({
|
|
1675
1748
|
const validate = strapiAdmin.useForm("PublishAction", (state) => state.validate);
|
1676
1749
|
const setErrors = strapiAdmin.useForm("PublishAction", (state) => state.setErrors);
|
1677
1750
|
const formValues = strapiAdmin.useForm("PublishAction", ({ values }) => values);
|
1751
|
+
React__namespace.useEffect(() => {
|
1752
|
+
if (isErrorDraftRelations) {
|
1753
|
+
toggleNotification({
|
1754
|
+
type: "danger",
|
1755
|
+
message: formatMessage({
|
1756
|
+
id: getTranslation("error.records.fetch-draft-relatons"),
|
1757
|
+
defaultMessage: "An error occurred while fetching draft relations on this document."
|
1758
|
+
})
|
1759
|
+
});
|
1760
|
+
}
|
1761
|
+
}, [isErrorDraftRelations, toggleNotification, formatMessage]);
|
1762
|
+
React__namespace.useEffect(() => {
|
1763
|
+
const localDraftRelations = /* @__PURE__ */ new Set();
|
1764
|
+
const extractDraftRelations = (data) => {
|
1765
|
+
const relations = data.connect || [];
|
1766
|
+
relations.forEach((relation) => {
|
1767
|
+
if (relation.status === "draft") {
|
1768
|
+
localDraftRelations.add(relation.id);
|
1769
|
+
}
|
1770
|
+
});
|
1771
|
+
};
|
1772
|
+
const traverseAndExtract = (data) => {
|
1773
|
+
Object.entries(data).forEach(([key, value]) => {
|
1774
|
+
if (key === "connect" && Array.isArray(value)) {
|
1775
|
+
extractDraftRelations({ connect: value });
|
1776
|
+
} else if (typeof value === "object" && value !== null) {
|
1777
|
+
traverseAndExtract(value);
|
1778
|
+
}
|
1779
|
+
});
|
1780
|
+
};
|
1781
|
+
if (!documentId || modified) {
|
1782
|
+
traverseAndExtract(formValues);
|
1783
|
+
setLocalCountOfDraftRelations(localDraftRelations.size);
|
1784
|
+
}
|
1785
|
+
}, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
|
1786
|
+
React__namespace.useEffect(() => {
|
1787
|
+
if (!document || !document.documentId || isListView) {
|
1788
|
+
return;
|
1789
|
+
}
|
1790
|
+
const fetchDraftRelationsCount = async () => {
|
1791
|
+
const { data, error } = await countDraftRelations({
|
1792
|
+
collectionType,
|
1793
|
+
model,
|
1794
|
+
documentId,
|
1795
|
+
params
|
1796
|
+
});
|
1797
|
+
if (error) {
|
1798
|
+
throw error;
|
1799
|
+
}
|
1800
|
+
if (data) {
|
1801
|
+
setServerCountOfDraftRelations(data.data);
|
1802
|
+
}
|
1803
|
+
};
|
1804
|
+
fetchDraftRelationsCount();
|
1805
|
+
}, [isListView, document, documentId, countDraftRelations, collectionType, model, params]);
|
1678
1806
|
const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
|
1679
1807
|
if (!schema?.options?.draftAndPublish) {
|
1680
1808
|
return null;
|
1681
1809
|
}
|
1810
|
+
const performPublish = async () => {
|
1811
|
+
setSubmitting(true);
|
1812
|
+
try {
|
1813
|
+
const { errors } = await validate();
|
1814
|
+
if (errors) {
|
1815
|
+
toggleNotification({
|
1816
|
+
type: "danger",
|
1817
|
+
message: formatMessage({
|
1818
|
+
id: "content-manager.validation.error",
|
1819
|
+
defaultMessage: "There are validation errors in your document. Please fix them before saving."
|
1820
|
+
})
|
1821
|
+
});
|
1822
|
+
return;
|
1823
|
+
}
|
1824
|
+
const res = await publish(
|
1825
|
+
{
|
1826
|
+
collectionType,
|
1827
|
+
model,
|
1828
|
+
documentId,
|
1829
|
+
params
|
1830
|
+
},
|
1831
|
+
formValues
|
1832
|
+
);
|
1833
|
+
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1834
|
+
navigate({
|
1835
|
+
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
1836
|
+
search: rawQuery
|
1837
|
+
});
|
1838
|
+
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1839
|
+
setErrors(formatValidationErrors(res.error));
|
1840
|
+
}
|
1841
|
+
} finally {
|
1842
|
+
setSubmitting(false);
|
1843
|
+
}
|
1844
|
+
};
|
1845
|
+
const totalDraftRelations = localCountOfDraftRelations + serverCountOfDraftRelations;
|
1846
|
+
const enableDraftRelationsCount = false;
|
1847
|
+
const hasDraftRelations = enableDraftRelationsCount;
|
1682
1848
|
return {
|
1683
1849
|
/**
|
1684
1850
|
* Disabled when:
|
@@ -1688,49 +1854,36 @@ const PublishAction$1 = ({
|
|
1688
1854
|
* - the document is already published & not modified
|
1689
1855
|
* - the document is being created & not modified
|
1690
1856
|
* - the user doesn't have the permission to publish
|
1691
|
-
* - the user doesn't have the permission to create a new document
|
1692
|
-
* - the user doesn't have the permission to update the document
|
1693
1857
|
*/
|
1694
|
-
disabled: isCloning || isSubmitting || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish
|
1858
|
+
disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish,
|
1695
1859
|
label: formatMessage({
|
1696
1860
|
id: "app.utils.publish",
|
1697
1861
|
defaultMessage: "Publish"
|
1698
1862
|
}),
|
1699
1863
|
onClick: async () => {
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
documentId,
|
1718
|
-
params
|
1719
|
-
},
|
1720
|
-
formValues
|
1721
|
-
);
|
1722
|
-
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1723
|
-
navigate({
|
1724
|
-
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
1725
|
-
search: rawQuery
|
1726
|
-
});
|
1727
|
-
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1728
|
-
setErrors(formatValidationErrors(res.error));
|
1864
|
+
await performPublish();
|
1865
|
+
},
|
1866
|
+
dialog: hasDraftRelations ? {
|
1867
|
+
type: "dialog",
|
1868
|
+
variant: "danger",
|
1869
|
+
footer: null,
|
1870
|
+
title: formatMessage({
|
1871
|
+
id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.title`),
|
1872
|
+
defaultMessage: "Confirmation"
|
1873
|
+
}),
|
1874
|
+
content: formatMessage(
|
1875
|
+
{
|
1876
|
+
id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.message`),
|
1877
|
+
defaultMessage: "This entry is related to {count, plural, one {# draft entry} other {# draft entries}}. Publishing it could leave broken links in your app."
|
1878
|
+
},
|
1879
|
+
{
|
1880
|
+
count: totalDraftRelations
|
1729
1881
|
}
|
1730
|
-
|
1731
|
-
|
1882
|
+
),
|
1883
|
+
onConfirm: async () => {
|
1884
|
+
await performPublish();
|
1732
1885
|
}
|
1733
|
-
}
|
1886
|
+
} : void 0
|
1734
1887
|
};
|
1735
1888
|
};
|
1736
1889
|
PublishAction$1.type = "publish";
|
@@ -1746,10 +1899,6 @@ const UpdateAction = ({
|
|
1746
1899
|
const cloneMatch = reactRouterDom.useMatch(CLONE_PATH);
|
1747
1900
|
const isCloning = cloneMatch !== null;
|
1748
1901
|
const { formatMessage } = reactIntl.useIntl();
|
1749
|
-
const { canCreate, canUpdate } = useDocumentRBAC("UpdateAction", ({ canCreate: canCreate2, canUpdate: canUpdate2 }) => ({
|
1750
|
-
canCreate: canCreate2,
|
1751
|
-
canUpdate: canUpdate2
|
1752
|
-
}));
|
1753
1902
|
const { create, update, clone } = useDocumentActions();
|
1754
1903
|
const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
|
1755
1904
|
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
@@ -1766,10 +1915,8 @@ const UpdateAction = ({
|
|
1766
1915
|
* - the form is submitting
|
1767
1916
|
* - the document is not modified & we're not cloning (you can save a clone entity straight away)
|
1768
1917
|
* - the active tab is the published tab
|
1769
|
-
* - the user doesn't have the permission to create a new document
|
1770
|
-
* - the user doesn't have the permission to update the document
|
1771
1918
|
*/
|
1772
|
-
disabled: isSubmitting || !modified && !isCloning || activeTab === "published"
|
1919
|
+
disabled: isSubmitting || !modified && !isCloning || activeTab === "published",
|
1773
1920
|
label: formatMessage({
|
1774
1921
|
id: "content-manager.containers.Edit.save",
|
1775
1922
|
defaultMessage: "Save"
|
@@ -1777,16 +1924,18 @@ const UpdateAction = ({
|
|
1777
1924
|
onClick: async () => {
|
1778
1925
|
setSubmitting(true);
|
1779
1926
|
try {
|
1780
|
-
|
1781
|
-
|
1782
|
-
|
1783
|
-
|
1784
|
-
|
1785
|
-
|
1786
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1927
|
+
if (activeTab !== "draft") {
|
1928
|
+
const { errors } = await validate();
|
1929
|
+
if (errors) {
|
1930
|
+
toggleNotification({
|
1931
|
+
type: "danger",
|
1932
|
+
message: formatMessage({
|
1933
|
+
id: "content-manager.validation.error",
|
1934
|
+
defaultMessage: "There are validation errors in your document. Please fix them before saving."
|
1935
|
+
})
|
1936
|
+
});
|
1937
|
+
return;
|
1938
|
+
}
|
1790
1939
|
}
|
1791
1940
|
if (isCloning) {
|
1792
1941
|
const res = await clone(
|
@@ -1798,10 +1947,13 @@ const UpdateAction = ({
|
|
1798
1947
|
document
|
1799
1948
|
);
|
1800
1949
|
if ("data" in res) {
|
1801
|
-
navigate(
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1950
|
+
navigate(
|
1951
|
+
{
|
1952
|
+
pathname: `../${res.data.documentId}`,
|
1953
|
+
search: rawQuery
|
1954
|
+
},
|
1955
|
+
{ relative: "path" }
|
1956
|
+
);
|
1805
1957
|
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1806
1958
|
setErrors(formatValidationErrors(res.error));
|
1807
1959
|
}
|
@@ -1829,10 +1981,13 @@ const UpdateAction = ({
|
|
1829
1981
|
document
|
1830
1982
|
);
|
1831
1983
|
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1832
|
-
navigate(
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1984
|
+
navigate(
|
1985
|
+
{
|
1986
|
+
pathname: `../${res.data.documentId}`,
|
1987
|
+
search: rawQuery
|
1988
|
+
},
|
1989
|
+
{ replace: true, relative: "path" }
|
1990
|
+
);
|
1836
1991
|
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1837
1992
|
setErrors(formatValidationErrors(res.error));
|
1838
1993
|
}
|
@@ -1876,7 +2031,7 @@ const UnpublishAction$1 = ({
|
|
1876
2031
|
id: "app.utils.unpublish",
|
1877
2032
|
defaultMessage: "Unpublish"
|
1878
2033
|
}),
|
1879
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
2034
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
|
1880
2035
|
onClick: async () => {
|
1881
2036
|
if (!documentId && collectionType !== SINGLE_TYPES || isDocumentModified) {
|
1882
2037
|
if (!documentId) {
|
@@ -1988,7 +2143,7 @@ const DiscardAction = ({
|
|
1988
2143
|
id: "content-manager.actions.discard.label",
|
1989
2144
|
defaultMessage: "Discard changes"
|
1990
2145
|
}),
|
1991
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
2146
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
|
1992
2147
|
position: ["panel", "table-row"],
|
1993
2148
|
variant: "danger",
|
1994
2149
|
dialog: {
|
@@ -2016,11 +2171,6 @@ const DiscardAction = ({
|
|
2016
2171
|
};
|
2017
2172
|
};
|
2018
2173
|
DiscardAction.type = "discard";
|
2019
|
-
const StyledCrossCircle = styledComponents.styled(Icons.CrossCircle)`
|
2020
|
-
path {
|
2021
|
-
fill: currentColor;
|
2022
|
-
}
|
2023
|
-
`;
|
2024
2174
|
const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
|
2025
2175
|
const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
|
2026
2176
|
const RelativeTime = React__namespace.forwardRef(
|
@@ -2068,7 +2218,7 @@ const getDisplayName = ({
|
|
2068
2218
|
};
|
2069
2219
|
const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
2070
2220
|
const DocumentStatus = ({ status = "draft", ...restProps }) => {
|
2071
|
-
const statusVariant = status === "draft" ? "
|
2221
|
+
const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
|
2072
2222
|
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Status, { ...restProps, showBullet: false, size: "S", variant: statusVariant, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: capitalise(status) }) });
|
2073
2223
|
};
|
2074
2224
|
const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
@@ -2078,23 +2228,13 @@ const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
|
2078
2228
|
id: "content-manager.containers.edit.title.new",
|
2079
2229
|
defaultMessage: "Create an entry"
|
2080
2230
|
}) : documentTitle;
|
2081
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop:
|
2231
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
|
2082
2232
|
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.BackButton, {}),
|
2083
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
2084
|
-
designSystem.
|
2085
|
-
{
|
2086
|
-
|
2087
|
-
|
2088
|
-
paddingTop: 1,
|
2089
|
-
gap: "80px",
|
2090
|
-
alignItems: "flex-start",
|
2091
|
-
children: [
|
2092
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
|
2093
|
-
/* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
|
2094
|
-
]
|
2095
|
-
}
|
2096
|
-
),
|
2097
|
-
status ? /* @__PURE__ */ jsxRuntime.jsx(DocumentStatus, { status: isCloning ? "draft" : status }) : null
|
2233
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
|
2234
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
|
2235
|
+
/* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
|
2236
|
+
] }),
|
2237
|
+
status ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(DocumentStatus, { status: isCloning ? "draft" : status }) }) : null
|
2098
2238
|
] });
|
2099
2239
|
};
|
2100
2240
|
const HeaderToolbar = () => {
|
@@ -2261,8 +2401,22 @@ const Information = ({ activeTab }) => {
|
|
2261
2401
|
);
|
2262
2402
|
};
|
2263
2403
|
const HeaderActions = ({ actions: actions2 }) => {
|
2264
|
-
|
2265
|
-
|
2404
|
+
const [dialogId, setDialogId] = React__namespace.useState(null);
|
2405
|
+
const handleClick = (action) => async (e) => {
|
2406
|
+
if (!("options" in action)) {
|
2407
|
+
const { onClick = () => false, dialog, id } = action;
|
2408
|
+
const muteDialog = await onClick(e);
|
2409
|
+
if (dialog && !muteDialog) {
|
2410
|
+
e.preventDefault();
|
2411
|
+
setDialogId(id);
|
2412
|
+
}
|
2413
|
+
}
|
2414
|
+
};
|
2415
|
+
const handleClose = () => {
|
2416
|
+
setDialogId(null);
|
2417
|
+
};
|
2418
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 1, children: actions2.map((action) => {
|
2419
|
+
if (action.options) {
|
2266
2420
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
2267
2421
|
designSystem.SingleSelect,
|
2268
2422
|
{
|
@@ -2276,10 +2430,49 @@ const HeaderActions = ({ actions: actions2 }) => {
|
|
2276
2430
|
action.id
|
2277
2431
|
);
|
2278
2432
|
} else {
|
2279
|
-
|
2433
|
+
if (action.type === "icon") {
|
2434
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
|
2435
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
2436
|
+
designSystem.IconButton,
|
2437
|
+
{
|
2438
|
+
disabled: action.disabled,
|
2439
|
+
label: action.label,
|
2440
|
+
size: "S",
|
2441
|
+
onClick: handleClick(action),
|
2442
|
+
children: action.icon
|
2443
|
+
}
|
2444
|
+
),
|
2445
|
+
action.dialog ? /* @__PURE__ */ jsxRuntime.jsx(
|
2446
|
+
HeaderActionDialog,
|
2447
|
+
{
|
2448
|
+
...action.dialog,
|
2449
|
+
isOpen: dialogId === action.id,
|
2450
|
+
onClose: handleClose
|
2451
|
+
}
|
2452
|
+
) : null
|
2453
|
+
] }, action.id);
|
2454
|
+
}
|
2280
2455
|
}
|
2281
2456
|
}) });
|
2282
2457
|
};
|
2458
|
+
const HeaderActionDialog = ({
|
2459
|
+
onClose,
|
2460
|
+
onCancel,
|
2461
|
+
title,
|
2462
|
+
content: Content,
|
2463
|
+
isOpen
|
2464
|
+
}) => {
|
2465
|
+
const handleClose = async () => {
|
2466
|
+
if (onCancel) {
|
2467
|
+
await onCancel();
|
2468
|
+
}
|
2469
|
+
onClose();
|
2470
|
+
};
|
2471
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
2472
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
|
2473
|
+
typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : Content
|
2474
|
+
] }) });
|
2475
|
+
};
|
2283
2476
|
const ConfigureTheViewAction = ({ collectionType, model }) => {
|
2284
2477
|
const navigate = reactRouterDom.useNavigate();
|
2285
2478
|
const { formatMessage } = reactIntl.useIntl();
|
@@ -2415,7 +2608,7 @@ const ActionsPanel = () => {
|
|
2415
2608
|
return {
|
2416
2609
|
title: formatMessage({
|
2417
2610
|
id: "content-manager.containers.edit.panels.default.title",
|
2418
|
-
defaultMessage: "
|
2611
|
+
defaultMessage: "Entry"
|
2419
2612
|
}),
|
2420
2613
|
content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
|
2421
2614
|
};
|
@@ -2659,7 +2852,8 @@ const formatEditLayout = (data, {
|
|
2659
2852
|
layout: convertEditLayoutToFieldLayouts(
|
2660
2853
|
configuration.layouts.edit,
|
2661
2854
|
components[uid].attributes,
|
2662
|
-
configuration.metadatas
|
2855
|
+
configuration.metadatas,
|
2856
|
+
{ configurations: data.components, schemas: components }
|
2663
2857
|
),
|
2664
2858
|
settings: {
|
2665
2859
|
...configuration.settings,
|
@@ -2785,7 +2979,7 @@ const ConfirmBulkActionDialog = ({
|
|
2785
2979
|
endAction
|
2786
2980
|
}) => {
|
2787
2981
|
const { formatMessage } = reactIntl.useIntl();
|
2788
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, {
|
2982
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
2789
2983
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: formatMessage({
|
2790
2984
|
id: "app.components.ConfirmDialog.title",
|
2791
2985
|
defaultMessage: "Confirmation"
|
@@ -2816,6 +3010,7 @@ const ConfirmDialogPublishAll = ({
|
|
2816
3010
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler(getTranslation);
|
2817
3011
|
const { model, schema } = useDoc();
|
2818
3012
|
const [{ query }] = strapiAdmin.useQueryParams();
|
3013
|
+
const enableDraftRelationsCount = false;
|
2819
3014
|
const {
|
2820
3015
|
data: countDraftRelations = 0,
|
2821
3016
|
isLoading,
|
@@ -2827,7 +3022,7 @@ const ConfirmDialogPublishAll = ({
|
|
2827
3022
|
locale: query?.plugins?.i18n?.locale
|
2828
3023
|
},
|
2829
3024
|
{
|
2830
|
-
skip:
|
3025
|
+
skip: !enableDraftRelationsCount
|
2831
3026
|
}
|
2832
3027
|
);
|
2833
3028
|
React__namespace.useEffect(() => {
|
@@ -2906,7 +3101,14 @@ const formatErrorMessages = (errors, parentKey, formatMessage) => {
|
|
2906
3101
|
)
|
2907
3102
|
);
|
2908
3103
|
} else {
|
2909
|
-
messages.push(
|
3104
|
+
messages.push(
|
3105
|
+
...formatErrorMessages(
|
3106
|
+
// @ts-expect-error TODO: check why value is not compatible with FormErrors
|
3107
|
+
value,
|
3108
|
+
currentKey,
|
3109
|
+
formatMessage
|
3110
|
+
)
|
3111
|
+
);
|
2910
3112
|
}
|
2911
3113
|
} else {
|
2912
3114
|
messages.push(
|
@@ -3005,7 +3207,7 @@ const SelectedEntriesTableContent = ({
|
|
3005
3207
|
status: row.status
|
3006
3208
|
}
|
3007
3209
|
) }),
|
3008
|
-
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
3210
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
3009
3211
|
designSystem.IconButton,
|
3010
3212
|
{
|
3011
3213
|
tag: reactRouterDom.Link,
|
@@ -3028,9 +3230,10 @@ const SelectedEntriesTableContent = ({
|
|
3028
3230
|
),
|
3029
3231
|
target: "_blank",
|
3030
3232
|
marginLeft: "auto",
|
3031
|
-
|
3233
|
+
variant: "ghost",
|
3234
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, { width: "1.6rem", height: "1.6rem" })
|
3032
3235
|
}
|
3033
|
-
) })
|
3236
|
+
) }) })
|
3034
3237
|
] }, row.id)) })
|
3035
3238
|
] });
|
3036
3239
|
};
|
@@ -3067,7 +3270,13 @@ const SelectedEntriesModalContent = ({
|
|
3067
3270
|
);
|
3068
3271
|
const { rows, validationErrors } = React__namespace.useMemo(() => {
|
3069
3272
|
if (data.length > 0 && schema) {
|
3070
|
-
const validate = createYupSchema(
|
3273
|
+
const validate = createYupSchema(
|
3274
|
+
schema.attributes,
|
3275
|
+
components,
|
3276
|
+
// Since this is the "Publish" action, the validation
|
3277
|
+
// schema must enforce the rules for published entities
|
3278
|
+
{ status: "published" }
|
3279
|
+
);
|
3071
3280
|
const validationErrors2 = {};
|
3072
3281
|
const rows2 = data.map((entry) => {
|
3073
3282
|
try {
|
@@ -3417,7 +3626,7 @@ const TableActions = ({ document }) => {
|
|
3417
3626
|
strapiAdmin.DescriptionComponentRenderer,
|
3418
3627
|
{
|
3419
3628
|
props,
|
3420
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
3629
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions().filter((action) => action.name !== "PublishAction"),
|
3421
3630
|
children: (actions2) => {
|
3422
3631
|
const tableRowActions = actions2.filter((action) => {
|
3423
3632
|
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
@@ -3528,7 +3737,7 @@ const CloneAction = ({ model, documentId }) => {
|
|
3528
3737
|
}),
|
3529
3738
|
content: /* @__PURE__ */ jsxRuntime.jsx(AutoCloneFailureModalBody, { prohibitedFields }),
|
3530
3739
|
footer: ({ onClose }) => {
|
3531
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.
|
3740
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
3532
3741
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
|
3533
3742
|
id: "cancel",
|
3534
3743
|
defaultMessage: "Cancel"
|
@@ -3569,8 +3778,7 @@ class ContentManagerPlugin {
|
|
3569
3778
|
documentActions = [
|
3570
3779
|
...DEFAULT_ACTIONS,
|
3571
3780
|
...DEFAULT_TABLE_ROW_ACTIONS,
|
3572
|
-
...DEFAULT_HEADER_ACTIONS
|
3573
|
-
HistoryAction
|
3781
|
+
...DEFAULT_HEADER_ACTIONS
|
3574
3782
|
];
|
3575
3783
|
editViewSidePanels = [ActionsPanel];
|
3576
3784
|
headerActions = [];
|
@@ -3659,6 +3867,52 @@ const getPrintableType = (value) => {
|
|
3659
3867
|
}
|
3660
3868
|
return nativeType;
|
3661
3869
|
};
|
3870
|
+
const HistoryAction = ({ model, document }) => {
|
3871
|
+
const { formatMessage } = reactIntl.useIntl();
|
3872
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
3873
|
+
const navigate = reactRouterDom.useNavigate();
|
3874
|
+
const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
|
3875
|
+
if (!window.strapi.features.isEnabled("cms-content-history")) {
|
3876
|
+
return null;
|
3877
|
+
}
|
3878
|
+
return {
|
3879
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
|
3880
|
+
label: formatMessage({
|
3881
|
+
id: "content-manager.history.document-action",
|
3882
|
+
defaultMessage: "Content History"
|
3883
|
+
}),
|
3884
|
+
onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
|
3885
|
+
disabled: (
|
3886
|
+
/**
|
3887
|
+
* The user is creating a new document.
|
3888
|
+
* It hasn't been saved yet, so there's no history to go to
|
3889
|
+
*/
|
3890
|
+
!document || /**
|
3891
|
+
* The document has been created but the current dimension has never been saved.
|
3892
|
+
* For example, the user is creating a new locale in an existing document,
|
3893
|
+
* so there's no history for the document in that locale
|
3894
|
+
*/
|
3895
|
+
!document.id || /**
|
3896
|
+
* History is only available for content types created by the user.
|
3897
|
+
* These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
|
3898
|
+
* which start with `admin::` or `plugin::`
|
3899
|
+
*/
|
3900
|
+
!model.startsWith("api::")
|
3901
|
+
),
|
3902
|
+
position: "header"
|
3903
|
+
};
|
3904
|
+
};
|
3905
|
+
HistoryAction.type = "history";
|
3906
|
+
const historyAdmin = {
|
3907
|
+
bootstrap(app) {
|
3908
|
+
const { addDocumentAction } = app.getPlugin("content-manager").apis;
|
3909
|
+
addDocumentAction((actions2) => {
|
3910
|
+
const indexOfDeleteAction = actions2.findIndex((action) => action.type === "delete");
|
3911
|
+
actions2.splice(indexOfDeleteAction, 0, HistoryAction);
|
3912
|
+
return actions2;
|
3913
|
+
});
|
3914
|
+
}
|
3915
|
+
};
|
3662
3916
|
const initialState = {
|
3663
3917
|
collectionTypeLinks: [],
|
3664
3918
|
components: [],
|
@@ -3709,15 +3963,29 @@ const index = {
|
|
3709
3963
|
defaultMessage: "Content Manager"
|
3710
3964
|
},
|
3711
3965
|
permissions: [],
|
3712
|
-
Component: () => Promise.resolve().then(() => require("./layout--iHdZzRk.js")).then((mod) => ({ default: mod.Layout })),
|
3713
3966
|
position: 1
|
3714
3967
|
});
|
3968
|
+
app.router.addRoute({
|
3969
|
+
path: "content-manager/*",
|
3970
|
+
lazy: async () => {
|
3971
|
+
const { Layout } = await Promise.resolve().then(() => require("./layout-T2xBqmuZ.js"));
|
3972
|
+
return {
|
3973
|
+
Component: Layout
|
3974
|
+
};
|
3975
|
+
},
|
3976
|
+
children: routes
|
3977
|
+
});
|
3715
3978
|
app.registerPlugin(cm.config);
|
3716
3979
|
},
|
3980
|
+
bootstrap(app) {
|
3981
|
+
if (typeof historyAdmin.bootstrap === "function") {
|
3982
|
+
historyAdmin.bootstrap(app);
|
3983
|
+
}
|
3984
|
+
},
|
3717
3985
|
async registerTrads({ locales }) {
|
3718
3986
|
const importedTrads = await Promise.all(
|
3719
3987
|
locales.map((locale) => {
|
3720
|
-
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => Promise.resolve().then(() => require("./ar-BUUWXIYu.js")), "./translations/ca.json": () => Promise.resolve().then(() => require("./ca-Cmk45QO6.js")), "./translations/cs.json": () => Promise.resolve().then(() => require("./cs-CkJy6B2v.js")), "./translations/de.json": () => Promise.resolve().then(() => require("./de-CCEmbAah.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-
|
3988
|
+
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => Promise.resolve().then(() => require("./ar-BUUWXIYu.js")), "./translations/ca.json": () => Promise.resolve().then(() => require("./ca-Cmk45QO6.js")), "./translations/cs.json": () => Promise.resolve().then(() => require("./cs-CkJy6B2v.js")), "./translations/de.json": () => Promise.resolve().then(() => require("./de-CCEmbAah.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-BVzUkPxZ.js")), "./translations/es.json": () => Promise.resolve().then(() => require("./es-EUonQTon.js")), "./translations/eu.json": () => Promise.resolve().then(() => require("./eu-VDH-3ovk.js")), "./translations/fr.json": () => Promise.resolve().then(() => require("./fr-B7kGGg3E.js")), "./translations/gu.json": () => Promise.resolve().then(() => require("./gu-BRmF601H.js")), "./translations/hi.json": () => Promise.resolve().then(() => require("./hi-CCJBptSq.js")), "./translations/hu.json": () => Promise.resolve().then(() => require("./hu-sNV_yLYy.js")), "./translations/id.json": () => Promise.resolve().then(() => require("./id-B5Ser98A.js")), "./translations/it.json": () => Promise.resolve().then(() => require("./it-DkBIs7vD.js")), "./translations/ja.json": () => Promise.resolve().then(() => require("./ja-CcFe8diO.js")), "./translations/ko.json": () => Promise.resolve().then(() => require("./ko-woFZPmLk.js")), "./translations/ml.json": () => Promise.resolve().then(() => require("./ml-C2W8N8k1.js")), "./translations/ms.json": () => Promise.resolve().then(() => require("./ms-BuFotyP_.js")), "./translations/nl.json": () => Promise.resolve().then(() => require("./nl-bbEOHChV.js")), "./translations/pl.json": () => Promise.resolve().then(() => require("./pl-uzwG-hk7.js")), "./translations/pt-BR.json": () => Promise.resolve().then(() => require("./pt-BR-BiOz37D9.js")), "./translations/pt.json": () => Promise.resolve().then(() => require("./pt-CeXQuq50.js")), "./translations/ru.json": () => Promise.resolve().then(() => require("./ru-BT3ybNny.js")), "./translations/sa.json": () => Promise.resolve().then(() => require("./sa-CcvkYInH.js")), "./translations/sk.json": () => Promise.resolve().then(() => require("./sk-CvY09Xjv.js")), "./translations/sv.json": () => Promise.resolve().then(() => require("./sv-MYDuzgvT.js")), "./translations/th.json": () => Promise.resolve().then(() => require("./th-D9_GfAjc.js")), "./translations/tr.json": () => Promise.resolve().then(() => require("./tr-D9UH-O_R.js")), "./translations/uk.json": () => Promise.resolve().then(() => require("./uk-C8EiqJY7.js")), "./translations/vi.json": () => Promise.resolve().then(() => require("./vi-CJlYDheJ.js")), "./translations/zh-Hans.json": () => Promise.resolve().then(() => require("./zh-Hans-9kOncHGw.js")), "./translations/zh.json": () => Promise.resolve().then(() => require("./zh-CQQfszqR.js")) }), `./translations/${locale}.json`).then(({ default: data }) => {
|
3721
3989
|
return {
|
3722
3990
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
3723
3991
|
locale
|
@@ -3735,6 +4003,7 @@ const index = {
|
|
3735
4003
|
};
|
3736
4004
|
exports.ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD = ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD;
|
3737
4005
|
exports.BulkActionsRenderer = BulkActionsRenderer;
|
4006
|
+
exports.CLONE_PATH = CLONE_PATH;
|
3738
4007
|
exports.COLLECTION_TYPES = COLLECTION_TYPES;
|
3739
4008
|
exports.CREATOR_FIELDS = CREATOR_FIELDS;
|
3740
4009
|
exports.DEFAULT_SETTINGS = DEFAULT_SETTINGS;
|
@@ -3761,7 +4030,6 @@ exports.getDisplayName = getDisplayName;
|
|
3761
4030
|
exports.getMainField = getMainField;
|
3762
4031
|
exports.getTranslation = getTranslation;
|
3763
4032
|
exports.index = index;
|
3764
|
-
exports.routes = routes;
|
3765
4033
|
exports.setInitialData = setInitialData;
|
3766
4034
|
exports.useContentTypeSchema = useContentTypeSchema;
|
3767
4035
|
exports.useDoc = useDoc;
|
@@ -3775,4 +4043,4 @@ exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
|
|
3775
4043
|
exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
|
3776
4044
|
exports.useGetInitialDataQuery = useGetInitialDataQuery;
|
3777
4045
|
exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
|
3778
|
-
//# sourceMappingURL=index-
|
4046
|
+
//# sourceMappingURL=index-jun-ZqyN.js.map
|