@strapi/content-manager 5.46.0 → 5.47.0

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 (197) hide show
  1. package/dist/admin/constants/hooks.js +5 -0
  2. package/dist/admin/constants/hooks.js.map +1 -1
  3. package/dist/admin/constants/hooks.mjs +5 -0
  4. package/dist/admin/constants/hooks.mjs.map +1 -1
  5. package/dist/admin/history/components/VersionInputRenderer.js +64 -26
  6. package/dist/admin/history/components/VersionInputRenderer.js.map +1 -1
  7. package/dist/admin/history/components/VersionInputRenderer.mjs +63 -27
  8. package/dist/admin/history/components/VersionInputRenderer.mjs.map +1 -1
  9. package/dist/admin/pages/ComponentConfigurationPage.js +2 -45
  10. package/dist/admin/pages/ComponentConfigurationPage.js.map +1 -1
  11. package/dist/admin/pages/ComponentConfigurationPage.mjs +3 -46
  12. package/dist/admin/pages/ComponentConfigurationPage.mjs.map +1 -1
  13. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +4 -4
  14. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
  15. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +4 -4
  16. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
  17. package/dist/admin/pages/ListConfiguration/ListConfigurationPage.js +11 -3
  18. package/dist/admin/pages/ListConfiguration/ListConfigurationPage.js.map +1 -1
  19. package/dist/admin/pages/ListConfiguration/ListConfigurationPage.mjs +11 -3
  20. package/dist/admin/pages/ListConfiguration/ListConfigurationPage.mjs.map +1 -1
  21. package/dist/admin/pages/ListView/ListViewPage.js +1 -0
  22. package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
  23. package/dist/admin/pages/ListView/ListViewPage.mjs +1 -0
  24. package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
  25. package/dist/admin/pages/ListView/components/Filters.js +38 -4
  26. package/dist/admin/pages/ListView/components/Filters.js.map +1 -1
  27. package/dist/admin/pages/ListView/components/Filters.mjs +39 -5
  28. package/dist/admin/pages/ListView/components/Filters.mjs.map +1 -1
  29. package/dist/admin/pages/formatComponentConfigurationEditLayout.js +58 -0
  30. package/dist/admin/pages/formatComponentConfigurationEditLayout.js.map +1 -0
  31. package/dist/admin/pages/formatComponentConfigurationEditLayout.mjs +56 -0
  32. package/dist/admin/pages/formatComponentConfigurationEditLayout.mjs.map +1 -0
  33. package/dist/admin/src/constants/hooks.d.ts +23 -0
  34. package/dist/admin/src/exports.d.ts +1 -0
  35. package/dist/admin/src/history/components/VersionInputRenderer.d.ts +27 -1
  36. package/dist/admin/src/pages/EditView/components/FormInputs/Relations/Relations.d.ts +9 -5
  37. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +4 -2
  38. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +38 -6
  39. package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +27 -5
  40. package/dist/admin/src/pages/ListView/components/Filters.d.ts +3 -4
  41. package/dist/admin/src/pages/formatComponentConfigurationEditLayout.d.ts +15 -0
  42. package/dist/admin/translations/cs.json.js +0 -1
  43. package/dist/admin/translations/cs.json.js.map +1 -1
  44. package/dist/admin/translations/cs.json.mjs +0 -1
  45. package/dist/admin/translations/cs.json.mjs.map +1 -1
  46. package/dist/admin/translations/de.json.js +0 -1
  47. package/dist/admin/translations/de.json.js.map +1 -1
  48. package/dist/admin/translations/de.json.mjs +0 -1
  49. package/dist/admin/translations/de.json.mjs.map +1 -1
  50. package/dist/admin/translations/en.json.js +0 -1
  51. package/dist/admin/translations/en.json.js.map +1 -1
  52. package/dist/admin/translations/en.json.mjs +0 -1
  53. package/dist/admin/translations/en.json.mjs.map +1 -1
  54. package/dist/admin/translations/es.json.js +0 -1
  55. package/dist/admin/translations/es.json.js.map +1 -1
  56. package/dist/admin/translations/es.json.mjs +0 -1
  57. package/dist/admin/translations/es.json.mjs.map +1 -1
  58. package/dist/admin/translations/fr.json.js +0 -1
  59. package/dist/admin/translations/fr.json.js.map +1 -1
  60. package/dist/admin/translations/fr.json.mjs +0 -1
  61. package/dist/admin/translations/fr.json.mjs.map +1 -1
  62. package/dist/admin/translations/nl.json.js +0 -1
  63. package/dist/admin/translations/nl.json.js.map +1 -1
  64. package/dist/admin/translations/nl.json.mjs +0 -1
  65. package/dist/admin/translations/nl.json.mjs.map +1 -1
  66. package/dist/admin/translations/pl.json.js +0 -1
  67. package/dist/admin/translations/pl.json.js.map +1 -1
  68. package/dist/admin/translations/pl.json.mjs +0 -1
  69. package/dist/admin/translations/pl.json.mjs.map +1 -1
  70. package/dist/admin/translations/ru.json.js +0 -1
  71. package/dist/admin/translations/ru.json.js.map +1 -1
  72. package/dist/admin/translations/ru.json.mjs +0 -1
  73. package/dist/admin/translations/ru.json.mjs.map +1 -1
  74. package/dist/admin/translations/sk.json.js +175 -9
  75. package/dist/admin/translations/sk.json.js.map +1 -1
  76. package/dist/admin/translations/sk.json.mjs +175 -9
  77. package/dist/admin/translations/sk.json.mjs.map +1 -1
  78. package/dist/admin/translations/uk.json.js +0 -1
  79. package/dist/admin/translations/uk.json.js.map +1 -1
  80. package/dist/admin/translations/uk.json.mjs +0 -1
  81. package/dist/admin/translations/uk.json.mjs.map +1 -1
  82. package/dist/admin/translations/zh-Hans.json.js +0 -1
  83. package/dist/admin/translations/zh-Hans.json.js.map +1 -1
  84. package/dist/admin/translations/zh-Hans.json.mjs +0 -1
  85. package/dist/admin/translations/zh-Hans.json.mjs.map +1 -1
  86. package/dist/server/bootstrap.js +4 -0
  87. package/dist/server/bootstrap.js.map +1 -1
  88. package/dist/server/bootstrap.mjs +4 -0
  89. package/dist/server/bootstrap.mjs.map +1 -1
  90. package/dist/server/controllers/collection-types.js +9 -5
  91. package/dist/server/controllers/collection-types.js.map +1 -1
  92. package/dist/server/controllers/collection-types.mjs +10 -6
  93. package/dist/server/controllers/collection-types.mjs.map +1 -1
  94. package/dist/server/mcp/derive-content-type-mcp-tools.js +524 -0
  95. package/dist/server/mcp/derive-content-type-mcp-tools.js.map +1 -0
  96. package/dist/server/mcp/derive-content-type-mcp-tools.mjs +518 -0
  97. package/dist/server/mcp/derive-content-type-mcp-tools.mjs.map +1 -0
  98. package/dist/server/mcp/handlers/collection-handlers.js +404 -0
  99. package/dist/server/mcp/handlers/collection-handlers.js.map +1 -0
  100. package/dist/server/mcp/handlers/collection-handlers.mjs +395 -0
  101. package/dist/server/mcp/handlers/collection-handlers.mjs.map +1 -0
  102. package/dist/server/mcp/handlers/constants.js +10 -0
  103. package/dist/server/mcp/handlers/constants.js.map +1 -0
  104. package/dist/server/mcp/handlers/constants.mjs +6 -0
  105. package/dist/server/mcp/handlers/constants.mjs.map +1 -0
  106. package/dist/server/mcp/handlers/single-type-handlers.js +344 -0
  107. package/dist/server/mcp/handlers/single-type-handlers.js.map +1 -0
  108. package/dist/server/mcp/handlers/single-type-handlers.mjs +336 -0
  109. package/dist/server/mcp/handlers/single-type-handlers.mjs.map +1 -0
  110. package/dist/server/mcp/permissions.js +138 -0
  111. package/dist/server/mcp/permissions.js.map +1 -0
  112. package/dist/server/mcp/permissions.mjs +131 -0
  113. package/dist/server/mcp/permissions.mjs.map +1 -0
  114. package/dist/server/mcp/register-content-manager-mcp-tools.js +30 -0
  115. package/dist/server/mcp/register-content-manager-mcp-tools.js.map +1 -0
  116. package/dist/server/mcp/register-content-manager-mcp-tools.mjs +28 -0
  117. package/dist/server/mcp/register-content-manager-mcp-tools.mjs.map +1 -0
  118. package/dist/server/mcp/schemas/blocks-schema.js +124 -0
  119. package/dist/server/mcp/schemas/blocks-schema.js.map +1 -0
  120. package/dist/server/mcp/schemas/blocks-schema.mjs +122 -0
  121. package/dist/server/mcp/schemas/blocks-schema.mjs.map +1 -0
  122. package/dist/server/mcp/schemas/data-schema.js +252 -0
  123. package/dist/server/mcp/schemas/data-schema.js.map +1 -0
  124. package/dist/server/mcp/schemas/data-schema.mjs +248 -0
  125. package/dist/server/mcp/schemas/data-schema.mjs.map +1 -0
  126. package/dist/server/mcp/schemas/filters-schema.js +111 -0
  127. package/dist/server/mcp/schemas/filters-schema.js.map +1 -0
  128. package/dist/server/mcp/schemas/filters-schema.mjs +107 -0
  129. package/dist/server/mcp/schemas/filters-schema.mjs.map +1 -0
  130. package/dist/server/mcp/schemas/input-schemas.js +18 -0
  131. package/dist/server/mcp/schemas/input-schemas.js.map +1 -0
  132. package/dist/server/mcp/schemas/input-schemas.mjs +13 -0
  133. package/dist/server/mcp/schemas/input-schemas.mjs.map +1 -0
  134. package/dist/server/mcp/schemas/output-schemas.js +48 -0
  135. package/dist/server/mcp/schemas/output-schemas.js.map +1 -0
  136. package/dist/server/mcp/schemas/output-schemas.mjs +44 -0
  137. package/dist/server/mcp/schemas/output-schemas.mjs.map +1 -0
  138. package/dist/server/mcp/schemas/sort-schema.js +80 -0
  139. package/dist/server/mcp/schemas/sort-schema.js.map +1 -0
  140. package/dist/server/mcp/schemas/sort-schema.mjs +76 -0
  141. package/dist/server/mcp/schemas/sort-schema.mjs.map +1 -0
  142. package/dist/server/mcp/utils.js +43 -0
  143. package/dist/server/mcp/utils.js.map +1 -0
  144. package/dist/server/mcp/utils.mjs +39 -0
  145. package/dist/server/mcp/utils.mjs.map +1 -0
  146. package/dist/server/services/index.js +1 -1
  147. package/dist/server/services/index.js.map +1 -1
  148. package/dist/server/services/permission-checker.js +4 -1
  149. package/dist/server/services/permission-checker.js.map +1 -1
  150. package/dist/server/services/permission-checker.mjs +1 -1
  151. package/dist/server/services/permission-checker.mjs.map +1 -1
  152. package/dist/server/services/utils/populate.js +3 -3
  153. package/dist/server/services/utils/populate.js.map +1 -1
  154. package/dist/server/services/utils/populate.mjs +3 -3
  155. package/dist/server/services/utils/populate.mjs.map +1 -1
  156. package/dist/server/src/bootstrap.d.ts.map +1 -1
  157. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  158. package/dist/server/src/index.d.ts +3 -3
  159. package/dist/server/src/mcp/derive-content-type-mcp-tools.d.ts +12 -0
  160. package/dist/server/src/mcp/derive-content-type-mcp-tools.d.ts.map +1 -0
  161. package/dist/server/src/mcp/handlers/collection-handlers.d.ts +69 -0
  162. package/dist/server/src/mcp/handlers/collection-handlers.d.ts.map +1 -0
  163. package/dist/server/src/mcp/handlers/constants.d.ts +4 -0
  164. package/dist/server/src/mcp/handlers/constants.d.ts.map +1 -0
  165. package/dist/server/src/mcp/handlers/index.d.ts +3 -0
  166. package/dist/server/src/mcp/handlers/index.d.ts.map +1 -0
  167. package/dist/server/src/mcp/handlers/single-type-handlers.d.ts +66 -0
  168. package/dist/server/src/mcp/handlers/single-type-handlers.d.ts.map +1 -0
  169. package/dist/server/src/mcp/permissions.d.ts +49 -0
  170. package/dist/server/src/mcp/permissions.d.ts.map +1 -0
  171. package/dist/server/src/mcp/register-content-manager-mcp-tools.d.ts +8 -0
  172. package/dist/server/src/mcp/register-content-manager-mcp-tools.d.ts.map +1 -0
  173. package/dist/server/src/mcp/schemas/blocks-schema.d.ts +8 -0
  174. package/dist/server/src/mcp/schemas/blocks-schema.d.ts.map +1 -0
  175. package/dist/server/src/mcp/schemas/data-schema.d.ts +36 -0
  176. package/dist/server/src/mcp/schemas/data-schema.d.ts.map +1 -0
  177. package/dist/server/src/mcp/schemas/filters-schema.d.ts +22 -0
  178. package/dist/server/src/mcp/schemas/filters-schema.d.ts.map +1 -0
  179. package/dist/server/src/mcp/schemas/index.d.ts +7 -0
  180. package/dist/server/src/mcp/schemas/index.d.ts.map +1 -0
  181. package/dist/server/src/mcp/schemas/input-schemas.d.ts +10 -0
  182. package/dist/server/src/mcp/schemas/input-schemas.d.ts.map +1 -0
  183. package/dist/server/src/mcp/schemas/output-schemas.d.ts +18 -0
  184. package/dist/server/src/mcp/schemas/output-schemas.d.ts.map +1 -0
  185. package/dist/server/src/mcp/schemas/sort-schema.d.ts +24 -0
  186. package/dist/server/src/mcp/schemas/sort-schema.d.ts.map +1 -0
  187. package/dist/server/src/mcp/types.d.ts +31 -0
  188. package/dist/server/src/mcp/types.d.ts.map +1 -0
  189. package/dist/server/src/mcp/utils.d.ts +21 -0
  190. package/dist/server/src/mcp/utils.d.ts.map +1 -0
  191. package/dist/server/src/services/index.d.ts +3 -3
  192. package/dist/server/src/services/permission-checker.d.ts +13 -3
  193. package/dist/server/src/services/permission-checker.d.ts.map +1 -1
  194. package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
  195. package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
  196. package/dist/server/src/services/utils/populate.d.ts.map +1 -1
  197. package/package.json +10 -8
