@strapi/content-manager 0.0.0-experimental.a6728ad43ac70ae19dabb624dbfca1f2d9610a86 → 0.0.0-experimental.a687a6977f91492ccfc6771bf398a5236ece3c94

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.
Files changed (169) hide show
  1. package/dist/_chunks/{ComponentConfigurationPage-_6osrv39.js → ComponentConfigurationPage-BebDdCkl.js} +4 -4
  2. package/dist/_chunks/{ComponentConfigurationPage-_6osrv39.js.map → ComponentConfigurationPage-BebDdCkl.js.map} +1 -1
  3. package/dist/_chunks/{ComponentConfigurationPage-DJ5voqEK.mjs → ComponentConfigurationPage-XdGcgtZh.mjs} +4 -4
  4. package/dist/_chunks/{ComponentConfigurationPage-DJ5voqEK.mjs.map → ComponentConfigurationPage-XdGcgtZh.mjs.map} +1 -1
  5. package/dist/_chunks/{EditConfigurationPage-CZofxSLy.mjs → EditConfigurationPage-DaNf9MoK.mjs} +4 -4
  6. package/dist/_chunks/{EditConfigurationPage-CZofxSLy.mjs.map → EditConfigurationPage-DaNf9MoK.mjs.map} +1 -1
  7. package/dist/_chunks/{EditConfigurationPage-ZN3s568V.js → EditConfigurationPage-sdGi-bna.js} +4 -4
  8. package/dist/_chunks/{EditConfigurationPage-ZN3s568V.js.map → EditConfigurationPage-sdGi-bna.js.map} +1 -1
  9. package/dist/_chunks/{EditViewPage-Co2IKQZH.js → EditViewPage-BRA-JSnw.js} +49 -9
  10. package/dist/_chunks/EditViewPage-BRA-JSnw.js.map +1 -0
  11. package/dist/_chunks/{EditViewPage-HYljoEY7.mjs → EditViewPage-DtbTsNeX.mjs} +50 -10
  12. package/dist/_chunks/EditViewPage-DtbTsNeX.mjs.map +1 -0
  13. package/dist/_chunks/{Field-BOPUMZ1u.mjs → Field-CDmB9zqh.mjs} +107 -44
  14. package/dist/_chunks/Field-CDmB9zqh.mjs.map +1 -0
  15. package/dist/_chunks/{Field-G9CkFUtP.js → Field-DoVRA4co.js} +107 -44
  16. package/dist/_chunks/Field-DoVRA4co.js.map +1 -0
  17. package/dist/_chunks/{Form-crsbkGxI.js → Form-BEh514bg.js} +3 -3
  18. package/dist/_chunks/Form-BEh514bg.js.map +1 -0
  19. package/dist/_chunks/{Form-CDwNp7pU.mjs → Form-Cle2X-4n.mjs} +3 -3
  20. package/dist/_chunks/Form-Cle2X-4n.mjs.map +1 -0
  21. package/dist/_chunks/{History-CWcM9HnW.js → History-BsPXl1XH.js} +40 -97
  22. package/dist/_chunks/History-BsPXl1XH.js.map +1 -0
  23. package/dist/_chunks/{History-BDZrgfZ3.mjs → History-ktAPcvHJ.mjs} +42 -99
  24. package/dist/_chunks/History-ktAPcvHJ.mjs.map +1 -0
  25. package/dist/_chunks/{ListConfigurationPage-BZ3ScUna.mjs → ListConfigurationPage-BNAS_v2s.mjs} +6 -5
  26. package/dist/_chunks/ListConfigurationPage-BNAS_v2s.mjs.map +1 -0
  27. package/dist/_chunks/{ListConfigurationPage-DGzoQD_I.js → ListConfigurationPage-CN1-7Pgi.js} +5 -4
  28. package/dist/_chunks/ListConfigurationPage-CN1-7Pgi.js.map +1 -0
  29. package/dist/_chunks/{ListViewPage-CsX7tWx-.mjs → ListViewPage-B15c_0Vt.mjs} +17 -6
  30. package/dist/_chunks/{ListViewPage-CsX7tWx-.mjs.map → ListViewPage-B15c_0Vt.mjs.map} +1 -1
  31. package/dist/_chunks/{ListViewPage-BBAC9aPu.js → ListViewPage-BUKFOJuS.js} +17 -6
  32. package/dist/_chunks/ListViewPage-BUKFOJuS.js.map +1 -0
  33. package/dist/_chunks/{NoContentTypePage-LClTUPWs.mjs → NoContentTypePage-CAgdmhlo.mjs} +2 -2
  34. package/dist/_chunks/{NoContentTypePage-LClTUPWs.mjs.map → NoContentTypePage-CAgdmhlo.mjs.map} +1 -1
  35. package/dist/_chunks/{NoContentTypePage-CwVDx_YC.js → NoContentTypePage-Cs7Kk9EW.js} +2 -2
  36. package/dist/_chunks/{NoContentTypePage-CwVDx_YC.js.map → NoContentTypePage-Cs7Kk9EW.js.map} +1 -1
  37. package/dist/_chunks/{NoPermissionsPage-D2iWw-sn.js → NoPermissionsPage-DRPnEq9t.js} +2 -2
  38. package/dist/_chunks/{NoPermissionsPage-D2iWw-sn.js.map → NoPermissionsPage-DRPnEq9t.js.map} +1 -1
  39. package/dist/_chunks/{NoPermissionsPage-S4Re3FwO.mjs → NoPermissionsPage-JxX4Y4RJ.mjs} +2 -2
  40. package/dist/_chunks/{NoPermissionsPage-S4Re3FwO.mjs.map → NoPermissionsPage-JxX4Y4RJ.mjs.map} +1 -1
  41. package/dist/_chunks/Preview-BKuVG1dV.js +286 -0
  42. package/dist/_chunks/Preview-BKuVG1dV.js.map +1 -0
  43. package/dist/_chunks/Preview-CQlTtbLc.mjs +267 -0
  44. package/dist/_chunks/Preview-CQlTtbLc.mjs.map +1 -0
  45. package/dist/_chunks/{Relations-Dmv0Tpe5.mjs → Relations-DMQ93R3L.mjs} +72 -36
  46. package/dist/_chunks/Relations-DMQ93R3L.mjs.map +1 -0
  47. package/dist/_chunks/{Relations-jwuTFGOV.js → Relations-DTEGSaM_.js} +71 -35
  48. package/dist/_chunks/Relations-DTEGSaM_.js.map +1 -0
  49. package/dist/_chunks/{en-C8YBvRrK.mjs → en-CfIXaZf9.mjs} +20 -9
  50. package/dist/_chunks/{en-C8YBvRrK.mjs.map → en-CfIXaZf9.mjs.map} +1 -1
  51. package/dist/_chunks/{en-BlhnxQfj.js → en-DTWPCdTS.js} +20 -9
  52. package/dist/_chunks/{en-BlhnxQfj.js.map → en-DTWPCdTS.js.map} +1 -1
  53. package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
  54. package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
  55. package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
  56. package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
  57. package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
  58. package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
  59. package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
  60. package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
  61. package/dist/_chunks/{index-BmUAydCA.mjs → index-BdUq-Dtg.mjs} +262 -156
  62. package/dist/_chunks/index-BdUq-Dtg.mjs.map +1 -0
  63. package/dist/_chunks/{index-CBX6KyXv.js → index-DjV7tyGu.js} +258 -151
  64. package/dist/_chunks/index-DjV7tyGu.js.map +1 -0
  65. package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
  66. package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
  67. package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
  68. package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
  69. package/dist/_chunks/{layout-ClP-DC72.mjs → layout-BJ8CpEJu.mjs} +3 -3
  70. package/dist/_chunks/{layout-ClP-DC72.mjs.map → layout-BJ8CpEJu.mjs.map} +1 -1
  71. package/dist/_chunks/{layout-CxxkX9jY.js → layout-Cx9LHtH5.js} +3 -3
  72. package/dist/_chunks/{layout-CxxkX9jY.js.map → layout-Cx9LHtH5.js.map} +1 -1
  73. package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
  74. package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
  75. package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
  76. package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
  77. package/dist/_chunks/{relations-DIjTADIu.js → relations-5bc76OJz.js} +6 -7
  78. package/dist/_chunks/relations-5bc76OJz.js.map +1 -0
  79. package/dist/_chunks/{relations-op89RClB.mjs → relations-BeezTo41.mjs} +6 -7
  80. package/dist/_chunks/relations-BeezTo41.mjs.map +1 -0
  81. package/dist/admin/index.js +1 -1
  82. package/dist/admin/index.mjs +4 -4
  83. package/dist/admin/src/hooks/useDocument.d.ts +2 -0
  84. package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
  85. package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +2 -2
  86. package/dist/admin/src/pages/EditView/components/Header.d.ts +1 -0
  87. package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
  88. package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
  89. package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
  90. package/dist/admin/src/preview/constants.d.ts +1 -0
  91. package/dist/admin/src/preview/index.d.ts +4 -0
  92. package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
  93. package/dist/admin/src/preview/routes.d.ts +3 -0
  94. package/dist/admin/src/preview/services/preview.d.ts +3 -0
  95. package/dist/admin/src/router.d.ts +1 -1
  96. package/dist/admin/src/services/documents.d.ts +0 -3
  97. package/dist/server/index.js +371 -158
  98. package/dist/server/index.js.map +1 -1
  99. package/dist/server/index.mjs +371 -158
  100. package/dist/server/index.mjs.map +1 -1
  101. package/dist/server/src/bootstrap.d.ts.map +1 -1
  102. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  103. package/dist/server/src/controllers/index.d.ts.map +1 -1
  104. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  105. package/dist/server/src/controllers/utils/metadata.d.ts +15 -1
  106. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  107. package/dist/server/src/history/services/history.d.ts.map +1 -1
  108. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  109. package/dist/server/src/history/services/utils.d.ts +2 -3
  110. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  111. package/dist/server/src/index.d.ts +4 -4
  112. package/dist/server/src/preview/constants.d.ts +2 -0
  113. package/dist/server/src/preview/constants.d.ts.map +1 -0
  114. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  115. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  116. package/dist/server/src/preview/controllers/preview.d.ts +13 -0
  117. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  118. package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
  119. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
  120. package/dist/server/src/preview/index.d.ts +4 -0
  121. package/dist/server/src/preview/index.d.ts.map +1 -0
  122. package/dist/server/src/preview/routes/index.d.ts +8 -0
  123. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  124. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  125. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  126. package/dist/server/src/preview/services/index.d.ts +15 -0
  127. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  128. package/dist/server/src/preview/services/preview-config.d.ts +30 -0
  129. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
  130. package/dist/server/src/preview/services/preview.d.ts +12 -0
  131. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  132. package/dist/server/src/preview/utils.d.ts +18 -0
  133. package/dist/server/src/preview/utils.d.ts.map +1 -0
  134. package/dist/server/src/routes/index.d.ts.map +1 -1
  135. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  136. package/dist/server/src/services/document-metadata.d.ts +8 -8
  137. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  138. package/dist/server/src/services/index.d.ts +4 -4
  139. package/dist/server/src/services/index.d.ts.map +1 -1
  140. package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
  141. package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
  142. package/dist/server/src/utils/index.d.ts +2 -0
  143. package/dist/server/src/utils/index.d.ts.map +1 -1
  144. package/dist/shared/contracts/index.d.ts +1 -0
  145. package/dist/shared/contracts/index.d.ts.map +1 -1
  146. package/dist/shared/contracts/preview.d.ts +27 -0
  147. package/dist/shared/contracts/preview.d.ts.map +1 -0
  148. package/dist/shared/index.js +4 -0
  149. package/dist/shared/index.js.map +1 -1
  150. package/dist/shared/index.mjs +4 -0
  151. package/dist/shared/index.mjs.map +1 -1
  152. package/package.json +11 -11
  153. package/dist/_chunks/EditViewPage-Co2IKQZH.js.map +0 -1
  154. package/dist/_chunks/EditViewPage-HYljoEY7.mjs.map +0 -1
  155. package/dist/_chunks/Field-BOPUMZ1u.mjs.map +0 -1
  156. package/dist/_chunks/Field-G9CkFUtP.js.map +0 -1
  157. package/dist/_chunks/Form-CDwNp7pU.mjs.map +0 -1
  158. package/dist/_chunks/Form-crsbkGxI.js.map +0 -1
  159. package/dist/_chunks/History-BDZrgfZ3.mjs.map +0 -1
  160. package/dist/_chunks/History-CWcM9HnW.js.map +0 -1
  161. package/dist/_chunks/ListConfigurationPage-BZ3ScUna.mjs.map +0 -1
  162. package/dist/_chunks/ListConfigurationPage-DGzoQD_I.js.map +0 -1
  163. package/dist/_chunks/ListViewPage-BBAC9aPu.js.map +0 -1
  164. package/dist/_chunks/Relations-Dmv0Tpe5.mjs.map +0 -1
  165. package/dist/_chunks/Relations-jwuTFGOV.js.map +0 -1
  166. package/dist/_chunks/index-BmUAydCA.mjs.map +0 -1
  167. package/dist/_chunks/index-CBX6KyXv.js.map +0 -1
  168. package/dist/_chunks/relations-DIjTADIu.js.map +0 -1
  169. package/dist/_chunks/relations-op89RClB.mjs.map +0 -1
