@strapi/content-manager 0.0.0-experimental.312e2942332daff7ae98a4f357d1913a4ae5e1ef → 0.0.0-experimental.3162602be5ecf801e9697f416d1467608d46ad32
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-BfOUhLa9.js → ComponentConfigurationPage-CO977CPh.js} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-BfOUhLa9.js.map → ComponentConfigurationPage-CO977CPh.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-DgDrdk-k.mjs → ComponentConfigurationPage-CQroR9Qk.mjs} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-DgDrdk-k.mjs.map → ComponentConfigurationPage-CQroR9Qk.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-BcXQLYY9.js → EditConfigurationPage-BPgoE-kf.js} +4 -4
- package/dist/_chunks/{EditConfigurationPage-BcXQLYY9.js.map → EditConfigurationPage-BPgoE-kf.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-CjV1kPAw.mjs → EditConfigurationPage-tVCJ5vWC.mjs} +4 -4
- package/dist/_chunks/{EditConfigurationPage-CjV1kPAw.mjs.map → EditConfigurationPage-tVCJ5vWC.mjs.map} +1 -1
- package/dist/_chunks/{EditViewPage-s_bjnR0M.mjs → EditViewPage-8mOu02ji.mjs} +15 -5
- package/dist/_chunks/EditViewPage-8mOu02ji.mjs.map +1 -0
- package/dist/_chunks/{EditViewPage-BOeuvemd.js → EditViewPage-BMVgUNOX.js} +15 -5
- package/dist/_chunks/EditViewPage-BMVgUNOX.js.map +1 -0
- package/dist/_chunks/{Field-D9nHkdjy.mjs → Field-CJPYzwD7.mjs} +70 -26
- package/dist/_chunks/Field-CJPYzwD7.mjs.map +1 -0
- package/dist/_chunks/{Field-CvfOxLel.js → Field-CdSLKFQk.js} +70 -26
- package/dist/_chunks/Field-CdSLKFQk.js.map +1 -0
- package/dist/_chunks/{Form-G4C35wJ4.mjs → Form-DJOJ-GF1.mjs} +3 -3
- package/dist/_chunks/Form-DJOJ-GF1.mjs.map +1 -0
- package/dist/_chunks/{Form-BKnDhP2B.js → Form-eP5bZwap.js} +3 -3
- package/dist/_chunks/Form-eP5bZwap.js.map +1 -0
- package/dist/_chunks/{History-BIYOzHws.js → History-B-Mrquzu.js} +23 -10
- package/dist/_chunks/History-B-Mrquzu.js.map +1 -0
- package/dist/_chunks/{History-FWwaCNUD.mjs → History-MnQLtk1g.mjs} +24 -11
- package/dist/_chunks/History-MnQLtk1g.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-BbOp66T2.mjs → ListConfigurationPage-BcycI8Lw.mjs} +3 -3
- package/dist/_chunks/{ListConfigurationPage-BbOp66T2.mjs.map → ListConfigurationPage-BcycI8Lw.mjs.map} +1 -1
- package/dist/_chunks/{ListConfigurationPage-N7prXhOp.js → ListConfigurationPage-C0n4rUzH.js} +3 -3
- package/dist/_chunks/{ListConfigurationPage-N7prXhOp.js.map → ListConfigurationPage-C0n4rUzH.js.map} +1 -1
- package/dist/_chunks/{ListViewPage-DTSW3r3X.mjs → ListViewPage-CRXONXwZ.mjs} +4 -4
- package/dist/_chunks/{ListViewPage-DTSW3r3X.mjs.map → ListViewPage-CRXONXwZ.mjs.map} +1 -1
- package/dist/_chunks/{ListViewPage-Djc5M_c0.js → ListViewPage-q0SHVPUS.js} +4 -4
- package/dist/_chunks/{ListViewPage-Djc5M_c0.js.map → ListViewPage-q0SHVPUS.js.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-DCX-hEMB.js → NoContentTypePage-Bh3komDV.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-DCX-hEMB.js.map → NoContentTypePage-Bh3komDV.js.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-A-6Pk0le.mjs → NoContentTypePage-ukzFRF3z.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-A-6Pk0le.mjs.map → NoContentTypePage-ukzFRF3z.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-B0vWytDx.mjs → NoPermissionsPage-B4sD7Ble.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-B0vWytDx.mjs.map → NoPermissionsPage-B4sD7Ble.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-PfJfspJV.js → NoPermissionsPage-BGBpj_Y1.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-PfJfspJV.js.map → NoPermissionsPage-BGBpj_Y1.js.map} +1 -1
- package/dist/_chunks/{Relations--9jwQ8HV.js → Relations-B53wYe8g.js} +32 -23
- package/dist/_chunks/Relations-B53wYe8g.js.map +1 -0
- package/dist/_chunks/{Relations-Ccdfw1dU.mjs → Relations-CIexb8gr.mjs} +32 -23
- package/dist/_chunks/Relations-CIexb8gr.mjs.map +1 -0
- package/dist/_chunks/{en-BVzUkPxZ.js → en-Bm0D0IWz.js} +8 -8
- package/dist/_chunks/{en-BVzUkPxZ.js.map → en-Bm0D0IWz.js.map} +1 -1
- package/dist/_chunks/{en-CPTj6CjC.mjs → en-DKV44jRb.mjs} +8 -8
- package/dist/_chunks/{en-CPTj6CjC.mjs.map → en-DKV44jRb.mjs.map} +1 -1
- package/dist/_chunks/{index-BwqXeHiv.mjs → index-CJ2vYwuT.mjs} +928 -868
- package/dist/_chunks/index-CJ2vYwuT.mjs.map +1 -0
- package/dist/_chunks/{index-jun-ZqyN.js → index-DbT2sx-Q.js} +926 -866
- package/dist/_chunks/index-DbT2sx-Q.js.map +1 -0
- package/dist/_chunks/{layout-T2xBqmuZ.js → layout-CeBSIkmP.js} +3 -3
- package/dist/_chunks/{layout-T2xBqmuZ.js.map → layout-CeBSIkmP.js.map} +1 -1
- package/dist/_chunks/{layout-BV5oiZQ9.mjs → layout-vzKSrr7p.mjs} +3 -3
- package/dist/_chunks/{layout-BV5oiZQ9.mjs.map → layout-vzKSrr7p.mjs.map} +1 -1
- package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
- package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
- package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
- package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
- package/dist/_chunks/{relations-D8jegO_8.js → relations-Cl-6t9iz.js} +2 -2
- package/dist/_chunks/{relations-D8jegO_8.js.map → relations-Cl-6t9iz.js.map} +1 -1
- package/dist/_chunks/{relations-wAeF76DP.mjs → relations-DI0lguF0.mjs} +2 -2
- package/dist/_chunks/{relations-wAeF76DP.mjs.map → relations-DI0lguF0.mjs.map} +1 -1
- package/dist/admin/index.js +2 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +3 -2
- package/dist/admin/src/exports.d.ts +1 -1
- package/dist/admin/src/hooks/useDocument.d.ts +32 -1
- package/dist/admin/src/pages/EditView/components/Header.d.ts +1 -0
- package/dist/server/index.js +27 -14
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +27 -14
- 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/history/services/history.d.ts.map +1 -1
- package/package.json +11 -11
- package/dist/_chunks/EditViewPage-BOeuvemd.js.map +0 -1
- package/dist/_chunks/EditViewPage-s_bjnR0M.mjs.map +0 -1
- package/dist/_chunks/Field-CvfOxLel.js.map +0 -1
- package/dist/_chunks/Field-D9nHkdjy.mjs.map +0 -1
- package/dist/_chunks/Form-BKnDhP2B.js.map +0 -1
- package/dist/_chunks/Form-G4C35wJ4.mjs.map +0 -1
- package/dist/_chunks/History-BIYOzHws.js.map +0 -1
- package/dist/_chunks/History-FWwaCNUD.mjs.map +0 -1
- package/dist/_chunks/Relations--9jwQ8HV.js.map +0 -1
- package/dist/_chunks/Relations-Ccdfw1dU.mjs.map +0 -1
- package/dist/_chunks/index-BwqXeHiv.mjs.map +0 -1
- package/dist/_chunks/index-jun-ZqyN.js.map +0 -1
- package/strapi-server.js +0 -3
@@ -121,6 +121,7 @@ const DocumentRBAC = ({ children, permissions }) => {
|
|
121
121
|
if (!slug) {
|
122
122
|
throw new Error("Cannot find the slug param in the URL");
|
123
123
|
}
|
124
|
+
const [{ rawQuery }] = strapiAdmin.useQueryParams();
|
124
125
|
const userPermissions = strapiAdmin.useAuth("DocumentRBAC", (state) => state.permissions);
|
125
126
|
const contentTypePermissions = React__namespace.useMemo(() => {
|
126
127
|
const contentTypePermissions2 = userPermissions.filter(
|
@@ -131,7 +132,14 @@ const DocumentRBAC = ({ children, permissions }) => {
|
|
131
132
|
return { ...acc, [action]: [permission] };
|
132
133
|
}, {});
|
133
134
|
}, [slug, userPermissions]);
|
134
|
-
const { isLoading, allowedActions } = strapiAdmin.useRBAC(
|
135
|
+
const { isLoading, allowedActions } = strapiAdmin.useRBAC(
|
136
|
+
contentTypePermissions,
|
137
|
+
permissions ?? void 0,
|
138
|
+
// TODO: useRBAC context should be typed and built differently
|
139
|
+
// We are passing raw query as context to the hook so that it can
|
140
|
+
// rely on the locale provided from DocumentRBAC for its permission calculations.
|
141
|
+
rawQuery
|
142
|
+
);
|
135
143
|
const canCreateFields = !isLoading && allowedActions.canCreate ? extractAndDedupeFields(contentTypePermissions.create) : [];
|
136
144
|
const canReadFields = !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];
|
137
145
|
const canUpdateFields = !isLoading && allowedActions.canUpdate ? extractAndDedupeFields(contentTypePermissions.update) : [];
|
@@ -482,6 +490,24 @@ const buildValidParams = (query) => {
|
|
482
490
|
const isBaseQueryError = (error) => {
|
483
491
|
return error.name !== void 0;
|
484
492
|
};
|
493
|
+
const arrayValidator = (attribute, options) => ({
|
494
|
+
message: strapiAdmin.translatedErrors.required,
|
495
|
+
test(value) {
|
496
|
+
if (options.status === "draft") {
|
497
|
+
return true;
|
498
|
+
}
|
499
|
+
if (!attribute.required) {
|
500
|
+
return true;
|
501
|
+
}
|
502
|
+
if (!value) {
|
503
|
+
return false;
|
504
|
+
}
|
505
|
+
if (Array.isArray(value) && value.length === 0) {
|
506
|
+
return false;
|
507
|
+
}
|
508
|
+
return true;
|
509
|
+
}
|
510
|
+
});
|
485
511
|
const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
|
486
512
|
const createModelSchema = (attributes2) => yup__namespace.object().shape(
|
487
513
|
Object.entries(attributes2).reduce((acc, [name, attribute]) => {
|
@@ -489,6 +515,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
|
|
489
515
|
return acc;
|
490
516
|
}
|
491
517
|
const validations = [
|
518
|
+
addNullableValidation,
|
492
519
|
addRequiredValidation,
|
493
520
|
addMinLengthValidation,
|
494
521
|
addMaxLengthValidation,
|
@@ -505,12 +532,12 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
|
|
505
532
|
...acc,
|
506
533
|
[name]: transformSchema(
|
507
534
|
yup__namespace.array().of(createModelSchema(attributes3).nullable(false))
|
508
|
-
)
|
535
|
+
).test(arrayValidator(attribute, options))
|
509
536
|
};
|
510
537
|
} else {
|
511
538
|
return {
|
512
539
|
...acc,
|
513
|
-
[name]: transformSchema(createModelSchema(attributes3))
|
540
|
+
[name]: transformSchema(createModelSchema(attributes3).nullable())
|
514
541
|
};
|
515
542
|
}
|
516
543
|
}
|
@@ -532,7 +559,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
|
|
532
559
|
}
|
533
560
|
)
|
534
561
|
)
|
535
|
-
)
|
562
|
+
).test(arrayValidator(attribute, options))
|
536
563
|
};
|
537
564
|
case "relation":
|
538
565
|
return {
|
@@ -544,7 +571,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
|
|
544
571
|
} else if (Array.isArray(value)) {
|
545
572
|
return yup__namespace.array().of(
|
546
573
|
yup__namespace.object().shape({
|
547
|
-
id: yup__namespace.
|
574
|
+
id: yup__namespace.number().required()
|
548
575
|
})
|
549
576
|
);
|
550
577
|
} else if (typeof value === "object") {
|
@@ -630,17 +657,17 @@ const nullableSchema = (schema) => {
|
|
630
657
|
schema
|
631
658
|
);
|
632
659
|
};
|
660
|
+
const addNullableValidation = () => (schema) => {
|
661
|
+
return nullableSchema(schema);
|
662
|
+
};
|
633
663
|
const addRequiredValidation = (attribute, options) => (schema) => {
|
634
|
-
if (options.status === "draft") {
|
635
|
-
return
|
636
|
-
}
|
637
|
-
if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
|
638
|
-
return schema.min(1, strapiAdmin.translatedErrors.required);
|
664
|
+
if (options.status === "draft" || !attribute.required) {
|
665
|
+
return schema;
|
639
666
|
}
|
640
|
-
if (attribute.required &&
|
667
|
+
if (attribute.required && "required" in schema) {
|
641
668
|
return schema.required(strapiAdmin.translatedErrors.required);
|
642
669
|
}
|
643
|
-
return
|
670
|
+
return schema;
|
644
671
|
};
|
645
672
|
const addMinLengthValidation = (attribute, options) => (schema) => {
|
646
673
|
if (options.status === "draft") {
|
@@ -668,31 +695,12 @@ const addMaxLengthValidation = (attribute) => (schema) => {
|
|
668
695
|
return schema;
|
669
696
|
};
|
670
697
|
const addMinValidation = (attribute, options) => (schema) => {
|
671
|
-
if ("
|
698
|
+
if (options.status === "draft") {
|
699
|
+
return schema;
|
700
|
+
}
|
701
|
+
if ("min" in attribute && "min" in schema) {
|
672
702
|
const min = toInteger(attribute.min);
|
673
|
-
if (
|
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
|
-
}
|
695
|
-
if ("min" in schema && min) {
|
703
|
+
if (min) {
|
696
704
|
return schema.min(min, {
|
697
705
|
...strapiAdmin.translatedErrors.min,
|
698
706
|
values: {
|
@@ -810,19 +818,115 @@ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
|
|
810
818
|
}, {});
|
811
819
|
return componentsByKey;
|
812
820
|
};
|
813
|
-
const
|
821
|
+
const HOOKS = {
|
822
|
+
/**
|
823
|
+
* Hook that allows to mutate the displayed headers of the list view table
|
824
|
+
* @constant
|
825
|
+
* @type {string}
|
826
|
+
*/
|
827
|
+
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
828
|
+
/**
|
829
|
+
* Hook that allows to mutate the CM's collection types links pre-set filters
|
830
|
+
* @constant
|
831
|
+
* @type {string}
|
832
|
+
*/
|
833
|
+
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
834
|
+
/**
|
835
|
+
* Hook that allows to mutate the CM's edit view layout
|
836
|
+
* @constant
|
837
|
+
* @type {string}
|
838
|
+
*/
|
839
|
+
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
840
|
+
/**
|
841
|
+
* Hook that allows to mutate the CM's single types links pre-set filters
|
842
|
+
* @constant
|
843
|
+
* @type {string}
|
844
|
+
*/
|
845
|
+
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
846
|
+
};
|
847
|
+
const contentTypesApi = contentManagerApi.injectEndpoints({
|
848
|
+
endpoints: (builder) => ({
|
849
|
+
getContentTypeConfiguration: builder.query({
|
850
|
+
query: (uid) => ({
|
851
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
852
|
+
method: "GET"
|
853
|
+
}),
|
854
|
+
transformResponse: (response) => response.data,
|
855
|
+
providesTags: (_result, _error, uid) => [
|
856
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
857
|
+
{ type: "ContentTypeSettings", id: "LIST" }
|
858
|
+
]
|
859
|
+
}),
|
860
|
+
getAllContentTypeSettings: builder.query({
|
861
|
+
query: () => "/content-manager/content-types-settings",
|
862
|
+
transformResponse: (response) => response.data,
|
863
|
+
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
864
|
+
}),
|
865
|
+
updateContentTypeConfiguration: builder.mutation({
|
866
|
+
query: ({ uid, ...body }) => ({
|
867
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
868
|
+
method: "PUT",
|
869
|
+
data: body
|
870
|
+
}),
|
871
|
+
transformResponse: (response) => response.data,
|
872
|
+
invalidatesTags: (_result, _error, { uid }) => [
|
873
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
874
|
+
{ type: "ContentTypeSettings", id: "LIST" },
|
875
|
+
// Is this necessary?
|
876
|
+
{ type: "InitialData" }
|
877
|
+
]
|
878
|
+
})
|
879
|
+
})
|
880
|
+
});
|
881
|
+
const {
|
882
|
+
useGetContentTypeConfigurationQuery,
|
883
|
+
useGetAllContentTypeSettingsQuery,
|
884
|
+
useUpdateContentTypeConfigurationMutation
|
885
|
+
} = contentTypesApi;
|
886
|
+
const checkIfAttributeIsDisplayable = (attribute) => {
|
887
|
+
const { type } = attribute;
|
888
|
+
if (type === "relation") {
|
889
|
+
return !attribute.relation.toLowerCase().includes("morph");
|
890
|
+
}
|
891
|
+
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
892
|
+
};
|
893
|
+
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
894
|
+
if (!mainFieldName) {
|
895
|
+
return void 0;
|
896
|
+
}
|
897
|
+
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
898
|
+
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
899
|
+
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
900
|
+
);
|
901
|
+
return {
|
902
|
+
name: mainFieldName,
|
903
|
+
type: mainFieldType ?? "string"
|
904
|
+
};
|
905
|
+
};
|
906
|
+
const DEFAULT_SETTINGS = {
|
907
|
+
bulkable: false,
|
908
|
+
filterable: false,
|
909
|
+
searchable: false,
|
910
|
+
pagination: false,
|
911
|
+
defaultSortBy: "",
|
912
|
+
defaultSortOrder: "asc",
|
913
|
+
mainField: "id",
|
914
|
+
pageSize: 10
|
915
|
+
};
|
916
|
+
const useDocumentLayout = (model) => {
|
917
|
+
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
918
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
919
|
+
const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
814
920
|
const { toggleNotification } = strapiAdmin.useNotification();
|
815
921
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
922
|
+
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
816
923
|
const {
|
817
|
-
|
818
|
-
isLoading:
|
819
|
-
|
820
|
-
|
821
|
-
} =
|
822
|
-
|
823
|
-
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
824
|
-
});
|
825
|
-
const { components, schema, isLoading: isLoadingSchema } = useContentTypeSchema(args.model);
|
924
|
+
data,
|
925
|
+
isLoading: isLoadingConfigs,
|
926
|
+
error,
|
927
|
+
isFetching: isFetchingConfigs
|
928
|
+
} = useGetContentTypeConfigurationQuery(model);
|
929
|
+
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
826
930
|
React__namespace.useEffect(() => {
|
827
931
|
if (error) {
|
828
932
|
toggleNotification({
|
@@ -830,400 +934,653 @@ const useDocument = (args, opts) => {
|
|
830
934
|
message: formatAPIError(error)
|
831
935
|
});
|
832
936
|
}
|
833
|
-
}, [
|
834
|
-
const
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
(document) => {
|
842
|
-
if (!validationSchema) {
|
843
|
-
throw new Error(
|
844
|
-
"There is no validation schema generated, this is likely due to the schema not being loaded yet."
|
845
|
-
);
|
846
|
-
}
|
847
|
-
try {
|
848
|
-
validationSchema.validateSync(document, { abortEarly: false, strict: true });
|
849
|
-
return null;
|
850
|
-
} catch (error2) {
|
851
|
-
if (error2 instanceof yup.ValidationError) {
|
852
|
-
return strapiAdmin.getYupValidationErrors(error2);
|
853
|
-
}
|
854
|
-
throw error2;
|
855
|
-
}
|
937
|
+
}, [error, formatAPIError, toggleNotification]);
|
938
|
+
const editLayout = React__namespace.useMemo(
|
939
|
+
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
940
|
+
layout: [],
|
941
|
+
components: {},
|
942
|
+
metadatas: {},
|
943
|
+
options: {},
|
944
|
+
settings: DEFAULT_SETTINGS
|
856
945
|
},
|
857
|
-
[
|
946
|
+
[data, isLoading, schemas, schema, components]
|
947
|
+
);
|
948
|
+
const listLayout = React__namespace.useMemo(() => {
|
949
|
+
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
950
|
+
layout: [],
|
951
|
+
metadatas: {},
|
952
|
+
options: {},
|
953
|
+
settings: DEFAULT_SETTINGS
|
954
|
+
};
|
955
|
+
}, [data, isLoading, schemas, schema, components]);
|
956
|
+
const { layout: edit } = React__namespace.useMemo(
|
957
|
+
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
958
|
+
layout: editLayout,
|
959
|
+
query
|
960
|
+
}),
|
961
|
+
[editLayout, query, runHookWaterfall]
|
858
962
|
);
|
859
|
-
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
860
963
|
return {
|
861
|
-
|
862
|
-
document: data?.data,
|
863
|
-
meta: data?.meta,
|
964
|
+
error,
|
864
965
|
isLoading,
|
865
|
-
|
866
|
-
|
867
|
-
};
|
868
|
-
};
|
869
|
-
const useDoc = () => {
|
870
|
-
const { id, slug, collectionType, origin } = reactRouterDom.useParams();
|
871
|
-
const [{ query }] = strapiAdmin.useQueryParams();
|
872
|
-
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
873
|
-
if (!collectionType) {
|
874
|
-
throw new Error("Could not find collectionType in url params");
|
875
|
-
}
|
876
|
-
if (!slug) {
|
877
|
-
throw new Error("Could not find model in url params");
|
878
|
-
}
|
879
|
-
return {
|
880
|
-
collectionType,
|
881
|
-
model: slug,
|
882
|
-
id: origin || id === "create" ? void 0 : id,
|
883
|
-
...useDocument(
|
884
|
-
{ documentId: origin || id, model: slug, collectionType, params },
|
885
|
-
{
|
886
|
-
skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
|
887
|
-
}
|
888
|
-
)
|
966
|
+
edit,
|
967
|
+
list: listLayout
|
889
968
|
};
|
890
969
|
};
|
891
|
-
const
|
892
|
-
|
893
|
-
|
894
|
-
}
|
895
|
-
return Object.keys(trad).reduce((acc, current) => {
|
896
|
-
acc[`${pluginId}.${current}`] = trad[current];
|
897
|
-
return acc;
|
898
|
-
}, {});
|
899
|
-
};
|
900
|
-
const getTranslation = (id) => `content-manager.${id}`;
|
901
|
-
const DEFAULT_UNEXPECTED_ERROR_MSG = {
|
902
|
-
id: "notification.error",
|
903
|
-
defaultMessage: "An error occurred, please try again"
|
970
|
+
const useDocLayout = () => {
|
971
|
+
const { model } = useDoc();
|
972
|
+
return useDocumentLayout(model);
|
904
973
|
};
|
905
|
-
const
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
const
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
toggleNotification({
|
925
|
-
type: "danger",
|
926
|
-
message: formatAPIError(res.error)
|
927
|
-
});
|
928
|
-
return { error: res.error };
|
929
|
-
}
|
930
|
-
toggleNotification({
|
931
|
-
type: "success",
|
932
|
-
message: formatMessage({
|
933
|
-
id: getTranslation("success.record.delete"),
|
934
|
-
defaultMessage: "Deleted document"
|
935
|
-
})
|
936
|
-
});
|
937
|
-
trackUsage("didDeleteEntry", trackerProperty);
|
938
|
-
return res.data;
|
939
|
-
} catch (err) {
|
940
|
-
toggleNotification({
|
941
|
-
type: "danger",
|
942
|
-
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
943
|
-
});
|
944
|
-
trackUsage("didNotDeleteEntry", { error: err, ...trackerProperty });
|
945
|
-
throw err;
|
974
|
+
const formatEditLayout = (data, {
|
975
|
+
schemas,
|
976
|
+
schema,
|
977
|
+
components
|
978
|
+
}) => {
|
979
|
+
let currentPanelIndex = 0;
|
980
|
+
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
981
|
+
data.contentType.layouts.edit,
|
982
|
+
schema?.attributes,
|
983
|
+
data.contentType.metadatas,
|
984
|
+
{ configurations: data.components, schemas: components },
|
985
|
+
schemas
|
986
|
+
).reduce((panels, row) => {
|
987
|
+
if (row.some((field) => field.type === "dynamiczone")) {
|
988
|
+
panels.push([row]);
|
989
|
+
currentPanelIndex += 2;
|
990
|
+
} else {
|
991
|
+
if (!panels[currentPanelIndex]) {
|
992
|
+
panels.push([]);
|
946
993
|
}
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
const
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
});
|
965
|
-
return { error: res.error };
|
994
|
+
panels[currentPanelIndex].push(row);
|
995
|
+
}
|
996
|
+
return panels;
|
997
|
+
}, []);
|
998
|
+
const componentEditAttributes = Object.entries(data.components).reduce(
|
999
|
+
(acc, [uid, configuration]) => {
|
1000
|
+
acc[uid] = {
|
1001
|
+
layout: convertEditLayoutToFieldLayouts(
|
1002
|
+
configuration.layouts.edit,
|
1003
|
+
components[uid].attributes,
|
1004
|
+
configuration.metadatas,
|
1005
|
+
{ configurations: data.components, schemas: components }
|
1006
|
+
),
|
1007
|
+
settings: {
|
1008
|
+
...configuration.settings,
|
1009
|
+
icon: components[uid].info.icon,
|
1010
|
+
displayName: components[uid].info.displayName
|
966
1011
|
}
|
967
|
-
|
968
|
-
|
969
|
-
title: formatMessage({
|
970
|
-
id: getTranslation("success.records.delete"),
|
971
|
-
defaultMessage: "Successfully deleted."
|
972
|
-
}),
|
973
|
-
message: ""
|
974
|
-
});
|
975
|
-
trackUsage("didBulkDeleteEntries");
|
976
|
-
return res.data;
|
977
|
-
} catch (err) {
|
978
|
-
toggleNotification({
|
979
|
-
type: "danger",
|
980
|
-
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
981
|
-
});
|
982
|
-
trackUsage("didNotBulkDeleteEntries");
|
983
|
-
throw err;
|
984
|
-
}
|
1012
|
+
};
|
1013
|
+
return acc;
|
985
1014
|
},
|
986
|
-
|
1015
|
+
{}
|
987
1016
|
);
|
988
|
-
const
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
model,
|
995
|
-
documentId,
|
996
|
-
params
|
997
|
-
});
|
998
|
-
if ("error" in res) {
|
999
|
-
toggleNotification({
|
1000
|
-
type: "danger",
|
1001
|
-
message: formatAPIError(res.error)
|
1002
|
-
});
|
1003
|
-
return { error: res.error };
|
1004
|
-
}
|
1005
|
-
toggleNotification({
|
1006
|
-
type: "success",
|
1007
|
-
message: formatMessage({
|
1008
|
-
id: "content-manager.success.record.discard",
|
1009
|
-
defaultMessage: "Changes discarded"
|
1010
|
-
})
|
1011
|
-
});
|
1012
|
-
return res.data;
|
1013
|
-
} catch (err) {
|
1014
|
-
toggleNotification({
|
1015
|
-
type: "danger",
|
1016
|
-
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1017
|
-
});
|
1018
|
-
throw err;
|
1019
|
-
}
|
1017
|
+
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1018
|
+
(acc, [attribute, metadata]) => {
|
1019
|
+
return {
|
1020
|
+
...acc,
|
1021
|
+
[attribute]: metadata.edit
|
1022
|
+
};
|
1020
1023
|
},
|
1021
|
-
|
1024
|
+
{}
|
1022
1025
|
);
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
model,
|
1031
|
-
documentId,
|
1032
|
-
data,
|
1033
|
-
params
|
1034
|
-
});
|
1035
|
-
if ("error" in res) {
|
1036
|
-
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1037
|
-
return { error: res.error };
|
1038
|
-
}
|
1039
|
-
trackUsage("didPublishEntry");
|
1040
|
-
toggleNotification({
|
1041
|
-
type: "success",
|
1042
|
-
message: formatMessage({
|
1043
|
-
id: getTranslation("success.record.publish"),
|
1044
|
-
defaultMessage: "Published document"
|
1045
|
-
})
|
1046
|
-
});
|
1047
|
-
return res.data;
|
1048
|
-
} catch (err) {
|
1049
|
-
toggleNotification({
|
1050
|
-
type: "danger",
|
1051
|
-
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1052
|
-
});
|
1053
|
-
throw err;
|
1054
|
-
}
|
1026
|
+
return {
|
1027
|
+
layout: panelledEditAttributes,
|
1028
|
+
components: componentEditAttributes,
|
1029
|
+
metadatas: editMetadatas,
|
1030
|
+
settings: {
|
1031
|
+
...data.contentType.settings,
|
1032
|
+
displayName: schema?.info.displayName
|
1055
1033
|
},
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
return { error: res.error };
|
1070
|
-
}
|
1071
|
-
toggleNotification({
|
1072
|
-
type: "success",
|
1073
|
-
message: formatMessage({
|
1074
|
-
id: getTranslation("success.record.publish"),
|
1075
|
-
defaultMessage: "Published document"
|
1076
|
-
})
|
1077
|
-
});
|
1078
|
-
return res.data;
|
1079
|
-
} catch (err) {
|
1080
|
-
toggleNotification({
|
1081
|
-
type: "danger",
|
1082
|
-
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1083
|
-
});
|
1084
|
-
throw err;
|
1034
|
+
options: {
|
1035
|
+
...schema?.options,
|
1036
|
+
...schema?.pluginOptions,
|
1037
|
+
...data.contentType.options
|
1038
|
+
}
|
1039
|
+
};
|
1040
|
+
};
|
1041
|
+
const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
|
1042
|
+
return rows.map(
|
1043
|
+
(row) => row.map((field) => {
|
1044
|
+
const attribute = attributes[field.name];
|
1045
|
+
if (!attribute) {
|
1046
|
+
return null;
|
1085
1047
|
}
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1048
|
+
const { edit: metadata } = metadatas[field.name];
|
1049
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1050
|
+
return {
|
1051
|
+
attribute,
|
1052
|
+
disabled: !metadata.editable,
|
1053
|
+
hint: metadata.description,
|
1054
|
+
label: metadata.label ?? "",
|
1055
|
+
name: field.name,
|
1056
|
+
// @ts-expect-error – mainField does exist on the metadata for a relation.
|
1057
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1058
|
+
schemas,
|
1059
|
+
components: components?.schemas ?? {}
|
1060
|
+
}),
|
1061
|
+
placeholder: metadata.placeholder ?? "",
|
1062
|
+
required: attribute.required ?? false,
|
1063
|
+
size: field.size,
|
1064
|
+
unique: "unique" in attribute ? attribute.unique : false,
|
1065
|
+
visible: metadata.visible ?? true,
|
1066
|
+
type: attribute.type
|
1067
|
+
};
|
1068
|
+
}).filter((field) => field !== null)
|
1094
1069
|
);
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1070
|
+
};
|
1071
|
+
const formatListLayout = (data, {
|
1072
|
+
schemas,
|
1073
|
+
schema,
|
1074
|
+
components
|
1075
|
+
}) => {
|
1076
|
+
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1077
|
+
(acc, [attribute, metadata]) => {
|
1078
|
+
return {
|
1079
|
+
...acc,
|
1080
|
+
[attribute]: metadata.list
|
1081
|
+
};
|
1082
|
+
},
|
1083
|
+
{}
|
1084
|
+
);
|
1085
|
+
const listAttributes = convertListLayoutToFieldLayouts(
|
1086
|
+
data.contentType.layouts.list,
|
1087
|
+
schema?.attributes,
|
1088
|
+
listMetadatas,
|
1089
|
+
{ configurations: data.components, schemas: components },
|
1090
|
+
schemas
|
1091
|
+
);
|
1092
|
+
return {
|
1093
|
+
layout: listAttributes,
|
1094
|
+
settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
|
1095
|
+
metadatas: listMetadatas,
|
1096
|
+
options: {
|
1097
|
+
...schema?.options,
|
1098
|
+
...schema?.pluginOptions,
|
1099
|
+
...data.contentType.options
|
1100
|
+
}
|
1101
|
+
};
|
1102
|
+
};
|
1103
|
+
const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
|
1104
|
+
return columns.map((name) => {
|
1105
|
+
const attribute = attributes[name];
|
1106
|
+
if (!attribute) {
|
1107
|
+
return null;
|
1108
|
+
}
|
1109
|
+
const metadata = metadatas[name];
|
1110
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1111
|
+
return {
|
1112
|
+
attribute,
|
1113
|
+
label: metadata.label ?? "",
|
1114
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1115
|
+
schemas,
|
1116
|
+
components: components?.schemas ?? {}
|
1117
|
+
}),
|
1118
|
+
name,
|
1119
|
+
searchable: metadata.searchable ?? true,
|
1120
|
+
sortable: metadata.sortable ?? true
|
1121
|
+
};
|
1122
|
+
}).filter((field) => field !== null);
|
1123
|
+
};
|
1124
|
+
const useDocument = (args, opts) => {
|
1125
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
1126
|
+
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
1127
|
+
const {
|
1128
|
+
currentData: data,
|
1129
|
+
isLoading: isLoadingDocument,
|
1130
|
+
isFetching: isFetchingDocument,
|
1131
|
+
error
|
1132
|
+
} = useGetDocumentQuery(args, {
|
1133
|
+
...opts,
|
1134
|
+
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
1135
|
+
});
|
1136
|
+
const {
|
1137
|
+
components,
|
1138
|
+
schema,
|
1139
|
+
schemas,
|
1140
|
+
isLoading: isLoadingSchema
|
1141
|
+
} = useContentTypeSchema(args.model);
|
1142
|
+
React__namespace.useEffect(() => {
|
1143
|
+
if (error) {
|
1144
|
+
toggleNotification({
|
1145
|
+
type: "danger",
|
1146
|
+
message: formatAPIError(error)
|
1147
|
+
});
|
1148
|
+
}
|
1149
|
+
}, [toggleNotification, error, formatAPIError, args.collectionType]);
|
1150
|
+
const validationSchema = React__namespace.useMemo(() => {
|
1151
|
+
if (!schema) {
|
1152
|
+
return null;
|
1153
|
+
}
|
1154
|
+
return createYupSchema(schema.attributes, components);
|
1155
|
+
}, [schema, components]);
|
1156
|
+
const validate = React__namespace.useCallback(
|
1157
|
+
(document) => {
|
1158
|
+
if (!validationSchema) {
|
1159
|
+
throw new Error(
|
1160
|
+
"There is no validation schema generated, this is likely due to the schema not being loaded yet."
|
1161
|
+
);
|
1162
|
+
}
|
1163
|
+
try {
|
1164
|
+
validationSchema.validateSync(document, { abortEarly: false, strict: true });
|
1165
|
+
return null;
|
1166
|
+
} catch (error2) {
|
1167
|
+
if (error2 instanceof yup.ValidationError) {
|
1168
|
+
return strapiAdmin.getYupValidationErrors(error2);
|
1111
1169
|
}
|
1112
|
-
|
1113
|
-
toggleNotification({
|
1114
|
-
type: "success",
|
1115
|
-
message: formatMessage({
|
1116
|
-
id: getTranslation("success.record.save"),
|
1117
|
-
defaultMessage: "Saved document"
|
1118
|
-
})
|
1119
|
-
});
|
1120
|
-
return res.data;
|
1121
|
-
} catch (err) {
|
1122
|
-
trackUsage("didNotEditEntry", { error: err, ...trackerProperty });
|
1123
|
-
toggleNotification({
|
1124
|
-
type: "danger",
|
1125
|
-
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1126
|
-
});
|
1127
|
-
throw err;
|
1170
|
+
throw error2;
|
1128
1171
|
}
|
1129
1172
|
},
|
1130
|
-
[
|
1173
|
+
[validationSchema]
|
1131
1174
|
);
|
1132
|
-
const
|
1133
|
-
const
|
1134
|
-
|
1175
|
+
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
1176
|
+
const hasError = !!error;
|
1177
|
+
return {
|
1178
|
+
components,
|
1179
|
+
document: data?.data,
|
1180
|
+
meta: data?.meta,
|
1181
|
+
isLoading,
|
1182
|
+
hasError,
|
1183
|
+
schema,
|
1184
|
+
schemas,
|
1185
|
+
validate
|
1186
|
+
};
|
1187
|
+
};
|
1188
|
+
const useDoc = () => {
|
1189
|
+
const { id, slug, collectionType, origin } = reactRouterDom.useParams();
|
1190
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
1191
|
+
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
1192
|
+
if (!collectionType) {
|
1193
|
+
throw new Error("Could not find collectionType in url params");
|
1194
|
+
}
|
1195
|
+
if (!slug) {
|
1196
|
+
throw new Error("Could not find model in url params");
|
1197
|
+
}
|
1198
|
+
const document = useDocument(
|
1199
|
+
{ documentId: origin || id, model: slug, collectionType, params },
|
1200
|
+
{
|
1201
|
+
skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
|
1202
|
+
}
|
1203
|
+
);
|
1204
|
+
const returnId = origin || id === "create" ? void 0 : id;
|
1205
|
+
return {
|
1206
|
+
collectionType,
|
1207
|
+
model: slug,
|
1208
|
+
id: returnId,
|
1209
|
+
...document
|
1210
|
+
};
|
1211
|
+
};
|
1212
|
+
const useContentManagerContext = () => {
|
1213
|
+
const {
|
1214
|
+
collectionType,
|
1215
|
+
model,
|
1216
|
+
id,
|
1217
|
+
components,
|
1218
|
+
isLoading: isLoadingDoc,
|
1219
|
+
schema,
|
1220
|
+
schemas
|
1221
|
+
} = useDoc();
|
1222
|
+
const layout = useDocumentLayout(model);
|
1223
|
+
const form = strapiAdmin.useForm("useContentManagerContext", (state) => state);
|
1224
|
+
const isSingleType = collectionType === SINGLE_TYPES;
|
1225
|
+
const slug = model;
|
1226
|
+
const isCreatingEntry = id === "create";
|
1227
|
+
useContentTypeSchema();
|
1228
|
+
const isLoading = isLoadingDoc || layout.isLoading;
|
1229
|
+
const error = layout.error;
|
1230
|
+
return {
|
1231
|
+
error,
|
1232
|
+
isLoading,
|
1233
|
+
// Base metadata
|
1234
|
+
model,
|
1235
|
+
collectionType,
|
1236
|
+
id,
|
1237
|
+
slug,
|
1238
|
+
isCreatingEntry,
|
1239
|
+
isSingleType,
|
1240
|
+
hasDraftAndPublish: schema?.options?.draftAndPublish ?? false,
|
1241
|
+
// All schema infos
|
1242
|
+
components,
|
1243
|
+
contentType: schema,
|
1244
|
+
contentTypes: schemas,
|
1245
|
+
// Form state
|
1246
|
+
form,
|
1247
|
+
// layout infos
|
1248
|
+
layout
|
1249
|
+
};
|
1250
|
+
};
|
1251
|
+
const prefixPluginTranslations = (trad, pluginId) => {
|
1252
|
+
return Object.keys(trad).reduce((acc, current) => {
|
1253
|
+
acc[`${pluginId}.${current}`] = trad[current];
|
1254
|
+
return acc;
|
1255
|
+
}, {});
|
1256
|
+
};
|
1257
|
+
const getTranslation = (id) => `content-manager.${id}`;
|
1258
|
+
const DEFAULT_UNEXPECTED_ERROR_MSG = {
|
1259
|
+
id: "notification.error",
|
1260
|
+
defaultMessage: "An error occurred, please try again"
|
1261
|
+
};
|
1262
|
+
const useDocumentActions = () => {
|
1263
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
1264
|
+
const { formatMessage } = reactIntl.useIntl();
|
1265
|
+
const { trackUsage } = strapiAdmin.useTracking();
|
1266
|
+
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
1267
|
+
const navigate = reactRouterDom.useNavigate();
|
1268
|
+
const setCurrentStep = strapiAdmin.useGuidedTour("useDocumentActions", (state) => state.setCurrentStep);
|
1269
|
+
const [deleteDocument] = useDeleteDocumentMutation();
|
1270
|
+
const _delete = React__namespace.useCallback(
|
1271
|
+
async ({ collectionType, model, documentId, params }, trackerProperty) => {
|
1135
1272
|
try {
|
1136
|
-
trackUsage("
|
1137
|
-
const res = await
|
1273
|
+
trackUsage("willDeleteEntry", trackerProperty);
|
1274
|
+
const res = await deleteDocument({
|
1138
1275
|
collectionType,
|
1139
1276
|
model,
|
1140
1277
|
documentId,
|
1141
|
-
params
|
1142
|
-
data: {
|
1143
|
-
discardDraft
|
1144
|
-
}
|
1278
|
+
params
|
1145
1279
|
});
|
1146
1280
|
if ("error" in res) {
|
1147
|
-
toggleNotification({
|
1281
|
+
toggleNotification({
|
1282
|
+
type: "danger",
|
1283
|
+
message: formatAPIError(res.error)
|
1284
|
+
});
|
1148
1285
|
return { error: res.error };
|
1149
1286
|
}
|
1150
|
-
trackUsage("didUnpublishEntry");
|
1151
1287
|
toggleNotification({
|
1152
1288
|
type: "success",
|
1153
1289
|
message: formatMessage({
|
1154
|
-
id: getTranslation("success.record.
|
1155
|
-
defaultMessage: "
|
1290
|
+
id: getTranslation("success.record.delete"),
|
1291
|
+
defaultMessage: "Deleted document"
|
1156
1292
|
})
|
1157
1293
|
});
|
1294
|
+
trackUsage("didDeleteEntry", trackerProperty);
|
1158
1295
|
return res.data;
|
1159
1296
|
} catch (err) {
|
1160
1297
|
toggleNotification({
|
1161
1298
|
type: "danger",
|
1162
1299
|
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1163
1300
|
});
|
1301
|
+
trackUsage("didNotDeleteEntry", { error: err, ...trackerProperty });
|
1164
1302
|
throw err;
|
1165
1303
|
}
|
1166
1304
|
},
|
1167
|
-
[trackUsage,
|
1305
|
+
[trackUsage, deleteDocument, toggleNotification, formatMessage, formatAPIError]
|
1168
1306
|
);
|
1169
|
-
const [
|
1170
|
-
const
|
1307
|
+
const [deleteManyDocuments] = useDeleteManyDocumentsMutation();
|
1308
|
+
const deleteMany = React__namespace.useCallback(
|
1171
1309
|
async ({ model, documentIds, params }) => {
|
1172
1310
|
try {
|
1173
|
-
trackUsage("
|
1174
|
-
const res = await
|
1311
|
+
trackUsage("willBulkDeleteEntries");
|
1312
|
+
const res = await deleteManyDocuments({
|
1175
1313
|
model,
|
1176
1314
|
documentIds,
|
1177
1315
|
params
|
1178
1316
|
});
|
1179
1317
|
if ("error" in res) {
|
1180
|
-
toggleNotification({
|
1318
|
+
toggleNotification({
|
1319
|
+
type: "danger",
|
1320
|
+
message: formatAPIError(res.error)
|
1321
|
+
});
|
1181
1322
|
return { error: res.error };
|
1182
1323
|
}
|
1183
|
-
trackUsage("didBulkUnpublishEntries");
|
1184
1324
|
toggleNotification({
|
1185
1325
|
type: "success",
|
1186
1326
|
title: formatMessage({
|
1187
|
-
id: getTranslation("success.records.
|
1188
|
-
defaultMessage: "Successfully
|
1327
|
+
id: getTranslation("success.records.delete"),
|
1328
|
+
defaultMessage: "Successfully deleted."
|
1189
1329
|
}),
|
1190
1330
|
message: ""
|
1191
1331
|
});
|
1332
|
+
trackUsage("didBulkDeleteEntries");
|
1192
1333
|
return res.data;
|
1193
1334
|
} catch (err) {
|
1194
1335
|
toggleNotification({
|
1195
1336
|
type: "danger",
|
1196
1337
|
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1197
1338
|
});
|
1198
|
-
trackUsage("
|
1339
|
+
trackUsage("didNotBulkDeleteEntries");
|
1199
1340
|
throw err;
|
1200
1341
|
}
|
1201
1342
|
},
|
1202
|
-
[trackUsage,
|
1343
|
+
[trackUsage, deleteManyDocuments, toggleNotification, formatMessage, formatAPIError]
|
1203
1344
|
);
|
1204
|
-
const [
|
1205
|
-
const
|
1206
|
-
async ({ model, params }
|
1345
|
+
const [discardDocument] = useDiscardDocumentMutation();
|
1346
|
+
const discard = React__namespace.useCallback(
|
1347
|
+
async ({ collectionType, model, documentId, params }) => {
|
1207
1348
|
try {
|
1208
|
-
const res = await
|
1349
|
+
const res = await discardDocument({
|
1350
|
+
collectionType,
|
1209
1351
|
model,
|
1210
|
-
|
1352
|
+
documentId,
|
1211
1353
|
params
|
1212
1354
|
});
|
1213
1355
|
if ("error" in res) {
|
1214
|
-
toggleNotification({
|
1215
|
-
|
1356
|
+
toggleNotification({
|
1357
|
+
type: "danger",
|
1358
|
+
message: formatAPIError(res.error)
|
1359
|
+
});
|
1216
1360
|
return { error: res.error };
|
1217
1361
|
}
|
1218
|
-
trackUsage("didCreateEntry", trackerProperty);
|
1219
1362
|
toggleNotification({
|
1220
1363
|
type: "success",
|
1221
1364
|
message: formatMessage({
|
1222
|
-
id:
|
1223
|
-
defaultMessage: "
|
1365
|
+
id: "content-manager.success.record.discard",
|
1366
|
+
defaultMessage: "Changes discarded"
|
1224
1367
|
})
|
1225
1368
|
});
|
1226
|
-
|
1369
|
+
return res.data;
|
1370
|
+
} catch (err) {
|
1371
|
+
toggleNotification({
|
1372
|
+
type: "danger",
|
1373
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1374
|
+
});
|
1375
|
+
throw err;
|
1376
|
+
}
|
1377
|
+
},
|
1378
|
+
[discardDocument, formatAPIError, formatMessage, toggleNotification]
|
1379
|
+
);
|
1380
|
+
const [publishDocument] = usePublishDocumentMutation();
|
1381
|
+
const publish = React__namespace.useCallback(
|
1382
|
+
async ({ collectionType, model, documentId, params }, data) => {
|
1383
|
+
try {
|
1384
|
+
trackUsage("willPublishEntry");
|
1385
|
+
const res = await publishDocument({
|
1386
|
+
collectionType,
|
1387
|
+
model,
|
1388
|
+
documentId,
|
1389
|
+
data,
|
1390
|
+
params
|
1391
|
+
});
|
1392
|
+
if ("error" in res) {
|
1393
|
+
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1394
|
+
return { error: res.error };
|
1395
|
+
}
|
1396
|
+
trackUsage("didPublishEntry");
|
1397
|
+
toggleNotification({
|
1398
|
+
type: "success",
|
1399
|
+
message: formatMessage({
|
1400
|
+
id: getTranslation("success.record.publish"),
|
1401
|
+
defaultMessage: "Published document"
|
1402
|
+
})
|
1403
|
+
});
|
1404
|
+
return res.data;
|
1405
|
+
} catch (err) {
|
1406
|
+
toggleNotification({
|
1407
|
+
type: "danger",
|
1408
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1409
|
+
});
|
1410
|
+
throw err;
|
1411
|
+
}
|
1412
|
+
},
|
1413
|
+
[trackUsage, publishDocument, toggleNotification, formatMessage, formatAPIError]
|
1414
|
+
);
|
1415
|
+
const [publishManyDocuments] = usePublishManyDocumentsMutation();
|
1416
|
+
const publishMany = React__namespace.useCallback(
|
1417
|
+
async ({ model, documentIds, params }) => {
|
1418
|
+
try {
|
1419
|
+
const res = await publishManyDocuments({
|
1420
|
+
model,
|
1421
|
+
documentIds,
|
1422
|
+
params
|
1423
|
+
});
|
1424
|
+
if ("error" in res) {
|
1425
|
+
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1426
|
+
return { error: res.error };
|
1427
|
+
}
|
1428
|
+
toggleNotification({
|
1429
|
+
type: "success",
|
1430
|
+
message: formatMessage({
|
1431
|
+
id: getTranslation("success.record.publish"),
|
1432
|
+
defaultMessage: "Published document"
|
1433
|
+
})
|
1434
|
+
});
|
1435
|
+
return res.data;
|
1436
|
+
} catch (err) {
|
1437
|
+
toggleNotification({
|
1438
|
+
type: "danger",
|
1439
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1440
|
+
});
|
1441
|
+
throw err;
|
1442
|
+
}
|
1443
|
+
},
|
1444
|
+
[
|
1445
|
+
// trackUsage,
|
1446
|
+
publishManyDocuments,
|
1447
|
+
toggleNotification,
|
1448
|
+
formatMessage,
|
1449
|
+
formatAPIError
|
1450
|
+
]
|
1451
|
+
);
|
1452
|
+
const [updateDocument] = useUpdateDocumentMutation();
|
1453
|
+
const update = React__namespace.useCallback(
|
1454
|
+
async ({ collectionType, model, documentId, params }, data, trackerProperty) => {
|
1455
|
+
try {
|
1456
|
+
trackUsage("willEditEntry", trackerProperty);
|
1457
|
+
const res = await updateDocument({
|
1458
|
+
collectionType,
|
1459
|
+
model,
|
1460
|
+
documentId,
|
1461
|
+
data,
|
1462
|
+
params
|
1463
|
+
});
|
1464
|
+
if ("error" in res) {
|
1465
|
+
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1466
|
+
trackUsage("didNotEditEntry", { error: res.error, ...trackerProperty });
|
1467
|
+
return { error: res.error };
|
1468
|
+
}
|
1469
|
+
trackUsage("didEditEntry", trackerProperty);
|
1470
|
+
toggleNotification({
|
1471
|
+
type: "success",
|
1472
|
+
message: formatMessage({
|
1473
|
+
id: getTranslation("success.record.save"),
|
1474
|
+
defaultMessage: "Saved document"
|
1475
|
+
})
|
1476
|
+
});
|
1477
|
+
return res.data;
|
1478
|
+
} catch (err) {
|
1479
|
+
trackUsage("didNotEditEntry", { error: err, ...trackerProperty });
|
1480
|
+
toggleNotification({
|
1481
|
+
type: "danger",
|
1482
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1483
|
+
});
|
1484
|
+
throw err;
|
1485
|
+
}
|
1486
|
+
},
|
1487
|
+
[trackUsage, updateDocument, toggleNotification, formatMessage, formatAPIError]
|
1488
|
+
);
|
1489
|
+
const [unpublishDocument] = useUnpublishDocumentMutation();
|
1490
|
+
const unpublish = React__namespace.useCallback(
|
1491
|
+
async ({ collectionType, model, documentId, params }, discardDraft = false) => {
|
1492
|
+
try {
|
1493
|
+
trackUsage("willUnpublishEntry");
|
1494
|
+
const res = await unpublishDocument({
|
1495
|
+
collectionType,
|
1496
|
+
model,
|
1497
|
+
documentId,
|
1498
|
+
params,
|
1499
|
+
data: {
|
1500
|
+
discardDraft
|
1501
|
+
}
|
1502
|
+
});
|
1503
|
+
if ("error" in res) {
|
1504
|
+
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1505
|
+
return { error: res.error };
|
1506
|
+
}
|
1507
|
+
trackUsage("didUnpublishEntry");
|
1508
|
+
toggleNotification({
|
1509
|
+
type: "success",
|
1510
|
+
message: formatMessage({
|
1511
|
+
id: getTranslation("success.record.unpublish"),
|
1512
|
+
defaultMessage: "Unpublished document"
|
1513
|
+
})
|
1514
|
+
});
|
1515
|
+
return res.data;
|
1516
|
+
} catch (err) {
|
1517
|
+
toggleNotification({
|
1518
|
+
type: "danger",
|
1519
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1520
|
+
});
|
1521
|
+
throw err;
|
1522
|
+
}
|
1523
|
+
},
|
1524
|
+
[trackUsage, unpublishDocument, toggleNotification, formatMessage, formatAPIError]
|
1525
|
+
);
|
1526
|
+
const [unpublishManyDocuments] = useUnpublishManyDocumentsMutation();
|
1527
|
+
const unpublishMany = React__namespace.useCallback(
|
1528
|
+
async ({ model, documentIds, params }) => {
|
1529
|
+
try {
|
1530
|
+
trackUsage("willBulkUnpublishEntries");
|
1531
|
+
const res = await unpublishManyDocuments({
|
1532
|
+
model,
|
1533
|
+
documentIds,
|
1534
|
+
params
|
1535
|
+
});
|
1536
|
+
if ("error" in res) {
|
1537
|
+
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1538
|
+
return { error: res.error };
|
1539
|
+
}
|
1540
|
+
trackUsage("didBulkUnpublishEntries");
|
1541
|
+
toggleNotification({
|
1542
|
+
type: "success",
|
1543
|
+
title: formatMessage({
|
1544
|
+
id: getTranslation("success.records.unpublish"),
|
1545
|
+
defaultMessage: "Successfully unpublished."
|
1546
|
+
}),
|
1547
|
+
message: ""
|
1548
|
+
});
|
1549
|
+
return res.data;
|
1550
|
+
} catch (err) {
|
1551
|
+
toggleNotification({
|
1552
|
+
type: "danger",
|
1553
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1554
|
+
});
|
1555
|
+
trackUsage("didNotBulkUnpublishEntries");
|
1556
|
+
throw err;
|
1557
|
+
}
|
1558
|
+
},
|
1559
|
+
[trackUsage, unpublishManyDocuments, toggleNotification, formatMessage, formatAPIError]
|
1560
|
+
);
|
1561
|
+
const [createDocument] = useCreateDocumentMutation();
|
1562
|
+
const create = React__namespace.useCallback(
|
1563
|
+
async ({ model, params }, data, trackerProperty) => {
|
1564
|
+
try {
|
1565
|
+
const res = await createDocument({
|
1566
|
+
model,
|
1567
|
+
data,
|
1568
|
+
params
|
1569
|
+
});
|
1570
|
+
if ("error" in res) {
|
1571
|
+
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1572
|
+
trackUsage("didNotCreateEntry", { error: res.error, ...trackerProperty });
|
1573
|
+
return { error: res.error };
|
1574
|
+
}
|
1575
|
+
trackUsage("didCreateEntry", trackerProperty);
|
1576
|
+
toggleNotification({
|
1577
|
+
type: "success",
|
1578
|
+
message: formatMessage({
|
1579
|
+
id: getTranslation("success.record.save"),
|
1580
|
+
defaultMessage: "Saved document"
|
1581
|
+
})
|
1582
|
+
});
|
1583
|
+
setCurrentStep("contentManager.success");
|
1227
1584
|
return res.data;
|
1228
1585
|
} catch (err) {
|
1229
1586
|
toggleNotification({
|
@@ -1326,7 +1683,7 @@ const useDocumentActions = () => {
|
|
1326
1683
|
};
|
1327
1684
|
};
|
1328
1685
|
const ProtectedHistoryPage = React.lazy(
|
1329
|
-
() => Promise.resolve().then(() => require("./History-
|
1686
|
+
() => Promise.resolve().then(() => require("./History-B-Mrquzu.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
|
1330
1687
|
);
|
1331
1688
|
const routes$1 = [
|
1332
1689
|
{
|
@@ -1339,31 +1696,31 @@ const routes$1 = [
|
|
1339
1696
|
}
|
1340
1697
|
];
|
1341
1698
|
const ProtectedEditViewPage = React.lazy(
|
1342
|
-
() => Promise.resolve().then(() => require("./EditViewPage-
|
1699
|
+
() => Promise.resolve().then(() => require("./EditViewPage-BMVgUNOX.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
|
1343
1700
|
);
|
1344
1701
|
const ProtectedListViewPage = React.lazy(
|
1345
|
-
() => Promise.resolve().then(() => require("./ListViewPage-
|
1702
|
+
() => Promise.resolve().then(() => require("./ListViewPage-q0SHVPUS.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
|
1346
1703
|
);
|
1347
1704
|
const ProtectedListConfiguration = React.lazy(
|
1348
|
-
() => Promise.resolve().then(() => require("./ListConfigurationPage-
|
1705
|
+
() => Promise.resolve().then(() => require("./ListConfigurationPage-C0n4rUzH.js")).then((mod) => ({
|
1349
1706
|
default: mod.ProtectedListConfiguration
|
1350
1707
|
}))
|
1351
1708
|
);
|
1352
1709
|
const ProtectedEditConfigurationPage = React.lazy(
|
1353
|
-
() => Promise.resolve().then(() => require("./EditConfigurationPage-
|
1710
|
+
() => Promise.resolve().then(() => require("./EditConfigurationPage-BPgoE-kf.js")).then((mod) => ({
|
1354
1711
|
default: mod.ProtectedEditConfigurationPage
|
1355
1712
|
}))
|
1356
1713
|
);
|
1357
1714
|
const ProtectedComponentConfigurationPage = React.lazy(
|
1358
|
-
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-
|
1715
|
+
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-CO977CPh.js")).then((mod) => ({
|
1359
1716
|
default: mod.ProtectedComponentConfigurationPage
|
1360
1717
|
}))
|
1361
1718
|
);
|
1362
1719
|
const NoPermissions = React.lazy(
|
1363
|
-
() => Promise.resolve().then(() => require("./NoPermissionsPage-
|
1720
|
+
() => Promise.resolve().then(() => require("./NoPermissionsPage-BGBpj_Y1.js")).then((mod) => ({ default: mod.NoPermissions }))
|
1364
1721
|
);
|
1365
1722
|
const NoContentType = React.lazy(
|
1366
|
-
() => Promise.resolve().then(() => require("./NoContentTypePage-
|
1723
|
+
() => Promise.resolve().then(() => require("./NoContentTypePage-Bh3komDV.js")).then((mod) => ({ default: mod.NoContentType }))
|
1367
1724
|
);
|
1368
1725
|
const CollectionTypePages = () => {
|
1369
1726
|
const { collectionType } = reactRouterDom.useParams();
|
@@ -1810,7 +2167,9 @@ const PublishAction$1 = ({
|
|
1810
2167
|
const performPublish = async () => {
|
1811
2168
|
setSubmitting(true);
|
1812
2169
|
try {
|
1813
|
-
const { errors } = await validate(
|
2170
|
+
const { errors } = await validate(true, {
|
2171
|
+
status: "published"
|
2172
|
+
});
|
1814
2173
|
if (errors) {
|
1815
2174
|
toggleNotification({
|
1816
2175
|
type: "danger",
|
@@ -1924,18 +2283,18 @@ const UpdateAction = ({
|
|
1924
2283
|
onClick: async () => {
|
1925
2284
|
setSubmitting(true);
|
1926
2285
|
try {
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1934
|
-
|
1935
|
-
|
1936
|
-
})
|
1937
|
-
|
1938
|
-
|
2286
|
+
const { errors } = await validate(true, {
|
2287
|
+
status: "draft"
|
2288
|
+
});
|
2289
|
+
if (errors) {
|
2290
|
+
toggleNotification({
|
2291
|
+
type: "danger",
|
2292
|
+
message: formatMessage({
|
2293
|
+
id: "content-manager.validation.error",
|
2294
|
+
defaultMessage: "There are validation errors in your document. Please fix them before saving."
|
2295
|
+
})
|
2296
|
+
});
|
2297
|
+
return;
|
1939
2298
|
}
|
1940
2299
|
if (isCloning) {
|
1941
2300
|
const res = await clone(
|
@@ -2317,12 +2676,12 @@ const Information = ({ activeTab }) => {
|
|
2317
2676
|
isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
|
2318
2677
|
label: formatMessage({
|
2319
2678
|
id: "content-manager.containers.edit.information.last-published.label",
|
2320
|
-
defaultMessage: "
|
2679
|
+
defaultMessage: "Published"
|
2321
2680
|
}),
|
2322
2681
|
value: formatMessage(
|
2323
2682
|
{
|
2324
2683
|
id: "content-manager.containers.edit.information.last-published.value",
|
2325
|
-
defaultMessage: `
|
2684
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2326
2685
|
},
|
2327
2686
|
{
|
2328
2687
|
time: /* @__PURE__ */ jsxRuntime.jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
|
@@ -2335,12 +2694,12 @@ const Information = ({ activeTab }) => {
|
|
2335
2694
|
isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
|
2336
2695
|
label: formatMessage({
|
2337
2696
|
id: "content-manager.containers.edit.information.last-draft.label",
|
2338
|
-
defaultMessage: "
|
2697
|
+
defaultMessage: "Updated"
|
2339
2698
|
}),
|
2340
2699
|
value: formatMessage(
|
2341
2700
|
{
|
2342
2701
|
id: "content-manager.containers.edit.information.last-draft.value",
|
2343
|
-
defaultMessage: `
|
2702
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2344
2703
|
},
|
2345
2704
|
{
|
2346
2705
|
time: /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -2358,12 +2717,12 @@ const Information = ({ activeTab }) => {
|
|
2358
2717
|
isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
|
2359
2718
|
label: formatMessage({
|
2360
2719
|
id: "content-manager.containers.edit.information.document.label",
|
2361
|
-
defaultMessage: "
|
2720
|
+
defaultMessage: "Created"
|
2362
2721
|
}),
|
2363
2722
|
value: formatMessage(
|
2364
2723
|
{
|
2365
2724
|
id: "content-manager.containers.edit.information.document.value",
|
2366
|
-
defaultMessage: `
|
2725
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2367
2726
|
},
|
2368
2727
|
{
|
2369
2728
|
time: /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -2421,10 +2780,9 @@ const HeaderActions = ({ actions: actions2 }) => {
|
|
2421
2780
|
designSystem.SingleSelect,
|
2422
2781
|
{
|
2423
2782
|
size: "S",
|
2424
|
-
disabled: action.disabled,
|
2425
|
-
"aria-label": action.label,
|
2426
2783
|
onChange: action.onSelect,
|
2427
|
-
|
2784
|
+
"aria-label": action.label,
|
2785
|
+
...action,
|
2428
2786
|
children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { ...option, children: label }, option.value))
|
2429
2787
|
},
|
2430
2788
|
action.id
|
@@ -2488,490 +2846,191 @@ const ConfigureTheViewAction = ({ collectionType, model }) => {
|
|
2488
2846
|
position: "header"
|
2489
2847
|
};
|
2490
2848
|
};
|
2491
|
-
ConfigureTheViewAction.type = "configure-the-view";
|
2492
|
-
const EditTheModelAction = ({ model }) => {
|
2493
|
-
const navigate = reactRouterDom.useNavigate();
|
2494
|
-
const { formatMessage } = reactIntl.useIntl();
|
2495
|
-
return {
|
2496
|
-
label: formatMessage({
|
2497
|
-
id: "content-manager.link-to-ctb",
|
2498
|
-
defaultMessage: "Edit the model"
|
2499
|
-
}),
|
2500
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, {}),
|
2501
|
-
onClick: () => {
|
2502
|
-
navigate(`/plugins/content-type-builder/content-types/${model}`);
|
2503
|
-
},
|
2504
|
-
position: "header"
|
2505
|
-
};
|
2506
|
-
};
|
2507
|
-
EditTheModelAction.type = "edit-the-model";
|
2508
|
-
const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
2509
|
-
const navigate = reactRouterDom.useNavigate();
|
2510
|
-
const { formatMessage } = reactIntl.useIntl();
|
2511
|
-
const listViewPathMatch = reactRouterDom.useMatch(LIST_PATH);
|
2512
|
-
const canDelete = useDocumentRBAC("DeleteAction", (state) => state.canDelete);
|
2513
|
-
const { delete: deleteAction } = useDocumentActions();
|
2514
|
-
const { toggleNotification } = strapiAdmin.useNotification();
|
2515
|
-
const setSubmitting = strapiAdmin.useForm("DeleteAction", (state) => state.setSubmitting);
|
2516
|
-
return {
|
2517
|
-
disabled: !canDelete || !document,
|
2518
|
-
label: formatMessage({
|
2519
|
-
id: "content-manager.actions.delete.label",
|
2520
|
-
defaultMessage: "Delete document"
|
2521
|
-
}),
|
2522
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}),
|
2523
|
-
dialog: {
|
2524
|
-
type: "dialog",
|
2525
|
-
title: formatMessage({
|
2526
|
-
id: "app.components.ConfirmDialog.title",
|
2527
|
-
defaultMessage: "Confirmation"
|
2528
|
-
}),
|
2529
|
-
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
|
2530
|
-
/* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
|
2531
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
|
2532
|
-
id: "content-manager.actions.delete.dialog.body",
|
2533
|
-
defaultMessage: "Are you sure?"
|
2534
|
-
}) })
|
2535
|
-
] }),
|
2536
|
-
onConfirm: async () => {
|
2537
|
-
if (!listViewPathMatch) {
|
2538
|
-
setSubmitting(true);
|
2539
|
-
}
|
2540
|
-
try {
|
2541
|
-
if (!documentId && collectionType !== SINGLE_TYPES) {
|
2542
|
-
console.error(
|
2543
|
-
"You're trying to delete a document without an id, this is likely a bug with Strapi. Please open an issue."
|
2544
|
-
);
|
2545
|
-
toggleNotification({
|
2546
|
-
message: formatMessage({
|
2547
|
-
id: "content-manager.actions.delete.error",
|
2548
|
-
defaultMessage: "An error occurred while trying to delete the document."
|
2549
|
-
}),
|
2550
|
-
type: "danger"
|
2551
|
-
});
|
2552
|
-
return;
|
2553
|
-
}
|
2554
|
-
const res = await deleteAction({
|
2555
|
-
documentId,
|
2556
|
-
model,
|
2557
|
-
collectionType,
|
2558
|
-
params: {
|
2559
|
-
locale: "*"
|
2560
|
-
}
|
2561
|
-
});
|
2562
|
-
if (!("error" in res)) {
|
2563
|
-
navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
|
2564
|
-
}
|
2565
|
-
} finally {
|
2566
|
-
if (!listViewPathMatch) {
|
2567
|
-
setSubmitting(false);
|
2568
|
-
}
|
2569
|
-
}
|
2570
|
-
}
|
2571
|
-
},
|
2572
|
-
variant: "danger",
|
2573
|
-
position: ["header", "table-row"]
|
2574
|
-
};
|
2575
|
-
};
|
2576
|
-
DeleteAction$1.type = "delete";
|
2577
|
-
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
|
2578
|
-
const Panels = () => {
|
2579
|
-
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2580
|
-
const [
|
2581
|
-
{
|
2582
|
-
query: { status }
|
2583
|
-
}
|
2584
|
-
] = strapiAdmin.useQueryParams({
|
2585
|
-
status: "draft"
|
2586
|
-
});
|
2587
|
-
const { model, id, document, meta, collectionType } = useDoc();
|
2588
|
-
const plugins = strapiAdmin.useStrapiApp("Panels", (state) => state.plugins);
|
2589
|
-
const props = {
|
2590
|
-
activeTab: status,
|
2591
|
-
model,
|
2592
|
-
documentId: id,
|
2593
|
-
document: isCloning ? void 0 : document,
|
2594
|
-
meta: isCloning ? void 0 : meta,
|
2595
|
-
collectionType
|
2596
|
-
};
|
2597
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
2598
|
-
strapiAdmin.DescriptionComponentRenderer,
|
2599
|
-
{
|
2600
|
-
props,
|
2601
|
-
descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
|
2602
|
-
children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsxRuntime.jsx(Panel, { ...description, children: content }, id2))
|
2603
|
-
}
|
2604
|
-
) });
|
2605
|
-
};
|
2606
|
-
const ActionsPanel = () => {
|
2607
|
-
const { formatMessage } = reactIntl.useIntl();
|
2608
|
-
return {
|
2609
|
-
title: formatMessage({
|
2610
|
-
id: "content-manager.containers.edit.panels.default.title",
|
2611
|
-
defaultMessage: "Entry"
|
2612
|
-
}),
|
2613
|
-
content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
|
2614
|
-
};
|
2615
|
-
};
|
2616
|
-
ActionsPanel.type = "actions";
|
2617
|
-
const ActionsPanelContent = () => {
|
2618
|
-
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2619
|
-
const [
|
2620
|
-
{
|
2621
|
-
query: { status = "draft" }
|
2622
|
-
}
|
2623
|
-
] = strapiAdmin.useQueryParams();
|
2624
|
-
const { model, id, document, meta, collectionType } = useDoc();
|
2625
|
-
const plugins = strapiAdmin.useStrapiApp("ActionsPanel", (state) => state.plugins);
|
2626
|
-
const props = {
|
2627
|
-
activeTab: status,
|
2628
|
-
model,
|
2629
|
-
documentId: id,
|
2630
|
-
document: isCloning ? void 0 : document,
|
2631
|
-
meta: isCloning ? void 0 : meta,
|
2632
|
-
collectionType
|
2633
|
-
};
|
2634
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, width: "100%", children: [
|
2635
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
2636
|
-
strapiAdmin.DescriptionComponentRenderer,
|
2637
|
-
{
|
2638
|
-
props,
|
2639
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
2640
|
-
children: (actions2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActions, { actions: actions2 })
|
2641
|
-
}
|
2642
|
-
),
|
2643
|
-
/* @__PURE__ */ jsxRuntime.jsx(InjectionZone, { area: "editView.right-links", slug: model })
|
2644
|
-
] });
|
2645
|
-
};
|
2646
|
-
const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
|
2647
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
2648
|
-
designSystem.Flex,
|
2649
|
-
{
|
2650
|
-
ref,
|
2651
|
-
tag: "aside",
|
2652
|
-
"aria-labelledby": "additional-information",
|
2653
|
-
background: "neutral0",
|
2654
|
-
borderColor: "neutral150",
|
2655
|
-
hasRadius: true,
|
2656
|
-
paddingBottom: 4,
|
2657
|
-
paddingLeft: 4,
|
2658
|
-
paddingRight: 4,
|
2659
|
-
paddingTop: 4,
|
2660
|
-
shadow: "tableShadow",
|
2661
|
-
gap: 3,
|
2662
|
-
direction: "column",
|
2663
|
-
justifyContent: "stretch",
|
2664
|
-
alignItems: "flex-start",
|
2665
|
-
children: [
|
2666
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
|
2667
|
-
children
|
2668
|
-
]
|
2669
|
-
}
|
2670
|
-
);
|
2671
|
-
});
|
2672
|
-
const HOOKS = {
|
2673
|
-
/**
|
2674
|
-
* Hook that allows to mutate the displayed headers of the list view table
|
2675
|
-
* @constant
|
2676
|
-
* @type {string}
|
2677
|
-
*/
|
2678
|
-
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
2679
|
-
/**
|
2680
|
-
* Hook that allows to mutate the CM's collection types links pre-set filters
|
2681
|
-
* @constant
|
2682
|
-
* @type {string}
|
2683
|
-
*/
|
2684
|
-
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
2685
|
-
/**
|
2686
|
-
* Hook that allows to mutate the CM's edit view layout
|
2687
|
-
* @constant
|
2688
|
-
* @type {string}
|
2689
|
-
*/
|
2690
|
-
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
2691
|
-
/**
|
2692
|
-
* Hook that allows to mutate the CM's single types links pre-set filters
|
2693
|
-
* @constant
|
2694
|
-
* @type {string}
|
2695
|
-
*/
|
2696
|
-
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
2697
|
-
};
|
2698
|
-
const contentTypesApi = contentManagerApi.injectEndpoints({
|
2699
|
-
endpoints: (builder) => ({
|
2700
|
-
getContentTypeConfiguration: builder.query({
|
2701
|
-
query: (uid) => ({
|
2702
|
-
url: `/content-manager/content-types/${uid}/configuration`,
|
2703
|
-
method: "GET"
|
2704
|
-
}),
|
2705
|
-
transformResponse: (response) => response.data,
|
2706
|
-
providesTags: (_result, _error, uid) => [
|
2707
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2708
|
-
{ type: "ContentTypeSettings", id: "LIST" }
|
2709
|
-
]
|
2710
|
-
}),
|
2711
|
-
getAllContentTypeSettings: builder.query({
|
2712
|
-
query: () => "/content-manager/content-types-settings",
|
2713
|
-
transformResponse: (response) => response.data,
|
2714
|
-
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
2715
|
-
}),
|
2716
|
-
updateContentTypeConfiguration: builder.mutation({
|
2717
|
-
query: ({ uid, ...body }) => ({
|
2718
|
-
url: `/content-manager/content-types/${uid}/configuration`,
|
2719
|
-
method: "PUT",
|
2720
|
-
data: body
|
2721
|
-
}),
|
2722
|
-
transformResponse: (response) => response.data,
|
2723
|
-
invalidatesTags: (_result, _error, { uid }) => [
|
2724
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2725
|
-
{ type: "ContentTypeSettings", id: "LIST" },
|
2726
|
-
// Is this necessary?
|
2727
|
-
{ type: "InitialData" }
|
2728
|
-
]
|
2729
|
-
})
|
2730
|
-
})
|
2731
|
-
});
|
2732
|
-
const {
|
2733
|
-
useGetContentTypeConfigurationQuery,
|
2734
|
-
useGetAllContentTypeSettingsQuery,
|
2735
|
-
useUpdateContentTypeConfigurationMutation
|
2736
|
-
} = contentTypesApi;
|
2737
|
-
const checkIfAttributeIsDisplayable = (attribute) => {
|
2738
|
-
const { type } = attribute;
|
2739
|
-
if (type === "relation") {
|
2740
|
-
return !attribute.relation.toLowerCase().includes("morph");
|
2741
|
-
}
|
2742
|
-
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
2743
|
-
};
|
2744
|
-
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
2745
|
-
if (!mainFieldName) {
|
2746
|
-
return void 0;
|
2747
|
-
}
|
2748
|
-
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
2749
|
-
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
2750
|
-
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
2751
|
-
);
|
2752
|
-
return {
|
2753
|
-
name: mainFieldName,
|
2754
|
-
type: mainFieldType ?? "string"
|
2755
|
-
};
|
2756
|
-
};
|
2757
|
-
const DEFAULT_SETTINGS = {
|
2758
|
-
bulkable: false,
|
2759
|
-
filterable: false,
|
2760
|
-
searchable: false,
|
2761
|
-
pagination: false,
|
2762
|
-
defaultSortBy: "",
|
2763
|
-
defaultSortOrder: "asc",
|
2764
|
-
mainField: "id",
|
2765
|
-
pageSize: 10
|
2766
|
-
};
|
2767
|
-
const useDocumentLayout = (model) => {
|
2768
|
-
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
2769
|
-
const [{ query }] = strapiAdmin.useQueryParams();
|
2770
|
-
const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
2771
|
-
const { toggleNotification } = strapiAdmin.useNotification();
|
2772
|
-
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
2773
|
-
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
2774
|
-
const {
|
2775
|
-
data,
|
2776
|
-
isLoading: isLoadingConfigs,
|
2777
|
-
error,
|
2778
|
-
isFetching: isFetchingConfigs
|
2779
|
-
} = useGetContentTypeConfigurationQuery(model);
|
2780
|
-
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
2781
|
-
React__namespace.useEffect(() => {
|
2782
|
-
if (error) {
|
2783
|
-
toggleNotification({
|
2784
|
-
type: "danger",
|
2785
|
-
message: formatAPIError(error)
|
2786
|
-
});
|
2787
|
-
}
|
2788
|
-
}, [error, formatAPIError, toggleNotification]);
|
2789
|
-
const editLayout = React__namespace.useMemo(
|
2790
|
-
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
2791
|
-
layout: [],
|
2792
|
-
components: {},
|
2793
|
-
metadatas: {},
|
2794
|
-
options: {},
|
2795
|
-
settings: DEFAULT_SETTINGS
|
2796
|
-
},
|
2797
|
-
[data, isLoading, schemas, schema, components]
|
2798
|
-
);
|
2799
|
-
const listLayout = React__namespace.useMemo(() => {
|
2800
|
-
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
2801
|
-
layout: [],
|
2802
|
-
metadatas: {},
|
2803
|
-
options: {},
|
2804
|
-
settings: DEFAULT_SETTINGS
|
2805
|
-
};
|
2806
|
-
}, [data, isLoading, schemas, schema, components]);
|
2807
|
-
const { layout: edit } = React__namespace.useMemo(
|
2808
|
-
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
2809
|
-
layout: editLayout,
|
2810
|
-
query
|
2811
|
-
}),
|
2812
|
-
[editLayout, query, runHookWaterfall]
|
2813
|
-
);
|
2814
|
-
return {
|
2815
|
-
error,
|
2816
|
-
isLoading,
|
2817
|
-
edit,
|
2818
|
-
list: listLayout
|
2819
|
-
};
|
2820
|
-
};
|
2821
|
-
const useDocLayout = () => {
|
2822
|
-
const { model } = useDoc();
|
2823
|
-
return useDocumentLayout(model);
|
2824
|
-
};
|
2825
|
-
const formatEditLayout = (data, {
|
2826
|
-
schemas,
|
2827
|
-
schema,
|
2828
|
-
components
|
2829
|
-
}) => {
|
2830
|
-
let currentPanelIndex = 0;
|
2831
|
-
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
2832
|
-
data.contentType.layouts.edit,
|
2833
|
-
schema?.attributes,
|
2834
|
-
data.contentType.metadatas,
|
2835
|
-
{ configurations: data.components, schemas: components },
|
2836
|
-
schemas
|
2837
|
-
).reduce((panels, row) => {
|
2838
|
-
if (row.some((field) => field.type === "dynamiczone")) {
|
2839
|
-
panels.push([row]);
|
2840
|
-
currentPanelIndex += 2;
|
2841
|
-
} else {
|
2842
|
-
if (!panels[currentPanelIndex]) {
|
2843
|
-
panels.push([]);
|
2844
|
-
}
|
2845
|
-
panels[currentPanelIndex].push(row);
|
2846
|
-
}
|
2847
|
-
return panels;
|
2848
|
-
}, []);
|
2849
|
-
const componentEditAttributes = Object.entries(data.components).reduce(
|
2850
|
-
(acc, [uid, configuration]) => {
|
2851
|
-
acc[uid] = {
|
2852
|
-
layout: convertEditLayoutToFieldLayouts(
|
2853
|
-
configuration.layouts.edit,
|
2854
|
-
components[uid].attributes,
|
2855
|
-
configuration.metadatas,
|
2856
|
-
{ configurations: data.components, schemas: components }
|
2857
|
-
),
|
2858
|
-
settings: {
|
2859
|
-
...configuration.settings,
|
2860
|
-
icon: components[uid].info.icon,
|
2861
|
-
displayName: components[uid].info.displayName
|
2862
|
-
}
|
2863
|
-
};
|
2864
|
-
return acc;
|
2865
|
-
},
|
2866
|
-
{}
|
2867
|
-
);
|
2868
|
-
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2869
|
-
(acc, [attribute, metadata]) => {
|
2870
|
-
return {
|
2871
|
-
...acc,
|
2872
|
-
[attribute]: metadata.edit
|
2873
|
-
};
|
2874
|
-
},
|
2875
|
-
{}
|
2876
|
-
);
|
2849
|
+
ConfigureTheViewAction.type = "configure-the-view";
|
2850
|
+
const EditTheModelAction = ({ model }) => {
|
2851
|
+
const navigate = reactRouterDom.useNavigate();
|
2852
|
+
const { formatMessage } = reactIntl.useIntl();
|
2877
2853
|
return {
|
2878
|
-
|
2879
|
-
|
2880
|
-
|
2881
|
-
|
2882
|
-
|
2883
|
-
|
2854
|
+
label: formatMessage({
|
2855
|
+
id: "content-manager.link-to-ctb",
|
2856
|
+
defaultMessage: "Edit the model"
|
2857
|
+
}),
|
2858
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, {}),
|
2859
|
+
onClick: () => {
|
2860
|
+
navigate(`/plugins/content-type-builder/content-types/${model}`);
|
2884
2861
|
},
|
2885
|
-
|
2886
|
-
...schema?.options,
|
2887
|
-
...schema?.pluginOptions,
|
2888
|
-
...data.contentType.options
|
2889
|
-
}
|
2862
|
+
position: "header"
|
2890
2863
|
};
|
2891
2864
|
};
|
2892
|
-
|
2893
|
-
|
2894
|
-
|
2895
|
-
|
2896
|
-
|
2897
|
-
|
2865
|
+
EditTheModelAction.type = "edit-the-model";
|
2866
|
+
const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
2867
|
+
const navigate = reactRouterDom.useNavigate();
|
2868
|
+
const { formatMessage } = reactIntl.useIntl();
|
2869
|
+
const listViewPathMatch = reactRouterDom.useMatch(LIST_PATH);
|
2870
|
+
const canDelete = useDocumentRBAC("DeleteAction", (state) => state.canDelete);
|
2871
|
+
const { delete: deleteAction } = useDocumentActions();
|
2872
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
2873
|
+
const setSubmitting = strapiAdmin.useForm("DeleteAction", (state) => state.setSubmitting);
|
2874
|
+
const isLocalized = document?.locale != null;
|
2875
|
+
return {
|
2876
|
+
disabled: !canDelete || !document,
|
2877
|
+
label: formatMessage(
|
2878
|
+
{
|
2879
|
+
id: "content-manager.actions.delete.label",
|
2880
|
+
defaultMessage: "Delete entry{isLocalized, select, true { (all locales)} other {}}"
|
2881
|
+
},
|
2882
|
+
{ isLocalized }
|
2883
|
+
),
|
2884
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}),
|
2885
|
+
dialog: {
|
2886
|
+
type: "dialog",
|
2887
|
+
title: formatMessage({
|
2888
|
+
id: "app.components.ConfirmDialog.title",
|
2889
|
+
defaultMessage: "Confirmation"
|
2890
|
+
}),
|
2891
|
+
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
|
2892
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
|
2893
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
|
2894
|
+
id: "content-manager.actions.delete.dialog.body",
|
2895
|
+
defaultMessage: "Are you sure?"
|
2896
|
+
}) })
|
2897
|
+
] }),
|
2898
|
+
onConfirm: async () => {
|
2899
|
+
if (!listViewPathMatch) {
|
2900
|
+
setSubmitting(true);
|
2901
|
+
}
|
2902
|
+
try {
|
2903
|
+
if (!documentId && collectionType !== SINGLE_TYPES) {
|
2904
|
+
console.error(
|
2905
|
+
"You're trying to delete a document without an id, this is likely a bug with Strapi. Please open an issue."
|
2906
|
+
);
|
2907
|
+
toggleNotification({
|
2908
|
+
message: formatMessage({
|
2909
|
+
id: "content-manager.actions.delete.error",
|
2910
|
+
defaultMessage: "An error occurred while trying to delete the document."
|
2911
|
+
}),
|
2912
|
+
type: "danger"
|
2913
|
+
});
|
2914
|
+
return;
|
2915
|
+
}
|
2916
|
+
const res = await deleteAction({
|
2917
|
+
documentId,
|
2918
|
+
model,
|
2919
|
+
collectionType,
|
2920
|
+
params: {
|
2921
|
+
locale: "*"
|
2922
|
+
}
|
2923
|
+
});
|
2924
|
+
if (!("error" in res)) {
|
2925
|
+
navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
|
2926
|
+
}
|
2927
|
+
} finally {
|
2928
|
+
if (!listViewPathMatch) {
|
2929
|
+
setSubmitting(false);
|
2930
|
+
}
|
2931
|
+
}
|
2898
2932
|
}
|
2899
|
-
const { edit: metadata } = metadatas[field.name];
|
2900
|
-
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
2901
|
-
return {
|
2902
|
-
attribute,
|
2903
|
-
disabled: !metadata.editable,
|
2904
|
-
hint: metadata.description,
|
2905
|
-
label: metadata.label ?? "",
|
2906
|
-
name: field.name,
|
2907
|
-
// @ts-expect-error – mainField does exist on the metadata for a relation.
|
2908
|
-
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
2909
|
-
schemas,
|
2910
|
-
components: components?.schemas ?? {}
|
2911
|
-
}),
|
2912
|
-
placeholder: metadata.placeholder ?? "",
|
2913
|
-
required: attribute.required ?? false,
|
2914
|
-
size: field.size,
|
2915
|
-
unique: "unique" in attribute ? attribute.unique : false,
|
2916
|
-
visible: metadata.visible ?? true,
|
2917
|
-
type: attribute.type
|
2918
|
-
};
|
2919
|
-
}).filter((field) => field !== null)
|
2920
|
-
);
|
2921
|
-
};
|
2922
|
-
const formatListLayout = (data, {
|
2923
|
-
schemas,
|
2924
|
-
schema,
|
2925
|
-
components
|
2926
|
-
}) => {
|
2927
|
-
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2928
|
-
(acc, [attribute, metadata]) => {
|
2929
|
-
return {
|
2930
|
-
...acc,
|
2931
|
-
[attribute]: metadata.list
|
2932
|
-
};
|
2933
2933
|
},
|
2934
|
-
|
2935
|
-
|
2936
|
-
|
2937
|
-
|
2938
|
-
|
2939
|
-
|
2940
|
-
|
2941
|
-
|
2942
|
-
|
2943
|
-
|
2944
|
-
|
2945
|
-
|
2946
|
-
|
2947
|
-
|
2948
|
-
|
2949
|
-
|
2950
|
-
|
2934
|
+
variant: "danger",
|
2935
|
+
position: ["header", "table-row"]
|
2936
|
+
};
|
2937
|
+
};
|
2938
|
+
DeleteAction$1.type = "delete";
|
2939
|
+
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
|
2940
|
+
const Panels = () => {
|
2941
|
+
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2942
|
+
const [
|
2943
|
+
{
|
2944
|
+
query: { status }
|
2945
|
+
}
|
2946
|
+
] = strapiAdmin.useQueryParams({
|
2947
|
+
status: "draft"
|
2948
|
+
});
|
2949
|
+
const { model, id, document, meta, collectionType } = useDoc();
|
2950
|
+
const plugins = strapiAdmin.useStrapiApp("Panels", (state) => state.plugins);
|
2951
|
+
const props = {
|
2952
|
+
activeTab: status,
|
2953
|
+
model,
|
2954
|
+
documentId: id,
|
2955
|
+
document: isCloning ? void 0 : document,
|
2956
|
+
meta: isCloning ? void 0 : meta,
|
2957
|
+
collectionType
|
2958
|
+
};
|
2959
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
2960
|
+
strapiAdmin.DescriptionComponentRenderer,
|
2961
|
+
{
|
2962
|
+
props,
|
2963
|
+
descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
|
2964
|
+
children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsxRuntime.jsx(Panel, { ...description, children: content }, id2))
|
2951
2965
|
}
|
2966
|
+
) });
|
2967
|
+
};
|
2968
|
+
const ActionsPanel = () => {
|
2969
|
+
const { formatMessage } = reactIntl.useIntl();
|
2970
|
+
return {
|
2971
|
+
title: formatMessage({
|
2972
|
+
id: "content-manager.containers.edit.panels.default.title",
|
2973
|
+
defaultMessage: "Entry"
|
2974
|
+
}),
|
2975
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
|
2952
2976
|
};
|
2953
2977
|
};
|
2954
|
-
|
2955
|
-
|
2956
|
-
|
2957
|
-
|
2958
|
-
|
2978
|
+
ActionsPanel.type = "actions";
|
2979
|
+
const ActionsPanelContent = () => {
|
2980
|
+
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2981
|
+
const [
|
2982
|
+
{
|
2983
|
+
query: { status = "draft" }
|
2959
2984
|
}
|
2960
|
-
|
2961
|
-
|
2962
|
-
|
2963
|
-
|
2964
|
-
|
2965
|
-
|
2966
|
-
|
2967
|
-
|
2968
|
-
|
2969
|
-
|
2970
|
-
|
2971
|
-
|
2972
|
-
|
2973
|
-
|
2985
|
+
] = strapiAdmin.useQueryParams();
|
2986
|
+
const { model, id, document, meta, collectionType } = useDoc();
|
2987
|
+
const plugins = strapiAdmin.useStrapiApp("ActionsPanel", (state) => state.plugins);
|
2988
|
+
const props = {
|
2989
|
+
activeTab: status,
|
2990
|
+
model,
|
2991
|
+
documentId: id,
|
2992
|
+
document: isCloning ? void 0 : document,
|
2993
|
+
meta: isCloning ? void 0 : meta,
|
2994
|
+
collectionType
|
2995
|
+
};
|
2996
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, width: "100%", children: [
|
2997
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
2998
|
+
strapiAdmin.DescriptionComponentRenderer,
|
2999
|
+
{
|
3000
|
+
props,
|
3001
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
3002
|
+
children: (actions2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActions, { actions: actions2 })
|
3003
|
+
}
|
3004
|
+
),
|
3005
|
+
/* @__PURE__ */ jsxRuntime.jsx(InjectionZone, { area: "editView.right-links", slug: model })
|
3006
|
+
] });
|
2974
3007
|
};
|
3008
|
+
const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
|
3009
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
3010
|
+
designSystem.Flex,
|
3011
|
+
{
|
3012
|
+
ref,
|
3013
|
+
tag: "aside",
|
3014
|
+
"aria-labelledby": "additional-information",
|
3015
|
+
background: "neutral0",
|
3016
|
+
borderColor: "neutral150",
|
3017
|
+
hasRadius: true,
|
3018
|
+
paddingBottom: 4,
|
3019
|
+
paddingLeft: 4,
|
3020
|
+
paddingRight: 4,
|
3021
|
+
paddingTop: 4,
|
3022
|
+
shadow: "tableShadow",
|
3023
|
+
gap: 3,
|
3024
|
+
direction: "column",
|
3025
|
+
justifyContent: "stretch",
|
3026
|
+
alignItems: "flex-start",
|
3027
|
+
children: [
|
3028
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
|
3029
|
+
children
|
3030
|
+
]
|
3031
|
+
}
|
3032
|
+
);
|
3033
|
+
});
|
2975
3034
|
const ConfirmBulkActionDialog = ({
|
2976
3035
|
onToggleDialog,
|
2977
3036
|
isOpen = false,
|
@@ -3968,7 +4027,7 @@ const index = {
|
|
3968
4027
|
app.router.addRoute({
|
3969
4028
|
path: "content-manager/*",
|
3970
4029
|
lazy: async () => {
|
3971
|
-
const { Layout } = await Promise.resolve().then(() => require("./layout-
|
4030
|
+
const { Layout } = await Promise.resolve().then(() => require("./layout-CeBSIkmP.js"));
|
3972
4031
|
return {
|
3973
4032
|
Component: Layout
|
3974
4033
|
};
|
@@ -3985,7 +4044,7 @@ const index = {
|
|
3985
4044
|
async registerTrads({ locales }) {
|
3986
4045
|
const importedTrads = await Promise.all(
|
3987
4046
|
locales.map((locale) => {
|
3988
|
-
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => Promise.resolve().then(() => require("./ar-BUUWXIYu.js")), "./translations/ca.json": () => Promise.resolve().then(() => require("./ca-Cmk45QO6.js")), "./translations/cs.json": () => Promise.resolve().then(() => require("./cs-CkJy6B2v.js")), "./translations/de.json": () => Promise.resolve().then(() => require("./de-CCEmbAah.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-
|
4047
|
+
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 }) => {
|
3989
4048
|
return {
|
3990
4049
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
3991
4050
|
locale
|
@@ -4031,6 +4090,7 @@ exports.getMainField = getMainField;
|
|
4031
4090
|
exports.getTranslation = getTranslation;
|
4032
4091
|
exports.index = index;
|
4033
4092
|
exports.setInitialData = setInitialData;
|
4093
|
+
exports.useContentManagerContext = useContentManagerContext;
|
4034
4094
|
exports.useContentTypeSchema = useContentTypeSchema;
|
4035
4095
|
exports.useDoc = useDoc;
|
4036
4096
|
exports.useDocLayout = useDocLayout;
|
@@ -4043,4 +4103,4 @@ exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
|
|
4043
4103
|
exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
|
4044
4104
|
exports.useGetInitialDataQuery = useGetInitialDataQuery;
|
4045
4105
|
exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
|
4046
|
-
//# sourceMappingURL=index-
|
4106
|
+
//# sourceMappingURL=index-DbT2sx-Q.js.map
|