@strapi/content-manager 0.0.0-experimental.17b4116f461a49b8ce5386f7c8d79c511d40fb3b → 0.0.0-experimental.19d775295eb622de3e659110caf22fcd2cd5d10d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +18 -3
- package/dist/_chunks/{CardDragPreview-DSVYodBX.js → CardDragPreview-C0QyJgRA.js} +10 -14
- package/dist/_chunks/CardDragPreview-C0QyJgRA.js.map +1 -0
- package/dist/_chunks/{CardDragPreview-ikSG4M46.mjs → CardDragPreview-DOxamsuj.mjs} +7 -9
- package/dist/_chunks/CardDragPreview-DOxamsuj.mjs.map +1 -0
- package/dist/_chunks/{ComponentConfigurationPage-DjQBdcKF.mjs → ComponentConfigurationPage-B_99pmC0.mjs} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-DjQBdcKF.mjs.map → ComponentConfigurationPage-B_99pmC0.mjs.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-2iOVVhqV.js → ComponentConfigurationPage-NeMPjY5M.js} +5 -6
- package/dist/_chunks/{ComponentConfigurationPage-2iOVVhqV.js.map → ComponentConfigurationPage-NeMPjY5M.js.map} +1 -1
- package/dist/_chunks/{ComponentIcon-BBQsYCVn.js → ComponentIcon-CRbtQEUV.js} +9 -4
- package/dist/_chunks/ComponentIcon-CRbtQEUV.js.map +1 -0
- package/dist/_chunks/{ComponentIcon-BOFnK76n.mjs → ComponentIcon-u4bIXTFY.mjs} +9 -3
- package/dist/_chunks/ComponentIcon-u4bIXTFY.mjs.map +1 -0
- package/dist/_chunks/{EditConfigurationPage-BoBb-DLH.mjs → EditConfigurationPage-B0kNlNoj.mjs} +4 -4
- package/dist/_chunks/{EditConfigurationPage-BoBb-DLH.mjs.map → EditConfigurationPage-B0kNlNoj.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-B7dw5_cS.js → EditConfigurationPage-n7_xHayb.js} +5 -6
- package/dist/_chunks/{EditConfigurationPage-B7dw5_cS.js.map → EditConfigurationPage-n7_xHayb.js.map} +1 -1
- package/dist/_chunks/EditViewPage-BT7Achc-.js +209 -0
- package/dist/_chunks/EditViewPage-BT7Achc-.js.map +1 -0
- package/dist/_chunks/EditViewPage-DYXZs4_2.mjs +191 -0
- package/dist/_chunks/EditViewPage-DYXZs4_2.mjs.map +1 -0
- package/dist/_chunks/FieldTypeIcon-CMlNO8PE.mjs.map +1 -1
- package/dist/_chunks/FieldTypeIcon-Dnwq_IRF.js.map +1 -1
- package/dist/_chunks/{Form-CQ67ZifP.js → Form-BRmk2Dp3.js} +68 -49
- package/dist/_chunks/Form-BRmk2Dp3.js.map +1 -0
- package/dist/_chunks/{Form-Jgh5hGTu.mjs → Form-D3paRF1F.mjs} +67 -46
- package/dist/_chunks/Form-D3paRF1F.mjs.map +1 -0
- package/dist/_chunks/{History-BLEnudTX.js → History-BQpDoOu8.js} +211 -148
- package/dist/_chunks/History-BQpDoOu8.js.map +1 -0
- package/dist/_chunks/{History-DKhZAPcK.mjs → History-CzQbTOwa.mjs} +204 -139
- package/dist/_chunks/History-CzQbTOwa.mjs.map +1 -0
- package/dist/_chunks/{Field-kVFO4ZKB.mjs → Input-ww3KFYZr.mjs} +1996 -1730
- package/dist/_chunks/Input-ww3KFYZr.mjs.map +1 -0
- package/dist/_chunks/{Field-kq1c2TF1.js → Input-yM6HnyQa.js} +2035 -1770
- package/dist/_chunks/Input-yM6HnyQa.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-Zso_LUjn.js → ListConfigurationPage-B6NsS-0m.js} +72 -63
- package/dist/_chunks/ListConfigurationPage-B6NsS-0m.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-nrXcxNYi.mjs → ListConfigurationPage-Bbw8w5cS.mjs} +68 -57
- package/dist/_chunks/ListConfigurationPage-Bbw8w5cS.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-ChhYmA-L.mjs → ListViewPage-DnOP55pM.mjs} +179 -160
- package/dist/_chunks/ListViewPage-DnOP55pM.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-DsaOakWQ.js → ListViewPage-Dt8OUTwO.js} +183 -165
- package/dist/_chunks/ListViewPage-Dt8OUTwO.js.map +1 -0
- package/dist/_chunks/{NoContentTypePage-BrdFcN33.mjs → NoContentTypePage-CXKXHNMa.mjs} +3 -3
- package/dist/_chunks/NoContentTypePage-CXKXHNMa.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-DPCuS9Y1.js → NoContentTypePage-Dgm-uj-6.js} +3 -3
- package/dist/_chunks/NoContentTypePage-Dgm-uj-6.js.map +1 -0
- package/dist/_chunks/{NoPermissionsPage-DdyOfdKb.js → NoPermissionsPage-CLbU5SOt.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-DdyOfdKb.js.map → NoPermissionsPage-CLbU5SOt.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-B9dqrtTy.mjs → NoPermissionsPage-kaj1rPiW.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-B9dqrtTy.mjs.map → NoPermissionsPage-kaj1rPiW.mjs.map} +1 -1
- package/dist/_chunks/Preview-Bieh13Ro.mjs +287 -0
- package/dist/_chunks/Preview-Bieh13Ro.mjs.map +1 -0
- package/dist/_chunks/Preview-CbXHXqBg.js +305 -0
- package/dist/_chunks/Preview-CbXHXqBg.js.map +1 -0
- package/dist/_chunks/{Relations-DjFiYd7-.mjs → Relations-7rWJcZ3_.mjs} +138 -94
- package/dist/_chunks/Relations-7rWJcZ3_.mjs.map +1 -0
- package/dist/_chunks/{Relations-CY8Isqdu.js → Relations-CvifV6Y6.js} +142 -100
- package/dist/_chunks/Relations-CvifV6Y6.js.map +1 -0
- package/dist/_chunks/{en-C-V1_90f.js → en-BR48D_RH.js} +45 -18
- package/dist/_chunks/{en-C-V1_90f.js.map → en-BR48D_RH.js.map} +1 -1
- package/dist/_chunks/{en-MBPul9Su.mjs → en-D65uIF6Y.mjs} +45 -18
- package/dist/_chunks/{en-MBPul9Su.mjs.map → en-D65uIF6Y.mjs.map} +1 -1
- package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
- package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
- package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
- package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
- package/dist/_chunks/{fr-B7kGGg3E.js → fr-C43IbhA_.js} +16 -3
- package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-C43IbhA_.js.map} +1 -1
- package/dist/_chunks/{fr-CD9VFbPM.mjs → fr-DBseuRuB.mjs} +16 -3
- package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr-DBseuRuB.mjs.map} +1 -1
- package/dist/_chunks/hooks-BAaaKPS_.js.map +1 -1
- package/dist/_chunks/{index-CAc9yTnx.mjs → index-BH2JnYpF.mjs} +2302 -995
- package/dist/_chunks/index-BH2JnYpF.mjs.map +1 -0
- package/dist/_chunks/{index-DNa1J4HE.js → index-DkJQjlak.js} +2273 -967
- package/dist/_chunks/index-DkJQjlak.js.map +1 -0
- package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
- package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
- package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
- package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
- package/dist/_chunks/{layout-BqtLA6Lb.js → layout-4BqLFW_b.js} +47 -32
- package/dist/_chunks/layout-4BqLFW_b.js.map +1 -0
- package/dist/_chunks/{layout-CXsHbc3E.mjs → layout-bbOlPwLA.mjs} +46 -28
- package/dist/_chunks/layout-bbOlPwLA.mjs.map +1 -0
- 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-mMFEcZRq.mjs → relations-HsflnFpO.mjs} +6 -7
- package/dist/_chunks/relations-HsflnFpO.mjs.map +1 -0
- package/dist/_chunks/{relations-BHY_KDJ_.js → relations-Yc0Z6A20.js} +6 -7
- package/dist/_chunks/relations-Yc0Z6A20.js.map +1 -0
- package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js → useDragAndDrop-BMtgCYzL.js} +5 -9
- package/dist/_chunks/useDragAndDrop-BMtgCYzL.js.map +1 -0
- package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs → useDragAndDrop-DJ6jqvZN.mjs} +4 -7
- package/dist/_chunks/useDragAndDrop-DJ6jqvZN.mjs.map +1 -0
- package/dist/_chunks/usePrev-CZGy2Vjf.mjs +29 -0
- package/dist/_chunks/usePrev-CZGy2Vjf.mjs.map +1 -0
- package/dist/_chunks/usePrev-D5J_2fEu.js +28 -0
- package/dist/_chunks/usePrev-D5J_2fEu.js.map +1 -0
- package/dist/admin/index.js +4 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +10 -7
- package/dist/admin/src/components/ComponentIcon.d.ts +6 -3
- package/dist/admin/src/content-manager.d.ts +7 -5
- package/dist/admin/src/exports.d.ts +3 -1
- package/dist/admin/src/history/components/VersionInputRenderer.d.ts +1 -1
- package/dist/admin/src/history/index.d.ts +3 -0
- package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
- package/dist/admin/src/hooks/useDocument.d.ts +54 -9
- package/dist/admin/src/hooks/useDocumentActions.d.ts +24 -3
- package/dist/admin/src/hooks/useDocumentLayout.d.ts +2 -2
- package/dist/admin/src/hooks/useDragAndDrop.d.ts +4 -4
- package/dist/admin/src/hooks/useKeyboardDragAndDrop.d.ts +1 -1
- package/dist/admin/src/index.d.ts +1 -0
- package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
- package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +12 -5
- package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +3 -3
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.d.ts +7 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/utils/prismLanguages.d.ts +49 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.d.ts +3 -3
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +5 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/Component/Input.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.d.ts +3 -5
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.d.ts +4 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +4 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +30 -18
- package/dist/admin/src/pages/EditView/components/FormInputs/UID.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +3 -49
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/Field.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 +16 -53
- package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +27 -0
- package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
- package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +2 -10
- package/dist/admin/src/pages/EditView/utils/data.d.ts +1 -0
- package/dist/admin/src/pages/ListView/components/BulkActions/Actions.d.ts +3 -30
- package/dist/admin/src/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.d.ts +2 -2
- package/dist/admin/src/pages/ListView/components/BulkActions/PublishAction.d.ts +9 -26
- package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
- package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
- package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
- package/dist/admin/src/preview/index.d.ts +4 -0
- package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
- package/dist/admin/src/preview/routes.d.ts +3 -0
- package/dist/admin/src/preview/services/preview.d.ts +3 -0
- package/dist/admin/src/router.d.ts +1 -1
- package/dist/admin/src/services/api.d.ts +2 -3
- package/dist/admin/src/services/components.d.ts +2 -2
- package/dist/admin/src/services/contentTypes.d.ts +5 -5
- package/dist/admin/src/services/documents.d.ts +31 -20
- package/dist/admin/src/services/init.d.ts +2 -2
- package/dist/admin/src/services/relations.d.ts +3 -3
- package/dist/admin/src/services/uid.d.ts +3 -3
- package/dist/admin/src/utils/api.d.ts +4 -18
- package/dist/admin/src/utils/validation.d.ts +5 -7
- package/dist/server/index.js +959 -543
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +960 -543
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/bootstrap.d.ts.map +1 -1
- package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
- package/dist/server/src/controllers/index.d.ts.map +1 -1
- package/dist/server/src/controllers/relations.d.ts.map +1 -1
- package/dist/server/src/controllers/single-types.d.ts.map +1 -1
- package/dist/server/src/controllers/uid.d.ts.map +1 -1
- package/dist/server/src/controllers/utils/metadata.d.ts +23 -0
- package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -0
- package/dist/server/src/controllers/validation/dimensions.d.ts +11 -0
- package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -0
- package/dist/server/src/controllers/validation/index.d.ts +1 -1
- package/dist/server/src/history/controllers/history-version.d.ts +1 -1
- package/dist/server/src/history/controllers/history-version.d.ts.map +1 -1
- package/dist/server/src/history/services/history.d.ts +3 -3
- 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 +8 -12
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +21 -36
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
- package/dist/server/src/preview/controllers/index.d.ts +2 -0
- package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/preview.d.ts +13 -0
- package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
- package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
- package/dist/server/src/preview/index.d.ts +4 -0
- package/dist/server/src/preview/index.d.ts.map +1 -0
- package/dist/server/src/preview/routes/index.d.ts +8 -0
- package/dist/server/src/preview/routes/index.d.ts.map +1 -0
- package/dist/server/src/preview/routes/preview.d.ts +4 -0
- package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
- package/dist/server/src/preview/services/index.d.ts +16 -0
- package/dist/server/src/preview/services/index.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview-config.d.ts +32 -0
- package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview.d.ts +12 -0
- package/dist/server/src/preview/services/preview.d.ts.map +1 -0
- package/dist/server/src/preview/utils.d.ts +19 -0
- package/dist/server/src/preview/utils.d.ts.map +1 -0
- package/dist/server/src/register.d.ts.map +1 -1
- package/dist/server/src/routes/index.d.ts.map +1 -1
- package/dist/server/src/services/document-manager.d.ts +11 -6
- package/dist/server/src/services/document-manager.d.ts.map +1 -1
- package/dist/server/src/services/document-metadata.d.ts +16 -35
- package/dist/server/src/services/document-metadata.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +21 -36
- package/dist/server/src/services/index.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 +8 -1
- package/dist/server/src/services/utils/populate.d.ts.map +1 -1
- package/dist/server/src/utils/index.d.ts +2 -0
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/dist/shared/contracts/collection-types.d.ts +17 -7
- package/dist/shared/contracts/collection-types.d.ts.map +1 -1
- package/dist/shared/contracts/index.d.ts +1 -0
- package/dist/shared/contracts/index.d.ts.map +1 -1
- package/dist/shared/contracts/preview.d.ts +27 -0
- package/dist/shared/contracts/preview.d.ts.map +1 -0
- package/dist/shared/contracts/relations.d.ts +2 -2
- package/dist/shared/contracts/relations.d.ts.map +1 -1
- package/dist/shared/index.js +4 -0
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/index.mjs +4 -0
- package/dist/shared/index.mjs.map +1 -1
- package/package.json +22 -22
- package/dist/_chunks/CardDragPreview-DSVYodBX.js.map +0 -1
- package/dist/_chunks/CardDragPreview-ikSG4M46.mjs.map +0 -1
- package/dist/_chunks/ComponentIcon-BBQsYCVn.js.map +0 -1
- package/dist/_chunks/ComponentIcon-BOFnK76n.mjs.map +0 -1
- package/dist/_chunks/EditViewPage-KRG56aCq.js +0 -224
- package/dist/_chunks/EditViewPage-KRG56aCq.js.map +0 -1
- package/dist/_chunks/EditViewPage-aUnqL-63.mjs +0 -203
- package/dist/_chunks/EditViewPage-aUnqL-63.mjs.map +0 -1
- package/dist/_chunks/Field-kVFO4ZKB.mjs.map +0 -1
- package/dist/_chunks/Field-kq1c2TF1.js.map +0 -1
- package/dist/_chunks/Form-CQ67ZifP.js.map +0 -1
- package/dist/_chunks/Form-Jgh5hGTu.mjs.map +0 -1
- package/dist/_chunks/History-BLEnudTX.js.map +0 -1
- package/dist/_chunks/History-DKhZAPcK.mjs.map +0 -1
- package/dist/_chunks/ListConfigurationPage-Zso_LUjn.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-nrXcxNYi.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-ChhYmA-L.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-DsaOakWQ.js.map +0 -1
- package/dist/_chunks/NoContentTypePage-BrdFcN33.mjs.map +0 -1
- package/dist/_chunks/NoContentTypePage-DPCuS9Y1.js.map +0 -1
- package/dist/_chunks/Relations-CY8Isqdu.js.map +0 -1
- package/dist/_chunks/Relations-DjFiYd7-.mjs.map +0 -1
- package/dist/_chunks/index-CAc9yTnx.mjs.map +0 -1
- package/dist/_chunks/index-DNa1J4HE.js.map +0 -1
- package/dist/_chunks/layout-BqtLA6Lb.js.map +0 -1
- package/dist/_chunks/layout-CXsHbc3E.mjs.map +0 -1
- package/dist/_chunks/relations-BHY_KDJ_.js.map +0 -1
- package/dist/_chunks/relations-mMFEcZRq.mjs.map +0 -1
- package/dist/_chunks/urls-CbOsUOoW.mjs +0 -7
- package/dist/_chunks/urls-CbOsUOoW.mjs.map +0 -1
- package/dist/_chunks/urls-DzZya_gm.js +0 -6
- package/dist/_chunks/urls-DzZya_gm.js.map +0 -1
- package/dist/_chunks/useDragAndDrop-DdHgKsqq.mjs.map +0 -1
- package/dist/_chunks/useDragAndDrop-J0TUUbR6.js.map +0 -1
- package/dist/server/src/controllers/utils/dimensions.d.ts +0 -5
- package/dist/server/src/controllers/utils/dimensions.d.ts.map +0 -1
- package/strapi-server.js +0 -3
@@ -2,22 +2,21 @@
|
|
2
2
|
const Icons = require("@strapi/icons");
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
4
4
|
const strapiAdmin = require("@strapi/admin/strapi-admin");
|
5
|
-
const qs = require("qs");
|
6
|
-
const reactIntl = require("react-intl");
|
7
|
-
const reactRouterDom = require("react-router-dom");
|
8
5
|
const React = require("react");
|
9
6
|
const designSystem = require("@strapi/design-system");
|
10
|
-
const
|
7
|
+
const mapValues = require("lodash/fp/mapValues");
|
8
|
+
const reactIntl = require("react-intl");
|
9
|
+
const reactRouterDom = require("react-router-dom");
|
10
|
+
const styledComponents = require("styled-components");
|
11
11
|
const yup = require("yup");
|
12
|
-
const
|
13
|
-
const axios = require("axios");
|
12
|
+
const fractionalIndexing = require("fractional-indexing");
|
14
13
|
const pipe = require("lodash/fp/pipe");
|
14
|
+
const qs = require("qs");
|
15
15
|
const dateFns = require("date-fns");
|
16
16
|
const toolkit = require("@reduxjs/toolkit");
|
17
17
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
18
18
|
function _interopNamespace(e) {
|
19
|
-
if (e && e.__esModule)
|
20
|
-
return e;
|
19
|
+
if (e && e.__esModule) return e;
|
21
20
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
22
21
|
if (e) {
|
23
22
|
for (const k in e) {
|
@@ -34,16 +33,23 @@ function _interopNamespace(e) {
|
|
34
33
|
return Object.freeze(n);
|
35
34
|
}
|
36
35
|
const React__namespace = /* @__PURE__ */ _interopNamespace(React);
|
37
|
-
const
|
36
|
+
const mapValues__default = /* @__PURE__ */ _interopDefault(mapValues);
|
38
37
|
const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
|
39
38
|
const pipe__default = /* @__PURE__ */ _interopDefault(pipe);
|
40
|
-
const __variableDynamicImportRuntimeHelper = (glob, path) => {
|
39
|
+
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
41
40
|
const v = glob[path];
|
42
41
|
if (v) {
|
43
42
|
return typeof v === "function" ? v() : Promise.resolve(v);
|
44
43
|
}
|
45
44
|
return new Promise((_, reject) => {
|
46
|
-
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
45
|
+
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
46
|
+
reject.bind(
|
47
|
+
null,
|
48
|
+
new Error(
|
49
|
+
"Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
|
50
|
+
)
|
51
|
+
)
|
52
|
+
);
|
47
53
|
});
|
48
54
|
};
|
49
55
|
const PLUGIN_ID = "content-manager";
|
@@ -73,42 +79,6 @@ const useInjectionZone = (area) => {
|
|
73
79
|
const [page, position] = area.split(".");
|
74
80
|
return contentManagerPlugin.getInjectedComponents(page, position);
|
75
81
|
};
|
76
|
-
const HistoryAction = ({ model, document }) => {
|
77
|
-
const { formatMessage } = reactIntl.useIntl();
|
78
|
-
const [{ query }] = strapiAdmin.useQueryParams();
|
79
|
-
const navigate = reactRouterDom.useNavigate();
|
80
|
-
const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
|
81
|
-
if (!window.strapi.features.isEnabled("cms-content-history")) {
|
82
|
-
return null;
|
83
|
-
}
|
84
|
-
return {
|
85
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
|
86
|
-
label: formatMessage({
|
87
|
-
id: "content-manager.history.document-action",
|
88
|
-
defaultMessage: "Content History"
|
89
|
-
}),
|
90
|
-
onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
|
91
|
-
disabled: (
|
92
|
-
/**
|
93
|
-
* The user is creating a new document.
|
94
|
-
* It hasn't been saved yet, so there's no history to go to
|
95
|
-
*/
|
96
|
-
!document || /**
|
97
|
-
* The document has been created but the current dimension has never been saved.
|
98
|
-
* For example, the user is creating a new locale in an existing document,
|
99
|
-
* so there's no history for the document in that locale
|
100
|
-
*/
|
101
|
-
!document.id || /**
|
102
|
-
* History is only available for content types created by the user.
|
103
|
-
* These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
|
104
|
-
* which start with `admin::` or `plugin::`
|
105
|
-
*/
|
106
|
-
!model.startsWith("api::")
|
107
|
-
),
|
108
|
-
position: "header"
|
109
|
-
};
|
110
|
-
};
|
111
|
-
HistoryAction.type = "history";
|
112
82
|
const ID = "id";
|
113
83
|
const CREATED_BY_ATTRIBUTE_NAME = "createdBy";
|
114
84
|
const UPDATED_BY_ATTRIBUTE_NAME = "updatedBy";
|
@@ -160,6 +130,7 @@ const DocumentRBAC = ({ children, permissions }) => {
|
|
160
130
|
if (!slug) {
|
161
131
|
throw new Error("Cannot find the slug param in the URL");
|
162
132
|
}
|
133
|
+
const [{ rawQuery }] = strapiAdmin.useQueryParams();
|
163
134
|
const userPermissions = strapiAdmin.useAuth("DocumentRBAC", (state) => state.permissions);
|
164
135
|
const contentTypePermissions = React__namespace.useMemo(() => {
|
165
136
|
const contentTypePermissions2 = userPermissions.filter(
|
@@ -170,7 +141,14 @@ const DocumentRBAC = ({ children, permissions }) => {
|
|
170
141
|
return { ...acc, [action]: [permission] };
|
171
142
|
}, {});
|
172
143
|
}, [slug, userPermissions]);
|
173
|
-
const { isLoading, allowedActions } = strapiAdmin.useRBAC(
|
144
|
+
const { isLoading, allowedActions } = strapiAdmin.useRBAC(
|
145
|
+
contentTypePermissions,
|
146
|
+
permissions ?? void 0,
|
147
|
+
// TODO: useRBAC context should be typed and built differently
|
148
|
+
// We are passing raw query as context to the hook so that it can
|
149
|
+
// rely on the locale provided from DocumentRBAC for its permission calculations.
|
150
|
+
rawQuery
|
151
|
+
);
|
174
152
|
const canCreateFields = !isLoading && allowedActions.canCreate ? extractAndDedupeFields(contentTypePermissions.create) : [];
|
175
153
|
const canReadFields = !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];
|
176
154
|
const canUpdateFields = !isLoading && allowedActions.canUpdate ? extractAndDedupeFields(contentTypePermissions.update) : [];
|
@@ -179,9 +157,8 @@ const DocumentRBAC = ({ children, permissions }) => {
|
|
179
157
|
const name = removeNumericalStrings(fieldName.split("."));
|
180
158
|
const componentFieldNames = fieldsUserCanAction.filter((field) => field.split(".").length > 1);
|
181
159
|
if (fieldType === "component") {
|
182
|
-
|
183
|
-
|
184
|
-
return field.includes(fieldName);
|
160
|
+
return componentFieldNames.some((field) => {
|
161
|
+
return field.includes(name.join("."));
|
185
162
|
});
|
186
163
|
}
|
187
164
|
if (name.length > 1) {
|
@@ -211,89 +188,128 @@ const extractAndDedupeFields = (permissions = []) => permissions.flatMap((permis
|
|
211
188
|
(field, index2, arr) => arr.indexOf(field) === index2 && typeof field === "string"
|
212
189
|
);
|
213
190
|
const removeNumericalStrings = (arr) => arr.filter((item) => isNaN(Number(item)));
|
214
|
-
const
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
}
|
241
|
-
if (method === "DELETE") {
|
242
|
-
const result2 = await del(url, { ...config, signal });
|
243
|
-
return { data: result2.data };
|
244
|
-
}
|
245
|
-
if (method === "PUT") {
|
246
|
-
const result2 = await put(url, data, { ...config, signal });
|
247
|
-
return { data: result2.data };
|
248
|
-
}
|
249
|
-
const result = await get(url, { ...config, signal });
|
250
|
-
return { data: result.data };
|
251
|
-
}
|
252
|
-
} catch (err) {
|
253
|
-
if (axios.isAxiosError(err)) {
|
254
|
-
if (typeof err.response?.data === "object" && err.response?.data !== null && "error" in err.response?.data) {
|
255
|
-
return { data: void 0, error: err.response?.data.error };
|
191
|
+
const BLOCK_LIST_ATTRIBUTE_KEYS = ["__component", "__temp_key__"];
|
192
|
+
const traverseData = (predicate, transform) => (schema, components = {}) => (data = {}) => {
|
193
|
+
const traverse = (datum, attributes) => {
|
194
|
+
return Object.entries(datum).reduce((acc, [key, value]) => {
|
195
|
+
const attribute = attributes[key];
|
196
|
+
if (BLOCK_LIST_ATTRIBUTE_KEYS.includes(key) || value === null || value === void 0) {
|
197
|
+
acc[key] = value;
|
198
|
+
return acc;
|
199
|
+
}
|
200
|
+
if (attribute.type === "component") {
|
201
|
+
if (attribute.repeatable) {
|
202
|
+
const componentValue = predicate(attribute, value) ? transform(value, attribute) : value;
|
203
|
+
acc[key] = componentValue.map(
|
204
|
+
(componentData) => traverse(componentData, components[attribute.component]?.attributes ?? {})
|
205
|
+
);
|
206
|
+
} else {
|
207
|
+
const componentValue = predicate(attribute, value) ? transform(value, attribute) : value;
|
208
|
+
acc[key] = traverse(componentValue, components[attribute.component]?.attributes ?? {});
|
209
|
+
}
|
210
|
+
} else if (attribute.type === "dynamiczone") {
|
211
|
+
const dynamicZoneValue = predicate(attribute, value) ? transform(value, attribute) : value;
|
212
|
+
acc[key] = dynamicZoneValue.map(
|
213
|
+
(componentData) => traverse(componentData, components[componentData.__component]?.attributes ?? {})
|
214
|
+
);
|
215
|
+
} else if (predicate(attribute, value)) {
|
216
|
+
acc[key] = transform(value, attribute);
|
256
217
|
} else {
|
257
|
-
|
258
|
-
data: void 0,
|
259
|
-
error: {
|
260
|
-
name: "UnknownError",
|
261
|
-
message: "There was an unknown error response from the API",
|
262
|
-
details: err.response?.data,
|
263
|
-
status: err.response?.status
|
264
|
-
}
|
265
|
-
};
|
218
|
+
acc[key] = value;
|
266
219
|
}
|
220
|
+
return acc;
|
221
|
+
}, {});
|
222
|
+
};
|
223
|
+
return traverse(data, schema.attributes);
|
224
|
+
};
|
225
|
+
const removeProhibitedFields = (prohibitedFields) => traverseData(
|
226
|
+
(attribute) => prohibitedFields.includes(attribute.type),
|
227
|
+
() => ""
|
228
|
+
);
|
229
|
+
const prepareRelations = traverseData(
|
230
|
+
(attribute) => attribute.type === "relation",
|
231
|
+
() => ({
|
232
|
+
connect: [],
|
233
|
+
disconnect: []
|
234
|
+
})
|
235
|
+
);
|
236
|
+
const prepareTempKeys = traverseData(
|
237
|
+
(attribute) => attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone",
|
238
|
+
(data) => {
|
239
|
+
if (Array.isArray(data) && data.length > 0) {
|
240
|
+
const keys = fractionalIndexing.generateNKeysBetween(void 0, void 0, data.length);
|
241
|
+
return data.map((datum, index2) => ({
|
242
|
+
...datum,
|
243
|
+
__temp_key__: keys[index2]
|
244
|
+
}));
|
267
245
|
}
|
268
|
-
|
269
|
-
return {
|
270
|
-
data: void 0,
|
271
|
-
error: {
|
272
|
-
name: error.name,
|
273
|
-
message: error.message,
|
274
|
-
stack: error.stack
|
275
|
-
}
|
276
|
-
};
|
246
|
+
return data;
|
277
247
|
}
|
248
|
+
);
|
249
|
+
const removeFieldsThatDontExistOnSchema = (schema) => (data) => {
|
250
|
+
const schemaKeys = Object.keys(schema.attributes);
|
251
|
+
const dataKeys = Object.keys(data);
|
252
|
+
const keysToRemove = dataKeys.filter((key) => !schemaKeys.includes(key));
|
253
|
+
const revisedData = [...keysToRemove, ...DOCUMENT_META_FIELDS].reduce((acc, key) => {
|
254
|
+
delete acc[key];
|
255
|
+
return acc;
|
256
|
+
}, structuredClone(data));
|
257
|
+
return revisedData;
|
278
258
|
};
|
279
|
-
const
|
280
|
-
return
|
259
|
+
const removeNullValues = (data) => {
|
260
|
+
return Object.entries(data).reduce((acc, [key, value]) => {
|
261
|
+
if (value === null) {
|
262
|
+
return acc;
|
263
|
+
}
|
264
|
+
acc[key] = value;
|
265
|
+
return acc;
|
266
|
+
}, {});
|
267
|
+
};
|
268
|
+
const transformDocument = (schema, components = {}) => (document) => {
|
269
|
+
const transformations = pipe__default.default(
|
270
|
+
removeFieldsThatDontExistOnSchema(schema),
|
271
|
+
removeProhibitedFields(["password"])(schema, components),
|
272
|
+
removeNullValues,
|
273
|
+
prepareRelations(schema, components),
|
274
|
+
prepareTempKeys(schema, components)
|
275
|
+
);
|
276
|
+
return transformations(document);
|
281
277
|
};
|
282
|
-
const
|
283
|
-
|
284
|
-
|
285
|
-
|
278
|
+
const createDefaultForm = (contentType, components = {}) => {
|
279
|
+
const traverseSchema = (attributes) => {
|
280
|
+
return Object.entries(attributes).reduce((acc, [key, attribute]) => {
|
281
|
+
if ("default" in attribute) {
|
282
|
+
acc[key] = attribute.default;
|
283
|
+
} else if (attribute.type === "component" && attribute.required) {
|
284
|
+
const defaultComponentForm = traverseSchema(components[attribute.component].attributes);
|
285
|
+
if (attribute.repeatable) {
|
286
|
+
acc[key] = attribute.min ? [...Array(attribute.min).fill(defaultComponentForm)] : [];
|
287
|
+
} else {
|
288
|
+
acc[key] = defaultComponentForm;
|
289
|
+
}
|
290
|
+
} else if (attribute.type === "dynamiczone" && attribute.required) {
|
291
|
+
acc[key] = [];
|
292
|
+
}
|
293
|
+
return acc;
|
294
|
+
}, {});
|
295
|
+
};
|
296
|
+
return traverseSchema(contentType.attributes);
|
297
|
+
};
|
298
|
+
const contentManagerApi = strapiAdmin.adminApi.enhanceEndpoints({
|
299
|
+
addTagTypes: [
|
286
300
|
"ComponentConfiguration",
|
287
301
|
"ContentTypesConfiguration",
|
288
302
|
"ContentTypeSettings",
|
289
303
|
"Document",
|
290
304
|
"InitialData",
|
291
305
|
"HistoryVersion",
|
292
|
-
"Relations"
|
293
|
-
|
294
|
-
|
306
|
+
"Relations",
|
307
|
+
"UidAvailability",
|
308
|
+
"RecentDocumentList"
|
309
|
+
]
|
295
310
|
});
|
296
311
|
const documentApi = contentManagerApi.injectEndpoints({
|
312
|
+
overrideExisting: true,
|
297
313
|
endpoints: (builder) => ({
|
298
314
|
autoCloneDocument: builder.mutation({
|
299
315
|
query: ({ model, sourceId, query }) => ({
|
@@ -303,7 +319,12 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
303
319
|
params: query
|
304
320
|
}
|
305
321
|
}),
|
306
|
-
invalidatesTags: (_result,
|
322
|
+
invalidatesTags: (_result, error, { model }) => {
|
323
|
+
if (error) {
|
324
|
+
return [];
|
325
|
+
}
|
326
|
+
return [{ type: "Document", id: `${model}_LIST` }, "RecentDocumentList"];
|
327
|
+
}
|
307
328
|
}),
|
308
329
|
cloneDocument: builder.mutation({
|
309
330
|
query: ({ model, sourceId, data, params }) => ({
|
@@ -314,7 +335,11 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
314
335
|
params
|
315
336
|
}
|
316
337
|
}),
|
317
|
-
invalidatesTags: (_result, _error, { model }) => [
|
338
|
+
invalidatesTags: (_result, _error, { model }) => [
|
339
|
+
{ type: "Document", id: `${model}_LIST` },
|
340
|
+
{ type: "UidAvailability", id: model },
|
341
|
+
"RecentDocumentList"
|
342
|
+
]
|
318
343
|
}),
|
319
344
|
/**
|
320
345
|
* Creates a new collection-type document. This should ONLY be used for collection-types.
|
@@ -331,8 +356,22 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
331
356
|
}),
|
332
357
|
invalidatesTags: (result, _error, { model }) => [
|
333
358
|
{ type: "Document", id: `${model}_LIST` },
|
334
|
-
"Relations"
|
335
|
-
|
359
|
+
"Relations",
|
360
|
+
{ type: "UidAvailability", id: model },
|
361
|
+
"RecentDocumentList"
|
362
|
+
],
|
363
|
+
transformResponse: (response, meta, arg) => {
|
364
|
+
if (!("data" in response) && arg.model === "plugin::users-permissions.user") {
|
365
|
+
return {
|
366
|
+
data: response,
|
367
|
+
meta: {
|
368
|
+
availableStatus: [],
|
369
|
+
availableLocales: []
|
370
|
+
}
|
371
|
+
};
|
372
|
+
}
|
373
|
+
return response;
|
374
|
+
}
|
336
375
|
}),
|
337
376
|
deleteDocument: builder.mutation({
|
338
377
|
query: ({ collectionType, model, documentId, params }) => ({
|
@@ -343,16 +382,23 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
343
382
|
}
|
344
383
|
}),
|
345
384
|
invalidatesTags: (_result, _error, { collectionType, model }) => [
|
346
|
-
{ type: "Document", id: collectionType !== SINGLE_TYPES ? `${model}_LIST` : model }
|
385
|
+
{ type: "Document", id: collectionType !== SINGLE_TYPES ? `${model}_LIST` : model },
|
386
|
+
"RecentDocumentList"
|
347
387
|
]
|
348
388
|
}),
|
349
389
|
deleteManyDocuments: builder.mutation({
|
350
|
-
query: ({ model, ...body }) => ({
|
390
|
+
query: ({ model, params, ...body }) => ({
|
351
391
|
url: `/content-manager/collection-types/${model}/actions/bulkDelete`,
|
352
392
|
method: "POST",
|
353
|
-
data: body
|
393
|
+
data: body,
|
394
|
+
config: {
|
395
|
+
params
|
396
|
+
}
|
354
397
|
}),
|
355
|
-
invalidatesTags: (_res, _error, { model
|
398
|
+
invalidatesTags: (_res, _error, { model }) => [
|
399
|
+
{ type: "Document", id: `${model}_LIST` },
|
400
|
+
"RecentDocumentList"
|
401
|
+
]
|
356
402
|
}),
|
357
403
|
discardDocument: builder.mutation({
|
358
404
|
query: ({ collectionType, model, documentId, params }) => ({
|
@@ -369,7 +415,9 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
369
415
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
370
416
|
},
|
371
417
|
{ type: "Document", id: `${model}_LIST` },
|
372
|
-
"Relations"
|
418
|
+
"Relations",
|
419
|
+
{ type: "UidAvailability", id: model },
|
420
|
+
"RecentDocumentList"
|
373
421
|
];
|
374
422
|
}
|
375
423
|
}),
|
@@ -382,11 +430,12 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
382
430
|
url: `/content-manager/collection-types/${model}`,
|
383
431
|
method: "GET",
|
384
432
|
config: {
|
385
|
-
params
|
433
|
+
params: qs.stringify(params, { encode: true })
|
386
434
|
}
|
387
435
|
}),
|
388
436
|
providesTags: (result, _error, arg) => {
|
389
437
|
return [
|
438
|
+
{ type: "Document", id: `ALL_LIST` },
|
390
439
|
{ type: "Document", id: `${arg.model}_LIST` },
|
391
440
|
...result?.results.map(({ documentId }) => ({
|
392
441
|
type: "Document",
|
@@ -425,6 +474,11 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
425
474
|
{
|
426
475
|
type: "Document",
|
427
476
|
id: collectionType !== SINGLE_TYPES ? `${model}_${result && "documentId" in result ? result.documentId : documentId}` : model
|
477
|
+
},
|
478
|
+
// Make it easy to invalidate all individual documents queries for a model
|
479
|
+
{
|
480
|
+
type: "Document",
|
481
|
+
id: `${model}_ALL_ITEMS`
|
428
482
|
}
|
429
483
|
];
|
430
484
|
}
|
@@ -458,15 +512,19 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
458
512
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
459
513
|
},
|
460
514
|
{ type: "Document", id: `${model}_LIST` },
|
461
|
-
"Relations"
|
515
|
+
"Relations",
|
516
|
+
"RecentDocumentList"
|
462
517
|
];
|
463
518
|
}
|
464
519
|
}),
|
465
520
|
publishManyDocuments: builder.mutation({
|
466
|
-
query: ({ model, ...body }) => ({
|
521
|
+
query: ({ model, params, ...body }) => ({
|
467
522
|
url: `/content-manager/collection-types/${model}/actions/bulkPublish`,
|
468
523
|
method: "POST",
|
469
|
-
data: body
|
524
|
+
data: body,
|
525
|
+
config: {
|
526
|
+
params
|
527
|
+
}
|
470
528
|
}),
|
471
529
|
invalidatesTags: (_res, _error, { model, documentIds }) => documentIds.map((id) => ({ type: "Document", id: `${model}_${id}` }))
|
472
530
|
}),
|
@@ -485,8 +543,23 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
485
543
|
type: "Document",
|
486
544
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
487
545
|
},
|
488
|
-
"Relations"
|
546
|
+
"Relations",
|
547
|
+
{ type: "UidAvailability", id: model },
|
548
|
+
"RecentDocumentList",
|
549
|
+
"RecentDocumentList"
|
489
550
|
];
|
551
|
+
},
|
552
|
+
async onQueryStarted({ data, ...patch }, { dispatch, queryFulfilled }) {
|
553
|
+
const patchResult = dispatch(
|
554
|
+
documentApi.util.updateQueryData("getDocument", patch, (draft) => {
|
555
|
+
Object.assign(draft.data, data);
|
556
|
+
})
|
557
|
+
);
|
558
|
+
try {
|
559
|
+
await queryFulfilled;
|
560
|
+
} catch {
|
561
|
+
patchResult.undo();
|
562
|
+
}
|
490
563
|
}
|
491
564
|
}),
|
492
565
|
unpublishDocument: builder.mutation({
|
@@ -503,17 +576,24 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
503
576
|
{
|
504
577
|
type: "Document",
|
505
578
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
506
|
-
}
|
579
|
+
},
|
580
|
+
"RecentDocumentList"
|
507
581
|
];
|
508
582
|
}
|
509
583
|
}),
|
510
584
|
unpublishManyDocuments: builder.mutation({
|
511
|
-
query: ({ model, ...body }) => ({
|
585
|
+
query: ({ model, params, ...body }) => ({
|
512
586
|
url: `/content-manager/collection-types/${model}/actions/bulkUnpublish`,
|
513
587
|
method: "POST",
|
514
|
-
data: body
|
588
|
+
data: body,
|
589
|
+
config: {
|
590
|
+
params
|
591
|
+
}
|
515
592
|
}),
|
516
|
-
invalidatesTags: (_res, _error, { model, documentIds }) =>
|
593
|
+
invalidatesTags: (_res, _error, { model, documentIds }) => [
|
594
|
+
...documentIds.map((id) => ({ type: "Document", id: `${model}_${id}` })),
|
595
|
+
"RecentDocumentList"
|
596
|
+
]
|
517
597
|
})
|
518
598
|
})
|
519
599
|
});
|
@@ -535,20 +615,53 @@ const {
|
|
535
615
|
useUnpublishDocumentMutation,
|
536
616
|
useUnpublishManyDocumentsMutation
|
537
617
|
} = documentApi;
|
538
|
-
const
|
618
|
+
const buildValidParams = (query) => {
|
619
|
+
if (!query) return query;
|
620
|
+
const { plugins: _, ...validQueryParams } = {
|
621
|
+
...query,
|
622
|
+
...Object.values(query?.plugins ?? {}).reduce(
|
623
|
+
(acc, current) => Object.assign(acc, current),
|
624
|
+
{}
|
625
|
+
)
|
626
|
+
};
|
627
|
+
return validQueryParams;
|
628
|
+
};
|
629
|
+
const isBaseQueryError = (error) => {
|
630
|
+
return error.name !== void 0;
|
631
|
+
};
|
632
|
+
const arrayValidator = (attribute, options) => ({
|
633
|
+
message: strapiAdmin.translatedErrors.required,
|
634
|
+
test(value) {
|
635
|
+
if (options.status === "draft") {
|
636
|
+
return true;
|
637
|
+
}
|
638
|
+
if (!attribute.required) {
|
639
|
+
return true;
|
640
|
+
}
|
641
|
+
if (!value) {
|
642
|
+
return false;
|
643
|
+
}
|
644
|
+
if (Array.isArray(value) && value.length === 0) {
|
645
|
+
return false;
|
646
|
+
}
|
647
|
+
return true;
|
648
|
+
}
|
649
|
+
});
|
650
|
+
const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
|
539
651
|
const createModelSchema = (attributes2) => yup__namespace.object().shape(
|
540
652
|
Object.entries(attributes2).reduce((acc, [name, attribute]) => {
|
541
653
|
if (DOCUMENT_META_FIELDS.includes(name)) {
|
542
654
|
return acc;
|
543
655
|
}
|
544
656
|
const validations = [
|
657
|
+
addNullableValidation,
|
545
658
|
addRequiredValidation,
|
546
659
|
addMinLengthValidation,
|
547
660
|
addMaxLengthValidation,
|
548
661
|
addMinValidation,
|
549
662
|
addMaxValidation,
|
550
663
|
addRegexValidation
|
551
|
-
].map((fn) => fn(attribute));
|
664
|
+
].map((fn) => fn(attribute, options));
|
552
665
|
const transformSchema = pipe__default.default(...validations);
|
553
666
|
switch (attribute.type) {
|
554
667
|
case "component": {
|
@@ -558,12 +671,12 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
558
671
|
...acc,
|
559
672
|
[name]: transformSchema(
|
560
673
|
yup__namespace.array().of(createModelSchema(attributes3).nullable(false))
|
561
|
-
)
|
674
|
+
).test(arrayValidator(attribute, options))
|
562
675
|
};
|
563
676
|
} else {
|
564
677
|
return {
|
565
678
|
...acc,
|
566
|
-
[name]: transformSchema(createModelSchema(attributes3))
|
679
|
+
[name]: transformSchema(createModelSchema(attributes3).nullable())
|
567
680
|
};
|
568
681
|
}
|
569
682
|
}
|
@@ -574,24 +687,42 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
574
687
|
yup__namespace.array().of(
|
575
688
|
yup__namespace.lazy(
|
576
689
|
(data) => {
|
577
|
-
const
|
578
|
-
|
690
|
+
const attributes3 = components?.[data?.__component]?.attributes;
|
691
|
+
const validation = yup__namespace.object().shape({
|
579
692
|
__component: yup__namespace.string().required().oneOf(Object.keys(components))
|
580
|
-
}).nullable(false)
|
693
|
+
}).nullable(false);
|
694
|
+
if (!attributes3) {
|
695
|
+
return validation;
|
696
|
+
}
|
697
|
+
return validation.concat(createModelSchema(attributes3));
|
581
698
|
}
|
582
699
|
)
|
583
700
|
)
|
584
|
-
)
|
701
|
+
).test(arrayValidator(attribute, options))
|
585
702
|
};
|
586
703
|
case "relation":
|
587
704
|
return {
|
588
705
|
...acc,
|
589
706
|
[name]: transformSchema(
|
590
|
-
yup__namespace.
|
591
|
-
|
592
|
-
|
593
|
-
})
|
594
|
-
|
707
|
+
yup__namespace.lazy((value) => {
|
708
|
+
if (!value) {
|
709
|
+
return yup__namespace.mixed().nullable(true);
|
710
|
+
} else if (Array.isArray(value)) {
|
711
|
+
return yup__namespace.array().of(
|
712
|
+
yup__namespace.object().shape({
|
713
|
+
id: yup__namespace.number().required()
|
714
|
+
})
|
715
|
+
);
|
716
|
+
} else if (typeof value === "object") {
|
717
|
+
return yup__namespace.object();
|
718
|
+
} else {
|
719
|
+
return yup__namespace.mixed().test(
|
720
|
+
"type-error",
|
721
|
+
"Relation values must be either null, an array of objects with {id} or an object.",
|
722
|
+
() => false
|
723
|
+
);
|
724
|
+
}
|
725
|
+
})
|
595
726
|
)
|
596
727
|
};
|
597
728
|
default:
|
@@ -631,6 +762,14 @@ const createAttributeSchema = (attribute) => {
|
|
631
762
|
if (!value || typeof value === "string" && value.length === 0) {
|
632
763
|
return true;
|
633
764
|
}
|
765
|
+
if (typeof value === "object") {
|
766
|
+
try {
|
767
|
+
JSON.stringify(value);
|
768
|
+
return true;
|
769
|
+
} catch (err) {
|
770
|
+
return false;
|
771
|
+
}
|
772
|
+
}
|
634
773
|
try {
|
635
774
|
JSON.parse(value);
|
636
775
|
return true;
|
@@ -649,16 +788,30 @@ const createAttributeSchema = (attribute) => {
|
|
649
788
|
return yup__namespace.mixed();
|
650
789
|
}
|
651
790
|
};
|
652
|
-
const
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
791
|
+
const nullableSchema = (schema) => {
|
792
|
+
return schema?.nullable ? schema.nullable() : (
|
793
|
+
// In some cases '.nullable' will not be available on the schema.
|
794
|
+
// e.g. when the schema has been built using yup.lazy (e.g. for relations).
|
795
|
+
// In these cases we should just return the schema as it is.
|
796
|
+
schema
|
797
|
+
);
|
798
|
+
};
|
799
|
+
const addNullableValidation = () => (schema) => {
|
800
|
+
return nullableSchema(schema);
|
801
|
+
};
|
802
|
+
const addRequiredValidation = (attribute, options) => (schema) => {
|
803
|
+
if (options.status === "draft" || !attribute.required) {
|
804
|
+
return schema;
|
658
805
|
}
|
659
|
-
|
806
|
+
if (attribute.required && "required" in schema) {
|
807
|
+
return schema.required(strapiAdmin.translatedErrors.required);
|
808
|
+
}
|
809
|
+
return schema;
|
660
810
|
};
|
661
|
-
const addMinLengthValidation = (attribute) => (schema) => {
|
811
|
+
const addMinLengthValidation = (attribute, options) => (schema) => {
|
812
|
+
if (options.status === "draft") {
|
813
|
+
return schema;
|
814
|
+
}
|
662
815
|
if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
|
663
816
|
return schema.min(attribute.minLength, {
|
664
817
|
...strapiAdmin.translatedErrors.minLength,
|
@@ -680,10 +833,13 @@ const addMaxLengthValidation = (attribute) => (schema) => {
|
|
680
833
|
}
|
681
834
|
return schema;
|
682
835
|
};
|
683
|
-
const addMinValidation = (attribute) => (schema) => {
|
684
|
-
if ("
|
836
|
+
const addMinValidation = (attribute, options) => (schema) => {
|
837
|
+
if (options.status === "draft") {
|
838
|
+
return schema;
|
839
|
+
}
|
840
|
+
if ("min" in attribute && "min" in schema) {
|
685
841
|
const min = toInteger(attribute.min);
|
686
|
-
if (
|
842
|
+
if (min) {
|
687
843
|
return schema.min(min, {
|
688
844
|
...strapiAdmin.translatedErrors.min,
|
689
845
|
values: {
|
@@ -728,24 +884,6 @@ const addRegexValidation = (attribute) => (schema) => {
|
|
728
884
|
}
|
729
885
|
return schema;
|
730
886
|
};
|
731
|
-
const extractValuesFromYupError = (errorType, errorParams) => {
|
732
|
-
if (!errorType || !errorParams) {
|
733
|
-
return {};
|
734
|
-
}
|
735
|
-
return {
|
736
|
-
[errorType]: errorParams[errorType]
|
737
|
-
};
|
738
|
-
};
|
739
|
-
const getInnerErrors = (error) => (error?.inner || []).reduce((acc, currentError) => {
|
740
|
-
if (currentError.path) {
|
741
|
-
acc[currentError.path.split("[").join(".").split("]").join("")] = {
|
742
|
-
id: currentError.message,
|
743
|
-
defaultMessage: currentError.message,
|
744
|
-
values: extractValuesFromYupError(currentError?.type, currentError?.params)
|
745
|
-
};
|
746
|
-
}
|
747
|
-
return acc;
|
748
|
-
}, {});
|
749
887
|
const initApi = contentManagerApi.injectEndpoints({
|
750
888
|
endpoints: (builder) => ({
|
751
889
|
getInitialData: builder.query({
|
@@ -759,27 +897,20 @@ const { useGetInitialDataQuery } = initApi;
|
|
759
897
|
const useContentTypeSchema = (model) => {
|
760
898
|
const { toggleNotification } = strapiAdmin.useNotification();
|
761
899
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
762
|
-
const {
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
)
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
error: res.error,
|
777
|
-
components: Object.keys(components2).length === 0 ? void 0 : components2,
|
778
|
-
contentType: contentType2,
|
779
|
-
contentTypes: res.data?.contentTypes ?? []
|
780
|
-
};
|
781
|
-
}
|
782
|
-
});
|
900
|
+
const { data, error, isLoading, isFetching } = useGetInitialDataQuery(void 0);
|
901
|
+
const { components, contentType, contentTypes } = React__namespace.useMemo(() => {
|
902
|
+
const contentType2 = data?.contentTypes.find((ct) => ct.uid === model);
|
903
|
+
const componentsByKey = data?.components.reduce((acc, component) => {
|
904
|
+
acc[component.uid] = component;
|
905
|
+
return acc;
|
906
|
+
}, {});
|
907
|
+
const components2 = extractContentTypeComponents(contentType2?.attributes, componentsByKey);
|
908
|
+
return {
|
909
|
+
components: Object.keys(components2).length === 0 ? void 0 : components2,
|
910
|
+
contentType: contentType2,
|
911
|
+
contentTypes: data?.contentTypes ?? []
|
912
|
+
};
|
913
|
+
}, [model, data]);
|
783
914
|
React__namespace.useEffect(() => {
|
784
915
|
if (error) {
|
785
916
|
toggleNotification({
|
@@ -826,58 +957,401 @@ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
|
|
826
957
|
}, {});
|
827
958
|
return componentsByKey;
|
828
959
|
};
|
829
|
-
const
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
960
|
+
const HOOKS = {
|
961
|
+
/**
|
962
|
+
* Hook that allows to mutate the displayed headers of the list view table
|
963
|
+
* @constant
|
964
|
+
* @type {string}
|
965
|
+
*/
|
966
|
+
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
967
|
+
/**
|
968
|
+
* Hook that allows to mutate the CM's collection types links pre-set filters
|
969
|
+
* @constant
|
970
|
+
* @type {string}
|
971
|
+
*/
|
972
|
+
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
973
|
+
/**
|
974
|
+
* Hook that allows to mutate the CM's edit view layout
|
975
|
+
* @constant
|
976
|
+
* @type {string}
|
977
|
+
*/
|
978
|
+
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
979
|
+
/**
|
980
|
+
* Hook that allows to mutate the CM's single types links pre-set filters
|
981
|
+
* @constant
|
982
|
+
* @type {string}
|
983
|
+
*/
|
984
|
+
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
985
|
+
};
|
986
|
+
const contentTypesApi = contentManagerApi.injectEndpoints({
|
987
|
+
endpoints: (builder) => ({
|
988
|
+
getContentTypeConfiguration: builder.query({
|
989
|
+
query: (uid) => ({
|
990
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
991
|
+
method: "GET"
|
992
|
+
}),
|
993
|
+
transformResponse: (response) => response.data,
|
994
|
+
providesTags: (_result, _error, uid) => [
|
995
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
996
|
+
{ type: "ContentTypeSettings", id: "LIST" }
|
997
|
+
]
|
998
|
+
}),
|
999
|
+
getAllContentTypeSettings: builder.query({
|
1000
|
+
query: () => "/content-manager/content-types-settings",
|
1001
|
+
transformResponse: (response) => response.data,
|
1002
|
+
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
1003
|
+
}),
|
1004
|
+
updateContentTypeConfiguration: builder.mutation({
|
1005
|
+
query: ({ uid, ...body }) => ({
|
1006
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
1007
|
+
method: "PUT",
|
1008
|
+
data: body
|
1009
|
+
}),
|
1010
|
+
transformResponse: (response) => response.data,
|
1011
|
+
invalidatesTags: (_result, _error, { uid }) => [
|
1012
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
1013
|
+
{ type: "ContentTypeSettings", id: "LIST" },
|
1014
|
+
// Is this necessary?
|
1015
|
+
{ type: "InitialData" }
|
1016
|
+
]
|
1017
|
+
})
|
1018
|
+
})
|
1019
|
+
});
|
1020
|
+
const {
|
1021
|
+
useGetContentTypeConfigurationQuery,
|
1022
|
+
useGetAllContentTypeSettingsQuery,
|
1023
|
+
useUpdateContentTypeConfigurationMutation
|
1024
|
+
} = contentTypesApi;
|
1025
|
+
const checkIfAttributeIsDisplayable = (attribute) => {
|
1026
|
+
const { type } = attribute;
|
1027
|
+
if (type === "relation") {
|
1028
|
+
return !attribute.relation.toLowerCase().includes("morph");
|
1029
|
+
}
|
1030
|
+
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
1031
|
+
};
|
1032
|
+
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
1033
|
+
if (!mainFieldName) {
|
1034
|
+
return void 0;
|
1035
|
+
}
|
1036
|
+
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
1037
|
+
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
1038
|
+
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
1039
|
+
);
|
1040
|
+
return {
|
1041
|
+
name: mainFieldName,
|
1042
|
+
type: mainFieldType ?? "string"
|
1043
|
+
};
|
1044
|
+
};
|
1045
|
+
const DEFAULT_SETTINGS = {
|
1046
|
+
bulkable: false,
|
1047
|
+
filterable: false,
|
1048
|
+
searchable: false,
|
1049
|
+
pagination: false,
|
1050
|
+
defaultSortBy: "",
|
1051
|
+
defaultSortOrder: "asc",
|
1052
|
+
mainField: "id",
|
1053
|
+
pageSize: 10
|
1054
|
+
};
|
1055
|
+
const useDocumentLayout = (model) => {
|
1056
|
+
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
1057
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
1058
|
+
const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
1059
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
1060
|
+
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
1061
|
+
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
1062
|
+
const {
|
1063
|
+
data,
|
1064
|
+
isLoading: isLoadingConfigs,
|
1065
|
+
error,
|
1066
|
+
isFetching: isFetchingConfigs
|
1067
|
+
} = useGetContentTypeConfigurationQuery(model);
|
1068
|
+
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
1069
|
+
React__namespace.useEffect(() => {
|
1070
|
+
if (error) {
|
1071
|
+
toggleNotification({
|
1072
|
+
type: "danger",
|
1073
|
+
message: formatAPIError(error)
|
1074
|
+
});
|
1075
|
+
}
|
1076
|
+
}, [error, formatAPIError, toggleNotification]);
|
1077
|
+
const editLayout = React__namespace.useMemo(
|
1078
|
+
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
1079
|
+
layout: [],
|
1080
|
+
components: {},
|
1081
|
+
metadatas: {},
|
1082
|
+
options: {},
|
1083
|
+
settings: DEFAULT_SETTINGS
|
1084
|
+
},
|
1085
|
+
[data, isLoading, schemas, schema, components]
|
1086
|
+
);
|
1087
|
+
const listLayout = React__namespace.useMemo(() => {
|
1088
|
+
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
1089
|
+
layout: [],
|
1090
|
+
metadatas: {},
|
1091
|
+
options: {},
|
1092
|
+
settings: DEFAULT_SETTINGS
|
1093
|
+
};
|
1094
|
+
}, [data, isLoading, schemas, schema, components]);
|
1095
|
+
const { layout: edit } = React__namespace.useMemo(
|
1096
|
+
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
1097
|
+
layout: editLayout,
|
1098
|
+
query
|
1099
|
+
}),
|
1100
|
+
[editLayout, query, runHookWaterfall]
|
1101
|
+
);
|
1102
|
+
return {
|
1103
|
+
error,
|
1104
|
+
isLoading,
|
1105
|
+
edit,
|
1106
|
+
list: listLayout
|
1107
|
+
};
|
1108
|
+
};
|
1109
|
+
const useDocLayout = () => {
|
1110
|
+
const { model } = useDoc();
|
1111
|
+
return useDocumentLayout(model);
|
1112
|
+
};
|
1113
|
+
const formatEditLayout = (data, {
|
1114
|
+
schemas,
|
1115
|
+
schema,
|
1116
|
+
components
|
1117
|
+
}) => {
|
1118
|
+
let currentPanelIndex = 0;
|
1119
|
+
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
1120
|
+
data.contentType.layouts.edit,
|
1121
|
+
schema?.attributes,
|
1122
|
+
data.contentType.metadatas,
|
1123
|
+
{ configurations: data.components, schemas: components },
|
1124
|
+
schemas
|
1125
|
+
).reduce((panels, row) => {
|
1126
|
+
if (row.some((field) => field.type === "dynamiczone")) {
|
1127
|
+
panels.push([row]);
|
1128
|
+
currentPanelIndex += 2;
|
1129
|
+
} else {
|
1130
|
+
if (!panels[currentPanelIndex]) {
|
1131
|
+
panels.push([row]);
|
1132
|
+
} else {
|
1133
|
+
panels[currentPanelIndex].push(row);
|
1134
|
+
}
|
1135
|
+
}
|
1136
|
+
return panels;
|
1137
|
+
}, []);
|
1138
|
+
const componentEditAttributes = Object.entries(data.components).reduce(
|
1139
|
+
(acc, [uid, configuration]) => {
|
1140
|
+
acc[uid] = {
|
1141
|
+
layout: convertEditLayoutToFieldLayouts(
|
1142
|
+
configuration.layouts.edit,
|
1143
|
+
components[uid].attributes,
|
1144
|
+
configuration.metadatas,
|
1145
|
+
{ configurations: data.components, schemas: components }
|
1146
|
+
),
|
1147
|
+
settings: {
|
1148
|
+
...configuration.settings,
|
1149
|
+
icon: components[uid].info.icon,
|
1150
|
+
displayName: components[uid].info.displayName
|
1151
|
+
}
|
1152
|
+
};
|
1153
|
+
return acc;
|
1154
|
+
},
|
1155
|
+
{}
|
1156
|
+
);
|
1157
|
+
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1158
|
+
(acc, [attribute, metadata]) => {
|
1159
|
+
return {
|
1160
|
+
...acc,
|
1161
|
+
[attribute]: metadata.edit
|
1162
|
+
};
|
1163
|
+
},
|
1164
|
+
{}
|
1165
|
+
);
|
1166
|
+
return {
|
1167
|
+
layout: panelledEditAttributes,
|
1168
|
+
components: componentEditAttributes,
|
1169
|
+
metadatas: editMetadatas,
|
1170
|
+
settings: {
|
1171
|
+
...data.contentType.settings,
|
1172
|
+
displayName: schema?.info.displayName
|
1173
|
+
},
|
1174
|
+
options: {
|
1175
|
+
...schema?.options,
|
1176
|
+
...schema?.pluginOptions,
|
1177
|
+
...data.contentType.options
|
1178
|
+
}
|
1179
|
+
};
|
1180
|
+
};
|
1181
|
+
const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
|
1182
|
+
return rows.map(
|
1183
|
+
(row) => row.map((field) => {
|
1184
|
+
const attribute = attributes[field.name];
|
1185
|
+
if (!attribute) {
|
1186
|
+
return null;
|
1187
|
+
}
|
1188
|
+
const { edit: metadata } = metadatas[field.name];
|
1189
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1190
|
+
return {
|
1191
|
+
attribute,
|
1192
|
+
disabled: !metadata.editable,
|
1193
|
+
hint: metadata.description,
|
1194
|
+
label: metadata.label ?? "",
|
1195
|
+
name: field.name,
|
1196
|
+
// @ts-expect-error – mainField does exist on the metadata for a relation.
|
1197
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1198
|
+
schemas,
|
1199
|
+
components: components?.schemas ?? {}
|
1200
|
+
}),
|
1201
|
+
placeholder: metadata.placeholder ?? "",
|
1202
|
+
required: attribute.required ?? false,
|
1203
|
+
size: field.size,
|
1204
|
+
unique: "unique" in attribute ? attribute.unique : false,
|
1205
|
+
visible: metadata.visible ?? true,
|
1206
|
+
type: attribute.type
|
1207
|
+
};
|
1208
|
+
}).filter((field) => field !== null)
|
1209
|
+
);
|
1210
|
+
};
|
1211
|
+
const formatListLayout = (data, {
|
1212
|
+
schemas,
|
1213
|
+
schema,
|
1214
|
+
components
|
1215
|
+
}) => {
|
1216
|
+
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1217
|
+
(acc, [attribute, metadata]) => {
|
1218
|
+
return {
|
1219
|
+
...acc,
|
1220
|
+
[attribute]: metadata.list
|
1221
|
+
};
|
1222
|
+
},
|
1223
|
+
{}
|
1224
|
+
);
|
1225
|
+
const listAttributes = convertListLayoutToFieldLayouts(
|
1226
|
+
data.contentType.layouts.list,
|
1227
|
+
schema?.attributes,
|
1228
|
+
listMetadatas,
|
1229
|
+
{ configurations: data.components, schemas: components },
|
1230
|
+
schemas
|
1231
|
+
);
|
1232
|
+
return {
|
1233
|
+
layout: listAttributes,
|
1234
|
+
settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
|
1235
|
+
metadatas: listMetadatas,
|
1236
|
+
options: {
|
1237
|
+
...schema?.options,
|
1238
|
+
...schema?.pluginOptions,
|
1239
|
+
...data.contentType.options
|
1240
|
+
}
|
1241
|
+
};
|
1242
|
+
};
|
1243
|
+
const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
|
1244
|
+
return columns.map((name) => {
|
1245
|
+
const attribute = attributes[name];
|
1246
|
+
if (!attribute) {
|
1247
|
+
return null;
|
1248
|
+
}
|
1249
|
+
const metadata = metadatas[name];
|
1250
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1251
|
+
return {
|
1252
|
+
attribute,
|
1253
|
+
label: metadata.label ?? "",
|
1254
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1255
|
+
schemas,
|
1256
|
+
components: components?.schemas ?? {}
|
1257
|
+
}),
|
1258
|
+
name,
|
1259
|
+
searchable: metadata.searchable ?? true,
|
1260
|
+
sortable: metadata.sortable ?? true
|
1261
|
+
};
|
1262
|
+
}).filter((field) => field !== null);
|
1263
|
+
};
|
1264
|
+
const useDocument = (args, opts) => {
|
1265
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
1266
|
+
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
1267
|
+
const { formatMessage } = reactIntl.useIntl();
|
1268
|
+
const {
|
1269
|
+
currentData: data,
|
1270
|
+
isLoading: isLoadingDocument,
|
1271
|
+
isFetching: isFetchingDocument,
|
1272
|
+
error
|
1273
|
+
} = useGetDocumentQuery(args, {
|
1274
|
+
...opts,
|
1275
|
+
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
1276
|
+
});
|
1277
|
+
const document = data?.data;
|
1278
|
+
const meta = data?.meta;
|
1279
|
+
const {
|
1280
|
+
components,
|
1281
|
+
schema,
|
1282
|
+
schemas,
|
1283
|
+
isLoading: isLoadingSchema
|
1284
|
+
} = useContentTypeSchema(args.model);
|
1285
|
+
const isSingleType = schema?.kind === "singleType";
|
1286
|
+
const getTitle = (mainField) => {
|
1287
|
+
if (mainField !== "id" && document?.[mainField]) {
|
1288
|
+
return document[mainField];
|
1289
|
+
}
|
1290
|
+
if (isSingleType && schema?.info.displayName) {
|
1291
|
+
return schema.info.displayName;
|
1292
|
+
}
|
1293
|
+
return formatMessage({
|
1294
|
+
id: "content-manager.containers.untitled",
|
1295
|
+
defaultMessage: "Untitled"
|
1296
|
+
});
|
1297
|
+
};
|
1298
|
+
React__namespace.useEffect(() => {
|
1299
|
+
if (error) {
|
1300
|
+
toggleNotification({
|
1301
|
+
type: "danger",
|
1302
|
+
message: formatAPIError(error)
|
1303
|
+
});
|
1304
|
+
}
|
1305
|
+
}, [toggleNotification, error, formatAPIError, args.collectionType]);
|
1306
|
+
const validationSchema = React__namespace.useMemo(() => {
|
1307
|
+
if (!schema) {
|
1308
|
+
return null;
|
1309
|
+
}
|
1310
|
+
return createYupSchema(schema.attributes, components);
|
1311
|
+
}, [schema, components]);
|
1312
|
+
const validate = React__namespace.useCallback(
|
1313
|
+
(document2) => {
|
1314
|
+
if (!validationSchema) {
|
1315
|
+
throw new Error(
|
1316
|
+
"There is no validation schema generated, this is likely due to the schema not being loaded yet."
|
1317
|
+
);
|
1318
|
+
}
|
1319
|
+
try {
|
1320
|
+
validationSchema.validateSync(document2, { abortEarly: false, strict: true });
|
1321
|
+
return null;
|
1322
|
+
} catch (error2) {
|
1323
|
+
if (error2 instanceof yup.ValidationError) {
|
1324
|
+
return strapiAdmin.getYupValidationErrors(error2);
|
1325
|
+
}
|
1326
|
+
throw error2;
|
1327
|
+
}
|
1328
|
+
},
|
1329
|
+
[validationSchema]
|
1330
|
+
);
|
1331
|
+
const getInitialFormValues = React__namespace.useCallback(
|
1332
|
+
(isCreatingDocument = false) => {
|
1333
|
+
if (!document && !isCreatingDocument && !isSingleType || !schema) {
|
1334
|
+
return void 0;
|
1335
|
+
}
|
1336
|
+
const form = document?.id ? document : createDefaultForm(schema, components);
|
1337
|
+
return transformDocument(schema, components)(form);
|
1338
|
+
},
|
1339
|
+
[document, isSingleType, schema, components]
|
1340
|
+
);
|
1341
|
+
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
1342
|
+
const hasError = !!error;
|
1343
|
+
return {
|
1344
|
+
components,
|
1345
|
+
document,
|
1346
|
+
meta,
|
1347
|
+
isLoading,
|
1348
|
+
hasError,
|
1349
|
+
schema,
|
1350
|
+
schemas,
|
1351
|
+
validate,
|
1352
|
+
getTitle,
|
1353
|
+
getInitialFormValues
|
1354
|
+
};
|
881
1355
|
};
|
882
1356
|
const useDoc = () => {
|
883
1357
|
const { id, slug, collectionType, origin } = reactRouterDom.useParams();
|
@@ -889,22 +1363,60 @@ const useDoc = () => {
|
|
889
1363
|
if (!slug) {
|
890
1364
|
throw new Error("Could not find model in url params");
|
891
1365
|
}
|
1366
|
+
const document = useDocument(
|
1367
|
+
{ documentId: origin || id, model: slug, collectionType, params },
|
1368
|
+
{
|
1369
|
+
skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
|
1370
|
+
}
|
1371
|
+
);
|
1372
|
+
const returnId = origin || id === "create" ? void 0 : id;
|
892
1373
|
return {
|
893
1374
|
collectionType,
|
894
1375
|
model: slug,
|
895
|
-
id:
|
896
|
-
...
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
1376
|
+
id: returnId,
|
1377
|
+
...document
|
1378
|
+
};
|
1379
|
+
};
|
1380
|
+
const useContentManagerContext = () => {
|
1381
|
+
const {
|
1382
|
+
collectionType,
|
1383
|
+
model,
|
1384
|
+
id,
|
1385
|
+
components,
|
1386
|
+
isLoading: isLoadingDoc,
|
1387
|
+
schema,
|
1388
|
+
schemas
|
1389
|
+
} = useDoc();
|
1390
|
+
const layout = useDocumentLayout(model);
|
1391
|
+
const form = strapiAdmin.useForm("useContentManagerContext", (state) => state);
|
1392
|
+
const isSingleType = collectionType === SINGLE_TYPES;
|
1393
|
+
const slug = model;
|
1394
|
+
const isCreatingEntry = id === "create";
|
1395
|
+
useContentTypeSchema();
|
1396
|
+
const isLoading = isLoadingDoc || layout.isLoading;
|
1397
|
+
const error = layout.error;
|
1398
|
+
return {
|
1399
|
+
error,
|
1400
|
+
isLoading,
|
1401
|
+
// Base metadata
|
1402
|
+
model,
|
1403
|
+
collectionType,
|
1404
|
+
id,
|
1405
|
+
slug,
|
1406
|
+
isCreatingEntry,
|
1407
|
+
isSingleType,
|
1408
|
+
hasDraftAndPublish: schema?.options?.draftAndPublish ?? false,
|
1409
|
+
// All schema infos
|
1410
|
+
components,
|
1411
|
+
contentType: schema,
|
1412
|
+
contentTypes: schemas,
|
1413
|
+
// Form state
|
1414
|
+
form,
|
1415
|
+
// layout infos
|
1416
|
+
layout
|
902
1417
|
};
|
903
1418
|
};
|
904
1419
|
const prefixPluginTranslations = (trad, pluginId) => {
|
905
|
-
if (!pluginId) {
|
906
|
-
throw new TypeError("pluginId can't be empty");
|
907
|
-
}
|
908
1420
|
return Object.keys(trad).reduce((acc, current) => {
|
909
1421
|
acc[`${pluginId}.${current}`] = trad[current];
|
910
1422
|
return acc;
|
@@ -920,6 +1432,8 @@ const useDocumentActions = () => {
|
|
920
1432
|
const { formatMessage } = reactIntl.useIntl();
|
921
1433
|
const { trackUsage } = strapiAdmin.useTracking();
|
922
1434
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
1435
|
+
const navigate = reactRouterDom.useNavigate();
|
1436
|
+
const setCurrentStep = strapiAdmin.useGuidedTour("useDocumentActions", (state) => state.setCurrentStep);
|
923
1437
|
const [deleteDocument] = useDeleteDocumentMutation();
|
924
1438
|
const _delete = React__namespace.useCallback(
|
925
1439
|
async ({ collectionType, model, documentId, params }, trackerProperty) => {
|
@@ -958,14 +1472,53 @@ const useDocumentActions = () => {
|
|
958
1472
|
},
|
959
1473
|
[trackUsage, deleteDocument, toggleNotification, formatMessage, formatAPIError]
|
960
1474
|
);
|
1475
|
+
const [deleteManyDocuments] = useDeleteManyDocumentsMutation();
|
1476
|
+
const deleteMany = React__namespace.useCallback(
|
1477
|
+
async ({ model, documentIds, params }) => {
|
1478
|
+
try {
|
1479
|
+
trackUsage("willBulkDeleteEntries");
|
1480
|
+
const res = await deleteManyDocuments({
|
1481
|
+
model,
|
1482
|
+
documentIds,
|
1483
|
+
params
|
1484
|
+
});
|
1485
|
+
if ("error" in res) {
|
1486
|
+
toggleNotification({
|
1487
|
+
type: "danger",
|
1488
|
+
message: formatAPIError(res.error)
|
1489
|
+
});
|
1490
|
+
return { error: res.error };
|
1491
|
+
}
|
1492
|
+
toggleNotification({
|
1493
|
+
type: "success",
|
1494
|
+
title: formatMessage({
|
1495
|
+
id: getTranslation("success.records.delete"),
|
1496
|
+
defaultMessage: "Successfully deleted."
|
1497
|
+
}),
|
1498
|
+
message: ""
|
1499
|
+
});
|
1500
|
+
trackUsage("didBulkDeleteEntries");
|
1501
|
+
return res.data;
|
1502
|
+
} catch (err) {
|
1503
|
+
toggleNotification({
|
1504
|
+
type: "danger",
|
1505
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1506
|
+
});
|
1507
|
+
trackUsage("didNotBulkDeleteEntries");
|
1508
|
+
throw err;
|
1509
|
+
}
|
1510
|
+
},
|
1511
|
+
[trackUsage, deleteManyDocuments, toggleNotification, formatMessage, formatAPIError]
|
1512
|
+
);
|
961
1513
|
const [discardDocument] = useDiscardDocumentMutation();
|
962
1514
|
const discard = React__namespace.useCallback(
|
963
|
-
async ({ collectionType, model, documentId }) => {
|
1515
|
+
async ({ collectionType, model, documentId, params }) => {
|
964
1516
|
try {
|
965
1517
|
const res = await discardDocument({
|
966
1518
|
collectionType,
|
967
1519
|
model,
|
968
|
-
documentId
|
1520
|
+
documentId,
|
1521
|
+
params
|
969
1522
|
});
|
970
1523
|
if ("error" in res) {
|
971
1524
|
toggleNotification({
|
@@ -1027,6 +1580,43 @@ const useDocumentActions = () => {
|
|
1027
1580
|
},
|
1028
1581
|
[trackUsage, publishDocument, toggleNotification, formatMessage, formatAPIError]
|
1029
1582
|
);
|
1583
|
+
const [publishManyDocuments] = usePublishManyDocumentsMutation();
|
1584
|
+
const publishMany = React__namespace.useCallback(
|
1585
|
+
async ({ model, documentIds, params }) => {
|
1586
|
+
try {
|
1587
|
+
const res = await publishManyDocuments({
|
1588
|
+
model,
|
1589
|
+
documentIds,
|
1590
|
+
params
|
1591
|
+
});
|
1592
|
+
if ("error" in res) {
|
1593
|
+
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1594
|
+
return { error: res.error };
|
1595
|
+
}
|
1596
|
+
toggleNotification({
|
1597
|
+
type: "success",
|
1598
|
+
message: formatMessage({
|
1599
|
+
id: getTranslation("success.record.publish"),
|
1600
|
+
defaultMessage: "Published document"
|
1601
|
+
})
|
1602
|
+
});
|
1603
|
+
return res.data;
|
1604
|
+
} catch (err) {
|
1605
|
+
toggleNotification({
|
1606
|
+
type: "danger",
|
1607
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1608
|
+
});
|
1609
|
+
throw err;
|
1610
|
+
}
|
1611
|
+
},
|
1612
|
+
[
|
1613
|
+
// trackUsage,
|
1614
|
+
publishManyDocuments,
|
1615
|
+
toggleNotification,
|
1616
|
+
formatMessage,
|
1617
|
+
formatAPIError
|
1618
|
+
]
|
1619
|
+
);
|
1030
1620
|
const [updateDocument] = useUpdateDocumentMutation();
|
1031
1621
|
const update = React__namespace.useCallback(
|
1032
1622
|
async ({ collectionType, model, documentId, params }, data, trackerProperty) => {
|
@@ -1099,7 +1689,42 @@ const useDocumentActions = () => {
|
|
1099
1689
|
throw err;
|
1100
1690
|
}
|
1101
1691
|
},
|
1102
|
-
[trackUsage, unpublishDocument, toggleNotification, formatMessage, formatAPIError]
|
1692
|
+
[trackUsage, unpublishDocument, toggleNotification, formatMessage, formatAPIError]
|
1693
|
+
);
|
1694
|
+
const [unpublishManyDocuments] = useUnpublishManyDocumentsMutation();
|
1695
|
+
const unpublishMany = React__namespace.useCallback(
|
1696
|
+
async ({ model, documentIds, params }) => {
|
1697
|
+
try {
|
1698
|
+
trackUsage("willBulkUnpublishEntries");
|
1699
|
+
const res = await unpublishManyDocuments({
|
1700
|
+
model,
|
1701
|
+
documentIds,
|
1702
|
+
params
|
1703
|
+
});
|
1704
|
+
if ("error" in res) {
|
1705
|
+
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1706
|
+
return { error: res.error };
|
1707
|
+
}
|
1708
|
+
trackUsage("didBulkUnpublishEntries");
|
1709
|
+
toggleNotification({
|
1710
|
+
type: "success",
|
1711
|
+
title: formatMessage({
|
1712
|
+
id: getTranslation("success.records.unpublish"),
|
1713
|
+
defaultMessage: "Successfully unpublished."
|
1714
|
+
}),
|
1715
|
+
message: ""
|
1716
|
+
});
|
1717
|
+
return res.data;
|
1718
|
+
} catch (err) {
|
1719
|
+
toggleNotification({
|
1720
|
+
type: "danger",
|
1721
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1722
|
+
});
|
1723
|
+
trackUsage("didNotBulkUnpublishEntries");
|
1724
|
+
throw err;
|
1725
|
+
}
|
1726
|
+
},
|
1727
|
+
[trackUsage, unpublishManyDocuments, toggleNotification, formatMessage, formatAPIError]
|
1103
1728
|
);
|
1104
1729
|
const [createDocument] = useCreateDocumentMutation();
|
1105
1730
|
const create = React__namespace.useCallback(
|
@@ -1123,6 +1748,7 @@ const useDocumentActions = () => {
|
|
1123
1748
|
defaultMessage: "Saved document"
|
1124
1749
|
})
|
1125
1750
|
});
|
1751
|
+
setCurrentStep("contentManager.success");
|
1126
1752
|
return res.data;
|
1127
1753
|
} catch (err) {
|
1128
1754
|
toggleNotification({
|
@@ -1144,7 +1770,6 @@ const useDocumentActions = () => {
|
|
1144
1770
|
sourceId
|
1145
1771
|
});
|
1146
1772
|
if ("error" in res) {
|
1147
|
-
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1148
1773
|
return { error: res.error };
|
1149
1774
|
}
|
1150
1775
|
toggleNotification({
|
@@ -1163,7 +1788,7 @@ const useDocumentActions = () => {
|
|
1163
1788
|
throw err;
|
1164
1789
|
}
|
1165
1790
|
},
|
1166
|
-
[autoCloneDocument,
|
1791
|
+
[autoCloneDocument, formatMessage, toggleNotification]
|
1167
1792
|
);
|
1168
1793
|
const [cloneDocument] = useCloneDocumentMutation();
|
1169
1794
|
const clone = React__namespace.useCallback(
|
@@ -1189,6 +1814,7 @@ const useDocumentActions = () => {
|
|
1189
1814
|
defaultMessage: "Cloned document"
|
1190
1815
|
})
|
1191
1816
|
});
|
1817
|
+
navigate(`../../${res.data.data.documentId}`, { relative: "path" });
|
1192
1818
|
return res.data;
|
1193
1819
|
} catch (err) {
|
1194
1820
|
toggleNotification({
|
@@ -1199,7 +1825,7 @@ const useDocumentActions = () => {
|
|
1199
1825
|
throw err;
|
1200
1826
|
}
|
1201
1827
|
},
|
1202
|
-
[cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError]
|
1828
|
+
[cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError, navigate]
|
1203
1829
|
);
|
1204
1830
|
const [getDoc] = useLazyGetDocumentQuery();
|
1205
1831
|
const getDocument = React__namespace.useCallback(
|
@@ -1214,17 +1840,20 @@ const useDocumentActions = () => {
|
|
1214
1840
|
clone,
|
1215
1841
|
create,
|
1216
1842
|
delete: _delete,
|
1843
|
+
deleteMany,
|
1217
1844
|
discard,
|
1218
1845
|
getDocument,
|
1219
1846
|
publish,
|
1847
|
+
publishMany,
|
1220
1848
|
unpublish,
|
1849
|
+
unpublishMany,
|
1221
1850
|
update
|
1222
1851
|
};
|
1223
1852
|
};
|
1224
|
-
const ProtectedHistoryPage =
|
1225
|
-
() => Promise.resolve().then(() => require("./History-
|
1853
|
+
const ProtectedHistoryPage = React__namespace.lazy(
|
1854
|
+
() => Promise.resolve().then(() => require("./History-BQpDoOu8.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
|
1226
1855
|
);
|
1227
|
-
const routes$
|
1856
|
+
const routes$2 = [
|
1228
1857
|
{
|
1229
1858
|
path: ":collectionType/:slug/:id/history",
|
1230
1859
|
Component: ProtectedHistoryPage
|
@@ -1234,32 +1863,45 @@ const routes$1 = [
|
|
1234
1863
|
Component: ProtectedHistoryPage
|
1235
1864
|
}
|
1236
1865
|
];
|
1866
|
+
const ProtectedPreviewPage = React__namespace.lazy(
|
1867
|
+
() => Promise.resolve().then(() => require("./Preview-CbXHXqBg.js")).then((mod) => ({ default: mod.ProtectedPreviewPage }))
|
1868
|
+
);
|
1869
|
+
const routes$1 = [
|
1870
|
+
{
|
1871
|
+
path: ":collectionType/:slug/:id/preview",
|
1872
|
+
Component: ProtectedPreviewPage
|
1873
|
+
},
|
1874
|
+
{
|
1875
|
+
path: ":collectionType/:slug/preview",
|
1876
|
+
Component: ProtectedPreviewPage
|
1877
|
+
}
|
1878
|
+
];
|
1237
1879
|
const ProtectedEditViewPage = React.lazy(
|
1238
|
-
() => Promise.resolve().then(() => require("./EditViewPage-
|
1880
|
+
() => Promise.resolve().then(() => require("./EditViewPage-BT7Achc-.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
|
1239
1881
|
);
|
1240
1882
|
const ProtectedListViewPage = React.lazy(
|
1241
|
-
() => Promise.resolve().then(() => require("./ListViewPage-
|
1883
|
+
() => Promise.resolve().then(() => require("./ListViewPage-Dt8OUTwO.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
|
1242
1884
|
);
|
1243
1885
|
const ProtectedListConfiguration = React.lazy(
|
1244
|
-
() => Promise.resolve().then(() => require("./ListConfigurationPage-
|
1886
|
+
() => Promise.resolve().then(() => require("./ListConfigurationPage-B6NsS-0m.js")).then((mod) => ({
|
1245
1887
|
default: mod.ProtectedListConfiguration
|
1246
1888
|
}))
|
1247
1889
|
);
|
1248
1890
|
const ProtectedEditConfigurationPage = React.lazy(
|
1249
|
-
() => Promise.resolve().then(() => require("./EditConfigurationPage-
|
1891
|
+
() => Promise.resolve().then(() => require("./EditConfigurationPage-n7_xHayb.js")).then((mod) => ({
|
1250
1892
|
default: mod.ProtectedEditConfigurationPage
|
1251
1893
|
}))
|
1252
1894
|
);
|
1253
1895
|
const ProtectedComponentConfigurationPage = React.lazy(
|
1254
|
-
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-
|
1896
|
+
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-NeMPjY5M.js")).then((mod) => ({
|
1255
1897
|
default: mod.ProtectedComponentConfigurationPage
|
1256
1898
|
}))
|
1257
1899
|
);
|
1258
1900
|
const NoPermissions = React.lazy(
|
1259
|
-
() => Promise.resolve().then(() => require("./NoPermissionsPage-
|
1901
|
+
() => Promise.resolve().then(() => require("./NoPermissionsPage-CLbU5SOt.js")).then((mod) => ({ default: mod.NoPermissions }))
|
1260
1902
|
);
|
1261
1903
|
const NoContentType = React.lazy(
|
1262
|
-
() => Promise.resolve().then(() => require("./NoContentTypePage-
|
1904
|
+
() => Promise.resolve().then(() => require("./NoContentTypePage-Dgm-uj-6.js")).then((mod) => ({ default: mod.NoContentType }))
|
1263
1905
|
);
|
1264
1906
|
const CollectionTypePages = () => {
|
1265
1907
|
const { collectionType } = reactRouterDom.useParams();
|
@@ -1271,7 +1913,7 @@ const CollectionTypePages = () => {
|
|
1271
1913
|
const CLONE_RELATIVE_PATH = ":collectionType/:slug/clone/:origin";
|
1272
1914
|
const CLONE_PATH = `/content-manager/${CLONE_RELATIVE_PATH}`;
|
1273
1915
|
const LIST_RELATIVE_PATH = ":collectionType/:slug";
|
1274
|
-
const LIST_PATH = `/content-manager
|
1916
|
+
const LIST_PATH = `/content-manager/collection-types/:slug`;
|
1275
1917
|
const routes = [
|
1276
1918
|
{
|
1277
1919
|
path: LIST_RELATIVE_PATH,
|
@@ -1305,6 +1947,7 @@ const routes = [
|
|
1305
1947
|
path: "no-content-types",
|
1306
1948
|
Component: NoContentType
|
1307
1949
|
},
|
1950
|
+
...routes$2,
|
1308
1951
|
...routes$1
|
1309
1952
|
];
|
1310
1953
|
const DocumentActions = ({ actions: actions2 }) => {
|
@@ -1373,12 +2016,14 @@ const DocumentActionButton = (action) => {
|
|
1373
2016
|
/* @__PURE__ */ jsxRuntime.jsx(
|
1374
2017
|
designSystem.Button,
|
1375
2018
|
{
|
1376
|
-
flex:
|
2019
|
+
flex: "auto",
|
1377
2020
|
startIcon: action.icon,
|
1378
2021
|
disabled: action.disabled,
|
1379
2022
|
onClick: handleClick(action),
|
1380
2023
|
justifyContent: "center",
|
1381
2024
|
variant: action.variant || "default",
|
2025
|
+
paddingTop: "7px",
|
2026
|
+
paddingBottom: "7px",
|
1382
2027
|
children: action.label
|
1383
2028
|
}
|
1384
2029
|
),
|
@@ -1386,7 +2031,7 @@ const DocumentActionButton = (action) => {
|
|
1386
2031
|
DocumentActionConfirmDialog,
|
1387
2032
|
{
|
1388
2033
|
...action.dialog,
|
1389
|
-
variant: action.variant,
|
2034
|
+
variant: action.dialog?.variant ?? action.variant,
|
1390
2035
|
isOpen: dialogId === action.id,
|
1391
2036
|
onClose: handleClose
|
1392
2037
|
}
|
@@ -1401,6 +2046,11 @@ const DocumentActionButton = (action) => {
|
|
1401
2046
|
) : null
|
1402
2047
|
] });
|
1403
2048
|
};
|
2049
|
+
const MenuItem = styledComponents.styled(designSystem.Menu.Item)`
|
2050
|
+
&:hover {
|
2051
|
+
background: ${({ theme, isVariantDanger, isDisabled }) => isVariantDanger && !isDisabled ? theme.colors.danger100 : "neutral"};
|
2052
|
+
}
|
2053
|
+
`;
|
1404
2054
|
const DocumentActionsMenu = ({
|
1405
2055
|
actions: actions2,
|
1406
2056
|
children,
|
@@ -1443,49 +2093,48 @@ const DocumentActionsMenu = ({
|
|
1443
2093
|
disabled: isDisabled,
|
1444
2094
|
size: "S",
|
1445
2095
|
endIcon: null,
|
1446
|
-
paddingTop: "
|
1447
|
-
paddingLeft: "
|
1448
|
-
paddingRight: "
|
2096
|
+
paddingTop: "4px",
|
2097
|
+
paddingLeft: "7px",
|
2098
|
+
paddingRight: "7px",
|
1449
2099
|
variant,
|
1450
2100
|
children: [
|
1451
2101
|
/* @__PURE__ */ jsxRuntime.jsx(Icons.More, { "aria-hidden": true, focusable: false }),
|
1452
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, {
|
2102
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { tag: "span", children: label || formatMessage({
|
1453
2103
|
id: "content-manager.containers.edit.panels.default.more-actions",
|
1454
2104
|
defaultMessage: "More document actions"
|
1455
2105
|
}) })
|
1456
2106
|
]
|
1457
2107
|
}
|
1458
2108
|
),
|
1459
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, {
|
2109
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
|
1460
2110
|
actions2.map((action) => {
|
1461
2111
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
1462
|
-
|
2112
|
+
MenuItem,
|
1463
2113
|
{
|
1464
2114
|
disabled: action.disabled,
|
1465
2115
|
onSelect: handleClick(action),
|
1466
2116
|
display: "block",
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
] })
|
2117
|
+
isVariantDanger: action.variant === "danger",
|
2118
|
+
isDisabled: action.disabled,
|
2119
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
2120
|
+
designSystem.Flex,
|
2121
|
+
{
|
2122
|
+
color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
|
2123
|
+
gap: 2,
|
2124
|
+
tag: "span",
|
2125
|
+
children: [
|
2126
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
2127
|
+
designSystem.Flex,
|
2128
|
+
{
|
2129
|
+
tag: "span",
|
2130
|
+
color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
|
2131
|
+
children: action.icon
|
2132
|
+
}
|
2133
|
+
),
|
2134
|
+
action.label
|
2135
|
+
]
|
2136
|
+
}
|
2137
|
+
) })
|
1489
2138
|
},
|
1490
2139
|
action.id
|
1491
2140
|
);
|
@@ -1527,6 +2176,18 @@ const convertActionVariantToColor = (variant = "secondary") => {
|
|
1527
2176
|
return "primary600";
|
1528
2177
|
}
|
1529
2178
|
};
|
2179
|
+
const convertActionVariantToIconColor = (variant = "secondary") => {
|
2180
|
+
switch (variant) {
|
2181
|
+
case "danger":
|
2182
|
+
return "danger600";
|
2183
|
+
case "secondary":
|
2184
|
+
return "neutral500";
|
2185
|
+
case "success":
|
2186
|
+
return "success600";
|
2187
|
+
default:
|
2188
|
+
return "primary600";
|
2189
|
+
}
|
2190
|
+
};
|
1530
2191
|
const DocumentActionConfirmDialog = ({
|
1531
2192
|
onClose,
|
1532
2193
|
onCancel,
|
@@ -1549,61 +2210,54 @@ const DocumentActionConfirmDialog = ({
|
|
1549
2210
|
}
|
1550
2211
|
onClose();
|
1551
2212
|
};
|
1552
|
-
return /* @__PURE__ */ jsxRuntime.
|
1553
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
1554
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
1555
|
-
|
1556
|
-
{
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
)
|
1567
|
-
] });
|
2213
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
2214
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
|
2215
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: content }),
|
2216
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
|
2217
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", fullWidth: true, children: formatMessage({
|
2218
|
+
id: "app.components.Button.cancel",
|
2219
|
+
defaultMessage: "Cancel"
|
2220
|
+
}) }) }),
|
2221
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, fullWidth: true, children: formatMessage({
|
2222
|
+
id: "app.components.Button.confirm",
|
2223
|
+
defaultMessage: "Confirm"
|
2224
|
+
}) })
|
2225
|
+
] })
|
2226
|
+
] }) });
|
1568
2227
|
};
|
1569
2228
|
const DocumentActionModal = ({
|
1570
2229
|
isOpen,
|
1571
2230
|
title,
|
1572
2231
|
onClose,
|
1573
2232
|
footer: Footer,
|
1574
|
-
content,
|
2233
|
+
content: Content,
|
1575
2234
|
onModalClose
|
1576
2235
|
}) => {
|
1577
|
-
const id = React__namespace.useId();
|
1578
|
-
if (!isOpen) {
|
1579
|
-
return null;
|
1580
|
-
}
|
1581
2236
|
const handleClose = () => {
|
1582
2237
|
if (onClose) {
|
1583
2238
|
onClose();
|
1584
2239
|
}
|
1585
2240
|
onModalClose();
|
1586
2241
|
};
|
1587
|
-
return /* @__PURE__ */ jsxRuntime.
|
1588
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
1589
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
1590
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
] });
|
2242
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { children: [
|
2243
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: title }) }),
|
2244
|
+
typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: Content }),
|
2245
|
+
typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
|
2246
|
+
] }) });
|
2247
|
+
};
|
2248
|
+
const transformData = (data) => {
|
2249
|
+
if (Array.isArray(data)) {
|
2250
|
+
return data.map(transformData);
|
2251
|
+
}
|
2252
|
+
if (typeof data === "object" && data !== null) {
|
2253
|
+
if ("apiData" in data) {
|
2254
|
+
return data.apiData;
|
2255
|
+
}
|
2256
|
+
return mapValues__default.default(transformData)(data);
|
2257
|
+
}
|
2258
|
+
return data;
|
1605
2259
|
};
|
1606
|
-
const PublishAction = ({
|
2260
|
+
const PublishAction$1 = ({
|
1607
2261
|
activeTab,
|
1608
2262
|
documentId,
|
1609
2263
|
model,
|
@@ -1615,13 +2269,18 @@ const PublishAction = ({
|
|
1615
2269
|
const navigate = reactRouterDom.useNavigate();
|
1616
2270
|
const { toggleNotification } = strapiAdmin.useNotification();
|
1617
2271
|
const { _unstableFormatValidationErrors: formatValidationErrors } = strapiAdmin.useAPIErrorHandler();
|
2272
|
+
const isListView = reactRouterDom.useMatch(LIST_PATH) !== null;
|
1618
2273
|
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2274
|
+
const { id } = reactRouterDom.useParams();
|
1619
2275
|
const { formatMessage } = reactIntl.useIntl();
|
1620
|
-
const { canPublish
|
1621
|
-
"PublishAction",
|
1622
|
-
({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
|
1623
|
-
);
|
2276
|
+
const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
|
1624
2277
|
const { publish } = useDocumentActions();
|
2278
|
+
const [
|
2279
|
+
countDraftRelations,
|
2280
|
+
{ isLoading: isLoadingDraftRelations, isError: isErrorDraftRelations }
|
2281
|
+
] = useLazyGetDraftRelationCountQuery();
|
2282
|
+
const [localCountOfDraftRelations, setLocalCountOfDraftRelations] = React__namespace.useState(0);
|
2283
|
+
const [serverCountOfDraftRelations, setServerCountOfDraftRelations] = React__namespace.useState(0);
|
1625
2284
|
const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
|
1626
2285
|
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
1627
2286
|
const modified = strapiAdmin.useForm("PublishAction", ({ modified: modified2 }) => modified2);
|
@@ -1630,10 +2289,107 @@ const PublishAction = ({
|
|
1630
2289
|
const validate = strapiAdmin.useForm("PublishAction", (state) => state.validate);
|
1631
2290
|
const setErrors = strapiAdmin.useForm("PublishAction", (state) => state.setErrors);
|
1632
2291
|
const formValues = strapiAdmin.useForm("PublishAction", ({ values }) => values);
|
2292
|
+
React__namespace.useEffect(() => {
|
2293
|
+
if (isErrorDraftRelations) {
|
2294
|
+
toggleNotification({
|
2295
|
+
type: "danger",
|
2296
|
+
message: formatMessage({
|
2297
|
+
id: getTranslation("error.records.fetch-draft-relatons"),
|
2298
|
+
defaultMessage: "An error occurred while fetching draft relations on this document."
|
2299
|
+
})
|
2300
|
+
});
|
2301
|
+
}
|
2302
|
+
}, [isErrorDraftRelations, toggleNotification, formatMessage]);
|
2303
|
+
React__namespace.useEffect(() => {
|
2304
|
+
const localDraftRelations = /* @__PURE__ */ new Set();
|
2305
|
+
const extractDraftRelations = (data) => {
|
2306
|
+
const relations = data.connect || [];
|
2307
|
+
relations.forEach((relation) => {
|
2308
|
+
if (relation.status === "draft") {
|
2309
|
+
localDraftRelations.add(relation.id);
|
2310
|
+
}
|
2311
|
+
});
|
2312
|
+
};
|
2313
|
+
const traverseAndExtract = (data) => {
|
2314
|
+
Object.entries(data).forEach(([key, value]) => {
|
2315
|
+
if (key === "connect" && Array.isArray(value)) {
|
2316
|
+
extractDraftRelations({ connect: value });
|
2317
|
+
} else if (typeof value === "object" && value !== null) {
|
2318
|
+
traverseAndExtract(value);
|
2319
|
+
}
|
2320
|
+
});
|
2321
|
+
};
|
2322
|
+
if (!documentId || modified) {
|
2323
|
+
traverseAndExtract(formValues);
|
2324
|
+
setLocalCountOfDraftRelations(localDraftRelations.size);
|
2325
|
+
}
|
2326
|
+
}, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
|
2327
|
+
React__namespace.useEffect(() => {
|
2328
|
+
if (!document || !document.documentId || isListView) {
|
2329
|
+
return;
|
2330
|
+
}
|
2331
|
+
const fetchDraftRelationsCount = async () => {
|
2332
|
+
const { data, error } = await countDraftRelations({
|
2333
|
+
collectionType,
|
2334
|
+
model,
|
2335
|
+
documentId,
|
2336
|
+
params
|
2337
|
+
});
|
2338
|
+
if (error) {
|
2339
|
+
throw error;
|
2340
|
+
}
|
2341
|
+
if (data) {
|
2342
|
+
setServerCountOfDraftRelations(data.data);
|
2343
|
+
}
|
2344
|
+
};
|
2345
|
+
fetchDraftRelationsCount();
|
2346
|
+
}, [isListView, document, documentId, countDraftRelations, collectionType, model, params]);
|
1633
2347
|
const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
|
1634
2348
|
if (!schema?.options?.draftAndPublish) {
|
1635
2349
|
return null;
|
1636
2350
|
}
|
2351
|
+
const performPublish = async () => {
|
2352
|
+
setSubmitting(true);
|
2353
|
+
try {
|
2354
|
+
const { errors } = await validate(true, {
|
2355
|
+
status: "published"
|
2356
|
+
});
|
2357
|
+
if (errors) {
|
2358
|
+
toggleNotification({
|
2359
|
+
type: "danger",
|
2360
|
+
message: formatMessage({
|
2361
|
+
id: "content-manager.validation.error",
|
2362
|
+
defaultMessage: "There are validation errors in your document. Please fix them before saving."
|
2363
|
+
})
|
2364
|
+
});
|
2365
|
+
return;
|
2366
|
+
}
|
2367
|
+
const res = await publish(
|
2368
|
+
{
|
2369
|
+
collectionType,
|
2370
|
+
model,
|
2371
|
+
documentId,
|
2372
|
+
params
|
2373
|
+
},
|
2374
|
+
transformData(formValues)
|
2375
|
+
);
|
2376
|
+
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
2377
|
+
if (id === "create") {
|
2378
|
+
navigate({
|
2379
|
+
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
2380
|
+
search: rawQuery
|
2381
|
+
});
|
2382
|
+
}
|
2383
|
+
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2384
|
+
setErrors(formatValidationErrors(res.error));
|
2385
|
+
}
|
2386
|
+
} finally {
|
2387
|
+
setSubmitting(false);
|
2388
|
+
}
|
2389
|
+
};
|
2390
|
+
const totalDraftRelations = localCountOfDraftRelations + serverCountOfDraftRelations;
|
2391
|
+
const enableDraftRelationsCount = false;
|
2392
|
+
const hasDraftRelations = enableDraftRelationsCount;
|
1637
2393
|
return {
|
1638
2394
|
/**
|
1639
2395
|
* Disabled when:
|
@@ -1643,52 +2399,40 @@ const PublishAction = ({
|
|
1643
2399
|
* - the document is already published & not modified
|
1644
2400
|
* - the document is being created & not modified
|
1645
2401
|
* - the user doesn't have the permission to publish
|
1646
|
-
* - the user doesn't have the permission to create a new document
|
1647
|
-
* - the user doesn't have the permission to update the document
|
1648
2402
|
*/
|
1649
|
-
disabled: isCloning || isSubmitting || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish
|
2403
|
+
disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish,
|
1650
2404
|
label: formatMessage({
|
1651
2405
|
id: "app.utils.publish",
|
1652
2406
|
defaultMessage: "Publish"
|
1653
2407
|
}),
|
1654
2408
|
onClick: async () => {
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1670
|
-
|
1671
|
-
|
1672
|
-
documentId,
|
1673
|
-
params
|
1674
|
-
},
|
1675
|
-
formValues
|
1676
|
-
);
|
1677
|
-
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1678
|
-
navigate({
|
1679
|
-
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
1680
|
-
search: rawQuery
|
1681
|
-
});
|
1682
|
-
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1683
|
-
setErrors(formatValidationErrors(res.error));
|
2409
|
+
await performPublish();
|
2410
|
+
},
|
2411
|
+
dialog: hasDraftRelations ? {
|
2412
|
+
type: "dialog",
|
2413
|
+
variant: "danger",
|
2414
|
+
footer: null,
|
2415
|
+
title: formatMessage({
|
2416
|
+
id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.title`),
|
2417
|
+
defaultMessage: "Confirmation"
|
2418
|
+
}),
|
2419
|
+
content: formatMessage(
|
2420
|
+
{
|
2421
|
+
id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.message`),
|
2422
|
+
defaultMessage: "This entry is related to {count, plural, one {# draft entry} other {# draft entries}}. Publishing it could leave broken links in your app."
|
2423
|
+
},
|
2424
|
+
{
|
2425
|
+
count: totalDraftRelations
|
1684
2426
|
}
|
1685
|
-
|
1686
|
-
|
2427
|
+
),
|
2428
|
+
onConfirm: async () => {
|
2429
|
+
await performPublish();
|
1687
2430
|
}
|
1688
|
-
}
|
2431
|
+
} : void 0
|
1689
2432
|
};
|
1690
2433
|
};
|
1691
|
-
PublishAction.type = "publish";
|
2434
|
+
PublishAction$1.type = "publish";
|
2435
|
+
PublishAction$1.position = "panel";
|
1692
2436
|
const UpdateAction = ({
|
1693
2437
|
activeTab,
|
1694
2438
|
documentId,
|
@@ -1701,10 +2445,6 @@ const UpdateAction = ({
|
|
1701
2445
|
const cloneMatch = reactRouterDom.useMatch(CLONE_PATH);
|
1702
2446
|
const isCloning = cloneMatch !== null;
|
1703
2447
|
const { formatMessage } = reactIntl.useIntl();
|
1704
|
-
const { canCreate, canUpdate } = useDocumentRBAC("UpdateAction", ({ canCreate: canCreate2, canUpdate: canUpdate2 }) => ({
|
1705
|
-
canCreate: canCreate2,
|
1706
|
-
canUpdate: canUpdate2
|
1707
|
-
}));
|
1708
2448
|
const { create, update, clone } = useDocumentActions();
|
1709
2449
|
const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
|
1710
2450
|
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
@@ -1715,95 +2455,139 @@ const UpdateAction = ({
|
|
1715
2455
|
const validate = strapiAdmin.useForm("UpdateAction", (state) => state.validate);
|
1716
2456
|
const setErrors = strapiAdmin.useForm("UpdateAction", (state) => state.setErrors);
|
1717
2457
|
const resetForm = strapiAdmin.useForm("PublishAction", ({ resetForm: resetForm2 }) => resetForm2);
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
}
|
1744
|
-
|
1745
|
-
|
1746
|
-
if (
|
1747
|
-
|
2458
|
+
const handleUpdate = React__namespace.useCallback(async () => {
|
2459
|
+
setSubmitting(true);
|
2460
|
+
try {
|
2461
|
+
if (!modified) {
|
2462
|
+
return;
|
2463
|
+
}
|
2464
|
+
const { errors } = await validate(true, {
|
2465
|
+
status: "draft"
|
2466
|
+
});
|
2467
|
+
if (errors) {
|
2468
|
+
toggleNotification({
|
2469
|
+
type: "danger",
|
2470
|
+
message: formatMessage({
|
2471
|
+
id: "content-manager.validation.error",
|
2472
|
+
defaultMessage: "There are validation errors in your document. Please fix them before saving."
|
2473
|
+
})
|
2474
|
+
});
|
2475
|
+
return;
|
2476
|
+
}
|
2477
|
+
if (isCloning) {
|
2478
|
+
const res = await clone(
|
2479
|
+
{
|
2480
|
+
model,
|
2481
|
+
documentId: cloneMatch.params.origin,
|
2482
|
+
params
|
2483
|
+
},
|
2484
|
+
transformData(document)
|
2485
|
+
);
|
2486
|
+
if ("data" in res) {
|
2487
|
+
navigate(
|
1748
2488
|
{
|
1749
|
-
|
1750
|
-
documentId: cloneMatch.params.origin,
|
1751
|
-
params
|
1752
|
-
},
|
1753
|
-
document
|
1754
|
-
);
|
1755
|
-
if ("data" in res) {
|
1756
|
-
navigate({
|
1757
|
-
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
2489
|
+
pathname: `../${res.data.documentId}`,
|
1758
2490
|
search: rawQuery
|
1759
|
-
});
|
1760
|
-
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1761
|
-
setErrors(formatValidationErrors(res.error));
|
1762
|
-
}
|
1763
|
-
} else if (documentId || collectionType === SINGLE_TYPES) {
|
1764
|
-
const res = await update(
|
1765
|
-
{
|
1766
|
-
collectionType,
|
1767
|
-
model,
|
1768
|
-
documentId,
|
1769
|
-
params
|
1770
2491
|
},
|
1771
|
-
|
2492
|
+
{ relative: "path" }
|
1772
2493
|
);
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
2494
|
+
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2495
|
+
setErrors(formatValidationErrors(res.error));
|
2496
|
+
}
|
2497
|
+
} else if (documentId || collectionType === SINGLE_TYPES) {
|
2498
|
+
const res = await update(
|
2499
|
+
{
|
2500
|
+
collectionType,
|
2501
|
+
model,
|
2502
|
+
documentId,
|
2503
|
+
params
|
2504
|
+
},
|
2505
|
+
transformData(document)
|
2506
|
+
);
|
2507
|
+
if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2508
|
+
setErrors(formatValidationErrors(res.error));
|
1778
2509
|
} else {
|
1779
|
-
|
2510
|
+
resetForm();
|
2511
|
+
}
|
2512
|
+
} else {
|
2513
|
+
const res = await create(
|
2514
|
+
{
|
2515
|
+
model,
|
2516
|
+
params
|
2517
|
+
},
|
2518
|
+
transformData(document)
|
2519
|
+
);
|
2520
|
+
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
2521
|
+
navigate(
|
1780
2522
|
{
|
1781
|
-
|
1782
|
-
|
2523
|
+
pathname: `../${res.data.documentId}`,
|
2524
|
+
search: rawQuery
|
1783
2525
|
},
|
1784
|
-
|
2526
|
+
{ replace: true, relative: "path" }
|
1785
2527
|
);
|
1786
|
-
|
1787
|
-
|
1788
|
-
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
1789
|
-
search: rawQuery
|
1790
|
-
});
|
1791
|
-
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1792
|
-
setErrors(formatValidationErrors(res.error));
|
1793
|
-
}
|
2528
|
+
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2529
|
+
setErrors(formatValidationErrors(res.error));
|
1794
2530
|
}
|
1795
|
-
} finally {
|
1796
|
-
setSubmitting(false);
|
1797
2531
|
}
|
2532
|
+
} finally {
|
2533
|
+
setSubmitting(false);
|
1798
2534
|
}
|
2535
|
+
}, [
|
2536
|
+
clone,
|
2537
|
+
cloneMatch?.params.origin,
|
2538
|
+
collectionType,
|
2539
|
+
create,
|
2540
|
+
document,
|
2541
|
+
documentId,
|
2542
|
+
formatMessage,
|
2543
|
+
formatValidationErrors,
|
2544
|
+
isCloning,
|
2545
|
+
model,
|
2546
|
+
modified,
|
2547
|
+
navigate,
|
2548
|
+
params,
|
2549
|
+
rawQuery,
|
2550
|
+
resetForm,
|
2551
|
+
setErrors,
|
2552
|
+
setSubmitting,
|
2553
|
+
toggleNotification,
|
2554
|
+
update,
|
2555
|
+
validate
|
2556
|
+
]);
|
2557
|
+
React__namespace.useEffect(() => {
|
2558
|
+
const handleKeyDown = (e) => {
|
2559
|
+
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
|
2560
|
+
e.preventDefault();
|
2561
|
+
handleUpdate();
|
2562
|
+
}
|
2563
|
+
};
|
2564
|
+
window.addEventListener("keydown", handleKeyDown);
|
2565
|
+
return () => {
|
2566
|
+
window.removeEventListener("keydown", handleKeyDown);
|
2567
|
+
};
|
2568
|
+
}, [handleUpdate]);
|
2569
|
+
return {
|
2570
|
+
/**
|
2571
|
+
* Disabled when:
|
2572
|
+
* - the form is submitting
|
2573
|
+
* - the document is not modified & we're not cloning (you can save a clone entity straight away)
|
2574
|
+
* - the active tab is the published tab
|
2575
|
+
*/
|
2576
|
+
disabled: isSubmitting || !modified && !isCloning || activeTab === "published",
|
2577
|
+
label: formatMessage({
|
2578
|
+
id: "global.save",
|
2579
|
+
defaultMessage: "Save"
|
2580
|
+
}),
|
2581
|
+
onClick: handleUpdate
|
1799
2582
|
};
|
1800
2583
|
};
|
1801
2584
|
UpdateAction.type = "update";
|
2585
|
+
UpdateAction.position = "panel";
|
1802
2586
|
const UNPUBLISH_DRAFT_OPTIONS = {
|
1803
2587
|
KEEP: "keep",
|
1804
2588
|
DISCARD: "discard"
|
1805
2589
|
};
|
1806
|
-
const UnpublishAction = ({
|
2590
|
+
const UnpublishAction$1 = ({
|
1807
2591
|
activeTab,
|
1808
2592
|
documentId,
|
1809
2593
|
model,
|
@@ -1819,10 +2603,8 @@ const UnpublishAction = ({
|
|
1819
2603
|
const { toggleNotification } = strapiAdmin.useNotification();
|
1820
2604
|
const [shouldKeepDraft, setShouldKeepDraft] = React__namespace.useState(true);
|
1821
2605
|
const isDocumentModified = document?.status === "modified";
|
1822
|
-
const handleChange = (
|
1823
|
-
|
1824
|
-
setShouldKeepDraft(e.target.value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
|
1825
|
-
}
|
2606
|
+
const handleChange = (value) => {
|
2607
|
+
setShouldKeepDraft(value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
|
1826
2608
|
};
|
1827
2609
|
if (!schema?.options?.draftAndPublish) {
|
1828
2610
|
return null;
|
@@ -1833,7 +2615,7 @@ const UnpublishAction = ({
|
|
1833
2615
|
id: "app.utils.unpublish",
|
1834
2616
|
defaultMessage: "Unpublish"
|
1835
2617
|
}),
|
1836
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
2618
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
|
1837
2619
|
onClick: async () => {
|
1838
2620
|
if (!documentId && collectionType !== SINGLE_TYPES || isDocumentModified) {
|
1839
2621
|
if (!documentId) {
|
@@ -1866,45 +2648,30 @@ const UnpublishAction = ({
|
|
1866
2648
|
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { alignItems: "flex-start", direction: "column", gap: 6, children: [
|
1867
2649
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", direction: "column", gap: 2, children: [
|
1868
2650
|
/* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
|
1869
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, {
|
2651
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
|
1870
2652
|
id: "content-manager.actions.unpublish.dialog.body",
|
1871
2653
|
defaultMessage: "Are you sure?"
|
1872
2654
|
}) })
|
1873
2655
|
] }),
|
1874
2656
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
1875
|
-
designSystem.
|
2657
|
+
designSystem.Radio.Group,
|
1876
2658
|
{
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
1881
|
-
|
2659
|
+
defaultValue: UNPUBLISH_DRAFT_OPTIONS.KEEP,
|
2660
|
+
name: "discard-options",
|
2661
|
+
"aria-label": formatMessage({
|
2662
|
+
id: "content-manager.actions.unpublish.dialog.radio-label",
|
2663
|
+
defaultMessage: "Choose an option to unpublish the document."
|
2664
|
+
}),
|
2665
|
+
onValueChange: handleChange,
|
1882
2666
|
children: [
|
1883
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
1884
|
-
|
1885
|
-
|
1886
|
-
|
1887
|
-
|
1888
|
-
|
1889
|
-
|
1890
|
-
|
1891
|
-
id: "content-manager.actions.unpublish.dialog.option.keep-draft",
|
1892
|
-
defaultMessage: "Keep draft"
|
1893
|
-
})
|
1894
|
-
}
|
1895
|
-
),
|
1896
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
1897
|
-
designSystem.Radio,
|
1898
|
-
{
|
1899
|
-
checked: !shouldKeepDraft,
|
1900
|
-
value: UNPUBLISH_DRAFT_OPTIONS.DISCARD,
|
1901
|
-
name: "discard-options",
|
1902
|
-
children: formatMessage({
|
1903
|
-
id: "content-manager.actions.unpublish.dialog.option.replace-draft",
|
1904
|
-
defaultMessage: "Replace draft"
|
1905
|
-
})
|
1906
|
-
}
|
1907
|
-
)
|
2667
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Radio.Item, { checked: shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.KEEP, children: formatMessage({
|
2668
|
+
id: "content-manager.actions.unpublish.dialog.option.keep-draft",
|
2669
|
+
defaultMessage: "Keep draft"
|
2670
|
+
}) }),
|
2671
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Radio.Item, { checked: !shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.DISCARD, children: formatMessage({
|
2672
|
+
id: "content-manager.actions.unpublish.dialog.option.replace-draft",
|
2673
|
+
defaultMessage: "Replace draft"
|
2674
|
+
}) })
|
1908
2675
|
]
|
1909
2676
|
}
|
1910
2677
|
)
|
@@ -1937,7 +2704,8 @@ const UnpublishAction = ({
|
|
1937
2704
|
position: ["panel", "table-row"]
|
1938
2705
|
};
|
1939
2706
|
};
|
1940
|
-
UnpublishAction.type = "unpublish";
|
2707
|
+
UnpublishAction$1.type = "unpublish";
|
2708
|
+
UnpublishAction$1.position = "panel";
|
1941
2709
|
const DiscardAction = ({
|
1942
2710
|
activeTab,
|
1943
2711
|
documentId,
|
@@ -1960,7 +2728,7 @@ const DiscardAction = ({
|
|
1960
2728
|
id: "content-manager.actions.discard.label",
|
1961
2729
|
defaultMessage: "Discard changes"
|
1962
2730
|
}),
|
1963
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
2731
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
|
1964
2732
|
position: ["panel", "table-row"],
|
1965
2733
|
variant: "danger",
|
1966
2734
|
dialog: {
|
@@ -1971,7 +2739,7 @@ const DiscardAction = ({
|
|
1971
2739
|
}),
|
1972
2740
|
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
|
1973
2741
|
/* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
|
1974
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, {
|
2742
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
|
1975
2743
|
id: "content-manager.actions.discard.dialog.body",
|
1976
2744
|
defaultMessage: "Are you sure?"
|
1977
2745
|
}) })
|
@@ -1988,12 +2756,8 @@ const DiscardAction = ({
|
|
1988
2756
|
};
|
1989
2757
|
};
|
1990
2758
|
DiscardAction.type = "discard";
|
1991
|
-
|
1992
|
-
|
1993
|
-
fill: currentColor;
|
1994
|
-
}
|
1995
|
-
`;
|
1996
|
-
const DEFAULT_ACTIONS = [PublishAction, UpdateAction, UnpublishAction, DiscardAction];
|
2759
|
+
DiscardAction.position = "panel";
|
2760
|
+
const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
|
1997
2761
|
const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
|
1998
2762
|
const RelativeTime = React__namespace.forwardRef(
|
1999
2763
|
({ timestamp, customIntervals = [], ...restProps }, forwardedRef) => {
|
@@ -2005,7 +2769,7 @@ const RelativeTime = React__namespace.forwardRef(
|
|
2005
2769
|
});
|
2006
2770
|
const unit = intervals.find((intervalUnit) => {
|
2007
2771
|
return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
|
2008
|
-
});
|
2772
|
+
}) ?? "seconds";
|
2009
2773
|
const relativeTime = dateFns.isPast(timestamp) ? -interval[unit] : interval[unit];
|
2010
2774
|
const customInterval = customIntervals.find(
|
2011
2775
|
(custom) => interval[custom.unit] < custom.threshold
|
@@ -2039,34 +2803,34 @@ const getDisplayName = ({
|
|
2039
2803
|
return email ?? "";
|
2040
2804
|
};
|
2041
2805
|
const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
2042
|
-
const DocumentStatus = ({ status = "draft", ...restProps }) => {
|
2043
|
-
const statusVariant = status === "draft" ? "
|
2044
|
-
|
2806
|
+
const DocumentStatus = ({ status = "draft", size = "S", ...restProps }) => {
|
2807
|
+
const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
|
2808
|
+
const { formatMessage } = reactIntl.useIntl();
|
2809
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Status, { ...restProps, size, variant: statusVariant, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: formatMessage({
|
2810
|
+
id: `content-manager.containers.List.${status}`,
|
2811
|
+
defaultMessage: capitalise(status)
|
2812
|
+
}) }) });
|
2045
2813
|
};
|
2046
2814
|
const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
2047
2815
|
const { formatMessage } = reactIntl.useIntl();
|
2048
2816
|
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2817
|
+
const params = reactRouterDom.useParams();
|
2049
2818
|
const title = isCreating ? formatMessage({
|
2050
2819
|
id: "content-manager.containers.edit.title.new",
|
2051
2820
|
defaultMessage: "Create an entry"
|
2052
2821
|
}) : documentTitle;
|
2053
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop:
|
2054
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
2055
|
-
|
2056
|
-
designSystem.Flex,
|
2822
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
|
2823
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
2824
|
+
strapiAdmin.BackButton,
|
2057
2825
|
{
|
2058
|
-
|
2059
|
-
justifyContent: "space-between",
|
2060
|
-
paddingTop: 1,
|
2061
|
-
gap: "80px",
|
2062
|
-
alignItems: "flex-start",
|
2063
|
-
children: [
|
2064
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", as: "h1", children: title }),
|
2065
|
-
/* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
|
2066
|
-
]
|
2826
|
+
fallback: params.collectionType === SINGLE_TYPES ? void 0 : `../${COLLECTION_TYPES}/${params.slug}`
|
2067
2827
|
}
|
2068
2828
|
),
|
2069
|
-
|
2829
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
|
2830
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
|
2831
|
+
/* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
|
2832
|
+
] }),
|
2833
|
+
status ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(DocumentStatus, { status: isCloning ? "draft" : status }) }) : null
|
2070
2834
|
] });
|
2071
2835
|
};
|
2072
2836
|
const HeaderToolbar = () => {
|
@@ -2112,7 +2876,7 @@ const HeaderToolbar = () => {
|
|
2112
2876
|
meta: isCloning ? void 0 : meta,
|
2113
2877
|
collectionType
|
2114
2878
|
},
|
2115
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
2879
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions("header"),
|
2116
2880
|
children: (actions2) => {
|
2117
2881
|
const headerActions = actions2.filter((action) => {
|
2118
2882
|
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
@@ -2149,12 +2913,12 @@ const Information = ({ activeTab }) => {
|
|
2149
2913
|
isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
|
2150
2914
|
label: formatMessage({
|
2151
2915
|
id: "content-manager.containers.edit.information.last-published.label",
|
2152
|
-
defaultMessage: "
|
2916
|
+
defaultMessage: "Published"
|
2153
2917
|
}),
|
2154
2918
|
value: formatMessage(
|
2155
2919
|
{
|
2156
2920
|
id: "content-manager.containers.edit.information.last-published.value",
|
2157
|
-
defaultMessage: `
|
2921
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2158
2922
|
},
|
2159
2923
|
{
|
2160
2924
|
time: /* @__PURE__ */ jsxRuntime.jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
|
@@ -2167,12 +2931,12 @@ const Information = ({ activeTab }) => {
|
|
2167
2931
|
isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
|
2168
2932
|
label: formatMessage({
|
2169
2933
|
id: "content-manager.containers.edit.information.last-draft.label",
|
2170
|
-
defaultMessage: "
|
2934
|
+
defaultMessage: "Updated"
|
2171
2935
|
}),
|
2172
2936
|
value: formatMessage(
|
2173
2937
|
{
|
2174
2938
|
id: "content-manager.containers.edit.information.last-draft.value",
|
2175
|
-
defaultMessage: `
|
2939
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2176
2940
|
},
|
2177
2941
|
{
|
2178
2942
|
time: /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -2190,12 +2954,12 @@ const Information = ({ activeTab }) => {
|
|
2190
2954
|
isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
|
2191
2955
|
label: formatMessage({
|
2192
2956
|
id: "content-manager.containers.edit.information.document.label",
|
2193
|
-
defaultMessage: "
|
2957
|
+
defaultMessage: "Created"
|
2194
2958
|
}),
|
2195
2959
|
value: formatMessage(
|
2196
2960
|
{
|
2197
2961
|
id: "content-manager.containers.edit.information.document.value",
|
2198
|
-
defaultMessage: `
|
2962
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2199
2963
|
},
|
2200
2964
|
{
|
2201
2965
|
time: /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -2218,7 +2982,7 @@ const Information = ({ activeTab }) => {
|
|
2218
2982
|
borderColor: "neutral150",
|
2219
2983
|
direction: "column",
|
2220
2984
|
marginTop: 2,
|
2221
|
-
|
2985
|
+
tag: "dl",
|
2222
2986
|
padding: 5,
|
2223
2987
|
gap: 3,
|
2224
2988
|
alignItems: "flex-start",
|
@@ -2226,31 +2990,83 @@ const Information = ({ activeTab }) => {
|
|
2226
2990
|
marginRight: "-0.4rem",
|
2227
2991
|
width: "calc(100% + 8px)",
|
2228
2992
|
children: information.map((info) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 1, direction: "column", alignItems: "flex-start", children: [
|
2229
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, {
|
2230
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, {
|
2993
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "dt", variant: "pi", fontWeight: "bold", children: info.label }),
|
2994
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "dd", variant: "pi", textColor: "neutral600", children: info.value })
|
2231
2995
|
] }, info.label))
|
2232
2996
|
}
|
2233
2997
|
);
|
2234
2998
|
};
|
2235
2999
|
const HeaderActions = ({ actions: actions2 }) => {
|
2236
|
-
|
2237
|
-
|
3000
|
+
const [dialogId, setDialogId] = React__namespace.useState(null);
|
3001
|
+
const handleClick = (action) => async (e) => {
|
3002
|
+
if (!("options" in action)) {
|
3003
|
+
const { onClick = () => false, dialog, id } = action;
|
3004
|
+
const muteDialog = await onClick(e);
|
3005
|
+
if (dialog && !muteDialog) {
|
3006
|
+
e.preventDefault();
|
3007
|
+
setDialogId(id);
|
3008
|
+
}
|
3009
|
+
}
|
3010
|
+
};
|
3011
|
+
const handleClose = () => {
|
3012
|
+
setDialogId(null);
|
3013
|
+
};
|
3014
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 1, children: actions2.map((action) => {
|
3015
|
+
if (action.options) {
|
2238
3016
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
2239
3017
|
designSystem.SingleSelect,
|
2240
3018
|
{
|
2241
3019
|
size: "S",
|
2242
|
-
disabled: action.disabled,
|
2243
|
-
"aria-label": action.label,
|
2244
3020
|
onChange: action.onSelect,
|
2245
|
-
|
3021
|
+
"aria-label": action.label,
|
3022
|
+
...action,
|
2246
3023
|
children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { ...option, children: label }, option.value))
|
2247
3024
|
},
|
2248
3025
|
action.id
|
2249
3026
|
);
|
2250
3027
|
} else {
|
2251
|
-
|
3028
|
+
if (action.type === "icon") {
|
3029
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
|
3030
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
3031
|
+
designSystem.IconButton,
|
3032
|
+
{
|
3033
|
+
disabled: action.disabled,
|
3034
|
+
label: action.label,
|
3035
|
+
size: "S",
|
3036
|
+
onClick: handleClick(action),
|
3037
|
+
children: action.icon
|
3038
|
+
}
|
3039
|
+
),
|
3040
|
+
action.dialog ? /* @__PURE__ */ jsxRuntime.jsx(
|
3041
|
+
HeaderActionDialog,
|
3042
|
+
{
|
3043
|
+
...action.dialog,
|
3044
|
+
isOpen: dialogId === action.id,
|
3045
|
+
onClose: handleClose
|
3046
|
+
}
|
3047
|
+
) : null
|
3048
|
+
] }, action.id);
|
3049
|
+
}
|
3050
|
+
}
|
3051
|
+
}) });
|
3052
|
+
};
|
3053
|
+
const HeaderActionDialog = ({
|
3054
|
+
onClose,
|
3055
|
+
onCancel,
|
3056
|
+
title,
|
3057
|
+
content: Content,
|
3058
|
+
isOpen
|
3059
|
+
}) => {
|
3060
|
+
const handleClose = async () => {
|
3061
|
+
if (onCancel) {
|
3062
|
+
await onCancel();
|
2252
3063
|
}
|
2253
|
-
|
3064
|
+
onClose();
|
3065
|
+
};
|
3066
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
3067
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
|
3068
|
+
typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : Content
|
3069
|
+
] }) });
|
2254
3070
|
};
|
2255
3071
|
const ConfigureTheViewAction = ({ collectionType, model }) => {
|
2256
3072
|
const navigate = reactRouterDom.useNavigate();
|
@@ -2260,7 +3076,7 @@ const ConfigureTheViewAction = ({ collectionType, model }) => {
|
|
2260
3076
|
id: "app.links.configure-view",
|
2261
3077
|
defaultMessage: "Configure the view"
|
2262
3078
|
}),
|
2263
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
3079
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ListPlus, {}),
|
2264
3080
|
onClick: () => {
|
2265
3081
|
navigate(`../${collectionType}/${model}/configurations/edit`);
|
2266
3082
|
},
|
@@ -2268,11 +3084,7 @@ const ConfigureTheViewAction = ({ collectionType, model }) => {
|
|
2268
3084
|
};
|
2269
3085
|
};
|
2270
3086
|
ConfigureTheViewAction.type = "configure-the-view";
|
2271
|
-
|
2272
|
-
path {
|
2273
|
-
fill: currentColor;
|
2274
|
-
}
|
2275
|
-
`;
|
3087
|
+
ConfigureTheViewAction.position = "header";
|
2276
3088
|
const EditTheModelAction = ({ model }) => {
|
2277
3089
|
const navigate = reactRouterDom.useNavigate();
|
2278
3090
|
const { formatMessage } = reactIntl.useIntl();
|
@@ -2281,7 +3093,7 @@ const EditTheModelAction = ({ model }) => {
|
|
2281
3093
|
id: "content-manager.link-to-ctb",
|
2282
3094
|
defaultMessage: "Edit the model"
|
2283
3095
|
}),
|
2284
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
3096
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, {}),
|
2285
3097
|
onClick: () => {
|
2286
3098
|
navigate(`/plugins/content-type-builder/content-types/${model}`);
|
2287
3099
|
},
|
@@ -2289,12 +3101,8 @@ const EditTheModelAction = ({ model }) => {
|
|
2289
3101
|
};
|
2290
3102
|
};
|
2291
3103
|
EditTheModelAction.type = "edit-the-model";
|
2292
|
-
|
2293
|
-
|
2294
|
-
fill: currentColor;
|
2295
|
-
}
|
2296
|
-
`;
|
2297
|
-
const DeleteAction = ({ documentId, model, collectionType, document }) => {
|
3104
|
+
EditTheModelAction.position = "header";
|
3105
|
+
const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
2298
3106
|
const navigate = reactRouterDom.useNavigate();
|
2299
3107
|
const { formatMessage } = reactIntl.useIntl();
|
2300
3108
|
const listViewPathMatch = reactRouterDom.useMatch(LIST_PATH);
|
@@ -2302,13 +3110,17 @@ const DeleteAction = ({ documentId, model, collectionType, document }) => {
|
|
2302
3110
|
const { delete: deleteAction } = useDocumentActions();
|
2303
3111
|
const { toggleNotification } = strapiAdmin.useNotification();
|
2304
3112
|
const setSubmitting = strapiAdmin.useForm("DeleteAction", (state) => state.setSubmitting);
|
3113
|
+
const isLocalized = document?.locale != null;
|
2305
3114
|
return {
|
2306
3115
|
disabled: !canDelete || !document,
|
2307
|
-
label: formatMessage(
|
2308
|
-
|
2309
|
-
|
2310
|
-
|
2311
|
-
|
3116
|
+
label: formatMessage(
|
3117
|
+
{
|
3118
|
+
id: "content-manager.actions.delete.label",
|
3119
|
+
defaultMessage: "Delete entry{isLocalized, select, true { (all locales)} other {}}"
|
3120
|
+
},
|
3121
|
+
{ isLocalized }
|
3122
|
+
),
|
3123
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}),
|
2312
3124
|
dialog: {
|
2313
3125
|
type: "dialog",
|
2314
3126
|
title: formatMessage({
|
@@ -2317,7 +3129,7 @@ const DeleteAction = ({ documentId, model, collectionType, document }) => {
|
|
2317
3129
|
}),
|
2318
3130
|
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
|
2319
3131
|
/* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
|
2320
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, {
|
3132
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
|
2321
3133
|
id: "content-manager.actions.delete.dialog.body",
|
2322
3134
|
defaultMessage: "Are you sure?"
|
2323
3135
|
}) })
|
@@ -2357,113 +3169,741 @@ const DeleteAction = ({ documentId, model, collectionType, document }) => {
|
|
2357
3169
|
}
|
2358
3170
|
}
|
2359
3171
|
}
|
2360
|
-
},
|
2361
|
-
variant: "danger",
|
2362
|
-
position: ["header", "table-row"]
|
2363
|
-
};
|
3172
|
+
},
|
3173
|
+
variant: "danger",
|
3174
|
+
position: ["header", "table-row"]
|
3175
|
+
};
|
3176
|
+
};
|
3177
|
+
DeleteAction$1.type = "delete";
|
3178
|
+
DeleteAction$1.position = ["header", "table-row"];
|
3179
|
+
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
|
3180
|
+
const Panels = () => {
|
3181
|
+
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
3182
|
+
const [
|
3183
|
+
{
|
3184
|
+
query: { status }
|
3185
|
+
}
|
3186
|
+
] = strapiAdmin.useQueryParams({
|
3187
|
+
status: "draft"
|
3188
|
+
});
|
3189
|
+
const { model, id, document, meta, collectionType } = useDoc();
|
3190
|
+
const plugins = strapiAdmin.useStrapiApp("Panels", (state) => state.plugins);
|
3191
|
+
const props = {
|
3192
|
+
activeTab: status,
|
3193
|
+
model,
|
3194
|
+
documentId: id,
|
3195
|
+
document: isCloning ? void 0 : document,
|
3196
|
+
meta: isCloning ? void 0 : meta,
|
3197
|
+
collectionType
|
3198
|
+
};
|
3199
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
3200
|
+
strapiAdmin.DescriptionComponentRenderer,
|
3201
|
+
{
|
3202
|
+
props,
|
3203
|
+
descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
|
3204
|
+
children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsxRuntime.jsx(Panel, { ...description, children: content }, id2))
|
3205
|
+
}
|
3206
|
+
) });
|
3207
|
+
};
|
3208
|
+
const ActionsPanel = () => {
|
3209
|
+
const { formatMessage } = reactIntl.useIntl();
|
3210
|
+
return {
|
3211
|
+
title: formatMessage({
|
3212
|
+
id: "content-manager.containers.edit.panels.default.title",
|
3213
|
+
defaultMessage: "Entry"
|
3214
|
+
}),
|
3215
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
|
3216
|
+
};
|
3217
|
+
};
|
3218
|
+
ActionsPanel.type = "actions";
|
3219
|
+
const ActionsPanelContent = () => {
|
3220
|
+
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
3221
|
+
const [
|
3222
|
+
{
|
3223
|
+
query: { status = "draft" }
|
3224
|
+
}
|
3225
|
+
] = strapiAdmin.useQueryParams();
|
3226
|
+
const { model, id, document, meta, collectionType } = useDoc();
|
3227
|
+
const plugins = strapiAdmin.useStrapiApp("ActionsPanel", (state) => state.plugins);
|
3228
|
+
const props = {
|
3229
|
+
activeTab: status,
|
3230
|
+
model,
|
3231
|
+
documentId: id,
|
3232
|
+
document: isCloning ? void 0 : document,
|
3233
|
+
meta: isCloning ? void 0 : meta,
|
3234
|
+
collectionType
|
3235
|
+
};
|
3236
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, width: "100%", children: [
|
3237
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
3238
|
+
strapiAdmin.DescriptionComponentRenderer,
|
3239
|
+
{
|
3240
|
+
props,
|
3241
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions("panel"),
|
3242
|
+
children: (actions2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActions, { actions: actions2 })
|
3243
|
+
}
|
3244
|
+
),
|
3245
|
+
/* @__PURE__ */ jsxRuntime.jsx(InjectionZone, { area: "editView.right-links", slug: model })
|
3246
|
+
] });
|
3247
|
+
};
|
3248
|
+
const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
|
3249
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
3250
|
+
designSystem.Flex,
|
3251
|
+
{
|
3252
|
+
ref,
|
3253
|
+
tag: "aside",
|
3254
|
+
"aria-labelledby": "additional-information",
|
3255
|
+
background: "neutral0",
|
3256
|
+
borderColor: "neutral150",
|
3257
|
+
hasRadius: true,
|
3258
|
+
paddingBottom: 4,
|
3259
|
+
paddingLeft: 4,
|
3260
|
+
paddingRight: 4,
|
3261
|
+
paddingTop: 4,
|
3262
|
+
shadow: "tableShadow",
|
3263
|
+
gap: 3,
|
3264
|
+
direction: "column",
|
3265
|
+
justifyContent: "stretch",
|
3266
|
+
alignItems: "flex-start",
|
3267
|
+
children: [
|
3268
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", textColor: "neutral600", children: title }),
|
3269
|
+
children
|
3270
|
+
]
|
3271
|
+
}
|
3272
|
+
);
|
3273
|
+
});
|
3274
|
+
const ConfirmBulkActionDialog = ({
|
3275
|
+
onToggleDialog,
|
3276
|
+
isOpen = false,
|
3277
|
+
dialogBody,
|
3278
|
+
endAction
|
3279
|
+
}) => {
|
3280
|
+
const { formatMessage } = reactIntl.useIntl();
|
3281
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
3282
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: formatMessage({
|
3283
|
+
id: "app.components.ConfirmDialog.title",
|
3284
|
+
defaultMessage: "Confirmation"
|
3285
|
+
}) }),
|
3286
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
3287
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
3288
|
+
dialogBody
|
3289
|
+
] }) }),
|
3290
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
|
3291
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { fullWidth: true, onClick: onToggleDialog, variant: "tertiary", children: formatMessage({
|
3292
|
+
id: "app.components.Button.cancel",
|
3293
|
+
defaultMessage: "Cancel"
|
3294
|
+
}) }) }),
|
3295
|
+
endAction
|
3296
|
+
] })
|
3297
|
+
] }) });
|
3298
|
+
};
|
3299
|
+
const BoldChunk = (chunks) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: chunks });
|
3300
|
+
const ConfirmDialogPublishAll = ({
|
3301
|
+
isOpen,
|
3302
|
+
onToggleDialog,
|
3303
|
+
isConfirmButtonLoading = false,
|
3304
|
+
onConfirm
|
3305
|
+
}) => {
|
3306
|
+
const { formatMessage } = reactIntl.useIntl();
|
3307
|
+
const selectedEntries = strapiAdmin.useTable("ConfirmDialogPublishAll", (state) => state.selectedRows);
|
3308
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
3309
|
+
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler(getTranslation);
|
3310
|
+
const { model, schema } = useDoc();
|
3311
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
3312
|
+
const enableDraftRelationsCount = false;
|
3313
|
+
const {
|
3314
|
+
data: countDraftRelations = 0,
|
3315
|
+
isLoading,
|
3316
|
+
error
|
3317
|
+
} = useGetManyDraftRelationCountQuery(
|
3318
|
+
{
|
3319
|
+
model,
|
3320
|
+
documentIds: selectedEntries.map((entry) => entry.documentId),
|
3321
|
+
locale: query?.plugins?.i18n?.locale
|
3322
|
+
},
|
3323
|
+
{
|
3324
|
+
skip: !enableDraftRelationsCount
|
3325
|
+
}
|
3326
|
+
);
|
3327
|
+
React__namespace.useEffect(() => {
|
3328
|
+
if (error) {
|
3329
|
+
toggleNotification({ type: "danger", message: formatAPIError(error) });
|
3330
|
+
}
|
3331
|
+
}, [error, formatAPIError, toggleNotification]);
|
3332
|
+
if (error) {
|
3333
|
+
return null;
|
3334
|
+
}
|
3335
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
3336
|
+
ConfirmBulkActionDialog,
|
3337
|
+
{
|
3338
|
+
isOpen: isOpen && !isLoading,
|
3339
|
+
onToggleDialog,
|
3340
|
+
dialogBody: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
3341
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { id: "confirm-description", textAlign: "center", children: [
|
3342
|
+
countDraftRelations > 0 && formatMessage(
|
3343
|
+
{
|
3344
|
+
id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.message`),
|
3345
|
+
defaultMessage: "<b>{count} {count, plural, one { relation } other { relations } } out of {entities} { entities, plural, one { entry } other { entries } } {count, plural, one { is } other { are } }</b> not published yet and might lead to unexpected behavior. "
|
3346
|
+
},
|
3347
|
+
{
|
3348
|
+
b: BoldChunk,
|
3349
|
+
count: countDraftRelations,
|
3350
|
+
entities: selectedEntries.length
|
3351
|
+
}
|
3352
|
+
),
|
3353
|
+
formatMessage({
|
3354
|
+
id: getTranslation("popUpWarning.bodyMessage.contentType.publish.all"),
|
3355
|
+
defaultMessage: "Are you sure you want to publish these entries?"
|
3356
|
+
})
|
3357
|
+
] }),
|
3358
|
+
schema?.pluginOptions && "i18n" in schema.pluginOptions && schema?.pluginOptions.i18n && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger500", textAlign: "center", children: formatMessage(
|
3359
|
+
{
|
3360
|
+
id: getTranslation("Settings.list.actions.publishAdditionalInfos"),
|
3361
|
+
defaultMessage: "This will publish the active locale versions <em>(from Internationalization)</em>"
|
3362
|
+
},
|
3363
|
+
{
|
3364
|
+
em: Emphasis
|
3365
|
+
}
|
3366
|
+
) })
|
3367
|
+
] }),
|
3368
|
+
endAction: /* @__PURE__ */ jsxRuntime.jsx(
|
3369
|
+
designSystem.Button,
|
3370
|
+
{
|
3371
|
+
onClick: onConfirm,
|
3372
|
+
variant: "secondary",
|
3373
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Check, {}),
|
3374
|
+
loading: isConfirmButtonLoading,
|
3375
|
+
children: formatMessage({
|
3376
|
+
id: "app.utils.publish",
|
3377
|
+
defaultMessage: "Publish"
|
3378
|
+
})
|
3379
|
+
}
|
3380
|
+
)
|
3381
|
+
}
|
3382
|
+
);
|
3383
|
+
};
|
3384
|
+
const TypographyMaxWidth = styledComponents.styled(designSystem.Typography)`
|
3385
|
+
max-width: 300px;
|
3386
|
+
`;
|
3387
|
+
const TableComponent = styledComponents.styled(designSystem.RawTable)`
|
3388
|
+
width: 100%;
|
3389
|
+
table-layout: fixed;
|
3390
|
+
td:first-child {
|
3391
|
+
border-right: 1px solid ${({ theme }) => theme.colors.neutral150};
|
3392
|
+
}
|
3393
|
+
td:first-of-type {
|
3394
|
+
padding: ${({ theme }) => theme.spaces[4]};
|
3395
|
+
}
|
3396
|
+
`;
|
3397
|
+
const formatErrorMessages = (errors, parentKey, formatMessage) => {
|
3398
|
+
const messages = [];
|
3399
|
+
Object.entries(errors).forEach(([key, value]) => {
|
3400
|
+
const currentKey = parentKey ? `${parentKey}.${key}` : key;
|
3401
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
3402
|
+
if ("id" in value && "defaultMessage" in value) {
|
3403
|
+
messages.push(
|
3404
|
+
formatMessage(
|
3405
|
+
{
|
3406
|
+
id: `${value.id}.withField`,
|
3407
|
+
defaultMessage: value.defaultMessage
|
3408
|
+
},
|
3409
|
+
{ field: currentKey }
|
3410
|
+
)
|
3411
|
+
);
|
3412
|
+
} else {
|
3413
|
+
messages.push(
|
3414
|
+
...formatErrorMessages(
|
3415
|
+
// @ts-expect-error TODO: check why value is not compatible with FormErrors
|
3416
|
+
value,
|
3417
|
+
currentKey,
|
3418
|
+
formatMessage
|
3419
|
+
)
|
3420
|
+
);
|
3421
|
+
}
|
3422
|
+
} else {
|
3423
|
+
messages.push(
|
3424
|
+
formatMessage(
|
3425
|
+
{
|
3426
|
+
id: `${value}.withField`,
|
3427
|
+
defaultMessage: value
|
3428
|
+
},
|
3429
|
+
{ field: currentKey }
|
3430
|
+
)
|
3431
|
+
);
|
3432
|
+
}
|
3433
|
+
});
|
3434
|
+
return messages;
|
3435
|
+
};
|
3436
|
+
const EntryValidationText = ({ validationErrors, status }) => {
|
3437
|
+
const { formatMessage } = reactIntl.useIntl();
|
3438
|
+
if (validationErrors) {
|
3439
|
+
const validationErrorsMessages = formatErrorMessages(validationErrors, "", formatMessage).join(
|
3440
|
+
" "
|
3441
|
+
);
|
3442
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
3443
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icons.CrossCircle, { fill: "danger600" }),
|
3444
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tooltip, { description: validationErrorsMessages, children: /* @__PURE__ */ jsxRuntime.jsx(TypographyMaxWidth, { textColor: "danger600", variant: "omega", fontWeight: "semiBold", ellipsis: true, children: validationErrorsMessages }) })
|
3445
|
+
] });
|
3446
|
+
}
|
3447
|
+
if (status === "published") {
|
3448
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
3449
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icons.CheckCircle, { fill: "success600" }),
|
3450
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "success600", fontWeight: "bold", children: formatMessage({
|
3451
|
+
id: "content-manager.bulk-publish.already-published",
|
3452
|
+
defaultMessage: "Already Published"
|
3453
|
+
}) })
|
3454
|
+
] });
|
3455
|
+
}
|
3456
|
+
if (status === "modified") {
|
3457
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
3458
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icons.ArrowsCounterClockwise, { fill: "alternative600" }),
|
3459
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
|
3460
|
+
id: "content-manager.bulk-publish.modified",
|
3461
|
+
defaultMessage: "Ready to publish changes"
|
3462
|
+
}) })
|
3463
|
+
] });
|
3464
|
+
}
|
3465
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
3466
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icons.CheckCircle, { fill: "success600" }),
|
3467
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
|
3468
|
+
id: "app.utils.ready-to-publish",
|
3469
|
+
defaultMessage: "Ready to publish"
|
3470
|
+
}) })
|
3471
|
+
] });
|
3472
|
+
};
|
3473
|
+
const TABLE_HEADERS = [
|
3474
|
+
{ name: "id", label: "id" },
|
3475
|
+
{ name: "name", label: "name" },
|
3476
|
+
{ name: "status", label: "status" },
|
3477
|
+
{ name: "publicationStatus", label: "Publication status" }
|
3478
|
+
];
|
3479
|
+
const SelectedEntriesTableContent = ({
|
3480
|
+
isPublishing,
|
3481
|
+
rowsToDisplay = [],
|
3482
|
+
entriesToPublish = [],
|
3483
|
+
validationErrors = {}
|
3484
|
+
}) => {
|
3485
|
+
const { pathname } = reactRouterDom.useLocation();
|
3486
|
+
const { formatMessage } = reactIntl.useIntl();
|
3487
|
+
const {
|
3488
|
+
list: {
|
3489
|
+
settings: { mainField }
|
3490
|
+
}
|
3491
|
+
} = useDocLayout();
|
3492
|
+
const shouldDisplayMainField = mainField != null && mainField !== "id";
|
3493
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Content, { children: [
|
3494
|
+
/* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Head, { children: [
|
3495
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.HeaderCheckboxCell, {}),
|
3496
|
+
TABLE_HEADERS.filter((head) => head.name !== "name" || shouldDisplayMainField).map(
|
3497
|
+
(head) => /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.HeaderCell, { ...head }, head.name)
|
3498
|
+
)
|
3499
|
+
] }),
|
3500
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Loading, {}),
|
3501
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Body, { children: rowsToDisplay.map((row) => /* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Row, { children: [
|
3502
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.CheckboxCell, { id: row.id }),
|
3503
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: row.id }) }),
|
3504
|
+
shouldDisplayMainField && /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: row[mainField] }) }),
|
3505
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(DocumentStatus, { status: row.status, maxWidth: "min-content" }) }),
|
3506
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: isPublishing && entriesToPublish.includes(row.documentId) ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
3507
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
|
3508
|
+
id: "content-manager.success.record.publishing",
|
3509
|
+
defaultMessage: "Publishing..."
|
3510
|
+
}) }),
|
3511
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true })
|
3512
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(
|
3513
|
+
EntryValidationText,
|
3514
|
+
{
|
3515
|
+
validationErrors: validationErrors[row.documentId],
|
3516
|
+
status: row.status
|
3517
|
+
}
|
3518
|
+
) }),
|
3519
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
3520
|
+
designSystem.IconButton,
|
3521
|
+
{
|
3522
|
+
tag: reactRouterDom.Link,
|
3523
|
+
to: {
|
3524
|
+
pathname: `${pathname}/${row.documentId}`,
|
3525
|
+
search: row.locale && `?plugins[i18n][locale]=${row.locale}`
|
3526
|
+
},
|
3527
|
+
state: { from: pathname },
|
3528
|
+
label: formatMessage({
|
3529
|
+
id: "content-manager.bulk-publish.edit",
|
3530
|
+
defaultMessage: "Edit"
|
3531
|
+
}),
|
3532
|
+
target: "_blank",
|
3533
|
+
marginLeft: "auto",
|
3534
|
+
variant: "ghost",
|
3535
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, { width: "1.6rem", height: "1.6rem" })
|
3536
|
+
}
|
3537
|
+
) }) })
|
3538
|
+
] }, row.id)) })
|
3539
|
+
] });
|
3540
|
+
};
|
3541
|
+
const PublicationStatusSummary = ({ count, icon, message }) => {
|
3542
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", flex: 1, gap: 3, children: [
|
3543
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
3544
|
+
icon,
|
3545
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: message })
|
3546
|
+
] }),
|
3547
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: count })
|
3548
|
+
] });
|
3549
|
+
};
|
3550
|
+
const PublicationStatusGrid = ({
|
3551
|
+
entriesReadyToPublishCount,
|
3552
|
+
entriesPublishedCount,
|
3553
|
+
entriesModifiedCount,
|
3554
|
+
entriesWithErrorsCount
|
3555
|
+
}) => {
|
3556
|
+
const { formatMessage } = reactIntl.useIntl();
|
3557
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { hasRadius: true, borderColor: "neutral150", children: /* @__PURE__ */ jsxRuntime.jsx(TableComponent, { colCount: 2, rowCount: 2, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tbody, { children: [
|
3558
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
|
3559
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
3560
|
+
PublicationStatusSummary,
|
3561
|
+
{
|
3562
|
+
count: entriesReadyToPublishCount,
|
3563
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.CheckCircle, { fill: "success600" }),
|
3564
|
+
message: formatMessage({
|
3565
|
+
id: "app.utils.ready-to-publish",
|
3566
|
+
defaultMessage: "Ready to publish"
|
3567
|
+
})
|
3568
|
+
}
|
3569
|
+
) }),
|
3570
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
3571
|
+
PublicationStatusSummary,
|
3572
|
+
{
|
3573
|
+
count: entriesPublishedCount,
|
3574
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.CheckCircle, { fill: "success600" }),
|
3575
|
+
message: formatMessage({
|
3576
|
+
id: "app.utils.already-published",
|
3577
|
+
defaultMessage: "Already published"
|
3578
|
+
})
|
3579
|
+
}
|
3580
|
+
) })
|
3581
|
+
] }),
|
3582
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
|
3583
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
3584
|
+
PublicationStatusSummary,
|
3585
|
+
{
|
3586
|
+
count: entriesModifiedCount,
|
3587
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ArrowsCounterClockwise, { fill: "alternative600" }),
|
3588
|
+
message: formatMessage({
|
3589
|
+
id: "content-manager.bulk-publish.modified",
|
3590
|
+
defaultMessage: "Ready to publish changes"
|
3591
|
+
})
|
3592
|
+
}
|
3593
|
+
) }),
|
3594
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
3595
|
+
PublicationStatusSummary,
|
3596
|
+
{
|
3597
|
+
count: entriesWithErrorsCount,
|
3598
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.CrossCircle, { fill: "danger600" }),
|
3599
|
+
message: formatMessage({
|
3600
|
+
id: "content-manager.bulk-publish.waiting-for-action",
|
3601
|
+
defaultMessage: "Waiting for action"
|
3602
|
+
})
|
3603
|
+
}
|
3604
|
+
) })
|
3605
|
+
] })
|
3606
|
+
] }) }) });
|
3607
|
+
};
|
3608
|
+
const SelectedEntriesModalContent = ({
|
3609
|
+
listViewSelectedEntries,
|
3610
|
+
toggleModal,
|
3611
|
+
setListViewSelectedDocuments,
|
3612
|
+
model
|
3613
|
+
}) => {
|
3614
|
+
const { formatMessage } = reactIntl.useIntl();
|
3615
|
+
const { schema, components } = useContentTypeSchema(model);
|
3616
|
+
const documentIds = listViewSelectedEntries.map(({ documentId }) => documentId);
|
3617
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
3618
|
+
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
3619
|
+
const { data, isLoading, isFetching, refetch } = useGetAllDocumentsQuery(
|
3620
|
+
{
|
3621
|
+
model,
|
3622
|
+
params: {
|
3623
|
+
page: "1",
|
3624
|
+
pageSize: documentIds.length.toString(),
|
3625
|
+
sort: query.sort,
|
3626
|
+
filters: {
|
3627
|
+
documentId: {
|
3628
|
+
$in: documentIds
|
3629
|
+
}
|
3630
|
+
},
|
3631
|
+
locale: query.plugins?.i18n?.locale
|
3632
|
+
}
|
3633
|
+
},
|
3634
|
+
{
|
3635
|
+
selectFromResult: ({ data: data2, ...restRes }) => ({ data: data2?.results ?? [], ...restRes })
|
3636
|
+
}
|
3637
|
+
);
|
3638
|
+
const { rows, validationErrors } = React__namespace.useMemo(() => {
|
3639
|
+
if (data.length > 0 && schema) {
|
3640
|
+
const validate = createYupSchema(
|
3641
|
+
schema.attributes,
|
3642
|
+
components,
|
3643
|
+
// Since this is the "Publish" action, the validation
|
3644
|
+
// schema must enforce the rules for published entities
|
3645
|
+
{ status: "published" }
|
3646
|
+
);
|
3647
|
+
const validationErrors2 = {};
|
3648
|
+
const rows2 = data.map((entry) => {
|
3649
|
+
try {
|
3650
|
+
validate.validateSync(entry, { abortEarly: false });
|
3651
|
+
return entry;
|
3652
|
+
} catch (e) {
|
3653
|
+
if (e instanceof yup.ValidationError) {
|
3654
|
+
validationErrors2[entry.documentId] = strapiAdmin.getYupValidationErrors(e);
|
3655
|
+
}
|
3656
|
+
return entry;
|
3657
|
+
}
|
3658
|
+
});
|
3659
|
+
return { rows: rows2, validationErrors: validationErrors2 };
|
3660
|
+
}
|
3661
|
+
return {
|
3662
|
+
rows: [],
|
3663
|
+
validationErrors: {}
|
3664
|
+
};
|
3665
|
+
}, [components, data, schema]);
|
3666
|
+
const [isDialogOpen, setIsDialogOpen] = React__namespace.useState(false);
|
3667
|
+
const { publishMany: bulkPublishAction } = useDocumentActions();
|
3668
|
+
const [, { isLoading: isSubmittingForm }] = usePublishManyDocumentsMutation();
|
3669
|
+
const selectedRows = strapiAdmin.useTable("publishAction", (state) => state.selectedRows);
|
3670
|
+
const selectedEntries = rows.filter(
|
3671
|
+
(entry) => selectedRows.some((selectedEntry) => selectedEntry.documentId === entry.documentId)
|
3672
|
+
);
|
3673
|
+
const entriesToPublish = selectedEntries.filter((entry) => !validationErrors[entry.documentId]).map((entry) => entry.documentId);
|
3674
|
+
const selectedEntriesWithErrorsCount = selectedEntries.filter(
|
3675
|
+
({ documentId }) => validationErrors[documentId]
|
3676
|
+
).length;
|
3677
|
+
const selectedEntriesPublishedCount = selectedEntries.filter(
|
3678
|
+
({ status }) => status === "published"
|
3679
|
+
).length;
|
3680
|
+
const selectedEntriesModifiedCount = selectedEntries.filter(
|
3681
|
+
({ status, documentId }) => status === "modified" && !validationErrors[documentId]
|
3682
|
+
).length;
|
3683
|
+
const selectedEntriesWithNoErrorsCount = selectedEntries.length - selectedEntriesWithErrorsCount - selectedEntriesPublishedCount;
|
3684
|
+
const toggleDialog = () => setIsDialogOpen((prev) => !prev);
|
3685
|
+
const handleConfirmBulkPublish = async () => {
|
3686
|
+
toggleDialog();
|
3687
|
+
const res = await bulkPublishAction({ model, documentIds: entriesToPublish, params });
|
3688
|
+
if (!("error" in res)) {
|
3689
|
+
const unpublishedEntries = rows.filter((row) => {
|
3690
|
+
return !entriesToPublish.includes(row.documentId);
|
3691
|
+
});
|
3692
|
+
setListViewSelectedDocuments(unpublishedEntries);
|
3693
|
+
}
|
3694
|
+
};
|
3695
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
3696
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Body, { children: [
|
3697
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
3698
|
+
PublicationStatusGrid,
|
3699
|
+
{
|
3700
|
+
entriesReadyToPublishCount: selectedEntriesWithNoErrorsCount - selectedEntriesModifiedCount,
|
3701
|
+
entriesPublishedCount: selectedEntriesPublishedCount,
|
3702
|
+
entriesModifiedCount: selectedEntriesModifiedCount,
|
3703
|
+
entriesWithErrorsCount: selectedEntriesWithErrorsCount
|
3704
|
+
}
|
3705
|
+
),
|
3706
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 7, children: /* @__PURE__ */ jsxRuntime.jsx(
|
3707
|
+
SelectedEntriesTableContent,
|
3708
|
+
{
|
3709
|
+
isPublishing: isSubmittingForm,
|
3710
|
+
rowsToDisplay: rows,
|
3711
|
+
entriesToPublish,
|
3712
|
+
validationErrors
|
3713
|
+
}
|
3714
|
+
) })
|
3715
|
+
] }),
|
3716
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
3717
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: toggleModal, variant: "tertiary", children: formatMessage({
|
3718
|
+
id: "app.components.Button.cancel",
|
3719
|
+
defaultMessage: "Cancel"
|
3720
|
+
}) }),
|
3721
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
3722
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: refetch, variant: "tertiary", loading: isFetching, children: formatMessage({ id: "app.utils.refresh", defaultMessage: "Refresh" }) }),
|
3723
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
3724
|
+
designSystem.Button,
|
3725
|
+
{
|
3726
|
+
onClick: toggleDialog,
|
3727
|
+
disabled: selectedEntries.length === 0 || selectedEntries.length === selectedEntriesWithErrorsCount || selectedEntriesPublishedCount === selectedEntries.length || isLoading,
|
3728
|
+
loading: isSubmittingForm,
|
3729
|
+
children: formatMessage({ id: "app.utils.publish", defaultMessage: "Publish" })
|
3730
|
+
}
|
3731
|
+
)
|
3732
|
+
] })
|
3733
|
+
] }),
|
3734
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
3735
|
+
ConfirmDialogPublishAll,
|
3736
|
+
{
|
3737
|
+
isOpen: isDialogOpen,
|
3738
|
+
onToggleDialog: toggleDialog,
|
3739
|
+
isConfirmButtonLoading: isSubmittingForm,
|
3740
|
+
onConfirm: handleConfirmBulkPublish
|
3741
|
+
}
|
3742
|
+
)
|
3743
|
+
] });
|
2364
3744
|
};
|
2365
|
-
|
2366
|
-
const
|
2367
|
-
|
2368
|
-
|
2369
|
-
|
2370
|
-
|
2371
|
-
|
2372
|
-
|
2373
|
-
|
2374
|
-
|
2375
|
-
|
2376
|
-
|
3745
|
+
const PublishAction = ({ documents, model }) => {
|
3746
|
+
const { formatMessage } = reactIntl.useIntl();
|
3747
|
+
const hasPublishPermission = useDocumentRBAC("unpublishAction", (state) => state.canPublish);
|
3748
|
+
const showPublishButton = hasPublishPermission && documents.some(({ status }) => status !== "published");
|
3749
|
+
const setListViewSelectedDocuments = strapiAdmin.useTable("publishAction", (state) => state.selectRow);
|
3750
|
+
const refetchList = () => {
|
3751
|
+
contentManagerApi.util.invalidateTags([{ type: "Document", id: `${model}_LIST` }]);
|
3752
|
+
};
|
3753
|
+
if (!showPublishButton) return null;
|
3754
|
+
return {
|
3755
|
+
actionType: "publish",
|
3756
|
+
variant: "tertiary",
|
3757
|
+
label: formatMessage({ id: "app.utils.publish", defaultMessage: "Publish" }),
|
3758
|
+
dialog: {
|
3759
|
+
type: "modal",
|
3760
|
+
title: formatMessage({
|
3761
|
+
id: getTranslation("containers.ListPage.selectedEntriesModal.title"),
|
3762
|
+
defaultMessage: "Publish entries"
|
3763
|
+
}),
|
3764
|
+
content: ({ onClose }) => {
|
3765
|
+
return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Root, { rows: documents, defaultSelectedRows: documents, headers: TABLE_HEADERS, children: /* @__PURE__ */ jsxRuntime.jsx(
|
3766
|
+
SelectedEntriesModalContent,
|
3767
|
+
{
|
3768
|
+
listViewSelectedEntries: documents,
|
3769
|
+
toggleModal: () => {
|
3770
|
+
onClose();
|
3771
|
+
refetchList();
|
3772
|
+
},
|
3773
|
+
setListViewSelectedDocuments,
|
3774
|
+
model
|
3775
|
+
}
|
3776
|
+
) });
|
3777
|
+
},
|
3778
|
+
onClose: () => {
|
3779
|
+
refetchList();
|
3780
|
+
}
|
2377
3781
|
}
|
2378
|
-
] = strapiAdmin.useQueryParams({
|
2379
|
-
status: "draft"
|
2380
|
-
});
|
2381
|
-
const { model, id, document, meta, collectionType } = useDoc();
|
2382
|
-
const plugins = strapiAdmin.useStrapiApp("Panels", (state) => state.plugins);
|
2383
|
-
const props = {
|
2384
|
-
activeTab: status,
|
2385
|
-
model,
|
2386
|
-
documentId: id,
|
2387
|
-
document: isCloning ? void 0 : document,
|
2388
|
-
meta: isCloning ? void 0 : meta,
|
2389
|
-
collectionType
|
2390
3782
|
};
|
2391
|
-
|
3783
|
+
};
|
3784
|
+
const BulkActionsRenderer = () => {
|
3785
|
+
const plugins = strapiAdmin.useStrapiApp("BulkActionsRenderer", (state) => state.plugins);
|
3786
|
+
const { model, collectionType } = useDoc();
|
3787
|
+
const { selectedRows } = strapiAdmin.useTable("BulkActionsRenderer", (state) => state);
|
3788
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
2392
3789
|
strapiAdmin.DescriptionComponentRenderer,
|
2393
3790
|
{
|
2394
|
-
props
|
2395
|
-
|
2396
|
-
|
3791
|
+
props: {
|
3792
|
+
model,
|
3793
|
+
collectionType,
|
3794
|
+
documents: selectedRows
|
3795
|
+
},
|
3796
|
+
descriptions: plugins["content-manager"].apis.getBulkActions(),
|
3797
|
+
children: (actions2) => actions2.map((action) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActionButton, { ...action }, action.id))
|
2397
3798
|
}
|
2398
3799
|
) });
|
2399
3800
|
};
|
2400
|
-
const
|
3801
|
+
const DeleteAction = ({ documents, model }) => {
|
2401
3802
|
const { formatMessage } = reactIntl.useIntl();
|
3803
|
+
const { schema: contentType } = useDoc();
|
3804
|
+
const selectRow = strapiAdmin.useTable("DeleteAction", (state) => state.selectRow);
|
3805
|
+
const hasI18nEnabled = Boolean(contentType?.pluginOptions?.i18n);
|
3806
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
3807
|
+
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
3808
|
+
const hasDeletePermission = useDocumentRBAC("deleteAction", (state) => state.canDelete);
|
3809
|
+
const { deleteMany: bulkDeleteAction } = useDocumentActions();
|
3810
|
+
const documentIds = documents.map(({ documentId }) => documentId);
|
3811
|
+
const handleConfirmBulkDelete = async () => {
|
3812
|
+
const res = await bulkDeleteAction({
|
3813
|
+
documentIds,
|
3814
|
+
model,
|
3815
|
+
params
|
3816
|
+
});
|
3817
|
+
if (!("error" in res)) {
|
3818
|
+
selectRow([]);
|
3819
|
+
}
|
3820
|
+
};
|
3821
|
+
if (!hasDeletePermission) return null;
|
2402
3822
|
return {
|
2403
|
-
|
2404
|
-
|
2405
|
-
|
2406
|
-
|
2407
|
-
|
3823
|
+
variant: "danger-light",
|
3824
|
+
label: formatMessage({ id: "global.delete", defaultMessage: "Delete" }),
|
3825
|
+
dialog: {
|
3826
|
+
type: "dialog",
|
3827
|
+
title: formatMessage({
|
3828
|
+
id: "app.components.ConfirmDialog.title",
|
3829
|
+
defaultMessage: "Confirmation"
|
3830
|
+
}),
|
3831
|
+
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
3832
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
3833
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
|
3834
|
+
id: "popUpWarning.bodyMessage.contentType.delete.all",
|
3835
|
+
defaultMessage: "Are you sure you want to delete these entries?"
|
3836
|
+
}) }),
|
3837
|
+
hasI18nEnabled && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { textAlign: "center", padding: 3, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger500", children: formatMessage(
|
3838
|
+
{
|
3839
|
+
id: getTranslation("Settings.list.actions.deleteAdditionalInfos"),
|
3840
|
+
defaultMessage: "This will delete the active locale versions <em>(from Internationalization)</em>"
|
3841
|
+
},
|
3842
|
+
{
|
3843
|
+
em: Emphasis
|
3844
|
+
}
|
3845
|
+
) }) })
|
3846
|
+
] }),
|
3847
|
+
onConfirm: handleConfirmBulkDelete
|
3848
|
+
}
|
2408
3849
|
};
|
2409
3850
|
};
|
2410
|
-
|
2411
|
-
const
|
2412
|
-
const
|
2413
|
-
const
|
2414
|
-
|
2415
|
-
|
3851
|
+
DeleteAction.type = "delete";
|
3852
|
+
const UnpublishAction = ({ documents, model }) => {
|
3853
|
+
const { formatMessage } = reactIntl.useIntl();
|
3854
|
+
const { schema } = useDoc();
|
3855
|
+
const selectRow = strapiAdmin.useTable("UnpublishAction", (state) => state.selectRow);
|
3856
|
+
const hasPublishPermission = useDocumentRBAC("unpublishAction", (state) => state.canPublish);
|
3857
|
+
const hasI18nEnabled = Boolean(schema?.pluginOptions?.i18n);
|
3858
|
+
const hasDraftAndPublishEnabled = Boolean(schema?.options?.draftAndPublish);
|
3859
|
+
const { unpublishMany: bulkUnpublishAction } = useDocumentActions();
|
3860
|
+
const documentIds = documents.map(({ documentId }) => documentId);
|
3861
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
3862
|
+
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
3863
|
+
const handleConfirmBulkUnpublish = async () => {
|
3864
|
+
const data = await bulkUnpublishAction({ documentIds, model, params });
|
3865
|
+
if (!("error" in data)) {
|
3866
|
+
selectRow([]);
|
2416
3867
|
}
|
2417
|
-
] = strapiAdmin.useQueryParams();
|
2418
|
-
const { model, id, document, meta, collectionType } = useDoc();
|
2419
|
-
const plugins = strapiAdmin.useStrapiApp("ActionsPanel", (state) => state.plugins);
|
2420
|
-
const props = {
|
2421
|
-
activeTab: status,
|
2422
|
-
model,
|
2423
|
-
documentId: id,
|
2424
|
-
document: isCloning ? void 0 : document,
|
2425
|
-
meta: isCloning ? void 0 : meta,
|
2426
|
-
collectionType
|
2427
3868
|
};
|
2428
|
-
|
2429
|
-
|
2430
|
-
|
2431
|
-
|
2432
|
-
|
2433
|
-
|
2434
|
-
|
2435
|
-
|
2436
|
-
|
2437
|
-
|
2438
|
-
|
2439
|
-
|
2440
|
-
|
2441
|
-
|
2442
|
-
|
2443
|
-
|
2444
|
-
|
2445
|
-
|
2446
|
-
|
2447
|
-
|
2448
|
-
|
2449
|
-
|
2450
|
-
|
2451
|
-
|
2452
|
-
|
2453
|
-
|
2454
|
-
|
2455
|
-
|
2456
|
-
|
2457
|
-
|
2458
|
-
|
2459
|
-
|
2460
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { as: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
|
2461
|
-
children
|
2462
|
-
]
|
3869
|
+
const showUnpublishButton = hasDraftAndPublishEnabled && hasPublishPermission && documents.some((entry) => entry.status === "published" || entry.status === "modified");
|
3870
|
+
if (!showUnpublishButton) return null;
|
3871
|
+
return {
|
3872
|
+
variant: "tertiary",
|
3873
|
+
label: formatMessage({ id: "app.utils.unpublish", defaultMessage: "Unpublish" }),
|
3874
|
+
dialog: {
|
3875
|
+
type: "dialog",
|
3876
|
+
title: formatMessage({
|
3877
|
+
id: "app.components.ConfirmDialog.title",
|
3878
|
+
defaultMessage: "Confirmation"
|
3879
|
+
}),
|
3880
|
+
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
3881
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
3882
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
|
3883
|
+
id: "popUpWarning.bodyMessage.contentType.unpublish.all",
|
3884
|
+
defaultMessage: "Are you sure you want to unpublish these entries?"
|
3885
|
+
}) }),
|
3886
|
+
hasI18nEnabled && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { textAlign: "center", padding: 3, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger500", children: formatMessage(
|
3887
|
+
{
|
3888
|
+
id: getTranslation("Settings.list.actions.unpublishAdditionalInfos"),
|
3889
|
+
defaultMessage: "This will unpublish the active locale versions <em>(from Internationalization)</em>"
|
3890
|
+
},
|
3891
|
+
{
|
3892
|
+
em: Emphasis
|
3893
|
+
}
|
3894
|
+
) }) })
|
3895
|
+
] }),
|
3896
|
+
confirmButton: formatMessage({
|
3897
|
+
id: "app.utils.unpublish",
|
3898
|
+
defaultMessage: "Unpublish"
|
3899
|
+
}),
|
3900
|
+
onConfirm: handleConfirmBulkUnpublish
|
2463
3901
|
}
|
2464
|
-
|
2465
|
-
}
|
2466
|
-
|
3902
|
+
};
|
3903
|
+
};
|
3904
|
+
UnpublishAction.type = "unpublish";
|
3905
|
+
const Emphasis = (chunks) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "semiBold", textColor: "danger500", children: chunks });
|
3906
|
+
const DEFAULT_BULK_ACTIONS = [PublishAction, UnpublishAction, DeleteAction];
|
2467
3907
|
const AutoCloneFailureModalBody = ({ prohibitedFields }) => {
|
2468
3908
|
const { formatMessage } = reactIntl.useIntl();
|
2469
3909
|
const getDefaultErrorMessage = (reason) => {
|
@@ -2495,7 +3935,7 @@ const AutoCloneFailureModalBody = ({ prohibitedFields }) => {
|
|
2495
3935
|
hasRadius: true,
|
2496
3936
|
padding: 6,
|
2497
3937
|
children: [
|
2498
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "row",
|
3938
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "row", tag: "ol", children: fieldPath.map((pathSegment, index2) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { fontWeight: "semiBold", tag: "li", children: [
|
2499
3939
|
pathSegment,
|
2500
3940
|
index2 !== fieldPath.length - 1 && /* @__PURE__ */ jsxRuntime.jsx(
|
2501
3941
|
Icons.ChevronRight,
|
@@ -2507,7 +3947,7 @@ const AutoCloneFailureModalBody = ({ prohibitedFields }) => {
|
|
2507
3947
|
}
|
2508
3948
|
)
|
2509
3949
|
] }, index2)) }),
|
2510
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, {
|
3950
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", textColor: "neutral600", children: formatMessage({
|
2511
3951
|
id: getTranslation(`containers.list.autoCloneModal.error.${reason}`),
|
2512
3952
|
defaultMessage: getDefaultErrorMessage(reason)
|
2513
3953
|
}) })
|
@@ -2532,7 +3972,7 @@ const TableActions = ({ document }) => {
|
|
2532
3972
|
strapiAdmin.DescriptionComponentRenderer,
|
2533
3973
|
{
|
2534
3974
|
props,
|
2535
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
3975
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions("table-row").filter((action) => action.name !== "PublishAction"),
|
2536
3976
|
children: (actions2) => {
|
2537
3977
|
const tableRowActions = actions2.filter((action) => {
|
2538
3978
|
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
@@ -2591,7 +4031,8 @@ const EditAction = ({ documentId }) => {
|
|
2591
4031
|
};
|
2592
4032
|
};
|
2593
4033
|
EditAction.type = "edit";
|
2594
|
-
|
4034
|
+
EditAction.position = "table-row";
|
4035
|
+
const StyledPencil = styledComponents.styled(Icons.Pencil)`
|
2595
4036
|
path {
|
2596
4037
|
fill: currentColor;
|
2597
4038
|
}
|
@@ -2643,7 +4084,7 @@ const CloneAction = ({ model, documentId }) => {
|
|
2643
4084
|
}),
|
2644
4085
|
content: /* @__PURE__ */ jsxRuntime.jsx(AutoCloneFailureModalBody, { prohibitedFields }),
|
2645
4086
|
footer: ({ onClose }) => {
|
2646
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.
|
4087
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
2647
4088
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
|
2648
4089
|
id: "cancel",
|
2649
4090
|
defaultMessage: "Cancel"
|
@@ -2651,7 +4092,7 @@ const CloneAction = ({ model, documentId }) => {
|
|
2651
4092
|
/* @__PURE__ */ jsxRuntime.jsx(
|
2652
4093
|
designSystem.LinkButton,
|
2653
4094
|
{
|
2654
|
-
|
4095
|
+
tag: reactRouterDom.NavLink,
|
2655
4096
|
to: {
|
2656
4097
|
pathname: `clone/${documentId}`
|
2657
4098
|
},
|
@@ -2667,7 +4108,8 @@ const CloneAction = ({ model, documentId }) => {
|
|
2667
4108
|
};
|
2668
4109
|
};
|
2669
4110
|
CloneAction.type = "clone";
|
2670
|
-
|
4111
|
+
CloneAction.position = "table-row";
|
4112
|
+
const StyledDuplicate = styledComponents.styled(Icons.Duplicate)`
|
2671
4113
|
path {
|
2672
4114
|
fill: currentColor;
|
2673
4115
|
}
|
@@ -2684,8 +4126,7 @@ class ContentManagerPlugin {
|
|
2684
4126
|
documentActions = [
|
2685
4127
|
...DEFAULT_ACTIONS,
|
2686
4128
|
...DEFAULT_TABLE_ROW_ACTIONS,
|
2687
|
-
...DEFAULT_HEADER_ACTIONS
|
2688
|
-
HistoryAction
|
4129
|
+
...DEFAULT_HEADER_ACTIONS
|
2689
4130
|
];
|
2690
4131
|
editViewSidePanels = [ActionsPanel];
|
2691
4132
|
headerActions = [];
|
@@ -2748,13 +4189,21 @@ class ContentManagerPlugin {
|
|
2748
4189
|
id: PLUGIN_ID,
|
2749
4190
|
name: "Content Manager",
|
2750
4191
|
injectionZones: INJECTION_ZONES,
|
4192
|
+
isReady: false,
|
2751
4193
|
apis: {
|
2752
4194
|
addBulkAction: this.addBulkAction.bind(this),
|
2753
4195
|
addDocumentAction: this.addDocumentAction.bind(this),
|
2754
4196
|
addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),
|
2755
4197
|
addEditViewSidePanel: this.addEditViewSidePanel.bind(this),
|
2756
4198
|
getBulkActions: () => this.bulkActions,
|
2757
|
-
getDocumentActions: () =>
|
4199
|
+
getDocumentActions: (position) => {
|
4200
|
+
if (position) {
|
4201
|
+
return this.documentActions.filter(
|
4202
|
+
(action) => action.position == void 0 || [action.position].flat().includes(position)
|
4203
|
+
);
|
4204
|
+
}
|
4205
|
+
return this.documentActions;
|
4206
|
+
},
|
2758
4207
|
getEditViewSidePanels: () => this.editViewSidePanels,
|
2759
4208
|
getHeaderActions: () => this.headerActions
|
2760
4209
|
}
|
@@ -2764,16 +4213,71 @@ class ContentManagerPlugin {
|
|
2764
4213
|
const getPrintableType = (value) => {
|
2765
4214
|
const nativeType = typeof value;
|
2766
4215
|
if (nativeType === "object") {
|
2767
|
-
if (value === null)
|
2768
|
-
|
2769
|
-
if (Array.isArray(value))
|
2770
|
-
return "array";
|
4216
|
+
if (value === null) return "null";
|
4217
|
+
if (Array.isArray(value)) return "array";
|
2771
4218
|
if (value instanceof Object && value.constructor.name !== "Object") {
|
2772
4219
|
return value.constructor.name;
|
2773
4220
|
}
|
2774
4221
|
}
|
2775
4222
|
return nativeType;
|
2776
4223
|
};
|
4224
|
+
const HistoryAction = ({ model, document }) => {
|
4225
|
+
const { formatMessage } = reactIntl.useIntl();
|
4226
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
4227
|
+
const navigate = reactRouterDom.useNavigate();
|
4228
|
+
const { trackUsage } = strapiAdmin.useTracking();
|
4229
|
+
const { pathname } = reactRouterDom.useLocation();
|
4230
|
+
const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
|
4231
|
+
if (!window.strapi.features.isEnabled("cms-content-history")) {
|
4232
|
+
return null;
|
4233
|
+
}
|
4234
|
+
const handleOnClick = () => {
|
4235
|
+
const destination = { pathname: "history", search: pluginsQueryParams };
|
4236
|
+
trackUsage("willNavigate", {
|
4237
|
+
from: pathname,
|
4238
|
+
to: `${pathname}/${destination.pathname}`
|
4239
|
+
});
|
4240
|
+
navigate(destination);
|
4241
|
+
};
|
4242
|
+
return {
|
4243
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
|
4244
|
+
label: formatMessage({
|
4245
|
+
id: "content-manager.history.document-action",
|
4246
|
+
defaultMessage: "Content History"
|
4247
|
+
}),
|
4248
|
+
onClick: handleOnClick,
|
4249
|
+
disabled: (
|
4250
|
+
/**
|
4251
|
+
* The user is creating a new document.
|
4252
|
+
* It hasn't been saved yet, so there's no history to go to
|
4253
|
+
*/
|
4254
|
+
!document || /**
|
4255
|
+
* The document has been created but the current dimension has never been saved.
|
4256
|
+
* For example, the user is creating a new locale in an existing document,
|
4257
|
+
* so there's no history for the document in that locale
|
4258
|
+
*/
|
4259
|
+
!document.id || /**
|
4260
|
+
* History is only available for content types created by the user.
|
4261
|
+
* These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
|
4262
|
+
* which start with `admin::` or `plugin::`
|
4263
|
+
*/
|
4264
|
+
!model.startsWith("api::")
|
4265
|
+
),
|
4266
|
+
position: "header"
|
4267
|
+
};
|
4268
|
+
};
|
4269
|
+
HistoryAction.type = "history";
|
4270
|
+
HistoryAction.position = "header";
|
4271
|
+
const historyAdmin = {
|
4272
|
+
bootstrap(app) {
|
4273
|
+
const { addDocumentAction } = app.getPlugin("content-manager").apis;
|
4274
|
+
addDocumentAction((actions2) => {
|
4275
|
+
const indexOfDeleteAction = actions2.findIndex((action) => action.type === "delete");
|
4276
|
+
actions2.splice(indexOfDeleteAction, 0, HistoryAction);
|
4277
|
+
return actions2;
|
4278
|
+
});
|
4279
|
+
}
|
4280
|
+
};
|
2777
4281
|
const initialState = {
|
2778
4282
|
collectionTypeLinks: [],
|
2779
4283
|
components: [],
|
@@ -2810,316 +4314,94 @@ const { setInitialData } = actions;
|
|
2810
4314
|
const reducer = toolkit.combineReducers({
|
2811
4315
|
app: reducer$1
|
2812
4316
|
});
|
2813
|
-
const
|
2814
|
-
|
2815
|
-
|
2816
|
-
|
2817
|
-
|
2818
|
-
|
2819
|
-
|
2820
|
-
|
2821
|
-
|
2822
|
-
|
2823
|
-
|
2824
|
-
|
2825
|
-
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
2826
|
-
/**
|
2827
|
-
* Hook that allows to mutate the CM's edit view layout
|
2828
|
-
* @constant
|
2829
|
-
* @type {string}
|
2830
|
-
*/
|
2831
|
-
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
2832
|
-
/**
|
2833
|
-
* Hook that allows to mutate the CM's single types links pre-set filters
|
2834
|
-
* @constant
|
2835
|
-
* @type {string}
|
2836
|
-
*/
|
2837
|
-
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
2838
|
-
};
|
2839
|
-
const contentTypesApi = contentManagerApi.injectEndpoints({
|
2840
|
-
endpoints: (builder) => ({
|
2841
|
-
getContentTypeConfiguration: builder.query({
|
2842
|
-
query: (uid) => ({
|
2843
|
-
url: `/content-manager/content-types/${uid}/configuration`,
|
2844
|
-
method: "GET"
|
2845
|
-
}),
|
2846
|
-
transformResponse: (response) => response.data,
|
2847
|
-
providesTags: (_result, _error, uid) => [
|
2848
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2849
|
-
{ type: "ContentTypeSettings", id: "LIST" }
|
2850
|
-
]
|
2851
|
-
}),
|
2852
|
-
getAllContentTypeSettings: builder.query({
|
2853
|
-
query: () => "/content-manager/content-types-settings",
|
2854
|
-
transformResponse: (response) => response.data,
|
2855
|
-
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
2856
|
-
}),
|
2857
|
-
updateContentTypeConfiguration: builder.mutation({
|
2858
|
-
query: ({ uid, ...body }) => ({
|
2859
|
-
url: `/content-manager/content-types/${uid}/configuration`,
|
2860
|
-
method: "PUT",
|
2861
|
-
data: body
|
2862
|
-
}),
|
2863
|
-
transformResponse: (response) => response.data,
|
2864
|
-
invalidatesTags: (_result, _error, { uid }) => [
|
2865
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2866
|
-
{ type: "ContentTypeSettings", id: "LIST" },
|
2867
|
-
// Is this necessary?
|
2868
|
-
{ type: "InitialData" }
|
2869
|
-
]
|
4317
|
+
const previewApi = contentManagerApi.injectEndpoints({
|
4318
|
+
endpoints: (builder) => ({
|
4319
|
+
getPreviewUrl: builder.query({
|
4320
|
+
query({ query, params }) {
|
4321
|
+
return {
|
4322
|
+
url: `/content-manager/preview/url/${params.contentType}`,
|
4323
|
+
method: "GET",
|
4324
|
+
config: {
|
4325
|
+
params: query
|
4326
|
+
}
|
4327
|
+
};
|
4328
|
+
}
|
2870
4329
|
})
|
2871
4330
|
})
|
2872
4331
|
});
|
2873
|
-
const {
|
2874
|
-
|
2875
|
-
|
2876
|
-
|
2877
|
-
} = contentTypesApi;
|
2878
|
-
const checkIfAttributeIsDisplayable = (attribute) => {
|
2879
|
-
const { type } = attribute;
|
2880
|
-
if (type === "relation") {
|
2881
|
-
return !attribute.relation.toLowerCase().includes("morph");
|
4332
|
+
const { useGetPreviewUrlQuery } = previewApi;
|
4333
|
+
const ConditionalTooltip = ({ isShown, label, children }) => {
|
4334
|
+
if (isShown) {
|
4335
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tooltip, { label, children });
|
2882
4336
|
}
|
2883
|
-
return
|
2884
|
-
};
|
2885
|
-
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
2886
|
-
if (!mainFieldName) {
|
2887
|
-
return void 0;
|
2888
|
-
}
|
2889
|
-
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
2890
|
-
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
2891
|
-
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
2892
|
-
);
|
2893
|
-
return {
|
2894
|
-
name: mainFieldName,
|
2895
|
-
type: mainFieldType ?? "string"
|
2896
|
-
};
|
2897
|
-
};
|
2898
|
-
const DEFAULT_SETTINGS = {
|
2899
|
-
bulkable: false,
|
2900
|
-
filterable: false,
|
2901
|
-
searchable: false,
|
2902
|
-
pagination: false,
|
2903
|
-
defaultSortBy: "",
|
2904
|
-
defaultSortOrder: "asc",
|
2905
|
-
mainField: "id",
|
2906
|
-
pageSize: 10
|
4337
|
+
return children;
|
2907
4338
|
};
|
2908
|
-
const
|
2909
|
-
const {
|
4339
|
+
const PreviewSidePanel = ({ model, documentId, document }) => {
|
4340
|
+
const { formatMessage } = reactIntl.useIntl();
|
4341
|
+
const { trackUsage } = strapiAdmin.useTracking();
|
4342
|
+
const { pathname } = reactRouterDom.useLocation();
|
2910
4343
|
const [{ query }] = strapiAdmin.useQueryParams();
|
2911
|
-
const
|
2912
|
-
const {
|
2913
|
-
|
2914
|
-
|
2915
|
-
const {
|
2916
|
-
data,
|
2917
|
-
isLoading: isLoadingConfigs,
|
2918
|
-
error,
|
2919
|
-
isFetching: isFetchingConfigs
|
2920
|
-
} = useGetContentTypeConfigurationQuery(model);
|
2921
|
-
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
2922
|
-
React__namespace.useEffect(() => {
|
2923
|
-
if (error) {
|
2924
|
-
toggleNotification({
|
2925
|
-
type: "danger",
|
2926
|
-
message: formatAPIError(error)
|
2927
|
-
});
|
2928
|
-
}
|
2929
|
-
}, [error, formatAPIError, toggleNotification]);
|
2930
|
-
const editLayout = React__namespace.useMemo(
|
2931
|
-
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
2932
|
-
layout: [],
|
2933
|
-
components: {},
|
2934
|
-
metadatas: {},
|
2935
|
-
options: {},
|
2936
|
-
settings: DEFAULT_SETTINGS
|
2937
|
-
},
|
2938
|
-
[data, isLoading, schemas, schema, components]
|
2939
|
-
);
|
2940
|
-
const listLayout = React__namespace.useMemo(() => {
|
2941
|
-
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
2942
|
-
layout: [],
|
2943
|
-
metadatas: {},
|
2944
|
-
options: {},
|
2945
|
-
settings: DEFAULT_SETTINGS
|
2946
|
-
};
|
2947
|
-
}, [data, isLoading, schemas, schema, components]);
|
2948
|
-
const { layout: edit } = React__namespace.useMemo(
|
2949
|
-
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
2950
|
-
layout: editLayout,
|
2951
|
-
query
|
2952
|
-
}),
|
2953
|
-
[editLayout, query, runHookWaterfall]
|
2954
|
-
);
|
2955
|
-
return {
|
2956
|
-
error,
|
2957
|
-
isLoading,
|
2958
|
-
edit,
|
2959
|
-
list: listLayout
|
2960
|
-
};
|
2961
|
-
};
|
2962
|
-
const useDocLayout = () => {
|
2963
|
-
const { model } = useDoc();
|
2964
|
-
return useDocumentLayout(model);
|
2965
|
-
};
|
2966
|
-
const formatEditLayout = (data, {
|
2967
|
-
schemas,
|
2968
|
-
schema,
|
2969
|
-
components
|
2970
|
-
}) => {
|
2971
|
-
let currentPanelIndex = 0;
|
2972
|
-
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
2973
|
-
data.contentType.layouts.edit,
|
2974
|
-
schema?.attributes,
|
2975
|
-
data.contentType.metadatas,
|
2976
|
-
{ configurations: data.components, schemas: components },
|
2977
|
-
schemas
|
2978
|
-
).reduce((panels, row) => {
|
2979
|
-
if (row.some((field) => field.type === "dynamiczone")) {
|
2980
|
-
panels.push([row]);
|
2981
|
-
currentPanelIndex += 2;
|
2982
|
-
} else {
|
2983
|
-
if (!panels[currentPanelIndex]) {
|
2984
|
-
panels.push([]);
|
2985
|
-
}
|
2986
|
-
panels[currentPanelIndex].push(row);
|
2987
|
-
}
|
2988
|
-
return panels;
|
2989
|
-
}, []);
|
2990
|
-
const componentEditAttributes = Object.entries(data.components).reduce(
|
2991
|
-
(acc, [uid, configuration]) => {
|
2992
|
-
acc[uid] = {
|
2993
|
-
layout: convertEditLayoutToFieldLayouts(
|
2994
|
-
configuration.layouts.edit,
|
2995
|
-
components[uid].attributes,
|
2996
|
-
configuration.metadatas
|
2997
|
-
),
|
2998
|
-
settings: {
|
2999
|
-
...configuration.settings,
|
3000
|
-
icon: components[uid].info.icon,
|
3001
|
-
displayName: components[uid].info.displayName
|
3002
|
-
}
|
3003
|
-
};
|
3004
|
-
return acc;
|
3005
|
-
},
|
3006
|
-
{}
|
3007
|
-
);
|
3008
|
-
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
3009
|
-
(acc, [attribute, metadata]) => {
|
3010
|
-
return {
|
3011
|
-
...acc,
|
3012
|
-
[attribute]: metadata.edit
|
3013
|
-
};
|
4344
|
+
const isModified = strapiAdmin.useForm("PreviewSidePanel", (state) => state.modified);
|
4345
|
+
const { data, error } = useGetPreviewUrlQuery({
|
4346
|
+
params: {
|
4347
|
+
contentType: model
|
3014
4348
|
},
|
3015
|
-
{
|
3016
|
-
|
3017
|
-
|
3018
|
-
|
3019
|
-
components: componentEditAttributes,
|
3020
|
-
metadatas: editMetadatas,
|
3021
|
-
settings: {
|
3022
|
-
...data.contentType.settings,
|
3023
|
-
displayName: schema?.info.displayName
|
3024
|
-
},
|
3025
|
-
options: {
|
3026
|
-
...schema?.options,
|
3027
|
-
...schema?.pluginOptions,
|
3028
|
-
...data.contentType.options
|
4349
|
+
query: {
|
4350
|
+
documentId,
|
4351
|
+
locale: document?.locale,
|
4352
|
+
status: document?.status
|
3029
4353
|
}
|
4354
|
+
});
|
4355
|
+
if (!data?.data?.url || error) {
|
4356
|
+
return null;
|
4357
|
+
}
|
4358
|
+
const trackNavigation = () => {
|
4359
|
+
const destinationPathname = pathname.replace(/\/$/, "") + "/preview";
|
4360
|
+
trackUsage("willNavigate", { from: pathname, to: destinationPathname });
|
3030
4361
|
};
|
3031
|
-
};
|
3032
|
-
const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
|
3033
|
-
return rows.map(
|
3034
|
-
(row) => row.map((field) => {
|
3035
|
-
const attribute = attributes[field.name];
|
3036
|
-
if (!attribute) {
|
3037
|
-
return null;
|
3038
|
-
}
|
3039
|
-
const { edit: metadata } = metadatas[field.name];
|
3040
|
-
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
3041
|
-
return {
|
3042
|
-
attribute,
|
3043
|
-
disabled: !metadata.editable,
|
3044
|
-
hint: metadata.description,
|
3045
|
-
label: metadata.label ?? "",
|
3046
|
-
name: field.name,
|
3047
|
-
// @ts-expect-error – mainField does exist on the metadata for a relation.
|
3048
|
-
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
3049
|
-
schemas,
|
3050
|
-
components: components?.schemas ?? {}
|
3051
|
-
}),
|
3052
|
-
placeholder: metadata.placeholder ?? "",
|
3053
|
-
required: attribute.required ?? false,
|
3054
|
-
size: field.size,
|
3055
|
-
unique: "unique" in attribute ? attribute.unique : false,
|
3056
|
-
visible: metadata.visible ?? true,
|
3057
|
-
type: attribute.type
|
3058
|
-
};
|
3059
|
-
}).filter((field) => field !== null)
|
3060
|
-
);
|
3061
|
-
};
|
3062
|
-
const formatListLayout = (data, {
|
3063
|
-
schemas,
|
3064
|
-
schema,
|
3065
|
-
components
|
3066
|
-
}) => {
|
3067
|
-
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
3068
|
-
(acc, [attribute, metadata]) => {
|
3069
|
-
return {
|
3070
|
-
...acc,
|
3071
|
-
[attribute]: metadata.list
|
3072
|
-
};
|
3073
|
-
},
|
3074
|
-
{}
|
3075
|
-
);
|
3076
|
-
const listAttributes = convertListLayoutToFieldLayouts(
|
3077
|
-
data.contentType.layouts.list,
|
3078
|
-
schema?.attributes,
|
3079
|
-
listMetadatas,
|
3080
|
-
{ configurations: data.components, schemas: components },
|
3081
|
-
schemas
|
3082
|
-
);
|
3083
4362
|
return {
|
3084
|
-
|
3085
|
-
|
3086
|
-
|
3087
|
-
|
3088
|
-
|
3089
|
-
|
3090
|
-
|
3091
|
-
|
4363
|
+
title: formatMessage({ id: "content-manager.preview.panel.title", defaultMessage: "Preview" }),
|
4364
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(
|
4365
|
+
ConditionalTooltip,
|
4366
|
+
{
|
4367
|
+
label: formatMessage({
|
4368
|
+
id: "content-manager.preview.panel.button-disabled-tooltip",
|
4369
|
+
defaultMessage: "Please save to open the preview"
|
4370
|
+
}),
|
4371
|
+
isShown: isModified,
|
4372
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { cursor: "not-allowed", width: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(
|
4373
|
+
designSystem.Button,
|
4374
|
+
{
|
4375
|
+
variant: "tertiary",
|
4376
|
+
tag: reactRouterDom.Link,
|
4377
|
+
to: { pathname: "preview", search: qs.stringify(query, { encode: false }) },
|
4378
|
+
onClick: trackNavigation,
|
4379
|
+
width: "100%",
|
4380
|
+
disabled: isModified,
|
4381
|
+
pointerEvents: isModified ? "none" : void 0,
|
4382
|
+
tabIndex: isModified ? -1 : void 0,
|
4383
|
+
children: formatMessage({
|
4384
|
+
id: "content-manager.preview.panel.button",
|
4385
|
+
defaultMessage: "Open preview"
|
4386
|
+
})
|
4387
|
+
}
|
4388
|
+
) })
|
4389
|
+
}
|
4390
|
+
)
|
3092
4391
|
};
|
3093
4392
|
};
|
3094
|
-
const
|
3095
|
-
|
3096
|
-
const
|
3097
|
-
|
3098
|
-
|
3099
|
-
}
|
3100
|
-
const metadata = metadatas[name];
|
3101
|
-
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
3102
|
-
return {
|
3103
|
-
attribute,
|
3104
|
-
label: metadata.label ?? "",
|
3105
|
-
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
3106
|
-
schemas,
|
3107
|
-
components: components?.schemas ?? {}
|
3108
|
-
}),
|
3109
|
-
name,
|
3110
|
-
searchable: metadata.searchable ?? true,
|
3111
|
-
sortable: metadata.sortable ?? true
|
3112
|
-
};
|
3113
|
-
}).filter((field) => field !== null);
|
4393
|
+
const previewAdmin = {
|
4394
|
+
bootstrap(app) {
|
4395
|
+
const contentManagerPluginApis = app.getPlugin("content-manager").apis;
|
4396
|
+
contentManagerPluginApis.addEditViewSidePanel([PreviewSidePanel]);
|
4397
|
+
}
|
3114
4398
|
};
|
3115
4399
|
const index = {
|
3116
4400
|
register(app) {
|
3117
4401
|
const cm = new ContentManagerPlugin();
|
3118
4402
|
app.addReducers({
|
3119
|
-
[contentManagerApi.reducerPath]: contentManagerApi.reducer,
|
3120
4403
|
[PLUGIN_ID]: reducer
|
3121
4404
|
});
|
3122
|
-
app.addMiddlewares([() => contentManagerApi.middleware]);
|
3123
4405
|
app.addMenuLink({
|
3124
4406
|
to: PLUGIN_ID,
|
3125
4407
|
icon: Icons.Feather,
|
@@ -3128,14 +4410,32 @@ const index = {
|
|
3128
4410
|
defaultMessage: "Content Manager"
|
3129
4411
|
},
|
3130
4412
|
permissions: [],
|
3131
|
-
|
4413
|
+
position: 1
|
4414
|
+
});
|
4415
|
+
app.router.addRoute({
|
4416
|
+
path: "content-manager/*",
|
4417
|
+
lazy: async () => {
|
4418
|
+
const { Layout } = await Promise.resolve().then(() => require("./layout-4BqLFW_b.js"));
|
4419
|
+
return {
|
4420
|
+
Component: Layout
|
4421
|
+
};
|
4422
|
+
},
|
4423
|
+
children: routes
|
3132
4424
|
});
|
3133
4425
|
app.registerPlugin(cm.config);
|
3134
4426
|
},
|
4427
|
+
bootstrap(app) {
|
4428
|
+
if (typeof historyAdmin.bootstrap === "function") {
|
4429
|
+
historyAdmin.bootstrap(app);
|
4430
|
+
}
|
4431
|
+
if (typeof previewAdmin.bootstrap === "function") {
|
4432
|
+
previewAdmin.bootstrap(app);
|
4433
|
+
}
|
4434
|
+
},
|
3135
4435
|
async registerTrads({ locales }) {
|
3136
4436
|
const importedTrads = await Promise.all(
|
3137
4437
|
locales.map((locale) => {
|
3138
|
-
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-
|
4438
|
+
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-BR48D_RH.js")), "./translations/es.json": () => Promise.resolve().then(() => require("./es-9K52xZIr.js")), "./translations/eu.json": () => Promise.resolve().then(() => require("./eu-VDH-3ovk.js")), "./translations/fr.json": () => Promise.resolve().then(() => require("./fr-C43IbhA_.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-7sfIbjxE.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`, 3).then(({ default: data }) => {
|
3139
4439
|
return {
|
3140
4440
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
3141
4441
|
locale
|
@@ -3152,10 +4452,11 @@ const index = {
|
|
3152
4452
|
}
|
3153
4453
|
};
|
3154
4454
|
exports.ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD = ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD;
|
4455
|
+
exports.BulkActionsRenderer = BulkActionsRenderer;
|
4456
|
+
exports.CLONE_PATH = CLONE_PATH;
|
3155
4457
|
exports.COLLECTION_TYPES = COLLECTION_TYPES;
|
3156
4458
|
exports.CREATOR_FIELDS = CREATOR_FIELDS;
|
3157
4459
|
exports.DEFAULT_SETTINGS = DEFAULT_SETTINGS;
|
3158
|
-
exports.DOCUMENT_META_FIELDS = DOCUMENT_META_FIELDS;
|
3159
4460
|
exports.DocumentRBAC = DocumentRBAC;
|
3160
4461
|
exports.DocumentStatus = DocumentStatus;
|
3161
4462
|
exports.HOOKS = HOOKS;
|
@@ -3172,14 +4473,18 @@ exports.checkIfAttributeIsDisplayable = checkIfAttributeIsDisplayable;
|
|
3172
4473
|
exports.contentManagerApi = contentManagerApi;
|
3173
4474
|
exports.convertEditLayoutToFieldLayouts = convertEditLayoutToFieldLayouts;
|
3174
4475
|
exports.convertListLayoutToFieldLayouts = convertListLayoutToFieldLayouts;
|
4476
|
+
exports.createDefaultForm = createDefaultForm;
|
3175
4477
|
exports.createYupSchema = createYupSchema;
|
3176
4478
|
exports.extractContentTypeComponents = extractContentTypeComponents;
|
3177
4479
|
exports.getDisplayName = getDisplayName;
|
3178
4480
|
exports.getMainField = getMainField;
|
3179
4481
|
exports.getTranslation = getTranslation;
|
3180
4482
|
exports.index = index;
|
3181
|
-
exports.
|
4483
|
+
exports.prepareTempKeys = prepareTempKeys;
|
4484
|
+
exports.removeFieldsThatDontExistOnSchema = removeFieldsThatDontExistOnSchema;
|
3182
4485
|
exports.setInitialData = setInitialData;
|
4486
|
+
exports.transformDocument = transformDocument;
|
4487
|
+
exports.useContentManagerContext = useContentManagerContext;
|
3183
4488
|
exports.useContentTypeSchema = useContentTypeSchema;
|
3184
4489
|
exports.useDoc = useDoc;
|
3185
4490
|
exports.useDocLayout = useDocLayout;
|
@@ -3191,5 +4496,6 @@ exports.useGetAllContentTypeSettingsQuery = useGetAllContentTypeSettingsQuery;
|
|
3191
4496
|
exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
|
3192
4497
|
exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
|
3193
4498
|
exports.useGetInitialDataQuery = useGetInitialDataQuery;
|
4499
|
+
exports.useGetPreviewUrlQuery = useGetPreviewUrlQuery;
|
3194
4500
|
exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
|
3195
|
-
//# sourceMappingURL=index-
|
4501
|
+
//# sourceMappingURL=index-DkJQjlak.js.map
|