@@ -1,17 +1,18 @@
1
1
  import { More, Cross, WarningCircle, ListPlus, Pencil, Trash, Check, CrossCircle, CheckCircle, ArrowsCounterClockwise, ChevronRight, Duplicate, ClockCounterClockwise, Feather } from "@strapi/icons";
2
2
  import { jsx, Fragment, jsxs } from "react/jsx-runtime";
3
- import { useStrapiApp, createContext, useAuth, useRBAC, Page, adminApi, translatedErrors, useNotification, useAPIErrorHandler, useQueryParams, getYupValidationErrors, useForm, useTracking, useGuidedTour, BackButton, DescriptionComponentRenderer, useTable, Table } from "@strapi/admin/strapi-admin";
3
+ import { useStrapiApp, createContext, useQueryParams, useAuth, useRBAC, Page, adminApi, translatedErrors, useNotification, useAPIErrorHandler, getYupValidationErrors, useForm, useTracking, useGuidedTour, BackButton, DescriptionComponentRenderer, useTable, Table } from "@strapi/admin/strapi-admin";
4
4
  import * as React from "react";
5
5
  import { lazy } from "react";
6
- import { Button, Menu, VisuallyHidden, Flex, Typography, Dialog, Modal, Radio, Status, Box, SingleSelect, SingleSelectOption, IconButton, Loader, Tooltip, LinkButton } from "@strapi/design-system";
6
+ import { Menu, Button, VisuallyHidden, Flex, Dialog, Modal, Typography, Radio, Status, Box, SingleSelect, SingleSelectOption, IconButton, Loader, Tooltip, LinkButton } from "@strapi/design-system";
7
+ import mapValues from "lodash/fp/mapValues";
7
8
  import { useIntl } from "react-intl";
