@strapi/content-manager 0.0.0-experimental.60f3ded53a22a24d208ebf6df9b84c118aa97abf → 0.0.0-experimental.6d27139261823fc4b18da9f3c10b271d5010dbf0
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-DErJQEVW.mjs → ComponentConfigurationPage-9lRmRdIr.mjs} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-DErJQEVW.mjs.map → ComponentConfigurationPage-9lRmRdIr.mjs.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-Cl7eB3s4.js → ComponentConfigurationPage-DyDkPajU.js} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-Cl7eB3s4.js.map → ComponentConfigurationPage-DyDkPajU.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-CBosWqQ7.mjs → EditConfigurationPage-Bk893vVY.mjs} +3 -3
- package/dist/_chunks/{EditConfigurationPage-CBosWqQ7.mjs.map → EditConfigurationPage-Bk893vVY.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-CyfFvH6-.js → EditConfigurationPage-DValmA0m.js} +3 -3
- package/dist/_chunks/{EditConfigurationPage-CyfFvH6-.js.map → EditConfigurationPage-DValmA0m.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-ClIueJnM.mjs → EditViewPage-DiNFdFqP.mjs} +19 -8
- package/dist/_chunks/EditViewPage-DiNFdFqP.mjs.map +1 -0
- package/dist/_chunks/{EditViewPage-DxyAOItK.js → EditViewPage-Dk7Eaft4.js} +19 -8
- package/dist/_chunks/EditViewPage-Dk7Eaft4.js.map +1 -0
- package/dist/_chunks/{Field-C0Y_SR9e.js → Field-DH2OaqUP.js} +458 -128
- package/dist/_chunks/Field-DH2OaqUP.js.map +1 -0
- package/dist/_chunks/{Field-BZBYmvaf.mjs → Field-Dv_HTFTa.mjs} +460 -130
- package/dist/_chunks/Field-Dv_HTFTa.mjs.map +1 -0
- package/dist/_chunks/{Form-DwvGnISS.js → Form-B_dUDizM.js} +22 -11
- package/dist/_chunks/Form-B_dUDizM.js.map +1 -0
- package/dist/_chunks/{Form-jwRSC2kV.mjs → Form-Dy6P4HgH.mjs} +22 -11
- package/dist/_chunks/Form-Dy6P4HgH.mjs.map +1 -0
- package/dist/_chunks/{History-Cda0Yjzz.js → History-BT4w83Oa.js} +44 -19
- package/dist/_chunks/History-BT4w83Oa.js.map +1 -0
- package/dist/_chunks/{History-BgzAIj0G.mjs → History-DrwsD1Vc.mjs} +44 -19
- package/dist/_chunks/History-DrwsD1Vc.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-GH55qfoT.mjs → ListConfigurationPage-BxIP0jRy.mjs} +20 -8
- package/dist/_chunks/ListConfigurationPage-BxIP0jRy.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-C29EF97r.js → ListConfigurationPage-CuYrMcW3.js} +20 -8
- package/dist/_chunks/ListConfigurationPage-CuYrMcW3.js.map +1 -0
- package/dist/_chunks/{ListViewPage-QU03PFj1.mjs → ListViewPage-5a1vw-OK.mjs} +40 -34
- package/dist/_chunks/ListViewPage-5a1vw-OK.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-CnRt0UT7.js → ListViewPage-BvpwNur7.js} +38 -32
- package/dist/_chunks/ListViewPage-BvpwNur7.js.map +1 -0
- package/dist/_chunks/{NoContentTypePage-CPs2CnzH.mjs → NoContentTypePage-Bm6tRcd3.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-CPs2CnzH.mjs.map → NoContentTypePage-Bm6tRcd3.mjs.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-DFDjxByI.js → NoContentTypePage-UqEiWKkM.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-DFDjxByI.js.map → NoContentTypePage-UqEiWKkM.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-ct58lcY0.mjs → NoPermissionsPage-BHPqn_tQ.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-ct58lcY0.mjs.map → NoPermissionsPage-BHPqn_tQ.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-BVHI-jv5.js → NoPermissionsPage-C_vGRo8Q.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-BVHI-jv5.js.map → NoPermissionsPage-C_vGRo8Q.js.map} +1 -1
- package/dist/_chunks/{Relations-KMf5qEN0.mjs → Relations-C7fPyh5P.mjs} +4 -4
- package/dist/_chunks/Relations-C7fPyh5P.mjs.map +1 -0
- package/dist/_chunks/{Relations-BjpPPCKp.js → Relations-CznVF6LS.js} +4 -4
- package/dist/_chunks/Relations-CznVF6LS.js.map +1 -0
- package/dist/_chunks/{en-Ux26r5pl.mjs → en-CbaIuYoB.mjs} +6 -5
- package/dist/_chunks/{en-Ux26r5pl.mjs.map → en-CbaIuYoB.mjs.map} +1 -1
- package/dist/_chunks/{en-fbKQxLGn.js → en-otD_UBJi.js} +6 -5
- package/dist/_chunks/{en-fbKQxLGn.js.map → en-otD_UBJi.js.map} +1 -1
- package/dist/_chunks/{index-6kKXK7y8.mjs → index-BJ6uTqLL.mjs} +381 -190
- package/dist/_chunks/index-BJ6uTqLL.mjs.map +1 -0
- package/dist/_chunks/{index-D9ZwczCV.js → index-D9UmmBcM.js} +374 -183
- package/dist/_chunks/index-D9UmmBcM.js.map +1 -0
- package/dist/_chunks/{layout-BJfBoBiF.js → layout-kfu5Wtix.js} +23 -11
- package/dist/_chunks/layout-kfu5Wtix.js.map +1 -0
- package/dist/_chunks/{layout-B1Z-9koY.mjs → layout-uomiIGbG.mjs} +25 -13
- package/dist/_chunks/layout-uomiIGbG.mjs.map +1 -0
- package/dist/_chunks/{relations-CMvjzyU3.js → relations-DKENrxko.js} +2 -2
- package/dist/_chunks/{relations-CMvjzyU3.js.map → relations-DKENrxko.js.map} +1 -1
- package/dist/_chunks/{relations-CgZg7Pyx.mjs → relations-DiDufGSA.mjs} +2 -2
- package/dist/_chunks/{relations-CgZg7Pyx.mjs.map → relations-DiDufGSA.mjs.map} +1 -1
- 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/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 +16 -16
- 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 +175 -104
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +176 -105
- 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/package.json +8 -8
- package/dist/_chunks/EditViewPage-ClIueJnM.mjs.map +0 -1
- package/dist/_chunks/EditViewPage-DxyAOItK.js.map +0 -1
- package/dist/_chunks/Field-BZBYmvaf.mjs.map +0 -1
- package/dist/_chunks/Field-C0Y_SR9e.js.map +0 -1
- package/dist/_chunks/Form-DwvGnISS.js.map +0 -1
- package/dist/_chunks/Form-jwRSC2kV.mjs.map +0 -1
- package/dist/_chunks/History-BgzAIj0G.mjs.map +0 -1
- package/dist/_chunks/History-Cda0Yjzz.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-C29EF97r.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-GH55qfoT.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-CnRt0UT7.js.map +0 -1
- package/dist/_chunks/ListViewPage-QU03PFj1.mjs.map +0 -1
- package/dist/_chunks/Relations-BjpPPCKp.js.map +0 -1
- package/dist/_chunks/Relations-KMf5qEN0.mjs.map +0 -1
- package/dist/_chunks/index-6kKXK7y8.mjs.map +0 -1
- package/dist/_chunks/index-D9ZwczCV.js.map +0 -1
- package/dist/_chunks/layout-B1Z-9koY.mjs.map +0 -1
- package/dist/_chunks/layout-BJfBoBiF.js.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");
|
7
|
+
const reactIntl = require("react-intl");
|
8
|
+
const reactRouterDom = require("react-router-dom");
|
10
9
|
const styledComponents = require("styled-components");
|
11
10
|
const yup = require("yup");
|
12
11
|
const pipe = require("lodash/fp/pipe");
|
13
12
|
const dateFns = require("date-fns");
|
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";
|
@@ -216,8 +180,7 @@ const contentManagerApi = strapiAdmin.adminApi.enhanceEndpoints({
|
|
216
180
|
"InitialData",
|
217
181
|
"HistoryVersion",
|
218
182
|
"Relations",
|
219
|
-
"
|
220
|
-
"ReleaseAction"
|
183
|
+
"UidAvailability"
|
221
184
|
]
|
222
185
|
});
|
223
186
|
const documentApi = contentManagerApi.injectEndpoints({
|
@@ -231,7 +194,12 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
231
194
|
params: query
|
232
195
|
}
|
233
196
|
}),
|
234
|
-
invalidatesTags: (_result,
|
197
|
+
invalidatesTags: (_result, error, { model }) => {
|
198
|
+
if (error) {
|
199
|
+
return [];
|
200
|
+
}
|
201
|
+
return [{ type: "Document", id: `${model}_LIST` }];
|
202
|
+
}
|
235
203
|
}),
|
236
204
|
cloneDocument: builder.mutation({
|
237
205
|
query: ({ model, sourceId, data, params }) => ({
|
@@ -242,7 +210,10 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
242
210
|
params
|
243
211
|
}
|
244
212
|
}),
|
245
|
-
invalidatesTags: (_result, _error, { model }) => [
|
213
|
+
invalidatesTags: (_result, _error, { model }) => [
|
214
|
+
{ type: "Document", id: `${model}_LIST` },
|
215
|
+
{ type: "UidAvailability", id: model }
|
216
|
+
]
|
246
217
|
}),
|
247
218
|
/**
|
248
219
|
* Creates a new collection-type document. This should ONLY be used for collection-types.
|
@@ -259,7 +230,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
259
230
|
}),
|
260
231
|
invalidatesTags: (result, _error, { model }) => [
|
261
232
|
{ type: "Document", id: `${model}_LIST` },
|
262
|
-
"Relations"
|
233
|
+
"Relations",
|
234
|
+
{ type: "UidAvailability", id: model }
|
263
235
|
]
|
264
236
|
}),
|
265
237
|
deleteDocument: builder.mutation({
|
@@ -271,9 +243,7 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
271
243
|
}
|
272
244
|
}),
|
273
245
|
invalidatesTags: (_result, _error, { collectionType, model }) => [
|
274
|
-
{ type: "Document", id: collectionType !== SINGLE_TYPES ? `${model}_LIST` : model }
|
275
|
-
{ type: "Release", id: "LIST" },
|
276
|
-
{ type: "ReleaseAction", id: "LIST" }
|
246
|
+
{ type: "Document", id: collectionType !== SINGLE_TYPES ? `${model}_LIST` : model }
|
277
247
|
]
|
278
248
|
}),
|
279
249
|
deleteManyDocuments: builder.mutation({
|
@@ -285,11 +255,7 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
285
255
|
params
|
286
256
|
}
|
287
257
|
}),
|
288
|
-
invalidatesTags: (_res, _error, { model }) => [
|
289
|
-
{ type: "Document", id: `${model}_LIST` },
|
290
|
-
{ type: "Release", id: "LIST" },
|
291
|
-
{ type: "ReleaseAction", id: "LIST" }
|
292
|
-
]
|
258
|
+
invalidatesTags: (_res, _error, { model }) => [{ type: "Document", id: `${model}_LIST` }]
|
293
259
|
}),
|
294
260
|
discardDocument: builder.mutation({
|
295
261
|
query: ({ collectionType, model, documentId, params }) => ({
|
@@ -307,8 +273,7 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
307
273
|
},
|
308
274
|
{ type: "Document", id: `${model}_LIST` },
|
309
275
|
"Relations",
|
310
|
-
{ type: "
|
311
|
-
{ type: "ReleaseAction", id: "LIST" }
|
276
|
+
{ type: "UidAvailability", id: model }
|
312
277
|
];
|
313
278
|
}
|
314
279
|
}),
|
@@ -326,6 +291,7 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
326
291
|
}),
|
327
292
|
providesTags: (result, _error, arg) => {
|
328
293
|
return [
|
294
|
+
{ type: "Document", id: `ALL_LIST` },
|
329
295
|
{ type: "Document", id: `${arg.model}_LIST` },
|
330
296
|
...result?.results.map(({ documentId }) => ({
|
331
297
|
type: "Document",
|
@@ -364,6 +330,11 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
364
330
|
{
|
365
331
|
type: "Document",
|
366
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`
|
367
338
|
}
|
368
339
|
];
|
369
340
|
}
|
@@ -428,9 +399,20 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
428
399
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
429
400
|
},
|
430
401
|
"Relations",
|
431
|
-
{ type: "
|
432
|
-
{ type: "ReleaseAction", id: "LIST" }
|
402
|
+
{ type: "UidAvailability", id: model }
|
433
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
|
+
}
|
434
416
|
}
|
435
417
|
}),
|
436
418
|
unpublishDocument: builder.mutation({
|
@@ -500,7 +482,7 @@ const buildValidParams = (query) => {
|
|
500
482
|
const isBaseQueryError = (error) => {
|
501
483
|
return error.name !== void 0;
|
502
484
|
};
|
503
|
-
const createYupSchema = (attributes = {}, components = {}) => {
|
485
|
+
const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
|
504
486
|
const createModelSchema = (attributes2) => yup__namespace.object().shape(
|
505
487
|
Object.entries(attributes2).reduce((acc, [name, attribute]) => {
|
506
488
|
if (DOCUMENT_META_FIELDS.includes(name)) {
|
@@ -513,7 +495,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
513
495
|
addMinValidation,
|
514
496
|
addMaxValidation,
|
515
497
|
addRegexValidation
|
516
|
-
].map((fn) => fn(attribute));
|
498
|
+
].map((fn) => fn(attribute, options));
|
517
499
|
const transformSchema = pipe__default.default(...validations);
|
518
500
|
switch (attribute.type) {
|
519
501
|
case "component": {
|
@@ -614,6 +596,14 @@ const createAttributeSchema = (attribute) => {
|
|
614
596
|
if (!value || typeof value === "string" && value.length === 0) {
|
615
597
|
return true;
|
616
598
|
}
|
599
|
+
if (typeof value === "object") {
|
600
|
+
try {
|
601
|
+
JSON.stringify(value);
|
602
|
+
return true;
|
603
|
+
} catch (err) {
|
604
|
+
return false;
|
605
|
+
}
|
606
|
+
}
|
617
607
|
try {
|
618
608
|
JSON.parse(value);
|
619
609
|
return true;
|
@@ -632,13 +622,7 @@ const createAttributeSchema = (attribute) => {
|
|
632
622
|
return yup__namespace.mixed();
|
633
623
|
}
|
634
624
|
};
|
635
|
-
const
|
636
|
-
if (attribute.required) {
|
637
|
-
return schema.required({
|
638
|
-
id: strapiAdmin.translatedErrors.required.id,
|
639
|
-
defaultMessage: "This field is required."
|
640
|
-
});
|
641
|
-
}
|
625
|
+
const nullableSchema = (schema) => {
|
642
626
|
return schema?.nullable ? schema.nullable() : (
|
643
627
|
// In some cases '.nullable' will not be available on the schema.
|
644
628
|
// e.g. when the schema has been built using yup.lazy (e.g. for relations).
|
@@ -646,7 +630,22 @@ const addRequiredValidation = (attribute) => (schema) => {
|
|
646
630
|
schema
|
647
631
|
);
|
648
632
|
};
|
649
|
-
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
|
+
}
|
650
649
|
if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
|
651
650
|
return schema.min(attribute.minLength, {
|
652
651
|
...strapiAdmin.translatedErrors.minLength,
|
@@ -668,9 +667,31 @@ const addMaxLengthValidation = (attribute) => (schema) => {
|
|
668
667
|
}
|
669
668
|
return schema;
|
670
669
|
};
|
671
|
-
const addMinValidation = (attribute) => (schema) => {
|
670
|
+
const addMinValidation = (attribute, options) => (schema) => {
|
672
671
|
if ("min" in attribute) {
|
673
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
|
+
}
|
674
695
|
if ("min" in schema && min) {
|
675
696
|
return schema.min(min, {
|
676
697
|
...strapiAdmin.translatedErrors.min,
|
@@ -797,7 +818,10 @@ const useDocument = (args, opts) => {
|
|
797
818
|
isLoading: isLoadingDocument,
|
798
819
|
isFetching: isFetchingDocument,
|
799
820
|
error
|
800
|
-
} = useGetDocumentQuery(args,
|
821
|
+
} = useGetDocumentQuery(args, {
|
822
|
+
...opts,
|
823
|
+
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
824
|
+
});
|
801
825
|
const { components, schema, isLoading: isLoadingSchema } = useContentTypeSchema(args.model);
|
802
826
|
React__namespace.useEffect(() => {
|
803
827
|
if (error) {
|
@@ -883,6 +907,7 @@ const useDocumentActions = () => {
|
|
883
907
|
const { formatMessage } = reactIntl.useIntl();
|
884
908
|
const { trackUsage } = strapiAdmin.useTracking();
|
885
909
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
910
|
+
const navigate = reactRouterDom.useNavigate();
|
886
911
|
const [deleteDocument] = useDeleteDocumentMutation();
|
887
912
|
const _delete = React__namespace.useCallback(
|
888
913
|
async ({ collectionType, model, documentId, params }, trackerProperty) => {
|
@@ -1218,7 +1243,6 @@ const useDocumentActions = () => {
|
|
1218
1243
|
sourceId
|
1219
1244
|
});
|
1220
1245
|
if ("error" in res) {
|
1221
|
-
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1222
1246
|
return { error: res.error };
|
1223
1247
|
}
|
1224
1248
|
toggleNotification({
|
@@ -1237,7 +1261,7 @@ const useDocumentActions = () => {
|
|
1237
1261
|
throw err;
|
1238
1262
|
}
|
1239
1263
|
},
|
1240
|
-
[autoCloneDocument,
|
1264
|
+
[autoCloneDocument, formatMessage, toggleNotification]
|
1241
1265
|
);
|
1242
1266
|
const [cloneDocument] = useCloneDocumentMutation();
|
1243
1267
|
const clone = React__namespace.useCallback(
|
@@ -1263,6 +1287,7 @@ const useDocumentActions = () => {
|
|
1263
1287
|
defaultMessage: "Cloned document"
|
1264
1288
|
})
|
1265
1289
|
});
|
1290
|
+
navigate(`../../${res.data.data.documentId}`, { relative: "path" });
|
1266
1291
|
return res.data;
|
1267
1292
|
} catch (err) {
|
1268
1293
|
toggleNotification({
|
@@ -1273,7 +1298,7 @@ const useDocumentActions = () => {
|
|
1273
1298
|
throw err;
|
1274
1299
|
}
|
1275
1300
|
},
|
1276
|
-
[cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError]
|
1301
|
+
[cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError, navigate]
|
1277
1302
|
);
|
1278
1303
|
const [getDoc] = useLazyGetDocumentQuery();
|
1279
1304
|
const getDocument = React__namespace.useCallback(
|
@@ -1299,7 +1324,7 @@ const useDocumentActions = () => {
|
|
1299
1324
|
};
|
1300
1325
|
};
|
1301
1326
|
const ProtectedHistoryPage = React.lazy(
|
1302
|
-
() => Promise.resolve().then(() => require("./History-
|
1327
|
+
() => Promise.resolve().then(() => require("./History-BT4w83Oa.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
|
1303
1328
|
);
|
1304
1329
|
const routes$1 = [
|
1305
1330
|
{
|
@@ -1312,31 +1337,31 @@ const routes$1 = [
|
|
1312
1337
|
}
|
1313
1338
|
];
|
1314
1339
|
const ProtectedEditViewPage = React.lazy(
|
1315
|
-
() => Promise.resolve().then(() => require("./EditViewPage-
|
1340
|
+
() => Promise.resolve().then(() => require("./EditViewPage-Dk7Eaft4.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
|
1316
1341
|
);
|
1317
1342
|
const ProtectedListViewPage = React.lazy(
|
1318
|
-
() => Promise.resolve().then(() => require("./ListViewPage-
|
1343
|
+
() => Promise.resolve().then(() => require("./ListViewPage-BvpwNur7.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
|
1319
1344
|
);
|
1320
1345
|
const ProtectedListConfiguration = React.lazy(
|
1321
|
-
() => Promise.resolve().then(() => require("./ListConfigurationPage-
|
1346
|
+
() => Promise.resolve().then(() => require("./ListConfigurationPage-CuYrMcW3.js")).then((mod) => ({
|
1322
1347
|
default: mod.ProtectedListConfiguration
|
1323
1348
|
}))
|
1324
1349
|
);
|
1325
1350
|
const ProtectedEditConfigurationPage = React.lazy(
|
1326
|
-
() => Promise.resolve().then(() => require("./EditConfigurationPage-
|
1351
|
+
() => Promise.resolve().then(() => require("./EditConfigurationPage-DValmA0m.js")).then((mod) => ({
|
1327
1352
|
default: mod.ProtectedEditConfigurationPage
|
1328
1353
|
}))
|
1329
1354
|
);
|
1330
1355
|
const ProtectedComponentConfigurationPage = React.lazy(
|
1331
|
-
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-
|
1356
|
+
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-DyDkPajU.js")).then((mod) => ({
|
1332
1357
|
default: mod.ProtectedComponentConfigurationPage
|
1333
1358
|
}))
|
1334
1359
|
);
|
1335
1360
|
const NoPermissions = React.lazy(
|
1336
|
-
() => Promise.resolve().then(() => require("./NoPermissionsPage-
|
1361
|
+
() => Promise.resolve().then(() => require("./NoPermissionsPage-C_vGRo8Q.js")).then((mod) => ({ default: mod.NoPermissions }))
|
1337
1362
|
);
|
1338
1363
|
const NoContentType = React.lazy(
|
1339
|
-
() => Promise.resolve().then(() => require("./NoContentTypePage-
|
1364
|
+
() => Promise.resolve().then(() => require("./NoContentTypePage-UqEiWKkM.js")).then((mod) => ({ default: mod.NoContentType }))
|
1340
1365
|
);
|
1341
1366
|
const CollectionTypePages = () => {
|
1342
1367
|
const { collectionType } = reactRouterDom.useParams();
|
@@ -1450,12 +1475,14 @@ const DocumentActionButton = (action) => {
|
|
1450
1475
|
/* @__PURE__ */ jsxRuntime.jsx(
|
1451
1476
|
designSystem.Button,
|
1452
1477
|
{
|
1453
|
-
flex:
|
1478
|
+
flex: "auto",
|
1454
1479
|
startIcon: action.icon,
|
1455
1480
|
disabled: action.disabled,
|
1456
1481
|
onClick: handleClick(action),
|
1457
1482
|
justifyContent: "center",
|
1458
1483
|
variant: action.variant || "default",
|
1484
|
+
paddingTop: "7px",
|
1485
|
+
paddingBottom: "7px",
|
1459
1486
|
children: action.label
|
1460
1487
|
}
|
1461
1488
|
),
|
@@ -1463,7 +1490,7 @@ const DocumentActionButton = (action) => {
|
|
1463
1490
|
DocumentActionConfirmDialog,
|
1464
1491
|
{
|
1465
1492
|
...action.dialog,
|
1466
|
-
variant: action.variant,
|
1493
|
+
variant: action.dialog?.variant ?? action.variant,
|
1467
1494
|
isOpen: dialogId === action.id,
|
1468
1495
|
onClose: handleClose
|
1469
1496
|
}
|
@@ -1520,9 +1547,9 @@ const DocumentActionsMenu = ({
|
|
1520
1547
|
disabled: isDisabled,
|
1521
1548
|
size: "S",
|
1522
1549
|
endIcon: null,
|
1523
|
-
paddingTop: "
|
1524
|
-
paddingLeft: "
|
1525
|
-
paddingRight: "
|
1550
|
+
paddingTop: "4px",
|
1551
|
+
paddingLeft: "7px",
|
1552
|
+
paddingRight: "7px",
|
1526
1553
|
variant,
|
1527
1554
|
children: [
|
1528
1555
|
/* @__PURE__ */ jsxRuntime.jsx(Icons.More, { "aria-hidden": true, focusable: false }),
|
@@ -1542,10 +1569,25 @@ const DocumentActionsMenu = ({
|
|
1542
1569
|
onSelect: handleClick(action),
|
1543
1570
|
display: "block",
|
1544
1571
|
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: [
|
1545
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1572
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
1573
|
+
designSystem.Flex,
|
1574
|
+
{
|
1575
|
+
color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
|
1576
|
+
gap: 2,
|
1577
|
+
tag: "span",
|
1578
|
+
children: [
|
1579
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
1580
|
+
designSystem.Flex,
|
1581
|
+
{
|
1582
|
+
tag: "span",
|
1583
|
+
color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
|
1584
|
+
children: action.icon
|
1585
|
+
}
|
1586
|
+
),
|
1587
|
+
action.label
|
1588
|
+
]
|
1589
|
+
}
|
1590
|
+
),
|
1549
1591
|
action.id.startsWith("HistoryAction") && /* @__PURE__ */ jsxRuntime.jsx(
|
1550
1592
|
designSystem.Flex,
|
1551
1593
|
{
|
@@ -1685,13 +1727,17 @@ const PublishAction$1 = ({
|
|
1685
1727
|
const navigate = reactRouterDom.useNavigate();
|
1686
1728
|
const { toggleNotification } = strapiAdmin.useNotification();
|
1687
1729
|
const { _unstableFormatValidationErrors: formatValidationErrors } = strapiAdmin.useAPIErrorHandler();
|
1730
|
+
const isListView = reactRouterDom.useMatch(LIST_PATH) !== null;
|
1688
1731
|
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
1689
1732
|
const { formatMessage } = reactIntl.useIntl();
|
1690
|
-
const { canPublish
|
1691
|
-
"PublishAction",
|
1692
|
-
({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
|
1693
|
-
);
|
1733
|
+
const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
|
1694
1734
|
const { publish } = useDocumentActions();
|
1735
|
+
const [
|
1736
|
+
countDraftRelations,
|
1737
|
+
{ isLoading: isLoadingDraftRelations, isError: isErrorDraftRelations }
|
1738
|
+
] = useLazyGetDraftRelationCountQuery();
|
1739
|
+
const [localCountOfDraftRelations, setLocalCountOfDraftRelations] = React__namespace.useState(0);
|
1740
|
+
const [serverCountOfDraftRelations, setServerCountOfDraftRelations] = React__namespace.useState(0);
|
1695
1741
|
const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
|
1696
1742
|
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
1697
1743
|
const modified = strapiAdmin.useForm("PublishAction", ({ modified: modified2 }) => modified2);
|
@@ -1700,10 +1746,102 @@ const PublishAction$1 = ({
|
|
1700
1746
|
const validate = strapiAdmin.useForm("PublishAction", (state) => state.validate);
|
1701
1747
|
const setErrors = strapiAdmin.useForm("PublishAction", (state) => state.setErrors);
|
1702
1748
|
const formValues = strapiAdmin.useForm("PublishAction", ({ values }) => values);
|
1749
|
+
React__namespace.useEffect(() => {
|
1750
|
+
if (isErrorDraftRelations) {
|
1751
|
+
toggleNotification({
|
1752
|
+
type: "danger",
|
1753
|
+
message: formatMessage({
|
1754
|
+
id: getTranslation("error.records.fetch-draft-relatons"),
|
1755
|
+
defaultMessage: "An error occurred while fetching draft relations on this document."
|
1756
|
+
})
|
1757
|
+
});
|
1758
|
+
}
|
1759
|
+
}, [isErrorDraftRelations, toggleNotification, formatMessage]);
|
1760
|
+
React__namespace.useEffect(() => {
|
1761
|
+
const localDraftRelations = /* @__PURE__ */ new Set();
|
1762
|
+
const extractDraftRelations = (data) => {
|
1763
|
+
const relations = data.connect || [];
|
1764
|
+
relations.forEach((relation) => {
|
1765
|
+
if (relation.status === "draft") {
|
1766
|
+
localDraftRelations.add(relation.id);
|
1767
|
+
}
|
1768
|
+
});
|
1769
|
+
};
|
1770
|
+
const traverseAndExtract = (data) => {
|
1771
|
+
Object.entries(data).forEach(([key, value]) => {
|
1772
|
+
if (key === "connect" && Array.isArray(value)) {
|
1773
|
+
extractDraftRelations({ connect: value });
|
1774
|
+
} else if (typeof value === "object" && value !== null) {
|
1775
|
+
traverseAndExtract(value);
|
1776
|
+
}
|
1777
|
+
});
|
1778
|
+
};
|
1779
|
+
if (!documentId || modified) {
|
1780
|
+
traverseAndExtract(formValues);
|
1781
|
+
setLocalCountOfDraftRelations(localDraftRelations.size);
|
1782
|
+
}
|
1783
|
+
}, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
|
1784
|
+
React__namespace.useEffect(() => {
|
1785
|
+
if (documentId && !isListView) {
|
1786
|
+
const fetchDraftRelationsCount = async () => {
|
1787
|
+
const { data, error } = await countDraftRelations({
|
1788
|
+
collectionType,
|
1789
|
+
model,
|
1790
|
+
documentId,
|
1791
|
+
params
|
1792
|
+
});
|
1793
|
+
if (error) {
|
1794
|
+
throw error;
|
1795
|
+
}
|
1796
|
+
if (data) {
|
1797
|
+
setServerCountOfDraftRelations(data.data);
|
1798
|
+
}
|
1799
|
+
};
|
1800
|
+
fetchDraftRelationsCount();
|
1801
|
+
}
|
1802
|
+
}, [isListView, documentId, countDraftRelations, collectionType, model, params]);
|
1703
1803
|
const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
|
1704
1804
|
if (!schema?.options?.draftAndPublish) {
|
1705
1805
|
return null;
|
1706
1806
|
}
|
1807
|
+
const performPublish = async () => {
|
1808
|
+
setSubmitting(true);
|
1809
|
+
try {
|
1810
|
+
const { errors } = await validate();
|
1811
|
+
if (errors) {
|
1812
|
+
toggleNotification({
|
1813
|
+
type: "danger",
|
1814
|
+
message: formatMessage({
|
1815
|
+
id: "content-manager.validation.error",
|
1816
|
+
defaultMessage: "There are validation errors in your document. Please fix them before saving."
|
1817
|
+
})
|
1818
|
+
});
|
1819
|
+
return;
|
1820
|
+
}
|
1821
|
+
const res = await publish(
|
1822
|
+
{
|
1823
|
+
collectionType,
|
1824
|
+
model,
|
1825
|
+
documentId,
|
1826
|
+
params
|
1827
|
+
},
|
1828
|
+
formValues
|
1829
|
+
);
|
1830
|
+
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1831
|
+
navigate({
|
1832
|
+
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
1833
|
+
search: rawQuery
|
1834
|
+
});
|
1835
|
+
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1836
|
+
setErrors(formatValidationErrors(res.error));
|
1837
|
+
}
|
1838
|
+
} finally {
|
1839
|
+
setSubmitting(false);
|
1840
|
+
}
|
1841
|
+
};
|
1842
|
+
const totalDraftRelations = localCountOfDraftRelations + serverCountOfDraftRelations;
|
1843
|
+
const enableDraftRelationsCount = false;
|
1844
|
+
const hasDraftRelations = enableDraftRelationsCount;
|
1707
1845
|
return {
|
1708
1846
|
/**
|
1709
1847
|
* Disabled when:
|
@@ -1713,49 +1851,36 @@ const PublishAction$1 = ({
|
|
1713
1851
|
* - the document is already published & not modified
|
1714
1852
|
* - the document is being created & not modified
|
1715
1853
|
* - the user doesn't have the permission to publish
|
1716
|
-
* - the user doesn't have the permission to create a new document
|
1717
|
-
* - the user doesn't have the permission to update the document
|
1718
1854
|
*/
|
1719
|
-
disabled: isCloning || isSubmitting || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish
|
1855
|
+
disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish,
|
1720
1856
|
label: formatMessage({
|
1721
1857
|
id: "app.utils.publish",
|
1722
1858
|
defaultMessage: "Publish"
|
1723
1859
|
}),
|
1724
1860
|
onClick: async () => {
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
documentId,
|
1743
|
-
params
|
1744
|
-
},
|
1745
|
-
formValues
|
1746
|
-
);
|
1747
|
-
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1748
|
-
navigate({
|
1749
|
-
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
1750
|
-
search: rawQuery
|
1751
|
-
});
|
1752
|
-
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1753
|
-
setErrors(formatValidationErrors(res.error));
|
1861
|
+
await performPublish();
|
1862
|
+
},
|
1863
|
+
dialog: hasDraftRelations ? {
|
1864
|
+
type: "dialog",
|
1865
|
+
variant: "danger",
|
1866
|
+
footer: null,
|
1867
|
+
title: formatMessage({
|
1868
|
+
id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.title`),
|
1869
|
+
defaultMessage: "Confirmation"
|
1870
|
+
}),
|
1871
|
+
content: formatMessage(
|
1872
|
+
{
|
1873
|
+
id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.message`),
|
1874
|
+
defaultMessage: "This entry is related to {count, plural, one {# draft entry} other {# draft entries}}. Publishing it could leave broken links in your app."
|
1875
|
+
},
|
1876
|
+
{
|
1877
|
+
count: totalDraftRelations
|
1754
1878
|
}
|
1755
|
-
|
1756
|
-
|
1879
|
+
),
|
1880
|
+
onConfirm: async () => {
|
1881
|
+
await performPublish();
|
1757
1882
|
}
|
1758
|
-
}
|
1883
|
+
} : void 0
|
1759
1884
|
};
|
1760
1885
|
};
|
1761
1886
|
PublishAction$1.type = "publish";
|
@@ -1771,10 +1896,6 @@ const UpdateAction = ({
|
|
1771
1896
|
const cloneMatch = reactRouterDom.useMatch(CLONE_PATH);
|
1772
1897
|
const isCloning = cloneMatch !== null;
|
1773
1898
|
const { formatMessage } = reactIntl.useIntl();
|
1774
|
-
const { canCreate, canUpdate } = useDocumentRBAC("UpdateAction", ({ canCreate: canCreate2, canUpdate: canUpdate2 }) => ({
|
1775
|
-
canCreate: canCreate2,
|
1776
|
-
canUpdate: canUpdate2
|
1777
|
-
}));
|
1778
1899
|
const { create, update, clone } = useDocumentActions();
|
1779
1900
|
const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
|
1780
1901
|
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
@@ -1791,10 +1912,8 @@ const UpdateAction = ({
|
|
1791
1912
|
* - the form is submitting
|
1792
1913
|
* - the document is not modified & we're not cloning (you can save a clone entity straight away)
|
1793
1914
|
* - the active tab is the published tab
|
1794
|
-
* - the user doesn't have the permission to create a new document
|
1795
|
-
* - the user doesn't have the permission to update the document
|
1796
1915
|
*/
|
1797
|
-
disabled: isSubmitting || !modified && !isCloning || activeTab === "published"
|
1916
|
+
disabled: isSubmitting || !modified && !isCloning || activeTab === "published",
|
1798
1917
|
label: formatMessage({
|
1799
1918
|
id: "content-manager.containers.Edit.save",
|
1800
1919
|
defaultMessage: "Save"
|
@@ -1802,16 +1921,18 @@ const UpdateAction = ({
|
|
1802
1921
|
onClick: async () => {
|
1803
1922
|
setSubmitting(true);
|
1804
1923
|
try {
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
1924
|
+
if (activeTab !== "draft") {
|
1925
|
+
const { errors } = await validate();
|
1926
|
+
if (errors) {
|
1927
|
+
toggleNotification({
|
1928
|
+
type: "danger",
|
1929
|
+
message: formatMessage({
|
1930
|
+
id: "content-manager.validation.error",
|
1931
|
+
defaultMessage: "There are validation errors in your document. Please fix them before saving."
|
1932
|
+
})
|
1933
|
+
});
|
1934
|
+
return;
|
1935
|
+
}
|
1815
1936
|
}
|
1816
1937
|
if (isCloning) {
|
1817
1938
|
const res = await clone(
|
@@ -1823,10 +1944,13 @@ const UpdateAction = ({
|
|
1823
1944
|
document
|
1824
1945
|
);
|
1825
1946
|
if ("data" in res) {
|
1826
|
-
navigate(
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1947
|
+
navigate(
|
1948
|
+
{
|
1949
|
+
pathname: `../${res.data.documentId}`,
|
1950
|
+
search: rawQuery
|
1951
|
+
},
|
1952
|
+
{ relative: "path" }
|
1953
|
+
);
|
1830
1954
|
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1831
1955
|
setErrors(formatValidationErrors(res.error));
|
1832
1956
|
}
|
@@ -1854,10 +1978,13 @@ const UpdateAction = ({
|
|
1854
1978
|
document
|
1855
1979
|
);
|
1856
1980
|
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1857
|
-
navigate(
|
1858
|
-
|
1859
|
-
|
1860
|
-
|
1981
|
+
navigate(
|
1982
|
+
{
|
1983
|
+
pathname: `../${res.data.documentId}`,
|
1984
|
+
search: rawQuery
|
1985
|
+
},
|
1986
|
+
{ replace: true, relative: "path" }
|
1987
|
+
);
|
1861
1988
|
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1862
1989
|
setErrors(formatValidationErrors(res.error));
|
1863
1990
|
}
|
@@ -2103,23 +2230,13 @@ const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
|
2103
2230
|
id: "content-manager.containers.edit.title.new",
|
2104
2231
|
defaultMessage: "Create an entry"
|
2105
2232
|
}) : documentTitle;
|
2106
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop:
|
2233
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
|
2107
2234
|
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.BackButton, {}),
|
2108
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
2109
|
-
designSystem.
|
2110
|
-
{
|
2111
|
-
|
2112
|
-
|
2113
|
-
paddingTop: 1,
|
2114
|
-
gap: "80px",
|
2115
|
-
alignItems: "flex-start",
|
2116
|
-
children: [
|
2117
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
|
2118
|
-
/* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
|
2119
|
-
]
|
2120
|
-
}
|
2121
|
-
),
|
2122
|
-
status ? /* @__PURE__ */ jsxRuntime.jsx(DocumentStatus, { status: isCloning ? "draft" : status }) : null
|
2235
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
|
2236
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
|
2237
|
+
/* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
|
2238
|
+
] }),
|
2239
|
+
status ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(DocumentStatus, { status: isCloning ? "draft" : status }) }) : null
|
2123
2240
|
] });
|
2124
2241
|
};
|
2125
2242
|
const HeaderToolbar = () => {
|
@@ -2810,7 +2927,7 @@ const ConfirmBulkActionDialog = ({
|
|
2810
2927
|
endAction
|
2811
2928
|
}) => {
|
2812
2929
|
const { formatMessage } = reactIntl.useIntl();
|
2813
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, {
|
2930
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
2814
2931
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: formatMessage({
|
2815
2932
|
id: "app.components.ConfirmDialog.title",
|
2816
2933
|
defaultMessage: "Confirmation"
|
@@ -2841,6 +2958,7 @@ const ConfirmDialogPublishAll = ({
|
|
2841
2958
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler(getTranslation);
|
2842
2959
|
const { model, schema } = useDoc();
|
2843
2960
|
const [{ query }] = strapiAdmin.useQueryParams();
|
2961
|
+
const enableDraftRelationsCount = false;
|
2844
2962
|
const {
|
2845
2963
|
data: countDraftRelations = 0,
|
2846
2964
|
isLoading,
|
@@ -2852,7 +2970,7 @@ const ConfirmDialogPublishAll = ({
|
|
2852
2970
|
locale: query?.plugins?.i18n?.locale
|
2853
2971
|
},
|
2854
2972
|
{
|
2855
|
-
skip:
|
2973
|
+
skip: !enableDraftRelationsCount
|
2856
2974
|
}
|
2857
2975
|
);
|
2858
2976
|
React__namespace.useEffect(() => {
|
@@ -2931,7 +3049,14 @@ const formatErrorMessages = (errors, parentKey, formatMessage) => {
|
|
2931
3049
|
)
|
2932
3050
|
);
|
2933
3051
|
} else {
|
2934
|
-
messages.push(
|
3052
|
+
messages.push(
|
3053
|
+
...formatErrorMessages(
|
3054
|
+
// @ts-expect-error TODO: check why value is not compatible with FormErrors
|
3055
|
+
value,
|
3056
|
+
currentKey,
|
3057
|
+
formatMessage
|
3058
|
+
)
|
3059
|
+
);
|
2935
3060
|
}
|
2936
3061
|
} else {
|
2937
3062
|
messages.push(
|
@@ -3030,7 +3155,7 @@ const SelectedEntriesTableContent = ({
|
|
3030
3155
|
status: row.status
|
3031
3156
|
}
|
3032
3157
|
) }),
|
3033
|
-
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
3158
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
3034
3159
|
designSystem.IconButton,
|
3035
3160
|
{
|
3036
3161
|
tag: reactRouterDom.Link,
|
@@ -3053,9 +3178,10 @@ const SelectedEntriesTableContent = ({
|
|
3053
3178
|
),
|
3054
3179
|
target: "_blank",
|
3055
3180
|
marginLeft: "auto",
|
3056
|
-
|
3181
|
+
variant: "ghost",
|
3182
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, { width: "1.6rem", height: "1.6rem" })
|
3057
3183
|
}
|
3058
|
-
) })
|
3184
|
+
) }) })
|
3059
3185
|
] }, row.id)) })
|
3060
3186
|
] });
|
3061
3187
|
};
|
@@ -3092,7 +3218,13 @@ const SelectedEntriesModalContent = ({
|
|
3092
3218
|
);
|
3093
3219
|
const { rows, validationErrors } = React__namespace.useMemo(() => {
|
3094
3220
|
if (data.length > 0 && schema) {
|
3095
|
-
const validate = createYupSchema(
|
3221
|
+
const validate = createYupSchema(
|
3222
|
+
schema.attributes,
|
3223
|
+
components,
|
3224
|
+
// Since this is the "Publish" action, the validation
|
3225
|
+
// schema must enforce the rules for published entities
|
3226
|
+
{ status: "published" }
|
3227
|
+
);
|
3096
3228
|
const validationErrors2 = {};
|
3097
3229
|
const rows2 = data.map((entry) => {
|
3098
3230
|
try {
|
@@ -3442,7 +3574,7 @@ const TableActions = ({ document }) => {
|
|
3442
3574
|
strapiAdmin.DescriptionComponentRenderer,
|
3443
3575
|
{
|
3444
3576
|
props,
|
3445
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
3577
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions().filter((action) => action.name !== "PublishAction"),
|
3446
3578
|
children: (actions2) => {
|
3447
3579
|
const tableRowActions = actions2.filter((action) => {
|
3448
3580
|
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
@@ -3553,7 +3685,7 @@ const CloneAction = ({ model, documentId }) => {
|
|
3553
3685
|
}),
|
3554
3686
|
content: /* @__PURE__ */ jsxRuntime.jsx(AutoCloneFailureModalBody, { prohibitedFields }),
|
3555
3687
|
footer: ({ onClose }) => {
|
3556
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.
|
3688
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
3557
3689
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
|
3558
3690
|
id: "cancel",
|
3559
3691
|
defaultMessage: "Cancel"
|
@@ -3594,8 +3726,7 @@ class ContentManagerPlugin {
|
|
3594
3726
|
documentActions = [
|
3595
3727
|
...DEFAULT_ACTIONS,
|
3596
3728
|
...DEFAULT_TABLE_ROW_ACTIONS,
|
3597
|
-
...DEFAULT_HEADER_ACTIONS
|
3598
|
-
HistoryAction
|
3729
|
+
...DEFAULT_HEADER_ACTIONS
|
3599
3730
|
];
|
3600
3731
|
editViewSidePanels = [ActionsPanel];
|
3601
3732
|
headerActions = [];
|
@@ -3684,6 +3815,52 @@ const getPrintableType = (value) => {
|
|
3684
3815
|
}
|
3685
3816
|
return nativeType;
|
3686
3817
|
};
|
3818
|
+
const HistoryAction = ({ model, document }) => {
|
3819
|
+
const { formatMessage } = reactIntl.useIntl();
|
3820
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
3821
|
+
const navigate = reactRouterDom.useNavigate();
|
3822
|
+
const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
|
3823
|
+
if (!window.strapi.features.isEnabled("cms-content-history")) {
|
3824
|
+
return null;
|
3825
|
+
}
|
3826
|
+
return {
|
3827
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
|
3828
|
+
label: formatMessage({
|
3829
|
+
id: "content-manager.history.document-action",
|
3830
|
+
defaultMessage: "Content History"
|
3831
|
+
}),
|
3832
|
+
onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
|
3833
|
+
disabled: (
|
3834
|
+
/**
|
3835
|
+
* The user is creating a new document.
|
3836
|
+
* It hasn't been saved yet, so there's no history to go to
|
3837
|
+
*/
|
3838
|
+
!document || /**
|
3839
|
+
* The document has been created but the current dimension has never been saved.
|
3840
|
+
* For example, the user is creating a new locale in an existing document,
|
3841
|
+
* so there's no history for the document in that locale
|
3842
|
+
*/
|
3843
|
+
!document.id || /**
|
3844
|
+
* History is only available for content types created by the user.
|
3845
|
+
* These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
|
3846
|
+
* which start with `admin::` or `plugin::`
|
3847
|
+
*/
|
3848
|
+
!model.startsWith("api::")
|
3849
|
+
),
|
3850
|
+
position: "header"
|
3851
|
+
};
|
3852
|
+
};
|
3853
|
+
HistoryAction.type = "history";
|
3854
|
+
const historyAdmin = {
|
3855
|
+
bootstrap(app) {
|
3856
|
+
const { addDocumentAction } = app.getPlugin("content-manager").apis;
|
3857
|
+
addDocumentAction((actions2) => {
|
3858
|
+
const indexOfDeleteAction = actions2.findIndex((action) => action.type === "delete");
|
3859
|
+
actions2.splice(indexOfDeleteAction, 0, HistoryAction);
|
3860
|
+
return actions2;
|
3861
|
+
});
|
3862
|
+
}
|
3863
|
+
};
|
3687
3864
|
const initialState = {
|
3688
3865
|
collectionTypeLinks: [],
|
3689
3866
|
components: [],
|
@@ -3734,15 +3911,29 @@ const index = {
|
|
3734
3911
|
defaultMessage: "Content Manager"
|
3735
3912
|
},
|
3736
3913
|
permissions: [],
|
3737
|
-
Component: () => Promise.resolve().then(() => require("./layout-BJfBoBiF.js")).then((mod) => ({ default: mod.Layout })),
|
3738
3914
|
position: 1
|
3739
3915
|
});
|
3916
|
+
app.router.addRoute({
|
3917
|
+
path: "content-manager/*",
|
3918
|
+
lazy: async () => {
|
3919
|
+
const { Layout } = await Promise.resolve().then(() => require("./layout-kfu5Wtix.js"));
|
3920
|
+
return {
|
3921
|
+
Component: Layout
|
3922
|
+
};
|
3923
|
+
},
|
3924
|
+
children: routes
|
3925
|
+
});
|
3740
3926
|
app.registerPlugin(cm.config);
|
3741
3927
|
},
|
3928
|
+
bootstrap(app) {
|
3929
|
+
if (typeof historyAdmin.bootstrap === "function") {
|
3930
|
+
historyAdmin.bootstrap(app);
|
3931
|
+
}
|
3932
|
+
},
|
3742
3933
|
async registerTrads({ locales }) {
|
3743
3934
|
const importedTrads = await Promise.all(
|
3744
3935
|
locales.map((locale) => {
|
3745
|
-
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-
|
3936
|
+
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-otD_UBJi.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 }) => {
|
3746
3937
|
return {
|
3747
3938
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
3748
3939
|
locale
|
@@ -3760,6 +3951,7 @@ const index = {
|
|
3760
3951
|
};
|
3761
3952
|
exports.ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD = ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD;
|
3762
3953
|
exports.BulkActionsRenderer = BulkActionsRenderer;
|
3954
|
+
exports.CLONE_PATH = CLONE_PATH;
|
3763
3955
|
exports.COLLECTION_TYPES = COLLECTION_TYPES;
|
3764
3956
|
exports.CREATOR_FIELDS = CREATOR_FIELDS;
|
3765
3957
|
exports.DEFAULT_SETTINGS = DEFAULT_SETTINGS;
|
@@ -3786,7 +3978,6 @@ exports.getDisplayName = getDisplayName;
|
|
3786
3978
|
exports.getMainField = getMainField;
|
3787
3979
|
exports.getTranslation = getTranslation;
|
3788
3980
|
exports.index = index;
|
3789
|
-
exports.routes = routes;
|
3790
3981
|
exports.setInitialData = setInitialData;
|
3791
3982
|
exports.useContentTypeSchema = useContentTypeSchema;
|
3792
3983
|
exports.useDoc = useDoc;
|
@@ -3800,4 +3991,4 @@ exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
|
|
3800
3991
|
exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
|
3801
3992
|
exports.useGetInitialDataQuery = useGetInitialDataQuery;
|
3802
3993
|
exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
|
3803
|
-
//# sourceMappingURL=index-
|
3994
|
+
//# sourceMappingURL=index-D9UmmBcM.js.map
|