@strapi/content-manager 0.0.0-experimental.25f7de53c1fc990bbb86d4aa43c379acfa838064 → 0.0.0-experimental.267375bdc00aa57de5e78acd345a838d21a63676

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 (70) hide show
  1. package/dist/admin/components/ConfigurationForm/Fields.js +300 -204
  2. package/dist/admin/components/ConfigurationForm/Fields.js.map +1 -1
  3. package/dist/admin/components/ConfigurationForm/Fields.mjs +304 -209
  4. package/dist/admin/components/ConfigurationForm/Fields.mjs.map +1 -1
  5. package/dist/admin/components/LeftMenu.js +34 -30
  6. package/dist/admin/components/LeftMenu.js.map +1 -1
  7. package/dist/admin/components/LeftMenu.mjs +36 -32
  8. package/dist/admin/components/LeftMenu.mjs.map +1 -1
  9. package/dist/admin/history/components/VersionHeader.js +6 -0
  10. package/dist/admin/history/components/VersionHeader.js.map +1 -1
  11. package/dist/admin/history/components/VersionHeader.mjs +7 -1
  12. package/dist/admin/history/components/VersionHeader.mjs.map +1 -1
  13. package/dist/admin/hooks/useDocumentActions.js +5 -1
  14. package/dist/admin/hooks/useDocumentActions.js.map +1 -1
  15. package/dist/admin/hooks/useDocumentActions.mjs +5 -1
  16. package/dist/admin/hooks/useDocumentActions.mjs.map +1 -1
  17. package/dist/admin/hooks/useDocumentContext.js.map +1 -1
  18. package/dist/admin/hooks/useDocumentContext.mjs.map +1 -1
  19. package/dist/admin/pages/EditView/EditViewPage.js +81 -74
  20. package/dist/admin/pages/EditView/EditViewPage.js.map +1 -1
  21. package/dist/admin/pages/EditView/EditViewPage.mjs +82 -75
  22. package/dist/admin/pages/EditView/EditViewPage.mjs.map +1 -1
  23. package/dist/admin/pages/EditView/components/DocumentActions.js +230 -28
  24. package/dist/admin/pages/EditView/components/DocumentActions.js.map +1 -1
  25. package/dist/admin/pages/EditView/components/DocumentActions.mjs +232 -30
  26. package/dist/admin/pages/EditView/components/DocumentActions.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/Relations/RelationModal.js +128 -55
  32. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js.map +1 -1
  33. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs +128 -55
  34. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs.map +1 -1
  35. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +91 -51
  36. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
  37. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +93 -53
  38. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
  39. package/dist/admin/pages/EditView/components/FormLayout.js +20 -24
  40. package/dist/admin/pages/EditView/components/FormLayout.js.map +1 -1
  41. package/dist/admin/pages/EditView/components/FormLayout.mjs +20 -24
  42. package/dist/admin/pages/EditView/components/FormLayout.mjs.map +1 -1
  43. package/dist/admin/pages/ListView/ListViewPage.js +77 -0
  44. package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
  45. package/dist/admin/pages/ListView/ListViewPage.mjs +78 -1
  46. package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
  47. package/dist/admin/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.js +2 -1
  48. package/dist/admin/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.js.map +1 -1
  49. package/dist/admin/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.mjs +2 -1
  50. package/dist/admin/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.mjs.map +1 -1
  51. package/dist/admin/src/components/ConfigurationForm/Fields.d.ts +6 -4
  52. package/dist/admin/src/hooks/useDocumentContext.d.ts +1 -1
  53. package/dist/admin/src/pages/EditView/components/FormInputs/Relations/RelationModal.d.ts +26 -5
  54. package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +7 -8
  55. package/dist/admin/translations/en.json.js +3 -1
  56. package/dist/admin/translations/en.json.js.map +1 -1
  57. package/dist/admin/translations/en.json.mjs +3 -1
  58. package/dist/admin/translations/en.json.mjs.map +1 -1
  59. package/dist/server/history/services/lifecycles.js +3 -0
  60. package/dist/server/history/services/lifecycles.js.map +1 -1
  61. package/dist/server/history/services/lifecycles.mjs +3 -0
  62. package/dist/server/history/services/lifecycles.mjs.map +1 -1
  63. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  64. package/dist/server/src/index.d.ts +1 -0
  65. package/dist/server/src/index.d.ts.map +1 -1
  66. package/dist/server/src/services/data-mapper.d.ts +1 -0
  67. package/dist/server/src/services/data-mapper.d.ts.map +1 -1
  68. package/dist/server/src/services/index.d.ts +1 -0
  69. package/dist/server/src/services/index.d.ts.map +1 -1
  70. package/package.json +11 -8
@@ -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;;;;"}
@@ -22,7 +22,16 @@ var Panels = require('./components/Panels.js');
22
22
 
