@strapi/content-manager 5.58.0 → 5.60.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.
- package/dist/admin/components/ConfigurationForm/Fields.js +4 -3
- package/dist/admin/components/ConfigurationForm/Fields.js.map +1 -1
- package/dist/admin/components/ConfigurationForm/Fields.mjs +4 -3
- package/dist/admin/components/ConfigurationForm/Fields.mjs.map +1 -1
- package/dist/admin/components/RelativeTime.js +2 -1
- package/dist/admin/components/RelativeTime.js.map +1 -1
- package/dist/admin/components/RelativeTime.mjs +2 -1
- package/dist/admin/components/RelativeTime.mjs.map +1 -1
- package/dist/admin/content-manager.js.map +1 -1
- package/dist/admin/content-manager.mjs.map +1 -1
- package/dist/admin/history/components/VersionContent.js +8 -8
- package/dist/admin/history/components/VersionContent.js.map +1 -1
- package/dist/admin/history/components/VersionContent.mjs +8 -8
- package/dist/admin/history/components/VersionContent.mjs.map +1 -1
- package/dist/admin/history/components/VersionInputRenderer.js +2 -1
- package/dist/admin/history/components/VersionInputRenderer.js.map +1 -1
- package/dist/admin/history/components/VersionInputRenderer.mjs +2 -1
- package/dist/admin/history/components/VersionInputRenderer.mjs.map +1 -1
- package/dist/admin/hooks/useDocumentActions.js.map +1 -1
- package/dist/admin/hooks/useDocumentActions.mjs.map +1 -1
- package/dist/admin/hooks/useDocumentLayout.js.map +1 -1
- package/dist/admin/hooks/useDocumentLayout.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Input.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Input.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.js +3 -2
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.mjs +3 -2
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js +8 -6
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs +8 -6
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.js +2 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.mjs +2 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentPicker.js +2 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentPicker.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentPicker.mjs +2 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentPicker.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js +6 -3
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs +6 -3
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +4 -4
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +4 -4
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/UID.js +2 -1
- package/dist/admin/pages/EditView/components/FormInputs/UID.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/UID.mjs +2 -1
- package/dist/admin/pages/EditView/components/FormInputs/UID.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Editor.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Editor.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormLayout.js +5 -4
- package/dist/admin/pages/EditView/components/FormLayout.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormLayout.mjs +5 -4
- package/dist/admin/pages/EditView/components/FormLayout.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/InputRenderer.js +3 -1
- package/dist/admin/pages/EditView/components/InputRenderer.js.map +1 -1
- package/dist/admin/pages/EditView/components/InputRenderer.mjs +3 -1
- package/dist/admin/pages/EditView/components/InputRenderer.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/Panels.js.map +1 -1
- package/dist/admin/pages/EditView/components/Panels.mjs.map +1 -1
- package/dist/admin/pages/EditView/utils/data.js +3 -3
- package/dist/admin/pages/EditView/utils/data.js.map +1 -1
- package/dist/admin/pages/EditView/utils/data.mjs +3 -3
- package/dist/admin/pages/EditView/utils/data.mjs.map +1 -1
- package/dist/admin/pages/ListConfiguration/components/Settings.js +3 -3
- package/dist/admin/pages/ListConfiguration/components/Settings.js.map +1 -1
- package/dist/admin/pages/ListConfiguration/components/Settings.mjs +3 -3
- package/dist/admin/pages/ListConfiguration/components/Settings.mjs.map +1 -1
- package/dist/admin/pages/ListConfiguration/components/SortDisplayedFields.js +2 -2
- package/dist/admin/pages/ListConfiguration/components/SortDisplayedFields.js.map +1 -1
- package/dist/admin/pages/ListConfiguration/components/SortDisplayedFields.mjs +2 -2
- package/dist/admin/pages/ListConfiguration/components/SortDisplayedFields.mjs.map +1 -1
- package/dist/admin/pages/ListView/ListViewPage.js +73 -13
- package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
- package/dist/admin/pages/ListView/ListViewPage.mjs +74 -14
- package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
- package/dist/admin/pages/ListView/components/AutoCloneFailureModal.js +1 -1
- package/dist/admin/pages/ListView/components/AutoCloneFailureModal.js.map +1 -1
- package/dist/admin/pages/ListView/components/AutoCloneFailureModal.mjs +1 -1
- package/dist/admin/pages/ListView/components/AutoCloneFailureModal.mjs.map +1 -1
- package/dist/admin/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.js.map +1 -1
- package/dist/admin/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.mjs.map +1 -1
- package/dist/admin/pages/ListView/components/BulkActions/PublishAction.js +4 -1
- package/dist/admin/pages/ListView/components/BulkActions/PublishAction.js.map +1 -1
- package/dist/admin/pages/ListView/components/BulkActions/PublishAction.mjs +4 -1
- package/dist/admin/pages/ListView/components/BulkActions/PublishAction.mjs.map +1 -1
- package/dist/admin/pages/ListView/components/Filters.js +12 -10
- package/dist/admin/pages/ListView/components/Filters.js.map +1 -1
- package/dist/admin/pages/ListView/components/Filters.mjs +12 -10
- package/dist/admin/pages/ListView/components/Filters.mjs.map +1 -1
- package/dist/admin/pages/ListView/components/TableCells/Relations.js.map +1 -1
- package/dist/admin/pages/ListView/components/TableCells/Relations.mjs.map +1 -1
- package/dist/admin/pages/ListView/components/ViewSettingsMenu.js +2 -1
- package/dist/admin/pages/ListView/components/ViewSettingsMenu.js.map +1 -1
- package/dist/admin/pages/ListView/components/ViewSettingsMenu.mjs +2 -1
- package/dist/admin/pages/ListView/components/ViewSettingsMenu.mjs.map +1 -1
- package/dist/admin/pages/ListView/utils/applyAttributeRenames.js +68 -0
- package/dist/admin/pages/ListView/utils/applyAttributeRenames.js.map +1 -0
- package/dist/admin/pages/ListView/utils/applyAttributeRenames.mjs +64 -0
- package/dist/admin/pages/ListView/utils/applyAttributeRenames.mjs.map +1 -0
- package/dist/admin/preview/components/PreviewHeader.js +3 -1
- package/dist/admin/preview/components/PreviewHeader.js.map +1 -1
- package/dist/admin/preview/components/PreviewHeader.mjs +3 -1
- package/dist/admin/preview/components/PreviewHeader.mjs.map +1 -1
- package/dist/admin/preview/components/PreviewSidePanel.js +2 -1
- package/dist/admin/preview/components/PreviewSidePanel.js.map +1 -1
- package/dist/admin/preview/components/PreviewSidePanel.mjs +2 -1
- package/dist/admin/preview/components/PreviewSidePanel.mjs.map +1 -1
- package/dist/admin/preview/utils/getPreviewUrlStatus.js +17 -0
- package/dist/admin/preview/utils/getPreviewUrlStatus.js.map +1 -0
- package/dist/admin/preview/utils/getPreviewUrlStatus.mjs +15 -0
- package/dist/admin/preview/utils/getPreviewUrlStatus.mjs.map +1 -0
- package/dist/admin/services/relations.js +2 -2
- package/dist/admin/services/relations.js.map +1 -1
- package/dist/admin/services/relations.mjs +2 -2
- package/dist/admin/services/relations.mjs.map +1 -1
- package/dist/admin/src/components/ConfigurationForm/Fields.d.ts +1 -1
- package/dist/admin/src/history/components/VersionInputRenderer.d.ts +3 -1
- package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +2 -0
- package/dist/admin/src/pages/ListView/utils/applyAttributeRenames.d.ts +12 -0
- package/dist/admin/src/preview/utils/getPreviewUrlStatus.d.ts +6 -0
- package/dist/admin/translations/eu.json.js +3 -3
- package/dist/admin/translations/eu.json.mjs +3 -3
- package/dist/admin/translations/gu.json.js +4 -4
- package/dist/admin/translations/gu.json.mjs +4 -4
- package/dist/admin/translations/hi.json.js +9 -9
- package/dist/admin/translations/hi.json.mjs +9 -9
- package/dist/admin/translations/ml.json.js +6 -6
- package/dist/admin/translations/ml.json.mjs +6 -6
- package/dist/admin/translations/sa.json.js +10 -10
- package/dist/admin/translations/sa.json.mjs +10 -10
- package/dist/server/controllers/relations.js +48 -16
- package/dist/server/controllers/relations.js.map +1 -1
- package/dist/server/controllers/relations.mjs +49 -17
- package/dist/server/controllers/relations.mjs.map +1 -1
- package/dist/server/history/services/history.js +1 -1
- package/dist/server/history/services/history.js.map +1 -1
- package/dist/server/history/services/history.mjs +1 -1
- package/dist/server/history/services/history.mjs.map +1 -1
- package/dist/server/homepage/services/homepage.js.map +1 -1
- package/dist/server/homepage/services/homepage.mjs.map +1 -1
- package/dist/server/mcp/schemas/filters-schema.js +10 -2
- package/dist/server/mcp/schemas/filters-schema.js.map +1 -1
- package/dist/server/mcp/schemas/filters-schema.mjs +10 -2
- package/dist/server/mcp/schemas/filters-schema.mjs.map +1 -1
- package/dist/server/preview/controllers/validation/preview.js +1 -1
- package/dist/server/preview/controllers/validation/preview.js.map +1 -1
- package/dist/server/preview/controllers/validation/preview.mjs +2 -2
- package/dist/server/preview/controllers/validation/preview.mjs.map +1 -1
- package/dist/server/preview/services/preview-config.js.map +1 -1
- package/dist/server/preview/services/preview-config.mjs.map +1 -1
- package/dist/server/register.js +6 -0
- package/dist/server/register.js.map +1 -1
- package/dist/server/register.mjs +6 -0
- package/dist/server/register.mjs.map +1 -1
- package/dist/server/services/components.js.map +1 -1
- package/dist/server/services/components.mjs.map +1 -1
- package/dist/server/services/configuration/rename-fields.js +68 -0
- package/dist/server/services/configuration/rename-fields.js.map +1 -0
- package/dist/server/services/configuration/rename-fields.mjs +66 -0
- package/dist/server/services/configuration/rename-fields.mjs.map +1 -0
- package/dist/server/services/document-metadata.js +1 -1
- package/dist/server/services/document-metadata.js.map +1 -1
- package/dist/server/services/document-metadata.mjs +1 -1
- package/dist/server/services/document-metadata.mjs.map +1 -1
- package/dist/server/services/utils/configuration/attribute-renames.js +164 -0
- package/dist/server/services/utils/configuration/attribute-renames.js.map +1 -0
- package/dist/server/services/utils/configuration/attribute-renames.mjs +161 -0
- package/dist/server/services/utils/configuration/attribute-renames.mjs.map +1 -0
- package/dist/server/services/utils/configuration/attributes.js +12 -12
- package/dist/server/services/utils/configuration/attributes.js.map +1 -1
- package/dist/server/services/utils/configuration/attributes.mjs +12 -12
- package/dist/server/services/utils/configuration/attributes.mjs.map +1 -1
- package/dist/server/src/controllers/relations.d.ts.map +1 -1
- package/dist/server/src/homepage/services/homepage.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +2 -0
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/mcp/schemas/filters-schema.d.ts.map +1 -1
- package/dist/server/src/preview/services/index.d.ts.map +1 -1
- package/dist/server/src/preview/services/preview-config.d.ts.map +1 -1
- package/dist/server/src/register.d.ts.map +1 -1
- package/dist/server/src/services/components.d.ts +2 -0
- package/dist/server/src/services/components.d.ts.map +1 -1
- package/dist/server/src/services/configuration/rename-fields.d.ts +15 -0
- package/dist/server/src/services/configuration/rename-fields.d.ts.map +1 -0
- package/dist/server/src/services/index.d.ts +2 -0
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/utils/configuration/attribute-renames.d.ts +57 -0
- package/dist/server/src/services/utils/configuration/attribute-renames.d.ts.map +1 -0
- package/dist/shared/contracts/content-types.d.ts +5 -0
- package/dist/shared/contracts/content-types.d.ts.map +1 -1
- package/package.json +7 -7
|
@@ -63,10 +63,10 @@ const createLayoutFromFields = (fields)=>{
|
|
|
63
63
|
* Those fields would be restored if the user restores the history version, which is why it's
|
|
64
64
|
* important to show them, even if they're not in the normal layout.
|
|
65
65
|
*/ function getRemaingFieldsLayout({ layout, metadatas, schemaAttributes, fieldSizes }) {
|
|
66
|
-
const fieldsInLayout = layout.flatMap((panel)=>panel.flatMap((row)=>row.flatMap((field)=>field.name)));
|
|
66
|
+
const fieldsInLayout = new Set(layout.flatMap((panel)=>panel.flatMap((row)=>row.flatMap((field)=>field.name))));
|
|
67
67
|
const remainingFields = Object.entries(metadatas).reduce((currentRemainingFields, [name, field])=>{
|
|
68
68
|
// Make sure we do not fields that are not visible, e.g. "id"
|
|
69
|
-
if (!fieldsInLayout.
|
|
69
|
+
if (!fieldsInLayout.has(name) && field.edit.visible === true) {
|
|
70
70
|
const attribute = schemaAttributes[name];
|
|
71
71
|
// @ts-expect-error not sure why attribute causes type error
|
|
72
72
|
currentRemainingFields.push({
|
|
@@ -170,7 +170,7 @@ const FormPanel = ({ panel })=>{
|
|
|
170
170
|
direction: "column",
|
|
171
171
|
alignItems: "stretch",
|
|
172
172
|
gap: 6,
|
|
173
|
-
children: panel.map((row
|
|
173
|
+
children: panel.map((row)=>{
|
|
174
174
|
const visibleFields = row.filter(isFieldVisible);
|
|
175
175
|
if (visibleFields.length === 0) {
|
|
176
176
|
return null; // Skip rendering the entire grid row
|
|
@@ -191,7 +191,7 @@ const FormPanel = ({ panel })=>{
|
|
|
191
191
|
})
|
|
192
192
|
}, field.name);
|
|
193
193
|
})
|
|
194
|
-
},
|
|
194
|
+
}, row.map((field)=>field.name).join('.'));
|
|
195
195
|
})
|
|
196
196
|
})
|
|
197
197
|
});
|
|
@@ -263,10 +263,10 @@ const VersionContent = ()=>{
|
|
|
263
263
|
children: [
|
|
264
264
|
...layout,
|
|
265
265
|
...remainingFieldsLayout
|
|
266
|
-
].map((panel
|
|
266
|
+
].map((panel)=>{
|
|
267
267
|
return /*#__PURE__*/ jsxRuntime.jsx(FormPanel, {
|
|
268
268
|
panel: panel
|
|
269
|
-
},
|
|
269
|
+
}, panel.flatMap((row)=>row.map((field)=>field.name)).join('.'));
|
|
270
270
|
})
|
|
271
271
|
})
|
|
272
272
|
}, version.id),
|
|
@@ -325,10 +325,10 @@ const VersionContent = ()=>{
|
|
|
325
325
|
alignItems: "stretch",
|
|
326
326
|
gap: 6,
|
|
327
327
|
position: "relative",
|
|
328
|
-
children: unknownFieldsLayout.map((panel
|
|
328
|
+
children: unknownFieldsLayout.map((panel)=>{
|
|
329
329
|
return /*#__PURE__*/ jsxRuntime.jsx(FormPanel, {
|
|
330
330
|
panel: panel
|
|
331
|
-
},
|
|
331
|
+
}, panel.flatMap((row)=>row.map((field)=>field.name)).join('.'));
|
|
332
332
|
})
|
|
333
333
|
})
|
|
334
334
|
}, `${version.id}-unknownFields`)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VersionContent.js","sources":["../../../../admin/src/history/components/VersionContent.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Form, Layouts, createRulesEngine, useForm, useIsMobile } from '@strapi/admin/strapi-admin';\nimport { Box, Divider, Flex, Grid, Typography } from '@strapi/design-system';\nimport flow from 'lodash/flow';\nimport { useIntl } from 'react-intl';\n\nimport { useDoc } from '../../hooks/useDocument';\nimport { useTypedSelector } from '../../modules/hooks';\nimport {\n prepareTempKeys,\n removeFieldsThatDontExistOnSchema,\n} from '../../pages/EditView/utils/data';\nimport {\n getConditionDependencyPaths,\n getConditionDependencySubscriptionValue,\n} from '../../utils/conditionalFields';\nimport { HistoryContextValue, useHistoryContext } from '../pages/History';\n\nimport { VersionInputRenderer } from './VersionInputRenderer';\n\nimport type { Metadatas } from '../../../../shared/contracts/content-types';\nimport type { GetInitData } from '../../../../shared/contracts/init';\nimport type { ComponentsDictionary, Document } from '../../hooks/useDocument';\nimport type { EditFieldLayout } from '../../hooks/useDocumentLayout';\nimport type { Schema } from '@strapi/types';\n\nconst createLayoutFromFields = <T extends EditFieldLayout | UnknownField>(fields: T[]) => {\n return (\n fields\n .reduce<Array<T[]>>((rows, field) => {\n if (field.type === 'dynamiczone') {\n // Dynamic zones take up all the columns in a row\n rows.push([field]);\n\n return rows;\n }\n\n if (!rows[rows.length - 1]) {\n // Create a new row if there isn't one available\n rows.push([]);\n }\n\n // Push fields to the current row, they wrap and handle their own column size\n rows[rows.length - 1].push(field);\n\n return rows;\n }, [])\n // Map the rows to panels\n .map((row) => [row])\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * getRemainingFieldsLayout\n * -----------------------------------------------------------------------------------------------*/\n\ninterface GetRemainingFieldsLayoutOptions\n extends Pick<HistoryContextValue, 'layout'>,\n Pick<GetInitData.Response['data'], 'fieldSizes'> {\n schemaAttributes: HistoryContextValue['schema']['attributes'];\n metadatas: Metadatas;\n}\n\n/**\n * Build a layout for the fields that are were deleted from the edit view layout\n * via the configure the view page. This layout will be merged with the main one.\n * Those fields would be restored if the user restores the history version, which is why it's\n * important to show them, even if they're not in the normal layout.\n */\nfunction getRemaingFieldsLayout({\n layout,\n metadatas,\n schemaAttributes,\n fieldSizes,\n}: GetRemainingFieldsLayoutOptions) {\n const fieldsInLayout = layout.flatMap((panel) =>\n panel.flatMap((row) => row.flatMap((field) => field.name))\n );\n const remainingFields = Object.entries(metadatas).reduce<EditFieldLayout[]>(\n (currentRemainingFields, [name, field]) => {\n // Make sure we do not fields that are not visible, e.g. \"id\"\n if (!fieldsInLayout.includes(name) && field.edit.visible === true) {\n const attribute = schemaAttributes[name];\n // @ts-expect-error not sure why attribute causes type error\n currentRemainingFields.push({\n attribute,\n type: attribute.type,\n visible: true,\n disabled: true,\n label: field.edit.label || name,\n name: name,\n size: fieldSizes[attribute.type].default ?? 12,\n });\n }\n\n return currentRemainingFields;\n },\n []\n );\n\n return createLayoutFromFields(remainingFields);\n}\n\n/* -------------------------------------------------------------------------------------------------\n * FormPanel\n * -----------------------------------------------------------------------------------------------*/\n\n// Reuse one rules engine instance instead of creating a new one on every render.\nconst rulesEngine = createRulesEngine();\n\nconst getPanelConditionDependencyPaths = (panel: EditFieldLayout[][]): string[] | null => {\n // Aggregate condition dependencies across all fields in the panel so we can subscribe narrowly.\n const dependencies = new Set<string>();\n\n for (const row of panel) {\n for (const field of row) {\n const condition = field.attribute?.conditions?.visible;\n\n if (!condition) {\n continue;\n }\n\n const paths = getConditionDependencyPaths(condition);\n\n if (paths === null) {\n return null;\n }\n\n for (const path of paths) {\n dependencies.add(path);\n }\n }\n }\n\n return [...dependencies].sort();\n};\n\nconst FormPanel = ({ panel }: { panel: EditFieldLayout[][] }) => {\n const isMobile = useIsMobile();\n const conditionDependencyPaths = React.useMemo(\n () => getPanelConditionDependencyPaths(panel),\n [panel]\n );\n const getValues = useForm(\n 'FormPanel',\n (state) => (state as typeof state & { getValues: () => unknown }).getValues\n );\n const conditionSubscriptionValue = useForm('FormPanel', (state) => {\n return getConditionDependencySubscriptionValue(state.values, conditionDependencyPaths);\n });\n // For narrow subscriptions, read the latest full values lazily via getValues() to evaluate rules.\n // This avoids rerendering for unrelated form changes while preserving correct condition evaluation.\n const fieldValues = conditionDependencyPaths === null ? conditionSubscriptionValue : getValues();\n\n const isFieldVisible = React.useCallback(\n (field: EditFieldLayout) => {\n const condition = field.attribute?.conditions?.visible;\n\n if (!condition) {\n return true;\n }\n\n return rulesEngine.evaluate(condition, fieldValues);\n },\n [fieldValues]\n );\n\n if (panel.some((row) => row.some((field) => field.type === 'dynamiczone'))) {\n const [row] = panel;\n const [field] = row;\n\n if (!isFieldVisible(field)) {\n return null;\n }\n\n return (\n <Grid.Root key={field.name} gap={4}>\n <Grid.Item xs={12} direction=\"column\" alignItems=\"stretch\">\n <VersionInputRenderer {...field} />\n </Grid.Item>\n </Grid.Root>\n );\n }\n\n return (\n <Box\n hasRadius={!isMobile}\n background={{ initial: 'transparent', medium: 'neutral0' }}\n shadow={{ initial: 'none', medium: 'tableShadow' }}\n padding={{ initial: 0, medium: 6 }}\n borderColor={{ initial: 'transparent', medium: 'neutral150' }}\n >\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6}>\n {panel.map((row, gridRowIndex) => {\n const visibleFields = row.filter(isFieldVisible);\n\n if (visibleFields.length === 0) {\n return null; // Skip rendering the entire grid row\n }\n\n return (\n <Grid.Root key={gridRowIndex} gap={{ initial: 6, medium: 4 }}>\n {visibleFields.map(({ size, ...field }) => {\n return (\n <Grid.Item\n col={size}\n key={field.name}\n xs={12}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n <VersionInputRenderer {...field} />\n </Grid.Item>\n );\n })}\n </Grid.Root>\n );\n })}\n </Flex>\n </Box>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * VersionContent\n * -----------------------------------------------------------------------------------------------*/\n\ntype UnknownField = EditFieldLayout & { shouldIgnoreRBAC: boolean };\n\nconst VersionContent = () => {\n const { formatMessage } = useIntl();\n const { fieldSizes } = useTypedSelector((state) => state['content-manager'].app);\n const version = useHistoryContext('VersionContent', (state) => state.selectedVersion);\n const layout = useHistoryContext('VersionContent', (state) => state.layout);\n const configuration = useHistoryContext('VersionContent', (state) => state.configuration);\n const schema = useHistoryContext('VersionContent', (state) => state.schema);\n\n // Build a layout for the unknown fields section\n const removedAttributes = version.meta.unknownAttributes.removed;\n const removedAttributesAsFields = Object.entries(removedAttributes).map(\n ([attributeName, attribute]) => {\n const field = {\n attribute,\n shouldIgnoreRBAC: true,\n type: attribute.type,\n visible: true,\n disabled: true,\n label: attributeName,\n name: attributeName,\n size: fieldSizes[attribute.type].default ?? 12,\n } as UnknownField;\n\n return field;\n }\n );\n const unknownFieldsLayout = createLayoutFromFields(removedAttributesAsFields);\n\n // Build a layout for the fields that are were deleted from the layout\n const remainingFieldsLayout = getRemaingFieldsLayout({\n metadatas: configuration.contentType.metadatas,\n layout,\n schemaAttributes: schema.attributes,\n fieldSizes,\n });\n\n const { components } = useDoc();\n\n /**\n * Transform the data before passing it to the form so that each field\n * has a uniquely generated key\n */\n const transformedData = React.useMemo(() => {\n const transform =\n (schemaAttributes: Schema.Attributes, components: ComponentsDictionary = {}) =>\n (document: Omit<Document, 'id'>) => {\n const schema = { attributes: schemaAttributes };\n\n const transformations = flow(\n removeFieldsThatDontExistOnSchema(schema),\n prepareTempKeys(schema, components)\n );\n return transformations(document);\n };\n\n return transform(version.schema, components)(version.data);\n }, [components, version.data, version.schema]);\n\n return (\n <Layouts.Content>\n <Box paddingBottom={{ initial: 0, large: 8 }}>\n <Form key={version.id} disabled={true} method=\"PUT\" initialValues={transformedData}>\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6} position=\"relative\">\n {[...layout, ...remainingFieldsLayout].map((panel, index) => {\n return <FormPanel key={index} panel={panel} />;\n })}\n </Flex>\n </Form>\n {removedAttributesAsFields.length > 0 && (\n <>\n <Box paddingTop={{ initial: 4, large: 0 }}>\n <Divider />\n </Box>\n <Box paddingTop={{ initial: 4, large: 8 }}>\n <Flex\n direction=\"column\"\n alignItems=\"flex-start\"\n paddingBottom={{ initial: 4, large: 6 }}\n gap={1}\n >\n <Typography variant=\"delta\">\n {formatMessage({\n id: 'content-manager.history.content.unknown-fields.title',\n defaultMessage: 'Unknown fields',\n })}\n </Typography>\n <Typography variant=\"pi\">\n {formatMessage(\n {\n id: 'content-manager.history.content.unknown-fields.message',\n defaultMessage:\n 'These fields have been deleted or renamed in the Content-Type Builder. <b>These fields will not be restored.</b>',\n },\n {\n b: (chunks: React.ReactNode) => (\n <Typography variant=\"pi\" fontWeight=\"bold\">\n {chunks}\n </Typography>\n ),\n }\n )}\n </Typography>\n </Flex>\n <Form\n key={`${version.id}-unknownFields`}\n disabled={true}\n method=\"PUT\"\n initialValues={version.data}\n >\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6} position=\"relative\">\n {unknownFieldsLayout.map((panel, index) => {\n return <FormPanel key={index} panel={panel} />;\n })}\n </Flex>\n </Form>\n </Box>\n </>\n )}\n </Box>\n </Layouts.Content>\n );\n};\n\nexport { VersionContent, getRemaingFieldsLayout };\n"],"names":["createLayoutFromFields","fields","reduce","rows","field","type","push","length","map","row","getRemaingFieldsLayout","layout","metadatas","schemaAttributes","fieldSizes","fieldsInLayout","flatMap","panel","name","remainingFields","Object","entries","currentRemainingFields","includes","edit","visible","attribute","disabled","label","size","default","rulesEngine","createRulesEngine","getPanelConditionDependencyPaths","dependencies","Set","condition","conditions","paths","getConditionDependencyPaths","path","add","sort","FormPanel","isMobile","useIsMobile","conditionDependencyPaths","React","useMemo","getValues","useForm","state","conditionSubscriptionValue","getConditionDependencySubscriptionValue","values","fieldValues","isFieldVisible","useCallback","evaluate","some","_jsx","Grid","Root","gap","Item","xs","direction","alignItems","VersionInputRenderer","Box","hasRadius","background","initial","medium","shadow","padding","borderColor","Flex","gridRowIndex","visibleFields","filter","col","VersionContent","formatMessage","useIntl","useTypedSelector","app","version","useHistoryContext","selectedVersion","configuration","schema","removedAttributes","meta","unknownAttributes","removed","removedAttributesAsFields","attributeName","shouldIgnoreRBAC","unknownFieldsLayout","remainingFieldsLayout","contentType","attributes","components","useDoc","transformedData","transform","document","transformations","flow","removeFieldsThatDontExistOnSchema","prepareTempKeys","data","Layouts","Content","_jsxs","paddingBottom","large","Form","method","initialValues","position","index","id","_Fragment","paddingTop","Divider","Typography","variant","defaultMessage","b","chunks","fontWeight"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAMA,yBAAyB,CAA2CC,MAAAA,GAAAA;AACxE,IAAA,OACEA,MAAAA,CACGC,MAAM,CAAa,CAACC,IAAAA,EAAMC,KAAAA,GAAAA;QACzB,IAAIA,KAAAA,CAAMC,IAAI,KAAK,aAAA,EAAe;;AAEhCF,YAAAA,IAAAA,CAAKG,IAAI,CAAC;AAACF,gBAAAA;AAAM,aAAA,CAAA;YAEjB,OAAOD,IAAAA;AACT,QAAA;AAEA,QAAA,IAAI,CAACA,IAAI,CAACA,KAAKI,MAAM,GAAG,EAAE,EAAE;;YAE1BJ,IAAAA,CAAKG,IAAI,CAAC,EAAE,CAAA;AACd,QAAA;;AAGAH,QAAAA,IAAI,CAACA,IAAAA,CAAKI,MAAM,GAAG,CAAA,CAAE,CAACD,IAAI,CAACF,KAAAA,CAAAA;QAE3B,OAAOD,IAAAA;IACT,CAAA,EAAG,EAAE,CACL;KACCK,GAAG,CAAC,CAACC,GAAAA,GAAQ;AAACA,YAAAA;AAAI,SAAA,CAAA;AAEzB,CAAA;AAaA;;;;;IAMA,SAASC,sBAAAA,CAAuB,EAC9BC,MAAM,EACNC,SAAS,EACTC,gBAAgB,EAChBC,UAAU,EACsB,EAAA;AAChC,IAAA,MAAMC,iBAAiBJ,MAAAA,CAAOK,OAAO,CAAC,CAACC,QACrCA,KAAAA,CAAMD,OAAO,CAAC,CAACP,MAAQA,GAAAA,CAAIO,OAAO,CAAC,CAACZ,K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ACC,uBACFvE,cAAA,CAACmE,uBAAAA,EAAAA;wDAAWC,OAAAA,EAAQ,IAAA;wDAAKI,UAAAA,EAAW,MAAA;AACjCD,wDAAAA,QAAAA,EAAAA;;AAGP,6CAAA;;;;8CAINvE,cAAA,CAAC0D,gBAAAA,EAAAA;oCAEC3F,QAAAA,EAAU,IAAA;oCACV4F,MAAAA,EAAO,KAAA;AACPC,oCAAAA,aAAAA,EAAejC,QAAQyB,IAAI;AAE3B,oCAAA,QAAA,gBAAApD,cAAA,CAACiB,iBAAAA,EAAAA;wCAAKX,SAAAA,EAAU,QAAA;wCAASC,UAAAA,EAAW,SAAA;wCAAUJ,GAAAA,EAAK,CAAA;wCAAG0D,QAAAA,EAAS,UAAA;kDAC5DtB,mBAAAA,CAAoB3F,GAAG,CAAC,CAACS,KAAAA,EAAOyG,KAAAA,GAAAA;AAC/B,4CAAA,qBAAO9D,cAAA,CAACjB,SAAAA,EAAAA;gDAAsB1B,KAAAA,EAAOA;AAAdyG,6CAAAA,EAAAA,KAAAA,CAAAA;AACzB,wCAAA,CAAA;;AARG,iCAAA,EAAA,CAAA,EAAGnC,OAAAA,CAAQoC,EAAE,CAAC,cAAc,CAAC;;;;;;;;AAiBlD;;;;;"}
|
|
1
|
+
{"version":3,"file":"VersionContent.js","sources":["../../../../admin/src/history/components/VersionContent.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Form, Layouts, createRulesEngine, useForm, useIsMobile } from '@strapi/admin/strapi-admin';\nimport { Box, Divider, Flex, Grid, Typography } from '@strapi/design-system';\nimport flow from 'lodash/flow';\nimport { useIntl } from 'react-intl';\n\nimport { useDoc } from '../../hooks/useDocument';\nimport { useTypedSelector } from '../../modules/hooks';\nimport {\n prepareTempKeys,\n removeFieldsThatDontExistOnSchema,\n} from '../../pages/EditView/utils/data';\nimport {\n getConditionDependencyPaths,\n getConditionDependencySubscriptionValue,\n} from '../../utils/conditionalFields';\nimport { HistoryContextValue, useHistoryContext } from '../pages/History';\n\nimport { VersionInputRenderer } from './VersionInputRenderer';\n\nimport type { Metadatas } from '../../../../shared/contracts/content-types';\nimport type { GetInitData } from '../../../../shared/contracts/init';\nimport type { ComponentsDictionary, Document } from '../../hooks/useDocument';\nimport type { EditFieldLayout } from '../../hooks/useDocumentLayout';\nimport type { Schema } from '@strapi/types';\n\nconst createLayoutFromFields = <T extends EditFieldLayout | UnknownField>(fields: T[]) => {\n return (\n fields\n .reduce<Array<T[]>>((rows, field) => {\n if (field.type === 'dynamiczone') {\n // Dynamic zones take up all the columns in a row\n rows.push([field]);\n\n return rows;\n }\n\n if (!rows[rows.length - 1]) {\n // Create a new row if there isn't one available\n rows.push([]);\n }\n\n // Push fields to the current row, they wrap and handle their own column size\n rows[rows.length - 1].push(field);\n\n return rows;\n }, [])\n // Map the rows to panels\n .map((row) => [row])\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * getRemainingFieldsLayout\n * -----------------------------------------------------------------------------------------------*/\n\ninterface GetRemainingFieldsLayoutOptions\n extends Pick<HistoryContextValue, 'layout'>, Pick<GetInitData.Response['data'], 'fieldSizes'> {\n schemaAttributes: HistoryContextValue['schema']['attributes'];\n metadatas: Metadatas;\n}\n\n/**\n * Build a layout for the fields that are were deleted from the edit view layout\n * via the configure the view page. This layout will be merged with the main one.\n * Those fields would be restored if the user restores the history version, which is why it's\n * important to show them, even if they're not in the normal layout.\n */\nfunction getRemaingFieldsLayout({\n layout,\n metadatas,\n schemaAttributes,\n fieldSizes,\n}: GetRemainingFieldsLayoutOptions) {\n const fieldsInLayout = new Set(\n layout.flatMap((panel) => panel.flatMap((row) => row.flatMap((field) => field.name)))\n );\n const remainingFields = Object.entries(metadatas).reduce<EditFieldLayout[]>(\n (currentRemainingFields, [name, field]) => {\n // Make sure we do not fields that are not visible, e.g. \"id\"\n if (!fieldsInLayout.has(name) && field.edit.visible === true) {\n const attribute = schemaAttributes[name];\n // @ts-expect-error not sure why attribute causes type error\n currentRemainingFields.push({\n attribute,\n type: attribute.type,\n visible: true,\n disabled: true,\n label: field.edit.label || name,\n name: name,\n size: fieldSizes[attribute.type].default ?? 12,\n });\n }\n\n return currentRemainingFields;\n },\n []\n );\n\n return createLayoutFromFields(remainingFields);\n}\n\n/* -------------------------------------------------------------------------------------------------\n * FormPanel\n * -----------------------------------------------------------------------------------------------*/\n\n// Reuse one rules engine instance instead of creating a new one on every render.\nconst rulesEngine = createRulesEngine();\n\nconst getPanelConditionDependencyPaths = (panel: EditFieldLayout[][]): string[] | null => {\n // Aggregate condition dependencies across all fields in the panel so we can subscribe narrowly.\n const dependencies = new Set<string>();\n\n for (const row of panel) {\n for (const field of row) {\n const condition = field.attribute?.conditions?.visible;\n\n if (!condition) {\n continue;\n }\n\n const paths = getConditionDependencyPaths(condition);\n\n if (paths === null) {\n return null;\n }\n\n for (const path of paths) {\n dependencies.add(path);\n }\n }\n }\n\n return [...dependencies].sort();\n};\n\nconst FormPanel = ({ panel }: { panel: EditFieldLayout[][] }) => {\n const isMobile = useIsMobile();\n const conditionDependencyPaths = React.useMemo(\n () => getPanelConditionDependencyPaths(panel),\n [panel]\n );\n const getValues = useForm(\n 'FormPanel',\n (state) => (state as typeof state & { getValues: () => unknown }).getValues\n );\n const conditionSubscriptionValue = useForm('FormPanel', (state) => {\n return getConditionDependencySubscriptionValue(state.values, conditionDependencyPaths);\n });\n // For narrow subscriptions, read the latest full values lazily via getValues() to evaluate rules.\n // This avoids rerendering for unrelated form changes while preserving correct condition evaluation.\n const fieldValues = conditionDependencyPaths === null ? conditionSubscriptionValue : getValues();\n\n const isFieldVisible = React.useCallback(\n (field: EditFieldLayout) => {\n const condition = field.attribute?.conditions?.visible;\n\n if (!condition) {\n return true;\n }\n\n return rulesEngine.evaluate(condition, fieldValues);\n },\n [fieldValues]\n );\n\n if (panel.some((row) => row.some((field) => field.type === 'dynamiczone'))) {\n const [row] = panel;\n const [field] = row;\n\n if (!isFieldVisible(field)) {\n return null;\n }\n\n return (\n <Grid.Root key={field.name} gap={4}>\n <Grid.Item xs={12} direction=\"column\" alignItems=\"stretch\">\n <VersionInputRenderer {...field} />\n </Grid.Item>\n </Grid.Root>\n );\n }\n\n return (\n <Box\n hasRadius={!isMobile}\n background={{ initial: 'transparent', medium: 'neutral0' }}\n shadow={{ initial: 'none', medium: 'tableShadow' }}\n padding={{ initial: 0, medium: 6 }}\n borderColor={{ initial: 'transparent', medium: 'neutral150' }}\n >\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6}>\n {panel.map((row) => {\n const visibleFields = row.filter(isFieldVisible);\n\n if (visibleFields.length === 0) {\n return null; // Skip rendering the entire grid row\n }\n\n return (\n <Grid.Root\n key={row.map((field) => field.name).join('.')}\n gap={{ initial: 6, medium: 4 }}\n >\n {visibleFields.map(({ size, ...field }) => {\n return (\n <Grid.Item\n col={size}\n key={field.name}\n xs={12}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n <VersionInputRenderer {...field} />\n </Grid.Item>\n );\n })}\n </Grid.Root>\n );\n })}\n </Flex>\n </Box>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * VersionContent\n * -----------------------------------------------------------------------------------------------*/\n\ntype UnknownField = EditFieldLayout & { shouldIgnoreRBAC: boolean };\n\nconst VersionContent = () => {\n const { formatMessage } = useIntl();\n const { fieldSizes } = useTypedSelector((state) => state['content-manager'].app);\n const version = useHistoryContext('VersionContent', (state) => state.selectedVersion);\n const layout = useHistoryContext('VersionContent', (state) => state.layout);\n const configuration = useHistoryContext('VersionContent', (state) => state.configuration);\n const schema = useHistoryContext('VersionContent', (state) => state.schema);\n\n // Build a layout for the unknown fields section\n const removedAttributes = version.meta.unknownAttributes.removed;\n const removedAttributesAsFields = Object.entries(removedAttributes).map(\n ([attributeName, attribute]) => {\n const field = {\n attribute,\n shouldIgnoreRBAC: true,\n type: attribute.type,\n visible: true,\n disabled: true,\n label: attributeName,\n name: attributeName,\n size: fieldSizes[attribute.type].default ?? 12,\n } as UnknownField;\n\n return field;\n }\n );\n const unknownFieldsLayout = createLayoutFromFields(removedAttributesAsFields);\n\n // Build a layout for the fields that are were deleted from the layout\n const remainingFieldsLayout = getRemaingFieldsLayout({\n metadatas: configuration.contentType.metadatas,\n layout,\n schemaAttributes: schema.attributes,\n fieldSizes,\n });\n\n const { components } = useDoc();\n\n /**\n * Transform the data before passing it to the form so that each field\n * has a uniquely generated key\n */\n const transformedData = React.useMemo(() => {\n const transform =\n (schemaAttributes: Schema.Attributes, components: ComponentsDictionary = {}) =>\n (document: Omit<Document, 'id'>) => {\n const schema = { attributes: schemaAttributes };\n\n const transformations = flow(\n removeFieldsThatDontExistOnSchema(schema),\n prepareTempKeys(schema, components)\n );\n return transformations(document);\n };\n\n return transform(version.schema, components)(version.data);\n }, [components, version.data, version.schema]);\n\n return (\n <Layouts.Content>\n <Box paddingBottom={{ initial: 0, large: 8 }}>\n <Form key={version.id} disabled={true} method=\"PUT\" initialValues={transformedData}>\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6} position=\"relative\">\n {[...layout, ...remainingFieldsLayout].map((panel) => {\n return (\n <FormPanel\n key={panel.flatMap((row) => row.map((field) => field.name)).join('.')}\n panel={panel}\n />\n );\n })}\n </Flex>\n </Form>\n {removedAttributesAsFields.length > 0 && (\n <>\n <Box paddingTop={{ initial: 4, large: 0 }}>\n <Divider />\n </Box>\n <Box paddingTop={{ initial: 4, large: 8 }}>\n <Flex\n direction=\"column\"\n alignItems=\"flex-start\"\n paddingBottom={{ initial: 4, large: 6 }}\n gap={1}\n >\n <Typography variant=\"delta\">\n {formatMessage({\n id: 'content-manager.history.content.unknown-fields.title',\n defaultMessage: 'Unknown fields',\n })}\n </Typography>\n <Typography variant=\"pi\">\n {formatMessage(\n {\n id: 'content-manager.history.content.unknown-fields.message',\n defaultMessage:\n 'These fields have been deleted or renamed in the Content-Type Builder. <b>These fields will not be restored.</b>',\n },\n {\n b: (chunks: React.ReactNode) => (\n <Typography variant=\"pi\" fontWeight=\"bold\">\n {chunks}\n </Typography>\n ),\n }\n )}\n </Typography>\n </Flex>\n <Form\n key={`${version.id}-unknownFields`}\n disabled={true}\n method=\"PUT\"\n initialValues={version.data}\n >\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6} position=\"relative\">\n {unknownFieldsLayout.map((panel) => {\n return (\n <FormPanel\n key={panel.flatMap((row) => row.map((field) => field.name)).join('.')}\n panel={panel}\n />\n );\n })}\n </Flex>\n </Form>\n </Box>\n </>\n )}\n </Box>\n </Layouts.Content>\n );\n};\n\nexport { VersionContent, getRemaingFieldsLayout };\n"],"names":["createLayoutFromFields","fields","reduce","rows","field","type","push","length","map","row","getRemaingFieldsLayout","layout","metadatas","schemaAttributes","fieldSizes","fieldsInLayout","Set","flatMap","panel","name","remainingFields","Object","entries","currentRemainingFields","has","edit","visible","attribute","disabled","label","size","default","rulesEngine","createRulesEngine","getPanelConditionDependencyPaths","dependencies","condition","conditions","paths","getConditionDependencyPaths","path","add","sort","FormPanel","isMobile","useIsMobile","conditionDependencyPaths","React","useMemo","getValues","useForm","state","conditionSubscriptionValue","getConditionDependencySubscriptionValue","values","fieldValues","isFieldVisible","useCallback","evaluate","some","_jsx","Grid","Root","gap","Item","xs","direction","alignItems","VersionInputRenderer","Box","hasRadius","background","initial","medium","shadow","padding","borderColor","Flex","visibleFields","filter","col","join","VersionContent","formatMessage","useIntl","useTypedSelector","app","version","useHistoryContext","selectedVersion","configuration","schema","removedAttributes","meta","unknownAttributes","removed","removedAttributesAsFields","attributeName","shouldIgnoreRBAC","unknownFieldsLayout","remainingFieldsLayout","contentType","attributes","components","useDoc","transformedData","transform","document","transformations","flow","removeFieldsThatDontExistOnSchema","prepareTempKeys","data","Layouts","Content","_jsxs","paddingBottom","large","Form","method","initialValues","position","id","_Fragment","paddingTop","Divider","Typography","variant","defaultMessage","b","chunks","fontWeight"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAMA,yBAAyB,CAA2CC,MAAAA,GAAAA;AACxE,IAAA,OACEA,MAAAA,CACGC,M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,IAAA;oCACV2F,MAAAA,EAAO,KAAA;AACPC,oCAAAA,aAAAA,EAAejC,QAAQyB,IAAI;AAE3B,oCAAA,QAAA,gBAAApD,cAAA,CAACiB,iBAAAA,EAAAA;wCAAKX,SAAAA,EAAU,QAAA;wCAASC,UAAAA,EAAW,SAAA;wCAAUJ,GAAAA,EAAK,CAAA;wCAAG0D,QAAAA,EAAS,UAAA;kDAC5DtB,mBAAAA,CAAoB3F,GAAG,CAAC,CAACU,KAAAA,GAAAA;AACxB,4CAAA,qBACE0C,cAAA,CAACjB,SAAAA,EAAAA;gDAECzB,KAAAA,EAAOA;AADFA,6CAAAA,EAAAA,KAAAA,CAAMD,OAAO,CAAC,CAACR,GAAAA,GAAQA,GAAAA,CAAID,GAAG,CAAC,CAACJ,KAAAA,GAAUA,KAAAA,CAAMe,IAAI,CAAA,CAAA,CAAG8D,IAAI,CAAC,GAAA,CAAA,CAAA;AAIvE,wCAAA,CAAA;;AAbG,iCAAA,EAAA,CAAA,EAAGM,OAAAA,CAAQmC,EAAE,CAAC,cAAc,CAAC;;;;;;;;AAsBlD;;;;;"}
|
|
@@ -38,10 +38,10 @@ const createLayoutFromFields = (fields)=>{
|
|
|
38
38
|
* Those fields would be restored if the user restores the history version, which is why it's
|
|
39
39
|
* important to show them, even if they're not in the normal layout.
|
|
40
40
|
*/ function getRemaingFieldsLayout({ layout, metadatas, schemaAttributes, fieldSizes }) {
|
|
41
|
-
const fieldsInLayout = layout.flatMap((panel)=>panel.flatMap((row)=>row.flatMap((field)=>field.name)));
|
|
41
|
+
const fieldsInLayout = new Set(layout.flatMap((panel)=>panel.flatMap((row)=>row.flatMap((field)=>field.name))));
|
|
42
42
|
const remainingFields = Object.entries(metadatas).reduce((currentRemainingFields, [name, field])=>{
|
|
43
43
|
// Make sure we do not fields that are not visible, e.g. "id"
|
|
44
|
-
if (!fieldsInLayout.
|
|
44
|
+
if (!fieldsInLayout.has(name) && field.edit.visible === true) {
|
|
45
45
|
const attribute = schemaAttributes[name];
|
|
46
46
|
// @ts-expect-error not sure why attribute causes type error
|
|
47
47
|
currentRemainingFields.push({
|
|
@@ -145,7 +145,7 @@ const FormPanel = ({ panel })=>{
|
|
|
145
145
|
direction: "column",
|
|
146
146
|
alignItems: "stretch",
|
|
147
147
|
gap: 6,
|
|
148
|
-
children: panel.map((row
|
|
148
|
+
children: panel.map((row)=>{
|
|
149
149
|
const visibleFields = row.filter(isFieldVisible);
|
|
150
150
|
if (visibleFields.length === 0) {
|
|
151
151
|
return null; // Skip rendering the entire grid row
|
|
@@ -166,7 +166,7 @@ const FormPanel = ({ panel })=>{
|
|
|
166
166
|
})
|
|
167
167
|
}, field.name);
|
|
168
168
|
})
|
|
169
|
-
},
|
|
169
|
+
}, row.map((field)=>field.name).join('.'));
|
|
170
170
|
})
|
|
171
171
|
})
|
|
172
172
|
});
|
|
@@ -238,10 +238,10 @@ const VersionContent = ()=>{
|
|
|
238
238
|
children: [
|
|
239
239
|
...layout,
|
|
240
240
|
...remainingFieldsLayout
|
|
241
|
-
].map((panel
|
|
241
|
+
].map((panel)=>{
|
|
242
242
|
return /*#__PURE__*/ jsx(FormPanel, {
|
|
243
243
|
panel: panel
|
|
244
|
-
},
|
|
244
|
+
}, panel.flatMap((row)=>row.map((field)=>field.name)).join('.'));
|
|
245
245
|
})
|
|
246
246
|
})
|
|
247
247
|
}, version.id),
|
|
@@ -300,10 +300,10 @@ const VersionContent = ()=>{
|
|
|
300
300
|
alignItems: "stretch",
|
|
301
301
|
gap: 6,
|
|
302
302
|
position: "relative",
|
|
303
|
-
children: unknownFieldsLayout.map((panel
|
|
303
|
+
children: unknownFieldsLayout.map((panel)=>{
|
|
304
304
|
return /*#__PURE__*/ jsx(FormPanel, {
|
|
305
305
|
panel: panel
|
|
306
|
-
},
|
|
306
|
+
}, panel.flatMap((row)=>row.map((field)=>field.name)).join('.'));
|
|
307
307
|
})
|
|
308
308
|
})
|
|
309
309
|
}, `${version.id}-unknownFields`)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VersionContent.mjs","sources":["../../../../admin/src/history/components/VersionContent.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Form, Layouts, createRulesEngine, useForm, useIsMobile } from '@strapi/admin/strapi-admin';\nimport { Box, Divider, Flex, Grid, Typography } from '@strapi/design-system';\nimport flow from 'lodash/flow';\nimport { useIntl } from 'react-intl';\n\nimport { useDoc } from '../../hooks/useDocument';\nimport { useTypedSelector } from '../../modules/hooks';\nimport {\n prepareTempKeys,\n removeFieldsThatDontExistOnSchema,\n} from '../../pages/EditView/utils/data';\nimport {\n getConditionDependencyPaths,\n getConditionDependencySubscriptionValue,\n} from '../../utils/conditionalFields';\nimport { HistoryContextValue, useHistoryContext } from '../pages/History';\n\nimport { VersionInputRenderer } from './VersionInputRenderer';\n\nimport type { Metadatas } from '../../../../shared/contracts/content-types';\nimport type { GetInitData } from '../../../../shared/contracts/init';\nimport type { ComponentsDictionary, Document } from '../../hooks/useDocument';\nimport type { EditFieldLayout } from '../../hooks/useDocumentLayout';\nimport type { Schema } from '@strapi/types';\n\nconst createLayoutFromFields = <T extends EditFieldLayout | UnknownField>(fields: T[]) => {\n return (\n fields\n .reduce<Array<T[]>>((rows, field) => {\n if (field.type === 'dynamiczone') {\n // Dynamic zones take up all the columns in a row\n rows.push([field]);\n\n return rows;\n }\n\n if (!rows[rows.length - 1]) {\n // Create a new row if there isn't one available\n rows.push([]);\n }\n\n // Push fields to the current row, they wrap and handle their own column size\n rows[rows.length - 1].push(field);\n\n return rows;\n }, [])\n // Map the rows to panels\n .map((row) => [row])\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * getRemainingFieldsLayout\n * -----------------------------------------------------------------------------------------------*/\n\ninterface GetRemainingFieldsLayoutOptions\n extends Pick<HistoryContextValue, 'layout'>,\n Pick<GetInitData.Response['data'], 'fieldSizes'> {\n schemaAttributes: HistoryContextValue['schema']['attributes'];\n metadatas: Metadatas;\n}\n\n/**\n * Build a layout for the fields that are were deleted from the edit view layout\n * via the configure the view page. This layout will be merged with the main one.\n * Those fields would be restored if the user restores the history version, which is why it's\n * important to show them, even if they're not in the normal layout.\n */\nfunction getRemaingFieldsLayout({\n layout,\n metadatas,\n schemaAttributes,\n fieldSizes,\n}: GetRemainingFieldsLayoutOptions) {\n const fieldsInLayout = layout.flatMap((panel) =>\n panel.flatMap((row) => row.flatMap((field) => field.name))\n );\n const remainingFields = Object.entries(metadatas).reduce<EditFieldLayout[]>(\n (currentRemainingFields, [name, field]) => {\n // Make sure we do not fields that are not visible, e.g. \"id\"\n if (!fieldsInLayout.includes(name) && field.edit.visible === true) {\n const attribute = schemaAttributes[name];\n // @ts-expect-error not sure why attribute causes type error\n currentRemainingFields.push({\n attribute,\n type: attribute.type,\n visible: true,\n disabled: true,\n label: field.edit.label || name,\n name: name,\n size: fieldSizes[attribute.type].default ?? 12,\n });\n }\n\n return currentRemainingFields;\n },\n []\n );\n\n return createLayoutFromFields(remainingFields);\n}\n\n/* -------------------------------------------------------------------------------------------------\n * FormPanel\n * -----------------------------------------------------------------------------------------------*/\n\n// Reuse one rules engine instance instead of creating a new one on every render.\nconst rulesEngine = createRulesEngine();\n\nconst getPanelConditionDependencyPaths = (panel: EditFieldLayout[][]): string[] | null => {\n // Aggregate condition dependencies across all fields in the panel so we can subscribe narrowly.\n const dependencies = new Set<string>();\n\n for (const row of panel) {\n for (const field of row) {\n const condition = field.attribute?.conditions?.visible;\n\n if (!condition) {\n continue;\n }\n\n const paths = getConditionDependencyPaths(condition);\n\n if (paths === null) {\n return null;\n }\n\n for (const path of paths) {\n dependencies.add(path);\n }\n }\n }\n\n return [...dependencies].sort();\n};\n\nconst FormPanel = ({ panel }: { panel: EditFieldLayout[][] }) => {\n const isMobile = useIsMobile();\n const conditionDependencyPaths = React.useMemo(\n () => getPanelConditionDependencyPaths(panel),\n [panel]\n );\n const getValues = useForm(\n 'FormPanel',\n (state) => (state as typeof state & { getValues: () => unknown }).getValues\n );\n const conditionSubscriptionValue = useForm('FormPanel', (state) => {\n return getConditionDependencySubscriptionValue(state.values, conditionDependencyPaths);\n });\n // For narrow subscriptions, read the latest full values lazily via getValues() to evaluate rules.\n // This avoids rerendering for unrelated form changes while preserving correct condition evaluation.\n const fieldValues = conditionDependencyPaths === null ? conditionSubscriptionValue : getValues();\n\n const isFieldVisible = React.useCallback(\n (field: EditFieldLayout) => {\n const condition = field.attribute?.conditions?.visible;\n\n if (!condition) {\n return true;\n }\n\n return rulesEngine.evaluate(condition, fieldValues);\n },\n [fieldValues]\n );\n\n if (panel.some((row) => row.some((field) => field.type === 'dynamiczone'))) {\n const [row] = panel;\n const [field] = row;\n\n if (!isFieldVisible(field)) {\n return null;\n }\n\n return (\n <Grid.Root key={field.name} gap={4}>\n <Grid.Item xs={12} direction=\"column\" alignItems=\"stretch\">\n <VersionInputRenderer {...field} />\n </Grid.Item>\n </Grid.Root>\n );\n }\n\n return (\n <Box\n hasRadius={!isMobile}\n background={{ initial: 'transparent', medium: 'neutral0' }}\n shadow={{ initial: 'none', medium: 'tableShadow' }}\n padding={{ initial: 0, medium: 6 }}\n borderColor={{ initial: 'transparent', medium: 'neutral150' }}\n >\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6}>\n {panel.map((row, gridRowIndex) => {\n const visibleFields = row.filter(isFieldVisible);\n\n if (visibleFields.length === 0) {\n return null; // Skip rendering the entire grid row\n }\n\n return (\n <Grid.Root key={gridRowIndex} gap={{ initial: 6, medium: 4 }}>\n {visibleFields.map(({ size, ...field }) => {\n return (\n <Grid.Item\n col={size}\n key={field.name}\n xs={12}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n <VersionInputRenderer {...field} />\n </Grid.Item>\n );\n })}\n </Grid.Root>\n );\n })}\n </Flex>\n </Box>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * VersionContent\n * -----------------------------------------------------------------------------------------------*/\n\ntype UnknownField = EditFieldLayout & { shouldIgnoreRBAC: boolean };\n\nconst VersionContent = () => {\n const { formatMessage } = useIntl();\n const { fieldSizes } = useTypedSelector((state) => state['content-manager'].app);\n const version = useHistoryContext('VersionContent', (state) => state.selectedVersion);\n const layout = useHistoryContext('VersionContent', (state) => state.layout);\n const configuration = useHistoryContext('VersionContent', (state) => state.configuration);\n const schema = useHistoryContext('VersionContent', (state) => state.schema);\n\n // Build a layout for the unknown fields section\n const removedAttributes = version.meta.unknownAttributes.removed;\n const removedAttributesAsFields = Object.entries(removedAttributes).map(\n ([attributeName, attribute]) => {\n const field = {\n attribute,\n shouldIgnoreRBAC: true,\n type: attribute.type,\n visible: true,\n disabled: true,\n label: attributeName,\n name: attributeName,\n size: fieldSizes[attribute.type].default ?? 12,\n } as UnknownField;\n\n return field;\n }\n );\n const unknownFieldsLayout = createLayoutFromFields(removedAttributesAsFields);\n\n // Build a layout for the fields that are were deleted from the layout\n const remainingFieldsLayout = getRemaingFieldsLayout({\n metadatas: configuration.contentType.metadatas,\n layout,\n schemaAttributes: schema.attributes,\n fieldSizes,\n });\n\n const { components } = useDoc();\n\n /**\n * Transform the data before passing it to the form so that each field\n * has a uniquely generated key\n */\n const transformedData = React.useMemo(() => {\n const transform =\n (schemaAttributes: Schema.Attributes, components: ComponentsDictionary = {}) =>\n (document: Omit<Document, 'id'>) => {\n const schema = { attributes: schemaAttributes };\n\n const transformations = flow(\n removeFieldsThatDontExistOnSchema(schema),\n prepareTempKeys(schema, components)\n );\n return transformations(document);\n };\n\n return transform(version.schema, components)(version.data);\n }, [components, version.data, version.schema]);\n\n return (\n <Layouts.Content>\n <Box paddingBottom={{ initial: 0, large: 8 }}>\n <Form key={version.id} disabled={true} method=\"PUT\" initialValues={transformedData}>\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6} position=\"relative\">\n {[...layout, ...remainingFieldsLayout].map((panel, index) => {\n return <FormPanel key={index} panel={panel} />;\n })}\n </Flex>\n </Form>\n {removedAttributesAsFields.length > 0 && (\n <>\n <Box paddingTop={{ initial: 4, large: 0 }}>\n <Divider />\n </Box>\n <Box paddingTop={{ initial: 4, large: 8 }}>\n <Flex\n direction=\"column\"\n alignItems=\"flex-start\"\n paddingBottom={{ initial: 4, large: 6 }}\n gap={1}\n >\n <Typography variant=\"delta\">\n {formatMessage({\n id: 'content-manager.history.content.unknown-fields.title',\n defaultMessage: 'Unknown fields',\n })}\n </Typography>\n <Typography variant=\"pi\">\n {formatMessage(\n {\n id: 'content-manager.history.content.unknown-fields.message',\n defaultMessage:\n 'These fields have been deleted or renamed in the Content-Type Builder. <b>These fields will not be restored.</b>',\n },\n {\n b: (chunks: React.ReactNode) => (\n <Typography variant=\"pi\" fontWeight=\"bold\">\n {chunks}\n </Typography>\n ),\n }\n )}\n </Typography>\n </Flex>\n <Form\n key={`${version.id}-unknownFields`}\n disabled={true}\n method=\"PUT\"\n initialValues={version.data}\n >\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6} position=\"relative\">\n {unknownFieldsLayout.map((panel, index) => {\n return <FormPanel key={index} panel={panel} />;\n })}\n </Flex>\n </Form>\n </Box>\n </>\n )}\n </Box>\n </Layouts.Content>\n );\n};\n\nexport { VersionContent, getRemaingFieldsLayout };\n"],"names":["createLayoutFromFields","fields","reduce","rows","field","type","push","length","map","row","getRemaingFieldsLayout","layout","metadatas","schemaAttributes","fieldSizes","fieldsInLayout","flatMap","panel","name","remainingFields","Object","entries","currentRemainingFields","includes","edit","visible","attribute","disabled","label","size","default","rulesEngine","createRulesEngine","getPanelConditionDependencyPaths","dependencies","Set","condition","conditions","paths","getConditionDependencyPaths","path","add","sort","FormPanel","isMobile","useIsMobile","conditionDependencyPaths","React","useMemo","getValues","useForm","state","conditionSubscriptionValue","getConditionDependencySubscriptionValue","values","fieldValues","isFieldVisible","useCallback","evaluate","some","_jsx","Grid","Root","gap","Item","xs","direction","alignItems","VersionInputRenderer","Box","hasRadius","background","initial","medium","shadow","padding","borderColor","Flex","gridRowIndex","visibleFields","filter","col","VersionContent","formatMessage","useIntl","useTypedSelector","app","version","useHistoryContext","selectedVersion","configuration","schema","removedAttributes","meta","unknownAttributes","removed","removedAttributesAsFields","attributeName","shouldIgnoreRBAC","unknownFieldsLayout","remainingFieldsLayout","contentType","attributes","components","useDoc","transformedData","transform","document","transformations","flow","removeFieldsThatDontExistOnSchema","prepareTempKeys","data","Layouts","Content","_jsxs","paddingBottom","large","Form","method","initialValues","position","index","id","_Fragment","paddingTop","Divider","Typography","variant","defaultMessage","b","chunks","fontWeight"],"mappings":";;;;;;;;;;;;;AA2BA,MAAMA,yBAAyB,CAA2CC,MAAAA,GAAAA;AACxE,IAAA,OACEA,MAAAA,CACGC,MAAM,CAAa,CAACC,IAAAA,EAAMC,KAAAA,GAAAA;QACzB,IAAIA,KAAAA,CAAMC,IAAI,KAAK,aAAA,EAAe;;AAEhCF,YAAAA,IAAAA,CAAKG,IAAI,CAAC;AAACF,gBAAAA;AAAM,aAAA,CAAA;YAEjB,OAAOD,IAAAA;AACT,QAAA;AAEA,QAAA,IAAI,CAACA,IAAI,CAACA,KAAKI,MAAM,GAAG,EAAE,EAAE;;YAE1BJ,IAAAA,CAAKG,IAAI,CAAC,EAAE,CAAA;AACd,QAAA;;AAGAH,QAAAA,IAAI,CAACA,IAAAA,CAAKI,MAAM,GAAG,CAAA,CAAE,CAACD,IAAI,CAACF,KAAAA,CAAAA;QAE3B,OAAOD,IAAAA;IACT,CAAA,EAAG,EAAE,CACL;KACCK,GAAG,CAAC,CAACC,GAAAA,GAAQ;AAACA,YAAAA;AAAI,SAAA,CAAA;AAEzB,CAAA;AAaA;;;;;IAMA,SAASC,sBAAAA,CAAuB,EAC9BC,MAAM,EACNC,SAAS,EACTC,gBAAgB,EAChBC,UAAU,EACsB,EAAA;AAChC,IAAA,MAAMC,iBAAiBJ,MAAAA,CAAOK,OAAO,CAAC,CAACC,QACrCA,KAAAA,CAAMD,OAAO,CAAC,CAACP,MAAQA,GAAAA,CAAIO,OAAO,CAAC,CAACZ,KAAAA,GAAUA,MAAMc,IAAI,CAAA,CAAA,CAAA;IAE1D,MAAM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W,MAAA;AACjCD,wDAAAA,QAAAA,EAAAA;;AAGP,6CAAA;;;;8CAINvE,GAAA,CAAC0D,IAAAA,EAAAA;oCAEC3F,QAAAA,EAAU,IAAA;oCACV4F,MAAAA,EAAO,KAAA;AACPC,oCAAAA,aAAAA,EAAejC,QAAQyB,IAAI;AAE3B,oCAAA,QAAA,gBAAApD,GAAA,CAACiB,IAAAA,EAAAA;wCAAKX,SAAAA,EAAU,QAAA;wCAASC,UAAAA,EAAW,SAAA;wCAAUJ,GAAAA,EAAK,CAAA;wCAAG0D,QAAAA,EAAS,UAAA;kDAC5DtB,mBAAAA,CAAoB3F,GAAG,CAAC,CAACS,KAAAA,EAAOyG,KAAAA,GAAAA;AAC/B,4CAAA,qBAAO9D,GAAA,CAACjB,SAAAA,EAAAA;gDAAsB1B,KAAAA,EAAOA;AAAdyG,6CAAAA,EAAAA,KAAAA,CAAAA;AACzB,wCAAA,CAAA;;AARG,iCAAA,EAAA,CAAA,EAAGnC,OAAAA,CAAQoC,EAAE,CAAC,cAAc,CAAC;;;;;;;;AAiBlD;;;;"}
|
|
1
|
+
{"version":3,"file":"VersionContent.mjs","sources":["../../../../admin/src/history/components/VersionContent.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Form, Layouts, createRulesEngine, useForm, useIsMobile } from '@strapi/admin/strapi-admin';\nimport { Box, Divider, Flex, Grid, Typography } from '@strapi/design-system';\nimport flow from 'lodash/flow';\nimport { useIntl } from 'react-intl';\n\nimport { useDoc } from '../../hooks/useDocument';\nimport { useTypedSelector } from '../../modules/hooks';\nimport {\n prepareTempKeys,\n removeFieldsThatDontExistOnSchema,\n} from '../../pages/EditView/utils/data';\nimport {\n getConditionDependencyPaths,\n getConditionDependencySubscriptionValue,\n} from '../../utils/conditionalFields';\nimport { HistoryContextValue, useHistoryContext } from '../pages/History';\n\nimport { VersionInputRenderer } from './VersionInputRenderer';\n\nimport type { Metadatas } from '../../../../shared/contracts/content-types';\nimport type { GetInitData } from '../../../../shared/contracts/init';\nimport type { ComponentsDictionary, Document } from '../../hooks/useDocument';\nimport type { EditFieldLayout } from '../../hooks/useDocumentLayout';\nimport type { Schema } from '@strapi/types';\n\nconst createLayoutFromFields = <T extends EditFieldLayout | UnknownField>(fields: T[]) => {\n return (\n fields\n .reduce<Array<T[]>>((rows, field) => {\n if (field.type === 'dynamiczone') {\n // Dynamic zones take up all the columns in a row\n rows.push([field]);\n\n return rows;\n }\n\n if (!rows[rows.length - 1]) {\n // Create a new row if there isn't one available\n rows.push([]);\n }\n\n // Push fields to the current row, they wrap and handle their own column size\n rows[rows.length - 1].push(field);\n\n return rows;\n }, [])\n // Map the rows to panels\n .map((row) => [row])\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * getRemainingFieldsLayout\n * -----------------------------------------------------------------------------------------------*/\n\ninterface GetRemainingFieldsLayoutOptions\n extends Pick<HistoryContextValue, 'layout'>, Pick<GetInitData.Response['data'], 'fieldSizes'> {\n schemaAttributes: HistoryContextValue['schema']['attributes'];\n metadatas: Metadatas;\n}\n\n/**\n * Build a layout for the fields that are were deleted from the edit view layout\n * via the configure the view page. This layout will be merged with the main one.\n * Those fields would be restored if the user restores the history version, which is why it's\n * important to show them, even if they're not in the normal layout.\n */\nfunction getRemaingFieldsLayout({\n layout,\n metadatas,\n schemaAttributes,\n fieldSizes,\n}: GetRemainingFieldsLayoutOptions) {\n const fieldsInLayout = new Set(\n layout.flatMap((panel) => panel.flatMap((row) => row.flatMap((field) => field.name)))\n );\n const remainingFields = Object.entries(metadatas).reduce<EditFieldLayout[]>(\n (currentRemainingFields, [name, field]) => {\n // Make sure we do not fields that are not visible, e.g. \"id\"\n if (!fieldsInLayout.has(name) && field.edit.visible === true) {\n const attribute = schemaAttributes[name];\n // @ts-expect-error not sure why attribute causes type error\n currentRemainingFields.push({\n attribute,\n type: attribute.type,\n visible: true,\n disabled: true,\n label: field.edit.label || name,\n name: name,\n size: fieldSizes[attribute.type].default ?? 12,\n });\n }\n\n return currentRemainingFields;\n },\n []\n );\n\n return createLayoutFromFields(remainingFields);\n}\n\n/* -------------------------------------------------------------------------------------------------\n * FormPanel\n * -----------------------------------------------------------------------------------------------*/\n\n// Reuse one rules engine instance instead of creating a new one on every render.\nconst rulesEngine = createRulesEngine();\n\nconst getPanelConditionDependencyPaths = (panel: EditFieldLayout[][]): string[] | null => {\n // Aggregate condition dependencies across all fields in the panel so we can subscribe narrowly.\n const dependencies = new Set<string>();\n\n for (const row of panel) {\n for (const field of row) {\n const condition = field.attribute?.conditions?.visible;\n\n if (!condition) {\n continue;\n }\n\n const paths = getConditionDependencyPaths(condition);\n\n if (paths === null) {\n return null;\n }\n\n for (const path of paths) {\n dependencies.add(path);\n }\n }\n }\n\n return [...dependencies].sort();\n};\n\nconst FormPanel = ({ panel }: { panel: EditFieldLayout[][] }) => {\n const isMobile = useIsMobile();\n const conditionDependencyPaths = React.useMemo(\n () => getPanelConditionDependencyPaths(panel),\n [panel]\n );\n const getValues = useForm(\n 'FormPanel',\n (state) => (state as typeof state & { getValues: () => unknown }).getValues\n );\n const conditionSubscriptionValue = useForm('FormPanel', (state) => {\n return getConditionDependencySubscriptionValue(state.values, conditionDependencyPaths);\n });\n // For narrow subscriptions, read the latest full values lazily via getValues() to evaluate rules.\n // This avoids rerendering for unrelated form changes while preserving correct condition evaluation.\n const fieldValues = conditionDependencyPaths === null ? conditionSubscriptionValue : getValues();\n\n const isFieldVisible = React.useCallback(\n (field: EditFieldLayout) => {\n const condition = field.attribute?.conditions?.visible;\n\n if (!condition) {\n return true;\n }\n\n return rulesEngine.evaluate(condition, fieldValues);\n },\n [fieldValues]\n );\n\n if (panel.some((row) => row.some((field) => field.type === 'dynamiczone'))) {\n const [row] = panel;\n const [field] = row;\n\n if (!isFieldVisible(field)) {\n return null;\n }\n\n return (\n <Grid.Root key={field.name} gap={4}>\n <Grid.Item xs={12} direction=\"column\" alignItems=\"stretch\">\n <VersionInputRenderer {...field} />\n </Grid.Item>\n </Grid.Root>\n );\n }\n\n return (\n <Box\n hasRadius={!isMobile}\n background={{ initial: 'transparent', medium: 'neutral0' }}\n shadow={{ initial: 'none', medium: 'tableShadow' }}\n padding={{ initial: 0, medium: 6 }}\n borderColor={{ initial: 'transparent', medium: 'neutral150' }}\n >\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6}>\n {panel.map((row) => {\n const visibleFields = row.filter(isFieldVisible);\n\n if (visibleFields.length === 0) {\n return null; // Skip rendering the entire grid row\n }\n\n return (\n <Grid.Root\n key={row.map((field) => field.name).join('.')}\n gap={{ initial: 6, medium: 4 }}\n >\n {visibleFields.map(({ size, ...field }) => {\n return (\n <Grid.Item\n col={size}\n key={field.name}\n xs={12}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n <VersionInputRenderer {...field} />\n </Grid.Item>\n );\n })}\n </Grid.Root>\n );\n })}\n </Flex>\n </Box>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * VersionContent\n * -----------------------------------------------------------------------------------------------*/\n\ntype UnknownField = EditFieldLayout & { shouldIgnoreRBAC: boolean };\n\nconst VersionContent = () => {\n const { formatMessage } = useIntl();\n const { fieldSizes } = useTypedSelector((state) => state['content-manager'].app);\n const version = useHistoryContext('VersionContent', (state) => state.selectedVersion);\n const layout = useHistoryContext('VersionContent', (state) => state.layout);\n const configuration = useHistoryContext('VersionContent', (state) => state.configuration);\n const schema = useHistoryContext('VersionContent', (state) => state.schema);\n\n // Build a layout for the unknown fields section\n const removedAttributes = version.meta.unknownAttributes.removed;\n const removedAttributesAsFields = Object.entries(removedAttributes).map(\n ([attributeName, attribute]) => {\n const field = {\n attribute,\n shouldIgnoreRBAC: true,\n type: attribute.type,\n visible: true,\n disabled: true,\n label: attributeName,\n name: attributeName,\n size: fieldSizes[attribute.type].default ?? 12,\n } as UnknownField;\n\n return field;\n }\n );\n const unknownFieldsLayout = createLayoutFromFields(removedAttributesAsFields);\n\n // Build a layout for the fields that are were deleted from the layout\n const remainingFieldsLayout = getRemaingFieldsLayout({\n metadatas: configuration.contentType.metadatas,\n layout,\n schemaAttributes: schema.attributes,\n fieldSizes,\n });\n\n const { components } = useDoc();\n\n /**\n * Transform the data before passing it to the form so that each field\n * has a uniquely generated key\n */\n const transformedData = React.useMemo(() => {\n const transform =\n (schemaAttributes: Schema.Attributes, components: ComponentsDictionary = {}) =>\n (document: Omit<Document, 'id'>) => {\n const schema = { attributes: schemaAttributes };\n\n const transformations = flow(\n removeFieldsThatDontExistOnSchema(schema),\n prepareTempKeys(schema, components)\n );\n return transformations(document);\n };\n\n return transform(version.schema, components)(version.data);\n }, [components, version.data, version.schema]);\n\n return (\n <Layouts.Content>\n <Box paddingBottom={{ initial: 0, large: 8 }}>\n <Form key={version.id} disabled={true} method=\"PUT\" initialValues={transformedData}>\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6} position=\"relative\">\n {[...layout, ...remainingFieldsLayout].map((panel) => {\n return (\n <FormPanel\n key={panel.flatMap((row) => row.map((field) => field.name)).join('.')}\n panel={panel}\n />\n );\n })}\n </Flex>\n </Form>\n {removedAttributesAsFields.length > 0 && (\n <>\n <Box paddingTop={{ initial: 4, large: 0 }}>\n <Divider />\n </Box>\n <Box paddingTop={{ initial: 4, large: 8 }}>\n <Flex\n direction=\"column\"\n alignItems=\"flex-start\"\n paddingBottom={{ initial: 4, large: 6 }}\n gap={1}\n >\n <Typography variant=\"delta\">\n {formatMessage({\n id: 'content-manager.history.content.unknown-fields.title',\n defaultMessage: 'Unknown fields',\n })}\n </Typography>\n <Typography variant=\"pi\">\n {formatMessage(\n {\n id: 'content-manager.history.content.unknown-fields.message',\n defaultMessage:\n 'These fields have been deleted or renamed in the Content-Type Builder. <b>These fields will not be restored.</b>',\n },\n {\n b: (chunks: React.ReactNode) => (\n <Typography variant=\"pi\" fontWeight=\"bold\">\n {chunks}\n </Typography>\n ),\n }\n )}\n </Typography>\n </Flex>\n <Form\n key={`${version.id}-unknownFields`}\n disabled={true}\n method=\"PUT\"\n initialValues={version.data}\n >\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6} position=\"relative\">\n {unknownFieldsLayout.map((panel) => {\n return (\n <FormPanel\n key={panel.flatMap((row) => row.map((field) => field.name)).join('.')}\n panel={panel}\n />\n );\n })}\n </Flex>\n </Form>\n </Box>\n </>\n )}\n </Box>\n </Layouts.Content>\n );\n};\n\nexport { VersionContent, getRemaingFieldsLayout };\n"],"names":["createLayoutFromFields","fields","reduce","rows","field","type","push","length","map","row","getRemaingFieldsLayout","layout","metadatas","schemaAttributes","fieldSizes","fieldsInLayout","Set","flatMap","panel","name","remainingFields","Object","entries","currentRemainingFields","has","edit","visible","attribute","disabled","label","size","default","rulesEngine","createRulesEngine","getPanelConditionDependencyPaths","dependencies","condition","conditions","paths","getConditionDependencyPaths","path","add","sort","FormPanel","isMobile","useIsMobile","conditionDependencyPaths","React","useMemo","getValues","useForm","state","conditionSubscriptionValue","getConditionDependencySubscriptionValue","values","fieldValues","isFieldVisible","useCallback","evaluate","some","_jsx","Grid","Root","gap","Item","xs","direction","alignItems","VersionInputRenderer","Box","hasRadius","background","initial","medium","shadow","padding","borderColor","Flex","visibleFields","filter","col","join","VersionContent","formatMessage","useIntl","useTypedSelector","app","version","useHistoryContext","selectedVersion","configuration","schema","removedAttributes","meta","unknownAttributes","removed","removedAttributesAsFields","attributeName","shouldIgnoreRBAC","unknownFieldsLayout","remainingFieldsLayout","contentType","attributes","components","useDoc","transformedData","transform","document","transformations","flow","removeFieldsThatDontExistOnSchema","prepareTempKeys","data","Layouts","Content","_jsxs","paddingBottom","large","Form","method","initialValues","position","id","_Fragment","paddingTop","Divider","Typography","variant","defaultMessage","b","chunks","fontWeight"],"mappings":";;;;;;;;;;;;;AA2BA,MAAMA,yBAAyB,CAA2CC,MAAAA,GAAAA;AACxE,IAAA,OACEA,MAAAA,CACGC,MAAM,CAAa,CAACC,IAAAA,EAAMC,KAAAA,GAAAA;QACzB,IAAIA,KAAAA,CAAMC,IAAI,KAAK,aAAA,EAAe;;AAEhCF,YAAAA,IAAAA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U,QAAA;wCAASC,UAAAA,EAAW,SAAA;wCAAUJ,GAAAA,EAAK,CAAA;wCAAG0D,QAAAA,EAAS,UAAA;kDAC5DtB,mBAAAA,CAAoB3F,GAAG,CAAC,CAACU,KAAAA,GAAAA;AACxB,4CAAA,qBACE0C,GAAA,CAACjB,SAAAA,EAAAA;gDAECzB,KAAAA,EAAOA;AADFA,6CAAAA,EAAAA,KAAAA,CAAMD,OAAO,CAAC,CAACR,GAAAA,GAAQA,GAAAA,CAAID,GAAG,CAAC,CAACJ,KAAAA,GAAUA,KAAAA,CAAMe,IAAI,CAAA,CAAA,CAAG8D,IAAI,CAAC,GAAA,CAAA,CAAA;AAIvE,wCAAA,CAAA;;AAbG,iCAAA,EAAA,CAAA,EAAGM,OAAAA,CAAQmC,EAAE,CAAC,cAAc,CAAC;;;;;;;;AAsBlD;;;;"}
|
|
@@ -303,7 +303,8 @@ const CustomMediaInput = (props)=>{
|
|
|
303
303
|
* @description An abstraction around the regular form input renderer designed specifically
|
|
304
304
|
* to be used on the History page in the content-manager. It understands how to render specific
|
|
305
305
|
* inputs within the context of a history version (i.e. relations, media, ignored RBAC, etc...)
|
|
306
|
-
*/ const VersionInputRenderer = ({ visible, hint: providedHint, shouldIgnoreRBAC = false, labelAction,
|
|
306
|
+
*/ const VersionInputRenderer = ({ visible, hint: providedHint, shouldIgnoreRBAC = false, labelAction, // Not spread with the rest: design-system inputs have a `size` prop of their own.
|
|
307
|
+
size: _size, ...props })=>{
|
|
307
308
|
const customLabelAction = getLabelAction(labelAction);
|
|
308
309
|
const { formatMessage } = reactIntl.useIntl();
|
|
309
310
|
const version = History.useHistoryContext('VersionContent', (state)=>state.selectedVersion);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VersionInputRenderer.js","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 emptyLabel = formatMessage({\n id: 'content-manager.containers.empty-label',\n defaultMessage: 'Untitled',\n });\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, emptyLabel);\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: unknown) => {\n const keys = keyPath.split('.');\n // The root level object\n const root: Record<string, unknown> = {};\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 const nextNode =\n typeof node[key] === 'object' && node[key] !== null && Array.isArray(node[key]) === false\n ? (node[key] as Record<string, unknown>)\n : {};\n node[key] = nextNode;\n node = nextNode;\n }\n });\n\n return root;\n};\n\nconst CustomMediaInput = (props: VersionInputRendererProps) => {\n const { value } = useField<{ results: unknown[]; meta: { missingCount: number } }>(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","emptyLabel","id","defaultMessage","field","useField","name","formattedFieldValue","Array","isArray","value","results","meta","missingCount","hasResultsShape","length","_jsxs","_Fragment","_jsx","Field","Label","action","labelAction","label","Box","marginTop","variant","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","nextNode","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":";;;;;;;;;;;;;;;;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U,EAAE,GAAGC,SAAAA,EAAW,GAAGlK,KAAAA;AACjE,YAAA,qBACEoB,cAAA,CAAC6H,yBAAAA,EAAAA;AACE,gBAAA,GAAGiB,SAAS;gBACb7D,IAAAA,EAAMA,IAAAA;gBACN7E,WAAAA,EAAagF,iBAAAA;;AAEbsB,gBAAAA,IAAAA,EAAM9H,KAAAA,CAAMmI,WAAW,GAAG,cAAA,GAAiBnI,MAAM8H,IAAI;gBACrD/C,QAAAA,EAAU0D;;AAGlB;AACF;AAEA,MAAMP,+BAAAA,GAAkC,CACtC9F,SAAAA,GAEA,aAAA,IAAiBA,aAAa,OAAOA,SAAAA,CAAU+F,WAAW,KAAK,QAAA;;;;;;"}
|
|
1
|
+
{"version":3,"file":"VersionInputRenderer.js","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 emptyLabel = formatMessage({\n id: 'content-manager.containers.empty-label',\n defaultMessage: 'Untitled',\n });\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, emptyLabel);\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: unknown) => {\n const keys = keyPath.split('.');\n // The root level object\n const root: Record<string, unknown> = {};\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 const nextNode =\n typeof node[key] === 'object' && node[key] !== null && Array.isArray(node[key]) === false\n ? (node[key] as Record<string, unknown>)\n : {};\n node[key] = nextNode;\n node = nextNode;\n }\n });\n\n return root;\n};\n\nconst CustomMediaInput = (props: VersionInputRendererProps) => {\n const { value } = useField<{ results: unknown[]; meta: { missingCount: number } }>(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 /** Passed down by component and dynamic zone layouts; not used here. */\n size?: number;\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 // Not spread with the rest: design-system inputs have a `size` prop of their own.\n size: _size,\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","emptyLabel","id","defaultMessage","field","useField","name","formattedFieldValue","Array","isArray","value","results","meta","missingCount","hasResultsShape","length","_jsxs","_Fragment","_jsx","Field","Label","action","labelAction","label","Box","marginTop","variant","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","nextNode","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","size","_size","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,uBAAAA,CAAOC,kBAAAA,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,uBAAAA,CAAOO,iBAAAA,CAAK;;;;;;;;;AASjC,CAAC;AAED,MAAMC,sBAAsB,CAACC,KAAAA,GAAAA;IAC3B,MAAM,EAAEC,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;AAC1B,IAAA,MAAMC,aAAaF,aAAAA,CAAc;QAC/BG,EAAAA,EAAI,wCAAA;QACJC,cAAAA,EAAgB;AAClB,KAAA,CAA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abstraction around the regular form input renderer designed specifically
|
|
282
282
|
* to be used on the History page in the content-manager. It understands how to render specific
|
|
283
283
|
* inputs within the context of a history version (i.e. relations, media, ignored RBAC, etc...)
|
|
284
|
-
*/ const VersionInputRenderer = ({ visible, hint: providedHint, shouldIgnoreRBAC = false, labelAction,
|
|
284
|
+
*/ const VersionInputRenderer = ({ visible, hint: providedHint, shouldIgnoreRBAC = false, labelAction, // Not spread with the rest: design-system inputs have a `size` prop of their own.
|
|
285
|
+
size: _size, ...props })=>{
|
|
285
286
|
const customLabelAction = getLabelAction(labelAction);
|
|
286
287
|
const { formatMessage } = useIntl();
|
|
287
288
|
const version = useHistoryContext('VersionContent', (state)=>state.selectedVersion);
|