@strapi/content-manager 0.0.0-experimental.545ccead2ee1717bbc7ab950455dbb0ddb9924a3 → 0.0.0-experimental.5788c38836be65c0321a2dcadbdf44f04b798e8a
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/dist/_chunks/{ComponentConfigurationPage-Bqgx7Mes.js → ComponentConfigurationPage-B42mQr1K.js} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-Bqgx7Mes.js.map → ComponentConfigurationPage-B42mQr1K.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-B1bIXVuX.mjs → ComponentConfigurationPage-D1YuKq8j.mjs} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-B1bIXVuX.mjs.map → ComponentConfigurationPage-D1YuKq8j.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-ZO0vOO8q.mjs → EditConfigurationPage-C9yiwgI_.mjs} +3 -3
- package/dist/_chunks/{EditConfigurationPage-ZO0vOO8q.mjs.map → EditConfigurationPage-C9yiwgI_.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-BFEwvdMW.js → EditConfigurationPage-NC89F29V.js} +3 -3
- package/dist/_chunks/{EditConfigurationPage-BFEwvdMW.js.map → EditConfigurationPage-NC89F29V.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-DA95Ha6J.js → EditViewPage-DYDpe5Wi.js} +30 -9
- package/dist/_chunks/EditViewPage-DYDpe5Wi.js.map +1 -0
- package/dist/_chunks/{EditViewPage-DlLEyUL6.mjs → EditViewPage-k8UcfVwt.mjs} +30 -9
- package/dist/_chunks/EditViewPage-k8UcfVwt.mjs.map +1 -0
- package/dist/_chunks/{Field-Dq7bDnuh.mjs → Field-BLL5lknV.mjs} +170 -102
- package/dist/_chunks/Field-BLL5lknV.mjs.map +1 -0
- package/dist/_chunks/{Field-CnK8dO8N.js → Field-Crhugun2.js} +172 -104
- package/dist/_chunks/Field-Crhugun2.js.map +1 -0
- package/dist/_chunks/{Form-BpiR4piS.js → Form-DUU19g6M.js} +35 -16
- package/dist/_chunks/Form-DUU19g6M.js.map +1 -0
- package/dist/_chunks/{Form-B_JE0dbz.mjs → Form-UHu2eOuG.mjs} +35 -16
- package/dist/_chunks/Form-UHu2eOuG.mjs.map +1 -0
- package/dist/_chunks/{History-CBNGU7a-.mjs → History-CpxkZXS3.mjs} +21 -11
- package/dist/_chunks/History-CpxkZXS3.mjs.map +1 -0
- package/dist/_chunks/{History-DdIstl8b.js → History-CyA8tvJZ.js} +21 -11
- package/dist/_chunks/History-CyA8tvJZ.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-5dr4qpue.mjs → ListConfigurationPage-OUwV8QF1.mjs} +14 -4
- package/dist/_chunks/ListConfigurationPage-OUwV8QF1.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-DkKRparB.js → ListConfigurationPage-pJV7aG2V.js} +14 -4
- package/dist/_chunks/ListConfigurationPage-pJV7aG2V.js.map +1 -0
- package/dist/_chunks/{ListViewPage-wE0lXqoD.js → ListViewPage-BIT0M8VG.js} +49 -40
- package/dist/_chunks/ListViewPage-BIT0M8VG.js.map +1 -0
- package/dist/_chunks/{ListViewPage-DecLrYV6.mjs → ListViewPage-BOnhCGkE.mjs} +47 -38
- package/dist/_chunks/ListViewPage-BOnhCGkE.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-CiIcfYsd.mjs → NoContentTypePage-CwjlHGTn.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-CiIcfYsd.mjs.map → NoContentTypePage-CwjlHGTn.mjs.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-DEKR6tf9.js → NoContentTypePage-uIBsBUmH.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-DEKR6tf9.js.map → NoContentTypePage-uIBsBUmH.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-DmNfF2Bb.js → NoPermissionsPage-C8wkEaOF.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-DmNfF2Bb.js.map → NoPermissionsPage-C8wkEaOF.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-CM5UD8ee.mjs → NoPermissionsPage-CcWbyT_z.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-CM5UD8ee.mjs.map → NoPermissionsPage-CcWbyT_z.mjs.map} +1 -1
- package/dist/_chunks/{Relations-L0xYRoSQ.js → Relations-CwRu_eZv.js} +33 -24
- package/dist/_chunks/Relations-CwRu_eZv.js.map +1 -0
- package/dist/_chunks/{Relations-Dqz0C1fz.mjs → Relations-wIdWJnA9.mjs} +33 -24
- package/dist/_chunks/Relations-wIdWJnA9.mjs.map +1 -0
- package/dist/_chunks/{en-uOUIxfcQ.js → en-Bm0D0IWz.js} +13 -12
- package/dist/_chunks/{en-uOUIxfcQ.js.map → en-Bm0D0IWz.js.map} +1 -1
- package/dist/_chunks/{en-BrCTWlZv.mjs → en-DKV44jRb.mjs} +13 -12
- package/dist/_chunks/{en-BrCTWlZv.mjs.map → en-DKV44jRb.mjs.map} +1 -1
- package/dist/_chunks/{index-DyvUPg1a.js → index-BO-T2BdP.js} +693 -524
- package/dist/_chunks/index-BO-T2BdP.js.map +1 -0
- package/dist/_chunks/{index-BSn97i8U.mjs → index-BQ8DxaCa.mjs} +713 -544
- package/dist/_chunks/index-BQ8DxaCa.mjs.map +1 -0
- package/dist/_chunks/{layout-TPqF2oJ5.js → layout-BTB1_M8g.js} +21 -8
- package/dist/_chunks/layout-BTB1_M8g.js.map +1 -0
- package/dist/_chunks/{layout-DPaHUusj.mjs → layout-N63eyE5E.mjs} +22 -9
- package/dist/_chunks/layout-N63eyE5E.mjs.map +1 -0
- package/dist/_chunks/{relations-Ck7-ecDT.mjs → relations-Bh9r0CVE.mjs} +2 -2
- package/dist/_chunks/{relations-Ck7-ecDT.mjs.map → relations-Bh9r0CVE.mjs.map} +1 -1
- package/dist/_chunks/{relations-BWYS9gkn.js → relations-C9AQuM2z.js} +2 -2
- package/dist/_chunks/{relations-BWYS9gkn.js.map → relations-C9AQuM2z.js.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 +2 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +5 -4
- package/dist/admin/src/exports.d.ts +1 -1
- package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
- package/dist/admin/src/hooks/useDocument.d.ts +32 -1
- 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 +11 -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 +195 -117
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +196 -118
- 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 +11 -11
- package/dist/_chunks/EditViewPage-DA95Ha6J.js.map +0 -1
- package/dist/_chunks/EditViewPage-DlLEyUL6.mjs.map +0 -1
- package/dist/_chunks/Field-CnK8dO8N.js.map +0 -1
- package/dist/_chunks/Field-Dq7bDnuh.mjs.map +0 -1
- package/dist/_chunks/Form-B_JE0dbz.mjs.map +0 -1
- package/dist/_chunks/Form-BpiR4piS.js.map +0 -1
- package/dist/_chunks/History-CBNGU7a-.mjs.map +0 -1
- package/dist/_chunks/History-DdIstl8b.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-5dr4qpue.mjs.map +0 -1
- package/dist/_chunks/ListConfigurationPage-DkKRparB.js.map +0 -1
- package/dist/_chunks/ListViewPage-DecLrYV6.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-wE0lXqoD.js.map +0 -1
- package/dist/_chunks/Relations-Dqz0C1fz.mjs.map +0 -1
- package/dist/_chunks/Relations-L0xYRoSQ.js.map +0 -1
- package/dist/_chunks/index-BSn97i8U.mjs.map +0 -1
- package/dist/_chunks/index-DyvUPg1a.js.map +0 -1
- package/dist/_chunks/layout-DPaHUusj.mjs.map +0 -1
- package/dist/_chunks/layout-TPqF2oJ5.js.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
- package/strapi-server.js +0 -3
@@ -6,10 +6,10 @@ const React = require("react");
|
|
6
6
|
const designSystem = require("@strapi/design-system");
|
7
7
|
const reactIntl = require("react-intl");
|
8
8
|
const reactRouterDom = require("react-router-dom");
|
9
|
-
const styledComponents = require("styled-components");
|
10
9
|
const yup = require("yup");
|
11
10
|
const pipe = require("lodash/fp/pipe");
|
12
11
|
const dateFns = require("date-fns");
|
12
|
+
const styledComponents = require("styled-components");
|
13
13
|
const qs = require("qs");
|
14
14
|
const toolkit = require("@reduxjs/toolkit");
|
15
15
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
@@ -179,7 +179,8 @@ const contentManagerApi = strapiAdmin.adminApi.enhanceEndpoints({
|
|
179
179
|
"Document",
|
180
180
|
"InitialData",
|
181
181
|
"HistoryVersion",
|
182
|
-
"Relations"
|
182
|
+
"Relations",
|
183
|
+
"UidAvailability"
|
183
184
|
]
|
184
185
|
});
|
185
186
|
const documentApi = contentManagerApi.injectEndpoints({
|
@@ -193,7 +194,12 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
193
194
|
params: query
|
194
195
|
}
|
195
196
|
}),
|
196
|
-
invalidatesTags: (_result,
|
197
|
+
invalidatesTags: (_result, error, { model }) => {
|
198
|
+
if (error) {
|
199
|
+
return [];
|
200
|
+
}
|
201
|
+
return [{ type: "Document", id: `${model}_LIST` }];
|
202
|
+
}
|
197
203
|
}),
|
198
204
|
cloneDocument: builder.mutation({
|
199
205
|
query: ({ model, sourceId, data, params }) => ({
|
@@ -204,7 +210,10 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
204
210
|
params
|
205
211
|
}
|
206
212
|
}),
|
207
|
-
invalidatesTags: (_result, _error, { model }) => [
|
213
|
+
invalidatesTags: (_result, _error, { model }) => [
|
214
|
+
{ type: "Document", id: `${model}_LIST` },
|
215
|
+
{ type: "UidAvailability", id: model }
|
216
|
+
]
|
208
217
|
}),
|
209
218
|
/**
|
210
219
|
* Creates a new collection-type document. This should ONLY be used for collection-types.
|
@@ -221,7 +230,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
221
230
|
}),
|
222
231
|
invalidatesTags: (result, _error, { model }) => [
|
223
232
|
{ type: "Document", id: `${model}_LIST` },
|
224
|
-
"Relations"
|
233
|
+
"Relations",
|
234
|
+
{ type: "UidAvailability", id: model }
|
225
235
|
]
|
226
236
|
}),
|
227
237
|
deleteDocument: builder.mutation({
|
@@ -262,7 +272,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
262
272
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
263
273
|
},
|
264
274
|
{ type: "Document", id: `${model}_LIST` },
|
265
|
-
"Relations"
|
275
|
+
"Relations",
|
276
|
+
{ type: "UidAvailability", id: model }
|
266
277
|
];
|
267
278
|
}
|
268
279
|
}),
|
@@ -280,6 +291,7 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
280
291
|
}),
|
281
292
|
providesTags: (result, _error, arg) => {
|
282
293
|
return [
|
294
|
+
{ type: "Document", id: `ALL_LIST` },
|
283
295
|
{ type: "Document", id: `${arg.model}_LIST` },
|
284
296
|
...result?.results.map(({ documentId }) => ({
|
285
297
|
type: "Document",
|
@@ -318,6 +330,11 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
318
330
|
{
|
319
331
|
type: "Document",
|
320
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`
|
321
338
|
}
|
322
339
|
];
|
323
340
|
}
|
@@ -381,8 +398,21 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
381
398
|
type: "Document",
|
382
399
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
383
400
|
},
|
384
|
-
"Relations"
|
401
|
+
"Relations",
|
402
|
+
{ type: "UidAvailability", id: model }
|
385
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
|
+
}
|
386
416
|
}
|
387
417
|
}),
|
388
418
|
unpublishDocument: builder.mutation({
|
@@ -452,20 +482,36 @@ const buildValidParams = (query) => {
|
|
452
482
|
const isBaseQueryError = (error) => {
|
453
483
|
return error.name !== void 0;
|
454
484
|
};
|
455
|
-
const
|
485
|
+
const arrayValidator = (options) => ({
|
486
|
+
message: strapiAdmin.translatedErrors.required,
|
487
|
+
test(value) {
|
488
|
+
if (options.status === "draft") {
|
489
|
+
return true;
|
490
|
+
}
|
491
|
+
if (!value) {
|
492
|
+
return false;
|
493
|
+
}
|
494
|
+
if (Array.isArray(value) && value.length === 0) {
|
495
|
+
return false;
|
496
|
+
}
|
497
|
+
return true;
|
498
|
+
}
|
499
|
+
});
|
500
|
+
const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
|
456
501
|
const createModelSchema = (attributes2) => yup__namespace.object().shape(
|
457
502
|
Object.entries(attributes2).reduce((acc, [name, attribute]) => {
|
458
503
|
if (DOCUMENT_META_FIELDS.includes(name)) {
|
459
504
|
return acc;
|
460
505
|
}
|
461
506
|
const validations = [
|
507
|
+
addNullableValidation,
|
462
508
|
addRequiredValidation,
|
463
509
|
addMinLengthValidation,
|
464
510
|
addMaxLengthValidation,
|
465
511
|
addMinValidation,
|
466
512
|
addMaxValidation,
|
467
513
|
addRegexValidation
|
468
|
-
].map((fn) => fn(attribute));
|
514
|
+
].map((fn) => fn(attribute, options));
|
469
515
|
const transformSchema = pipe__default.default(...validations);
|
470
516
|
switch (attribute.type) {
|
471
517
|
case "component": {
|
@@ -475,12 +521,12 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
475
521
|
...acc,
|
476
522
|
[name]: transformSchema(
|
477
523
|
yup__namespace.array().of(createModelSchema(attributes3).nullable(false))
|
478
|
-
)
|
524
|
+
).test(arrayValidator(options))
|
479
525
|
};
|
480
526
|
} else {
|
481
527
|
return {
|
482
528
|
...acc,
|
483
|
-
[name]: transformSchema(createModelSchema(attributes3))
|
529
|
+
[name]: transformSchema(createModelSchema(attributes3).nullable())
|
484
530
|
};
|
485
531
|
}
|
486
532
|
}
|
@@ -502,7 +548,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
502
548
|
}
|
503
549
|
)
|
504
550
|
)
|
505
|
-
)
|
551
|
+
).test(arrayValidator(options))
|
506
552
|
};
|
507
553
|
case "relation":
|
508
554
|
return {
|
@@ -514,7 +560,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
514
560
|
} else if (Array.isArray(value)) {
|
515
561
|
return yup__namespace.array().of(
|
516
562
|
yup__namespace.object().shape({
|
517
|
-
id: yup__namespace.
|
563
|
+
id: yup__namespace.number().required()
|
518
564
|
})
|
519
565
|
);
|
520
566
|
} else if (typeof value === "object") {
|
@@ -566,6 +612,14 @@ const createAttributeSchema = (attribute) => {
|
|
566
612
|
if (!value || typeof value === "string" && value.length === 0) {
|
567
613
|
return true;
|
568
614
|
}
|
615
|
+
if (typeof value === "object") {
|
616
|
+
try {
|
617
|
+
JSON.stringify(value);
|
618
|
+
return true;
|
619
|
+
} catch (err) {
|
620
|
+
return false;
|
621
|
+
}
|
622
|
+
}
|
569
623
|
try {
|
570
624
|
JSON.parse(value);
|
571
625
|
return true;
|
@@ -584,13 +638,7 @@ const createAttributeSchema = (attribute) => {
|
|
584
638
|
return yup__namespace.mixed();
|
585
639
|
}
|
586
640
|
};
|
587
|
-
const
|
588
|
-
if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
|
589
|
-
return schema.min(1, strapiAdmin.translatedErrors.required);
|
590
|
-
}
|
591
|
-
if (attribute.required && attribute.type !== "relation") {
|
592
|
-
return schema.required(strapiAdmin.translatedErrors.required);
|
593
|
-
}
|
641
|
+
const nullableSchema = (schema) => {
|
594
642
|
return schema?.nullable ? schema.nullable() : (
|
595
643
|
// In some cases '.nullable' will not be available on the schema.
|
596
644
|
// e.g. when the schema has been built using yup.lazy (e.g. for relations).
|
@@ -598,7 +646,22 @@ const addRequiredValidation = (attribute) => (schema) => {
|
|
598
646
|
schema
|
599
647
|
);
|
600
648
|
};
|
601
|
-
const
|
649
|
+
const addNullableValidation = () => (schema) => {
|
650
|
+
return nullableSchema(schema);
|
651
|
+
};
|
652
|
+
const addRequiredValidation = (attribute, options) => (schema) => {
|
653
|
+
if (options.status === "draft" || !attribute.required) {
|
654
|
+
return schema;
|
655
|
+
}
|
656
|
+
if (attribute.required && "required" in schema) {
|
657
|
+
return schema.required(strapiAdmin.translatedErrors.required);
|
658
|
+
}
|
659
|
+
return schema;
|
660
|
+
};
|
661
|
+
const addMinLengthValidation = (attribute, options) => (schema) => {
|
662
|
+
if (options.status === "draft") {
|
663
|
+
return schema;
|
664
|
+
}
|
602
665
|
if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
|
603
666
|
return schema.min(attribute.minLength, {
|
604
667
|
...strapiAdmin.translatedErrors.minLength,
|
@@ -620,32 +683,13 @@ const addMaxLengthValidation = (attribute) => (schema) => {
|
|
620
683
|
}
|
621
684
|
return schema;
|
622
685
|
};
|
623
|
-
const addMinValidation = (attribute) => (schema) => {
|
624
|
-
if ("
|
686
|
+
const addMinValidation = (attribute, options) => (schema) => {
|
687
|
+
if (options.status === "draft") {
|
688
|
+
return schema;
|
689
|
+
}
|
690
|
+
if ("min" in attribute && "min" in schema) {
|
625
691
|
const min = toInteger(attribute.min);
|
626
|
-
if (
|
627
|
-
if (!attribute.required && "test" in schema && min) {
|
628
|
-
return schema.test(
|
629
|
-
"custom-min",
|
630
|
-
{
|
631
|
-
...strapiAdmin.translatedErrors.min,
|
632
|
-
values: {
|
633
|
-
min: attribute.min
|
634
|
-
}
|
635
|
-
},
|
636
|
-
(value) => {
|
637
|
-
if (!value) {
|
638
|
-
return true;
|
639
|
-
}
|
640
|
-
if (Array.isArray(value) && value.length === 0) {
|
641
|
-
return true;
|
642
|
-
}
|
643
|
-
return value.length >= min;
|
644
|
-
}
|
645
|
-
);
|
646
|
-
}
|
647
|
-
}
|
648
|
-
if ("min" in schema && min) {
|
692
|
+
if (min) {
|
649
693
|
return schema.min(min, {
|
650
694
|
...strapiAdmin.translatedErrors.min,
|
651
695
|
values: {
|
@@ -763,19 +807,115 @@ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
|
|
763
807
|
}, {});
|
764
808
|
return componentsByKey;
|
765
809
|
};
|
766
|
-
const
|
810
|
+
const HOOKS = {
|
811
|
+
/**
|
812
|
+
* Hook that allows to mutate the displayed headers of the list view table
|
813
|
+
* @constant
|
814
|
+
* @type {string}
|
815
|
+
*/
|
816
|
+
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
817
|
+
/**
|
818
|
+
* Hook that allows to mutate the CM's collection types links pre-set filters
|
819
|
+
* @constant
|
820
|
+
* @type {string}
|
821
|
+
*/
|
822
|
+
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
823
|
+
/**
|
824
|
+
* Hook that allows to mutate the CM's edit view layout
|
825
|
+
* @constant
|
826
|
+
* @type {string}
|
827
|
+
*/
|
828
|
+
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
829
|
+
/**
|
830
|
+
* Hook that allows to mutate the CM's single types links pre-set filters
|
831
|
+
* @constant
|
832
|
+
* @type {string}
|
833
|
+
*/
|
834
|
+
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
835
|
+
};
|
836
|
+
const contentTypesApi = contentManagerApi.injectEndpoints({
|
837
|
+
endpoints: (builder) => ({
|
838
|
+
getContentTypeConfiguration: builder.query({
|
839
|
+
query: (uid) => ({
|
840
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
841
|
+
method: "GET"
|
842
|
+
}),
|
843
|
+
transformResponse: (response) => response.data,
|
844
|
+
providesTags: (_result, _error, uid) => [
|
845
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
846
|
+
{ type: "ContentTypeSettings", id: "LIST" }
|
847
|
+
]
|
848
|
+
}),
|
849
|
+
getAllContentTypeSettings: builder.query({
|
850
|
+
query: () => "/content-manager/content-types-settings",
|
851
|
+
transformResponse: (response) => response.data,
|
852
|
+
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
853
|
+
}),
|
854
|
+
updateContentTypeConfiguration: builder.mutation({
|
855
|
+
query: ({ uid, ...body }) => ({
|
856
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
857
|
+
method: "PUT",
|
858
|
+
data: body
|
859
|
+
}),
|
860
|
+
transformResponse: (response) => response.data,
|
861
|
+
invalidatesTags: (_result, _error, { uid }) => [
|
862
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
863
|
+
{ type: "ContentTypeSettings", id: "LIST" },
|
864
|
+
// Is this necessary?
|
865
|
+
{ type: "InitialData" }
|
866
|
+
]
|
867
|
+
})
|
868
|
+
})
|
869
|
+
});
|
870
|
+
const {
|
871
|
+
useGetContentTypeConfigurationQuery,
|
872
|
+
useGetAllContentTypeSettingsQuery,
|
873
|
+
useUpdateContentTypeConfigurationMutation
|
874
|
+
} = contentTypesApi;
|
875
|
+
const checkIfAttributeIsDisplayable = (attribute) => {
|
876
|
+
const { type } = attribute;
|
877
|
+
if (type === "relation") {
|
878
|
+
return !attribute.relation.toLowerCase().includes("morph");
|
879
|
+
}
|
880
|
+
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
881
|
+
};
|
882
|
+
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
883
|
+
if (!mainFieldName) {
|
884
|
+
return void 0;
|
885
|
+
}
|
886
|
+
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
887
|
+
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
888
|
+
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
889
|
+
);
|
890
|
+
return {
|
891
|
+
name: mainFieldName,
|
892
|
+
type: mainFieldType ?? "string"
|
893
|
+
};
|
894
|
+
};
|
895
|
+
const DEFAULT_SETTINGS = {
|
896
|
+
bulkable: false,
|
897
|
+
filterable: false,
|
898
|
+
searchable: false,
|
899
|
+
pagination: false,
|
900
|
+
defaultSortBy: "",
|
901
|
+
defaultSortOrder: "asc",
|
902
|
+
mainField: "id",
|
903
|
+
pageSize: 10
|
904
|
+
};
|
905
|
+
const useDocumentLayout = (model) => {
|
906
|
+
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
907
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
908
|
+
const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
767
909
|
const { toggleNotification } = strapiAdmin.useNotification();
|
768
910
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
911
|
+
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
769
912
|
const {
|
770
|
-
|
771
|
-
isLoading:
|
772
|
-
|
773
|
-
|
774
|
-
} =
|
775
|
-
|
776
|
-
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
777
|
-
});
|
778
|
-
const { components, schema, isLoading: isLoadingSchema } = useContentTypeSchema(args.model);
|
913
|
+
data,
|
914
|
+
isLoading: isLoadingConfigs,
|
915
|
+
error,
|
916
|
+
isFetching: isFetchingConfigs
|
917
|
+
} = useGetContentTypeConfigurationQuery(model);
|
918
|
+
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
779
919
|
React__namespace.useEffect(() => {
|
780
920
|
if (error) {
|
781
921
|
toggleNotification({
|
@@ -783,83 +923,339 @@ const useDocument = (args, opts) => {
|
|
783
923
|
message: formatAPIError(error)
|
784
924
|
});
|
785
925
|
}
|
786
|
-
}, [
|
787
|
-
const
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
(document) => {
|
795
|
-
if (!validationSchema) {
|
796
|
-
throw new Error(
|
797
|
-
"There is no validation schema generated, this is likely due to the schema not being loaded yet."
|
798
|
-
);
|
799
|
-
}
|
800
|
-
try {
|
801
|
-
validationSchema.validateSync(document, { abortEarly: false, strict: true });
|
802
|
-
return null;
|
803
|
-
} catch (error2) {
|
804
|
-
if (error2 instanceof yup.ValidationError) {
|
805
|
-
return strapiAdmin.getYupValidationErrors(error2);
|
806
|
-
}
|
807
|
-
throw error2;
|
808
|
-
}
|
926
|
+
}, [error, formatAPIError, toggleNotification]);
|
927
|
+
const editLayout = React__namespace.useMemo(
|
928
|
+
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
929
|
+
layout: [],
|
930
|
+
components: {},
|
931
|
+
metadatas: {},
|
932
|
+
options: {},
|
933
|
+
settings: DEFAULT_SETTINGS
|
809
934
|
},
|
810
|
-
[
|
935
|
+
[data, isLoading, schemas, schema, components]
|
936
|
+
);
|
937
|
+
const listLayout = React__namespace.useMemo(() => {
|
938
|
+
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
939
|
+
layout: [],
|
940
|
+
metadatas: {},
|
941
|
+
options: {},
|
942
|
+
settings: DEFAULT_SETTINGS
|
943
|
+
};
|
944
|
+
}, [data, isLoading, schemas, schema, components]);
|
945
|
+
const { layout: edit } = React__namespace.useMemo(
|
946
|
+
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
947
|
+
layout: editLayout,
|
948
|
+
query
|
949
|
+
}),
|
950
|
+
[editLayout, query, runHookWaterfall]
|
811
951
|
);
|
812
|
-
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
813
952
|
return {
|
814
|
-
|
815
|
-
document: data?.data,
|
816
|
-
meta: data?.meta,
|
953
|
+
error,
|
817
954
|
isLoading,
|
818
|
-
|
819
|
-
|
820
|
-
};
|
821
|
-
};
|
822
|
-
const useDoc = () => {
|
823
|
-
const { id, slug, collectionType, origin } = reactRouterDom.useParams();
|
824
|
-
const [{ query }] = strapiAdmin.useQueryParams();
|
825
|
-
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
826
|
-
if (!collectionType) {
|
827
|
-
throw new Error("Could not find collectionType in url params");
|
828
|
-
}
|
829
|
-
if (!slug) {
|
830
|
-
throw new Error("Could not find model in url params");
|
831
|
-
}
|
832
|
-
return {
|
833
|
-
collectionType,
|
834
|
-
model: slug,
|
835
|
-
id: origin || id === "create" ? void 0 : id,
|
836
|
-
...useDocument(
|
837
|
-
{ documentId: origin || id, model: slug, collectionType, params },
|
838
|
-
{
|
839
|
-
skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
|
840
|
-
}
|
841
|
-
)
|
955
|
+
edit,
|
956
|
+
list: listLayout
|
842
957
|
};
|
843
958
|
};
|
844
|
-
const
|
845
|
-
|
846
|
-
|
847
|
-
}
|
848
|
-
return Object.keys(trad).reduce((acc, current) => {
|
849
|
-
acc[`${pluginId}.${current}`] = trad[current];
|
850
|
-
return acc;
|
851
|
-
}, {});
|
959
|
+
const useDocLayout = () => {
|
960
|
+
const { model } = useDoc();
|
961
|
+
return useDocumentLayout(model);
|
852
962
|
};
|
853
|
-
const
|
854
|
-
|
855
|
-
|
856
|
-
|
963
|
+
const formatEditLayout = (data, {
|
964
|
+
schemas,
|
965
|
+
schema,
|
966
|
+
components
|
967
|
+
}) => {
|
968
|
+
let currentPanelIndex = 0;
|
969
|
+
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
970
|
+
data.contentType.layouts.edit,
|
971
|
+
schema?.attributes,
|
972
|
+
data.contentType.metadatas,
|
973
|
+
{ configurations: data.components, schemas: components },
|
974
|
+
schemas
|
975
|
+
).reduce((panels, row) => {
|
976
|
+
if (row.some((field) => field.type === "dynamiczone")) {
|
977
|
+
panels.push([row]);
|
978
|
+
currentPanelIndex += 2;
|
979
|
+
} else {
|
980
|
+
if (!panels[currentPanelIndex]) {
|
981
|
+
panels.push([]);
|
982
|
+
}
|
983
|
+
panels[currentPanelIndex].push(row);
|
984
|
+
}
|
985
|
+
return panels;
|
986
|
+
}, []);
|
987
|
+
const componentEditAttributes = Object.entries(data.components).reduce(
|
988
|
+
(acc, [uid, configuration]) => {
|
989
|
+
acc[uid] = {
|
990
|
+
layout: convertEditLayoutToFieldLayouts(
|
991
|
+
configuration.layouts.edit,
|
992
|
+
components[uid].attributes,
|
993
|
+
configuration.metadatas,
|
994
|
+
{ configurations: data.components, schemas: components }
|
995
|
+
),
|
996
|
+
settings: {
|
997
|
+
...configuration.settings,
|
998
|
+
icon: components[uid].info.icon,
|
999
|
+
displayName: components[uid].info.displayName
|
1000
|
+
}
|
1001
|
+
};
|
1002
|
+
return acc;
|
1003
|
+
},
|
1004
|
+
{}
|
1005
|
+
);
|
1006
|
+
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1007
|
+
(acc, [attribute, metadata]) => {
|
1008
|
+
return {
|
1009
|
+
...acc,
|
1010
|
+
[attribute]: metadata.edit
|
1011
|
+
};
|
1012
|
+
},
|
1013
|
+
{}
|
1014
|
+
);
|
1015
|
+
return {
|
1016
|
+
layout: panelledEditAttributes,
|
1017
|
+
components: componentEditAttributes,
|
1018
|
+
metadatas: editMetadatas,
|
1019
|
+
settings: {
|
1020
|
+
...data.contentType.settings,
|
1021
|
+
displayName: schema?.info.displayName
|
1022
|
+
},
|
1023
|
+
options: {
|
1024
|
+
...schema?.options,
|
1025
|
+
...schema?.pluginOptions,
|
1026
|
+
...data.contentType.options
|
1027
|
+
}
|
1028
|
+
};
|
1029
|
+
};
|
1030
|
+
const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
|
1031
|
+
return rows.map(
|
1032
|
+
(row) => row.map((field) => {
|
1033
|
+
const attribute = attributes[field.name];
|
1034
|
+
if (!attribute) {
|
1035
|
+
return null;
|
1036
|
+
}
|
1037
|
+
const { edit: metadata } = metadatas[field.name];
|
1038
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1039
|
+
return {
|
1040
|
+
attribute,
|
1041
|
+
disabled: !metadata.editable,
|
1042
|
+
hint: metadata.description,
|
1043
|
+
label: metadata.label ?? "",
|
1044
|
+
name: field.name,
|
1045
|
+
// @ts-expect-error – mainField does exist on the metadata for a relation.
|
1046
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1047
|
+
schemas,
|
1048
|
+
components: components?.schemas ?? {}
|
1049
|
+
}),
|
1050
|
+
placeholder: metadata.placeholder ?? "",
|
1051
|
+
required: attribute.required ?? false,
|
1052
|
+
size: field.size,
|
1053
|
+
unique: "unique" in attribute ? attribute.unique : false,
|
1054
|
+
visible: metadata.visible ?? true,
|
1055
|
+
type: attribute.type
|
1056
|
+
};
|
1057
|
+
}).filter((field) => field !== null)
|
1058
|
+
);
|
1059
|
+
};
|
1060
|
+
const formatListLayout = (data, {
|
1061
|
+
schemas,
|
1062
|
+
schema,
|
1063
|
+
components
|
1064
|
+
}) => {
|
1065
|
+
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1066
|
+
(acc, [attribute, metadata]) => {
|
1067
|
+
return {
|
1068
|
+
...acc,
|
1069
|
+
[attribute]: metadata.list
|
1070
|
+
};
|
1071
|
+
},
|
1072
|
+
{}
|
1073
|
+
);
|
1074
|
+
const listAttributes = convertListLayoutToFieldLayouts(
|
1075
|
+
data.contentType.layouts.list,
|
1076
|
+
schema?.attributes,
|
1077
|
+
listMetadatas,
|
1078
|
+
{ configurations: data.components, schemas: components },
|
1079
|
+
schemas
|
1080
|
+
);
|
1081
|
+
return {
|
1082
|
+
layout: listAttributes,
|
1083
|
+
settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
|
1084
|
+
metadatas: listMetadatas,
|
1085
|
+
options: {
|
1086
|
+
...schema?.options,
|
1087
|
+
...schema?.pluginOptions,
|
1088
|
+
...data.contentType.options
|
1089
|
+
}
|
1090
|
+
};
|
1091
|
+
};
|
1092
|
+
const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
|
1093
|
+
return columns.map((name) => {
|
1094
|
+
const attribute = attributes[name];
|
1095
|
+
if (!attribute) {
|
1096
|
+
return null;
|
1097
|
+
}
|
1098
|
+
const metadata = metadatas[name];
|
1099
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1100
|
+
return {
|
1101
|
+
attribute,
|
1102
|
+
label: metadata.label ?? "",
|
1103
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1104
|
+
schemas,
|
1105
|
+
components: components?.schemas ?? {}
|
1106
|
+
}),
|
1107
|
+
name,
|
1108
|
+
searchable: metadata.searchable ?? true,
|
1109
|
+
sortable: metadata.sortable ?? true
|
1110
|
+
};
|
1111
|
+
}).filter((field) => field !== null);
|
1112
|
+
};
|
1113
|
+
const useDocument = (args, opts) => {
|
1114
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
1115
|
+
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
1116
|
+
const {
|
1117
|
+
currentData: data,
|
1118
|
+
isLoading: isLoadingDocument,
|
1119
|
+
isFetching: isFetchingDocument,
|
1120
|
+
error
|
1121
|
+
} = useGetDocumentQuery(args, {
|
1122
|
+
...opts,
|
1123
|
+
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
1124
|
+
});
|
1125
|
+
const {
|
1126
|
+
components,
|
1127
|
+
schema,
|
1128
|
+
schemas,
|
1129
|
+
isLoading: isLoadingSchema
|
1130
|
+
} = useContentTypeSchema(args.model);
|
1131
|
+
React__namespace.useEffect(() => {
|
1132
|
+
if (error) {
|
1133
|
+
toggleNotification({
|
1134
|
+
type: "danger",
|
1135
|
+
message: formatAPIError(error)
|
1136
|
+
});
|
1137
|
+
}
|
1138
|
+
}, [toggleNotification, error, formatAPIError, args.collectionType]);
|
1139
|
+
const validationSchema = React__namespace.useMemo(() => {
|
1140
|
+
if (!schema) {
|
1141
|
+
return null;
|
1142
|
+
}
|
1143
|
+
return createYupSchema(schema.attributes, components);
|
1144
|
+
}, [schema, components]);
|
1145
|
+
const validate = React__namespace.useCallback(
|
1146
|
+
(document) => {
|
1147
|
+
if (!validationSchema) {
|
1148
|
+
throw new Error(
|
1149
|
+
"There is no validation schema generated, this is likely due to the schema not being loaded yet."
|
1150
|
+
);
|
1151
|
+
}
|
1152
|
+
try {
|
1153
|
+
validationSchema.validateSync(document, { abortEarly: false, strict: true });
|
1154
|
+
return null;
|
1155
|
+
} catch (error2) {
|
1156
|
+
if (error2 instanceof yup.ValidationError) {
|
1157
|
+
return strapiAdmin.getYupValidationErrors(error2);
|
1158
|
+
}
|
1159
|
+
throw error2;
|
1160
|
+
}
|
1161
|
+
},
|
1162
|
+
[validationSchema]
|
1163
|
+
);
|
1164
|
+
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
1165
|
+
const hasError = !!error;
|
1166
|
+
return {
|
1167
|
+
components,
|
1168
|
+
document: data?.data,
|
1169
|
+
meta: data?.meta,
|
1170
|
+
isLoading,
|
1171
|
+
hasError,
|
1172
|
+
schema,
|
1173
|
+
schemas,
|
1174
|
+
validate
|
1175
|
+
};
|
1176
|
+
};
|
1177
|
+
const useDoc = () => {
|
1178
|
+
const { id, slug, collectionType, origin } = reactRouterDom.useParams();
|
1179
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
1180
|
+
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
1181
|
+
if (!collectionType) {
|
1182
|
+
throw new Error("Could not find collectionType in url params");
|
1183
|
+
}
|
1184
|
+
if (!slug) {
|
1185
|
+
throw new Error("Could not find model in url params");
|
1186
|
+
}
|
1187
|
+
return {
|
1188
|
+
collectionType,
|
1189
|
+
model: slug,
|
1190
|
+
id: origin || id === "create" ? void 0 : id,
|
1191
|
+
...useDocument(
|
1192
|
+
{ documentId: origin || id, model: slug, collectionType, params },
|
1193
|
+
{
|
1194
|
+
skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
|
1195
|
+
}
|
1196
|
+
)
|
1197
|
+
};
|
1198
|
+
};
|
1199
|
+
const useContentManagerContext = () => {
|
1200
|
+
const {
|
1201
|
+
collectionType,
|
1202
|
+
model,
|
1203
|
+
id,
|
1204
|
+
components,
|
1205
|
+
isLoading: isLoadingDoc,
|
1206
|
+
schema,
|
1207
|
+
schemas
|
1208
|
+
} = useDoc();
|
1209
|
+
const layout = useDocumentLayout(model);
|
1210
|
+
const form = strapiAdmin.useForm("useContentManagerContext", (state) => state);
|
1211
|
+
const isSingleType = collectionType === SINGLE_TYPES;
|
1212
|
+
const slug = model;
|
1213
|
+
const isCreatingEntry = id === "create";
|
1214
|
+
useContentTypeSchema();
|
1215
|
+
const isLoading = isLoadingDoc || layout.isLoading;
|
1216
|
+
const error = layout.error;
|
1217
|
+
return {
|
1218
|
+
error,
|
1219
|
+
isLoading,
|
1220
|
+
// Base metadata
|
1221
|
+
model,
|
1222
|
+
collectionType,
|
1223
|
+
id,
|
1224
|
+
slug,
|
1225
|
+
isCreatingEntry,
|
1226
|
+
isSingleType,
|
1227
|
+
hasDraftAndPublish: schema?.options?.draftAndPublish ?? false,
|
1228
|
+
// All schema infos
|
1229
|
+
components,
|
1230
|
+
contentType: schema,
|
1231
|
+
contentTypes: schemas,
|
1232
|
+
// Form state
|
1233
|
+
form,
|
1234
|
+
// layout infos
|
1235
|
+
layout
|
1236
|
+
};
|
1237
|
+
};
|
1238
|
+
const prefixPluginTranslations = (trad, pluginId) => {
|
1239
|
+
if (!pluginId) {
|
1240
|
+
throw new TypeError("pluginId can't be empty");
|
1241
|
+
}
|
1242
|
+
return Object.keys(trad).reduce((acc, current) => {
|
1243
|
+
acc[`${pluginId}.${current}`] = trad[current];
|
1244
|
+
return acc;
|
1245
|
+
}, {});
|
1246
|
+
};
|
1247
|
+
const getTranslation = (id) => `content-manager.${id}`;
|
1248
|
+
const DEFAULT_UNEXPECTED_ERROR_MSG = {
|
1249
|
+
id: "notification.error",
|
1250
|
+
defaultMessage: "An error occurred, please try again"
|
857
1251
|
};
|
858
1252
|
const useDocumentActions = () => {
|
859
1253
|
const { toggleNotification } = strapiAdmin.useNotification();
|
860
1254
|
const { formatMessage } = reactIntl.useIntl();
|
861
1255
|
const { trackUsage } = strapiAdmin.useTracking();
|
862
1256
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
1257
|
+
const navigate = reactRouterDom.useNavigate();
|
1258
|
+
const setCurrentStep = strapiAdmin.useGuidedTour("useDocumentActions", (state) => state.setCurrentStep);
|
863
1259
|
const [deleteDocument] = useDeleteDocumentMutation();
|
864
1260
|
const _delete = React__namespace.useCallback(
|
865
1261
|
async ({ collectionType, model, documentId, params }, trackerProperty) => {
|
@@ -1174,6 +1570,7 @@ const useDocumentActions = () => {
|
|
1174
1570
|
defaultMessage: "Saved document"
|
1175
1571
|
})
|
1176
1572
|
});
|
1573
|
+
setCurrentStep("contentManager.success");
|
1177
1574
|
return res.data;
|
1178
1575
|
} catch (err) {
|
1179
1576
|
toggleNotification({
|
@@ -1195,7 +1592,6 @@ const useDocumentActions = () => {
|
|
1195
1592
|
sourceId
|
1196
1593
|
});
|
1197
1594
|
if ("error" in res) {
|
1198
|
-
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1199
1595
|
return { error: res.error };
|
1200
1596
|
}
|
1201
1597
|
toggleNotification({
|
@@ -1214,7 +1610,7 @@ const useDocumentActions = () => {
|
|
1214
1610
|
throw err;
|
1215
1611
|
}
|
1216
1612
|
},
|
1217
|
-
[autoCloneDocument,
|
1613
|
+
[autoCloneDocument, formatMessage, toggleNotification]
|
1218
1614
|
);
|
1219
1615
|
const [cloneDocument] = useCloneDocumentMutation();
|
1220
1616
|
const clone = React__namespace.useCallback(
|
@@ -1240,6 +1636,7 @@ const useDocumentActions = () => {
|
|
1240
1636
|
defaultMessage: "Cloned document"
|
1241
1637
|
})
|
1242
1638
|
});
|
1639
|
+
navigate(`../../${res.data.data.documentId}`, { relative: "path" });
|
1243
1640
|
return res.data;
|
1244
1641
|
} catch (err) {
|
1245
1642
|
toggleNotification({
|
@@ -1250,7 +1647,7 @@ const useDocumentActions = () => {
|
|
1250
1647
|
throw err;
|
1251
1648
|
}
|
1252
1649
|
},
|
1253
|
-
[cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError]
|
1650
|
+
[cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError, navigate]
|
1254
1651
|
);
|
1255
1652
|
const [getDoc] = useLazyGetDocumentQuery();
|
1256
1653
|
const getDocument = React__namespace.useCallback(
|
@@ -1276,7 +1673,7 @@ const useDocumentActions = () => {
|
|
1276
1673
|
};
|
1277
1674
|
};
|
1278
1675
|
const ProtectedHistoryPage = React.lazy(
|
1279
|
-
() => Promise.resolve().then(() => require("./History-
|
1676
|
+
() => Promise.resolve().then(() => require("./History-CyA8tvJZ.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
|
1280
1677
|
);
|
1281
1678
|
const routes$1 = [
|
1282
1679
|
{
|
@@ -1289,31 +1686,31 @@ const routes$1 = [
|
|
1289
1686
|
}
|
1290
1687
|
];
|
1291
1688
|
const ProtectedEditViewPage = React.lazy(
|
1292
|
-
() => Promise.resolve().then(() => require("./EditViewPage-
|
1689
|
+
() => Promise.resolve().then(() => require("./EditViewPage-DYDpe5Wi.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
|
1293
1690
|
);
|
1294
1691
|
const ProtectedListViewPage = React.lazy(
|
1295
|
-
() => Promise.resolve().then(() => require("./ListViewPage-
|
1692
|
+
() => Promise.resolve().then(() => require("./ListViewPage-BIT0M8VG.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
|
1296
1693
|
);
|
1297
1694
|
const ProtectedListConfiguration = React.lazy(
|
1298
|
-
() => Promise.resolve().then(() => require("./ListConfigurationPage-
|
1695
|
+
() => Promise.resolve().then(() => require("./ListConfigurationPage-pJV7aG2V.js")).then((mod) => ({
|
1299
1696
|
default: mod.ProtectedListConfiguration
|
1300
1697
|
}))
|
1301
1698
|
);
|
1302
1699
|
const ProtectedEditConfigurationPage = React.lazy(
|
1303
|
-
() => Promise.resolve().then(() => require("./EditConfigurationPage-
|
1700
|
+
() => Promise.resolve().then(() => require("./EditConfigurationPage-NC89F29V.js")).then((mod) => ({
|
1304
1701
|
default: mod.ProtectedEditConfigurationPage
|
1305
1702
|
}))
|
1306
1703
|
);
|
1307
1704
|
const ProtectedComponentConfigurationPage = React.lazy(
|
1308
|
-
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-
|
1705
|
+
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-B42mQr1K.js")).then((mod) => ({
|
1309
1706
|
default: mod.ProtectedComponentConfigurationPage
|
1310
1707
|
}))
|
1311
1708
|
);
|
1312
1709
|
const NoPermissions = React.lazy(
|
1313
|
-
() => Promise.resolve().then(() => require("./NoPermissionsPage-
|
1710
|
+
() => Promise.resolve().then(() => require("./NoPermissionsPage-C8wkEaOF.js")).then((mod) => ({ default: mod.NoPermissions }))
|
1314
1711
|
);
|
1315
1712
|
const NoContentType = React.lazy(
|
1316
|
-
() => Promise.resolve().then(() => require("./NoContentTypePage-
|
1713
|
+
() => Promise.resolve().then(() => require("./NoContentTypePage-uIBsBUmH.js")).then((mod) => ({ default: mod.NoContentType }))
|
1317
1714
|
);
|
1318
1715
|
const CollectionTypePages = () => {
|
1319
1716
|
const { collectionType } = reactRouterDom.useParams();
|
@@ -1427,12 +1824,14 @@ const DocumentActionButton = (action) => {
|
|
1427
1824
|
/* @__PURE__ */ jsxRuntime.jsx(
|
1428
1825
|
designSystem.Button,
|
1429
1826
|
{
|
1430
|
-
flex:
|
1827
|
+
flex: "auto",
|
1431
1828
|
startIcon: action.icon,
|
1432
1829
|
disabled: action.disabled,
|
1433
1830
|
onClick: handleClick(action),
|
1434
1831
|
justifyContent: "center",
|
1435
1832
|
variant: action.variant || "default",
|
1833
|
+
paddingTop: "7px",
|
1834
|
+
paddingBottom: "7px",
|
1436
1835
|
children: action.label
|
1437
1836
|
}
|
1438
1837
|
),
|
@@ -1497,9 +1896,9 @@ const DocumentActionsMenu = ({
|
|
1497
1896
|
disabled: isDisabled,
|
1498
1897
|
size: "S",
|
1499
1898
|
endIcon: null,
|
1500
|
-
paddingTop: "
|
1501
|
-
paddingLeft: "
|
1502
|
-
paddingRight: "
|
1899
|
+
paddingTop: "4px",
|
1900
|
+
paddingLeft: "7px",
|
1901
|
+
paddingRight: "7px",
|
1503
1902
|
variant,
|
1504
1903
|
children: [
|
1505
1904
|
/* @__PURE__ */ jsxRuntime.jsx(Icons.More, { "aria-hidden": true, focusable: false }),
|
@@ -1510,7 +1909,7 @@ const DocumentActionsMenu = ({
|
|
1510
1909
|
]
|
1511
1910
|
}
|
1512
1911
|
),
|
1513
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, {
|
1912
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
|
1514
1913
|
actions2.map((action) => {
|
1515
1914
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
1516
1915
|
designSystem.Menu.Item,
|
@@ -1519,10 +1918,25 @@ const DocumentActionsMenu = ({
|
|
1519
1918
|
onSelect: handleClick(action),
|
1520
1919
|
display: "block",
|
1521
1920
|
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: [
|
1522
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1921
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
1922
|
+
designSystem.Flex,
|
1923
|
+
{
|
1924
|
+
color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
|
1925
|
+
gap: 2,
|
1926
|
+
tag: "span",
|
1927
|
+
children: [
|
1928
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
1929
|
+
designSystem.Flex,
|
1930
|
+
{
|
1931
|
+
tag: "span",
|
1932
|
+
color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
|
1933
|
+
children: action.icon
|
1934
|
+
}
|
1935
|
+
),
|
1936
|
+
action.label
|
1937
|
+
]
|
1938
|
+
}
|
1939
|
+
),
|
1526
1940
|
action.id.startsWith("HistoryAction") && /* @__PURE__ */ jsxRuntime.jsx(
|
1527
1941
|
designSystem.Flex,
|
1528
1942
|
{
|
@@ -1619,11 +2033,11 @@ const DocumentActionConfirmDialog = ({
|
|
1619
2033
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
|
1620
2034
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: content }),
|
1621
2035
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
|
1622
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: formatMessage({
|
2036
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", fullWidth: true, children: formatMessage({
|
1623
2037
|
id: "app.components.Button.cancel",
|
1624
2038
|
defaultMessage: "Cancel"
|
1625
2039
|
}) }) }),
|
1626
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, children: formatMessage({
|
2040
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, fullWidth: true, children: formatMessage({
|
1627
2041
|
id: "app.components.Button.confirm",
|
1628
2042
|
defaultMessage: "Confirm"
|
1629
2043
|
}) })
|
@@ -1646,8 +2060,8 @@ const DocumentActionModal = ({
|
|
1646
2060
|
};
|
1647
2061
|
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { children: [
|
1648
2062
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: title }) }),
|
1649
|
-
|
1650
|
-
|
2063
|
+
typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: Content }),
|
2064
|
+
typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
|
1651
2065
|
] }) });
|
1652
2066
|
};
|
1653
2067
|
const PublishAction$1 = ({
|
@@ -1662,12 +2076,10 @@ const PublishAction$1 = ({
|
|
1662
2076
|
const navigate = reactRouterDom.useNavigate();
|
1663
2077
|
const { toggleNotification } = strapiAdmin.useNotification();
|
1664
2078
|
const { _unstableFormatValidationErrors: formatValidationErrors } = strapiAdmin.useAPIErrorHandler();
|
2079
|
+
const isListView = reactRouterDom.useMatch(LIST_PATH) !== null;
|
1665
2080
|
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
1666
2081
|
const { formatMessage } = reactIntl.useIntl();
|
1667
|
-
const { canPublish
|
1668
|
-
"PublishAction",
|
1669
|
-
({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
|
1670
|
-
);
|
2082
|
+
const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
|
1671
2083
|
const { publish } = useDocumentActions();
|
1672
2084
|
const [
|
1673
2085
|
countDraftRelations,
|
@@ -1719,24 +2131,25 @@ const PublishAction$1 = ({
|
|
1719
2131
|
}
|
1720
2132
|
}, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
|
1721
2133
|
React__namespace.useEffect(() => {
|
1722
|
-
if (documentId) {
|
1723
|
-
|
1724
|
-
const { data, error } = await countDraftRelations({
|
1725
|
-
collectionType,
|
1726
|
-
model,
|
1727
|
-
documentId,
|
1728
|
-
params
|
1729
|
-
});
|
1730
|
-
if (error) {
|
1731
|
-
throw error;
|
1732
|
-
}
|
1733
|
-
if (data) {
|
1734
|
-
setServerCountOfDraftRelations(data.data);
|
1735
|
-
}
|
1736
|
-
};
|
1737
|
-
fetchDraftRelationsCount();
|
2134
|
+
if (!document || !document.documentId || isListView) {
|
2135
|
+
return;
|
1738
2136
|
}
|
1739
|
-
|
2137
|
+
const fetchDraftRelationsCount = async () => {
|
2138
|
+
const { data, error } = await countDraftRelations({
|
2139
|
+
collectionType,
|
2140
|
+
model,
|
2141
|
+
documentId,
|
2142
|
+
params
|
2143
|
+
});
|
2144
|
+
if (error) {
|
2145
|
+
throw error;
|
2146
|
+
}
|
2147
|
+
if (data) {
|
2148
|
+
setServerCountOfDraftRelations(data.data);
|
2149
|
+
}
|
2150
|
+
};
|
2151
|
+
fetchDraftRelationsCount();
|
2152
|
+
}, [isListView, document, documentId, countDraftRelations, collectionType, model, params]);
|
1740
2153
|
const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
|
1741
2154
|
if (!schema?.options?.draftAndPublish) {
|
1742
2155
|
return null;
|
@@ -1744,7 +2157,9 @@ const PublishAction$1 = ({
|
|
1744
2157
|
const performPublish = async () => {
|
1745
2158
|
setSubmitting(true);
|
1746
2159
|
try {
|
1747
|
-
const { errors } = await validate(
|
2160
|
+
const { errors } = await validate(true, {
|
2161
|
+
status: "published"
|
2162
|
+
});
|
1748
2163
|
if (errors) {
|
1749
2164
|
toggleNotification({
|
1750
2165
|
type: "danger",
|
@@ -1777,7 +2192,8 @@ const PublishAction$1 = ({
|
|
1777
2192
|
}
|
1778
2193
|
};
|
1779
2194
|
const totalDraftRelations = localCountOfDraftRelations + serverCountOfDraftRelations;
|
1780
|
-
const
|
2195
|
+
const enableDraftRelationsCount = false;
|
2196
|
+
const hasDraftRelations = enableDraftRelationsCount;
|
1781
2197
|
return {
|
1782
2198
|
/**
|
1783
2199
|
* Disabled when:
|
@@ -1787,18 +2203,13 @@ const PublishAction$1 = ({
|
|
1787
2203
|
* - the document is already published & not modified
|
1788
2204
|
* - the document is being created & not modified
|
1789
2205
|
* - the user doesn't have the permission to publish
|
1790
|
-
* - the user doesn't have the permission to create a new document
|
1791
|
-
* - the user doesn't have the permission to update the document
|
1792
2206
|
*/
|
1793
|
-
disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish
|
2207
|
+
disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish,
|
1794
2208
|
label: formatMessage({
|
1795
2209
|
id: "app.utils.publish",
|
1796
2210
|
defaultMessage: "Publish"
|
1797
2211
|
}),
|
1798
2212
|
onClick: async () => {
|
1799
|
-
if (hasDraftRelations) {
|
1800
|
-
return;
|
1801
|
-
}
|
1802
2213
|
await performPublish();
|
1803
2214
|
},
|
1804
2215
|
dialog: hasDraftRelations ? {
|
@@ -1837,10 +2248,6 @@ const UpdateAction = ({
|
|
1837
2248
|
const cloneMatch = reactRouterDom.useMatch(CLONE_PATH);
|
1838
2249
|
const isCloning = cloneMatch !== null;
|
1839
2250
|
const { formatMessage } = reactIntl.useIntl();
|
1840
|
-
const { canCreate, canUpdate } = useDocumentRBAC("UpdateAction", ({ canCreate: canCreate2, canUpdate: canUpdate2 }) => ({
|
1841
|
-
canCreate: canCreate2,
|
1842
|
-
canUpdate: canUpdate2
|
1843
|
-
}));
|
1844
2251
|
const { create, update, clone } = useDocumentActions();
|
1845
2252
|
const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
|
1846
2253
|
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
@@ -1857,10 +2264,8 @@ const UpdateAction = ({
|
|
1857
2264
|
* - the form is submitting
|
1858
2265
|
* - the document is not modified & we're not cloning (you can save a clone entity straight away)
|
1859
2266
|
* - the active tab is the published tab
|
1860
|
-
* - the user doesn't have the permission to create a new document
|
1861
|
-
* - the user doesn't have the permission to update the document
|
1862
2267
|
*/
|
1863
|
-
disabled: isSubmitting || !modified && !isCloning || activeTab === "published"
|
2268
|
+
disabled: isSubmitting || !modified && !isCloning || activeTab === "published",
|
1864
2269
|
label: formatMessage({
|
1865
2270
|
id: "content-manager.containers.Edit.save",
|
1866
2271
|
defaultMessage: "Save"
|
@@ -1868,7 +2273,9 @@ const UpdateAction = ({
|
|
1868
2273
|
onClick: async () => {
|
1869
2274
|
setSubmitting(true);
|
1870
2275
|
try {
|
1871
|
-
const { errors } = await validate(
|
2276
|
+
const { errors } = await validate(true, {
|
2277
|
+
status: "draft"
|
2278
|
+
});
|
1872
2279
|
if (errors) {
|
1873
2280
|
toggleNotification({
|
1874
2281
|
type: "danger",
|
@@ -1889,10 +2296,13 @@ const UpdateAction = ({
|
|
1889
2296
|
document
|
1890
2297
|
);
|
1891
2298
|
if ("data" in res) {
|
1892
|
-
navigate(
|
1893
|
-
|
1894
|
-
|
1895
|
-
|
2299
|
+
navigate(
|
2300
|
+
{
|
2301
|
+
pathname: `../${res.data.documentId}`,
|
2302
|
+
search: rawQuery
|
2303
|
+
},
|
2304
|
+
{ relative: "path" }
|
2305
|
+
);
|
1896
2306
|
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1897
2307
|
setErrors(formatValidationErrors(res.error));
|
1898
2308
|
}
|
@@ -1922,10 +2332,10 @@ const UpdateAction = ({
|
|
1922
2332
|
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1923
2333
|
navigate(
|
1924
2334
|
{
|
1925
|
-
pathname: `../${
|
2335
|
+
pathname: `../${res.data.documentId}`,
|
1926
2336
|
search: rawQuery
|
1927
2337
|
},
|
1928
|
-
{ replace: true }
|
2338
|
+
{ replace: true, relative: "path" }
|
1929
2339
|
);
|
1930
2340
|
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1931
2341
|
setErrors(formatValidationErrors(res.error));
|
@@ -1970,7 +2380,7 @@ const UnpublishAction$1 = ({
|
|
1970
2380
|
id: "app.utils.unpublish",
|
1971
2381
|
defaultMessage: "Unpublish"
|
1972
2382
|
}),
|
1973
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
2383
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
|
1974
2384
|
onClick: async () => {
|
1975
2385
|
if (!documentId && collectionType !== SINGLE_TYPES || isDocumentModified) {
|
1976
2386
|
if (!documentId) {
|
@@ -2082,7 +2492,7 @@ const DiscardAction = ({
|
|
2082
2492
|
id: "content-manager.actions.discard.label",
|
2083
2493
|
defaultMessage: "Discard changes"
|
2084
2494
|
}),
|
2085
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
2495
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
|
2086
2496
|
position: ["panel", "table-row"],
|
2087
2497
|
variant: "danger",
|
2088
2498
|
dialog: {
|
@@ -2110,11 +2520,6 @@ const DiscardAction = ({
|
|
2110
2520
|
};
|
2111
2521
|
};
|
2112
2522
|
DiscardAction.type = "discard";
|
2113
|
-
const StyledCrossCircle = styledComponents.styled(Icons.CrossCircle)`
|
2114
|
-
path {
|
2115
|
-
fill: currentColor;
|
2116
|
-
}
|
2117
|
-
`;
|
2118
2523
|
const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
|
2119
2524
|
const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
|
2120
2525
|
const RelativeTime = React__namespace.forwardRef(
|
@@ -2162,7 +2567,7 @@ const getDisplayName = ({
|
|
2162
2567
|
};
|
2163
2568
|
const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
2164
2569
|
const DocumentStatus = ({ status = "draft", ...restProps }) => {
|
2165
|
-
const statusVariant = status === "draft" ? "
|
2570
|
+
const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
|
2166
2571
|
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) }) });
|
2167
2572
|
};
|
2168
2573
|
const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
@@ -2261,12 +2666,12 @@ const Information = ({ activeTab }) => {
|
|
2261
2666
|
isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
|
2262
2667
|
label: formatMessage({
|
2263
2668
|
id: "content-manager.containers.edit.information.last-published.label",
|
2264
|
-
defaultMessage: "
|
2669
|
+
defaultMessage: "Published"
|
2265
2670
|
}),
|
2266
2671
|
value: formatMessage(
|
2267
2672
|
{
|
2268
2673
|
id: "content-manager.containers.edit.information.last-published.value",
|
2269
|
-
defaultMessage: `
|
2674
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2270
2675
|
},
|
2271
2676
|
{
|
2272
2677
|
time: /* @__PURE__ */ jsxRuntime.jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
|
@@ -2279,12 +2684,12 @@ const Information = ({ activeTab }) => {
|
|
2279
2684
|
isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
|
2280
2685
|
label: formatMessage({
|
2281
2686
|
id: "content-manager.containers.edit.information.last-draft.label",
|
2282
|
-
defaultMessage: "
|
2687
|
+
defaultMessage: "Updated"
|
2283
2688
|
}),
|
2284
2689
|
value: formatMessage(
|
2285
2690
|
{
|
2286
2691
|
id: "content-manager.containers.edit.information.last-draft.value",
|
2287
|
-
defaultMessage: `
|
2692
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2288
2693
|
},
|
2289
2694
|
{
|
2290
2695
|
time: /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -2302,12 +2707,12 @@ const Information = ({ activeTab }) => {
|
|
2302
2707
|
isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
|
2303
2708
|
label: formatMessage({
|
2304
2709
|
id: "content-manager.containers.edit.information.document.label",
|
2305
|
-
defaultMessage: "
|
2710
|
+
defaultMessage: "Created"
|
2306
2711
|
}),
|
2307
2712
|
value: formatMessage(
|
2308
2713
|
{
|
2309
2714
|
id: "content-manager.containers.edit.information.document.value",
|
2310
|
-
defaultMessage: `
|
2715
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2311
2716
|
},
|
2312
2717
|
{
|
2313
2718
|
time: /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -2345,25 +2750,77 @@ const Information = ({ activeTab }) => {
|
|
2345
2750
|
);
|
2346
2751
|
};
|
2347
2752
|
const HeaderActions = ({ actions: actions2 }) => {
|
2348
|
-
|
2349
|
-
|
2753
|
+
const [dialogId, setDialogId] = React__namespace.useState(null);
|
2754
|
+
const handleClick = (action) => async (e) => {
|
2755
|
+
if (!("options" in action)) {
|
2756
|
+
const { onClick = () => false, dialog, id } = action;
|
2757
|
+
const muteDialog = await onClick(e);
|
2758
|
+
if (dialog && !muteDialog) {
|
2759
|
+
e.preventDefault();
|
2760
|
+
setDialogId(id);
|
2761
|
+
}
|
2762
|
+
}
|
2763
|
+
};
|
2764
|
+
const handleClose = () => {
|
2765
|
+
setDialogId(null);
|
2766
|
+
};
|
2767
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 1, children: actions2.map((action) => {
|
2768
|
+
if (action.options) {
|
2350
2769
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
2351
2770
|
designSystem.SingleSelect,
|
2352
2771
|
{
|
2353
2772
|
size: "S",
|
2354
|
-
disabled: action.disabled,
|
2355
|
-
"aria-label": action.label,
|
2356
2773
|
onChange: action.onSelect,
|
2357
|
-
|
2774
|
+
"aria-label": action.label,
|
2775
|
+
...action,
|
2358
2776
|
children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { ...option, children: label }, option.value))
|
2359
2777
|
},
|
2360
2778
|
action.id
|
2361
2779
|
);
|
2362
2780
|
} else {
|
2363
|
-
|
2781
|
+
if (action.type === "icon") {
|
2782
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
|
2783
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
2784
|
+
designSystem.IconButton,
|
2785
|
+
{
|
2786
|
+
disabled: action.disabled,
|
2787
|
+
label: action.label,
|
2788
|
+
size: "S",
|
2789
|
+
onClick: handleClick(action),
|
2790
|
+
children: action.icon
|
2791
|
+
}
|
2792
|
+
),
|
2793
|
+
action.dialog ? /* @__PURE__ */ jsxRuntime.jsx(
|
2794
|
+
HeaderActionDialog,
|
2795
|
+
{
|
2796
|
+
...action.dialog,
|
2797
|
+
isOpen: dialogId === action.id,
|
2798
|
+
onClose: handleClose
|
2799
|
+
}
|
2800
|
+
) : null
|
2801
|
+
] }, action.id);
|
2802
|
+
}
|
2364
2803
|
}
|
2365
2804
|
}) });
|
2366
2805
|
};
|
2806
|
+
const HeaderActionDialog = ({
|
2807
|
+
onClose,
|
2808
|
+
onCancel,
|
2809
|
+
title,
|
2810
|
+
content: Content,
|
2811
|
+
isOpen
|
2812
|
+
}) => {
|
2813
|
+
const handleClose = async () => {
|
2814
|
+
if (onCancel) {
|
2815
|
+
await onCancel();
|
2816
|
+
}
|
2817
|
+
onClose();
|
2818
|
+
};
|
2819
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
2820
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
|
2821
|
+
typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : Content
|
2822
|
+
] }) });
|
2823
|
+
};
|
2367
2824
|
const ConfigureTheViewAction = ({ collectionType, model }) => {
|
2368
2825
|
const navigate = reactRouterDom.useNavigate();
|
2369
2826
|
const { formatMessage } = reactIntl.useIntl();
|
@@ -2404,12 +2861,16 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
|
2404
2861
|
const { delete: deleteAction } = useDocumentActions();
|
2405
2862
|
const { toggleNotification } = strapiAdmin.useNotification();
|
2406
2863
|
const setSubmitting = strapiAdmin.useForm("DeleteAction", (state) => state.setSubmitting);
|
2864
|
+
const isLocalized = document?.locale != null;
|
2407
2865
|
return {
|
2408
2866
|
disabled: !canDelete || !document,
|
2409
|
-
label: formatMessage(
|
2410
|
-
|
2411
|
-
|
2412
|
-
|
2867
|
+
label: formatMessage(
|
2868
|
+
{
|
2869
|
+
id: "content-manager.actions.delete.label",
|
2870
|
+
defaultMessage: "Delete entry{isLocalized, select, true { (all locales)} other {}}"
|
2871
|
+
},
|
2872
|
+
{ isLocalized }
|
2873
|
+
),
|
2413
2874
|
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}),
|
2414
2875
|
dialog: {
|
2415
2876
|
type: "dialog",
|
@@ -2499,7 +2960,7 @@ const ActionsPanel = () => {
|
|
2499
2960
|
return {
|
2500
2961
|
title: formatMessage({
|
2501
2962
|
id: "content-manager.containers.edit.panels.default.title",
|
2502
|
-
defaultMessage: "
|
2963
|
+
defaultMessage: "Entry"
|
2503
2964
|
}),
|
2504
2965
|
content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
|
2505
2966
|
};
|
@@ -2560,308 +3021,6 @@ const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
|
|
2560
3021
|
}
|
2561
3022
|
);
|
2562
3023
|
});
|
2563
|
-
const HOOKS = {
|
2564
|
-
/**
|
2565
|
-
* Hook that allows to mutate the displayed headers of the list view table
|
2566
|
-
* @constant
|
2567
|
-
* @type {string}
|
2568
|
-
*/
|
2569
|
-
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
2570
|
-
/**
|
2571
|
-
* Hook that allows to mutate the CM's collection types links pre-set filters
|
2572
|
-
* @constant
|
2573
|
-
* @type {string}
|
2574
|
-
*/
|
2575
|
-
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
2576
|
-
/**
|
2577
|
-
* Hook that allows to mutate the CM's edit view layout
|
2578
|
-
* @constant
|
2579
|
-
* @type {string}
|
2580
|
-
*/
|
2581
|
-
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
2582
|
-
/**
|
2583
|
-
* Hook that allows to mutate the CM's single types links pre-set filters
|
2584
|
-
* @constant
|
2585
|
-
* @type {string}
|
2586
|
-
*/
|
2587
|
-
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
2588
|
-
};
|
2589
|
-
const contentTypesApi = contentManagerApi.injectEndpoints({
|
2590
|
-
endpoints: (builder) => ({
|
2591
|
-
getContentTypeConfiguration: builder.query({
|
2592
|
-
query: (uid) => ({
|
2593
|
-
url: `/content-manager/content-types/${uid}/configuration`,
|
2594
|
-
method: "GET"
|
2595
|
-
}),
|
2596
|
-
transformResponse: (response) => response.data,
|
2597
|
-
providesTags: (_result, _error, uid) => [
|
2598
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2599
|
-
{ type: "ContentTypeSettings", id: "LIST" }
|
2600
|
-
]
|
2601
|
-
}),
|
2602
|
-
getAllContentTypeSettings: builder.query({
|
2603
|
-
query: () => "/content-manager/content-types-settings",
|
2604
|
-
transformResponse: (response) => response.data,
|
2605
|
-
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
2606
|
-
}),
|
2607
|
-
updateContentTypeConfiguration: builder.mutation({
|
2608
|
-
query: ({ uid, ...body }) => ({
|
2609
|
-
url: `/content-manager/content-types/${uid}/configuration`,
|
2610
|
-
method: "PUT",
|
2611
|
-
data: body
|
2612
|
-
}),
|
2613
|
-
transformResponse: (response) => response.data,
|
2614
|
-
invalidatesTags: (_result, _error, { uid }) => [
|
2615
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2616
|
-
{ type: "ContentTypeSettings", id: "LIST" },
|
2617
|
-
// Is this necessary?
|
2618
|
-
{ type: "InitialData" }
|
2619
|
-
]
|
2620
|
-
})
|
2621
|
-
})
|
2622
|
-
});
|
2623
|
-
const {
|
2624
|
-
useGetContentTypeConfigurationQuery,
|
2625
|
-
useGetAllContentTypeSettingsQuery,
|
2626
|
-
useUpdateContentTypeConfigurationMutation
|
2627
|
-
} = contentTypesApi;
|
2628
|
-
const checkIfAttributeIsDisplayable = (attribute) => {
|
2629
|
-
const { type } = attribute;
|
2630
|
-
if (type === "relation") {
|
2631
|
-
return !attribute.relation.toLowerCase().includes("morph");
|
2632
|
-
}
|
2633
|
-
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
2634
|
-
};
|
2635
|
-
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
2636
|
-
if (!mainFieldName) {
|
2637
|
-
return void 0;
|
2638
|
-
}
|
2639
|
-
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
2640
|
-
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
2641
|
-
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
2642
|
-
);
|
2643
|
-
return {
|
2644
|
-
name: mainFieldName,
|
2645
|
-
type: mainFieldType ?? "string"
|
2646
|
-
};
|
2647
|
-
};
|
2648
|
-
const DEFAULT_SETTINGS = {
|
2649
|
-
bulkable: false,
|
2650
|
-
filterable: false,
|
2651
|
-
searchable: false,
|
2652
|
-
pagination: false,
|
2653
|
-
defaultSortBy: "",
|
2654
|
-
defaultSortOrder: "asc",
|
2655
|
-
mainField: "id",
|
2656
|
-
pageSize: 10
|
2657
|
-
};
|
2658
|
-
const useDocumentLayout = (model) => {
|
2659
|
-
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
2660
|
-
const [{ query }] = strapiAdmin.useQueryParams();
|
2661
|
-
const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
2662
|
-
const { toggleNotification } = strapiAdmin.useNotification();
|
2663
|
-
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
2664
|
-
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
2665
|
-
const {
|
2666
|
-
data,
|
2667
|
-
isLoading: isLoadingConfigs,
|
2668
|
-
error,
|
2669
|
-
isFetching: isFetchingConfigs
|
2670
|
-
} = useGetContentTypeConfigurationQuery(model);
|
2671
|
-
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
2672
|
-
React__namespace.useEffect(() => {
|
2673
|
-
if (error) {
|
2674
|
-
toggleNotification({
|
2675
|
-
type: "danger",
|
2676
|
-
message: formatAPIError(error)
|
2677
|
-
});
|
2678
|
-
}
|
2679
|
-
}, [error, formatAPIError, toggleNotification]);
|
2680
|
-
const editLayout = React__namespace.useMemo(
|
2681
|
-
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
2682
|
-
layout: [],
|
2683
|
-
components: {},
|
2684
|
-
metadatas: {},
|
2685
|
-
options: {},
|
2686
|
-
settings: DEFAULT_SETTINGS
|
2687
|
-
},
|
2688
|
-
[data, isLoading, schemas, schema, components]
|
2689
|
-
);
|
2690
|
-
const listLayout = React__namespace.useMemo(() => {
|
2691
|
-
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
2692
|
-
layout: [],
|
2693
|
-
metadatas: {},
|
2694
|
-
options: {},
|
2695
|
-
settings: DEFAULT_SETTINGS
|
2696
|
-
};
|
2697
|
-
}, [data, isLoading, schemas, schema, components]);
|
2698
|
-
const { layout: edit } = React__namespace.useMemo(
|
2699
|
-
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
2700
|
-
layout: editLayout,
|
2701
|
-
query
|
2702
|
-
}),
|
2703
|
-
[editLayout, query, runHookWaterfall]
|
2704
|
-
);
|
2705
|
-
return {
|
2706
|
-
error,
|
2707
|
-
isLoading,
|
2708
|
-
edit,
|
2709
|
-
list: listLayout
|
2710
|
-
};
|
2711
|
-
};
|
2712
|
-
const useDocLayout = () => {
|
2713
|
-
const { model } = useDoc();
|
2714
|
-
return useDocumentLayout(model);
|
2715
|
-
};
|
2716
|
-
const formatEditLayout = (data, {
|
2717
|
-
schemas,
|
2718
|
-
schema,
|
2719
|
-
components
|
2720
|
-
}) => {
|
2721
|
-
let currentPanelIndex = 0;
|
2722
|
-
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
2723
|
-
data.contentType.layouts.edit,
|
2724
|
-
schema?.attributes,
|
2725
|
-
data.contentType.metadatas,
|
2726
|
-
{ configurations: data.components, schemas: components },
|
2727
|
-
schemas
|
2728
|
-
).reduce((panels, row) => {
|
2729
|
-
if (row.some((field) => field.type === "dynamiczone")) {
|
2730
|
-
panels.push([row]);
|
2731
|
-
currentPanelIndex += 2;
|
2732
|
-
} else {
|
2733
|
-
if (!panels[currentPanelIndex]) {
|
2734
|
-
panels.push([]);
|
2735
|
-
}
|
2736
|
-
panels[currentPanelIndex].push(row);
|
2737
|
-
}
|
2738
|
-
return panels;
|
2739
|
-
}, []);
|
2740
|
-
const componentEditAttributes = Object.entries(data.components).reduce(
|
2741
|
-
(acc, [uid, configuration]) => {
|
2742
|
-
acc[uid] = {
|
2743
|
-
layout: convertEditLayoutToFieldLayouts(
|
2744
|
-
configuration.layouts.edit,
|
2745
|
-
components[uid].attributes,
|
2746
|
-
configuration.metadatas
|
2747
|
-
),
|
2748
|
-
settings: {
|
2749
|
-
...configuration.settings,
|
2750
|
-
icon: components[uid].info.icon,
|
2751
|
-
displayName: components[uid].info.displayName
|
2752
|
-
}
|
2753
|
-
};
|
2754
|
-
return acc;
|
2755
|
-
},
|
2756
|
-
{}
|
2757
|
-
);
|
2758
|
-
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2759
|
-
(acc, [attribute, metadata]) => {
|
2760
|
-
return {
|
2761
|
-
...acc,
|
2762
|
-
[attribute]: metadata.edit
|
2763
|
-
};
|
2764
|
-
},
|
2765
|
-
{}
|
2766
|
-
);
|
2767
|
-
return {
|
2768
|
-
layout: panelledEditAttributes,
|
2769
|
-
components: componentEditAttributes,
|
2770
|
-
metadatas: editMetadatas,
|
2771
|
-
settings: {
|
2772
|
-
...data.contentType.settings,
|
2773
|
-
displayName: schema?.info.displayName
|
2774
|
-
},
|
2775
|
-
options: {
|
2776
|
-
...schema?.options,
|
2777
|
-
...schema?.pluginOptions,
|
2778
|
-
...data.contentType.options
|
2779
|
-
}
|
2780
|
-
};
|
2781
|
-
};
|
2782
|
-
const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
|
2783
|
-
return rows.map(
|
2784
|
-
(row) => row.map((field) => {
|
2785
|
-
const attribute = attributes[field.name];
|
2786
|
-
if (!attribute) {
|
2787
|
-
return null;
|
2788
|
-
}
|
2789
|
-
const { edit: metadata } = metadatas[field.name];
|
2790
|
-
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
2791
|
-
return {
|
2792
|
-
attribute,
|
2793
|
-
disabled: !metadata.editable,
|
2794
|
-
hint: metadata.description,
|
2795
|
-
label: metadata.label ?? "",
|
2796
|
-
name: field.name,
|
2797
|
-
// @ts-expect-error – mainField does exist on the metadata for a relation.
|
2798
|
-
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
2799
|
-
schemas,
|
2800
|
-
components: components?.schemas ?? {}
|
2801
|
-
}),
|
2802
|
-
placeholder: metadata.placeholder ?? "",
|
2803
|
-
required: attribute.required ?? false,
|
2804
|
-
size: field.size,
|
2805
|
-
unique: "unique" in attribute ? attribute.unique : false,
|
2806
|
-
visible: metadata.visible ?? true,
|
2807
|
-
type: attribute.type
|
2808
|
-
};
|
2809
|
-
}).filter((field) => field !== null)
|
2810
|
-
);
|
2811
|
-
};
|
2812
|
-
const formatListLayout = (data, {
|
2813
|
-
schemas,
|
2814
|
-
schema,
|
2815
|
-
components
|
2816
|
-
}) => {
|
2817
|
-
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2818
|
-
(acc, [attribute, metadata]) => {
|
2819
|
-
return {
|
2820
|
-
...acc,
|
2821
|
-
[attribute]: metadata.list
|
2822
|
-
};
|
2823
|
-
},
|
2824
|
-
{}
|
2825
|
-
);
|
2826
|
-
const listAttributes = convertListLayoutToFieldLayouts(
|
2827
|
-
data.contentType.layouts.list,
|
2828
|
-
schema?.attributes,
|
2829
|
-
listMetadatas,
|
2830
|
-
{ configurations: data.components, schemas: components },
|
2831
|
-
schemas
|
2832
|
-
);
|
2833
|
-
return {
|
2834
|
-
layout: listAttributes,
|
2835
|
-
settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
|
2836
|
-
metadatas: listMetadatas,
|
2837
|
-
options: {
|
2838
|
-
...schema?.options,
|
2839
|
-
...schema?.pluginOptions,
|
2840
|
-
...data.contentType.options
|
2841
|
-
}
|
2842
|
-
};
|
2843
|
-
};
|
2844
|
-
const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
|
2845
|
-
return columns.map((name) => {
|
2846
|
-
const attribute = attributes[name];
|
2847
|
-
if (!attribute) {
|
2848
|
-
return null;
|
2849
|
-
}
|
2850
|
-
const metadata = metadatas[name];
|
2851
|
-
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
2852
|
-
return {
|
2853
|
-
attribute,
|
2854
|
-
label: metadata.label ?? "",
|
2855
|
-
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
2856
|
-
schemas,
|
2857
|
-
components: components?.schemas ?? {}
|
2858
|
-
}),
|
2859
|
-
name,
|
2860
|
-
searchable: metadata.searchable ?? true,
|
2861
|
-
sortable: metadata.sortable ?? true
|
2862
|
-
};
|
2863
|
-
}).filter((field) => field !== null);
|
2864
|
-
};
|
2865
3024
|
const ConfirmBulkActionDialog = ({
|
2866
3025
|
onToggleDialog,
|
2867
3026
|
isOpen = false,
|
@@ -2900,6 +3059,7 @@ const ConfirmDialogPublishAll = ({
|
|
2900
3059
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler(getTranslation);
|
2901
3060
|
const { model, schema } = useDoc();
|
2902
3061
|
const [{ query }] = strapiAdmin.useQueryParams();
|
3062
|
+
const enableDraftRelationsCount = false;
|
2903
3063
|
const {
|
2904
3064
|
data: countDraftRelations = 0,
|
2905
3065
|
isLoading,
|
@@ -2911,7 +3071,7 @@ const ConfirmDialogPublishAll = ({
|
|
2911
3071
|
locale: query?.plugins?.i18n?.locale
|
2912
3072
|
},
|
2913
3073
|
{
|
2914
|
-
skip:
|
3074
|
+
skip: !enableDraftRelationsCount
|
2915
3075
|
}
|
2916
3076
|
);
|
2917
3077
|
React__namespace.useEffect(() => {
|
@@ -3096,7 +3256,7 @@ const SelectedEntriesTableContent = ({
|
|
3096
3256
|
status: row.status
|
3097
3257
|
}
|
3098
3258
|
) }),
|
3099
|
-
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
3259
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
3100
3260
|
designSystem.IconButton,
|
3101
3261
|
{
|
3102
3262
|
tag: reactRouterDom.Link,
|
@@ -3119,9 +3279,10 @@ const SelectedEntriesTableContent = ({
|
|
3119
3279
|
),
|
3120
3280
|
target: "_blank",
|
3121
3281
|
marginLeft: "auto",
|
3122
|
-
|
3282
|
+
variant: "ghost",
|
3283
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, { width: "1.6rem", height: "1.6rem" })
|
3123
3284
|
}
|
3124
|
-
) })
|
3285
|
+
) }) })
|
3125
3286
|
] }, row.id)) })
|
3126
3287
|
] });
|
3127
3288
|
};
|
@@ -3158,7 +3319,13 @@ const SelectedEntriesModalContent = ({
|
|
3158
3319
|
);
|
3159
3320
|
const { rows, validationErrors } = React__namespace.useMemo(() => {
|
3160
3321
|
if (data.length > 0 && schema) {
|
3161
|
-
const validate = createYupSchema(
|
3322
|
+
const validate = createYupSchema(
|
3323
|
+
schema.attributes,
|
3324
|
+
components,
|
3325
|
+
// Since this is the "Publish" action, the validation
|
3326
|
+
// schema must enforce the rules for published entities
|
3327
|
+
{ status: "published" }
|
3328
|
+
);
|
3162
3329
|
const validationErrors2 = {};
|
3163
3330
|
const rows2 = data.map((entry) => {
|
3164
3331
|
try {
|
@@ -3508,7 +3675,7 @@ const TableActions = ({ document }) => {
|
|
3508
3675
|
strapiAdmin.DescriptionComponentRenderer,
|
3509
3676
|
{
|
3510
3677
|
props,
|
3511
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
3678
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions().filter((action) => action.name !== "PublishAction"),
|
3512
3679
|
children: (actions2) => {
|
3513
3680
|
const tableRowActions = actions2.filter((action) => {
|
3514
3681
|
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
@@ -3619,7 +3786,7 @@ const CloneAction = ({ model, documentId }) => {
|
|
3619
3786
|
}),
|
3620
3787
|
content: /* @__PURE__ */ jsxRuntime.jsx(AutoCloneFailureModalBody, { prohibitedFields }),
|
3621
3788
|
footer: ({ onClose }) => {
|
3622
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.
|
3789
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
3623
3790
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
|
3624
3791
|
id: "cancel",
|
3625
3792
|
defaultMessage: "Cancel"
|
@@ -3850,7 +4017,7 @@ const index = {
|
|
3850
4017
|
app.router.addRoute({
|
3851
4018
|
path: "content-manager/*",
|
3852
4019
|
lazy: async () => {
|
3853
|
-
const { Layout } = await Promise.resolve().then(() => require("./layout-
|
4020
|
+
const { Layout } = await Promise.resolve().then(() => require("./layout-BTB1_M8g.js"));
|
3854
4021
|
return {
|
3855
4022
|
Component: Layout
|
3856
4023
|
};
|
@@ -3867,7 +4034,7 @@ const index = {
|
|
3867
4034
|
async registerTrads({ locales }) {
|
3868
4035
|
const importedTrads = await Promise.all(
|
3869
4036
|
locales.map((locale) => {
|
3870
|
-
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-
|
4037
|
+
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-Bm0D0IWz.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 }) => {
|
3871
4038
|
return {
|
3872
4039
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
3873
4040
|
locale
|
@@ -3885,6 +4052,7 @@ const index = {
|
|
3885
4052
|
};
|
3886
4053
|
exports.ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD = ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD;
|
3887
4054
|
exports.BulkActionsRenderer = BulkActionsRenderer;
|
4055
|
+
exports.CLONE_PATH = CLONE_PATH;
|
3888
4056
|
exports.COLLECTION_TYPES = COLLECTION_TYPES;
|
3889
4057
|
exports.CREATOR_FIELDS = CREATOR_FIELDS;
|
3890
4058
|
exports.DEFAULT_SETTINGS = DEFAULT_SETTINGS;
|
@@ -3912,6 +4080,7 @@ exports.getMainField = getMainField;
|
|
3912
4080
|
exports.getTranslation = getTranslation;
|
3913
4081
|
exports.index = index;
|
3914
4082
|
exports.setInitialData = setInitialData;
|
4083
|
+
exports.useContentManagerContext = useContentManagerContext;
|
3915
4084
|
exports.useContentTypeSchema = useContentTypeSchema;
|
3916
4085
|
exports.useDoc = useDoc;
|
3917
4086
|
exports.useDocLayout = useDocLayout;
|
@@ -3924,4 +4093,4 @@ exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
|
|
3924
4093
|
exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
|
3925
4094
|
exports.useGetInitialDataQuery = useGetInitialDataQuery;
|
3926
4095
|
exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
|
3927
|
-
//# sourceMappingURL=index-
|
4096
|
+
//# sourceMappingURL=index-BO-T2BdP.js.map
|