8
9
  import { useParams, useNavigate, Navigate, useMatch, useLocation, Link, NavLink } from "react-router-dom";
10
+ import { styled } from "styled-components";
9
11
  import * as yup from "yup";
10
12
  import { ValidationError } from "yup";
13
+ import { stringify } from "qs";
11
14
  import pipe from "lodash/fp/pipe";
12
15
  import { intervalToDuration, isPast } from "date-fns";
13
- import { styled } from "styled-components";
14
- import { stringify } from "qs";
15
16
  import { createSlice, combineReducers } from "@reduxjs/toolkit";
16
17
  const __variableDynamicImportRuntimeHelper = (glob, path) => {
17
18
  const v = glob[path];
@@ -100,6 +101,7 @@ const DocumentRBAC = ({ children, permissions }) => {
100
101
  if (!slug) {
101
102
  throw new Error("Cannot find the slug param in the URL");
102
103
  }
104
+ const [{ rawQuery }] = useQueryParams();
103
105
  const userPermissions = useAuth("DocumentRBAC", (state) => state.permissions);
104
106
  const contentTypePermissions = React.useMemo(() => {
105
107
  const contentTypePermissions2 = userPermissions.filter(
@@ -110,7 +112,14 @@ const DocumentRBAC = ({ children, permissions }) => {
110
112
  return { ...acc, [action]: [permission] };
111
113
  }, {});
112
114
  }, [slug, userPermissions]);
113
- const { isLoading, allowedActions } = useRBAC(contentTypePermissions, permissions ?? void 0);
115
+ const { isLoading, allowedActions } = useRBAC(
116
+ contentTypePermissions,
117
+ permissions ?? void 0,
118
+ // TODO: useRBAC context should be typed and built differently
119
+ // We are passing raw query as context to the hook so that it can
120
+ // rely on the locale provided from DocumentRBAC for its permission calculations.
121
+ rawQuery
122
+ );
114
123
  const canCreateFields = !isLoading && allowedActions.canCreate ? extractAndDedupeFields(contentTypePermissions.create) : [];
115
124
  const canReadFields = !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];
116
125
  const canUpdateFields = !isLoading && allowedActions.canUpdate ? extractAndDedupeFields(contentTypePermissions.update) : [];
@@ -265,7 +274,7 @@ const documentApi = contentManagerApi.injectEndpoints({
265
274
  url: `/content-manager/collection-types/${model}`,
266
275
  method: "GET",
267
276
  config: {
268
- params
277
+ params: stringify(params, { encode: true })
269
278
  }
270
279
  }),
271
280
  providesTags: (result, _error, arg) => {
@@ -453,14 +462,29 @@ const buildValidParams = (query) => {
453
462
  {}
454
463
  )
455
464
  };
456
- if ("_q" in validQueryParams) {
457
- validQueryParams._q = encodeURIComponent(validQueryParams._q);
458
- }
459
465
  return validQueryParams;
460
466
  };
461
467
  const isBaseQueryError = (error) => {
462
468
  return error.name !== void 0;
463
469
  };
470
+ const arrayValidator = (attribute, options) => ({
471
+ message: translatedErrors.required,
472
+ test(value) {
473
+ if (options.status === "draft") {
474
+ return true;
475
+ }
476
+ if (!attribute.required) {
477
+ return true;
478
+ }
479
+ if (!value) {
480
+ return false;
481
+ }
482
+ if (Array.isArray(value) && value.length === 0) {
483
+ return false;
484
+ }
485
+ return true;
486
+ }
487
+ });
464
488
  const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
465
489
  const createModelSchema = (attributes2) => yup.object().shape(
466
490
  Object.entries(attributes2).reduce((acc, [name, attribute]) => {
@@ -468,6 +492,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
468
492
  return acc;
469
493
  }
470
494
  const validations = [
495
+ addNullableValidation,
471
496
  addRequiredValidation,
472
497
  addMinLengthValidation,
473
498
  addMaxLengthValidation,
@@ -484,12 +509,12 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
484
509
  ...acc,
485
510
  [name]: transformSchema(
486
511
  yup.array().of(createModelSchema(attributes3).nullable(false))
487
- )
512
+ ).test(arrayValidator(attribute, options))
488
513
  };
489
514
  } else {
490
515
  return {
491
516
  ...acc,
492
- [name]: transformSchema(createModelSchema(attributes3))
517
+ [name]: transformSchema(createModelSchema(attributes3).nullable())
493
518
  };
494
519
  }
495
520
  }
@@ -511,7 +536,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
511
536
  }
512
537
  )
513
538
  )
514
- )
539
+ ).test(arrayValidator(attribute, options))
515
540
  };
516
541
  case "relation":
517
542
  return {
@@ -523,7 +548,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
523
548
  } else if (Array.isArray(value)) {
524
549
  return yup.array().of(
525
550
  yup.object().shape({
526
- id: yup.string().required()
551
+ id: yup.number().required()
527
552
  })
528
553
  );
529
554
  } else if (typeof value === "object") {
@@ -609,17 +634,17 @@ const nullableSchema = (schema) => {
609
634
  schema
610
635
  );
611
636
  };
