@strapi/content-manager 0.0.0-next.0791cd2736057a8f66ee1682f02c46307a4d6e4a → 0.0.0-next.0fc44faf3ab6f94c481a4d426988705776878bb3

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 (156) hide show
  1. package/dist/admin/components/LeftMenu.js +34 -30
  2. package/dist/admin/components/LeftMenu.js.map +1 -1
  3. package/dist/admin/components/LeftMenu.mjs +36 -32
  4. package/dist/admin/components/LeftMenu.mjs.map +1 -1
  5. package/dist/admin/components/Widgets.js +161 -0
  6. package/dist/admin/components/Widgets.js.map +1 -0
  7. package/dist/admin/components/Widgets.mjs +158 -0
  8. package/dist/admin/components/Widgets.mjs.map +1 -0
  9. package/dist/admin/hooks/useDocumentActions.js +5 -1
  10. package/dist/admin/hooks/useDocumentActions.js.map +1 -1
  11. package/dist/admin/hooks/useDocumentActions.mjs +5 -1
  12. package/dist/admin/hooks/useDocumentActions.mjs.map +1 -1
  13. package/dist/admin/hooks/useDocumentContext.js.map +1 -1
  14. package/dist/admin/hooks/useDocumentContext.mjs.map +1 -1
  15. package/dist/admin/index.js +42 -5
  16. package/dist/admin/index.js.map +1 -1
  17. package/dist/admin/index.mjs +42 -3
  18. package/dist/admin/index.mjs.map +1 -1
  19. package/dist/admin/pages/EditView/components/DocumentActions.js +230 -28
  20. package/dist/admin/pages/EditView/components/DocumentActions.js.map +1 -1
  21. package/dist/admin/pages/EditView/components/DocumentActions.mjs +232 -30
  22. package/dist/admin/pages/EditView/components/DocumentActions.mjs.map +1 -1
  23. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.js +7 -12
  24. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.js.map +1 -1
  25. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.mjs +8 -13
  26. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.mjs.map +1 -1
  27. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.js +19 -33
  28. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.js.map +1 -1
  29. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.mjs +19 -33
  30. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.mjs.map +1 -1
  31. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.js +46 -95
  32. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.js.map +1 -1
  33. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.mjs +48 -78
  34. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.mjs.map +1 -1
  35. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js +2 -0
  36. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js.map +1 -1
  37. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs +2 -0
  38. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs.map +1 -1
  39. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js +128 -55
  40. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js.map +1 -1
  41. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs +128 -55
  42. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs.map +1 -1
  43. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +89 -50
  44. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
  45. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +91 -52
  46. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
  47. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.js +50 -97
  48. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.js.map +1 -1
  49. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.mjs +51 -79
  50. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.mjs.map +1 -1
  51. package/dist/admin/pages/EditView/components/FormLayout.js +3 -3
  52. package/dist/admin/pages/EditView/components/FormLayout.js.map +1 -1
  53. package/dist/admin/pages/EditView/components/FormLayout.mjs +3 -3
  54. package/dist/admin/pages/EditView/components/FormLayout.mjs.map +1 -1
  55. package/dist/admin/pages/ListView/ListViewPage.js +77 -0
  56. package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
  57. package/dist/admin/pages/ListView/ListViewPage.mjs +78 -1
  58. package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
  59. package/dist/admin/preview/components/PreviewHeader.js +1 -1
  60. package/dist/admin/preview/components/PreviewHeader.js.map +1 -1
  61. package/dist/admin/preview/components/PreviewHeader.mjs +1 -1
  62. package/dist/admin/preview/components/PreviewHeader.mjs.map +1 -1
  63. package/dist/admin/services/homepage.js +30 -0
  64. package/dist/admin/services/homepage.js.map +1 -0
  65. package/dist/admin/services/homepage.mjs +28 -0
  66. package/dist/admin/services/homepage.mjs.map +1 -0
  67. package/dist/admin/src/components/Widgets.d.ts +3 -0
  68. package/dist/admin/src/hooks/useDocumentContext.d.ts +1 -1
  69. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.d.ts +2 -2
  70. package/dist/admin/src/pages/EditView/components/FormInputs/Relations/RelationModal.d.ts +26 -5
  71. package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +0 -1
  72. package/dist/admin/src/services/homepage.d.ts +5 -0
  73. package/dist/admin/translations/en.json.js +3 -1
  74. package/dist/admin/translations/en.json.js.map +1 -1
  75. package/dist/admin/translations/en.json.mjs +3 -1
  76. package/dist/admin/translations/en.json.mjs.map +1 -1
  77. package/dist/admin/translations/ru.json.js +235 -226
  78. package/dist/admin/translations/ru.json.js.map +1 -1
  79. package/dist/admin/translations/ru.json.mjs +230 -226
  80. package/dist/admin/translations/ru.json.mjs.map +1 -1
  81. package/dist/server/controllers/index.js +3 -1
  82. package/dist/server/controllers/index.js.map +1 -1
  83. package/dist/server/controllers/index.mjs +3 -1
  84. package/dist/server/controllers/index.mjs.map +1 -1
  85. package/dist/server/history/services/lifecycles.js +3 -0
  86. package/dist/server/history/services/lifecycles.js.map +1 -1
  87. package/dist/server/history/services/lifecycles.mjs +3 -0
  88. package/dist/server/history/services/lifecycles.mjs.map +1 -1
  89. package/dist/server/homepage/controllers/homepage.js +57 -0
  90. package/dist/server/homepage/controllers/homepage.js.map +1 -0
  91. package/dist/server/homepage/controllers/homepage.mjs +36 -0
  92. package/dist/server/homepage/controllers/homepage.mjs.map +1 -0
  93. package/dist/server/homepage/controllers/index.js +10 -0
  94. package/dist/server/homepage/controllers/index.js.map +1 -0
  95. package/dist/server/homepage/controllers/index.mjs +8 -0
  96. package/dist/server/homepage/controllers/index.mjs.map +1 -0
  97. package/dist/server/homepage/index.js +14 -0
  98. package/dist/server/homepage/index.js.map +1 -0
  99. package/dist/server/homepage/index.mjs +12 -0
  100. package/dist/server/homepage/index.mjs.map +1 -0
  101. package/dist/server/homepage/routes/homepage.js +25 -0
  102. package/dist/server/homepage/routes/homepage.js.map +1 -0
  103. package/dist/server/homepage/routes/homepage.mjs +23 -0
  104. package/dist/server/homepage/routes/homepage.mjs.map +1 -0
  105. package/dist/server/homepage/routes/index.js +13 -0
  106. package/dist/server/homepage/routes/index.js.map +1 -0
  107. package/dist/server/homepage/routes/index.mjs +11 -0
  108. package/dist/server/homepage/routes/index.mjs.map +1 -0
  109. package/dist/server/homepage/services/homepage.js +157 -0
  110. package/dist/server/homepage/services/homepage.js.map +1 -0
  111. package/dist/server/homepage/services/homepage.mjs +155 -0
  112. package/dist/server/homepage/services/homepage.mjs.map +1 -0
  113. package/dist/server/homepage/services/index.js +10 -0
  114. package/dist/server/homepage/services/index.js.map +1 -0
  115. package/dist/server/homepage/services/index.mjs +8 -0
  116. package/dist/server/homepage/services/index.mjs.map +1 -0
  117. package/dist/server/preview/services/preview.js +0 -1
  118. package/dist/server/preview/services/preview.js.map +1 -1
  119. package/dist/server/preview/services/preview.mjs +0 -1
  120. package/dist/server/preview/services/preview.mjs.map +1 -1
  121. package/dist/server/routes/index.js +3 -1
  122. package/dist/server/routes/index.js.map +1 -1
  123. package/dist/server/routes/index.mjs +3 -1
  124. package/dist/server/routes/index.mjs.map +1 -1
  125. package/dist/server/services/index.js +3 -1
  126. package/dist/server/services/index.js.map +1 -1
  127. package/dist/server/services/index.mjs +3 -1
  128. package/dist/server/services/index.mjs.map +1 -1
  129. package/dist/server/src/controllers/index.d.ts.map +1 -1
  130. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  131. package/dist/server/src/homepage/controllers/homepage.d.ts +7 -0
  132. package/dist/server/src/homepage/controllers/homepage.d.ts.map +1 -0
  133. package/dist/server/src/homepage/controllers/index.d.ts +2 -0
  134. package/dist/server/src/homepage/controllers/index.d.ts.map +1 -0
  135. package/dist/server/src/homepage/index.d.ts +16 -0
  136. package/dist/server/src/homepage/index.d.ts.map +1 -0
  137. package/dist/server/src/homepage/routes/homepage.d.ts +4 -0
  138. package/dist/server/src/homepage/routes/homepage.d.ts.map +1 -0
  139. package/dist/server/src/homepage/routes/index.d.ts +8 -0
  140. package/dist/server/src/homepage/routes/index.d.ts.map +1 -0
  141. package/dist/server/src/homepage/services/homepage.d.ts +11 -0
  142. package/dist/server/src/homepage/services/homepage.d.ts.map +1 -0
  143. package/dist/server/src/homepage/services/index.d.ts +9 -0
  144. package/dist/server/src/homepage/services/index.d.ts.map +1 -0
  145. package/dist/server/src/index.d.ts +8 -0
  146. package/dist/server/src/index.d.ts.map +1 -1
  147. package/dist/server/src/preview/services/preview.d.ts.map +1 -1
  148. package/dist/server/src/routes/index.d.ts +1 -0
  149. package/dist/server/src/routes/index.d.ts.map +1 -1
  150. package/dist/server/src/services/data-mapper.d.ts +1 -0
  151. package/dist/server/src/services/data-mapper.d.ts.map +1 -1
  152. package/dist/server/src/services/index.d.ts +7 -0
  153. package/dist/server/src/services/index.d.ts.map +1 -1
  154. package/dist/shared/contracts/homepage.d.ts +25 -0
  155. package/dist/shared/contracts/homepage.d.ts.map +1 -0
  156. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"useDocumentContext.js","sources":["../../../admin/src/hooks/useDocumentContext.ts"],"sourcesContent":["import * as React from 'react';\n\nimport { useQueryParams } from '@strapi/admin/strapi-admin';\n\nimport { useDoc, useDocument, type UseDocument } from '../hooks/useDocument';\nimport { useRelationModal } from '../pages/EditView/components/FormInputs/Relations/RelationModal';\nimport { buildValidParams } from '../utils/api';\n\ninterface DocumentMeta {\n /**\n * The equivalent of the \":id\" url param value\n * i.e. gus5a67jcboa3o2zjnz39mb1\n */\n documentId: string;\n /**\n * The equivalent of the url \":slug\" param value\n * i.e. api::articles.article\n */\n model: string;\n /**\n * The equivalent of the url \":collectionType\" param value\n * i.e. collection-types or single-types\n */\n collectionType: string;\n /**\n * Query params object\n * i.e. { locale: 'fr' }\n */\n params?: Record<string, string | string[] | null>;\n}\n\ninterface DocumentContextValue {\n currentDocumentMeta: DocumentMeta;\n currentDocument: ReturnType<UseDocument>;\n}\n\nfunction useDocumentContext(consumerName: string): DocumentContextValue {\n // Try to get state from the relation modal context first\n const currentRelationDocumentMeta = useRelationModal(\n consumerName,\n (state) => state.currentDocumentMeta,\n false\n );\n const currentRelationDocument = useRelationModal(\n consumerName,\n (state) => state.currentDocument,\n false\n );\n\n // Then try to get the same state from the URL\n const { collectionType, model, id: documentId } = useDoc();\n const [{ query }] = useQueryParams();\n\n // TODO: look into why we never seem to pass any params\n const params = React.useMemo(() => buildValidParams(query ?? {}), [query]);\n const urlDocumentMeta: DocumentMeta = { collectionType, model, documentId: documentId!, params };\n const urlDocument = useDocument(urlDocumentMeta);\n\n /**\n * If there's modal state, use it in priority as it's the most specific\n * Fallback to the state derived from the URL, which is the default behavior,\n * used for the edit view, history and preview.\n */\n return {\n currentDocumentMeta: currentRelationDocumentMeta ?? urlDocumentMeta,\n currentDocument: currentRelationDocument ?? urlDocument,\n };\n}\n\nexport { useDocumentContext };\nexport type { DocumentMeta };\n"],"names":["useDocumentContext","consumerName","currentRelationDocumentMeta","useRelationModal","state","currentDocumentMeta","currentRelationDocument","currentDocument","collectionType","model","id","documentId","useDoc","query","useQueryParams","params","React","useMemo","buildValidParams","urlDocumentMeta","urlDocument","useDocument"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAASA,mBAAmBC,YAAoB,EAAA;;AAE9C,IAAA,MAAMC,8BAA8BC,8BAClCF,CAAAA,YAAAA,EACA,CAACG,KAAUA,GAAAA,KAAAA,CAAMC,mBAAmB,EACpC,KAAA,CAAA;AAEF,IAAA,MAAMC,0BAA0BH,8BAC9BF,CAAAA,YAAAA,EACA,CAACG,KAAUA,GAAAA,KAAAA,CAAMG,eAAe,EAChC,KAAA,CAAA;;IAIF,MAAM,EAAEC,cAAc,EAAEC,KAAK,EAAEC,EAAIC,EAAAA,UAAU,EAAE,GAAGC,kBAAAA,EAAAA;AAClD,IAAA,MAAM,CAAC,EAAEC,KAAK,EAAE,CAAC,GAAGC,0BAAAA,EAAAA;;IAGpB,MAAMC,MAAAA,GAASC,iBAAMC,OAAO,CAAC,IAAMC,oBAAiBL,CAAAA,KAAAA,IAAS,EAAK,CAAA,EAAA;AAACA,QAAAA;AAAM,KAAA,CAAA;AACzE,IAAA,MAAMM,eAAgC,GAAA;AAAEX,QAAAA,cAAAA;AAAgBC,QAAAA,KAAAA;QAAOE,UAAYA,EAAAA,UAAAA;AAAaI,QAAAA;AAAO,KAAA;AAC/F,IAAA,MAAMK,cAAcC,uBAAYF,CAAAA,eAAAA,CAAAA;AAEhC;;;;AAIC,MACD,OAAO;AACLd,QAAAA,mBAAAA,EAAqBH,2BAA+BiB,IAAAA,eAAAA;AACpDZ,QAAAA,eAAAA,EAAiBD,uBAA2Bc,IAAAA;AAC9C,KAAA;AACF;;;;"}
1
+ {"version":3,"file":"useDocumentContext.js","sources":["../../../admin/src/hooks/useDocumentContext.ts"],"sourcesContent":["import * as React from 'react';\n\nimport { useQueryParams } from '@strapi/admin/strapi-admin';\n\nimport { useDoc, useDocument, type UseDocument } from '../hooks/useDocument';\nimport { useRelationModal } from '../pages/EditView/components/FormInputs/Relations/RelationModal';\nimport { buildValidParams } from '../utils/api';\n\ninterface DocumentMeta {\n /**\n * The equivalent of the \":id\" url param value\n * i.e. gus5a67jcboa3o2zjnz39mb1\n */\n documentId?: string;\n /**\n * The equivalent of the url \":slug\" param value\n * i.e. api::articles.article\n */\n model: string;\n /**\n * The equivalent of the url \":collectionType\" param value\n * i.e. collection-types or single-types\n */\n collectionType: string;\n /**\n * Query params object\n * i.e. { locale: 'fr' }\n */\n params?: Record<string, string | string[] | null>;\n}\n\ninterface DocumentContextValue {\n currentDocumentMeta: DocumentMeta;\n currentDocument: ReturnType<UseDocument>;\n}\n\nfunction useDocumentContext(consumerName: string): DocumentContextValue {\n // Try to get state from the relation modal context first\n const currentRelationDocumentMeta = useRelationModal(\n consumerName,\n (state) => state.currentDocumentMeta,\n false\n );\n const currentRelationDocument = useRelationModal(\n consumerName,\n (state) => state.currentDocument,\n false\n );\n\n // Then try to get the same state from the URL\n const { collectionType, model, id: documentId } = useDoc();\n const [{ query }] = useQueryParams();\n\n // TODO: look into why we never seem to pass any params\n const params = React.useMemo(() => buildValidParams(query ?? {}), [query]);\n const urlDocumentMeta: DocumentMeta = { collectionType, model, documentId: documentId!, params };\n const urlDocument = useDocument(urlDocumentMeta);\n\n /**\n * If there's modal state, use it in priority as it's the most specific\n * Fallback to the state derived from the URL, which is the default behavior,\n * used for the edit view, history and preview.\n */\n return {\n currentDocumentMeta: currentRelationDocumentMeta ?? urlDocumentMeta,\n currentDocument: currentRelationDocument ?? urlDocument,\n };\n}\n\nexport { useDocumentContext };\nexport type { DocumentMeta };\n"],"names":["useDocumentContext","consumerName","currentRelationDocumentMeta","useRelationModal","state","currentDocumentMeta","currentRelationDocument","currentDocument","collectionType","model","id","documentId","useDoc","query","useQueryParams","params","React","useMemo","buildValidParams","urlDocumentMeta","urlDocument","useDocument"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAASA,mBAAmBC,YAAoB,EAAA;;AAE9C,IAAA,MAAMC,8BAA8BC,8BAClCF,CAAAA,YAAAA,EACA,CAACG,KAAUA,GAAAA,KAAAA,CAAMC,mBAAmB,EACpC,KAAA,CAAA;AAEF,IAAA,MAAMC,0BAA0BH,8BAC9BF,CAAAA,YAAAA,EACA,CAACG,KAAUA,GAAAA,KAAAA,CAAMG,eAAe,EAChC,KAAA,CAAA;;IAIF,MAAM,EAAEC,cAAc,EAAEC,KAAK,EAAEC,EAAIC,EAAAA,UAAU,EAAE,GAAGC,kBAAAA,EAAAA;AAClD,IAAA,MAAM,CAAC,EAAEC,KAAK,EAAE,CAAC,GAAGC,0BAAAA,EAAAA;;IAGpB,MAAMC,MAAAA,GAASC,iBAAMC,OAAO,CAAC,IAAMC,oBAAiBL,CAAAA,KAAAA,IAAS,EAAK,CAAA,EAAA;AAACA,QAAAA;AAAM,KAAA,CAAA;AACzE,IAAA,MAAMM,eAAgC,GAAA;AAAEX,QAAAA,cAAAA;AAAgBC,QAAAA,KAAAA;QAAOE,UAAYA,EAAAA,UAAAA;AAAaI,QAAAA;AAAO,KAAA;AAC/F,IAAA,MAAMK,cAAcC,uBAAYF,CAAAA,eAAAA,CAAAA;AAEhC;;;;AAIC,MACD,OAAO;AACLd,QAAAA,mBAAAA,EAAqBH,2BAA+BiB,IAAAA,eAAAA;AACpDZ,QAAAA,eAAAA,EAAiBD,uBAA2Bc,IAAAA;AAC9C,KAAA;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDocumentContext.mjs","sources":["../../../admin/src/hooks/useDocumentContext.ts"],"sourcesContent":["import * as React from 'react';\n\nimport { useQueryParams } from '@strapi/admin/strapi-admin';\n\nimport { useDoc, useDocument, type UseDocument } from '../hooks/useDocument';\nimport { useRelationModal } from '../pages/EditView/components/FormInputs/Relations/RelationModal';\nimport { buildValidParams } from '../utils/api';\n\ninterface DocumentMeta {\n /**\n * The equivalent of the \":id\" url param value\n * i.e. gus5a67jcboa3o2zjnz39mb1\n */\n documentId: string;\n /**\n * The equivalent of the url \":slug\" param value\n * i.e. api::articles.article\n */\n model: string;\n /**\n * The equivalent of the url \":collectionType\" param value\n * i.e. collection-types or single-types\n */\n collectionType: string;\n /**\n * Query params object\n * i.e. { locale: 'fr' }\n */\n params?: Record<string, string | string[] | null>;\n}\n\ninterface DocumentContextValue {\n currentDocumentMeta: DocumentMeta;\n currentDocument: ReturnType<UseDocument>;\n}\n\nfunction useDocumentContext(consumerName: string): DocumentContextValue {\n // Try to get state from the relation modal context first\n const currentRelationDocumentMeta = useRelationModal(\n consumerName,\n (state) => state.currentDocumentMeta,\n false\n );\n const currentRelationDocument = useRelationModal(\n consumerName,\n (state) => state.currentDocument,\n false\n );\n\n // Then try to get the same state from the URL\n const { collectionType, model, id: documentId } = useDoc();\n const [{ query }] = useQueryParams();\n\n // TODO: look into why we never seem to pass any params\n const params = React.useMemo(() => buildValidParams(query ?? {}), [query]);\n const urlDocumentMeta: DocumentMeta = { collectionType, model, documentId: documentId!, params };\n const urlDocument = useDocument(urlDocumentMeta);\n\n /**\n * If there's modal state, use it in priority as it's the most specific\n * Fallback to the state derived from the URL, which is the default behavior,\n * used for the edit view, history and preview.\n */\n return {\n currentDocumentMeta: currentRelationDocumentMeta ?? urlDocumentMeta,\n currentDocument: currentRelationDocument ?? urlDocument,\n };\n}\n\nexport { useDocumentContext };\nexport type { DocumentMeta };\n"],"names":["useDocumentContext","consumerName","currentRelationDocumentMeta","useRelationModal","state","currentDocumentMeta","currentRelationDocument","currentDocument","collectionType","model","id","documentId","useDoc","query","useQueryParams","params","React","useMemo","buildValidParams","urlDocumentMeta","urlDocument","useDocument"],"mappings":";;;;;;AAoCA,SAASA,mBAAmBC,YAAoB,EAAA;;AAE9C,IAAA,MAAMC,8BAA8BC,gBAClCF,CAAAA,YAAAA,EACA,CAACG,KAAUA,GAAAA,KAAAA,CAAMC,mBAAmB,EACpC,KAAA,CAAA;AAEF,IAAA,MAAMC,0BAA0BH,gBAC9BF,CAAAA,YAAAA,EACA,CAACG,KAAUA,GAAAA,KAAAA,CAAMG,eAAe,EAChC,KAAA,CAAA;;IAIF,MAAM,EAAEC,cAAc,EAAEC,KAAK,EAAEC,EAAIC,EAAAA,UAAU,EAAE,GAAGC,MAAAA,EAAAA;AAClD,IAAA,MAAM,CAAC,EAAEC,KAAK,EAAE,CAAC,GAAGC,cAAAA,EAAAA;;IAGpB,MAAMC,MAAAA,GAASC,MAAMC,OAAO,CAAC,IAAMC,gBAAiBL,CAAAA,KAAAA,IAAS,EAAK,CAAA,EAAA;AAACA,QAAAA;AAAM,KAAA,CAAA;AACzE,IAAA,MAAMM,eAAgC,GAAA;AAAEX,QAAAA,cAAAA;AAAgBC,QAAAA,KAAAA;QAAOE,UAAYA,EAAAA,UAAAA;AAAaI,QAAAA;AAAO,KAAA;AAC/F,IAAA,MAAMK,cAAcC,WAAYF,CAAAA,eAAAA,CAAAA;AAEhC;;;;AAIC,MACD,OAAO;AACLd,QAAAA,mBAAAA,EAAqBH,2BAA+BiB,IAAAA,eAAAA;AACpDZ,QAAAA,eAAAA,EAAiBD,uBAA2Bc,IAAAA;AAC9C,KAAA;AACF;;;;"}
1
+ {"version":3,"file":"useDocumentContext.mjs","sources":["../../../admin/src/hooks/useDocumentContext.ts"],"sourcesContent":["import * as React from 'react';\n\nimport { useQueryParams } from '@strapi/admin/strapi-admin';\n\nimport { useDoc, useDocument, type UseDocument } from '../hooks/useDocument';\nimport { useRelationModal } from '../pages/EditView/components/FormInputs/Relations/RelationModal';\nimport { buildValidParams } from '../utils/api';\n\ninterface DocumentMeta {\n /**\n * The equivalent of the \":id\" url param value\n * i.e. gus5a67jcboa3o2zjnz39mb1\n */\n documentId?: string;\n /**\n * The equivalent of the url \":slug\" param value\n * i.e. api::articles.article\n */\n model: string;\n /**\n * The equivalent of the url \":collectionType\" param value\n * i.e. collection-types or single-types\n */\n collectionType: string;\n /**\n * Query params object\n * i.e. { locale: 'fr' }\n */\n params?: Record<string, string | string[] | null>;\n}\n\ninterface DocumentContextValue {\n currentDocumentMeta: DocumentMeta;\n currentDocument: ReturnType<UseDocument>;\n}\n\nfunction useDocumentContext(consumerName: string): DocumentContextValue {\n // Try to get state from the relation modal context first\n const currentRelationDocumentMeta = useRelationModal(\n consumerName,\n (state) => state.currentDocumentMeta,\n false\n );\n const currentRelationDocument = useRelationModal(\n consumerName,\n (state) => state.currentDocument,\n false\n );\n\n // Then try to get the same state from the URL\n const { collectionType, model, id: documentId } = useDoc();\n const [{ query }] = useQueryParams();\n\n // TODO: look into why we never seem to pass any params\n const params = React.useMemo(() => buildValidParams(query ?? {}), [query]);\n const urlDocumentMeta: DocumentMeta = { collectionType, model, documentId: documentId!, params };\n const urlDocument = useDocument(urlDocumentMeta);\n\n /**\n * If there's modal state, use it in priority as it's the most specific\n * Fallback to the state derived from the URL, which is the default behavior,\n * used for the edit view, history and preview.\n */\n return {\n currentDocumentMeta: currentRelationDocumentMeta ?? urlDocumentMeta,\n currentDocument: currentRelationDocument ?? urlDocument,\n };\n}\n\nexport { useDocumentContext };\nexport type { DocumentMeta };\n"],"names":["useDocumentContext","consumerName","currentRelationDocumentMeta","useRelationModal","state","currentDocumentMeta","currentRelationDocument","currentDocument","collectionType","model","id","documentId","useDoc","query","useQueryParams","params","React","useMemo","buildValidParams","urlDocumentMeta","urlDocument","useDocument"],"mappings":";;;;;;AAoCA,SAASA,mBAAmBC,YAAoB,EAAA;;AAE9C,IAAA,MAAMC,8BAA8BC,gBAClCF,CAAAA,YAAAA,EACA,CAACG,KAAUA,GAAAA,KAAAA,CAAMC,mBAAmB,EACpC,KAAA,CAAA;AAEF,IAAA,MAAMC,0BAA0BH,gBAC9BF,CAAAA,YAAAA,EACA,CAACG,KAAUA,GAAAA,KAAAA,CAAMG,eAAe,EAChC,KAAA,CAAA;;IAIF,MAAM,EAAEC,cAAc,EAAEC,KAAK,EAAEC,EAAIC,EAAAA,UAAU,EAAE,GAAGC,MAAAA,EAAAA;AAClD,IAAA,MAAM,CAAC,EAAEC,KAAK,EAAE,CAAC,GAAGC,cAAAA,EAAAA;;IAGpB,MAAMC,MAAAA,GAASC,MAAMC,OAAO,CAAC,IAAMC,gBAAiBL,CAAAA,KAAAA,IAAS,EAAK,CAAA,EAAA;AAACA,QAAAA;AAAM,KAAA,CAAA;AACzE,IAAA,MAAMM,eAAgC,GAAA;AAAEX,QAAAA,cAAAA;AAAgBC,QAAAA,KAAAA;QAAOE,UAAYA,EAAAA,UAAAA;AAAaI,QAAAA;AAAO,KAAA;AAC/F,IAAA,MAAMK,cAAcC,WAAYF,CAAAA,eAAAA,CAAAA;AAEhC;;;;AAIC,MACD,OAAO;AACLd,QAAAA,mBAAAA,EAAqBH,2BAA+BiB,IAAAA,eAAAA;AACpDZ,QAAAA,eAAAA,EAAiBD,uBAA2Bc,IAAAA;AAC9C,KAAA;AACF;;;;"}
@@ -18,9 +18,7 @@ var useDocumentActions = require('./hooks/useDocumentActions.js');
18
18
  var useDocumentLayout = require('./hooks/useDocumentLayout.js');
19
19
  var DocumentRBAC = require('./features/DocumentRBAC.js');
20
20
 
21
- function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); }
22
-
23
- function __variableDynamicImportRuntime1__(path) {
21
+ function __variableDynamicImportRuntime3__(path) {
24
22
  switch (path) {
25
23
  case './translations/ar.json': return Promise.resolve().then(function () { return require('./translations/ar.json.js'); });
26
24
  case './translations/ca.json': return Promise.resolve().then(function () { return require('./translations/ca.json.js'); });
@@ -43,7 +41,7 @@ function __variableDynamicImportRuntime1__(path) {
43
41
  case './translations/pl.json': return Promise.resolve().then(function () { return require('./translations/pl.json.js'); });
44
42
  case './translations/pt-BR.json': return Promise.resolve().then(function () { return require('./translations/pt-BR.json.js'); });
45
43
  case './translations/pt.json': return Promise.resolve().then(function () { return require('./translations/pt.json.js'); });
46
- case './translations/ru.json': return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefaultOnly(require('./translations/ru.json.js')); });
44
+ case './translations/ru.json': return Promise.resolve().then(function () { return require('./translations/ru.json.js'); });
47
45
  case './translations/sa.json': return Promise.resolve().then(function () { return require('./translations/sa.json.js'); });
48
46
  case './translations/sk.json': return Promise.resolve().then(function () { return require('./translations/sk.json.js'); });
49
47
  case './translations/sv.json': return Promise.resolve().then(function () { return require('./translations/sv.json.js'); });
@@ -88,6 +86,45 @@ var index = {
88
86
  children: router.routes
89
87
  });
90
88
  app.registerPlugin(cm.config);
89
+ // Register homepage widgets
90
+ app.widgets.register([
91
+ {
92
+ icon: Icons.Pencil,
93
+ title: {
94
+ id: `${plugin.PLUGIN_ID}.widget.last-edited.title`,
95
+ defaultMessage: 'Last edited entries'
96
+ },
97
+ component: async ()=>{
98
+ const { LastEditedWidget } = await Promise.resolve().then(function () { return require('./components/Widgets.js'); });
99
+ return LastEditedWidget;
100
+ },
101
+ pluginId: plugin.PLUGIN_ID,
102
+ id: 'last-edited-entries',
103
+ permissions: [
104
+ {
105
+ action: 'plugin::content-manager.explorer.read'
106
+ }
107
+ ]
108
+ },
109
+ {
110
+ icon: Icons.CheckCircle,
111
+ title: {
112
+ id: `${plugin.PLUGIN_ID}.widget.last-published.title`,
113
+ defaultMessage: 'Last published entries'
114
+ },
115
+ component: async ()=>{
116
+ const { LastPublishedWidget } = await Promise.resolve().then(function () { return require('./components/Widgets.js'); });
117
+ return LastPublishedWidget;
118
+ },
119
+ pluginId: plugin.PLUGIN_ID,
120
+ id: 'last-published-entries',
121
+ permissions: [
122
+ {
123
+ action: 'plugin::content-manager.explorer.read'
124
+ }
125
+ ]
126
+ }
127
+ ]);
91
128
  },
92
129
  bootstrap (app) {
93
130
  if (typeof index$1.historyAdmin.bootstrap === 'function') {
@@ -99,7 +136,7 @@ var index = {
99
136
  },
100
137
  async registerTrads ({ locales }) {
101
138
  const importedTrads = await Promise.all(locales.map((locale)=>{
102
- return __variableDynamicImportRuntime1__(`./translations/${locale}.json`).then(({ default: data })=>{
139
+ return __variableDynamicImportRuntime3__(`./translations/${locale}.json`).then(({ default: data })=>{
103
140
  return {
104
141
  data: translations.prefixPluginTranslations(data, plugin.PLUGIN_ID),
105
142
  locale
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../admin/src/index.ts"],"sourcesContent":["import { Feather } from '@strapi/icons';\n\nimport { PLUGIN_ID } from './constants/plugin';\nimport { ContentManagerPlugin } from './content-manager';\nimport { historyAdmin } from './history';\nimport { reducer } from './modules/reducers';\nimport { previewAdmin } from './preview';\nimport { routes } from './router';\nimport { prefixPluginTranslations } from './utils/translations';\n\n// NOTE: we have to preload it to ensure chunks will have it available as global\nimport 'prismjs';\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n register(app: any) {\n const cm = new ContentManagerPlugin();\n\n app.addReducers({\n [PLUGIN_ID]: reducer,\n });\n\n app.addMenuLink({\n to: PLUGIN_ID,\n icon: Feather,\n intlLabel: {\n id: `content-manager.plugin.name`,\n defaultMessage: 'Content Manager',\n },\n permissions: [],\n position: 1,\n });\n\n app.router.addRoute({\n path: 'content-manager/*',\n lazy: async () => {\n const { Layout } = await import('./layout');\n\n return {\n Component: Layout,\n };\n },\n children: routes,\n });\n\n app.registerPlugin(cm.config);\n },\n bootstrap(app: any) {\n if (typeof historyAdmin.bootstrap === 'function') {\n historyAdmin.bootstrap(app);\n }\n if (typeof previewAdmin.bootstrap === 'function') {\n previewAdmin.bootstrap(app);\n }\n },\n async registerTrads({ locales }: { locales: string[] }) {\n const importedTrads = await Promise.all(\n locales.map((locale) => {\n return import(`./translations/${locale}.json`)\n .then(({ default: data }) => {\n return {\n data: prefixPluginTranslations(data, PLUGIN_ID),\n locale,\n };\n })\n .catch(() => {\n return {\n data: {},\n locale,\n };\n });\n })\n );\n\n return Promise.resolve(importedTrads);\n },\n};\n\nexport * from './exports';\n"],"names":["register","app","cm","ContentManagerPlugin","addReducers","PLUGIN_ID","reducer","addMenuLink","to","icon","Feather","intlLabel","id","defaultMessage","permissions","position","router","addRoute","path","lazy","Layout","Component","children","routes","registerPlugin","config","bootstrap","historyAdmin","previewAdmin","registerTrads","locales","importedTrads","Promise","all","map","locale","then","default","data","prefixPluginTranslations","catch","resolve"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA;AACA,YAAe;AACbA,IAAAA,QAAAA,CAAAA,CAASC,GAAQ,EAAA;AACf,QAAA,MAAMC,KAAK,IAAIC,mCAAAA,EAAAA;AAEfF,QAAAA,GAAAA,CAAIG,WAAW,CAAC;AACd,YAAA,CAACC,mBAAYC;AACf,SAAA,CAAA;AAEAL,QAAAA,GAAAA,CAAIM,WAAW,CAAC;YACdC,EAAIH,EAAAA,gBAAAA;YACJI,IAAMC,EAAAA,aAAAA;YACNC,SAAW,EAAA;gBACTC,EAAI,EAAA,CAAC,2BAA2B,CAAC;gBACjCC,cAAgB,EAAA;AAClB,aAAA;AACAC,YAAAA,WAAAA,EAAa,EAAE;YACfC,QAAU,EAAA;AACZ,SAAA,CAAA;QAEAd,GAAIe,CAAAA,MAAM,CAACC,QAAQ,CAAC;YAClBC,IAAM,EAAA,mBAAA;YACNC,IAAM,EAAA,UAAA;AACJ,gBAAA,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAM,oDAAO,aAAA,KAAA;gBAEhC,OAAO;oBACLC,SAAWD,EAAAA;AACb,iBAAA;AACF,aAAA;YACAE,QAAUC,EAAAA;AACZ,SAAA,CAAA;QAEAtB,GAAIuB,CAAAA,cAAc,CAACtB,EAAAA,CAAGuB,MAAM,CAAA;AAC9B,KAAA;AACAC,IAAAA,SAAAA,CAAAA,CAAUzB,GAAQ,EAAA;AAChB,QAAA,IAAI,OAAO0B,oBAAAA,CAAaD,SAAS,KAAK,UAAY,EAAA;AAChDC,YAAAA,oBAAAA,CAAaD,SAAS,CAACzB,GAAAA,CAAAA;AACzB;AACA,QAAA,IAAI,OAAO2B,oBAAAA,CAAaF,SAAS,KAAK,UAAY,EAAA;AAChDE,YAAAA,oBAAAA,CAAaF,SAAS,CAACzB,GAAAA,CAAAA;AACzB;AACF,KAAA;IACA,MAAM4B,aAAAA,CAAAA,CAAc,EAAEC,OAAO,EAAyB,EAAA;QACpD,MAAMC,aAAAA,GAAgB,MAAMC,OAAQC,CAAAA,GAAG,CACrCH,OAAQI,CAAAA,GAAG,CAAC,CAACC,MAAAA,GAAAA;AACX,YAAA,OAAO,iCAAM,CAAC,CAAC,eAAe,EAAEA,MAAO,CAAA,KAAK,CAAC,CAAA,CAC1CC,IAAI,CAAC,CAAC,EAAEC,OAAAA,EAASC,IAAI,EAAE,GAAA;gBACtB,OAAO;AACLA,oBAAAA,IAAAA,EAAMC,sCAAyBD,IAAMjC,EAAAA,gBAAAA,CAAAA;AACrC8B,oBAAAA;AACF,iBAAA;AACF,aAAA,CAAA,CACCK,KAAK,CAAC,IAAA;gBACL,OAAO;AACLF,oBAAAA,IAAAA,EAAM,EAAC;AACPH,oBAAAA;AACF,iBAAA;AACF,aAAA,CAAA;AACJ,SAAA,CAAA,CAAA;QAGF,OAAOH,OAAAA,CAAQS,OAAO,CAACV,aAAAA,CAAAA;AACzB;AACF,CAAE;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../admin/src/index.ts"],"sourcesContent":["import { CheckCircle, Feather, Pencil } from '@strapi/icons';\n\nimport { PLUGIN_ID } from './constants/plugin';\nimport { ContentManagerPlugin } from './content-manager';\nimport { historyAdmin } from './history';\nimport { reducer } from './modules/reducers';\nimport { previewAdmin } from './preview';\nimport { routes } from './router';\nimport { prefixPluginTranslations } from './utils/translations';\n\n// NOTE: we have to preload it to ensure chunks will have it available as global\nimport 'prismjs';\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n register(app: any) {\n const cm = new ContentManagerPlugin();\n\n app.addReducers({\n [PLUGIN_ID]: reducer,\n });\n\n app.addMenuLink({\n to: PLUGIN_ID,\n icon: Feather,\n intlLabel: {\n id: `content-manager.plugin.name`,\n defaultMessage: 'Content Manager',\n },\n permissions: [],\n position: 1,\n });\n\n app.router.addRoute({\n path: 'content-manager/*',\n lazy: async () => {\n const { Layout } = await import('./layout');\n\n return {\n Component: Layout,\n };\n },\n children: routes,\n });\n\n app.registerPlugin(cm.config);\n\n // Register homepage widgets\n app.widgets.register([\n {\n icon: Pencil,\n title: {\n id: `${PLUGIN_ID}.widget.last-edited.title`,\n defaultMessage: 'Last edited entries',\n },\n component: async () => {\n const { LastEditedWidget } = await import('./components/Widgets');\n return LastEditedWidget;\n },\n pluginId: PLUGIN_ID,\n id: 'last-edited-entries',\n permissions: [{ action: 'plugin::content-manager.explorer.read' }],\n },\n {\n icon: CheckCircle,\n title: {\n id: `${PLUGIN_ID}.widget.last-published.title`,\n defaultMessage: 'Last published entries',\n },\n component: async () => {\n const { LastPublishedWidget } = await import('./components/Widgets');\n return LastPublishedWidget;\n },\n pluginId: PLUGIN_ID,\n id: 'last-published-entries',\n permissions: [{ action: 'plugin::content-manager.explorer.read' }],\n },\n ]);\n },\n bootstrap(app: any) {\n if (typeof historyAdmin.bootstrap === 'function') {\n historyAdmin.bootstrap(app);\n }\n if (typeof previewAdmin.bootstrap === 'function') {\n previewAdmin.bootstrap(app);\n }\n },\n async registerTrads({ locales }: { locales: string[] }) {\n const importedTrads = await Promise.all(\n locales.map((locale) => {\n return import(`./translations/${locale}.json`)\n .then(({ default: data }) => {\n return {\n data: prefixPluginTranslations(data, PLUGIN_ID),\n locale,\n };\n })\n .catch(() => {\n return {\n data: {},\n locale,\n };\n });\n })\n );\n\n return Promise.resolve(importedTrads);\n },\n};\n\nexport * from './exports';\n"],"names":["register","app","cm","ContentManagerPlugin","addReducers","PLUGIN_ID","reducer","addMenuLink","to","icon","Feather","intlLabel","id","defaultMessage","permissions","position","router","addRoute","path","lazy","Layout","Component","children","routes","registerPlugin","config","widgets","Pencil","title","component","LastEditedWidget","pluginId","action","CheckCircle","LastPublishedWidget","bootstrap","historyAdmin","previewAdmin","registerTrads","locales","importedTrads","Promise","all","map","locale","then","default","data","prefixPluginTranslations","catch","resolve"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA;AACA,YAAe;AACbA,IAAAA,QAAAA,CAAAA,CAASC,GAAQ,EAAA;AACf,QAAA,MAAMC,KAAK,IAAIC,mCAAAA,EAAAA;AAEfF,QAAAA,GAAAA,CAAIG,WAAW,CAAC;AACd,YAAA,CAACC,mBAAYC;AACf,SAAA,CAAA;AAEAL,QAAAA,GAAAA,CAAIM,WAAW,CAAC;YACdC,EAAIH,EAAAA,gBAAAA;YACJI,IAAMC,EAAAA,aAAAA;YACNC,SAAW,EAAA;gBACTC,EAAI,EAAA,CAAC,2BAA2B,CAAC;gBACjCC,cAAgB,EAAA;AAClB,aAAA;AACAC,YAAAA,WAAAA,EAAa,EAAE;YACfC,QAAU,EAAA;AACZ,SAAA,CAAA;QAEAd,GAAIe,CAAAA,MAAM,CAACC,QAAQ,CAAC;YAClBC,IAAM,EAAA,mBAAA;YACNC,IAAM,EAAA,UAAA;AACJ,gBAAA,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAM,oDAAO,aAAA,KAAA;gBAEhC,OAAO;oBACLC,SAAWD,EAAAA;AACb,iBAAA;AACF,aAAA;YACAE,QAAUC,EAAAA;AACZ,SAAA,CAAA;QAEAtB,GAAIuB,CAAAA,cAAc,CAACtB,EAAAA,CAAGuB,MAAM,CAAA;;QAG5BxB,GAAIyB,CAAAA,OAAO,CAAC1B,QAAQ,CAAC;AACnB,YAAA;gBACES,IAAMkB,EAAAA,YAAAA;gBACNC,KAAO,EAAA;AACLhB,oBAAAA,EAAAA,EAAI,CAAC,EAAEP,gBAAU,CAAA,yBAAyB,CAAC;oBAC3CQ,cAAgB,EAAA;AAClB,iBAAA;gBACAgB,SAAW,EAAA,UAAA;AACT,oBAAA,MAAM,EAAEC,gBAAgB,EAAE,GAAG,MAAM,oDAAO,yBAAA,KAAA;oBAC1C,OAAOA,gBAAAA;AACT,iBAAA;gBACAC,QAAU1B,EAAAA,gBAAAA;gBACVO,EAAI,EAAA,qBAAA;gBACJE,WAAa,EAAA;AAAC,oBAAA;wBAAEkB,MAAQ,EAAA;AAAwC;AAAE;AACpE,aAAA;AACA,YAAA;gBACEvB,IAAMwB,EAAAA,iBAAAA;gBACNL,KAAO,EAAA;AACLhB,oBAAAA,EAAAA,EAAI,CAAC,EAAEP,gBAAU,CAAA,4BAA4B,CAAC;oBAC9CQ,cAAgB,EAAA;AAClB,iBAAA;gBACAgB,SAAW,EAAA,UAAA;AACT,oBAAA,MAAM,EAAEK,mBAAmB,EAAE,GAAG,MAAM,oDAAO,yBAAA,KAAA;oBAC7C,OAAOA,mBAAAA;AACT,iBAAA;gBACAH,QAAU1B,EAAAA,gBAAAA;gBACVO,EAAI,EAAA,wBAAA;gBACJE,WAAa,EAAA;AAAC,oBAAA;wBAAEkB,MAAQ,EAAA;AAAwC;AAAE;AACpE;AACD,SAAA,CAAA;AACH,KAAA;AACAG,IAAAA,SAAAA,CAAAA,CAAUlC,GAAQ,EAAA;AAChB,QAAA,IAAI,OAAOmC,oBAAAA,CAAaD,SAAS,KAAK,UAAY,EAAA;AAChDC,YAAAA,oBAAAA,CAAaD,SAAS,CAAClC,GAAAA,CAAAA;AACzB;AACA,QAAA,IAAI,OAAOoC,oBAAAA,CAAaF,SAAS,KAAK,UAAY,EAAA;AAChDE,YAAAA,oBAAAA,CAAaF,SAAS,CAAClC,GAAAA,CAAAA;AACzB;AACF,KAAA;IACA,MAAMqC,aAAAA,CAAAA,CAAc,EAAEC,OAAO,EAAyB,EAAA;QACpD,MAAMC,aAAAA,GAAgB,MAAMC,OAAQC,CAAAA,GAAG,CACrCH,OAAQI,CAAAA,GAAG,CAAC,CAACC,MAAAA,GAAAA;AACX,YAAA,OAAO,iCAAM,CAAC,CAAC,eAAe,EAAEA,MAAO,CAAA,KAAK,CAAC,CAAA,CAC1CC,IAAI,CAAC,CAAC,EAAEC,OAAAA,EAASC,IAAI,EAAE,GAAA;gBACtB,OAAO;AACLA,oBAAAA,IAAAA,EAAMC,sCAAyBD,IAAM1C,EAAAA,gBAAAA,CAAAA;AACrCuC,oBAAAA;AACF,iBAAA;AACF,aAAA,CAAA,CACCK,KAAK,CAAC,IAAA;gBACL,OAAO;AACLF,oBAAAA,IAAAA,EAAM,EAAC;AACPH,oBAAAA;AACF,iBAAA;AACF,aAAA,CAAA;AACJ,SAAA,CAAA,CAAA;QAGF,OAAOH,OAAAA,CAAQS,OAAO,CAACV,aAAAA,CAAAA;AACzB;AACF,CAAE;;;;;;;;;;;;"}
@@ -1,4 +1,4 @@
1
- import { Feather } from '@strapi/icons';
1
+ import { Feather, Pencil, CheckCircle } from '@strapi/icons';
2
2
  import { PLUGIN_ID } from './constants/plugin.mjs';
3
3
  import { ContentManagerPlugin } from './content-manager.mjs';
4
4
  import { historyAdmin } from './history/index.mjs';
@@ -14,7 +14,7 @@ export { useDocumentActions as unstable_useDocumentActions } from './hooks/useDo
14
14
  export { useDocumentLayout as unstable_useDocumentLayout } from './hooks/useDocumentLayout.mjs';
15
15
  export { DocumentRBAC, useDocumentRBAC } from './features/DocumentRBAC.mjs';
16
16
 
17
- function __variableDynamicImportRuntime1__(path) {
17
+ function __variableDynamicImportRuntime3__(path) {
18
18
  switch (path) {
19
19
  case './translations/ar.json': return import('./translations/ar.json.mjs');
20
20
  case './translations/ca.json': return import('./translations/ca.json.mjs');
@@ -82,6 +82,45 @@ var index = {
82
82
  children: routes
83
83
  });
84
84
  app.registerPlugin(cm.config);
85
+ // Register homepage widgets
86
+ app.widgets.register([
87
+ {
88
+ icon: Pencil,
89
+ title: {
90
+ id: `${PLUGIN_ID}.widget.last-edited.title`,
91
+ defaultMessage: 'Last edited entries'
92
+ },
93
+ component: async ()=>{
94
+ const { LastEditedWidget } = await import('./components/Widgets.mjs');
95
+ return LastEditedWidget;
96
+ },
97
+ pluginId: PLUGIN_ID,
98
+ id: 'last-edited-entries',
99
+ permissions: [
100
+ {
101
+ action: 'plugin::content-manager.explorer.read'
102
+ }
103
+ ]
104
+ },
105
+ {
106
+ icon: CheckCircle,
107
+ title: {
108
+ id: `${PLUGIN_ID}.widget.last-published.title`,
109
+ defaultMessage: 'Last published entries'
110
+ },
111
+ component: async ()=>{
112
+ const { LastPublishedWidget } = await import('./components/Widgets.mjs');
113
+ return LastPublishedWidget;
114
+ },
115
+ pluginId: PLUGIN_ID,
116
+ id: 'last-published-entries',
117
+ permissions: [
118
+ {
119
+ action: 'plugin::content-manager.explorer.read'
120
+ }
121
+ ]
122
+ }
123
+ ]);
85
124
  },
86
125
  bootstrap (app) {
87
126
  if (typeof historyAdmin.bootstrap === 'function') {
@@ -93,7 +132,7 @@ var index = {
93
132
  },
94
133
  async registerTrads ({ locales }) {
95
134
  const importedTrads = await Promise.all(locales.map((locale)=>{
96
- return __variableDynamicImportRuntime1__(`./translations/${locale}.json`).then(({ default: data })=>{
135
+ return __variableDynamicImportRuntime3__(`./translations/${locale}.json`).then(({ default: data })=>{
97
136
  return {
98
137
  data: prefixPluginTranslations(data, PLUGIN_ID),
99
138
  locale
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../admin/src/index.ts"],"sourcesContent":["import { Feather } from '@strapi/icons';\n\nimport { PLUGIN_ID } from './constants/plugin';\nimport { ContentManagerPlugin } from './content-manager';\nimport { historyAdmin } from './history';\nimport { reducer } from './modules/reducers';\nimport { previewAdmin } from './preview';\nimport { routes } from './router';\nimport { prefixPluginTranslations } from './utils/translations';\n\n// NOTE: we have to preload it to ensure chunks will have it available as global\nimport 'prismjs';\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n register(app: any) {\n const cm = new ContentManagerPlugin();\n\n app.addReducers({\n [PLUGIN_ID]: reducer,\n });\n\n app.addMenuLink({\n to: PLUGIN_ID,\n icon: Feather,\n intlLabel: {\n id: `content-manager.plugin.name`,\n defaultMessage: 'Content Manager',\n },\n permissions: [],\n position: 1,\n });\n\n app.router.addRoute({\n path: 'content-manager/*',\n lazy: async () => {\n const { Layout } = await import('./layout');\n\n return {\n Component: Layout,\n };\n },\n children: routes,\n });\n\n app.registerPlugin(cm.config);\n },\n bootstrap(app: any) {\n if (typeof historyAdmin.bootstrap === 'function') {\n historyAdmin.bootstrap(app);\n }\n if (typeof previewAdmin.bootstrap === 'function') {\n previewAdmin.bootstrap(app);\n }\n },\n async registerTrads({ locales }: { locales: string[] }) {\n const importedTrads = await Promise.all(\n locales.map((locale) => {\n return import(`./translations/${locale}.json`)\n .then(({ default: data }) => {\n return {\n data: prefixPluginTranslations(data, PLUGIN_ID),\n locale,\n };\n })\n .catch(() => {\n return {\n data: {},\n locale,\n };\n });\n })\n );\n\n return Promise.resolve(importedTrads);\n },\n};\n\nexport * from './exports';\n"],"names":["register","app","cm","ContentManagerPlugin","addReducers","PLUGIN_ID","reducer","addMenuLink","to","icon","Feather","intlLabel","id","defaultMessage","permissions","position","router","addRoute","path","lazy","Layout","Component","children","routes","registerPlugin","config","bootstrap","historyAdmin","previewAdmin","registerTrads","locales","importedTrads","Promise","all","map","locale","then","default","data","prefixPluginTranslations","catch","resolve"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA;AACA,YAAe;AACbA,IAAAA,QAAAA,CAAAA,CAASC,GAAQ,EAAA;AACf,QAAA,MAAMC,KAAK,IAAIC,oBAAAA,EAAAA;AAEfF,QAAAA,GAAAA,CAAIG,WAAW,CAAC;AACd,YAAA,CAACC,YAAYC;AACf,SAAA,CAAA;AAEAL,QAAAA,GAAAA,CAAIM,WAAW,CAAC;YACdC,EAAIH,EAAAA,SAAAA;YACJI,IAAMC,EAAAA,OAAAA;YACNC,SAAW,EAAA;gBACTC,EAAI,EAAA,CAAC,2BAA2B,CAAC;gBACjCC,cAAgB,EAAA;AAClB,aAAA;AACAC,YAAAA,WAAAA,EAAa,EAAE;YACfC,QAAU,EAAA;AACZ,SAAA,CAAA;QAEAd,GAAIe,CAAAA,MAAM,CAACC,QAAQ,CAAC;YAClBC,IAAM,EAAA,mBAAA;YACNC,IAAM,EAAA,UAAA;AACJ,gBAAA,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAM,OAAO,cAAA,CAAA;gBAEhC,OAAO;oBACLC,SAAWD,EAAAA;AACb,iBAAA;AACF,aAAA;YACAE,QAAUC,EAAAA;AACZ,SAAA,CAAA;QAEAtB,GAAIuB,CAAAA,cAAc,CAACtB,EAAAA,CAAGuB,MAAM,CAAA;AAC9B,KAAA;AACAC,IAAAA,SAAAA,CAAAA,CAAUzB,GAAQ,EAAA;AAChB,QAAA,IAAI,OAAO0B,YAAAA,CAAaD,SAAS,KAAK,UAAY,EAAA;AAChDC,YAAAA,YAAAA,CAAaD,SAAS,CAACzB,GAAAA,CAAAA;AACzB;AACA,QAAA,IAAI,OAAO2B,YAAAA,CAAaF,SAAS,KAAK,UAAY,EAAA;AAChDE,YAAAA,YAAAA,CAAaF,SAAS,CAACzB,GAAAA,CAAAA;AACzB;AACF,KAAA;IACA,MAAM4B,aAAAA,CAAAA,CAAc,EAAEC,OAAO,EAAyB,EAAA;QACpD,MAAMC,aAAAA,GAAgB,MAAMC,OAAQC,CAAAA,GAAG,CACrCH,OAAQI,CAAAA,GAAG,CAAC,CAACC,MAAAA,GAAAA;AACX,YAAA,OAAO,iCAAM,CAAC,CAAC,eAAe,EAAEA,MAAO,CAAA,KAAK,CAAC,CAAA,CAC1CC,IAAI,CAAC,CAAC,EAAEC,OAAAA,EAASC,IAAI,EAAE,GAAA;gBACtB,OAAO;AACLA,oBAAAA,IAAAA,EAAMC,yBAAyBD,IAAMjC,EAAAA,SAAAA,CAAAA;AACrC8B,oBAAAA;AACF,iBAAA;AACF,aAAA,CAAA,CACCK,KAAK,CAAC,IAAA;gBACL,OAAO;AACLF,oBAAAA,IAAAA,EAAM,EAAC;AACPH,oBAAAA;AACF,iBAAA;AACF,aAAA,CAAA;AACJ,SAAA,CAAA,CAAA;QAGF,OAAOH,OAAAA,CAAQS,OAAO,CAACV,aAAAA,CAAAA;AACzB;AACF,CAAE;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../admin/src/index.ts"],"sourcesContent":["import { CheckCircle, Feather, Pencil } from '@strapi/icons';\n\nimport { PLUGIN_ID } from './constants/plugin';\nimport { ContentManagerPlugin } from './content-manager';\nimport { historyAdmin } from './history';\nimport { reducer } from './modules/reducers';\nimport { previewAdmin } from './preview';\nimport { routes } from './router';\nimport { prefixPluginTranslations } from './utils/translations';\n\n// NOTE: we have to preload it to ensure chunks will have it available as global\nimport 'prismjs';\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n register(app: any) {\n const cm = new ContentManagerPlugin();\n\n app.addReducers({\n [PLUGIN_ID]: reducer,\n });\n\n app.addMenuLink({\n to: PLUGIN_ID,\n icon: Feather,\n intlLabel: {\n id: `content-manager.plugin.name`,\n defaultMessage: 'Content Manager',\n },\n permissions: [],\n position: 1,\n });\n\n app.router.addRoute({\n path: 'content-manager/*',\n lazy: async () => {\n const { Layout } = await import('./layout');\n\n return {\n Component: Layout,\n };\n },\n children: routes,\n });\n\n app.registerPlugin(cm.config);\n\n // Register homepage widgets\n app.widgets.register([\n {\n icon: Pencil,\n title: {\n id: `${PLUGIN_ID}.widget.last-edited.title`,\n defaultMessage: 'Last edited entries',\n },\n component: async () => {\n const { LastEditedWidget } = await import('./components/Widgets');\n return LastEditedWidget;\n },\n pluginId: PLUGIN_ID,\n id: 'last-edited-entries',\n permissions: [{ action: 'plugin::content-manager.explorer.read' }],\n },\n {\n icon: CheckCircle,\n title: {\n id: `${PLUGIN_ID}.widget.last-published.title`,\n defaultMessage: 'Last published entries',\n },\n component: async () => {\n const { LastPublishedWidget } = await import('./components/Widgets');\n return LastPublishedWidget;\n },\n pluginId: PLUGIN_ID,\n id: 'last-published-entries',\n permissions: [{ action: 'plugin::content-manager.explorer.read' }],\n },\n ]);\n },\n bootstrap(app: any) {\n if (typeof historyAdmin.bootstrap === 'function') {\n historyAdmin.bootstrap(app);\n }\n if (typeof previewAdmin.bootstrap === 'function') {\n previewAdmin.bootstrap(app);\n }\n },\n async registerTrads({ locales }: { locales: string[] }) {\n const importedTrads = await Promise.all(\n locales.map((locale) => {\n return import(`./translations/${locale}.json`)\n .then(({ default: data }) => {\n return {\n data: prefixPluginTranslations(data, PLUGIN_ID),\n locale,\n };\n })\n .catch(() => {\n return {\n data: {},\n locale,\n };\n });\n })\n );\n\n return Promise.resolve(importedTrads);\n },\n};\n\nexport * from './exports';\n"],"names":["register","app","cm","ContentManagerPlugin","addReducers","PLUGIN_ID","reducer","addMenuLink","to","icon","Feather","intlLabel","id","defaultMessage","permissions","position","router","addRoute","path","lazy","Layout","Component","children","routes","registerPlugin","config","widgets","Pencil","title","component","LastEditedWidget","pluginId","action","CheckCircle","LastPublishedWidget","bootstrap","historyAdmin","previewAdmin","registerTrads","locales","importedTrads","Promise","all","map","locale","then","default","data","prefixPluginTranslations","catch","resolve"],"mappings":"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"}
@@ -6,6 +6,9 @@ var strapiAdmin = require('@strapi/admin/strapi-admin');
6
6
  var designSystem = require('@strapi/design-system');
7
7
  var Icons = require('@strapi/icons');
8
8
  var mapValues = require('lodash/fp/mapValues');
9
+ var get = require('lodash/get');
10
+ var merge = require('lodash/merge');
11
+ var set = require('lodash/set');
9
12
  var reactIntl = require('react-intl');
10
13
  var reactRouterDom = require('react-router-dom');
11
14
  var styledComponents = require('styled-components');
@@ -20,6 +23,7 @@ var router = require('../../../router.js');
20
23
  var documents = require('../../../services/documents.js');
21
24
  var api = require('../../../utils/api.js');
22
25
  var translations = require('../../../utils/translations.js');
26
+ var RelationModal = require('./FormInputs/Relations/RelationModal.js');
23
27
 
24
28
  function _interopNamespaceDefault(e) {
25
29
  var n = Object.create(null);
@@ -40,6 +44,38 @@ function _interopNamespaceDefault(e) {
40
44
 
41
45
  var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
42
46
 
47
+ const connectRelationToParent = (parentDataToUpdate, fieldToConnect, data, fieldToConnectUID)=>{
48
+ /*
49
+ * Check if the fieldToConnect is already present in the parentDataToUpdate.
50
+ * This happens in particular when in the parentDocument you have created
51
+ * a new component without saving.
52
+ */ const isFieldPresent = !!get(parentDataToUpdate, fieldToConnect);
53
+ const fieldToConnectPath = isFieldPresent ? fieldToConnect : fieldToConnect.split('.').slice(0, -1).join('.');
54
+ const fieldToConnectValue = isFieldPresent ? {
55
+ connect: [
56
+ {
57
+ id: data.documentId,
58
+ documentId: data.documentId,
59
+ locale: data.locale
60
+ }
61
+ ]
62
+ } : {
63
+ [fieldToConnect.split('.').pop()]: {
64
+ connect: [
65
+ {
66
+ id: data.documentId,
67
+ documentId: data.documentId,
68
+ locale: data.locale
69
+ }
70
+ ],
71
+ disconnect: []
72
+ },
73
+ // In case the object was not present you need to pass the componentUID of the parent document
74
+ __component: fieldToConnectUID
75
+ };
76
+ const objectToConnect = set({}, fieldToConnectPath, fieldToConnectValue);
77
+ return merge(parentDataToUpdate, objectToConnect);
78
+ };
43
79
  const DocumentActions = ({ actions })=>{
44
80
  const { formatMessage } = reactIntl.useIntl();
45
81
  const [primaryAction, secondaryAction, ...restActions] = actions.filter((action)=>{
@@ -381,7 +417,10 @@ const transformData = (data)=>{
381
417
  const isCloning = reactRouterDom.useMatch(router.CLONE_PATH) !== null;
382
418
  const { id } = reactRouterDom.useParams();
383
419
  const { formatMessage } = reactIntl.useIntl();
384
- const canPublish = DocumentRBAC.useDocumentRBAC('PublishAction', ({ canPublish })=>canPublish);
420
+ const { canPublish, canReadFields } = DocumentRBAC.useDocumentRBAC('PublishAction', ({ canPublish, canReadFields })=>({
421
+ canPublish,
422
+ canReadFields
423
+ }));
385
424
  const { publish, isLoading } = useDocumentActions.useDocumentActions();
386
425
  const onPreview = Preview.usePreviewContext('UpdateAction', (state)=>state.onPreview, false);
387
426
  const [countDraftRelations, { isLoading: isLoadingDraftRelations, isError: isErrorDraftRelations }] = documents.useGetDraftRelationCountQuery();
@@ -395,7 +434,17 @@ const transformData = (data)=>{
395
434
  const setErrors = strapiAdmin.useForm('PublishAction', (state)=>state.setErrors);
396
435
  const formValues = strapiAdmin.useForm('PublishAction', ({ values })=>values);
397
436
  const resetForm = strapiAdmin.useForm('PublishAction', ({ resetForm })=>resetForm);
437
+ // need to discriminate if the publish is coming from a relation modal or in the edit view
438
+ const relationContext = RelationModal.useRelationModal('PublishAction', ()=>true, false);
439
+ const fromRelationModal = relationContext != undefined;
440
+ const dispatch = RelationModal.useRelationModal('PublishAction', (state)=>state.dispatch);
441
+ const fieldToConnect = RelationModal.useRelationModal('PublishAction', (state)=>state.state.fieldToConnect, false);
442
+ const fieldToConnectUID = RelationModal.useRelationModal('PublishAction', (state)=>state.state.fieldToConnectUID, false);
443
+ const documentHistory = RelationModal.useRelationModal('PublishAction', (state)=>state.state.documentHistory, false);
444
+ const rootDocumentMeta = RelationModal.useRelationModal('PublishAction', (state)=>state.rootDocumentMeta);
398
445
  const { currentDocumentMeta } = useDocumentContext.useDocumentContext('PublishAction');
446
+ const [updateDocumentMutation] = documents.useUpdateDocumentMutation();
447
+ const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
399
448
  const idToPublish = currentDocumentMeta.documentId || id;
400
449
  React__namespace.useEffect(()=>{
401
450
  if (isErrorDraftRelations) {
@@ -479,6 +528,16 @@ const transformData = (data)=>{
479
528
  model,
480
529
  currentDocumentMeta.params
481
530
  ]);
531
+ const parentDocumentMetaToUpdate = documentHistory?.at(-2) ?? rootDocumentMeta;
532
+ const parentDocumentData = useDocument.useDocument({
533
+ documentId: parentDocumentMetaToUpdate?.documentId,
534
+ model: parentDocumentMetaToUpdate?.model,
535
+ collectionType: parentDocumentMetaToUpdate?.collectionType,
536
+ params: parentDocumentMetaToUpdate?.params
537
+ }, {
538
+ skip: !parentDocumentMetaToUpdate
539
+ });
540
+ const { getInitialFormValues } = useDocument.useDoc();
482
541
  const isDocumentPublished = (document?.[attributes.PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc)=>doc[attributes.PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== 'modified';
483
542
  if (!schema?.options?.draftAndPublish) {
484
543
  return null;
@@ -490,13 +549,27 @@ const transformData = (data)=>{
490
549
  status: 'published'
491
550
  });
492
551
  if (errors) {
493
- toggleNotification({
494
- type: 'danger',
495
- message: formatMessage({
496
- id: 'content-manager.validation.error',
497
- defaultMessage: 'There are validation errors in your document. Please fix them before saving.'
498
- })
552
+ const hasUnreadableRequiredField = Object.keys(schema.attributes).some((fieldName)=>{
553
+ const attribute = schema.attributes[fieldName];
554
+ return attribute?.required && !(canReadFields ?? []).includes(fieldName);
499
555
  });
556
+ if (hasUnreadableRequiredField) {
557
+ toggleNotification({
558
+ type: 'danger',
559
+ message: formatMessage({
560
+ id: 'content-manager.validation.error.unreadable-required-field',
561
+ defaultMessage: 'Your current permissions prevent access to certain required fields. Please request access from an administrator to proceed.'
562
+ })
563
+ });
564
+ } else {
565
+ toggleNotification({
566
+ type: 'danger',
567
+ message: formatMessage({
568
+ id: 'content-manager.validation.error',
569
+ defaultMessage: 'There are validation errors in your document. Please fix them before saving.'
570
+ })
571
+ });
572
+ }
500
573
  return;
501
574
  }
502
575
  const res = await publish({
@@ -512,11 +585,59 @@ const transformData = (data)=>{
512
585
  if ('data' in res && collectionType !== collections.SINGLE_TYPES) {
513
586
  /**
514
587
  * TODO: refactor the router so we can just do `../${res.data.documentId}` instead of this.
515
- */ if (idToPublish === 'create') {
588
+ */ if (idToPublish === 'create' && !fromRelationModal) {
516
589
  navigate({
517
590
  pathname: `../${collectionType}/${model}/${res.data.documentId}`,
518
591
  search: rawQuery
519
592
  });
593
+ } else if (fromRelationModal) {
594
+ const newRelation = {
595
+ documentId: res.data.documentId,
596
+ collectionType,
597
+ model,
598
+ params: currentDocumentMeta.params
599
+ };
600
+ /*
601
+ * Update, if needed, the parent relation with the newly published document.
602
+ * Check if in history we have the parent relation otherwise use the
603
+ * rootDocument
604
+ */ if (fieldToConnect && documentHistory && (parentDocumentMetaToUpdate.documentId || parentDocumentMetaToUpdate.collectionType === collections.SINGLE_TYPES)) {
605
+ const parentDataToUpdate = parentDocumentMetaToUpdate.collectionType === collections.SINGLE_TYPES ? getInitialFormValues() : parentDocumentData.getInitialFormValues();
606
+ const metaDocumentToUpdate = documentHistory.at(-2) ?? rootDocumentMeta;
607
+ const dataToUpdate = connectRelationToParent(parentDataToUpdate, fieldToConnect, res.data, fieldToConnectUID);
608
+ try {
609
+ const updateRes = await updateDocumentMutation({
610
+ collectionType: metaDocumentToUpdate.collectionType,
611
+ model: metaDocumentToUpdate.model,
612
+ documentId: metaDocumentToUpdate.collectionType !== collections.SINGLE_TYPES ? metaDocumentToUpdate.documentId : undefined,
613
+ params: metaDocumentToUpdate.params,
614
+ data: dataToUpdate
615
+ });
616
+ if ('error' in updateRes) {
617
+ toggleNotification({
618
+ type: 'danger',
619
+ message: formatAPIError(updateRes.error)
620
+ });
621
+ return;
622
+ }
623
+ } catch (err) {
624
+ toggleNotification({
625
+ type: 'danger',
626
+ message: formatMessage({
627
+ id: 'notification.error',
628
+ defaultMessage: 'An error occurred'
629
+ })
630
+ });
631
+ throw err;
632
+ }
633
+ }
634
+ dispatch({
635
+ type: 'GO_TO_CREATED_RELATION',
636
+ payload: {
637
+ document: newRelation,
638
+ shouldBypassConfirmation: true
639
+ }
640
+ });
520
641
  }
521
642
  } else if ('error' in res && api.isBaseQueryError(res.error) && res.error.name === 'ValidationError') {
522
643
  setErrors(formatValidationErrors(res.error));
@@ -592,14 +713,34 @@ const UpdateAction = ({ activeTab, documentId, model, collectionType })=>{
592
713
  const { create, update, clone, isLoading } = useDocumentActions.useDocumentActions();
593
714
  const [{ rawQuery }] = strapiAdmin.useQueryParams();
594
715
  const onPreview = Preview.usePreviewContext('UpdateAction', (state)=>state.onPreview, false);
716
+ const { getInitialFormValues } = useDocument.useDoc();
595
717
  const isSubmitting = strapiAdmin.useForm('UpdateAction', ({ isSubmitting })=>isSubmitting);
596
718
  const modified = strapiAdmin.useForm('UpdateAction', ({ modified })=>modified);
597
719
  const setSubmitting = strapiAdmin.useForm('UpdateAction', ({ setSubmitting })=>setSubmitting);
598
720
  const document = strapiAdmin.useForm('UpdateAction', ({ values })=>values);
599
721
  const validate = strapiAdmin.useForm('UpdateAction', (state)=>state.validate);
600
722
  const setErrors = strapiAdmin.useForm('UpdateAction', (state)=>state.setErrors);
601
- const resetForm = strapiAdmin.useForm('PublishAction', ({ resetForm })=>resetForm);
723
+ const resetForm = strapiAdmin.useForm('UpdateAction', ({ resetForm })=>resetForm);
724
+ const dispatch = RelationModal.useRelationModal('UpdateAction', (state)=>state.dispatch);
725
+ // need to discriminate if the update is coming from a relation modal or in the edit view
726
+ const relationContext = RelationModal.useRelationModal('UpdateAction', ()=>true, false);
727
+ const fieldToConnect = RelationModal.useRelationModal('UpdateAction', (state)=>state.state.fieldToConnect, false);
728
+ const fieldToConnectUID = RelationModal.useRelationModal('PublishAction', (state)=>state.state.fieldToConnectUID, false);
729
+ const documentHistory = RelationModal.useRelationModal('UpdateAction', (state)=>state.state.documentHistory, false);
730
+ const rootDocumentMeta = RelationModal.useRelationModal('UpdateAction', (state)=>state.rootDocumentMeta);
731
+ const fromRelationModal = relationContext != undefined;
602
732
  const { currentDocumentMeta } = useDocumentContext.useDocumentContext('UpdateAction');
733
+ const [updateDocumentMutation] = documents.useUpdateDocumentMutation();
734
+ const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
735
+ const parentDocumentMetaToUpdate = documentHistory?.at(-2) ?? rootDocumentMeta;
736
+ const parentDocumentData = useDocument.useDocument({
737
+ documentId: parentDocumentMetaToUpdate?.documentId,
738
+ model: parentDocumentMetaToUpdate?.model,
739
+ collectionType: parentDocumentMetaToUpdate?.collectionType,
740
+ params: parentDocumentMetaToUpdate?.params
741
+ }, {
742
+ skip: !parentDocumentMetaToUpdate
743
+ });
603
744
  const handleUpdate = React__namespace.useCallback(async ()=>{
604
745
  setSubmitting(true);
605
746
  try {
@@ -653,13 +794,64 @@ const UpdateAction = ({ activeTab, documentId, model, collectionType })=>{
653
794
  params: currentDocumentMeta.params
654
795
  }, transformData(document));
655
796
  if ('data' in res && collectionType !== collections.SINGLE_TYPES) {
656
- navigate({
657
- pathname: `../${res.data.documentId}`,
658
- search: rawQuery
659
- }, {
660
- replace: true,
661
- relative: 'path'
662
- });
797
+ if (fromRelationModal) {
798
+ const createdRelation = {
799
+ documentId: res.data.documentId,
800
+ collectionType,
801
+ model,
802
+ params: currentDocumentMeta.params
803
+ };
804
+ /*
805
+ * Update, if needed, the parent relation with the newly published document.
806
+ * Check if in history we have the parent relation otherwise use the
807
+ * rootDocument
808
+ */ if (fieldToConnect && documentHistory && (parentDocumentMetaToUpdate.documentId || parentDocumentMetaToUpdate.collectionType === collections.SINGLE_TYPES)) {
809
+ const parentDataToUpdate = parentDocumentMetaToUpdate.collectionType === collections.SINGLE_TYPES ? getInitialFormValues() : parentDocumentData.getInitialFormValues();
810
+ const dataToUpdate = connectRelationToParent(parentDataToUpdate, fieldToConnect, res.data, fieldToConnectUID);
811
+ try {
812
+ const updateRes = await updateDocumentMutation({
813
+ collectionType: parentDocumentMetaToUpdate.collectionType,
814
+ model: parentDocumentMetaToUpdate.model,
815
+ documentId: parentDocumentMetaToUpdate.collectionType !== collections.SINGLE_TYPES ? parentDocumentMetaToUpdate.documentId : undefined,
816
+ params: parentDocumentMetaToUpdate.params,
817
+ data: {
818
+ ...dataToUpdate
819
+ }
820
+ });
821
+ if ('error' in updateRes) {
822
+ toggleNotification({
823
+ type: 'danger',
824
+ message: formatAPIError(updateRes.error)
825
+ });
826
+ return;
827
+ }
828
+ } catch (err) {
829
+ toggleNotification({
830
+ type: 'danger',
831
+ message: formatMessage({
832
+ id: 'notification.error',
833
+ defaultMessage: 'An error occurred'
834
+ })
835
+ });
836
+ throw err;
837
+ }
838
+ }
839
+ dispatch({
840
+ type: 'GO_TO_CREATED_RELATION',
841
+ payload: {
842
+ document: createdRelation,
843
+ shouldBypassConfirmation: true
844
+ }
845
+ });
846
+ } else {
847
+ navigate({
848
+ pathname: `../${res.data.documentId}`,
849
+ search: rawQuery
850
+ }, {
851
+ replace: true,
852
+ relative: 'path'
853
+ });
854
+ }
663
855
  } else if ('error' in res && api.isBaseQueryError(res.error) && res.error.name === 'ValidationError') {
664
856
  setErrors(formatValidationErrors(res.error));
665
857
  }
@@ -671,26 +863,36 @@ const UpdateAction = ({ activeTab, documentId, model, collectionType })=>{
671
863
  }
672
864
  }
673
865
  }, [
866
+ setSubmitting,
867
+ modified,
868
+ validate,
869
+ isCloning,
870
+ documentId,
871
+ collectionType,
872
+ toggleNotification,
873
+ formatMessage,
674
874
  clone,
875
+ model,
675
876
  cloneMatch?.params.origin,
676
- collectionType,
677
- create,
678
877
  currentDocumentMeta.params,
679
878
  document,
680
- documentId,
681
- formatMessage,
682
- formatValidationErrors,
683
- isCloning,
684
- model,
685
- modified,
686
879
  navigate,
687
880
  rawQuery,
688
- resetForm,
689
881
  setErrors,
690
- setSubmitting,
691
- toggleNotification,
882
+ formatValidationErrors,
692
883
  update,
693
- validate,
884
+ resetForm,
885
+ create,
886
+ fromRelationModal,
887
+ fieldToConnect,
888
+ documentHistory,
889
+ parentDocumentMetaToUpdate,
890
+ dispatch,
891
+ getInitialFormValues,
892
+ parentDocumentData,
893
+ fieldToConnectUID,
894
+ updateDocumentMutation,
895
+ formatAPIError,
694
896
  onPreview
695
897
  ]);
696
898
  // Auto-save on CMD+S or CMD+Enter on macOS, and CTRL+S or CTRL+Enter on Windows/Linux