23
23
  /* -------------------------------------------------------------------------------------------------
24
24
  * EditViewPage
25
- * -----------------------------------------------------------------------------------------------*/ const EditViewPage = ()=>{
25
+ * -----------------------------------------------------------------------------------------------*/ // Needs to be wrapped in a component to have access to the form context via a hook.
26
+ // Using the Form component's render prop instead would cause unnecessary re-renders of Form children
27
+ const BlockerWrapper = ()=>{
28
+ const resetForm = strapiAdmin.useForm('BlockerWrapper', (state)=>state.resetForm);
29
+ // We reset the form to the published version to avoid errors like – https://strapi-inc.atlassian.net/browse/CONTENT-2284
30
+ return /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.Blocker, {
31
+ onProceed: resetForm
32
+ });
33
+ };
34
+ const EditViewPage = ()=>{
26
35
  const location = reactRouterDom.useLocation();
27
36
  const [{ query: { status } }, setQuery] = strapiAdmin.useQueryParams({
28
37
  status: 'draft'
@@ -53,6 +62,7 @@ var Panels = require('./components/Panels.js');
53
62
  * document with varying params.
54
63
  */ const isCreatingDocument = !id && !isSingleType;
55
64
  const { isLoading: isLoadingLayout, edit: { layout, settings: { mainField } } } = useDocumentLayout.useDocumentLayout(model);
65
+ const pageTitle = getTitle(mainField);
56
66
  const { isLazyLoading } = useLazyComponents.useLazyComponents([]);
57
67
  const isLoading = isLoadingActionsRBAC || isLoadingDocument || isLoadingLayout || isLazyLoading;
58
68
  const initialValues = getInitialFormValues(isCreatingDocument);
@@ -83,7 +93,7 @@ var Panels = require('./components/Panels.js');
83
93
  paddingRight: 10,
84
94
  children: [
85
95
  /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.Page.Title, {
86
- children: getTitle(mainField)
96
+ children: pageTitle
87
97
  }),
88
98
  /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.Form, {
89
99
  disabled: hasDraftAndPublished && status === 'published',
@@ -99,86 +109,83 @@ var Panels = require('./components/Panels.js');
99
109
  });
100
110
  },
101
111
  initialErrors: location?.state?.forceValidation ? validateSync(initialValues, {}) : {},
102
- children: ({ resetForm })=>/*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
103
- children: [
104
- /*#__PURE__*/ jsxRuntime.jsx(Header.Header, {
105
- isCreating: isCreatingDocument,
106
- status: hasDraftAndPublished ? getDocumentStatus(document, meta) : undefined,
107
- title: getTitle(mainField)
108
- }),
109
- /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Tabs.Root, {
110
- variant: "simple",
111
- value: status,
112
- onValueChange: handleTabChange,
113
- children: [
114
- /*#__PURE__*/ jsxRuntime.jsx(designSystem.Tabs.List, {
115
- "aria-label": formatMessage({
116
- id: translations.getTranslation('containers.edit.tabs.label'),
117
- defaultMessage: 'Document status'
118
- }),
119
- children: hasDraftAndPublished ? /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
112
+ children: /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
113
+ children: [
114
+ /*#__PURE__*/ jsxRuntime.jsx(Header.Header, {
115
+ isCreating: isCreatingDocument,
116
+ status: hasDraftAndPublished ? getDocumentStatus(document, meta) : undefined,
117
+ title: pageTitle
118
+ }),
119
+ /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Tabs.Root, {
120
+ variant: "simple",
121
+ value: status,
122
+ onValueChange: handleTabChange,
123
+ children: [
124
+ /*#__PURE__*/ jsxRuntime.jsx(designSystem.Tabs.List, {
125
+ "aria-label": formatMessage({
126
+ id: translations.getTranslation('containers.edit.tabs.label'),
127
+ defaultMessage: 'Document status'
128
+ }),
129
+ children: hasDraftAndPublished ? /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
130
+ children: [
131
+ /*#__PURE__*/ jsxRuntime.jsx(StatusTab, {
132
+ value: "draft",
133
+ children: formatMessage({
134
+ id: translations.getTranslation('containers.edit.tabs.draft'),
135
+ defaultMessage: 'draft'
136
+ })
137
+ }),
138
+ /*#__PURE__*/ jsxRuntime.jsx(StatusTab, {
139
+ disabled: !meta || meta.availableStatus.length === 0,
140
+ value: "published",
141
+ children: formatMessage({
142
+ id: translations.getTranslation('containers.edit.tabs.published'),
143
+ defaultMessage: 'published'
144
+ })
145
+ })
146
+ ]
147
+ }) : null
148
+ }),
149
+ /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Grid.Root, {
150
+ paddingTop: 8,
151
+ gap: 4,
152
+ children: [
153
+ /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Grid.Item, {
154
+ col: 9,
155
+ s: 12,
156
+ direction: "column",
157
+ alignItems: "stretch",
120
158
  children: [
121
- /*#__PURE__*/ jsxRuntime.jsx(StatusTab, {
159
+ /*#__PURE__*/ jsxRuntime.jsx(designSystem.Tabs.Content, {
122
160
  value: "draft",
123
- children: formatMessage({
124
- id: translations.getTranslation('containers.edit.tabs.draft'),
125
- defaultMessage: 'draft'
161
+ children: /*#__PURE__*/ jsxRuntime.jsx(FormLayout.FormLayout, {
162
+ layout: layout,
163
+ document: doc
126
164
  })
127
165
  }),
128
- /*#__PURE__*/ jsxRuntime.jsx(StatusTab, {
129
- disabled: !meta || meta.availableStatus.length === 0,
166
+ /*#__PURE__*/ jsxRuntime.jsx(designSystem.Tabs.Content, {
130
167
  value: "published",
131
- children: formatMessage({
132
- id: translations.getTranslation('containers.edit.tabs.published'),
133
- defaultMessage: 'published'
168
+ children: /*#__PURE__*/ jsxRuntime.jsx(FormLayout.FormLayout, {
169
+ layout: layout,
170
+ document: doc
134
171
  })
135
172
  })
136
173
  ]
137
- }) : null
138
- }),
139
- /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Grid.Root, {
140
- paddingTop: 8,
141
- gap: 4,
142
- children: [
143
- /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Grid.Item, {
144
- col: 9,
145
- s: 12,
146
- direction: "column",
147
- alignItems: "stretch",
148
- children: [
149
- /*#__PURE__*/ jsxRuntime.jsx(designSystem.Tabs.Content, {
150
- value: "draft",
151
- children: /*#__PURE__*/ jsxRuntime.jsx(FormLayout.FormLayout, {
152
- layout: layout,
153
- document: doc
154
- })
155
- }),
156
- /*#__PURE__*/ jsxRuntime.jsx(designSystem.Tabs.Content, {
157
- value: "published",
158
- children: /*#__PURE__*/ jsxRuntime.jsx(FormLayout.FormLayout, {
159
- layout: layout,
160
- document: doc
161
- })
162
- })
163
- ]
164
- }),
165
- /*#__PURE__*/ jsxRuntime.jsx(designSystem.Grid.Item, {
166
- col: 3,
167
- s: 12,
168
- direction: "column",
169
- alignItems: "stretch",
170
- children: /*#__PURE__*/ jsxRuntime.jsx(Panels.Panels, {})
171
- })
172
- ]
173
- })
174
- ]
175
- }),
176
- /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.Blocker, {
177
- // We reset the form to the published version to avoid errors like – https://strapi-inc.atlassian.net/browse/CONTENT-2284
178
- onProceed: resetForm
179
- })
180
- ]
181
- })
174
+ }),
175
+ /*#__PURE__*/ jsxRuntime.jsx(designSystem.Grid.Item, {
176
+ col: 3,
177
+ s: 12,
178
+ direction: "column",
179
+ alignItems: "stretch",
180
+ children: /*#__PURE__*/ jsxRuntime.jsx(Panels.Panels, {})
181
+ })
182
+ ]
183
+ })
184
+ ]
185
+ }),
186
+ /*#__PURE__*/ jsxRuntime.jsx(BlockerWrapper, {})
187
+ ]
188
+ })
182
189
  })
183
190
  ]
184
191
  });