@@ -1 +1 @@
1
- {"version":3,"file":"VersionInputRenderer.mjs","sources":["../../../../admin/src/history/components/VersionInputRenderer.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useStrapiApp,\n useForm,\n InputRenderer as FormInputRenderer,\n useField,\n Form,\n} from '@strapi/admin/strapi-admin';\nimport { Alert, Box, Field, Flex, Link, Tooltip, Typography } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { NavLink } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { HistoryVersionDataResponse } from '../../../../shared/contracts/history-versions';\nimport { COLLECTION_TYPES } from '../../constants/collections';\nimport { useDocumentRBAC } from '../../features/DocumentRBAC';\nimport { useDoc } from '../../hooks/useDocument';\nimport { useDocLayout } from '../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../hooks/useLazyComponents';\nimport { useTypedSelector } from '../../modules/hooks';\nimport { DocumentStatus } from '../../pages/EditView/components/DocumentStatus';\nimport { BlocksInput } from '../../pages/EditView/components/FormInputs/BlocksInput/BlocksInput';\nimport { ComponentInput } from '../../pages/EditView/components/FormInputs/Component/Input';\nimport {\n DynamicZone,\n useDynamicZone,\n} from '../../pages/EditView/components/FormInputs/DynamicZone/Field';\nimport { NotAllowedInput } from '../../pages/EditView/components/FormInputs/NotAllowed';\nimport { UIDInput } from '../../pages/EditView/components/FormInputs/UID';\nimport { Wysiwyg } from '../../pages/EditView/components/FormInputs/Wysiwyg/Field';\nimport { useFieldHint } from '../../pages/EditView/components/InputRenderer';\nimport { getRelationLabel } from '../../utils/relations';\nimport { useHistoryContext } from '../pages/History';\n\nimport { getRemaingFieldsLayout } from './VersionContent';\n\nimport type { EditFieldLayout } from '../../hooks/useDocumentLayout';\nimport type { RelationsFieldProps } from '../../pages/EditView/components/FormInputs/Relations/Relations';\nimport type { RelationResult } from '../../services/relations';\nimport type { Schema } from '@strapi/types';\nimport type { DistributiveOmit } from 'react-redux';\n\nconst StyledAlert = styled(Alert).attrs({ closeLabel: 'Close', onClose: () => {}, shadow: 'none' })`\n button {\n display: none;\n }\n`;\n\n/* -------------------------------------------------------------------------------------------------\n * CustomRelationInput\n * -----------------------------------------------------------------------------------------------*/\n\nconst LinkEllipsis = styled(Link)`\n display: block;\n\n & > span {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n display: block;\n }\n`;\n\nconst CustomRelationInput = (props: RelationsFieldProps) => {\n const { formatMessage } = useIntl();\n const field = useField<\n { results: RelationResult[]; meta: { missingCount: number } } | RelationResult[]\n >(props.name);\n\n /**\n * Ideally the server would return the correct shape, however, for admin user relations\n * it sanitizes everything out when it finds an object for the relation value.\n */\n let formattedFieldValue;\n if (field) {\n formattedFieldValue = Array.isArray(field.value)\n ? { results: field.value, meta: { missingCount: 0 } }\n : field.value;\n }\n\n if (\n !formattedFieldValue ||\n (formattedFieldValue.results.length === 0 && formattedFieldValue.meta.missingCount === 0)\n ) {\n return (\n <>\n <Field.Label action={props.labelAction}>{props.label}</Field.Label>\n <Box marginTop={1}>\n {/* @ts-expect-error – we dont need closeLabel */}\n <StyledAlert variant=\"default\">\n {formatMessage({\n id: 'content-manager.history.content.no-relations',\n defaultMessage: 'No relations.',\n })}\n </StyledAlert>\n </Box>\n </>\n );\n }\n\n const { results, meta } = formattedFieldValue;\n\n return (\n <Box>\n <Field.Label>{props.label}</Field.Label>\n {results.length > 0 && (\n <Flex direction=\"column\" gap={2} marginTop={1} alignItems=\"stretch\">\n {results.map((relationData) => {\n // @ts-expect-error - targetModel does exist on the attribute. But it's not typed.\n const { targetModel } = props.attribute;\n const href = `../${COLLECTION_TYPES}/${targetModel}/${relationData.documentId}`;\n const label = getRelationLabel(relationData, props.mainField);\n const isAdminUserRelation = targetModel === 'admin::user';\n\n return (\n <Flex\n key={relationData.documentId ?? relationData.id}\n paddingTop={2}\n paddingBottom={2}\n paddingLeft={4}\n paddingRight={4}\n hasRadius\n borderColor=\"neutral200\"\n background=\"neutral150\"\n justifyContent=\"space-between\"\n >\n <Box minWidth={0} paddingTop={1} paddingBottom={1} paddingRight={4}>\n <Tooltip label={label}>\n {isAdminUserRelation ? (\n <Typography>{label}</Typography>\n ) : (\n <LinkEllipsis tag={NavLink} to={href}>\n {label}\n </LinkEllipsis>\n )}\n </Tooltip>\n </Box>\n <DocumentStatus status={relationData.status as string} />\n </Flex>\n );\n })}\n </Flex>\n )}\n {meta.missingCount > 0 && (\n /* @ts-expect-error – we dont need closeLabel */\n <StyledAlert\n marginTop={1}\n variant=\"warning\"\n title={formatMessage(\n {\n id: 'content-manager.history.content.missing-relations.title',\n defaultMessage:\n '{number, plural, =1 {Missing relation} other {{number} missing relations}}',\n },\n { number: meta.missingCount }\n )}\n >\n {formatMessage(\n {\n id: 'content-manager.history.content.missing-relations.message',\n defaultMessage:\n \"{number, plural, =1 {It has} other {They have}} been deleted and can't be restored.\",\n },\n { number: meta.missingCount }\n )}\n </StyledAlert>\n )}\n </Box>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * CustomMediaInput\n * -----------------------------------------------------------------------------------------------*/\n\n// Create an object with value at key path (i.e. 'a.b.c')\nconst createInitialValuesForPath = (keyPath: string, value: any) => {\n const keys = keyPath.split('.');\n // The root level object\n const root: Record<string, any> = {};\n\n // Make the first node the root\n let node = root;\n keys.forEach((key, index) => {\n // Skip prototype pollution keys\n if (key === '__proto__' || key === 'constructor') return;\n // If it's the last key, set the node value\n if (index === keys.length - 1) {\n node[key] = value;\n } else {\n // Ensure the key exists and is an object\n node[key] = node[key] || {};\n }\n\n // Traverse down the tree\n node = node[key];\n });\n\n return root;\n};\n\nconst CustomMediaInput = (props: VersionInputRendererProps) => {\n const { value } = useField(props.name);\n const results = value?.results ?? [];\n const meta = value?.meta ?? { missingCount: 0 };\n\n const { formatMessage } = useIntl();\n\n const fields = useStrapiApp('CustomMediaInput', (state) => state.fields);\n const MediaLibrary = fields.media as React.ComponentType<\n VersionInputRendererProps & { multiple: boolean }\n >;\n\n return (\n <Flex direction=\"column\" gap={2} alignItems=\"stretch\">\n <Form\n method=\"PUT\"\n disabled={true}\n initialValues={createInitialValuesForPath(props.name, results)}\n >\n <MediaLibrary {...props} disabled={true} multiple={results.length > 1} />\n </Form>\n {meta.missingCount > 0 && (\n <StyledAlert\n variant=\"warning\"\n closeLabel=\"Close\"\n onClose={() => {}}\n title={formatMessage(\n {\n id: 'content-manager.history.content.missing-assets.title',\n defaultMessage:\n '{number, plural, =1 {Missing asset} other {{number} missing assets}}',\n },\n { number: meta.missingCount }\n )}\n >\n {formatMessage(\n {\n id: 'content-manager.history.content.missing-assets.message',\n defaultMessage:\n \"{number, plural, =1 {It has} other {They have}} been deleted in the Media Library and can't be restored.\",\n },\n { number: meta.missingCount }\n )}\n </StyledAlert>\n )}\n </Flex>\n );\n};\n\ntype VersionInputRendererProps = DistributiveOmit<EditFieldLayout, 'size'> & {\n /**\n * In the context of content history, deleted fields need to ignore RBAC\n * @default false\n */\n shouldIgnoreRBAC?: boolean;\n};\n\n/**\n * Checks if the i18n plugin added a label action to the field and modifies it\n * to adapt the wording for the history page.\n */\nconst getLabelAction = (labelAction: VersionInputRendererProps['labelAction']) => {\n if (!React.isValidElement(labelAction)) {\n return labelAction;\n }\n\n // TODO: find a better way to do this rather than access internals\n const labelActionTitleId = labelAction.props.title.id;\n\n if (labelActionTitleId === 'i18n.Field.localized') {\n return React.cloneElement(labelAction, {\n ...labelAction.props,\n title: {\n id: 'history.content.localized',\n defaultMessage:\n 'This value is specific to this locale. If you restore this version, the content will not be replaced for other locales.',\n },\n });\n }\n\n if (labelActionTitleId === 'i18n.Field.not-localized') {\n return React.cloneElement(labelAction, {\n ...labelAction.props,\n title: {\n id: 'history.content.not-localized',\n defaultMessage:\n 'This value is common to all locales. If you restore this version and save the changes, the content will be replaced for all locales.',\n },\n });\n }\n\n // Label action is unrelated to i18n, don't touch it.\n return labelAction;\n};\n\n/**\n * @internal\n *\n * @description An abstraction around the regular form input renderer designed specifically\n * to be used on the History page in the content-manager. It understands how to render specific\n * inputs within the context of a history version (i.e. relations, media, ignored RBAC, etc...)\n */\nconst VersionInputRenderer = ({\n visible,\n hint: providedHint,\n shouldIgnoreRBAC = false,\n labelAction,\n ...props\n}: VersionInputRendererProps) => {\n const customLabelAction = getLabelAction(labelAction);\n\n const { formatMessage } = useIntl();\n const version = useHistoryContext('VersionContent', (state) => state.selectedVersion);\n const configuration = useHistoryContext('VersionContent', (state) => state.configuration);\n const fieldSizes = useTypedSelector((state) => state['content-manager'].app.fieldSizes);\n\n const { id, components } = useDoc();\n const isFormDisabled = useForm('InputRenderer', (state) => state.disabled);\n\n const isInDynamicZone = useDynamicZone('isInDynamicZone', (state) => state.isInDynamicZone);\n\n const canCreateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canCreateFields);\n const canReadFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canReadFields);\n const canUpdateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUpdateFields);\n const canUserAction = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUserAction);\n\n const editableFields = id ? canUpdateFields : canCreateFields;\n const readableFields = id ? canReadFields : canCreateFields;\n /**\n * Component fields are always readable and editable,\n * however the fields within them may not be.\n */\n const canUserReadField = canUserAction(props.name, readableFields, props.type);\n const canUserEditField = canUserAction(props.name, editableFields, props.type);\n\n const fields = useStrapiApp('InputRenderer', (app) => app.fields);\n const { lazyComponentStore } = useLazyComponents(\n attributeHasCustomFieldProperty(props.attribute) ? [props.attribute.customField] : undefined\n );\n\n const hint = useFieldHint(providedHint, props.attribute);\n const {\n edit: { components: componentsLayout },\n } = useDocLayout();\n\n if (!visible) {\n return null;\n }\n\n /**\n * Don't render the field if the user can't read it.\n */\n if (!shouldIgnoreRBAC && !canUserReadField && !isInDynamicZone) {\n return <NotAllowedInput hint={hint} {...props} />;\n }\n\n const fieldIsDisabled =\n (!canUserEditField && !isInDynamicZone) || props.disabled || isFormDisabled;\n\n /**\n * Attributes found on the current content-type schema cannot be restored. We handle\n * this by displaying a warning alert to the user instead of the input for that field type.\n */\n const addedAttributes = version.meta.unknownAttributes.added;\n if (Object.keys(addedAttributes).includes(props.name)) {\n return (\n <Flex direction=\"column\" alignItems=\"flex-start\" gap={1}>\n <Field.Label>{props.label}</Field.Label>\n <StyledAlert\n width=\"100%\"\n closeLabel=\"Close\"\n onClose={() => {}}\n variant=\"warning\"\n title={formatMessage({\n id: 'content-manager.history.content.new-field.title',\n defaultMessage: 'New field',\n })}\n >\n {formatMessage({\n id: 'content-manager.history.content.new-field.message',\n defaultMessage:\n \"This field didn't exist when this version was saved. If you restore this version, it will be empty.\",\n })}\n </StyledAlert>\n </Flex>\n );\n }\n\n /**\n * Because a custom field has a unique prop but the type could be confused with either\n * the useField hook or the type of the field we need to handle it separately and first.\n */\n if (attributeHasCustomFieldProperty(props.attribute)) {\n const CustomInput = lazyComponentStore[props.attribute.customField];\n\n if (CustomInput) {\n return (\n <CustomInput\n {...props}\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n return (\n <FormInputRenderer\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n // @ts-expect-error – this workaround lets us display that the custom field is missing.\n type={props.attribute.customField}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * Since media fields use a custom input via the upload plugin provided by the useLibrary hook,\n * we need to handle the them before other custom inputs coming from the useLibrary hook.\n */\n if (props.type === 'media') {\n return (\n <CustomMediaInput {...props} labelAction={customLabelAction} disabled={fieldIsDisabled} />\n );\n }\n /**\n * This is where we handle ONLY the fields from the `useLibrary` hook.\n */\n const addedInputTypes = Object.keys(fields);\n if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {\n const CustomInput = fields[props.type];\n return (\n <CustomInput\n {...props}\n // @ts-expect-error – TODO: fix this type error in the useLibrary hook.\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * These include the content-manager specific fields, failing that we fall back\n * to the more generic form input renderer.\n */\n switch (props.type) {\n case 'blocks':\n return <BlocksInput {...props} hint={hint} type={props.type} disabled={fieldIsDisabled} />;\n case 'component':\n const { layout } = componentsLayout[props.attribute.component];\n // Components can only have one panel, so only save the first layout item\n const [remainingFieldsLayout] = getRemaingFieldsLayout({\n layout: [layout],\n metadatas: configuration.components[props.attribute.component].metadatas,\n fieldSizes,\n schemaAttributes: components[props.attribute.component].attributes,\n });\n\n return (\n <ComponentInput\n {...props}\n layout={[...layout, ...(remainingFieldsLayout || [])]}\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n >\n {(inputProps) => <VersionInputRenderer {...inputProps} shouldIgnoreRBAC={true} />}\n </ComponentInput>\n );\n case 'dynamiczone':\n return (\n <DynamicZone\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n >\n {(inputProps) => <VersionInputRenderer {...inputProps} shouldIgnoreRBAC={true} />}\n </DynamicZone>\n );\n case 'relation':\n return (\n <CustomRelationInput\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n case 'richtext':\n return (\n <Wysiwyg\n {...props}\n hint={hint}\n type={props.type}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n case 'uid':\n return (\n <UIDInput\n {...props}\n hint={hint}\n type={props.type}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n /**\n * Enumerations are a special case because they require options.\n */\n case 'enumeration':\n return (\n <FormInputRenderer\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n options={props.attribute.enum.map((value) => ({ value }))}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n default:\n // These props are not needed for the generic form input renderer.\n const { unique: _unique, mainField: _mainField, ...restProps } = props;\n return (\n <FormInputRenderer\n {...restProps}\n hint={hint}\n labelAction={customLabelAction}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n }\n};\n\nconst attributeHasCustomFieldProperty = (\n attribute: Schema.Attribute.AnyAttribute\n): attribute is Schema.Attribute.AnyAttribute & Schema.Attribute.CustomField<string> =>\n 'customField' in attribute && typeof attribute.customField === 'string';\n\nexport type { VersionInputRendererProps };\nexport { VersionInputRenderer };\n"],"names":["StyledAlert","styled","Alert","attrs","closeLabel","onClose","shadow","LinkEllipsis","Link","CustomRelationInput","props","formatMessage","useIntl","field","useField","name","formattedFieldValue","Array","isArray","value","results","meta","missingCount","length","_jsxs","_Fragment","_jsx","Field","Label","action","labelAction","label","Box","marginTop","variant","id","defaultMessage","Flex","direction","gap","alignItems","map","relationData","targetModel","attribute","href","COLLECTION_TYPES","documentId","getRelationLabel","mainField","isAdminUserRelation","paddingTop","paddingBottom","paddingLeft","paddingRight","hasRadius","borderColor","background","justifyContent","minWidth","Tooltip","Typography","tag","NavLink","to","DocumentStatus","status","title","number","createInitialValuesForPath","keyPath","keys","split","root","node","forEach","key","index","CustomMediaInput","fields","useStrapiApp","state","MediaLibrary","media","Form","method","disabled","initialValues","multiple","getLabelAction","React","isValidElement","labelActionTitleId","cloneElement","VersionInputRenderer","visible","hint","providedHint","shouldIgnoreRBAC","customLabelAction","version","useHistoryContext","selectedVersion","configuration","fieldSizes","useTypedSelector","app","components","useDoc","isFormDisabled","useForm","isInDynamicZone","useDynamicZone","canCreateFields","useDocumentRBAC","rbac","canReadFields","canUpdateFields","canUserAction","editableFields","readableFields","canUserReadField","type","canUserEditField","lazyComponentStore","useLazyComponents","attributeHasCustomFieldProperty","customField","undefined","useFieldHint","edit","componentsLayout","useDocLayout","NotAllowedInput","fieldIsDisabled","addedAttributes","unknownAttributes","added","Object","includes","width","CustomInput","FormInputRenderer","addedInputTypes","BlocksInput","layout","component","remainingFieldsLayout","getRemaingFieldsLayout","metadatas","schemaAttributes","attributes","ComponentInput","inputProps","DynamicZone","Wysiwyg","UIDInput","options","enum","unique","_unique","_mainField","restProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAMA,WAAAA,GAAcC,MAAAA,CAAOC,KAAAA,CAAAA,CAAOC,KAAK,CAAC;IAAEC,UAAAA,EAAY,OAAA;AAASC,IAAAA,OAAAA,EAAS,IAAA,CAAO,CAAA;IAAGC,MAAAA,EAAQ;AAAO,CAAA,CAAE;;;;AAInG,CAAC;AAED;;AAEkG,qGAElG,MAAMC,YAAAA,GAAeN,MAAAA,CAAOO,IAAAA,CAAK;;;;;;;;;AASjC,CAAC;AAED,MAAMC,sBAAsB,CAACC,KAAAA,GAAAA;IAC3B,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;IAC1B,MAAMC,KAAAA,GAAQC,QAAAA,CAEZJ,KAAAA,CAAMK,IAAI,CAAA;AAEZ;;;AAGC,MACD,IAAIC,mBAAAA;AACJ,IAAA,IAAIH,KAAAA,EAAO;AACTG,QAAAA,mBAAAA,GAAsBC,KAAAA,CAAMC,OAAO,CAACL,KAAAA,CAAMM,KAAK,CAAA,GAC3C;AAAEC,YAAAA,OAAAA,EAASP,MAAMM,KAAK;YAAEE,IAAAA,EAAM;gBAAEC,YAAAA,EAAc;AAAE;AAAE,SAAA,GAClDT,MAAMM,KAAK;AACjB,IAAA;AAEA,IAAA,IACE,C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AAA,EAAaqE,iBAAAA;gBACb0D,OAAAA,EAASnJ,KAAAA,CAAMkC,SAAS,CAACkH,IAAI,CAACrH,GAAG,CAAC,CAACtB,KAAAA,IAAW;AAAEA,wBAAAA;qBAAM,CAAA,CAAA;;AAEtDuG,gBAAAA,IAAAA,EAAMhH,KAAAA,CAAMqH,WAAW,GAAG,cAAA,GAAiBrH,MAAMgH,IAAI;gBACrDpC,QAAAA,EAAUgD;;AAGhB,QAAA;;YAEE,MAAM,EAAEyB,QAAQC,OAAO,EAAE/G,WAAWgH,UAAU,EAAE,GAAGC,SAAAA,EAAW,GAAGxJ,KAAAA;AACjE,YAAA,qBACEgB,GAAA,CAACoH,aAAAA,EAAAA;AACE,gBAAA,GAAGoB,SAAS;gBACblE,IAAAA,EAAMA,IAAAA;gBACNlE,WAAAA,EAAaqE,iBAAAA;;AAEbuB,gBAAAA,IAAAA,EAAMhH,KAAAA,CAAMqH,WAAW,GAAG,cAAA,GAAiBrH,MAAMgH,IAAI;gBACrDpC,QAAAA,EAAUgD;;AAGlB;AACF;AAEA,MAAMR,+BAAAA,GAAkC,CACtClF,SAAAA,GAEA,aAAA,IAAiBA,aAAa,OAAOA,SAAAA,CAAUmF,WAAW,KAAK,QAAA;;;;"}
1
+ {"version":3,"file":"VersionInputRenderer.mjs","sources":["../../../../admin/src/history/components/VersionInputRenderer.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useStrapiApp,\n useForm,\n InputRenderer as FormInputRenderer,\n useField,\n Form,\n} from '@strapi/admin/strapi-admin';\nimport { Alert, Box, Field, Flex, Link, Tooltip, Typography } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { NavLink } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { COLLECTION_TYPES } from '../../constants/collections';\nimport { useDocumentRBAC } from '../../features/DocumentRBAC';\nimport { useDoc } from '../../hooks/useDocument';\nimport { useDocLayout } from '../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../hooks/useLazyComponents';\nimport { useTypedSelector } from '../../modules/hooks';\nimport { DocumentStatus } from '../../pages/EditView/components/DocumentStatus';\nimport { BlocksInput } from '../../pages/EditView/components/FormInputs/BlocksInput/BlocksInput';\nimport { ComponentInput } from '../../pages/EditView/components/FormInputs/Component/Input';\nimport {\n DynamicZone,\n useDynamicZone,\n} from '../../pages/EditView/components/FormInputs/DynamicZone/Field';\nimport { NotAllowedInput } from '../../pages/EditView/components/FormInputs/NotAllowed';\nimport { UIDInput } from '../../pages/EditView/components/FormInputs/UID';\nimport { Wysiwyg } from '../../pages/EditView/components/FormInputs/Wysiwyg/Field';\nimport { useFieldHint } from '../../pages/EditView/components/InputRenderer';\nimport { getRelationLabel } from '../../utils/relations';\nimport { useHistoryContext } from '../pages/History';\n\nimport { getRemaingFieldsLayout } from './VersionContent';\n\nimport type { EditFieldLayout } from '../../hooks/useDocumentLayout';\nimport type { RelationsFieldProps } from '../../pages/EditView/components/FormInputs/Relations/Relations';\nimport type { RelationResult } from '../../services/relations';\nimport type { Schema } from '@strapi/types';\nimport type { DistributiveOmit } from 'react-redux';\n\nconst StyledAlert = styled(Alert).attrs({ closeLabel: 'Close', onClose: () => {}, shadow: 'none' })`\n button {\n display: none;\n }\n`;\n\n/* -------------------------------------------------------------------------------------------------\n * CustomRelationInput\n * -----------------------------------------------------------------------------------------------*/\n\nconst LinkEllipsis = styled(Link)`\n display: block;\n\n & > span {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n display: block;\n }\n`;\n\nconst CustomRelationInput = (props: RelationsFieldProps) => {\n const { formatMessage } = useIntl();\n const field = useField<\n { results: RelationResult[]; meta: { missingCount: number } } | RelationResult[]\n >(props.name);\n\n /**\n * Ideally the server would return the correct shape, however, for admin user relations\n * it sanitizes everything out when it finds an object for the relation value.\n */\n let formattedFieldValue;\n if (field) {\n formattedFieldValue = Array.isArray(field.value)\n ? { results: field.value, meta: { missingCount: 0 } }\n : field.value;\n }\n\n // Be defensive about the shape: admin-user relations are sanitized to a\n // plain user object on the server, and historical version data can carry\n // shapes that pre-date the `{ results, meta }` contract. Treat anything\n // without an array `results` as \"no relations\".\n const hasResultsShape =\n !!formattedFieldValue &&\n typeof formattedFieldValue === 'object' &&\n Array.isArray((formattedFieldValue as { results?: unknown }).results);\n const missingCount =\n hasResultsShape &&\n typeof (formattedFieldValue as { meta?: { missingCount?: number } }).meta?.missingCount ===\n 'number'\n ? (formattedFieldValue as { meta: { missingCount: number } }).meta.missingCount\n : 0;\n\n if (\n !hasResultsShape ||\n ((formattedFieldValue as { results: unknown[] }).results.length === 0 && missingCount === 0)\n ) {\n return (\n <>\n <Field.Label action={props.labelAction}>{props.label}</Field.Label>\n <Box marginTop={1}>\n <StyledAlert variant=\"default\">\n {formatMessage({\n id: 'content-manager.history.content.no-relations',\n defaultMessage: 'No relations.',\n })}\n </StyledAlert>\n </Box>\n </>\n );\n }\n\n const { results, meta } = formattedFieldValue as {\n results: RelationResult[];\n meta: { missingCount: number };\n };\n\n return (\n <Box>\n <Field.Label>{props.label}</Field.Label>\n {results.length > 0 && (\n <Flex direction=\"column\" gap={2} marginTop={1} alignItems=\"stretch\">\n {results.map((relationData) => {\n // @ts-expect-error - targetModel does exist on the attribute. But it's not typed.\n const { targetModel } = props.attribute;\n const href = `../${COLLECTION_TYPES}/${targetModel}/${relationData.documentId}`;\n const label = getRelationLabel(relationData, props.mainField);\n const isAdminUserRelation = targetModel === 'admin::user';\n\n return (\n <Flex\n key={relationData.documentId ?? relationData.id}\n paddingTop={2}\n paddingBottom={2}\n paddingLeft={4}\n paddingRight={4}\n hasRadius\n borderColor=\"neutral200\"\n background=\"neutral150\"\n justifyContent=\"space-between\"\n >\n <Box minWidth={0} paddingTop={1} paddingBottom={1} paddingRight={4}>\n <Tooltip label={label}>\n {isAdminUserRelation ? (\n <Typography>{label}</Typography>\n ) : (\n <LinkEllipsis tag={NavLink} to={href}>\n {label}\n </LinkEllipsis>\n )}\n </Tooltip>\n </Box>\n <DocumentStatus status={relationData.status as string} />\n </Flex>\n );\n })}\n </Flex>\n )}\n {meta.missingCount > 0 && (\n <StyledAlert\n marginTop={1}\n variant=\"warning\"\n title={formatMessage(\n {\n id: 'content-manager.history.content.missing-relations.title',\n defaultMessage:\n '{number, plural, =1 {Missing relation} other {{number} missing relations}}',\n },\n { number: meta.missingCount }\n )}\n >\n {formatMessage(\n {\n id: 'content-manager.history.content.missing-relations.message',\n defaultMessage:\n \"{number, plural, =1 {It has} other {They have}} been deleted and can't be restored.\",\n },\n { number: meta.missingCount }\n )}\n </StyledAlert>\n )}\n </Box>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * CustomMediaInput\n * -----------------------------------------------------------------------------------------------*/\n\n// Create an object with value at key path (i.e. 'a.b.c')\nconst createInitialValuesForPath = (keyPath: string, value: any) => {\n const keys = keyPath.split('.');\n // The root level object\n const root: Record<string, any> = {};\n\n // Make the first node the root\n let node = root;\n keys.forEach((key, index) => {\n // Skip prototype pollution keys\n if (key === '__proto__' || key === 'constructor') return;\n // If it's the last key, set the node value\n if (index === keys.length - 1) {\n node[key] = value;\n } else {\n // Ensure the key exists and is an object\n node[key] = node[key] || {};\n }\n\n // Traverse down the tree\n node = node[key];\n });\n\n return root;\n};\n\nconst CustomMediaInput = (props: VersionInputRendererProps) => {\n const { value } = useField(props.name);\n const results = value?.results ?? [];\n const meta = value?.meta ?? { missingCount: 0 };\n\n const { formatMessage } = useIntl();\n\n const fields = useStrapiApp('CustomMediaInput', (state) => state.fields);\n const MediaLibrary = fields.media as React.ComponentType<\n VersionInputRendererProps & { multiple: boolean }\n >;\n\n return (\n <Flex direction=\"column\" gap={2} alignItems=\"stretch\">\n <Form\n method=\"PUT\"\n disabled={true}\n initialValues={createInitialValuesForPath(props.name, results)}\n >\n <MediaLibrary {...props} disabled={true} multiple={results.length > 1} />\n </Form>\n {meta.missingCount > 0 && (\n <StyledAlert\n variant=\"warning\"\n closeLabel=\"Close\"\n onClose={() => {}}\n title={formatMessage(\n {\n id: 'content-manager.history.content.missing-assets.title',\n defaultMessage:\n '{number, plural, =1 {Missing asset} other {{number} missing assets}}',\n },\n { number: meta.missingCount }\n )}\n >\n {formatMessage(\n {\n id: 'content-manager.history.content.missing-assets.message',\n defaultMessage:\n \"{number, plural, =1 {It has} other {They have}} been deleted in the Media Library and can't be restored.\",\n },\n { number: meta.missingCount }\n )}\n </StyledAlert>\n )}\n </Flex>\n );\n};\n\ntype VersionInputRendererProps = DistributiveOmit<EditFieldLayout, 'size'> & {\n /**\n * In the context of content history, deleted fields need to ignore RBAC\n * @default false\n */\n shouldIgnoreRBAC?: boolean;\n};\n\n/**\n * Checks if the i18n plugin added a label action to the field and modifies it\n * to adapt the wording for the history page.\n */\nconst getLabelAction = (labelAction: VersionInputRendererProps['labelAction']) => {\n if (!React.isValidElement(labelAction)) {\n return labelAction;\n }\n\n // TODO: find a better way to do this rather than access internals\n const labelActionTitleId = labelAction.props.title.id;\n\n if (labelActionTitleId === 'i18n.Field.localized') {\n return React.cloneElement(labelAction, {\n ...labelAction.props,\n title: {\n id: 'history.content.localized',\n defaultMessage:\n 'This value is specific to this locale. If you restore this version, the content will not be replaced for other locales.',\n },\n });\n }\n\n if (labelActionTitleId === 'i18n.Field.not-localized') {\n return React.cloneElement(labelAction, {\n ...labelAction.props,\n title: {\n id: 'history.content.not-localized',\n defaultMessage:\n 'This value is common to all locales. If you restore this version and save the changes, the content will be replaced for all locales.',\n },\n });\n }\n\n // Label action is unrelated to i18n, don't touch it.\n return labelAction;\n};\n\n/**\n * Resolve the layout, configuration metadata and schema attributes needed to\n * render a component field on the history page. Returns `null` when any of\n * those are missing — happens when the component schema referenced by the\n * version was deleted via the Content-Type Builder, in which case the caller\n * should render a fallback instead of crashing on the destructuring.\n */\nconst resolveComponentRenderResources = (\n componentUID: string,\n componentsLayout: { [uid: string]: { layout: unknown } | undefined },\n configurationComponents: { [uid: string]: { metadatas: unknown } | undefined },\n components: { [uid: string]: { attributes: unknown } | undefined }\n) => {\n const componentLayout = componentsLayout[componentUID];\n const componentConfiguration = configurationComponents[componentUID];\n const componentSchema = components[componentUID];\n\n if (!componentLayout || !componentConfiguration || !componentSchema) {\n return null;\n }\n\n return {\n layout: componentLayout.layout,\n metadatas: componentConfiguration.metadatas,\n schemaAttributes: componentSchema.attributes,\n };\n};\n\n/**\n * @internal\n *\n * @description An abstraction around the regular form input renderer designed specifically\n * to be used on the History page in the content-manager. It understands how to render specific\n * inputs within the context of a history version (i.e. relations, media, ignored RBAC, etc...)\n */\nconst VersionInputRenderer = ({\n visible,\n hint: providedHint,\n shouldIgnoreRBAC = false,\n labelAction,\n ...props\n}: VersionInputRendererProps) => {\n const customLabelAction = getLabelAction(labelAction);\n\n const { formatMessage } = useIntl();\n const version = useHistoryContext('VersionContent', (state) => state.selectedVersion);\n const configuration = useHistoryContext('VersionContent', (state) => state.configuration);\n const fieldSizes = useTypedSelector((state) => state['content-manager'].app.fieldSizes);\n\n const { id, components } = useDoc();\n const isFormDisabled = useForm('InputRenderer', (state) => state.disabled);\n\n const isInDynamicZone = useDynamicZone('isInDynamicZone', (state) => state.isInDynamicZone);\n\n const canCreateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canCreateFields);\n const canReadFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canReadFields);\n const canUpdateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUpdateFields);\n const canUserAction = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUserAction);\n\n const editableFields = id ? canUpdateFields : canCreateFields;\n const readableFields = id ? canReadFields : canCreateFields;\n /**\n * Component fields are always readable and editable,\n * however the fields within them may not be.\n */\n const canUserReadField = canUserAction(props.name, readableFields, props.type);\n const canUserEditField = canUserAction(props.name, editableFields, props.type);\n\n const fields = useStrapiApp('InputRenderer', (app) => app.fields);\n const { lazyComponentStore } = useLazyComponents(\n attributeHasCustomFieldProperty(props.attribute) ? [props.attribute.customField] : undefined\n );\n\n const hint = useFieldHint(providedHint, props.attribute);\n const {\n edit: { components: componentsLayout },\n } = useDocLayout();\n\n if (!visible) {\n return null;\n }\n\n /**\n * Don't render the field if the user can't read it.\n */\n if (!shouldIgnoreRBAC && !canUserReadField && !isInDynamicZone) {\n return <NotAllowedInput hint={hint} {...props} />;\n }\n\n const fieldIsDisabled =\n (!canUserEditField && !isInDynamicZone) || props.disabled || isFormDisabled;\n\n /**\n * Attributes found on the current content-type schema cannot be restored. We handle\n * this by displaying a warning alert to the user instead of the input for that field type.\n */\n const addedAttributes = version.meta.unknownAttributes.added;\n if (Object.keys(addedAttributes).includes(props.name)) {\n return (\n <Flex direction=\"column\" alignItems=\"flex-start\" gap={1}>\n <Field.Label>{props.label}</Field.Label>\n <StyledAlert\n width=\"100%\"\n closeLabel=\"Close\"\n onClose={() => {}}\n variant=\"warning\"\n title={formatMessage({\n id: 'content-manager.history.content.new-field.title',\n defaultMessage: 'New field',\n })}\n >\n {formatMessage({\n id: 'content-manager.history.content.new-field.message',\n defaultMessage:\n \"This field didn't exist when this version was saved. If you restore this version, it will be empty.\",\n })}\n </StyledAlert>\n </Flex>\n );\n }\n\n /**\n * Because a custom field has a unique prop but the type could be confused with either\n * the useField hook or the type of the field we need to handle it separately and first.\n */\n if (attributeHasCustomFieldProperty(props.attribute)) {\n const CustomInput = lazyComponentStore[props.attribute.customField];\n\n if (CustomInput) {\n return (\n <CustomInput\n {...props}\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n return (\n <FormInputRenderer\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n // @ts-expect-error – this workaround lets us display that the custom field is missing.\n type={props.attribute.customField}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * Since media fields use a custom input via the upload plugin provided by the useLibrary hook,\n * we need to handle the them before other custom inputs coming from the useLibrary hook.\n */\n if (props.type === 'media') {\n return (\n <CustomMediaInput {...props} labelAction={customLabelAction} disabled={fieldIsDisabled} />\n );\n }\n /**\n * This is where we handle ONLY the fields from the `useLibrary` hook.\n */\n const addedInputTypes = Object.keys(fields);\n if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {\n const CustomInput = fields[props.type];\n return (\n <CustomInput\n {...props}\n // @ts-expect-error – TODO: fix this type error in the useLibrary hook.\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * These include the content-manager specific fields, failing that we fall back\n * to the more generic form input renderer.\n */\n switch (props.type) {\n case 'blocks':\n return <BlocksInput {...props} hint={hint} type={props.type} disabled={fieldIsDisabled} />;\n case 'component': {\n const renderResources = resolveComponentRenderResources(\n props.attribute.component,\n componentsLayout,\n configuration.components,\n components\n );\n\n // The component schema referenced by this version is no longer present\n // (deleted via the Content-Type Builder). Render the label only so the\n // rest of the page still loads instead of crashing on the lookups below.\n if (!renderResources) {\n return <Field.Label>{props.label}</Field.Label>;\n }\n\n const { layout, metadatas, schemaAttributes } = renderResources as {\n layout: Array<EditFieldLayout[]>;\n metadatas: Parameters<typeof getRemaingFieldsLayout>[0]['metadatas'];\n schemaAttributes: Parameters<typeof getRemaingFieldsLayout>[0]['schemaAttributes'];\n };\n\n // Components can only have one panel, so only save the first layout item\n const [remainingFieldsLayout] = getRemaingFieldsLayout({\n layout: [layout],\n metadatas,\n fieldSizes,\n schemaAttributes,\n });\n\n return (\n <ComponentInput\n {...props}\n layout={[...layout, ...(remainingFieldsLayout || [])]}\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n >\n {(inputProps) => <VersionInputRenderer {...inputProps} shouldIgnoreRBAC={true} />}\n </ComponentInput>\n );\n }\n case 'dynamiczone':\n return (\n <DynamicZone\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n >\n {(inputProps) => <VersionInputRenderer {...inputProps} shouldIgnoreRBAC={true} />}\n </DynamicZone>\n );\n case 'relation':\n return (\n <CustomRelationInput\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n case 'richtext':\n return (\n <Wysiwyg\n {...props}\n hint={hint}\n type={props.type}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n case 'uid':\n return (\n <UIDInput\n {...props}\n hint={hint}\n type={props.type}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n /**\n * Enumerations are a special case because they require options.\n */\n case 'enumeration':\n return (\n <FormInputRenderer\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n options={props.attribute.enum.map((value) => ({ value }))}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n default:\n // These props are not needed for the generic form input renderer.\n const { unique: _unique, mainField: _mainField, ...restProps } = props;\n return (\n <FormInputRenderer\n {...restProps}\n hint={hint}\n labelAction={customLabelAction}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n }\n};\n\nconst attributeHasCustomFieldProperty = (\n attribute: Schema.Attribute.AnyAttribute\n): attribute is Schema.Attribute.AnyAttribute & Schema.Attribute.CustomField<string> =>\n 'customField' in attribute && typeof attribute.customField === 'string';\n\nexport type { VersionInputRendererProps };\nexport { VersionInputRenderer, CustomRelationInput, resolveComponentRenderResources };\n"],"names":["StyledAlert","styled","Alert","attrs","closeLabel","onClose","shadow","LinkEllipsis","Link","CustomRelationInput","props","formatMessage","useIntl","field","useField","name","formattedFieldValue","Array","isArray","value","results","meta","missingCount","hasResultsShape","length","_jsxs","_Fragment","_jsx","Field","Label","action","labelAction","label","Box","marginTop","variant","id","defaultMessage","Flex","direction","gap","alignItems","map","relationData","targetModel","attribute","href","COLLECTION_TYPES","documentId","getRelationLabel","mainField","isAdminUserRelation","paddingTop","paddingBottom","paddingLeft","paddingRight","hasRadius","borderColor","background","justifyContent","minWidth","Tooltip","Typography","tag","NavLink","to","DocumentStatus","status","title","number","createInitialValuesForPath","keyPath","keys","split","root","node","forEach","key","index","CustomMediaInput","fields","useStrapiApp","state","MediaLibrary","media","Form","method","disabled","initialValues","multiple","getLabelAction","React","isValidElement","labelActionTitleId","cloneElement","resolveComponentRenderResources","componentUID","componentsLayout","configurationComponents","components","componentLayout","componentConfiguration","componentSchema","layout","metadatas","schemaAttributes","attributes","VersionInputRenderer","visible","hint","providedHint","shouldIgnoreRBAC","customLabelAction","version","useHistoryContext","selectedVersion","configuration","fieldSizes","useTypedSelector","app","useDoc","isFormDisabled","useForm","isInDynamicZone","useDynamicZone","canCreateFields","useDocumentRBAC","rbac","canReadFields","canUpdateFields","canUserAction","editableFields","readableFields","canUserReadField","type","canUserEditField","lazyComponentStore","useLazyComponents","attributeHasCustomFieldProperty","customField","undefined","useFieldHint","edit","useDocLayout","NotAllowedInput","fieldIsDisabled","addedAttributes","unknownAttributes","added","Object","includes","width","CustomInput","FormInputRenderer","addedInputTypes","BlocksInput","renderResources","component","remainingFieldsLayout","getRemaingFieldsLayout","ComponentInput","inputProps","DynamicZone","Wysiwyg","UIDInput","options","enum","unique","_unique","_mainField","restProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAMA,WAAAA,GAAcC,MAAAA,CAAOC,KAAAA,CAAAA,CAAOC,KAAK,CAAC;IAAEC,UAAAA,EAAY,OAAA;AAASC,IAAAA,OAAAA,EAAS,IAAA,CAAO,CAAA;IAAGC,MAAAA,EAAQ;AAAO,CAAA,CAAE;;;;AAInG,CAAC;AAED;;AAEkG,qGAElG,MAAMC,YAAAA,GAAeN,MAAAA,CAAOO,IAAAA,CAAK;;;;;;;;;AASjC,CAAC;AAED,MAAMC,sBAAsB,CAACC,KAAAA,GAAAA;IAC3B,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;IAC1B,MAAMC,KAAAA,GAAQC,QAAAA,CAEZJ,KAAAA,CAAMK,IAAI,CAAA;AAEZ;;;AA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KAAK;gBACTmG,IAAAA,EAAMA,IAAAA;gBACN9E,WAAAA,EAAaiF,iBAAAA;gBACbqD,OAAAA,EAAS3J,KAAAA,CAAMmC,SAAS,CAACyH,IAAI,CAAC5H,GAAG,CAAC,CAACvB,KAAAA,IAAW;AAAEA,wBAAAA;qBAAM,CAAA,CAAA;;AAEtDmH,gBAAAA,IAAAA,EAAM5H,KAAAA,CAAMiI,WAAW,GAAG,cAAA,GAAiBjI,MAAM4H,IAAI;gBACrD/C,QAAAA,EAAU0D;;AAGhB,QAAA;;YAEE,MAAM,EAAEsB,QAAQC,OAAO,EAAEtH,WAAWuH,UAAU,EAAE,GAAGC,SAAAA,EAAW,GAAGhK,KAAAA;AACjE,YAAA,qBACEiB,GAAA,CAAC8H,aAAAA,EAAAA;AACE,gBAAA,GAAGiB,SAAS;gBACb7D,IAAAA,EAAMA,IAAAA;gBACN9E,WAAAA,EAAaiF,iBAAAA;;AAEbsB,gBAAAA,IAAAA,EAAM5H,KAAAA,CAAMiI,WAAW,GAAG,cAAA,GAAiBjI,MAAM4H,IAAI;gBACrD/C,QAAAA,EAAU0D;;AAGlB;AACF;AAEA,MAAMP,+BAAAA,GAAkC,CACtC7F,SAAAA,GAEA,aAAA,IAAiBA,aAAa,OAAOA,SAAAA,CAAU8F,WAAW,KAAK,QAAA;;;;"}
@@ -13,6 +13,7 @@ var hooks = require('../modules/hooks.js');
13
13
  var components = require('../services/components.js');
14
14
  var init = require('../services/init.js');
15
15
  var objects = require('../utils/objects.js');
16
+ var formatComponentConfigurationEditLayout = require('./formatComponentConfigurationEditLayout.js');
16
17
 
17
18
  function _interopNamespaceDefault(e) {
18
19
  var n = Object.create(null);
@@ -96,7 +97,7 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
96
97
  * you **must** check if we're loading or fetching in case the component gets new props
97
98
  * but nothing was unmounted, it then becomes a fetch, not a load.
98
99
  */ const isLoading = isLoadingConfig || isLoadingSchema || isFetchingConfig || isFetchingSchema;
99
- const editLayout = React__namespace.useMemo(()=>data && !isLoading ? formatEditLayout(data, {
100
+ const editLayout = React__namespace.useMemo(()=>data && !isLoading ? formatComponentConfigurationEditLayout.formatComponentConfigurationEditLayout(data, {
100
101
  schema,
101
102
  components: components$1
102
103
  }) : {
@@ -193,50 +194,6 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
193
194
  ]
194
195
  });
195
196
  };
196
- /* -------------------------------------------------------------------------------------------------
197
- * Header
198
- * -----------------------------------------------------------------------------------------------*/ const formatEditLayout = (data, { schema, components })=>{
199
- const editAttributes = useDocumentLayout.convertEditLayoutToFieldLayouts(data.component.layouts.edit, schema?.attributes, data.component.metadatas, {
200
- configurations: data.components,
201
- schemas: components
202
- });
203
- const componentEditAttributes = Object.entries(data.components).reduce((acc, [uid, configuration])=>{
204
- const componentSchema = components[uid];
205
- if (!componentSchema) {
206
- return acc;
207
- }
208
- acc[uid] = {
209
- layout: useDocumentLayout.convertEditLayoutToFieldLayouts(configuration.layouts.edit, componentSchema.attributes, configuration.metadatas),
210
- settings: {
211
- ...configuration.settings,
212
- icon: componentSchema.info.icon,
213
- displayName: componentSchema.info.displayName
214
- }
215
- };
216
- return acc;
217
- }, {});
218
- const editMetadatas = Object.entries(data.component.metadatas).reduce((acc, [attribute, metadata])=>{
219
- return {
220
- ...acc,
221
- [attribute]: metadata.edit
222
- };
223
- }, {});
224
- return {
225
- layout: [
226
- editAttributes
227
- ],
228
- components: componentEditAttributes,
229
- metadatas: editMetadatas,
230
- options: {
231
- ...schema?.options,
232
- ...schema?.pluginOptions
233
- },
234
- settings: {
235
- ...data.component.settings,
236
- displayName: schema?.info.displayName
237
- }
238
- };
239
- };
240
197
  /* -------------------------------------------------------------------------------------------------
241
198
  * Header
242
199
  * -----------------------------------------------------------------------------------------------*/ const ProtectedComponentConfigurationPage = ()=>{
@@ -1 +1 @@
1
- {"version":3,"file":"ComponentConfigurationPage.js","sources":["../../../admin/src/pages/ComponentConfigurationPage.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Page, useNotification, useAPIErrorHandler } from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\nimport { useParams } from 'react-router-dom';\n\nimport { TEMP_FIELD_NAME } from '../components/ConfigurationForm/Fields';\nimport { ConfigurationForm, ConfigurationFormProps } from '../components/ConfigurationForm/Form';\nimport { ComponentsDictionary, extractContentTypeComponents } from '../hooks/useContentTypeSchema';\nimport {\n DEFAULT_SETTINGS,\n EditLayout,\n convertEditLayoutToFieldLayouts,\n} from '../hooks/useDocumentLayout';\nimport { useTypedSelector } from '../modules/hooks';\nimport {\n useGetComponentConfigurationQuery,\n useUpdateComponentConfigurationMutation,\n} from '../services/components';\nimport { useGetInitialDataQuery } from '../services/init';\nimport { setIn } from '../utils/objects';\n\nimport type { Component, FindComponentConfiguration } from '../../../shared/contracts/components';\nimport type { Metadatas } from '../../../shared/contracts/content-types';\n\n/* -------------------------------------------------------------------------------------------------\n * ComponentConfigurationPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst ComponentConfigurationPage = () => {\n /**\n * useDocumentLayout only works for documents, not components,\n * it feels weird to make that hook work for both when this is SUCH\n * a unique use case and we only do it here, so in short, we essentially\n * just extracted the logic to make an edit view layout and reproduced it here.\n */\n const { slug: model } = useParams<{ slug: string }>();\n const { toggleNotification } = useNotification();\n const { formatMessage } = useIntl();\n const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();\n\n const {\n components,\n fieldSizes,\n schema,\n error: errorSchema,\n isLoading: isLoadingSchema,\n isFetching: isFetchingSchema,\n } = useGetInitialDataQuery(undefined, {\n selectFromResult: (res) => {\n const schema = res.data?.components.find((ct) => ct.uid === model);\n\n const componentsByKey = res.data?.components.reduce<ComponentsDictionary>(\n (acc, component) => {\n acc[component.uid] = component;\n\n return acc;\n },\n {}\n );\n\n const components = extractContentTypeComponents(schema?.attributes, componentsByKey);\n\n const fieldSizes = Object.entries(res.data?.fieldSizes ?? {}).reduce<\n ConfigurationFormProps['fieldSizes']\n >((acc, [attributeName, { default: size }]) => {\n acc[attributeName] = size;\n\n return acc;\n }, {});\n\n return {\n isFetching: res.isFetching,\n isLoading: res.isLoading,\n error: res.error,\n components,\n schema,\n fieldSizes,\n };\n },\n });\n\n React.useEffect(() => {\n if (errorSchema) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(errorSchema),\n });\n }\n }, [errorSchema, formatAPIError, toggleNotification]);\n\n const {\n data,\n isLoading: isLoadingConfig,\n isFetching: isFetchingConfig,\n error,\n } = useGetComponentConfigurationQuery(model ?? '');\n\n React.useEffect(() => {\n if (error) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(error),\n });\n }\n }, [error, formatAPIError, toggleNotification]);\n\n /**\n * you **must** check if we're loading or fetching in case the component gets new props\n * but nothing was unmounted, it then becomes a fetch, not a load.\n */\n const isLoading = isLoadingConfig || isLoadingSchema || isFetchingConfig || isFetchingSchema;\n\n const editLayout = React.useMemo(\n () =>\n data && !isLoading\n ? formatEditLayout(data, { schema, components })\n : ({\n layout: [],\n components: {},\n metadatas: {},\n options: {},\n settings: DEFAULT_SETTINGS,\n } as EditLayout),\n [data, isLoading, schema, components]\n );\n\n const [updateConfiguration] = useUpdateComponentConfigurationMutation();\n const handleSubmit: ConfigurationFormProps['onSubmit'] = async (formData) => {\n try {\n /**\n * We reconstruct the metadatas object by taking the existing list metadatas\n * and re-merging that by attribute name with the current list metadatas, whilst overwriting\n * the data from the form we've built.\n */\n const meta = Object.entries(data?.component.metadatas ?? {}).reduce<Metadatas>(\n (acc, [name, { edit, list }]) => {\n const {\n __temp_key__,\n size: _size,\n name: _name,\n ...editedMetadata\n } = formData.layout.flatMap((row) => row.children).find((field) => field.name === name) ??\n {};\n\n acc[name] = {\n edit: {\n ...edit,\n ...editedMetadata,\n },\n list,\n };\n\n return acc;\n },\n {}\n );\n\n const res = await updateConfiguration({\n layouts: {\n edit: formData.layout.map((row) =>\n row.children.reduce<Array<{ name: string; size: number }>>((acc, { name, size }) => {\n if (name !== TEMP_FIELD_NAME) {\n return [...acc, { name, size }];\n }\n\n return acc;\n }, [])\n ),\n list: data?.component.layouts.list,\n },\n settings: setIn(formData.settings, 'displayName', undefined),\n metadatas: meta,\n uid: model,\n });\n\n if ('data' in res) {\n toggleNotification({\n type: 'success',\n message: formatMessage({ id: 'notification.success.saved', defaultMessage: 'Saved' }),\n });\n } else {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(res.error),\n });\n }\n } catch {\n toggleNotification({\n type: 'danger',\n message: formatMessage({ id: 'notification.error', defaultMessage: 'An error occurred' }),\n });\n }\n };\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (error || errorSchema || !schema) {\n return <Page.Error />;\n }\n\n return (\n <>\n <Page.Title>{`Configure ${editLayout.settings.displayName} Edit View`}</Page.Title>\n <ConfigurationForm\n onSubmit={handleSubmit}\n attributes={schema.attributes}\n fieldSizes={fieldSizes}\n layout={editLayout}\n />\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Header\n * -----------------------------------------------------------------------------------------------*/\n\nconst formatEditLayout = (\n data: FindComponentConfiguration.Response['data'],\n { schema, components }: { schema?: Component; components: ComponentsDictionary }\n) => {\n const editAttributes = convertEditLayoutToFieldLayouts(\n data.component.layouts.edit,\n schema?.attributes,\n data.component.metadatas,\n { configurations: data.components, schemas: components }\n );\n\n const componentEditAttributes = Object.entries(data.components).reduce<EditLayout['components']>(\n (acc, [uid, configuration]) => {\n const componentSchema = components[uid];\n if (!componentSchema) {\n return acc;\n }\n\n acc[uid] = {\n layout: convertEditLayoutToFieldLayouts(\n configuration.layouts.edit,\n componentSchema.attributes,\n configuration.metadatas\n ),\n settings: {\n ...configuration.settings,\n icon: componentSchema.info.icon,\n displayName: componentSchema.info.displayName,\n },\n };\n return acc;\n },\n {}\n );\n\n const editMetadatas = Object.entries(data.component.metadatas).reduce<EditLayout['metadatas']>(\n (acc, [attribute, metadata]) => {\n return {\n ...acc,\n [attribute]: metadata.edit,\n };\n },\n {}\n );\n\n return {\n layout: [editAttributes],\n components: componentEditAttributes,\n metadatas: editMetadatas,\n options: {\n ...schema?.options,\n ...schema?.pluginOptions,\n },\n settings: {\n ...data.component.settings,\n displayName: schema?.info.displayName,\n },\n };\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Header\n * -----------------------------------------------------------------------------------------------*/\n\nconst ProtectedComponentConfigurationPage = () => {\n const permissions = useTypedSelector(\n (state) => state.admin_app.permissions.contentManager?.componentsConfigurations\n );\n\n return (\n <Page.Protect permissions={permissions}>\n <ComponentConfigurationPage />\n </Page.Protect>\n );\n};\n\nexport { ComponentConfigurationPage, ProtectedComponentConfigurationPage };\n"],"names":["ComponentConfigurationPage","slug","model","useParams","toggleNotification","useNotification","formatMessage","useIntl","_unstableFormatAPIError","formatAPIError","useAPIErrorHandler","components","fieldSizes","schema","error","errorSchema","isLoading","isLoadingSchema","isFetching","isFetchingSchema","useGetInitialDataQuery","undefined","selectFromResult","res","data","find","ct","uid","componentsByKey","reduce","acc","component","extractContentTypeComponents","attributes","Object","entries","attributeName","default","size","React","useEffect","type","message","isLoadingConfig","isFetchingConfig","useGetComponentConfigurationQuery","editLayout","useMemo","formatEditLayout","layout","metadatas","options","settings","DEFAULT_SETTINGS","updateConfiguration","useUpdateComponentConfigurationMutation","handleSubmit","formData","meta","name","edit","list","__temp_key__","_size","_name","editedMetadata","flatMap","row","children","field","layouts","map","TEMP_FIELD_NAME","setIn","id","defaultMessage","_jsx","Page","Loading","Error","_jsxs","_Fragment","Title","displayName","ConfigurationForm","onSubmit","editAttributes","convertEditLayoutToFieldLayouts","configurations","schemas","componentEditAttributes","configuration","componentSchema","icon","info","editMetadatas","attribute","metadata","pluginOptions","ProtectedComponentConfigurationPage","permissions","useTypedSelector","state","admin_app","contentManager","componentsConfigurations","Protect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA;;AAEkG,2GAE5FA,0BAAAA,GAA6B,IAAA;AACjC;;;;;AAKC,MACD,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CAACI,cAAc,EAAEC,wBAAAA,CAAAA;IAGzD,qBACE7B,cAAA,CAACC,iBAAK6B,OAAO,EAAA;QAACN,WAAAA,EAAaA,WAAAA;AACzB,QAAA,QAAA,gBAAAxB,cAAA,CAAC5E,0BAAAA,EAAAA,EAAAA;;AAGP;;;;;"}
1
+ {"version":3,"file":"ComponentConfigurationPage.js","sources":["../../../admin/src/pages/ComponentConfigurationPage.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Page, useNotification, useAPIErrorHandler } from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\nimport { useParams } from 'react-router-dom';\n\nimport { TEMP_FIELD_NAME } from '../components/ConfigurationForm/Fields';\nimport { ConfigurationForm, ConfigurationFormProps } from '../components/ConfigurationForm/Form';\nimport { ComponentsDictionary, extractContentTypeComponents } from '../hooks/useContentTypeSchema';\nimport { DEFAULT_SETTINGS, EditLayout } from '../hooks/useDocumentLayout';\nimport { useTypedSelector } from '../modules/hooks';\nimport {\n useGetComponentConfigurationQuery,\n useUpdateComponentConfigurationMutation,\n} from '../services/components';\nimport { useGetInitialDataQuery } from '../services/init';\nimport { setIn } from '../utils/objects';\n\nimport { formatComponentConfigurationEditLayout } from './formatComponentConfigurationEditLayout';\n\nimport type { Component } from '../../../shared/contracts/components';\nimport type { Metadatas } from '../../../shared/contracts/content-types';\n\n/* -------------------------------------------------------------------------------------------------\n * ComponentConfigurationPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst ComponentConfigurationPage = () => {\n /**\n * useDocumentLayout only works for documents, not components,\n * it feels weird to make that hook work for both when this is SUCH\n * a unique use case and we only do it here, so in short, we essentially\n * just extracted the logic to make an edit view layout and reproduced it here.\n */\n const { slug: model } = useParams<{ slug: string }>();\n const { toggleNotification } = useNotification();\n const { formatMessage } = useIntl();\n const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();\n\n const {\n components,\n fieldSizes,\n schema,\n error: errorSchema,\n isLoading: isLoadingSchema,\n isFetching: isFetchingSchema,\n } = useGetInitialDataQuery(undefined, {\n selectFromResult: (res) => {\n const schema = res.data?.components.find((ct) => ct.uid === model);\n\n const componentsByKey = res.data?.components.reduce<ComponentsDictionary>(\n (acc, component) => {\n acc[component.uid] = component;\n\n return acc;\n },\n {}\n );\n\n const components = extractContentTypeComponents(schema?.attributes, componentsByKey);\n\n const fieldSizes = Object.entries(res.data?.fieldSizes ?? {}).reduce<\n ConfigurationFormProps['fieldSizes']\n >((acc, [attributeName, { default: size }]) => {\n acc[attributeName] = size;\n\n return acc;\n }, {});\n\n return {\n isFetching: res.isFetching,\n isLoading: res.isLoading,\n error: res.error,\n components,\n schema,\n fieldSizes,\n };\n },\n });\n\n React.useEffect(() => {\n if (errorSchema) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(errorSchema),\n });\n }\n }, [errorSchema, formatAPIError, toggleNotification]);\n\n const {\n data,\n isLoading: isLoadingConfig,\n isFetching: isFetchingConfig,\n error,\n } = useGetComponentConfigurationQuery(model ?? '');\n\n React.useEffect(() => {\n if (error) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(error),\n });\n }\n }, [error, formatAPIError, toggleNotification]);\n\n /**\n * you **must** check if we're loading or fetching in case the component gets new props\n * but nothing was unmounted, it then becomes a fetch, not a load.\n */\n const isLoading = isLoadingConfig || isLoadingSchema || isFetchingConfig || isFetchingSchema;\n\n const editLayout = React.useMemo(\n () =>\n data && !isLoading\n ? formatComponentConfigurationEditLayout(data, { schema, components })\n : ({\n layout: [],\n components: {},\n metadatas: {},\n options: {},\n settings: DEFAULT_SETTINGS,\n } as EditLayout),\n [data, isLoading, schema, components]\n );\n\n const [updateConfiguration] = useUpdateComponentConfigurationMutation();\n const handleSubmit: ConfigurationFormProps['onSubmit'] = async (formData) => {\n try {\n /**\n * We reconstruct the metadatas object by taking the existing list metadatas\n * and re-merging that by attribute name with the current list metadatas, whilst overwriting\n * the data from the form we've built.\n */\n const meta = Object.entries(data?.component.metadatas ?? {}).reduce<Metadatas>(\n (acc, [name, { edit, list }]) => {\n const {\n __temp_key__,\n size: _size,\n name: _name,\n ...editedMetadata\n } = formData.layout.flatMap((row) => row.children).find((field) => field.name === name) ??\n {};\n\n acc[name] = {\n edit: {\n ...edit,\n ...editedMetadata,\n },\n list,\n };\n\n return acc;\n },\n {}\n );\n\n const res = await updateConfiguration({\n layouts: {\n edit: formData.layout.map((row) =>\n row.children.reduce<Array<{ name: string; size: number }>>((acc, { name, size }) => {\n if (name !== TEMP_FIELD_NAME) {\n return [...acc, { name, size }];\n }\n\n return acc;\n }, [])\n ),\n list: data?.component.layouts.list,\n },\n settings: setIn(formData.settings, 'displayName', undefined),\n metadatas: meta,\n uid: model,\n });\n\n if ('data' in res) {\n toggleNotification({\n type: 'success',\n message: formatMessage({ id: 'notification.success.saved', defaultMessage: 'Saved' }),\n });\n } else {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(res.error),\n });\n }\n } catch {\n toggleNotification({\n type: 'danger',\n message: formatMessage({ id: 'notification.error', defaultMessage: 'An error occurred' }),\n });\n }\n };\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (error || errorSchema || !schema) {\n return <Page.Error />;\n }\n\n return (\n <>\n <Page.Title>{`Configure ${editLayout.settings.displayName} Edit View`}</Page.Title>\n <ConfigurationForm\n onSubmit={handleSubmit}\n attributes={schema.attributes}\n fieldSizes={fieldSizes}\n layout={editLayout}\n />\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Header\n * -----------------------------------------------------------------------------------------------*/\n\nconst ProtectedComponentConfigurationPage = () => {\n const permissions = useTypedSelector(\n (state) => state.admin_app.permissions.contentManager?.componentsConfigurations\n );\n\n return (\n <Page.Protect permissions={permissions}>\n <ComponentConfigurationPage />\n </Page.Protect>\n );\n};\n\nexport { ComponentConfigurationPage, ProtectedComponentConfigurationPage };\n"],"names":["ComponentConfigurationPage","slug","model","useParams","toggleNotification","useNotification","formatMessage","useIntl","_unstableFormatAPIError","formatAPIError","useAPIErrorHandler","components","fieldSizes","schema","error","errorSchema","isLoading","isLoadingSchema","isFetching","isFetchingSchema","useGetInitialDataQuery","undefined","selectFromResult","res","data","find","ct","uid","componentsByKey","reduce","acc","component","extractContentTypeComponents","attributes","Object","entries","attributeName","default","size","React","useEffect","type","message","isLoadingConfig","isFetchingConfig","useGetComponentConfigurationQuery","editLayout","useMemo","formatComponentConfigurationEditLayout","layout","metadatas","options","settings","DEFAULT_SETTINGS","updateConfiguration","useUpdateComponentConfigurationMutation","handleSubmit","formData","meta","name","edit","list","__temp_key__","_size","_name","editedMetadata","flatMap","row","children","field","layouts","map","TEMP_FIELD_NAME","setIn","id","defaultMessage","_jsx","Page","Loading","Error","_jsxs","_Fragment","Title","displayName","ConfigurationForm","onSubmit","ProtectedComponentConfigurationPage","permissions","useTypedSelector","state","admin_app","contentManager","componentsConfigurations","Protect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA;;AAEkG,2GAE5FA,0BAAAA,GAA6B,IAAA;AACjC;;;;;AAKC,MACD,MAAM,EAAEC,IAAAA,EAAMC,KAAK,EAAE,GAAGC,wBAAAA,EAAAA;IACxB,MAAM,EAAEC,kBAAkB,EAAE,GAAGC,2BAAAA,EAAAA;IAC/B,MAAM,EAAEC,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;AAC1B,IAAA,MAAM,EAAEC,uBAAAA,EAAyBC,cAAc,EAAE,GAAGC,8BAAAA,EAAAA;AAEpD,IAAA,MAAM,cACJC,YAAU,EACVC,UAAU,EACVC,MAAM,EACNC,KAAAA,EAAOC,WAAW,EAClBC,SAAAA,EAAWC,eAAe,EAC1BC,UAAAA,EAAYC,gBAAgB,EAC7B,GAAGC,4BAAuBC,SAAAA,EAAW;AACpCC,QAAAA,gBAAAA,EAAkB,CAACC,GAAAA,GAAAA;YACjB,MAAMV,MAAAA,GAASU,GAAAA,CAAIC,IAAI,EAAEb,UAAAA,CAAWc,KAAK,CAACC,EAAAA,GAAOA,EAAAA,CA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AAAA,EAAQH;;;;AAIhB;AAEA;;AAEkG,2GAE5FwC,mCAAAA,GAAsC,IAAA;IAC1C,MAAMC,WAAAA,GAAcC,sBAAAA,CAClB,CAACC,KAAAA,GAAUA,KAAAA,CAAMC,SAAS,CAACH,WAAW,CAACI,cAAc,EAAEC,wBAAAA,CAAAA;IAGzD,qBACEhB,cAAA,CAACC,iBAAKgB,OAAO,EAAA;QAACN,WAAAA,EAAaA,WAAAA;AACzB,QAAA,QAAA,gBAAAX,cAAA,CAAC5E,0BAAAA,EAAAA,EAAAA;;AAGP;;;;;"}
@@ -6,11 +6,12 @@ import { useParams } from 'react-router-dom';
6
6
  import { TEMP_FIELD_NAME } from '../components/ConfigurationForm/Fields.mjs';
7
7
  import { ConfigurationForm } from '../components/ConfigurationForm/Form.mjs';
8
8
  import { extractContentTypeComponents } from '../hooks/useContentTypeSchema.mjs';
9
- import { DEFAULT_SETTINGS, convertEditLayoutToFieldLayouts } from '../hooks/useDocumentLayout.mjs';
9
+ import { DEFAULT_SETTINGS } from '../hooks/useDocumentLayout.mjs';
10
10
  import { useTypedSelector } from '../modules/hooks.mjs';
11
11
  import { useGetComponentConfigurationQuery, useUpdateComponentConfigurationMutation } from '../services/components.mjs';
12
12
  import { useGetInitialDataQuery } from '../services/init.mjs';
13
13
  import { setIn } from '../utils/objects.mjs';
14
+ import { formatComponentConfigurationEditLayout } from './formatComponentConfigurationEditLayout.mjs';
14
15
 
15
16
  /* -------------------------------------------------------------------------------------------------
16
17
  * ComponentConfigurationPage
@@ -75,7 +76,7 @@ import { setIn } from '../utils/objects.mjs';
75
76
  * you **must** check if we're loading or fetching in case the component gets new props
76
77
  * but nothing was unmounted, it then becomes a fetch, not a load.
77
78
  */ const isLoading = isLoadingConfig || isLoadingSchema || isFetchingConfig || isFetchingSchema;
78
- const editLayout = React.useMemo(()=>data && !isLoading ? formatEditLayout(data, {
79
+ const editLayout = React.useMemo(()=>data && !isLoading ? formatComponentConfigurationEditLayout(data, {
79
80
  schema,
80
81
  components
81
82
  }) : {
@@ -172,50 +173,6 @@ import { setIn } from '../utils/objects.mjs';
172
173
  ]
173
174
  });
174
175
  };
175
- /* -------------------------------------------------------------------------------------------------
176
- * Header
177
- * -----------------------------------------------------------------------------------------------*/ const formatEditLayout = (data, { schema, components })=>{
178
- const editAttributes = convertEditLayoutToFieldLayouts(data.component.layouts.edit, schema?.attributes, data.component.metadatas, {
179
- configurations: data.components,
180
- schemas: components
181
- });
182
- const componentEditAttributes = Object.entries(data.components).reduce((acc, [uid, configuration])=>{
183
- const componentSchema = components[uid];
184
- if (!componentSchema) {
185
- return acc;
186
- }
187
- acc[uid] = {
188
- layout: convertEditLayoutToFieldLayouts(configuration.layouts.edit, componentSchema.attributes, configuration.metadatas),
189
- settings: {
190
- ...configuration.settings,
191
- icon: componentSchema.info.icon,
192
- displayName: componentSchema.info.displayName
193
- }
194
- };
195
- return acc;
196
- }, {});
197
- const editMetadatas = Object.entries(data.component.metadatas).reduce((acc, [attribute, metadata])=>{
198
- return {
199
- ...acc,
200
- [attribute]: metadata.edit
201
- };
202
- }, {});
203
- return {
204
- layout: [
205
- editAttributes
206
- ],
207
- components: componentEditAttributes,
208
- metadatas: editMetadatas,
209
- options: {
210
- ...schema?.options,
211
- ...schema?.pluginOptions
212
- },
213
- settings: {
214
- ...data.component.settings,
215
- displayName: schema?.info.displayName
216
- }
217
- };
218
- };
219
176
  /* -------------------------------------------------------------------------------------------------
220
177
  * Header
221
178
  * -----------------------------------------------------------------------------------------------*/ const ProtectedComponentConfigurationPage = ()=>{
@@ -1 +1 @@
1
- {"version":3,"file":"ComponentConfigurationPage.mjs","sources":["../../../admin/src/pages/ComponentConfigurationPage.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Page, useNotification, useAPIErrorHandler } from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\nimport { useParams } from 'react-router-dom';\n\nimport { TEMP_FIELD_NAME } from '../components/ConfigurationForm/Fields';\nimport { ConfigurationForm, ConfigurationFormProps } from '../components/ConfigurationForm/Form';\nimport { ComponentsDictionary, extractContentTypeComponents } from '../hooks/useContentTypeSchema';\nimport {\n DEFAULT_SETTINGS,\n EditLayout,\n convertEditLayoutToFieldLayouts,\n} from '../hooks/useDocumentLayout';\nimport { useTypedSelector } from '../modules/hooks';\nimport {\n useGetComponentConfigurationQuery,\n useUpdateComponentConfigurationMutation,\n} from '../services/components';\nimport { useGetInitialDataQuery } from '../services/init';\nimport { setIn } from '../utils/objects';\n\nimport type { Component, FindComponentConfiguration } from '../../../shared/contracts/components';\nimport type { Metadatas } from '../../../shared/contracts/content-types';\n\n/* -------------------------------------------------------------------------------------------------\n * ComponentConfigurationPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst ComponentConfigurationPage = () => {\n /**\n * useDocumentLayout only works for documents, not components,\n * it feels weird to make that hook work for both when this is SUCH\n * a unique use case and we only do it here, so in short, we essentially\n * just extracted the logic to make an edit view layout and reproduced it here.\n */\n const { slug: model } = useParams<{ slug: string }>();\n const { toggleNotification } = useNotification();\n const { formatMessage } = useIntl();\n const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();\n\n const {\n components,\n fieldSizes,\n schema,\n error: errorSchema,\n isLoading: isLoadingSchema,\n isFetching: isFetchingSchema,\n } = useGetInitialDataQuery(undefined, {\n selectFromResult: (res) => {\n const schema = res.data?.components.find((ct) => ct.uid === model);\n\n const componentsByKey = res.data?.components.reduce<ComponentsDictionary>(\n (acc, component) => {\n acc[component.uid] = component;\n\n return acc;\n },\n {}\n );\n\n const components = extractContentTypeComponents(schema?.attributes, componentsByKey);\n\n const fieldSizes = Object.entries(res.data?.fieldSizes ?? {}).reduce<\n ConfigurationFormProps['fieldSizes']\n >((acc, [attributeName, { default: size }]) => {\n acc[attributeName] = size;\n\n return acc;\n }, {});\n\n return {\n isFetching: res.isFetching,\n isLoading: res.isLoading,\n error: res.error,\n components,\n schema,\n fieldSizes,\n };\n },\n });\n\n React.useEffect(() => {\n if (errorSchema) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(errorSchema),\n });\n }\n }, [errorSchema, formatAPIError, toggleNotification]);\n\n const {\n data,\n isLoading: isLoadingConfig,\n isFetching: isFetchingConfig,\n error,\n } = useGetComponentConfigurationQuery(model ?? '');\n\n React.useEffect(() => {\n if (error) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(error),\n });\n }\n }, [error, formatAPIError, toggleNotification]);\n\n /**\n * you **must** check if we're loading or fetching in case the component gets new props\n * but nothing was unmounted, it then becomes a fetch, not a load.\n */\n const isLoading = isLoadingConfig || isLoadingSchema || isFetchingConfig || isFetchingSchema;\n\n const editLayout = React.useMemo(\n () =>\n data && !isLoading\n ? formatEditLayout(data, { schema, components })\n : ({\n layout: [],\n components: {},\n metadatas: {},\n options: {},\n settings: DEFAULT_SETTINGS,\n } as EditLayout),\n [data, isLoading, schema, components]\n );\n\n const [updateConfiguration] = useUpdateComponentConfigurationMutation();\n const handleSubmit: ConfigurationFormProps['onSubmit'] = async (formData) => {\n try {\n /**\n * We reconstruct the metadatas object by taking the existing list metadatas\n * and re-merging that by attribute name with the current list metadatas, whilst overwriting\n * the data from the form we've built.\n */\n const meta = Object.entries(data?.component.metadatas ?? {}).reduce<Metadatas>(\n (acc, [name, { edit, list }]) => {\n const {\n __temp_key__,\n size: _size,\n name: _name,\n ...editedMetadata\n } = formData.layout.flatMap((row) => row.children).find((field) => field.name === name) ??\n {};\n\n acc[name] = {\n edit: {\n ...edit,\n ...editedMetadata,\n },\n list,\n };\n\n return acc;\n },\n {}\n );\n\n const res = await updateConfiguration({\n layouts: {\n edit: formData.layout.map((row) =>\n row.children.reduce<Array<{ name: string; size: number }>>((acc, { name, size }) => {\n if (name !== TEMP_FIELD_NAME) {\n return [...acc, { name, size }];\n }\n\n return acc;\n }, [])\n ),\n list: data?.component.layouts.list,\n },\n settings: setIn(formData.settings, 'displayName', undefined),\n metadatas: meta,\n uid: model,\n });\n\n if ('data' in res) {\n toggleNotification({\n type: 'success',\n message: formatMessage({ id: 'notification.success.saved', defaultMessage: 'Saved' }),\n });\n } else {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(res.error),\n });\n }\n } catch {\n toggleNotification({\n type: 'danger',\n message: formatMessage({ id: 'notification.error', defaultMessage: 'An error occurred' }),\n });\n }\n };\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (error || errorSchema || !schema) {\n return <Page.Error />;\n }\n\n return (\n <>\n <Page.Title>{`Configure ${editLayout.settings.displayName} Edit View`}</Page.Title>\n <ConfigurationForm\n onSubmit={handleSubmit}\n attributes={schema.attributes}\n fieldSizes={fieldSizes}\n layout={editLayout}\n />\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Header\n * -----------------------------------------------------------------------------------------------*/\n\nconst formatEditLayout = (\n data: FindComponentConfiguration.Response['data'],\n { schema, components }: { schema?: Component; components: ComponentsDictionary }\n) => {\n const editAttributes = convertEditLayoutToFieldLayouts(\n data.component.layouts.edit,\n schema?.attributes,\n data.component.metadatas,\n { configurations: data.components, schemas: components }\n );\n\n const componentEditAttributes = Object.entries(data.components).reduce<EditLayout['components']>(\n (acc, [uid, configuration]) => {\n const componentSchema = components[uid];\n if (!componentSchema) {\n return acc;\n }\n\n acc[uid] = {\n layout: convertEditLayoutToFieldLayouts(\n configuration.layouts.edit,\n componentSchema.attributes,\n configuration.metadatas\n ),\n settings: {\n ...configuration.settings,\n icon: componentSchema.info.icon,\n displayName: componentSchema.info.displayName,\n },\n };\n return acc;\n },\n {}\n );\n\n const editMetadatas = Object.entries(data.component.metadatas).reduce<EditLayout['metadatas']>(\n (acc, [attribute, metadata]) => {\n return {\n ...acc,\n [attribute]: metadata.edit,\n };\n },\n {}\n );\n\n return {\n layout: [editAttributes],\n components: componentEditAttributes,\n metadatas: editMetadatas,\n options: {\n ...schema?.options,\n ...schema?.pluginOptions,\n },\n settings: {\n ...data.component.settings,\n displayName: schema?.info.displayName,\n },\n };\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Header\n * -----------------------------------------------------------------------------------------------*/\n\nconst ProtectedComponentConfigurationPage = () => {\n const permissions = useTypedSelector(\n (state) => state.admin_app.permissions.contentManager?.componentsConfigurations\n );\n\n return (\n <Page.Protect permissions={permissions}>\n <ComponentConfigurationPage />\n </Page.Protect>\n );\n};\n\nexport { ComponentConfigurationPage, ProtectedComponentConfigurationPage };\n"],"names":["ComponentConfigurationPage","slug","model","useParams","toggleNotification","useNotification","formatMessage","useIntl","_unstableFormatAPIError","formatAPIError","useAPIErrorHandler","components","fieldSizes","schema","error","errorSchema","isLoading","isLoadingSchema","isFetching","isFetchingSchema","useGetInitialDataQuery","undefined","selectFromResult","res","data","find","ct","uid","componentsByKey","reduce","acc","component","extractContentTypeComponents","attributes","Object","entries","attributeName","default","size","React","useEffect","type","message","isLoadingConfig","isFetchingConfig","useGetComponentConfigurationQuery","editLayout","useMemo","formatEditLayout","layout","metadatas","options","settings","DEFAULT_SETTINGS","updateConfiguration","useUpdateComponentConfigurationMutation","handleSubmit","formData","meta","name","edit","list","__temp_key__","_size","_name","editedMetadata","flatMap","row","children","field","layouts","map","TEMP_FIELD_NAME","setIn","id","defaultMessage","_jsx","Page","Loading","Error","_jsxs","_Fragment","Title","displayName","ConfigurationForm","onSubmit","editAttributes","convertEditLayoutToFieldLayouts","configurations","schemas","componentEditAttributes","configuration","componentSchema","icon","info","editMetadatas","attribute","metadata","pluginOptions","ProtectedComponentConfigurationPage","permissions","useTypedSelector","state","admin_app","contentManager","componentsConfigurations","Protect"],"mappings":";;;;;;;;;;;;;;AAyBA;;AAEkG,2GAE5FA,0BAAAA,GAA6B,IAAA;AACjC;;;;;AAKC,MACD,MAAM,EAAEC,IAAAA,EAAMC,KAAK,EAAE,GAAGC,SAAAA,EAAAA;IACxB,MAAM,EAAEC,kBAAkB,EAAE,GAAGC,eAAAA,EAAAA;IAC/B,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;AAC1B,IAAA,MAAM,EAAEC,uBAAA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Page.mjs","sources":["../../../admin/src/pages/ComponentConfigurationPage.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Page, useNotification, useAPIErrorHandler } from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\nimport { useParams } from 'react-router-dom';\n\nimport { TEMP_FIELD_NAME } from '../components/ConfigurationForm/Fields';\nimport { ConfigurationForm, ConfigurationFormProps } from '../components/ConfigurationForm/Form';\nimport { ComponentsDictionary, extractContentTypeComponents } from '../hooks/useContentTypeSchema';\nimport { DEFAULT_SETTINGS, EditLayout } from '../hooks/useDocumentLayout';\nimport { useTypedSelector } from '../modules/hooks';\nimport {\n useGetComponentConfigurationQuery,\n useUpdateComponentConfigurationMutation,\n} from '../services/components';\nimport { useGetInitialDataQuery } from '../services/init';\nimport { setIn } from '../utils/objects';\n\nimport { formatComponentConfigurationEditLayout } from './formatComponentConfigurationEditLayout';\n\nimport type { Component } from '../../../shared/contracts/components';\nimport type { Metadatas } from '../../../shared/contracts/content-types';\n\n/* -------------------------------------------------------------------------------------------------\n * ComponentConfigurationPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst ComponentConfigurationPage = () => {\n /**\n * useDocumentLayout only works for documents, not components,\n * it feels weird to make that hook work for both when this is SUCH\n * a unique use case and we only do it here, so in short, we essentially\n * just extracted the logic to make an edit view layout and reproduced it here.\n */\n const { slug: model } = useParams<{ slug: string }>();\n const { toggleNotification } = useNotification();\n const { formatMessage } = useIntl();\n const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();\n\n const {\n components,\n fieldSizes,\n schema,\n error: errorSchema,\n isLoading: isLoadingSchema,\n isFetching: isFetchingSchema,\n } = useGetInitialDataQuery(undefined, {\n selectFromResult: (res) => {\n const schema = res.data?.components.find((ct) => ct.uid === model);\n\n const componentsByKey = res.data?.components.reduce<ComponentsDictionary>(\n (acc, component) => {\n acc[component.uid] = component;\n\n return acc;\n },\n {}\n );\n\n const components = extractContentTypeComponents(schema?.attributes, componentsByKey);\n\n const fieldSizes = Object.entries(res.data?.fieldSizes ?? {}).reduce<\n ConfigurationFormProps['fieldSizes']\n >((acc, [attributeName, { default: size }]) => {\n acc[attributeName] = size;\n\n return acc;\n }, {});\n\n return {\n isFetching: res.isFetching,\n isLoading: res.isLoading,\n error: res.error,\n components,\n schema,\n fieldSizes,\n };\n },\n });\n\n React.useEffect(() => {\n if (errorSchema) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(errorSchema),\n });\n }\n }, [errorSchema, formatAPIError, toggleNotification]);\n\n const {\n data,\n isLoading: isLoadingConfig,\n isFetching: isFetchingConfig,\n error,\n } = useGetComponentConfigurationQuery(model ?? '');\n\n React.useEffect(() => {\n if (error) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(error),\n });\n }\n }, [error, formatAPIError, toggleNotification]);\n\n /**\n * you **must** check if we're loading or fetching in case the component gets new props\n * but nothing was unmounted, it then becomes a fetch, not a load.\n */\n const isLoading = isLoadingConfig || isLoadingSchema || isFetchingConfig || isFetchingSchema;\n\n const editLayout = React.useMemo(\n () =>\n data && !isLoading\n ? formatComponentConfigurationEditLayout(data, { schema, components })\n : ({\n layout: [],\n components: {},\n metadatas: {},\n options: {},\n settings: DEFAULT_SETTINGS,\n } as EditLayout),\n [data, isLoading, schema, components]\n );\n\n const [updateConfiguration] = useUpdateComponentConfigurationMutation();\n const handleSubmit: ConfigurationFormProps['onSubmit'] = async (formData) => {\n try {\n /**\n * We reconstruct the metadatas object by taking the existing list metadatas\n * and re-merging that by attribute name with the current list metadatas, whilst overwriting\n * the data from the form we've built.\n */\n const meta = Object.entries(data?.component.metadatas ?? {}).reduce<Metadatas>(\n (acc, [name, { edit, list }]) => {\n const {\n __temp_key__,\n size: _size,\n name: _name,\n ...editedMetadata\n } = formData.layout.flatMap((row) => row.children).find((field) => field.name === name) ??\n {};\n\n acc[name] = {\n edit: {\n ...edit,\n ...editedMetadata,\n },\n list,\n };\n\n return acc;\n },\n {}\n );\n\n const res = await updateConfiguration({\n layouts: {\n edit: formData.layout.map((row) =>\n row.children.reduce<Array<{ name: string; size: number }>>((acc, { name, size }) => {\n if (name !== TEMP_FIELD_NAME) {\n return [...acc, { name, size }];\n }\n\n return acc;\n }, [])\n ),\n list: data?.component.layouts.list,\n },\n settings: setIn(formData.settings, 'displayName', undefined),\n metadatas: meta,\n uid: model,\n });\n\n if ('data' in res) {\n toggleNotification({\n type: 'success',\n message: formatMessage({ id: 'notification.success.saved', defaultMessage: 'Saved' }),\n });\n } else {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(res.error),\n });\n }\n } catch {\n toggleNotification({\n type: 'danger',\n message: formatMessage({ id: 'notification.error', defaultMessage: 'An error occurred' }),\n });\n }\n };\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (error || errorSchema || !schema) {\n return <Page.Error />;\n }\n\n return (\n <>\n <Page.Title>{`Configure ${editLayout.settings.displayName} Edit View`}</Page.Title>\n <ConfigurationForm\n onSubmit={handleSubmit}\n attributes={schema.attributes}\n fieldSizes={fieldSizes}\n layout={editLayout}\n />\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Header\n * -----------------------------------------------------------------------------------------------*/\n\nconst ProtectedComponentConfigurationPage = () => {\n const permissions = useTypedSelector(\n (state) => state.admin_app.permissions.contentManager?.componentsConfigurations\n );\n\n return (\n <Page.Protect permissions={permissions}>\n <ComponentConfigurationPage />\n </Page.Protect>\n );\n};\n\nexport { ComponentConfigurationPage, ProtectedComponentConfigurationPage };\n"],"names":["ComponentConfigurationPage","slug","model","useParams","toggleNotification","useNotification","formatMessage","useIntl","_unstableFormatAPIError","formatAPIError","useAPIErrorHandler","components","fieldSizes","schema","error","errorSchema","isLoading","isLoadingSchema","isFetching","isFetchingSchema","useGetInitialDataQuery","undefined","selectFromResult","res","data","find","ct","uid","componentsByKey","reduce","acc","component","extractContentTypeComponents","attributes","Object","entries","attributeName","default","size","React","useEffect","type","message","isLoadingConfig","isFetchingConfig","useGetComponentConfigurationQuery","editLayout","useMemo","formatComponentConfigurationEditLayout","layout","metadatas","options","settings","DEFAULT_SETTINGS","updateConfiguration","useUpdateComponentConfigurationMutation","handleSubmit","formData","meta","name","edit","list","__temp_key__","_size","_name","editedMetadata","flatMap","row","children","field","layouts","map","TEMP_FIELD_NAME","setIn","id","defaultMessage","_jsx","Page","Loading","Error","_jsxs","_Fragment","Title","displayName","ConfigurationForm","onSubmit","ProtectedComponentConfigurationPage","permissions","useTypedSelector","state","admin_app","contentManager","componentsConfigurations","Protect"],"mappings":";;;;;;;;;;;;;;;AAuBA;;AAEkG,2GAE5FA,0BAAAA,GAA6B,IAAA;AACjC;;;;;AAKC,MACD,MAAM,EAAEC,IAAAA,EAAMC,KAAK,EAAE,GAAGC,SAAAA,EAAAA;IACxB,MAAM,EAAEC,kBAAkB,EAAE,GAAGC,eAAAA,EAAAA;IAC/B,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;AAC1B,IAAA,MAAM,EAAEC,uBAAAA,EAAyBC,cAAc,EAAE,GAAGC,kBAAAA,EAAAA;AAEpD,IAAA,MAAM,EACJC,UAAU,EACVC,UAAU,EACVC,MAAM,EACNC,KAAAA,EAAOC,WAAW,EAClBC,SAAAA,EAAWC,eAAe,EAC1BC,UAAAA,EAAYC,gBAAgB,EAC7B,GAAGC,uBAAuBC,SAAAA,EAAW;AACpCC,QAAAA,gBAAAA,EAAkB,CAACC,GAAAA,GAAAA;YACjB,MAAMV,MAAAA,GAASU,GAAAA,CAAIC,IAAI,EAAEb,UAAAA,CAAWc,KAAK,CAACC,EAAAA,GAAOA,EAAAA,CAAGC,GAAG,KAAKzB,KAAAA,CAAAA;AAE5D,YAAA,MAAM0B,kBAAkBL,GAAAA,CAAIC,IAAI,EAAEb,UAAAA,CAAWkB,MAAAA,CAC3C,CAACC,GAAAA,EAAKC,SAAAA,GAAAA;AACJD,gBAAAA,GAAG,CAACC,SAAAA,CAAUJ,GAAG,CAAC,GAAGI,SAAAA;gBAErB,OAAOD,GAAAA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AAAA,EAAaA,WAAAA;AACzB,QAAA,QAAA,gBAAAX,GAAA,CAAC5E,0BAAAA,EAAAA,EAAAA;;AAGP;;;;"}
@@ -121,13 +121,13 @@ const EMPTY_RELATION_RESULTS = [];
121
121
  }, [
122
122
  isSubmitting
123
123
  ]);
124
- const component = componentUID && currentDocument.components[componentUID];
124
+ const component = componentUID ? currentDocument.components[componentUID] : undefined;
125
125
  /**
126
126
  * We'll always have a documentId in a created entry, so we look for a componentId first.
127
127
  * Same with `uid` and `documentModel`.
128
128
  * The componentId is empty when adding a new component in a repeatable. Let it be null to skip isRelatedToCurrentDocument
129
- */ const model = component ? component.uid : currentDocumentMeta.model;
130
- const id = component ? componentId?.toString() : documentId;
129
+ */ const model = componentUID || currentDocumentMeta.model;
130
+ const id = componentUID ? componentId?.toString() : documentId;
131
131
  /**
132
132
  * The `name` prop is a complete path to the field, e.g. `field1.field2.field3`.
133
133
  * Where the above example would a nested field within two components, however
@@ -271,7 +271,7 @@ const EMPTY_RELATION_RESULTS = [];
271
271
  /*#__PURE__*/ jsxRuntime.jsx(MemoizedRelationsComboboxInput, {
272
272
  disabled: isDisabled,
273
273
  // NOTE: we should not default to using the documentId if the component is being created (componentUID is undefined)
274
- id: componentUID && component ? componentId ? `${componentId}` : '' : documentId,
274
+ id: id,
275
275
  label: `${label} ${relationsCount > 0 ? `(${relationsCount})` : ''}`,
276
276
  model: model,
277
277
  onChange: handleConnect,