637
+ const addNullableValidation = () => (schema) => {
638
+ return nullableSchema(schema);
639
+ };
612
640
  const addRequiredValidation = (attribute, options) => (schema) => {
613
- if (options.status === "draft") {
614
- return nullableSchema(schema);
615
- }
616
- if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
617
- return schema.min(1, translatedErrors.required);
641
+ if (options.status === "draft" || !attribute.required) {
642
+ return schema;
618
643
  }
619
- if (attribute.required && attribute.type !== "relation") {
644
+ if (attribute.required && "required" in schema) {
620
645
  return schema.required(translatedErrors.required);
621
646
  }
622
- return nullableSchema(schema);
647
+ return schema;
623
648
  };
624
649
  const addMinLengthValidation = (attribute, options) => (schema) => {
625
650
  if (options.status === "draft") {
@@ -647,31 +672,12 @@ const addMaxLengthValidation = (attribute) => (schema) => {
647
672
  return schema;
648
673
  };
649
674
  const addMinValidation = (attribute, options) => (schema) => {
650
- if ("min" in attribute) {
675
+ if (options.status === "draft") {
676
+ return schema;
677
+ }
678
+ if ("min" in attribute && "min" in schema) {
651
679
  const min = toInteger(attribute.min);
652
- if (attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") {
653
- if (options.status !== "draft" && !attribute.required && "test" in schema && min) {
654
- return schema.test(
655
- "custom-min",
656
- {
657
- ...translatedErrors.min,
658
- values: {
659
- min: attribute.min
660
- }
661
- },
662
- (value) => {
663
- if (!value) {
664
- return true;
665
- }
666
- if (Array.isArray(value) && value.length === 0) {
667
- return true;
668
- }
669
- return value.length >= min;
670
- }
671
- );
672
- }
673
- }
674
- if ("min" in schema && min) {
680
+ if (min) {
675
681
  return schema.min(min, {
676
682
  ...translatedErrors.min,
677
683
  values: {
@@ -960,9 +966,10 @@ const formatEditLayout = (data, {
960
966
  currentPanelIndex += 2;
961
967
  } else {
962
968
  if (!panels[currentPanelIndex]) {
963
- panels.push([]);
969
+ panels.push([row]);
970
+ } else {
971
+ panels[currentPanelIndex].push(row);
964
972
  }
965
- panels[currentPanelIndex].push(row);
966
973
  }
967
974
  return panels;
968
975
  }, []);
@@ -1144,11 +1151,13 @@ const useDocument = (args, opts) => {
1144
1151
  [validationSchema]
1145
1152
  );
1146
1153
  const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
1154
+ const hasError = !!error;
1147
1155
  return {
1148
1156
  components,
1149
1157
  document: data?.data,
1150
1158
  meta: data?.meta,
1151
1159
  isLoading,
1160
+ hasError,
1152
1161
  schema,
1153
1162
  schemas,
1154
1163
  validate
@@ -1164,16 +1173,18 @@ const useDoc = () => {
1164
1173
  if (!slug) {
1165
1174
  throw new Error("Could not find model in url params");
1166
1175
  }
1176
+ const document = useDocument(
1177
+ { documentId: origin || id, model: slug, collectionType, params },
1178
+ {
1179
+ skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
1180
+ }
1181
+ );
1182
+ const returnId = origin || id === "create" ? void 0 : id;
1167
1183
  return {
1168
1184
  collectionType,
1169
1185
  model: slug,
1170
- id: origin || id === "create" ? void 0 : id,
1171
- ...useDocument(
1172
- { documentId: origin || id, model: slug, collectionType, params },
1173
- {
1174
- skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
1175
- }
1176
- )
1186
+ id: returnId,
1187
+ ...document
1177
1188
  };
1178
1189
  };
1179
1190
  const useContentManagerContext = () => {
@@ -1216,9 +1227,6 @@ const useContentManagerContext = () => {
1216
1227
  };
1217
1228
  };
1218
1229
  const prefixPluginTranslations = (trad, pluginId) => {
1219
- if (!pluginId) {
1220
- throw new TypeError("pluginId can't be empty");
1221
- }
1222
1230
  return Object.keys(trad).reduce((acc, current) => {
1223
1231
  acc[`${pluginId}.${current}`] = trad[current];
1224
1232
  return acc;
@@ -1652,10 +1660,10 @@ const useDocumentActions = () => {
1652
1660
  update
1653
1661
  };
1654
1662
  };
1655
- const ProtectedHistoryPage = lazy(
1656
- () => import("./History-BDZrgfZ3.mjs").then((mod) => ({ default: mod.ProtectedHistoryPage }))
1663
+ const ProtectedHistoryPage = React.lazy(
1664
+ () => import("./History-ktAPcvHJ.mjs").then((mod) => ({ default: mod.ProtectedHistoryPage }))
1657
1665
  );
1658
- const routes$1 = [
1666
+ const routes$2 = [
1659
1667
  {
1660
1668
  path: ":collectionType/:slug/:id/history",
1661
1669
  Component: ProtectedHistoryPage
@@ -1665,32 +1673,45 @@ const routes$1 = [
1665
1673
  Component: ProtectedHistoryPage
1666
1674
  }
1667
1675
  ];
1676
+ const ProtectedPreviewPage = React.lazy(
1677
+ () => import("./Preview-CQlTtbLc.mjs").then((mod) => ({ default: mod.ProtectedPreviewPage }))
1678
+ );
1679
+ const routes$1 = [
1680
+ {
1681
+ path: ":collectionType/:slug/:id/preview",
1682
+ Component: ProtectedPreviewPage
1683
+ },
1684
+ {
1685
+ path: ":collectionType/:slug/preview",
1686
+ Component: ProtectedPreviewPage
1687
+ }
1688
+ ];
1668
1689
  const ProtectedEditViewPage = lazy(
1669
- () => import("./EditViewPage-HYljoEY7.mjs").then((mod) => ({ default: mod.ProtectedEditViewPage }))
1690
+ () => import("./EditViewPage-DtbTsNeX.mjs").then((mod) => ({ default: mod.ProtectedEditViewPage }))
1670
1691
  );
1671
1692
  const ProtectedListViewPage = lazy(
1672
- () => import("./ListViewPage-CsX7tWx-.mjs").then((mod) => ({ default: mod.ProtectedListViewPage }))
1693
+ () => import("./ListViewPage-B15c_0Vt.mjs").then((mod) => ({ default: mod.ProtectedListViewPage }))
1673
1694
  );
1674
1695
  const ProtectedListConfiguration = lazy(
1675
- () => import("./ListConfigurationPage-BZ3ScUna.mjs").then((mod) => ({
1696
+ () => import("./ListConfigurationPage-BNAS_v2s.mjs").then((mod) => ({
1676
1697
  default: mod.ProtectedListConfiguration
1677
1698
  }))
1678
1699
  );
1679
1700
  const ProtectedEditConfigurationPage = lazy(
1680
- () => import("./EditConfigurationPage-CZofxSLy.mjs").then((mod) => ({
1701
+ () => import("./EditConfigurationPage-DaNf9MoK.mjs").then((mod) => ({
1681
1702
  default: mod.ProtectedEditConfigurationPage
1682
1703
  }))
1683
1704
  );
1684
1705
  const ProtectedComponentConfigurationPage = lazy(
1685
- () => import("./ComponentConfigurationPage-DJ5voqEK.mjs").then((mod) => ({
1706
+ () => import("./ComponentConfigurationPage-XdGcgtZh.mjs").then((mod) => ({
1686
1707
  default: mod.ProtectedComponentConfigurationPage
1687
1708
  }))
1688
1709
  );
1689
1710
  const NoPermissions = lazy(
1690
- () => import("./NoPermissionsPage-S4Re3FwO.mjs").then((mod) => ({ default: mod.NoPermissions }))
1711
+ () => import("./NoPermissionsPage-JxX4Y4RJ.mjs").then((mod) => ({ default: mod.NoPermissions }))
1691
1712
  );
1692
1713
  const NoContentType = lazy(
1693
- () => import("./NoContentTypePage-LClTUPWs.mjs").then((mod) => ({ default: mod.NoContentType }))
1714
+ () => import("./NoContentTypePage-CAgdmhlo.mjs").then((mod) => ({ default: mod.NoContentType }))
1694
1715
  );
1695
1716
  const CollectionTypePages = () => {
1696
1717
  const { collectionType } = useParams();
@@ -1702,7 +1723,7 @@ const CollectionTypePages = () => {
1702
1723
  const CLONE_RELATIVE_PATH = ":collectionType/:slug/clone/:origin";
1703
1724
  const CLONE_PATH = `/content-manager/${CLONE_RELATIVE_PATH}`;
1704
1725
  const LIST_RELATIVE_PATH = ":collectionType/:slug";
1705
- const LIST_PATH = `/content-manager/${LIST_RELATIVE_PATH}`;
1726
+ const LIST_PATH = `/content-manager/collection-types/:slug`;
1706
1727
  const routes = [
1707
1728
  {
1708
1729
  path: LIST_RELATIVE_PATH,
@@ -1736,6 +1757,7 @@ const routes = [
1736
1757
  path: "no-content-types",
1737
1758
  Component: NoContentType
1738
1759
  },
1760
+ ...routes$2,
1739
1761
  ...routes$1
1740
1762
  ];
1741
1763
  const DocumentActions = ({ actions: actions2 }) => {
@@ -1834,6 +1856,11 @@ const DocumentActionButton = (action) => {
1834
1856
  ) : null
1835
1857
  ] });
1836
1858
  };
1859
+ const MenuItem = styled(Menu.Item)`
1860
+ &:hover {
1861
+ background: ${({ theme, isVariantDanger, isDisabled }) => isVariantDanger && !isDisabled ? theme.colors.danger100 : "neutral"};
1862
+ }
1863
+ `;
1837
1864
  const DocumentActionsMenu = ({
1838
1865
  actions: actions2,
1839
1866
  children,
@@ -1892,48 +1919,32 @@ const DocumentActionsMenu = ({
1892
1919
  /* @__PURE__ */ jsxs(Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
1893
1920
  actions2.map((action) => {
1894
1921
  return /* @__PURE__ */ jsx(
1895
- Menu.Item,
1922
+ MenuItem,
1896
1923
  {
1897
1924
  disabled: action.disabled,
1898
1925
  onSelect: handleClick(action),
1899
1926
  display: "block",
1900
- children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", gap: 4, children: [
1901
- /* @__PURE__ */ jsxs(
1902
- Flex,
1903
- {
1904
- color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
1905
- gap: 2,
1906
- tag: "span",
1907
- children: [
1908
- /* @__PURE__ */ jsx(
1909
- Flex,
1910
- {
1911
- tag: "span",
1912
- color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
1913
- children: action.icon
1914
- }
1915
- ),
1916
- action.label
1917
- ]
1918
- }
1919
- ),
1920
- action.id.startsWith("HistoryAction") && /* @__PURE__ */ jsx(
1921
- Flex,
1922
- {
1923
- alignItems: "center",
1924
- background: "alternative100",
1925
- borderStyle: "solid",
1926
- borderColor: "alternative200",
1927
- borderWidth: "1px",
1928
- height: 5,
1929
- paddingLeft: 2,
1930
- paddingRight: 2,
1931
- hasRadius: true,
1932
- color: "alternative600",
1933
- children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", fontWeight: "bold", lineHeight: 1, children: formatMessage({ id: "global.new", defaultMessage: "New" }) })
1934
- }
1935
- )
1936
- ] })
1927
+ isVariantDanger: action.variant === "danger",
1928
+ isDisabled: action.disabled,
1929
+ children: /* @__PURE__ */ jsx(Flex, { justifyContent: "space-between", gap: 4, children: /* @__PURE__ */ jsxs(
1930
+ Flex,
1931
+ {
1932
+ color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
1933
+ gap: 2,
1934
+ tag: "span",
1935
+ children: [
1936
+ /* @__PURE__ */ jsx(
1937
+ Flex,
1938
+ {
1939
+ tag: "span",
1940
+ color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
1941
+ children: action.icon
1942
+ }
1943
+ ),
1944
+ action.label
1945
+ ]
1946
+ }
1947
+ ) })
1937
1948
  },
1938
1949
  action.id
1939
1950
  );
@@ -2044,6 +2055,18 @@ const DocumentActionModal = ({
2044
2055
  typeof Footer === "function" ? /* @__PURE__ */ jsx(Footer, { onClose: handleClose }) : Footer
2045
2056
  ] }) });
2046
2057
  };
2058
+ const transformData = (data) => {
2059
+ if (Array.isArray(data)) {
2060
+ return data.map(transformData);
2061
+ }
2062
+ if (typeof data === "object" && data !== null) {
2063
+ if ("apiData" in data) {
2064
+ return data.apiData;
2065
+ }
2066
+ return mapValues(transformData)(data);
2067
+ }
2068
+ return data;
2069
+ };
2047
2070
  const PublishAction$1 = ({
2048
2071
  activeTab,
2049
2072
  documentId,
@@ -2137,7 +2160,9 @@ const PublishAction$1 = ({
2137
2160
  const performPublish = async () => {
2138
2161
  setSubmitting(true);
2139
2162
  try {
2140
- const { errors } = await validate();
2163
+ const { errors } = await validate(true, {
2164
+ status: "published"
2165
+ });
2141
2166
  if (errors) {
2142
2167
  toggleNotification({
2143
2168
  type: "danger",
@@ -2155,7 +2180,7 @@ const PublishAction$1 = ({
2155
2180
  documentId,
2156
2181
  params
2157
2182
  },
2158
- formValues
2183
+ transformData(formValues)
2159
2184
  );
2160
2185
  if ("data" in res && collectionType !== SINGLE_TYPES) {
2161
2186
  navigate({
@@ -2245,24 +2270,24 @@ const UpdateAction = ({
2245
2270
  */
2246
2271
  disabled: isSubmitting || !modified && !isCloning || activeTab === "published",
2247
2272
  label: formatMessage({
2248
- id: "content-manager.containers.Edit.save",
2273
+ id: "global.save",
2249
2274
  defaultMessage: "Save"
2250
2275
  }),
2251
2276
  onClick: async () => {
2252
2277
  setSubmitting(true);
2253
2278
  try {
2254
- if (activeTab !== "draft") {
2255
- const { errors } = await validate();
2256
- if (errors) {
2257
- toggleNotification({
2258
- type: "danger",
2259
- message: formatMessage({
2260
- id: "content-manager.validation.error",
2261
- defaultMessage: "There are validation errors in your document. Please fix them before saving."
2262
- })
2263
- });
2264
- return;
2265
- }
2279
+ const { errors } = await validate(true, {
2280
+ status: "draft"
2281
+ });
2282
+ if (errors) {
2283
+ toggleNotification({
2284
+ type: "danger",
2285
+ message: formatMessage({
2286
+ id: "content-manager.validation.error",
2287
+ defaultMessage: "There are validation errors in your document. Please fix them before saving."
2288
+ })
2289
+ });
2290
+ return;
2266
2291
  }
2267
2292
  if (isCloning) {
2268
2293
  const res = await clone(
@@ -2271,7 +2296,7 @@ const UpdateAction = ({
2271
2296
  documentId: cloneMatch.params.origin,
2272
2297
  params
2273
2298
  },
2274
- document
2299
+ transformData(document)
2275
2300
  );
2276
2301
  if ("data" in res) {
2277
2302
  navigate(
@@ -2292,7 +2317,7 @@ const UpdateAction = ({
2292
2317
  documentId,
2293
2318
  params
2294
2319
  },
2295
- document
2320
+ transformData(document)
2296
2321
  );
2297
2322
  if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
2298
2323
  setErrors(formatValidationErrors(res.error));
@@ -2305,7 +2330,7 @@ const UpdateAction = ({
2305
2330
  model,
2306
2331
  params
2307
2332
  },
2308
- document
2333
+ transformData(document)
2309
2334
  );
2310
2335
  if ("data" in res && collectionType !== SINGLE_TYPES) {
2311
2336
  navigate(
@@ -2510,7 +2535,7 @@ const RelativeTime = React.forwardRef(
2510
2535
  });
2511
2536
  const unit = intervals.find((intervalUnit) => {
2512
2537
  return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
2513
- });
2538
+ }) ?? "seconds";
2514
2539
  const relativeTime = isPast(timestamp) ? -interval[unit] : interval[unit];
2515
2540
  const customInterval = customIntervals.find(
2516
2541
  (custom) => interval[custom.unit] < custom.threshold
@@ -2544,19 +2569,29 @@ const getDisplayName = ({
2544
2569
  return email ?? "";
2545
2570
  };
2546
2571
  const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
2547
- const DocumentStatus = ({ status = "draft", ...restProps }) => {
2572
+ const DocumentStatus = ({ status = "draft", size = "S", ...restProps }) => {
2548
2573
  const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
2549
- return /* @__PURE__ */ jsx(Status, { ...restProps, showBullet: false, size: "S", variant: statusVariant, children: /* @__PURE__ */ jsx(Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: capitalise(status) }) });
2574
+ const { formatMessage } = useIntl();
2575
+ return /* @__PURE__ */ jsx(Status, { ...restProps, size, variant: statusVariant, children: /* @__PURE__ */ jsx(Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: formatMessage({
2576
+ id: `content-manager.containers.List.${status}`,
2577
+ defaultMessage: capitalise(status)
2578
+ }) }) });
2550
2579
  };
2551
2580
  const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
2552
2581
  const { formatMessage } = useIntl();
2553
2582
  const isCloning = useMatch(CLONE_PATH) !== null;
2583
+ const params = useParams();
2554
2584
  const title = isCreating ? formatMessage({
2555
2585
  id: "content-manager.containers.edit.title.new",
2556
2586
  defaultMessage: "Create an entry"
2557
2587
  }) : documentTitle;
2558
2588
  return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
2559
- /* @__PURE__ */ jsx(BackButton, {}),
2589
+ /* @__PURE__ */ jsx(
2590
+ BackButton,
2591
+ {
2592
+ fallback: params.collectionType === SINGLE_TYPES ? void 0 : `../${COLLECTION_TYPES}/${params.slug}`
2593
+ }
2594
+ ),
2560
2595
  /* @__PURE__ */ jsxs(Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
2561
2596
  /* @__PURE__ */ jsx(Typography, { variant: "alpha", tag: "h1", children: title }),
2562
2597
  /* @__PURE__ */ jsx(HeaderToolbar, {})
@@ -2644,12 +2679,12 @@ const Information = ({ activeTab }) => {
2644
2679
  isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
2645
2680
  label: formatMessage({
2646
2681
  id: "content-manager.containers.edit.information.last-published.label",
2647
- defaultMessage: "Last published"
2682
+ defaultMessage: "Published"
2648
2683
  }),
2649
2684
  value: formatMessage(
2650
2685
  {
2651
2686
  id: "content-manager.containers.edit.information.last-published.value",
2652
- defaultMessage: `Published {time}{isAnonymous, select, true {} other { by {author}}}`
2687
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2653
2688
  },
2654
2689
  {
2655
2690
  time: /* @__PURE__ */ jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
@@ -2662,12 +2697,12 @@ const Information = ({ activeTab }) => {
2662
2697
  isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
2663
2698
  label: formatMessage({
2664
2699
  id: "content-manager.containers.edit.information.last-draft.label",
2665
- defaultMessage: "Last draft"
2700
+ defaultMessage: "Updated"
2666
2701
  }),
2667
2702
  value: formatMessage(
2668
2703
  {
2669
2704
  id: "content-manager.containers.edit.information.last-draft.value",
2670
- defaultMessage: `Modified {time}{isAnonymous, select, true {} other { by {author}}}`
2705
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2671
2706
  },
2672
2707
  {
2673
2708
  time: /* @__PURE__ */ jsx(
@@ -2685,12 +2720,12 @@ const Information = ({ activeTab }) => {
2685
2720
  isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
2686
2721
  label: formatMessage({
2687
2722
  id: "content-manager.containers.edit.information.document.label",
2688
- defaultMessage: "Document"
2723
+ defaultMessage: "Created"
2689
2724
  }),
2690
2725
  value: formatMessage(
2691
2726
  {
2692
2727
  id: "content-manager.containers.edit.information.document.value",
2693
- defaultMessage: `Created {time}{isAnonymous, select, true {} other { by {author}}}`
2728
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2694
2729
  },
2695
2730
  {
2696
2731
  time: /* @__PURE__ */ jsx(
@@ -2748,10 +2783,9 @@ const HeaderActions = ({ actions: actions2 }) => {
2748
2783
  SingleSelect,
2749
2784
  {
2750
2785
  size: "S",
2751
- disabled: action.disabled,
2752
- "aria-label": action.label,
2753
2786
  onChange: action.onSelect,
2754
- value: action.value,
2787
+ "aria-label": action.label,
2788
+ ...action,
2755
2789
  children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsx(SingleSelectOption, { ...option, children: label }, option.value))
2756
2790
  },
2757
2791
  action.id
@@ -2994,7 +3028,7 @@ const Panel = React.forwardRef(({ children, title }, ref) => {
2994
3028
  justifyContent: "stretch",
2995
3029
  alignItems: "flex-start",
2996
3030
  children: [
2997
- /* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
3031
+ /* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", textColor: "neutral600", children: title }),
2998
3032
  children
2999
3033
  ]
3000
3034
  }
@@ -3244,18 +3278,10 @@ const SelectedEntriesTableContent = ({
3244
3278
  search: row.locale && `?plugins[i18n][locale]=${row.locale}`
3245
3279
  },
3246
3280
  state: { from: pathname },
3247
- label: formatMessage(
3248
- { id: "app.component.HelperPluginTable.edit", defaultMessage: "Edit {target}" },
3249
- {
3250
- target: formatMessage(
3251
- {
3252
- id: "content-manager.components.ListViewHelperPluginTable.row-line",
3253
- defaultMessage: "item line {number}"
3254
- },
3255
- { number: index2 + 1 }
3256
- )
3257
- }
3258
- ),
3281
+ label: formatMessage({
3282
+ id: "content-manager.bulk-publish.edit",
3283
+ defaultMessage: "Edit"
3284
+ }),
3259
3285
  target: "_blank",
3260
3286
  marginLeft: "auto",
3261
3287
  variant: "ghost",
@@ -3899,17 +3925,27 @@ const HistoryAction = ({ model, document }) => {
3899
3925
  const { formatMessage } = useIntl();
3900
3926
  const [{ query }] = useQueryParams();
3901
3927
  const navigate = useNavigate();
3928
+ const { trackUsage } = useTracking();
3929
+ const { pathname } = useLocation();
3902
3930
  const pluginsQueryParams = stringify({ plugins: query.plugins }, { encode: false });
3903
3931
  if (!window.strapi.features.isEnabled("cms-content-history")) {
3904
3932
  return null;
3905
3933
  }
3934
+ const handleOnClick = () => {
3935
+ const destination = { pathname: "history", search: pluginsQueryParams };
3936
+ trackUsage("willNavigate", {
3937
+ from: pathname,
3938
+ to: `${pathname}/${destination.pathname}`
3939
+ });
3940
+ navigate(destination);
3941
+ };
3906
3942
  return {
3907
3943
  icon: /* @__PURE__ */ jsx(ClockCounterClockwise, {}),
3908
3944
  label: formatMessage({
3909
3945
  id: "content-manager.history.document-action",
3910
3946
  defaultMessage: "Content History"
3911
3947
  }),
3912
- onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
3948
+ onClick: handleOnClick,
3913
3949
  disabled: (
3914
3950
  /**
3915
3951
  * The user is creating a new document.
@@ -3977,6 +4013,72 @@ const { setInitialData } = actions;
3977
4013
  const reducer = combineReducers({
3978
4014
  app: reducer$1
3979
4015
  });
4016
+ const previewApi = contentManagerApi.injectEndpoints({
4017
+ endpoints: (builder) => ({
4018
+ getPreviewUrl: builder.query({
4019
+ query({ query, params }) {
4020
+ return {
4021
+ url: `/content-manager/preview/url/${params.contentType}`,
4022
+ method: "GET",
4023
+ config: {
4024
+ params: query
4025
+ }
4026
+ };
4027
+ }
4028
+ })
4029
+ })
4030
+ });
4031
+ const { useGetPreviewUrlQuery } = previewApi;
4032
+ const PreviewSidePanel = ({ model, documentId, document }) => {
4033
+ const { formatMessage } = useIntl();
4034
+ const { trackUsage } = useTracking();
4035
+ const { pathname } = useLocation();
4036
+ const [{ query }] = useQueryParams();
4037
+ const { data, error } = useGetPreviewUrlQuery({
4038
+ params: {
4039
+ contentType: model
4040
+ },
4041
+ query: {
4042
+ documentId,
4043
+ locale: document?.locale,
4044
+ status: document?.status
4045
+ }
4046
+ });
4047
+ if (!data?.data?.url || error) {
4048
+ return null;
4049
+ }
4050
+ const trackNavigation = () => {
4051
+ const destinationPathname = pathname.replace(/\/$/, "") + "/preview";
4052
+ trackUsage("willNavigate", { from: pathname, to: destinationPathname });
4053
+ };
4054
+ return {
4055
+ title: formatMessage({ id: "content-manager.preview.panel.title", defaultMessage: "Preview" }),
4056
+ content: /* @__PURE__ */ jsx(Flex, { gap: 2, width: "100%", children: /* @__PURE__ */ jsx(
4057
+ Button,
4058
+ {
4059
+ variant: "tertiary",
4060
+ tag: Link,
4061
+ to: { pathname: "preview", search: stringify(query, { encode: false }) },
4062
+ onClick: trackNavigation,
4063
+ flex: "auto",
4064
+ children: formatMessage({
4065
+ id: "content-manager.preview.panel.button",
4066
+ defaultMessage: "Open preview"
4067
+ })
4068
+ }
4069
+ ) })
4070
+ };
4071
+ };
4072
+ const FEATURE_ID = "preview";
4073
+ const previewAdmin = {
4074
+ bootstrap(app) {
4075
+ if (!window.strapi.future.isEnabled(FEATURE_ID)) {
4076
+ return;
4077
+ }
4078
+ const contentManagerPluginApis = app.getPlugin("content-manager").apis;
4079
+ contentManagerPluginApis.addEditViewSidePanel([PreviewSidePanel]);
4080
+ }
4081
+ };
3980
4082
  const index = {
3981
4083
  register(app) {
3982
4084
  const cm = new ContentManagerPlugin();
@@ -3996,7 +4098,7 @@ const index = {
3996
4098
  app.router.addRoute({
3997
4099
  path: "content-manager/*",
3998
4100
  lazy: async () => {
3999
- const { Layout } = await import("./layout-ClP-DC72.mjs");
4101
+ const { Layout } = await import("./layout-BJ8CpEJu.mjs");
4000
4102
  return {
4001
4103
  Component: Layout
4002
4104
  };
@@ -4009,11 +4111,14 @@ const index = {
4009
4111
  if (typeof historyAdmin.bootstrap === "function") {
4010
4112
  historyAdmin.bootstrap(app);
4011
4113
  }
4114
+ if (typeof previewAdmin.bootstrap === "function") {
4115
+ previewAdmin.bootstrap(app);
4116
+ }
4012
4117
  },
4013
4118
  async registerTrads({ locales }) {
4014
4119
  const importedTrads = await Promise.all(
4015
4120
  locales.map((locale) => {
4016
- return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => import("./ar-CCEVvqGG.mjs"), "./translations/ca.json": () => import("./ca-5U32ON2v.mjs"), "./translations/cs.json": () => import("./cs-CM2aBUar.mjs"), "./translations/de.json": () => import("./de-C72KDNOl.mjs"), "./translations/en.json": () => import("./en-C8YBvRrK.mjs"), "./translations/es.json": () => import("./es-CeXiYflN.mjs"), "./translations/eu.json": () => import("./eu-CdALomew.mjs"), "./translations/fr.json": () => import("./fr-CD9VFbPM.mjs"), "./translations/gu.json": () => import("./gu-CNpaMDpH.mjs"), "./translations/hi.json": () => import("./hi-Dwvd04m3.mjs"), "./translations/hu.json": () => import("./hu-CeYvaaO0.mjs"), "./translations/id.json": () => import("./id-BtwA9WJT.mjs"), "./translations/it.json": () => import("./it-BrVPqaf1.mjs"), "./translations/ja.json": () => import("./ja-CtsUxOvk.mjs"), "./translations/ko.json": () => import("./ko-HVQRlfUI.mjs"), "./translations/ml.json": () => import("./ml-BihZwQit.mjs"), "./translations/ms.json": () => import("./ms-m_WjyWx7.mjs"), "./translations/nl.json": () => import("./nl-D4R9gHx5.mjs"), "./translations/pl.json": () => import("./pl-sbx9mSt_.mjs"), "./translations/pt-BR.json": () => import("./pt-BR-C71iDxnh.mjs"), "./translations/pt.json": () => import("./pt-BsaFvS8-.mjs"), "./translations/ru.json": () => import("./ru-BE6A4Exp.mjs"), "./translations/sa.json": () => import("./sa-Dag0k-Z8.mjs"), "./translations/sk.json": () => import("./sk-BFg-R8qJ.mjs"), "./translations/sv.json": () => import("./sv-CUnfWGsh.mjs"), "./translations/th.json": () => import("./th-BqbI8lIT.mjs"), "./translations/tr.json": () => import("./tr-CgeK3wJM.mjs"), "./translations/uk.json": () => import("./uk-CR-zDhAY.mjs"), "./translations/vi.json": () => import("./vi-DUXIk_fw.mjs"), "./translations/zh-Hans.json": () => import("./zh-Hans-BPQcRIyH.mjs"), "./translations/zh.json": () => import("./zh-BWZspA60.mjs") }), `./translations/${locale}.json`).then(({ default: data }) => {
4121
+ return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => import("./ar-CCEVvqGG.mjs"), "./translations/ca.json": () => import("./ca-5U32ON2v.mjs"), "./translations/cs.json": () => import("./cs-CM2aBUar.mjs"), "./translations/de.json": () => import("./de-C72KDNOl.mjs"), "./translations/en.json": () => import("./en-CfIXaZf9.mjs"), "./translations/es.json": () => import("./es-D34tqjMw.mjs"), "./translations/eu.json": () => import("./eu-CdALomew.mjs"), "./translations/fr.json": () => import("./fr--pg5jUbt.mjs"), "./translations/gu.json": () => import("./gu-CNpaMDpH.mjs"), "./translations/hi.json": () => import("./hi-Dwvd04m3.mjs"), "./translations/hu.json": () => import("./hu-CeYvaaO0.mjs"), "./translations/id.json": () => import("./id-BtwA9WJT.mjs"), "./translations/it.json": () => import("./it-BrVPqaf1.mjs"), "./translations/ja.json": () => import("./ja-BHqhDq4V.mjs"), "./translations/ko.json": () => import("./ko-HVQRlfUI.mjs"), "./translations/ml.json": () => import("./ml-BihZwQit.mjs"), "./translations/ms.json": () => import("./ms-m_WjyWx7.mjs"), "./translations/nl.json": () => import("./nl-D4R9gHx5.mjs"), "./translations/pl.json": () => import("./pl-sbx9mSt_.mjs"), "./translations/pt-BR.json": () => import("./pt-BR-C71iDxnh.mjs"), "./translations/pt.json": () => import("./pt-BsaFvS8-.mjs"), "./translations/ru.json": () => import("./ru-BE6A4Exp.mjs"), "./translations/sa.json": () => import("./sa-Dag0k-Z8.mjs"), "./translations/sk.json": () => import("./sk-BFg-R8qJ.mjs"), "./translations/sv.json": () => import("./sv-CUnfWGsh.mjs"), "./translations/th.json": () => import("./th-BqbI8lIT.mjs"), "./translations/tr.json": () => import("./tr-CgeK3wJM.mjs"), "./translations/uk.json": () => import("./uk-CR-zDhAY.mjs"), "./translations/vi.json": () => import("./vi-DUXIk_fw.mjs"), "./translations/zh-Hans.json": () => import("./zh-Hans-BPQcRIyH.mjs"), "./translations/zh.json": () => import("./zh-BWZspA60.mjs") }), `./translations/${locale}.json`).then(({ default: data }) => {
4017
4122
  return {
4018
4123
  data: prefixPluginTranslations(data, PLUGIN_ID),
4019
4124
  locale
@@ -4040,9 +4145,10 @@ export {
4040
4145
  HOOKS as H,
4041
4146
  InjectionZone as I,
4042
4147
  useDocument as J,
4043
- index as K,
4044
- useContentManagerContext as L,
4045
- useDocumentActions as M,
4148
+ useGetPreviewUrlQuery as K,
4149
+ index as L,
4150
+ useContentManagerContext as M,
4151
+ useDocumentActions as N,
4046
4152
  Panels as P,
4047
4153
  RelativeTime as R,
4048
4154
  SINGLE_TYPES as S,
@@ -4074,4 +4180,4 @@ export {
4074
4180
  capitalise as y,
4075
4181
  useUpdateContentTypeConfigurationMutation as z
4076
4182
  };
4077
- //# sourceMappingURL=index-BmUAydCA.mjs.map
4183
+ //# sourceMappingURL=index-BdUq-Dtg.mjs.map