@@ -1 +1 @@
1
- {"version":3,"file":"EditViewPage.js","sources":["../../../../admin/src/pages/EditView/EditViewPage.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n Page,\n Blocker,\n Form,\n useRBAC,\n useNotification,\n useQueryParams,\n} from '@strapi/admin/strapi-admin';\nimport { Grid, Main, Tabs } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { useLocation, useParams } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { SINGLE_TYPES } from '../../constants/collections';\nimport { PERMISSIONS } from '../../constants/plugin';\nimport { DocumentRBAC, useDocumentRBAC } from '../../features/DocumentRBAC';\nimport { useDoc, type UseDocument } from '../../hooks/useDocument';\nimport { useDocumentLayout } from '../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../hooks/useLazyComponents';\nimport { useOnce } from '../../hooks/useOnce';\nimport { getTranslation } from '../../utils/translations';\nimport { createYupSchema } from '../../utils/validation';\n\nimport { FormLayout } from './components/FormLayout';\nimport { Header } from './components/Header';\nimport { Panels } from './components/Panels';\n\n/* -------------------------------------------------------------------------------------------------\n * EditViewPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst EditViewPage = () => {\n const location = useLocation();\n const [\n {\n query: { status },\n },\n setQuery,\n ] = useQueryParams<{ status: 'draft' | 'published' }>({\n status: 'draft',\n });\n const { formatMessage } = useIntl();\n const { toggleNotification } = useNotification();\n\n const doc = useDoc();\n const {\n document,\n meta,\n isLoading: isLoadingDocument,\n schema,\n components,\n collectionType,\n id,\n model,\n hasError,\n getTitle,\n getInitialFormValues,\n } = doc;\n\n const hasDraftAndPublished = schema?.options?.draftAndPublish ?? false;\n\n useOnce(() => {\n /**\n * We only ever want to fire the notification once otherwise\n * whenever the app re-renders it'll pop up regardless of\n * what we do because the state comes from react-router-dom\n */\n if (location?.state && 'error' in location.state) {\n toggleNotification({\n type: 'danger',\n message: location.state.error,\n timeout: 5000,\n });\n }\n });\n\n const isLoadingActionsRBAC = useDocumentRBAC('EditViewPage', (state) => state.isLoading);\n\n const isSingleType = collectionType === SINGLE_TYPES;\n\n /**\n * single-types don't current have an id, but because they're a singleton\n * we can simply use the update operation to continuously update the same\n * document with varying params.\n */\n const isCreatingDocument = !id && !isSingleType;\n\n const {\n isLoading: isLoadingLayout,\n edit: {\n layout,\n settings: { mainField },\n },\n } = useDocumentLayout(model);\n\n const { isLazyLoading } = useLazyComponents([]);\n\n const isLoading = isLoadingActionsRBAC || isLoadingDocument || isLoadingLayout || isLazyLoading;\n\n const initialValues = getInitialFormValues(isCreatingDocument);\n\n if (isLoading && !document?.documentId) {\n return <Page.Loading />;\n }\n\n if (!initialValues || hasError) {\n return <Page.Error />;\n }\n\n const handleTabChange = (status: string) => {\n if (status === 'published' || status === 'draft') {\n setQuery({ status }, 'push', true);\n }\n };\n\n const validateSync = (values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(schema?.attributes, components, {\n status,\n ...options,\n });\n\n return yupSchema.validateSync(values, { abortEarly: false });\n };\n\n return (\n <Main paddingLeft={10} paddingRight={10}>\n <Page.Title>{getTitle(mainField)}</Page.Title>\n <Form\n disabled={hasDraftAndPublished && status === 'published'}\n initialValues={initialValues}\n method={isCreatingDocument ? 'POST' : 'PUT'}\n validate={(values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(schema?.attributes, components, {\n status,\n ...options,\n });\n\n return yupSchema.validate(values, { abortEarly: false });\n }}\n initialErrors={location?.state?.forceValidation ? validateSync(initialValues, {}) : {}}\n >\n {({ resetForm }) => (\n <>\n <Header\n isCreating={isCreatingDocument}\n status={hasDraftAndPublished ? getDocumentStatus(document, meta) : undefined}\n title={getTitle(mainField)}\n />\n <Tabs.Root variant=\"simple\" value={status} onValueChange={handleTabChange}>\n <Tabs.List\n aria-label={formatMessage({\n id: getTranslation('containers.edit.tabs.label'),\n defaultMessage: 'Document status',\n })}\n >\n {hasDraftAndPublished ? (\n <>\n <StatusTab value=\"draft\">\n {formatMessage({\n id: getTranslation('containers.edit.tabs.draft'),\n defaultMessage: 'draft',\n })}\n </StatusTab>\n <StatusTab\n disabled={!meta || meta.availableStatus.length === 0}\n value=\"published\"\n >\n {formatMessage({\n id: getTranslation('containers.edit.tabs.published'),\n defaultMessage: 'published',\n })}\n </StatusTab>\n </>\n ) : null}\n </Tabs.List>\n <Grid.Root paddingTop={8} gap={4}>\n <Grid.Item col={9} s={12} direction=\"column\" alignItems=\"stretch\">\n <Tabs.Content value=\"draft\">\n <FormLayout layout={layout} document={doc} />\n </Tabs.Content>\n <Tabs.Content value=\"published\">\n <FormLayout layout={layout} document={doc} />\n </Tabs.Content>\n </Grid.Item>\n <Grid.Item col={3} s={12} direction=\"column\" alignItems=\"stretch\">\n <Panels />\n </Grid.Item>\n </Grid.Root>\n </Tabs.Root>\n <Blocker\n // We reset the form to the published version to avoid errors like – https://strapi-inc.atlassian.net/browse/CONTENT-2284\n onProceed={resetForm}\n />\n </>\n )}\n </Form>\n </Main>\n );\n};\n\nconst StatusTab = styled(Tabs.Trigger)`\n text-transform: uppercase;\n`;\n\n/**\n * @internal\n * @description Returns the status of the document where its latest state takes priority,\n * this typically will be \"published\" unless a user has edited their draft in which we should\n * display \"modified\".\n */\nconst getDocumentStatus = (\n document: ReturnType<UseDocument>['document'],\n meta: ReturnType<UseDocument>['meta']\n): 'draft' | 'published' | 'modified' => {\n const docStatus = document?.status;\n const statuses = meta?.availableStatus ?? [];\n\n /**\n * Creating an entry\n */\n if (!docStatus) {\n return 'draft';\n }\n\n /**\n * We're viewing a draft, but the document could have a published version\n */\n if (docStatus === 'draft' && statuses.find((doc) => doc.publishedAt !== null)) {\n return 'published';\n }\n\n return docStatus;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * ProtectedEditViewPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst ProtectedEditViewPage = () => {\n const { slug = '' } = useParams<{\n slug: string;\n }>();\n const {\n permissions = [],\n isLoading,\n error,\n } = useRBAC(\n PERMISSIONS.map((action) => ({\n action,\n subject: slug,\n }))\n );\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (error || !slug) {\n return <Page.Error />;\n }\n\n return (\n <Page.Protect permissions={permissions}>\n {({ permissions }) => (\n <DocumentRBAC permissions={permissions}>\n <EditViewPage />\n </DocumentRBAC>\n )}\n </Page.Protect>\n );\n};\n\nexport { EditViewPage, ProtectedEditViewPage, getDocumentStatus };\n"],"names":["EditViewPage","location","useLocation","query","status","setQuery","useQueryParams","formatMessage","useIntl","toggleNotification","useNotification","doc","useDoc","document","meta","isLoading","isLoadingDocument","schema","components","collectionType","id","model","hasError","getTitle","getInitialFormValues","hasDraftAndPublished","options","draftAndPublish","useOnce","state","type","message","error","timeout","isLoadingActionsRBAC","useDocumentRBAC","isSingleType","SINGLE_TYPES","isCreatingDocument","isLoadingLayout","edit","layout","settings","mainField","useDocumentLayout","isLazyLoading","useLazyComponents","initialValues","documentId","_jsx","Page","Loading","Error","handleTabChange","validateSync","values","yupSchema","createYupSchema","attributes","abortEarly","_jsxs","Main","paddingLeft","paddingRight","Title","Form","disabled","method","validate","initialErrors","forceValidation","resetForm","_Fragment","Header","isCreating","getDocumentStatus","undefined","title","Tabs","Root","variant","value","onValueChange","List","aria-label","getTranslation","defaultMessage","StatusTab","availableStatus","length","Grid","paddingTop","gap","Item","col","s","direction","alignItems","Content","FormLayout","Panels","Blocker","onProceed","styled","Trigger","docStatus","statuses","find","publishedAt","ProtectedEditViewPage","slug","useParams","permissions","useRBAC","PERMISSIONS","map","action","subject","Protect","DocumentRBAC"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA6BA;;AAEkG,2GAE5FA,YAAe,GAAA,IAAA;AACnB,IAAA,MAAMC,QAAWC,GAAAA,0BAAAA,EAAAA;IACjB,MAAM,CACJ,EACEC,KAAAA,EAAO,EAAEC,MAAM,EAAE,EAClB,EACDC,QACD,CAAA,GAAGC,0BAAkD,CAAA;QACpDF,MAAQ,EAAA;AACV,KAAA,CAAA;IACA,MAAM,EAAEG,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;IAC1B,MAAM,EAAEC,kBAAkB,EAAE,GAAGC,2BAAAA,EAAAA;AAE/B,IAAA,MAAMC,GAAMC,GAAAA,kBAAAA,EAAAA;IACZ,MAAM,EACJC,QAAQ,EACRC,IAAI,EACJC,WAAWC,iBAAiB,EAC5BC,MAAM,EACNC,UAAU,EACVC,cAAc,EACdC,EAAE,EACFC,KAAK,EACLC,QAAQ,EACRC,QAAQ,EACRC,oBAAoB,EACrB,GAAGb,GAAAA;IAEJ,MAAMc,oBAAAA,GAAuBR,MAAQS,EAAAA,OAAAA,EAASC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ACiB,SAAW,EAAA;QACd,OAAO,OAAA;AACT;AAEA;;MAGA,IAAIA,SAAc,KAAA,OAAA,IAAWC,QAASC,CAAAA,IAAI,CAAC,CAAChG,GAAQA,GAAAA,GAAAA,CAAIiG,WAAW,KAAK,IAAO,CAAA,EAAA;QAC7E,OAAO,WAAA;AACT;IAEA,OAAOH,SAAAA;AACT;AAEA;;AAEkG,2GAE5FI,qBAAwB,GAAA,IAAA;AAC5B,IAAA,MAAM,EAAEC,IAAAA,GAAO,EAAE,EAAE,GAAGC,wBAAAA,EAAAA;AAGtB,IAAA,MAAM,EACJC,WAAAA,GAAc,EAAE,EAChBjG,SAAS,EACTiB,KAAK,EACN,GAAGiF,oBACFC,kBAAYC,CAAAA,GAAG,CAAC,CAACC,UAAY;AAC3BA,YAAAA,MAAAA;YACAC,OAASP,EAAAA;SACX,CAAA,CAAA,CAAA;AAGF,IAAA,IAAI/F,SAAW,EAAA;QACb,qBAAOkC,cAAA,CAACC,iBAAKC,OAAO,EAAA,EAAA,CAAA;AACtB;IAEA,IAAInB,KAAAA,IAAS,CAAC8E,IAAM,EAAA;QAClB,qBAAO7D,cAAA,CAACC,iBAAKE,KAAK,EAAA,EAAA,CAAA;AACpB;IAEA,qBACEH,cAAA,CAACC,iBAAKoE,OAAO,EAAA;QAACN,WAAaA,EAAAA,WAAAA;AACxB,QAAA,QAAA,EAAA,CAAC,EAAEA,WAAW,EAAE,iBACf/D,cAACsE,CAAAA,yBAAAA,EAAAA;gBAAaP,WAAaA,EAAAA,WAAAA;AACzB,gBAAA,QAAA,gBAAA/D,cAACjD,CAAAA,YAAAA,EAAAA,EAAAA;;;AAKX;;;;;;"}
1
+ {"version":3,"file":"EditViewPage.js","sources":["../../../../admin/src/pages/EditView/EditViewPage.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n Page,\n Blocker,\n Form,\n useForm,\n useRBAC,\n useNotification,\n useQueryParams,\n} from '@strapi/admin/strapi-admin';\nimport { Grid, Main, Tabs } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { useLocation, useParams } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { SINGLE_TYPES } from '../../constants/collections';\nimport { PERMISSIONS } from '../../constants/plugin';\nimport { DocumentRBAC, useDocumentRBAC } from '../../features/DocumentRBAC';\nimport { useDoc, type UseDocument } from '../../hooks/useDocument';\nimport { useDocumentLayout } from '../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../hooks/useLazyComponents';\nimport { useOnce } from '../../hooks/useOnce';\nimport { getTranslation } from '../../utils/translations';\nimport { createYupSchema } from '../../utils/validation';\n\nimport { FormLayout } from './components/FormLayout';\nimport { Header } from './components/Header';\nimport { Panels } from './components/Panels';\n\n/* -------------------------------------------------------------------------------------------------\n * EditViewPage\n * -----------------------------------------------------------------------------------------------*/\n\n// Needs to be wrapped in a component to have access to the form context via a hook.\n// Using the Form component's render prop instead would cause unnecessary re-renders of Form children\nconst BlockerWrapper = () => {\n const resetForm = useForm('BlockerWrapper', (state) => state.resetForm);\n\n // We reset the form to the published version to avoid errors like – https://strapi-inc.atlassian.net/browse/CONTENT-2284\n return <Blocker onProceed={resetForm} />;\n};\n\nconst EditViewPage = () => {\n const location = useLocation();\n const [\n {\n query: { status },\n },\n setQuery,\n ] = useQueryParams<{ status: 'draft' | 'published' }>({\n status: 'draft',\n });\n const { formatMessage } = useIntl();\n const { toggleNotification } = useNotification();\n\n const doc = useDoc();\n const {\n document,\n meta,\n isLoading: isLoadingDocument,\n schema,\n components,\n collectionType,\n id,\n model,\n hasError,\n getTitle,\n getInitialFormValues,\n } = doc;\n\n const hasDraftAndPublished = schema?.options?.draftAndPublish ?? false;\n\n useOnce(() => {\n /**\n * We only ever want to fire the notification once otherwise\n * whenever the app re-renders it'll pop up regardless of\n * what we do because the state comes from react-router-dom\n */\n if (location?.state && 'error' in location.state) {\n toggleNotification({\n type: 'danger',\n message: location.state.error,\n timeout: 5000,\n });\n }\n });\n\n const isLoadingActionsRBAC = useDocumentRBAC('EditViewPage', (state) => state.isLoading);\n\n const isSingleType = collectionType === SINGLE_TYPES;\n\n /**\n * single-types don't current have an id, but because they're a singleton\n * we can simply use the update operation to continuously update the same\n * document with varying params.\n */\n const isCreatingDocument = !id && !isSingleType;\n\n const {\n isLoading: isLoadingLayout,\n edit: {\n layout,\n settings: { mainField },\n },\n } = useDocumentLayout(model);\n const pageTitle = getTitle(mainField);\n\n const { isLazyLoading } = useLazyComponents([]);\n\n const isLoading = isLoadingActionsRBAC || isLoadingDocument || isLoadingLayout || isLazyLoading;\n\n const initialValues = getInitialFormValues(isCreatingDocument);\n\n if (isLoading && !document?.documentId) {\n return <Page.Loading />;\n }\n\n if (!initialValues || hasError) {\n return <Page.Error />;\n }\n\n const handleTabChange = (status: string) => {\n if (status === 'published' || status === 'draft') {\n setQuery({ status }, 'push', true);\n }\n };\n\n const validateSync = (values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(schema?.attributes, components, {\n status,\n ...options,\n });\n\n return yupSchema.validateSync(values, { abortEarly: false });\n };\n\n return (\n <Main paddingLeft={10} paddingRight={10}>\n <Page.Title>{pageTitle}</Page.Title>\n <Form\n disabled={hasDraftAndPublished && status === 'published'}\n initialValues={initialValues}\n method={isCreatingDocument ? 'POST' : 'PUT'}\n validate={(values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(schema?.attributes, components, {\n status,\n ...options,\n });\n\n return yupSchema.validate(values, { abortEarly: false });\n }}\n initialErrors={location?.state?.forceValidation ? validateSync(initialValues, {}) : {}}\n >\n <>\n <Header\n isCreating={isCreatingDocument}\n status={hasDraftAndPublished ? getDocumentStatus(document, meta) : undefined}\n title={pageTitle}\n />\n <Tabs.Root variant=\"simple\" value={status} onValueChange={handleTabChange}>\n <Tabs.List\n aria-label={formatMessage({\n id: getTranslation('containers.edit.tabs.label'),\n defaultMessage: 'Document status',\n })}\n >\n {hasDraftAndPublished ? (\n <>\n <StatusTab value=\"draft\">\n {formatMessage({\n id: getTranslation('containers.edit.tabs.draft'),\n defaultMessage: 'draft',\n })}\n </StatusTab>\n <StatusTab\n disabled={!meta || meta.availableStatus.length === 0}\n value=\"published\"\n >\n {formatMessage({\n id: getTranslation('containers.edit.tabs.published'),\n defaultMessage: 'published',\n })}\n </StatusTab>\n </>\n ) : null}\n </Tabs.List>\n <Grid.Root paddingTop={8} gap={4}>\n <Grid.Item col={9} s={12} direction=\"column\" alignItems=\"stretch\">\n <Tabs.Content value=\"draft\">\n <FormLayout layout={layout} document={doc} />\n </Tabs.Content>\n <Tabs.Content value=\"published\">\n <FormLayout layout={layout} document={doc} />\n </Tabs.Content>\n </Grid.Item>\n <Grid.Item col={3} s={12} direction=\"column\" alignItems=\"stretch\">\n <Panels />\n </Grid.Item>\n </Grid.Root>\n </Tabs.Root>\n <BlockerWrapper />\n </>\n </Form>\n </Main>\n );\n};\n\nconst StatusTab = styled(Tabs.Trigger)`\n text-transform: uppercase;\n`;\n\n/**\n * @internal\n * @description Returns the status of the document where its latest state takes priority,\n * this typically will be \"published\" unless a user has edited their draft in which we should\n * display \"modified\".\n */\nconst getDocumentStatus = (\n document: ReturnType<UseDocument>['document'],\n meta: ReturnType<UseDocument>['meta']\n): 'draft' | 'published' | 'modified' => {\n const docStatus = document?.status;\n const statuses = meta?.availableStatus ?? [];\n\n /**\n * Creating an entry\n */\n if (!docStatus) {\n return 'draft';\n }\n\n /**\n * We're viewing a draft, but the document could have a published version\n */\n if (docStatus === 'draft' && statuses.find((doc) => doc.publishedAt !== null)) {\n return 'published';\n }\n\n return docStatus;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * ProtectedEditViewPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst ProtectedEditViewPage = () => {\n const { slug = '' } = useParams<{\n slug: string;\n }>();\n const {\n permissions = [],\n isLoading,\n error,\n } = useRBAC(\n PERMISSIONS.map((action) => ({\n action,\n subject: slug,\n }))\n );\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (error || !slug) {\n return <Page.Error />;\n }\n\n return (\n <Page.Protect permissions={permissions}>\n {({ permissions }) => (\n <DocumentRBAC permissions={permissions}>\n <EditViewPage />\n </DocumentRBAC>\n )}\n </Page.Protect>\n );\n};\n\nexport { EditViewPage, ProtectedEditViewPage, getDocumentStatus };\n"],"names":["BlockerWrapper","resetForm","useForm","state","_jsx","Blocker","onProceed","EditViewPage","location","useLocation","query","status","setQuery","useQueryParams","formatMessage","useIntl","toggleNotification","useNotification","doc","useDoc","document","meta","isLoading","isLoadingDocument","schema","components","collectionType","id","model","hasError","getTitle","getInitialFormValues","hasDraftAndPublished","options","draftAndPublish","useOnce","type","message","error","timeout","isLoadingActionsRBAC","useDocumentRBAC","isSingleType","SINGLE_TYPES","isCreatingDocument","isLoadingLayout","edit","layout","settings","mainField","useDocumentLayout","pageTitle","isLazyLoading","useLazyComponents","initialValues","documentId","Page","Loading","Error","handleTabChange","validateSync","values","yupSchema","createYupSchema","attributes","abortEarly","_jsxs","Main","paddingLeft","paddingRight","Title","Form","disabled","method","validate","initialErrors","forceValidation","_Fragment","Header","isCreating","getDocumentStatus","undefined","title","Tabs","Root","variant","value","onValueChange","List","aria-label","getTranslation","defaultMessage","StatusTab","availableStatus","length","Grid","paddingTop","gap","Item","col","s","direction","alignItems","Content","FormLayout","Panels","styled","Trigger","docStatus","statuses","find","publishedAt","ProtectedEditViewPage","slug","useParams","permissions","useRBAC","PERMISSIONS","map","action","subject","Protect","DocumentRBAC"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA8BA;;AAEkG;AAGlG;AACA,MAAMA,cAAiB,GAAA,IAAA;AACrB,IAAA,MAAMC,YAAYC,mBAAQ,CAAA,gBAAA,EAAkB,CAACC,KAAAA,GAAUA,MAAMF,SAAS,CAAA;;AAGtE,IAAA,qBAAOG,cAACC,CAAAA,mBAAAA,EAAAA;QAAQC,SAAWL,EAAAA;;AAC7B,CAAA;AAEA,MAAMM,YAAe,GAAA,IAAA;AACnB,IAAA,MAAMC,QAA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7G,cAAA,CAACoD,iBAAKE,KAAK,EAAA,EAAA,CAAA;AACpB;IAEA,qBACEtD,cAAA,CAACoD,iBAAKiE,OAAO,EAAA;QAACN,WAAaA,EAAAA,WAAAA;AACxB,QAAA,QAAA,EAAA,CAAC,EAAEA,WAAW,EAAE,iBACf/G,cAACsH,CAAAA,yBAAAA,EAAAA;gBAAaP,WAAaA,EAAAA,WAAAA;AACzB,gBAAA,QAAA,gBAAA/G,cAACG,CAAAA,YAAAA,EAAAA,EAAAA;;;AAKX;;;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import 'react';
3
- import { useQueryParams, useNotification, Page, Form, Blocker, useRBAC } from '@strapi/admin/strapi-admin';
3
+ import { useQueryParams, useNotification, Page, Form, useRBAC, useForm, Blocker } from '@strapi/admin/strapi-admin';
4
4
  import { Tabs, Main, Grid } from '@strapi/design-system';
5
5
  import { useIntl } from 'react-intl';
6
6
  import { useLocation, useParams } from 'react-router-dom';
@@ -20,7 +20,16 @@ import { Panels } from './components/Panels.mjs';
20
20
 
21
21
  /* -------------------------------------------------------------------------------------------------
22
22
  * EditViewPage
23
- * -----------------------------------------------------------------------------------------------*/ const EditViewPage = ()=>{
23
+ * -----------------------------------------------------------------------------------------------*/ // Needs to be wrapped in a component to have access to the form context via a hook.
24
+ // Using the Form component's render prop instead would cause unnecessary re-renders of Form children
25
+ const BlockerWrapper = ()=>{
26
+ const resetForm = useForm('BlockerWrapper', (state)=>state.resetForm);
27
+ // We reset the form to the published version to avoid errors like – https://strapi-inc.atlassian.net/browse/CONTENT-2284
28
+ return /*#__PURE__*/ jsx(Blocker, {
29
+ onProceed: resetForm
30
+ });
31
+ };
32
+ const EditViewPage = ()=>{
24
33
  const location = useLocation();
25
34
  const [{ query: { status } }, setQuery] = useQueryParams({
26
35
  status: 'draft'
@@ -51,6 +60,7 @@ import { Panels } from './components/Panels.mjs';
51
60
  * document with varying params.
52
61
  */ const isCreatingDocument = !id && !isSingleType;
53
62
  const { isLoading: isLoadingLayout, edit: { layout, settings: { mainField } } } = useDocumentLayout(model);
63
+ const pageTitle = getTitle(mainField);
54
64
  const { isLazyLoading } = useLazyComponents([]);
55
65
  const isLoading = isLoadingActionsRBAC || isLoadingDocument || isLoadingLayout || isLazyLoading;
56
66
  const initialValues = getInitialFormValues(isCreatingDocument);
@@ -81,7 +91,7 @@ import { Panels } from './components/Panels.mjs';
81
91
  paddingRight: 10,
82
92
  children: [
83
93
  /*#__PURE__*/ jsx(Page.Title, {
84
- children: getTitle(mainField)
94
+ children: pageTitle
85
95
  }),
86
96
  /*#__PURE__*/ jsx(Form, {
87
97
  disabled: hasDraftAndPublished && status === 'published',
@@ -97,86 +107,83 @@ import { Panels } from './components/Panels.mjs';
97
107
  });
98
108
  },
99
109
  initialErrors: location?.state?.forceValidation ? validateSync(initialValues, {}) : {},
100
- children: ({ resetForm })=>/*#__PURE__*/ jsxs(Fragment, {
101
- children: [
102
- /*#__PURE__*/ jsx(Header, {
103
- isCreating: isCreatingDocument,
104
- status: hasDraftAndPublished ? getDocumentStatus(document, meta) : undefined,
105
- title: getTitle(mainField)
106
- }),
107
- /*#__PURE__*/ jsxs(Tabs.Root, {
108
- variant: "simple",
109
- value: status,
110
- onValueChange: handleTabChange,
111
- children: [
112
- /*#__PURE__*/ jsx(Tabs.List, {
113
- "aria-label": formatMessage({
114
- id: getTranslation('containers.edit.tabs.label'),
115
- defaultMessage: 'Document status'
116
- }),
117
- children: hasDraftAndPublished ? /*#__PURE__*/ jsxs(Fragment, {
110
+ children: /*#__PURE__*/ jsxs(Fragment, {
111
+ children: [
112
+ /*#__PURE__*/ jsx(Header, {
113
+ isCreating: isCreatingDocument,
114
+ status: hasDraftAndPublished ? getDocumentStatus(document, meta) : undefined,
115
+ title: pageTitle
116
+ }),
117
+ /*#__PURE__*/ jsxs(Tabs.Root, {
118
+ variant: "simple",
119
+ value: status,
120
+ onValueChange: handleTabChange,
121
+ children: [
122
+ /*#__PURE__*/ jsx(Tabs.List, {
123
+ "aria-label": formatMessage({
124
+ id: getTranslation('containers.edit.tabs.label'),
125
+ defaultMessage: 'Document status'
126
+ }),
127
+ children: hasDraftAndPublished ? /*#__PURE__*/ jsxs(Fragment, {
128
+ children: [
129
+ /*#__PURE__*/ jsx(StatusTab, {
130
+ value: "draft",
131
+ children: formatMessage({
132
+ id: getTranslation('containers.edit.tabs.draft'),
133
+ defaultMessage: 'draft'
134
+ })
135
+ }),
136
+ /*#__PURE__*/ jsx(StatusTab, {
137
+ disabled: !meta || meta.availableStatus.length === 0,
138
+ value: "published",
139
+ children: formatMessage({
140
+ id: getTranslation('containers.edit.tabs.published'),
141
+ defaultMessage: 'published'
142
+ })
143
+ })
144
+ ]
145
+ }) : null
146
+ }),
147
+ /*#__PURE__*/ jsxs(Grid.Root, {
148
+ paddingTop: 8,
149
+ gap: 4,
150
+ children: [
151
+ /*#__PURE__*/ jsxs(Grid.Item, {
152
+ col: 9,
153
+ s: 12,
154
+ direction: "column",
155
+ alignItems: "stretch",
118
156
  children: [
119
- /*#__PURE__*/ jsx(StatusTab, {
157
+ /*#__PURE__*/ jsx(Tabs.Content, {
120
158
  value: "draft",
121
- children: formatMessage({
122
- id: getTranslation('containers.edit.tabs.draft'),
123
- defaultMessage: 'draft'
159
+ children: /*#__PURE__*/ jsx(FormLayout, {
160
+ layout: layout,
161
+ document: doc
124
162
  })
125
163
  }),
126
- /*#__PURE__*/ jsx(StatusTab, {
127
- disabled: !meta || meta.availableStatus.length === 0,
164
+ /*#__PURE__*/ jsx(Tabs.Content, {
128
165
  value: "published",
129
- children: formatMessage({
130
- id: getTranslation('containers.edit.tabs.published'),
131
- defaultMessage: 'published'
166
+ children: /*#__PURE__*/ jsx(FormLayout, {
167
+ layout: layout,
168
+ document: doc
132
169
  })
133
170
  })
134
171
  ]
135
- }) : null
136
- }),
137
- /*#__PURE__*/ jsxs(Grid.Root, {
138
- paddingTop: 8,
139
- gap: 4,
140
- children: [
141
- /*#__PURE__*/ jsxs(Grid.Item, {
142
- col: 9,
143
- s: 12,
144
- direction: "column",
145
- alignItems: "stretch",
146
- children: [
147
- /*#__PURE__*/ jsx(Tabs.Content, {
148
- value: "draft",
149
- children: /*#__PURE__*/ jsx(FormLayout, {
150
- layout: layout,
151
- document: doc
152
- })
153
- }),
154
- /*#__PURE__*/ jsx(Tabs.Content, {
155
- value: "published",
156
- children: /*#__PURE__*/ jsx(FormLayout, {
157
- layout: layout,
158
- document: doc
159
- })
160
- })
161
- ]
162
- }),
163
- /*#__PURE__*/ jsx(Grid.Item, {
164
- col: 3,
165
- s: 12,
166
- direction: "column",
167
- alignItems: "stretch",
168
- children: /*#__PURE__*/ jsx(Panels, {})
169
- })
170
- ]
171
- })
172
- ]
173
- }),
174
- /*#__PURE__*/ jsx(Blocker, {
175
- // We reset the form to the published version to avoid errors like – https://strapi-inc.atlassian.net/browse/CONTENT-2284
176
- onProceed: resetForm
177
- })
178
- ]
179
- })
172
+ }),
173
+ /*#__PURE__*/ jsx(Grid.Item, {
174
+ col: 3,
175
+ s: 12,
176
+ direction: "column",
177
+ alignItems: "stretch",
178
+ children: /*#__PURE__*/ jsx(Panels, {})
179
+ })
180
+ ]
181
+ })
182
+ ]
183
+ }),
184
+ /*#__PURE__*/ jsx(BlockerWrapper, {})
185
+ ]
186
+ })
180
187
  })
181
188
  ]
182
189
  });
@@ -1 +1 @@
1
- {"version":3,"file":"EditViewPage.mjs","sources":["../../../../admin/src/pages/EditView/EditViewPage.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n Page,\n Blocker,\n Form,\n useRBAC,\n useNotification,\n useQueryParams,\n} from '@strapi/admin/strapi-admin';\nimport { Grid, Main, Tabs } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { useLocation, useParams } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { SINGLE_TYPES } from '../../constants/collections';\nimport { PERMISSIONS } from '../../constants/plugin';\nimport { DocumentRBAC, useDocumentRBAC } from '../../features/DocumentRBAC';\nimport { useDoc, type UseDocument } from '../../hooks/useDocument';\nimport { useDocumentLayout } from '../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../hooks/useLazyComponents';\nimport { useOnce } from '../../hooks/useOnce';\nimport { getTranslation } from '../../utils/translations';\nimport { createYupSchema } from '../../utils/validation';\n\nimport { FormLayout } from './components/FormLayout';\nimport { Header } from './components/Header';\nimport { Panels } from './components/Panels';\n\n/* -------------------------------------------------------------------------------------------------\n * EditViewPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst EditViewPage = () => {\n const location = useLocation();\n const [\n {\n query: { status },\n },\n setQuery,\n ] = useQueryParams<{ status: 'draft' | 'published' }>({\n status: 'draft',\n });\n const { formatMessage } = useIntl();\n const { toggleNotification } = useNotification();\n\n const doc = useDoc();\n const {\n document,\n meta,\n isLoading: isLoadingDocument,\n schema,\n components,\n collectionType,\n id,\n model,\n hasError,\n getTitle,\n getInitialFormValues,\n } = doc;\n\n const hasDraftAndPublished = schema?.options?.draftAndPublish ?? false;\n\n useOnce(() => {\n /**\n * We only ever want to fire the notification once otherwise\n * whenever the app re-renders it'll pop up regardless of\n * what we do because the state comes from react-router-dom\n */\n if (location?.state && 'error' in location.state) {\n toggleNotification({\n type: 'danger',\n message: location.state.error,\n timeout: 5000,\n });\n }\n });\n\n const isLoadingActionsRBAC = useDocumentRBAC('EditViewPage', (state) => state.isLoading);\n\n const isSingleType = collectionType === SINGLE_TYPES;\n\n /**\n * single-types don't current have an id, but because they're a singleton\n * we can simply use the update operation to continuously update the same\n * document with varying params.\n */\n const isCreatingDocument = !id && !isSingleType;\n\n const {\n isLoading: isLoadingLayout,\n edit: {\n layout,\n settings: { mainField },\n },\n } = useDocumentLayout(model);\n\n const { isLazyLoading } = useLazyComponents([]);\n\n const isLoading = isLoadingActionsRBAC || isLoadingDocument || isLoadingLayout || isLazyLoading;\n\n const initialValues = getInitialFormValues(isCreatingDocument);\n\n if (isLoading && !document?.documentId) {\n return <Page.Loading />;\n }\n\n if (!initialValues || hasError) {\n return <Page.Error />;\n }\n\n const handleTabChange = (status: string) => {\n if (status === 'published' || status === 'draft') {\n setQuery({ status }, 'push', true);\n }\n };\n\n const validateSync = (values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(schema?.attributes, components, {\n status,\n ...options,\n });\n\n return yupSchema.validateSync(values, { abortEarly: false });\n };\n\n return (\n <Main paddingLeft={10} paddingRight={10}>\n <Page.Title>{getTitle(mainField)}</Page.Title>\n <Form\n disabled={hasDraftAndPublished && status === 'published'}\n initialValues={initialValues}\n method={isCreatingDocument ? 'POST' : 'PUT'}\n validate={(values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(schema?.attributes, components, {\n status,\n ...options,\n });\n\n return yupSchema.validate(values, { abortEarly: false });\n }}\n initialErrors={location?.state?.forceValidation ? validateSync(initialValues, {}) : {}}\n >\n {({ resetForm }) => (\n <>\n <Header\n isCreating={isCreatingDocument}\n status={hasDraftAndPublished ? getDocumentStatus(document, meta) : undefined}\n title={getTitle(mainField)}\n />\n <Tabs.Root variant=\"simple\" value={status} onValueChange={handleTabChange}>\n <Tabs.List\n aria-label={formatMessage({\n id: getTranslation('containers.edit.tabs.label'),\n defaultMessage: 'Document status',\n })}\n >\n {hasDraftAndPublished ? (\n <>\n <StatusTab value=\"draft\">\n {formatMessage({\n id: getTranslation('containers.edit.tabs.draft'),\n defaultMessage: 'draft',\n })}\n </StatusTab>\n <StatusTab\n disabled={!meta || meta.availableStatus.length === 0}\n value=\"published\"\n >\n {formatMessage({\n id: getTranslation('containers.edit.tabs.published'),\n defaultMessage: 'published',\n })}\n </StatusTab>\n </>\n ) : null}\n </Tabs.List>\n <Grid.Root paddingTop={8} gap={4}>\n <Grid.Item col={9} s={12} direction=\"column\" alignItems=\"stretch\">\n <Tabs.Content value=\"draft\">\n <FormLayout layout={layout} document={doc} />\n </Tabs.Content>\n <Tabs.Content value=\"published\">\n <FormLayout layout={layout} document={doc} />\n </Tabs.Content>\n </Grid.Item>\n <Grid.Item col={3} s={12} direction=\"column\" alignItems=\"stretch\">\n <Panels />\n </Grid.Item>\n </Grid.Root>\n </Tabs.Root>\n <Blocker\n // We reset the form to the published version to avoid errors like – https://strapi-inc.atlassian.net/browse/CONTENT-2284\n onProceed={resetForm}\n />\n </>\n )}\n </Form>\n </Main>\n );\n};\n\nconst StatusTab = styled(Tabs.Trigger)`\n text-transform: uppercase;\n`;\n\n/**\n * @internal\n * @description Returns the status of the document where its latest state takes priority,\n * this typically will be \"published\" unless a user has edited their draft in which we should\n * display \"modified\".\n */\nconst getDocumentStatus = (\n document: ReturnType<UseDocument>['document'],\n meta: ReturnType<UseDocument>['meta']\n): 'draft' | 'published' | 'modified' => {\n const docStatus = document?.status;\n const statuses = meta?.availableStatus ?? [];\n\n /**\n * Creating an entry\n */\n if (!docStatus) {\n return 'draft';\n }\n\n /**\n * We're viewing a draft, but the document could have a published version\n */\n if (docStatus === 'draft' && statuses.find((doc) => doc.publishedAt !== null)) {\n return 'published';\n }\n\n return docStatus;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * ProtectedEditViewPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst ProtectedEditViewPage = () => {\n const { slug = '' } = useParams<{\n slug: string;\n }>();\n const {\n permissions = [],\n isLoading,\n error,\n } = useRBAC(\n PERMISSIONS.map((action) => ({\n action,\n subject: slug,\n }))\n );\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (error || !slug) {\n return <Page.Error />;\n }\n\n return (\n <Page.Protect permissions={permissions}>\n {({ permissions }) => (\n <DocumentRBAC permissions={permissions}>\n <EditViewPage />\n </DocumentRBAC>\n )}\n </Page.Protect>\n );\n};\n\nexport { EditViewPage, ProtectedEditViewPage, getDocumentStatus };\n"],"names":["EditViewPage","location","useLocation","query","status","setQuery","useQueryParams","formatMessage","useIntl","toggleNotification","useNotification","doc","useDoc","document","meta","isLoading","isLoadingDocument","schema","components","collectionType","id","model","hasError","getTitle","getInitialFormValues","hasDraftAndPublished","options","draftAndPublish","useOnce","state","type","message","error","timeout","isLoadingActionsRBAC","useDocumentRBAC","isSingleType","SINGLE_TYPES","isCreatingDocument","isLoadingLayout","edit","layout","settings","mainField","useDocumentLayout","isLazyLoading","useLazyComponents","initialValues","documentId","_jsx","Page","Loading","Error","handleTabChange","validateSync","values","yupSchema","createYupSchema","attributes","abortEarly","_jsxs","Main","paddingLeft","paddingRight","Title","Form","disabled","method","validate","initialErrors","forceValidation","resetForm","_Fragment","Header","isCreating","getDocumentStatus","undefined","title","Tabs","Root","variant","value","onValueChange","List","aria-label","getTranslation","defaultMessage","StatusTab","availableStatus","length","Grid","paddingTop","gap","Item","col","s","direction","alignItems","Content","FormLayout","Panels","Blocker","onProceed","styled","Trigger","docStatus","statuses","find","publishedAt","ProtectedEditViewPage","slug","useParams","permissions","useRBAC","PERMISSIONS","map","action","subject","Protect","DocumentRBAC"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6BA;;AAEkG,2GAE5FA,YAAe,GAAA,IAAA;AACnB,IAAA,MAAMC,QAAWC,GAAAA,WAAAA,EAAAA;IACjB,MAAM,CACJ,EACEC,KAAAA,EAAO,EAAEC,MAAM,EAAE,EAClB,EACDC,QACD,CAAA,GAAGC,cAAkD,CAAA;QACpDF,MAAQ,EAAA;AACV,KAAA,CAAA;IACA,MAAM,EAAEG,aAAa,EAAE,GAAGC,OAAAA,EAAAA;IAC1B,MAAM,EAAEC,kBAAkB,EAAE,GAAGC,eAAAA,EAAAA;AAE/B,IAAA,MAAMC,GAAMC,GAAAA,MAAAA,EAAAA;IACZ,MAAM,EACJC,QAAQ,EACRC,IAAI,EACJC,WAAWC,iBAAiB,EAC5BC,MAAM,EACNC,UAAU,EACVC,cAAc,EACdC,EAAE,EACFC,KAAK,EACLC,QAAQ,EACRC,QAAQ,EACRC,oBAAoB,EACrB,GAAGb,GAAAA;IAEJ,MAAMc,oBAAAA,GAAuBR,MAAQS,EAAAA,OAAAA,EA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AAA;AACT;AAEA;;MAGA,IAAIA,SAAc,KAAA,OAAA,IAAWC,QAASC,CAAAA,IAAI,CAAC,CAAChG,GAAQA,GAAAA,GAAAA,CAAIiG,WAAW,KAAK,IAAO,CAAA,EAAA;QAC7E,OAAO,WAAA;AACT;IAEA,OAAOH,SAAAA;AACT;AAEA;;AAEkG,2GAE5FI,qBAAwB,GAAA,IAAA;AAC5B,IAAA,MAAM,EAAEC,IAAAA,GAAO,EAAE,EAAE,GAAGC,SAAAA,EAAAA;AAGtB,IAAA,MAAM,EACJC,WAAAA,GAAc,EAAE,EAChBjG,SAAS,EACTiB,KAAK,EACN,GAAGiF,QACFC,WAAYC,CAAAA,GAAG,CAAC,CAACC,UAAY;AAC3BA,YAAAA,MAAAA;YACAC,OAASP,EAAAA;SACX,CAAA,CAAA,CAAA;AAGF,IAAA,IAAI/F,SAAW,EAAA;QACb,qBAAOkC,GAAA,CAACC,KAAKC,OAAO,EAAA,EAAA,CAAA;AACtB;IAEA,IAAInB,KAAAA,IAAS,CAAC8E,IAAM,EAAA;QAClB,qBAAO7D,GAAA,CAACC,KAAKE,KAAK,EAAA,EAAA,CAAA;AACpB;IAEA,qBACEH,GAAA,CAACC,KAAKoE,OAAO,EAAA;QAACN,WAAaA,EAAAA,WAAAA;AACxB,QAAA,QAAA,EAAA,CAAC,EAAEA,WAAW,EAAE,iBACf/D,GAACsE,CAAAA,YAAAA,EAAAA;gBAAaP,WAAaA,EAAAA,WAAAA;AACzB,gBAAA,QAAA,gBAAA/D,GAACjD,CAAAA,YAAAA,EAAAA,EAAAA;;;AAKX;;;;"}
1
+ {"version":3,"file":"EditViewPage.mjs","sources":["../../../../admin/src/pages/EditView/EditViewPage.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n Page,\n Blocker,\n Form,\n useForm,\n useRBAC,\n useNotification,\n useQueryParams,\n} from '@strapi/admin/strapi-admin';\nimport { Grid, Main, Tabs } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { useLocation, useParams } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { SINGLE_TYPES } from '../../constants/collections';\nimport { PERMISSIONS } from '../../constants/plugin';\nimport { DocumentRBAC, useDocumentRBAC } from '../../features/DocumentRBAC';\nimport { useDoc, type UseDocument } from '../../hooks/useDocument';\nimport { useDocumentLayout } from '../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../hooks/useLazyComponents';\nimport { useOnce } from '../../hooks/useOnce';\nimport { getTranslation } from '../../utils/translations';\nimport { createYupSchema } from '../../utils/validation';\n\nimport { FormLayout } from './components/FormLayout';\nimport { Header } from './components/Header';\nimport { Panels } from './components/Panels';\n\n/* -------------------------------------------------------------------------------------------------\n * EditViewPage\n * -----------------------------------------------------------------------------------------------*/\n\n// Needs to be wrapped in a component to have access to the form context via a hook.\n// Using the Form component's render prop instead would cause unnecessary re-renders of Form children\nconst BlockerWrapper = () => {\n const resetForm = useForm('BlockerWrapper', (state) => state.resetForm);\n\n // We reset the form to the published version to avoid errors like – https://strapi-inc.atlassian.net/browse/CONTENT-2284\n return <Blocker onProceed={resetForm} />;\n};\n\nconst EditViewPage = () => {\n const location = useLocation();\n const [\n {\n query: { status },\n },\n setQuery,\n ] = useQueryParams<{ status: 'draft' | 'published' }>({\n status: 'draft',\n });\n const { formatMessage } = useIntl();\n const { toggleNotification } = useNotification();\n\n const doc = useDoc();\n const {\n document,\n meta,\n isLoading: isLoadingDocument,\n schema,\n components,\n collectionType,\n id,\n model,\n hasError,\n getTitle,\n getInitialFormValues,\n } = doc;\n\n const hasDraftAndPublished = schema?.options?.draftAndPublish ?? false;\n\n useOnce(() => {\n /**\n * We only ever want to fire the notification once otherwise\n * whenever the app re-renders it'll pop up regardless of\n * what we do because the state comes from react-router-dom\n */\n if (location?.state && 'error' in location.state) {\n toggleNotification({\n type: 'danger',\n message: location.state.error,\n timeout: 5000,\n });\n }\n });\n\n const isLoadingActionsRBAC = useDocumentRBAC('EditViewPage', (state) => state.isLoading);\n\n const isSingleType = collectionType === SINGLE_TYPES;\n\n /**\n * single-types don't current have an id, but because they're a singleton\n * we can simply use the update operation to continuously update the same\n * document with varying params.\n */\n const isCreatingDocument = !id && !isSingleType;\n\n const {\n isLoading: isLoadingLayout,\n edit: {\n layout,\n settings: { mainField },\n },\n } = useDocumentLayout(model);\n const pageTitle = getTitle(mainField);\n\n const { isLazyLoading } = useLazyComponents([]);\n\n const isLoading = isLoadingActionsRBAC || isLoadingDocument || isLoadingLayout || isLazyLoading;\n\n const initialValues = getInitialFormValues(isCreatingDocument);\n\n if (isLoading && !document?.documentId) {\n return <Page.Loading />;\n }\n\n if (!initialValues || hasError) {\n return <Page.Error />;\n }\n\n const handleTabChange = (status: string) => {\n if (status === 'published' || status === 'draft') {\n setQuery({ status }, 'push', true);\n }\n };\n\n const validateSync = (values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(schema?.attributes, components, {\n status,\n ...options,\n });\n\n return yupSchema.validateSync(values, { abortEarly: false });\n };\n\n return (\n <Main paddingLeft={10} paddingRight={10}>\n <Page.Title>{pageTitle}</Page.Title>\n <Form\n disabled={hasDraftAndPublished && status === 'published'}\n initialValues={initialValues}\n method={isCreatingDocument ? 'POST' : 'PUT'}\n validate={(values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(schema?.attributes, components, {\n status,\n ...options,\n });\n\n return yupSchema.validate(values, { abortEarly: false });\n }}\n initialErrors={location?.state?.forceValidation ? validateSync(initialValues, {}) : {}}\n >\n <>\n <Header\n isCreating={isCreatingDocument}\n status={hasDraftAndPublished ? getDocumentStatus(document, meta) : undefined}\n title={pageTitle}\n />\n <Tabs.Root variant=\"simple\" value={status} onValueChange={handleTabChange}>\n <Tabs.List\n aria-label={formatMessage({\n id: getTranslation('containers.edit.tabs.label'),\n defaultMessage: 'Document status',\n })}\n >\n {hasDraftAndPublished ? (\n <>\n <StatusTab value=\"draft\">\n {formatMessage({\n id: getTranslation('containers.edit.tabs.draft'),\n defaultMessage: 'draft',\n })}\n </StatusTab>\n <StatusTab\n disabled={!meta || meta.availableStatus.length === 0}\n value=\"published\"\n >\n {formatMessage({\n id: getTranslation('containers.edit.tabs.published'),\n defaultMessage: 'published',\n })}\n </StatusTab>\n </>\n ) : null}\n </Tabs.List>\n <Grid.Root paddingTop={8} gap={4}>\n <Grid.Item col={9} s={12} direction=\"column\" alignItems=\"stretch\">\n <Tabs.Content value=\"draft\">\n <FormLayout layout={layout} document={doc} />\n </Tabs.Content>\n <Tabs.Content value=\"published\">\n <FormLayout layout={layout} document={doc} />\n </Tabs.Content>\n </Grid.Item>\n <Grid.Item col={3} s={12} direction=\"column\" alignItems=\"stretch\">\n <Panels />\n </Grid.Item>\n </Grid.Root>\n </Tabs.Root>\n <BlockerWrapper />\n </>\n </Form>\n </Main>\n );\n};\n\nconst StatusTab = styled(Tabs.Trigger)`\n text-transform: uppercase;\n`;\n\n/**\n * @internal\n * @description Returns the status of the document where its latest state takes priority,\n * this typically will be \"published\" unless a user has edited their draft in which we should\n * display \"modified\".\n */\nconst getDocumentStatus = (\n document: ReturnType<UseDocument>['document'],\n meta: ReturnType<UseDocument>['meta']\n): 'draft' | 'published' | 'modified' => {\n const docStatus = document?.status;\n const statuses = meta?.availableStatus ?? [];\n\n /**\n * Creating an entry\n */\n if (!docStatus) {\n return 'draft';\n }\n\n /**\n * We're viewing a draft, but the document could have a published version\n */\n if (docStatus === 'draft' && statuses.find((doc) => doc.publishedAt !== null)) {\n return 'published';\n }\n\n return docStatus;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * ProtectedEditViewPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst ProtectedEditViewPage = () => {\n const { slug = '' } = useParams<{\n slug: string;\n }>();\n const {\n permissions = [],\n isLoading,\n error,\n } = useRBAC(\n PERMISSIONS.map((action) => ({\n action,\n subject: slug,\n }))\n );\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (error || !slug) {\n return <Page.Error />;\n }\n\n return (\n <Page.Protect permissions={permissions}>\n {({ permissions }) => (\n <DocumentRBAC permissions={permissions}>\n <EditViewPage />\n </DocumentRBAC>\n )}\n </Page.Protect>\n );\n};\n\nexport { EditViewPage, ProtectedEditViewPage, getDocumentStatus };\n"],"names":["BlockerWrapper","resetForm","useForm","state","_jsx","Blocker","onProceed","EditViewPage","location","useLocation","query","status","setQuery","useQueryParams","formatMessage","useIntl","toggleNotification","useNotification","doc","useDoc","document","meta","isLoading","isLoadingDocument","schema","components","collectionType","id","model","hasError","getTitle","getInitialFormValues","hasDraftAndPublished","options","draftAndPublish","useOnce","type","message","error","timeout","isLoadingActionsRBAC","useDocumentRBAC","isSingleType","SINGLE_TYPES","isCreatingDocument","isLoadingLayout","edit","layout","settings","mainField","useDocumentLayout","pageTitle","isLazyLoading","useLazyComponents","initialValues","documentId","Page","Loading","Error","handleTabChange","validateSync","values","yupSchema","createYupSchema","attributes","abortEarly","_jsxs","Main","paddingLeft","paddingRight","Title","Form","disabled","method","validate","initialErrors","forceValidation","_Fragment","Header","isCreating","getDocumentStatus","undefined","title","Tabs","Root","variant","value","onValueChange","List","aria-label","getTranslation","defaultMessage","StatusTab","availableStatus","length","Grid","paddingTop","gap","Item","col","s","direction","alignItems","Content","FormLayout","Panels","styled","Trigger","docStatus","statuses","find","publishedAt","ProtectedEditViewPage","slug","useParams","permissions","useRBAC","PERMISSIONS","map","action","subject","Protect","DocumentRBAC"],"mappings":";;;;;;;;;;;;;;;;;;;;AA8BA;;AAEkG;AAGlG;AACA,MAAMA,cAAiB,GAAA,IAAA;AACrB,IAAA,MAAMC,YAAYC,OAAQ,CAAA,gBAAA,EAAkB,CAACC,KAAAA,GAAUA,MAAMF,SAAS,CAAA;;AAGtE,IAAA,qBAAOG,GAACC,CAAAA,OAAAA,EAAAA;QAAQC,SAAWL,EAAAA;;AAC7B,CAAA;AAEA,MAAMM,YAAe,GAAA,IAAA;AACnB,IAAA,MAAMC,QAAWC,GAAAA,WAAAA,EAAAA;IACjB,MAAM,CACJ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