@strapi/content-manager 5.52.1 → 5.52.3
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 +6 -3
- package/dist/admin/components/ConfigurationForm/Fields.js.map +1 -1
- package/dist/admin/components/ConfigurationForm/Fields.mjs +6 -3
- package/dist/admin/components/ConfigurationForm/Fields.mjs.map +1 -1
- package/dist/admin/history/components/VersionInputRenderer.js +5 -1
- package/dist/admin/history/components/VersionInputRenderer.js.map +1 -1
- package/dist/admin/history/components/VersionInputRenderer.mjs +5 -1
- package/dist/admin/history/components/VersionInputRenderer.mjs.map +1 -1
- package/dist/admin/hooks/usePersistentQueryParams.js +10 -2
- package/dist/admin/hooks/usePersistentQueryParams.js.map +1 -1
- package/dist/admin/hooks/usePersistentQueryParams.mjs +11 -3
- package/dist/admin/hooks/usePersistentQueryParams.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +29 -11
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +29 -11
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
- package/dist/admin/pages/ListView/ListViewPage.js +3 -3
- package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
- package/dist/admin/pages/ListView/ListViewPage.mjs +4 -4
- package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
- package/dist/admin/pages/ListView/components/TableCells/Relations.js +11 -2
- package/dist/admin/pages/ListView/components/TableCells/Relations.js.map +1 -1
- package/dist/admin/pages/ListView/components/TableCells/Relations.mjs +11 -2
- package/dist/admin/pages/ListView/components/TableCells/Relations.mjs.map +1 -1
- package/dist/admin/src/utils/relations.d.ts +4 -3
- package/dist/admin/translations/cs.json.js +1 -0
- package/dist/admin/translations/cs.json.js.map +1 -1
- package/dist/admin/translations/cs.json.mjs +1 -0
- package/dist/admin/translations/cs.json.mjs.map +1 -1
- package/dist/admin/translations/de.json.js +1 -0
- package/dist/admin/translations/de.json.js.map +1 -1
- package/dist/admin/translations/de.json.mjs +1 -0
- package/dist/admin/translations/de.json.mjs.map +1 -1
- package/dist/admin/translations/en.json.js +1 -0
- package/dist/admin/translations/en.json.js.map +1 -1
- package/dist/admin/translations/en.json.mjs +1 -0
- package/dist/admin/translations/en.json.mjs.map +1 -1
- package/dist/admin/translations/fr.json.js +1 -0
- package/dist/admin/translations/fr.json.js.map +1 -1
- package/dist/admin/translations/fr.json.mjs +1 -0
- package/dist/admin/translations/fr.json.mjs.map +1 -1
- package/dist/admin/translations/ja.json.js +1 -0
- package/dist/admin/translations/ja.json.js.map +1 -1
- package/dist/admin/translations/ja.json.mjs +1 -0
- package/dist/admin/translations/ja.json.mjs.map +1 -1
- package/dist/admin/translations/ko.json.js +1 -0
- package/dist/admin/translations/ko.json.js.map +1 -1
- package/dist/admin/translations/ko.json.mjs +1 -0
- package/dist/admin/translations/ko.json.mjs.map +1 -1
- package/dist/admin/translations/nl.json.js +1 -0
- package/dist/admin/translations/nl.json.js.map +1 -1
- package/dist/admin/translations/nl.json.mjs +1 -0
- package/dist/admin/translations/nl.json.mjs.map +1 -1
- package/dist/admin/translations/pl.json.js +1 -0
- package/dist/admin/translations/pl.json.js.map +1 -1
- package/dist/admin/translations/pl.json.mjs +1 -0
- package/dist/admin/translations/pl.json.mjs.map +1 -1
- package/dist/admin/translations/pt-BR.json.js +5 -5
- package/dist/admin/translations/pt-BR.json.mjs +5 -5
- package/dist/admin/translations/sk.json.js +1 -0
- package/dist/admin/translations/sk.json.js.map +1 -1
- package/dist/admin/translations/sk.json.mjs +1 -0
- package/dist/admin/translations/sk.json.mjs.map +1 -1
- package/dist/admin/utils/relations.js +9 -4
- package/dist/admin/utils/relations.js.map +1 -1
- package/dist/admin/utils/relations.mjs +9 -4
- package/dist/admin/utils/relations.mjs.map +1 -1
- package/dist/server/controllers/collection-types.js +1 -1
- package/dist/server/controllers/collection-types.js.map +1 -1
- package/dist/server/controllers/collection-types.mjs +1 -1
- package/dist/server/controllers/collection-types.mjs.map +1 -1
- package/dist/server/history/services/history.js +22 -4
- package/dist/server/history/services/history.js.map +1 -1
- package/dist/server/history/services/history.mjs +22 -4
- package/dist/server/history/services/history.mjs.map +1 -1
- package/dist/server/mcp/schemas/data-schema.js +6 -1
- package/dist/server/mcp/schemas/data-schema.js.map +1 -1
- package/dist/server/mcp/schemas/data-schema.mjs +6 -1
- package/dist/server/mcp/schemas/data-schema.mjs.map +1 -1
- package/dist/server/services/permission-checker.js +0 -4
- package/dist/server/services/permission-checker.js.map +1 -1
- package/dist/server/services/permission-checker.mjs +0 -4
- package/dist/server/services/permission-checker.mjs.map +1 -1
- package/dist/server/src/history/services/history.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +4 -4
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/mcp/schemas/data-schema.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +4 -4
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/permission-checker.d.ts +2 -2
- package/dist/server/src/services/permission-checker.d.ts.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Fields.mjs","sources":["../../../../admin/src/components/ConfigurationForm/Fields.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useDroppable, DndContext, UniqueIdentifier, DragOverlay } from '@dnd-kit/core';\nimport { arraySwap, SortableContext, useSortable, rectSwappingStrategy } from '@dnd-kit/sortable';\nimport { CSS } from '@dnd-kit/utilities';\nimport { useField, useForm, useIsDesktop } from '@strapi/admin/strapi-admin';\nimport {\n Modal,\n Box,\n Flex,\n Grid,\n IconButton,\n IconButtonComponent,\n Typography,\n Link,\n Menu,\n} from '@strapi/design-system';\nimport { Cog, Cross, Drag, Pencil, Plus } from '@strapi/icons';\nimport { generateNKeysBetween as generateNKeysBetweenImpl } from 'fractional-indexing';\nimport { produce } from 'immer';\nimport { useIntl } from 'react-intl';\nimport { NavLink } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { getTranslation } from '../../utils/translations';\nimport { ComponentIcon } from '../ComponentIcon';\n\nimport { EditFieldForm, EditFieldFormProps } from './EditFieldForm';\n\nimport type { ConfigurationFormData, EditFieldSpacerLayout } from './Form';\nimport type { EditLayout } from '../../hooks/useDocumentLayout';\n\ntype FormField = ConfigurationFormData['layout'][number]['children'][number];\ntype Field = Omit<ConfigurationFormData['layout'][number]['children'][number], '__temp_key__'>;\n\nconst GRID_COLUMNS = 12;\n\n/* -------------------------------------------------------------------------------------------------\n * Drag and Drop\n * -----------------------------------------------------------------------------------------------*/\n\nconst DroppableContainer = ({\n id,\n children,\n}: {\n id: string;\n children: (props: ReturnType<typeof useDroppable>) => React.ReactNode;\n}) => {\n const droppable = useDroppable({\n id,\n });\n\n return children(droppable);\n};\n\nexport const SortableItem = ({ id, children }: { id: string; children: React.ReactNode }) => {\n const { attributes, setNodeRef, transform, transition, isDragging } = useSortable({\n id,\n });\n\n const style = {\n transform: CSS.Transform.toString({\n x: transform?.x ?? 0,\n y: transform?.y ?? 0,\n // Avoid any scaling animations which can visually \"squish\" or\n // \"stretch\" neighbouring cards in mixed-width grids (4/8/12 cols).\n scaleX: 1,\n scaleY: 1,\n }),\n transition,\n height: '100%',\n opacity: isDragging ? 0.6 : 1,\n outlineOffset: 2,\n };\n\n return (\n <div ref={setNodeRef} style={style} {...attributes}>\n {children}\n </div>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Fields\n * -----------------------------------------------------------------------------------------------*/\n\ninterface FieldsProps extends Pick<EditLayout, 'metadatas'>, Pick<FieldProps, 'components'> {\n attributes: {\n [key: string]: FieldProps['attribute'];\n };\n fieldSizes: Record<string, number>;\n components: EditLayout['components'];\n}\n\n/**\n * Compute uids and formName for drag and drop items for the incoming layout\n */\nconst createDragAndDropContainersFromLayout = (layout: ConfigurationFormData['layout']) => {\n return layout.map((row, containerIndex) => ({\n ...row,\n // Use unique ids for drag and drop items\n dndId: `container-${containerIndex}`,\n children: row.children.map((child, childIndex) => ({\n ...child,\n dndId: `container-${containerIndex}-child-${childIndex}`,\n\n // The formName must be recomputed each time an item is moved\n formName: `layout.${containerIndex}.children.${childIndex}`,\n })),\n }));\n};\n\nconst Fields = ({ attributes, fieldSizes, components, metadatas = {} }: FieldsProps) => {\n const { formatMessage } = useIntl();\n\n const layout = useForm<ConfigurationFormData['layout']>(\n 'Fields',\n (state) => (state.values as ConfigurationFormData).layout ?? []\n );\n\n const onChange = useForm('Fields', (state) => state.onChange);\n const addFieldRow = useForm('Fields', (state) => state.addFieldRow);\n const removeFieldRow = useForm('Fields', (state) => state.removeFieldRow);\n\n const existingFields = layout.map((row) => row.children.map((field) => field.name)).flat();\n\n /**\n * Get the fields that are not already in the layout\n * But also check that they are visible before we give users\n * the option to display them. e.g. `id` is not visible.\n */\n const remainingFields = Object.entries(metadatas).reduce<Field[]>((acc, current) => {\n const [name, { visible, ...field }] = current;\n\n if (!existingFields.includes(name) && visible === true) {\n const type = attributes[name]?.type;\n const size = type ? fieldSizes[type] : GRID_COLUMNS;\n\n acc.push({\n ...field,\n label: field.label ?? name,\n name,\n size,\n });\n }\n\n return acc;\n }, []);\n\n const handleRemoveField =\n (rowIndex: number, fieldIndex: number): FieldProps['onRemoveField'] =>\n () => {\n if (layout[rowIndex].children.length === 1) {\n removeFieldRow(`layout`, rowIndex);\n } else {\n onChange(`layout.${rowIndex}.children`, [\n ...layout[rowIndex].children.slice(0, fieldIndex),\n ...layout[rowIndex].children.slice(fieldIndex + 1),\n ]);\n }\n };\n\n const handleAddField = (field: Field) => () => {\n addFieldRow('layout', { children: [field] });\n };\n\n const [containers, setContainers] = React.useState(() =>\n createDragAndDropContainersFromLayout(layout)\n );\n type Container = (typeof containers)[number];\n const [activeDragItem, setActiveDragItem] = React.useState<Container['children'][number] | null>(\n null\n );\n\n /**\n * Finds either the parent container id or the child id within a container\n */\n function findContainer(id: UniqueIdentifier, containersAsDictionary: Record<string, Container>) {\n // If the id is a key, then it is the parent container\n if (id in containersAsDictionary) {\n return id;\n }\n\n // Otherwise, it is a child inside a container\n return Object.keys(containersAsDictionary).find((key) =>\n containersAsDictionary[key].children.find((child) => child.dndId === id)\n );\n }\n\n /**\n * Gets an item from a container based on its id\n */\n const getItemFromContainer = (id: UniqueIdentifier, container: Container) => {\n return container.children.find((item) => id === item.dndId);\n };\n\n /**\n * Gets the containers as dictionary for quick lookup\n */\n const getContainersAsDictionary = () => {\n return Object.fromEntries(containers.map((container) => [container.dndId, container]));\n };\n\n /**\n * Recomputes the empty space in the grid\n */\n const createContainersWithSpacers = (layout: typeof containers) => {\n return layout\n .map((row) => ({\n ...row,\n children: row.children.filter((field) => field.name !== TEMP_FIELD_NAME),\n }))\n .filter((row) => row.children.length > 0)\n .map((row) => {\n const totalSpaceTaken = row.children.reduce((acc, curr) => acc + curr.size, 0);\n\n if (totalSpaceTaken < GRID_COLUMNS) {\n const [spacerKey] = generateNKeysBetweenImpl(\n row.children.at(-1)?.__temp_key__,\n undefined,\n 1\n );\n\n return {\n ...row,\n children: [\n ...row.children,\n {\n name: TEMP_FIELD_NAME,\n size: GRID_COLUMNS - totalSpaceTaken,\n __temp_key__: spacerKey,\n } satisfies EditFieldSpacerLayout,\n ],\n };\n }\n\n return row;\n });\n };\n\n /**\n * When layout changes (e.g. when a field size is changed or the containers are reordered)\n * we need to update the ids and form names\n */\n React.useEffect(() => {\n const containers = createDragAndDropContainersFromLayout(layout);\n setContainers(containers);\n }, [layout, setContainers]);\n\n return (\n <DndContext\n onDragStart={(event) => {\n const containersAsDictionary = getContainersAsDictionary();\n\n const activeContainer = findContainer(event.active.id, containersAsDictionary);\n\n if (!activeContainer) return;\n\n const activeItem = getItemFromContainer(\n event.active.id,\n containersAsDictionary[activeContainer]\n );\n\n if (activeItem) {\n setActiveDragItem(activeItem);\n }\n }}\n onDragOver={({ active, over }) => {\n const containersAsDictionary = getContainersAsDictionary();\n const activeContainer = findContainer(active.id, containersAsDictionary);\n const overContainer = findContainer(over?.id ?? '', containersAsDictionary);\n const activeContainerIndex = containers.findIndex(\n (container) => container.dndId === activeContainer\n );\n const overContainerIndex = containers.findIndex(\n (container) => container.dndId === overContainer\n );\n\n if (!activeContainer || !overContainer) {\n return;\n }\n\n const draggedItem = getItemFromContainer(\n active.id,\n containersAsDictionary[activeContainer]\n );\n const overItem = getItemFromContainer(\n over?.id ?? '',\n containersAsDictionary[overContainer]\n );\n const overIndex = containersAsDictionary[overContainer].children.findIndex(\n (item) => item.dndId === over?.id\n );\n const activeIndex = containersAsDictionary[activeContainer].children.findIndex(\n (item) => item.dndId === active.id\n );\n\n if (!draggedItem) return;\n\n // Handle a full width field being dragged\n if (draggedItem?.size === GRID_COLUMNS) {\n // Swap the items in the containers\n const update = produce(containers, (draft) => {\n draft[activeContainerIndex].children = containers[overContainerIndex].children;\n draft[overContainerIndex].children = containers[activeContainerIndex].children;\n });\n setContainers(update);\n return;\n }\n\n /**\n * Handle an item being dragged from one container to another,\n * the item is removed from its current container, and then added to its new container\n * An item can only be added in a container if there is enough space\n */\n const update = produce(containers, (draft) => {\n draft[activeContainerIndex].children = draft[activeContainerIndex].children.filter(\n (item) => item.dndId !== active.id\n );\n\n const targetChildren = draft[overContainerIndex].children;\n const spaceTaken = targetChildren.reduce((acc, curr) => {\n if (curr.name === TEMP_FIELD_NAME) {\n return acc;\n }\n\n return acc + curr.size;\n }, 0);\n const isNotEnoughSpace = spaceTaken + draggedItem.size > GRID_COLUMNS;\n const canSwapSameSizeItem =\n overItem &&\n overItem.name !== TEMP_FIELD_NAME &&\n overItem.size === draggedItem.size &&\n activeIndex !== -1 &&\n overIndex !== -1;\n const canCreateNewRowForItem =\n activeContainerIndex !== overContainerIndex && GRID_COLUMNS - spaceTaken === 0;\n const isHoveringOverSpacer = overItem?.name === TEMP_FIELD_NAME;\n\n /**\n * Not enough space in the hovered row\n *\n * We still want:\n * - ability to swap items of the same size\n * - ability to create a single extra row to host the dragged item\n * when surrounding rows are full\n */\n if (isNotEnoughSpace) {\n // Try a simple swap when target item is of the same size\n if (canSwapSameSizeItem) {\n const sourceChildren = draft[activeContainerIndex].children;\n\n // Put the hovered item back where the dragged item came from\n sourceChildren.splice(activeIndex, 0, overItem);\n\n // Swap the hovered item with the dragged one in the target row\n const draftOverIndex = targetChildren.findIndex(\n (item) => item.dndId === overItem.dndId\n );\n\n if (draftOverIndex !== -1) {\n targetChildren.splice(draftOverIndex, 1, draggedItem);\n }\n\n return;\n }\n\n // If there is absolutely no space left in the target row and the\n // dragged item comes from a different row, add it to a new row\n if (canCreateNewRowForItem) {\n // Default: insert a new row after the row being hovered (between that row and the\n // next). For row 0, use index 0 instead so fields that are not full-width can still\n // be moved above the first row—there is no separate drop area above it in the UI.\n const insertIndex = overContainerIndex === 0 ? 0 : overContainerIndex + 1;\n\n /**\n * When inserting *after* the hovered row, reuse the following row if it only\n * contains spacers. Skip when inserting at index 0 — draft[0] is the hovered row.\n */\n if (insertIndex > overContainerIndex) {\n const existingRow = draft[insertIndex];\n\n if (existingRow) {\n const nonTempChildren = existingRow.children.filter(\n (child) => child.name !== TEMP_FIELD_NAME\n );\n const isNextRowEmpty = nonTempChildren.length === 0;\n\n // If the row directly after is empty (only spacers), reuse it\n // instead of creating yet another row.\n if (isNextRowEmpty) {\n existingRow.children = [draggedItem];\n return;\n }\n }\n }\n\n const newContainerPrototype = draft[overContainerIndex];\n const newContainerId = `container-${draft.length}`;\n\n draft.splice(insertIndex, 0, {\n ...newContainerPrototype,\n dndId: newContainerId,\n children: [draggedItem],\n });\n\n return;\n }\n }\n\n // There is enough room in the target row\n if (isHoveringOverSpacer) {\n // We are over an invisible spacer, replace it with the dragged item\n targetChildren.splice(overIndex, 1, draggedItem);\n return;\n }\n\n // There is room for the item in the container, drop it\n targetChildren.splice(overIndex, 0, draggedItem);\n });\n\n setContainers(update);\n }}\n onDragEnd={(event) => {\n const { active, over } = event;\n const { id } = active;\n const overId = over?.id;\n const containersAsDictionary = getContainersAsDictionary();\n const activeContainer = findContainer(id, containersAsDictionary);\n const overContainer = findContainer(overId!, containersAsDictionary);\n\n if (!activeContainer || !overContainer) {\n return;\n }\n\n const activeIndex = containersAsDictionary[activeContainer].children.findIndex(\n (children) => children.dndId === id\n );\n const overIndex = containersAsDictionary[overContainer].children.findIndex(\n (children) => children.dndId === overId\n );\n\n const movedContainerItems = produce(containersAsDictionary, (draft) => {\n if (\n activeIndex >= 0 &&\n overIndex >= 0 &&\n activeIndex !== overIndex &&\n activeContainer === overContainer\n ) {\n // Move items around inside their own container\n draft[activeContainer].children = arraySwap(\n draft[activeContainer].children,\n activeIndex,\n overIndex\n );\n }\n });\n\n // Remove properties the server does not expect before updating the form\n const updatedContainers = Object.values(movedContainerItems);\n const updatedContainersWithSpacers = createContainersWithSpacers(\n updatedContainers\n ) as typeof containers;\n const updatedLayout = updatedContainersWithSpacers.map(\n ({ dndId: _dndId, children, ...container }) => ({\n ...container,\n children: children.map(({ dndId: _dndId, formName: _formName, ...child }) => child),\n })\n );\n\n // Update the layout\n onChange('layout', updatedLayout);\n setActiveDragItem(null);\n }}\n >\n <Flex paddingTop={6} direction=\"column\" alignItems=\"stretch\" gap={4}>\n <Flex alignItems=\"flex-start\" direction=\"column\" justifyContent=\"space-between\">\n <Typography fontWeight=\"bold\">\n {formatMessage({\n id: getTranslation('containers.list.displayedFields'),\n defaultMessage: 'Displayed fields',\n })}\n </Typography>\n <Typography variant=\"pi\" textColor=\"neutral600\">\n {formatMessage({\n id: 'containers.SettingPage.editSettings.description',\n defaultMessage: 'Drag & drop the fields to build the layout',\n })}\n </Typography>\n </Flex>\n <Box padding={4} hasRadius borderStyle=\"dashed\" borderWidth=\"1px\" borderColor=\"neutral300\">\n <Flex direction=\"column\" alignItems=\"stretch\" gap={2}>\n {containers.map((container, containerIndex) => (\n <SortableContext\n key={container.dndId}\n id={container.dndId}\n items={container.children.map((child) => ({ id: child.dndId }))}\n strategy={rectSwappingStrategy}\n >\n <DroppableContainer id={container.dndId}>\n {({ setNodeRef }) => (\n <Grid.Root key={container.dndId} ref={setNodeRef} gap={2}>\n {container.children.map((child, childIndex) => (\n <Grid.Item\n col={child.size}\n xs={12}\n key={child.dndId}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n <SortableItem id={child.dndId}>\n <Field\n attribute={attributes[child.name]}\n components={components}\n name={child.formName}\n onRemoveField={handleRemoveField(containerIndex, childIndex)}\n dndId={child.dndId}\n />\n </SortableItem>\n </Grid.Item>\n ))}\n </Grid.Root>\n )}\n </DroppableContainer>\n </SortableContext>\n ))}\n <DragOverlay>\n {activeDragItem ? (\n <Field\n attribute={attributes[activeDragItem.name]}\n components={components}\n name={activeDragItem.formName}\n dndId={activeDragItem.dndId}\n />\n ) : null}\n </DragOverlay>\n <Menu.Root>\n <Menu.Trigger\n startIcon={<Plus />}\n endIcon={null}\n disabled={remainingFields.length === 0}\n fullWidth\n variant=\"secondary\"\n >\n {formatMessage({\n id: getTranslation('containers.SettingPage.add.field'),\n defaultMessage: 'Insert another field',\n })}\n </Menu.Trigger>\n <Menu.Content>\n {remainingFields.map((field) => (\n <Menu.Item key={field.name} onSelect={handleAddField(field)}>\n {field.label}\n </Menu.Item>\n ))}\n </Menu.Content>\n </Menu.Root>\n </Flex>\n </Box>\n </Flex>\n </DndContext>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Field\n * -----------------------------------------------------------------------------------------------*/\n\ninterface FieldProps extends Pick<EditFieldFormProps, 'name' | 'attribute'> {\n components: EditLayout['components'];\n dndId: string;\n onRemoveField?: React.MouseEventHandler<HTMLButtonElement>;\n}\n\nconst TEMP_FIELD_NAME = '_TEMP_';\n\n/**\n * Displays a field in the layout with drag options, also\n * opens a modal to edit the details of said field.\n */\nconst Field = ({ attribute, components, name, onRemoveField, dndId }: FieldProps) => {\n const isDesktop = useIsDesktop();\n const [isModalOpen, setIsModalOpen] = React.useState(false);\n const { formatMessage } = useIntl();\n const { value } = useField<FormField>(name);\n const { listeners, setActivatorNodeRef } = useSortable({\n id: dndId,\n });\n\n const handleRemoveField: React.MouseEventHandler<HTMLButtonElement> = (e) => {\n e.preventDefault();\n e.stopPropagation();\n if (onRemoveField) {\n onRemoveField?.(e);\n }\n };\n\n const onEditFieldMeta: React.MouseEventHandler<HTMLButtonElement> = (e) => {\n e.preventDefault();\n e.stopPropagation();\n setIsModalOpen(true);\n };\n\n if (!value) {\n return null;\n }\n\n if (value.name === TEMP_FIELD_NAME) {\n return <Flex tag=\"span\" height=\"100%\" style={{ opacity: 0 }} />;\n }\n\n if (!attribute) {\n return null;\n }\n\n return (\n <Modal.Root open={isModalOpen} onOpenChange={setIsModalOpen}>\n <Flex\n borderColor=\"neutral150\"\n background=\"neutral100\"\n hasRadius\n gap={3}\n cursor=\"pointer\"\n onClick={() => {\n setIsModalOpen(true);\n }}\n position=\"relative\"\n >\n {isDesktop && (\n <DragButton\n ref={setActivatorNodeRef}\n tag=\"span\"\n withTooltip={false}\n label={formatMessage(\n {\n id: getTranslation('components.DraggableCard.move.field'),\n defaultMessage: 'Move {item}',\n },\n { item: value.label }\n )}\n {...listeners}\n >\n <Drag />\n </DragButton>\n )}\n <Flex direction=\"column\" alignItems=\"flex-start\" grow={1} overflow=\"hidden\">\n <Flex gap={3} justifyContent=\"space-between\" width=\"100%\">\n <Typography ellipsis fontWeight=\"bold\">\n {value.label}\n </Typography>\n <Flex position=\"relative\">\n <IconButton\n type=\"button\"\n variant=\"ghost\"\n background=\"transparent\"\n onClick={onEditFieldMeta}\n withTooltip={false}\n label={formatMessage(\n {\n id: getTranslation('components.DraggableCard.edit.field'),\n defaultMessage: 'Edit {item}',\n },\n { item: value.label }\n )}\n >\n <Pencil />\n </IconButton>\n <IconButton\n type=\"button\"\n variant=\"ghost\"\n onClick={handleRemoveField}\n background=\"transparent\"\n withTooltip={false}\n label={formatMessage(\n {\n id: getTranslation('components.DraggableCard.delete.field'),\n defaultMessage: 'Delete {item}',\n },\n { item: value.label }\n )}\n >\n <Cross />\n </IconButton>\n </Flex>\n </Flex>\n {attribute?.type === 'component' ? (\n <Flex\n paddingTop={3}\n paddingRight={3}\n paddingBottom={3}\n paddingLeft={0}\n alignItems=\"flex-start\"\n direction=\"column\"\n gap={2}\n width=\"100%\"\n >\n <Grid.Root gap={4} width=\"100%\">\n {components[attribute.component].layout.map((row) =>\n row.map(({ size, ...field }) => (\n <Grid.Item\n key={field.name}\n col={size}\n xs={12}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n <Flex\n alignItems=\"center\"\n background=\"neutral0\"\n paddingTop={2}\n paddingBottom={2}\n paddingLeft={3}\n paddingRight={3}\n hasRadius\n borderColor=\"neutral200\"\n >\n <Typography textColor=\"neutral800\">{field.name}</Typography>\n </Flex>\n </Grid.Item>\n ))\n )}\n </Grid.Root>\n <Link\n // used to stop the edit form from appearing when we click here.\n onClick={(e) => e.stopPropagation()}\n startIcon={<Cog />}\n tag={NavLink}\n to={`../components/${attribute.component}/configurations/edit`}\n >\n {formatMessage({\n id: getTranslation('components.FieldItem.linkToComponentLayout'),\n defaultMessage: \"Set the component's layout\",\n })}\n </Link>\n </Flex>\n ) : null}\n {attribute?.type === 'dynamiczone' ? (\n <Flex\n paddingTop={3}\n paddingRight={3}\n paddingBottom={3}\n paddingLeft={0}\n alignItems=\"flex-start\"\n gap={2}\n width=\"100%\"\n wrap=\"wrap\"\n >\n {attribute?.components.map((uid) => (\n <ComponentLink\n // used to stop the edit form from appearing when we click here.\n onClick={(e) => e.stopPropagation()}\n key={uid}\n to={`../components/${uid}/configurations/edit`}\n >\n <ComponentIcon icon={components[uid].settings.icon} />\n <Typography fontSize={1} textColor=\"neutral600\" fontWeight=\"bold\">\n {components[uid].settings.displayName}\n </Typography>\n </ComponentLink>\n ))}\n </Flex>\n ) : null}\n </Flex>\n </Flex>\n {value.name !== TEMP_FIELD_NAME && (\n <EditFieldForm attribute={attribute} name={name} onClose={() => setIsModalOpen(false)} />\n )}\n </Modal.Root>\n );\n};\n\nconst DragButton = styled<IconButtonComponent<'span'>>(IconButton)`\n height: unset;\n align-self: stretch;\n display: flex;\n align-items: center;\n padding: 0;\n border: none;\n background-color: transparent;\n border-radius: 0px;\n border-right: 1px solid ${({ theme }) => theme.colors.neutral150};\n cursor: all-scroll;\n\n svg {\n width: 1.2rem;\n height: 1.2rem;\n }\n`;\n\nconst ComponentLink = styled(NavLink)`\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: ${({ theme }) => theme.spaces[1]};\n padding: ${(props) => props.theme.spaces[2]};\n border: 1px solid ${({ theme }) => theme.colors.neutral200};\n background: ${({ theme }) => theme.colors.neutral0};\n width: 14rem;\n border-radius: ${({ theme }) => theme.borderRadius};\n text-decoration: none;\n\n &:focus,\n &:hover {\n ${({ theme }) => `\n background-color: ${theme.colors.primary100};\n border-color: ${theme.colors.primary200};\n\n ${Typography} {\n color: ${theme.colors.primary600};\n }\n `}\n\n /* > ComponentIcon */\n > div:first-child {\n background: ${({ theme }) => theme.colors.primary200};\n color: ${({ theme }) => theme.colors.primary600};\n\n svg {\n path {\n fill: ${({ theme }) => theme.colors.primary600};\n }\n }\n }\n }\n`;\n\nexport { Fields, TEMP_FIELD_NAME };\nexport type { FieldsProps };\n"],"names":["GRID_COLUMNS","DroppableContainer","id","children","droppable","useDroppable","SortableItem","attributes","setNodeRef","transform","transition","isDragging","useSortable","style","CSS","Transform","toString","x","y","scaleX","scaleY","height","opacity","outlineOffset","_jsx","div","ref","createDragAndDropContainersFromLayout","layout","map","row","containerIndex","dndId","child","childIndex","formName","Fields","fieldSizes","components","metadatas","formatMessage","useIntl","useForm","state","values","onChange","addFieldRow","removeFieldRow","existingFields","field","name","flat","remainingFields","Object","entries","reduce","acc","current","visible","includes","type","size","push","label","handleRemoveField","rowIndex","fieldIndex","length","slice","handleAddField","containers","setContainers","React","useState","activeDragItem","setActiveDragItem","findContainer","containersAsDictionary","keys","find","key","getItemFromContainer","container","item","getContainersAsDictionary","fromEntries","createContainersWithSpacers","filter","TEMP_FIELD_NAME","totalSpaceTaken","curr","spacerKey","generateNKeysBetweenImpl","at","__temp_key__","undefined","useEffect","DndContext","onDragStart","event","activeContainer","active","activeItem","onDragOver","over","overContainer","activeContainerIndex","findIndex","overContainerIndex","draggedItem","overItem","overIndex","activeIndex","update","produce","draft","targetChildren","spaceTaken","isNotEnoughSpace","canSwapSameSizeItem","canCreateNewRowForItem","isHoveringOverSpacer","sourceChildren","splice","draftOverIndex","insertIndex","existingRow","nonTempChildren","isNextRowEmpty","newContainerPrototype","newContainerId","onDragEnd","overId","movedContainerItems","arraySwap","updatedContainers","updatedContainersWithSpacers","updatedLayout","_dndId","_formName","_jsxs","Flex","paddingTop","direction","alignItems","gap","justifyContent","Typography","fontWeight","getTranslation","defaultMessage","variant","textColor","Box","padding","hasRadius","borderStyle","borderWidth","borderColor","SortableContext","items","strategy","rectSwappingStrategy","Grid","Root","Item","col","xs","Field","attribute","onRemoveField","DragOverlay","Menu","Trigger","startIcon","Plus","endIcon","disabled","fullWidth","Content","onSelect","isDesktop","useIsDesktop","isModalOpen","setIsModalOpen","value","useField","listeners","setActivatorNodeRef","e","preventDefault","stopPropagation","onEditFieldMeta","tag","Modal","open","onOpenChange","background","cursor","onClick","position","DragButton","withTooltip","Drag","grow","overflow","width","ellipsis","IconButton","Pencil","Cross","paddingRight","paddingBottom","paddingLeft","component","Link","Cog","NavLink","to","wrap","uid","ComponentLink","ComponentIcon","icon","settings","fontSize","displayName","EditFieldForm","onClose","styled","theme","colors","neutral150","spaces","props","neutral200","neutral0","borderRadius","primary100","primary200","primary600"],"mappings":";;;;;;;;;;;;;;;;;AAmCA,MAAMA,YAAAA,GAAe,EAAA;AAErB;;AAEkG,qGAElG,MAAMC,kBAAAA,GAAqB,CAAC,EAC1BC,EAAE,EACFC,QAAQ,EAIT,GAAA;AACC,IAAA,MAAMC,YAAYC,YAAAA,CAAa;AAC7BH,QAAAA;AACF,KAAA,CAAA;AAEA,IAAA,OAAOC,QAA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CAAMO,YAAY,CAAC;;;;;AAKjD,IAAA,EAAE,CAAC,EAAEP,KAAK,EAAE,GAAK;AACG,wBAAA,EAAEA,KAAAA,CAAMC,MAAM,CAACO,UAAU,CAAC;AAC9B,oBAAA,EAAER,KAAAA,CAAMC,MAAM,CAACQ,UAAU,CAAC;;AAExC,MAAA,EAAE5F,UAAAA,CAAW;AACF,iBAAA,EAAEmF,KAAAA,CAAMC,MAAM,CAACS,UAAU,CAAC;;AAEvC,IAAA,CAAC;;;;kBAIa,EAAE,CAAC,EAAEV,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAACQ,UAAU,CAAC;aAC9C,EAAE,CAAC,EAAET,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAACS,UAAU,CAAC;;;;gBAItC,EAAE,CAAC,EAAEV,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAACS,UAAU,CAAC;;;;;AAKzD,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"Fields.mjs","sources":["../../../../admin/src/components/ConfigurationForm/Fields.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useDroppable, DndContext, UniqueIdentifier, DragOverlay } from '@dnd-kit/core';\nimport { arraySwap, SortableContext, useSortable, rectSwappingStrategy } from '@dnd-kit/sortable';\nimport { CSS } from '@dnd-kit/utilities';\nimport { useField, useForm, useIsDesktop } from '@strapi/admin/strapi-admin';\nimport {\n Modal,\n Box,\n Flex,\n Grid,\n IconButton,\n IconButtonComponent,\n Typography,\n Link,\n Menu,\n} from '@strapi/design-system';\nimport { Cog, Cross, Drag, Pencil, Plus } from '@strapi/icons';\nimport { generateNKeysBetween as generateNKeysBetweenImpl } from 'fractional-indexing';\nimport { produce } from 'immer';\nimport { useIntl } from 'react-intl';\nimport { NavLink } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { getTranslation } from '../../utils/translations';\nimport { ComponentIcon } from '../ComponentIcon';\n\nimport { EditFieldForm, EditFieldFormProps } from './EditFieldForm';\n\nimport type { ConfigurationFormData, EditFieldSpacerLayout } from './Form';\nimport type { EditLayout } from '../../hooks/useDocumentLayout';\n\ntype FormField = ConfigurationFormData['layout'][number]['children'][number];\ntype Field = Omit<ConfigurationFormData['layout'][number]['children'][number], '__temp_key__'>;\n\nconst GRID_COLUMNS = 12;\n\n/* -------------------------------------------------------------------------------------------------\n * Drag and Drop\n * -----------------------------------------------------------------------------------------------*/\n\nconst DroppableContainer = ({\n id,\n children,\n}: {\n id: string;\n children: (props: ReturnType<typeof useDroppable>) => React.ReactNode;\n}) => {\n const droppable = useDroppable({\n id,\n });\n\n return children(droppable);\n};\n\nexport const SortableItem = ({ id, children }: { id: string; children: React.ReactNode }) => {\n const { attributes, setNodeRef, transform, transition, isDragging } = useSortable({\n id,\n });\n\n const style = {\n transform: CSS.Transform.toString({\n x: transform?.x ?? 0,\n y: transform?.y ?? 0,\n // Avoid any scaling animations which can visually \"squish\" or\n // \"stretch\" neighbouring cards in mixed-width grids (4/8/12 cols).\n scaleX: 1,\n scaleY: 1,\n }),\n transition,\n height: '100%',\n opacity: isDragging ? 0.6 : 1,\n outlineOffset: 2,\n };\n\n return (\n <div ref={setNodeRef} style={style} {...attributes}>\n {children}\n </div>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Fields\n * -----------------------------------------------------------------------------------------------*/\n\ninterface FieldsProps extends Pick<EditLayout, 'metadatas'>, Pick<FieldProps, 'components'> {\n attributes: {\n [key: string]: FieldProps['attribute'];\n };\n fieldSizes: Record<string, number>;\n components: EditLayout['components'];\n}\n\n/**\n * Compute uids and formName for drag and drop items for the incoming layout\n */\nconst createDragAndDropContainersFromLayout = (layout: ConfigurationFormData['layout']) => {\n return layout.map((row, containerIndex) => ({\n ...row,\n // Use unique ids for drag and drop items\n dndId: `container-${containerIndex}`,\n children: row.children.map((child, childIndex) => ({\n ...child,\n dndId: `container-${containerIndex}-child-${childIndex}`,\n\n // The formName must be recomputed each time an item is moved\n formName: `layout.${containerIndex}.children.${childIndex}`,\n })),\n }));\n};\n\nconst Fields = ({ attributes, fieldSizes, components, metadatas = {} }: FieldsProps) => {\n const { formatMessage } = useIntl();\n\n const layout = useForm<ConfigurationFormData['layout']>(\n 'Fields',\n (state) => (state.values as ConfigurationFormData).layout ?? []\n );\n\n const onChange = useForm('Fields', (state) => state.onChange);\n const addFieldRow = useForm('Fields', (state) => state.addFieldRow);\n const removeFieldRow = useForm('Fields', (state) => state.removeFieldRow);\n\n const existingFields = layout.map((row) => row.children.map((field) => field.name)).flat();\n\n /**\n * Get the fields that are not already in the layout\n * But also check that they are visible before we give users\n * the option to display them. e.g. `id` is not visible.\n */\n const remainingFields = Object.entries(metadatas).reduce<Field[]>((acc, current) => {\n const [name, { visible, ...field }] = current;\n\n if (!existingFields.includes(name) && visible === true) {\n const type = attributes[name]?.type;\n const size = type ? fieldSizes[type] : GRID_COLUMNS;\n\n acc.push({\n ...field,\n label: field.label ?? name,\n name,\n size,\n });\n }\n\n return acc;\n }, []);\n\n const handleRemoveField =\n (rowIndex: number, fieldIndex: number): FieldProps['onRemoveField'] =>\n () => {\n if (layout[rowIndex].children.length === 1) {\n removeFieldRow(`layout`, rowIndex);\n } else {\n onChange(`layout.${rowIndex}.children`, [\n ...layout[rowIndex].children.slice(0, fieldIndex),\n ...layout[rowIndex].children.slice(fieldIndex + 1),\n ]);\n }\n };\n\n const handleAddField = (field: Field) => () => {\n addFieldRow('layout', { children: [field] });\n };\n\n const [containers, setContainers] = React.useState(() =>\n createDragAndDropContainersFromLayout(layout)\n );\n type Container = (typeof containers)[number];\n const [activeDragItem, setActiveDragItem] = React.useState<Container['children'][number] | null>(\n null\n );\n\n /**\n * Finds either the parent container id or the child id within a container\n */\n function findContainer(id: UniqueIdentifier, containersAsDictionary: Record<string, Container>) {\n // If the id is a key, then it is the parent container\n if (id in containersAsDictionary) {\n return id;\n }\n\n // Otherwise, it is a child inside a container\n return Object.keys(containersAsDictionary).find((key) =>\n containersAsDictionary[key].children.find((child) => child.dndId === id)\n );\n }\n\n /**\n * Gets an item from a container based on its id\n */\n const getItemFromContainer = (id: UniqueIdentifier, container: Container) => {\n return container.children.find((item) => id === item.dndId);\n };\n\n /**\n * Gets the containers as dictionary for quick lookup\n */\n const getContainersAsDictionary = () => {\n return Object.fromEntries(containers.map((container) => [container.dndId, container]));\n };\n\n /**\n * Recomputes the empty space in the grid\n */\n const createContainersWithSpacers = (layout: typeof containers) => {\n return layout\n .map((row) => ({\n ...row,\n children: row.children.filter((field) => field.name !== TEMP_FIELD_NAME),\n }))\n .filter((row) => row.children.length > 0)\n .map((row) => {\n const totalSpaceTaken = row.children.reduce((acc, curr) => acc + curr.size, 0);\n\n if (totalSpaceTaken < GRID_COLUMNS) {\n const [spacerKey] = generateNKeysBetweenImpl(\n row.children.at(-1)?.__temp_key__,\n undefined,\n 1\n );\n\n return {\n ...row,\n children: [\n ...row.children,\n {\n name: TEMP_FIELD_NAME,\n size: GRID_COLUMNS - totalSpaceTaken,\n __temp_key__: spacerKey,\n } satisfies EditFieldSpacerLayout,\n ],\n };\n }\n\n return row;\n });\n };\n\n /**\n * When layout changes (e.g. when a field size is changed or the containers are reordered)\n * we need to update the ids and form names\n */\n React.useEffect(() => {\n const containers = createDragAndDropContainersFromLayout(layout);\n setContainers(containers);\n }, [layout, setContainers]);\n\n return (\n <DndContext\n onDragStart={(event) => {\n const containersAsDictionary = getContainersAsDictionary();\n\n const activeContainer = findContainer(event.active.id, containersAsDictionary);\n\n if (!activeContainer) return;\n\n const activeItem = getItemFromContainer(\n event.active.id,\n containersAsDictionary[activeContainer]\n );\n\n if (activeItem) {\n setActiveDragItem(activeItem);\n }\n }}\n onDragOver={({ active, over }) => {\n const containersAsDictionary = getContainersAsDictionary();\n const activeContainer = findContainer(active.id, containersAsDictionary);\n const overContainer = findContainer(over?.id ?? '', containersAsDictionary);\n const activeContainerIndex = containers.findIndex(\n (container) => container.dndId === activeContainer\n );\n const overContainerIndex = containers.findIndex(\n (container) => container.dndId === overContainer\n );\n\n if (!activeContainer || !overContainer) {\n return;\n }\n\n const draggedItem = getItemFromContainer(\n active.id,\n containersAsDictionary[activeContainer]\n );\n const overItem = getItemFromContainer(\n over?.id ?? '',\n containersAsDictionary[overContainer]\n );\n const overIndex = containersAsDictionary[overContainer].children.findIndex(\n (item) => item.dndId === over?.id\n );\n const activeIndex = containersAsDictionary[activeContainer].children.findIndex(\n (item) => item.dndId === active.id\n );\n\n if (!draggedItem) return;\n\n // Handle a full width field being dragged\n if (draggedItem?.size === GRID_COLUMNS) {\n // Swap the items in the containers\n const update = produce(containers, (draft) => {\n draft[activeContainerIndex].children = containers[overContainerIndex].children;\n draft[overContainerIndex].children = containers[activeContainerIndex].children;\n });\n setContainers(update);\n return;\n }\n\n /**\n * Handle an item being dragged from one container to another,\n * the item is removed from its current container, and then added to its new container\n * An item can only be added in a container if there is enough space\n */\n const update = produce(containers, (draft) => {\n draft[activeContainerIndex].children = draft[activeContainerIndex].children.filter(\n (item) => item.dndId !== active.id\n );\n\n const targetChildren = draft[overContainerIndex].children;\n const spaceTaken = targetChildren.reduce((acc, curr) => {\n if (curr.name === TEMP_FIELD_NAME) {\n return acc;\n }\n\n return acc + curr.size;\n }, 0);\n const isNotEnoughSpace = spaceTaken + draggedItem.size > GRID_COLUMNS;\n const canSwapSameSizeItem =\n overItem &&\n overItem.name !== TEMP_FIELD_NAME &&\n overItem.size === draggedItem.size &&\n activeIndex !== -1 &&\n overIndex !== -1;\n const canCreateNewRowForItem =\n activeContainerIndex !== overContainerIndex &&\n GRID_COLUMNS - spaceTaken < draggedItem.size;\n const isHoveringOverSpacer = overItem?.name === TEMP_FIELD_NAME;\n\n /**\n * Not enough space in the hovered row\n *\n * We still want:\n * - ability to swap items of the same size\n * - ability to create a single extra row to host the dragged item\n * when surrounding rows are full\n */\n if (isNotEnoughSpace) {\n // Try a simple swap when target item is of the same size\n if (canSwapSameSizeItem) {\n const sourceChildren = draft[activeContainerIndex].children;\n\n // Put the hovered item back where the dragged item came from\n sourceChildren.splice(activeIndex, 0, overItem);\n\n // Swap the hovered item with the dragged one in the target row\n const draftOverIndex = targetChildren.findIndex(\n (item) => item.dndId === overItem.dndId\n );\n\n if (draftOverIndex !== -1) {\n targetChildren.splice(draftOverIndex, 1, draggedItem);\n }\n\n return;\n }\n\n // If there is absolutely no space left in the target row and the\n // dragged item comes from a different row, add it to a new row\n if (canCreateNewRowForItem) {\n // Default: insert a new row after the row being hovered (between that row and the\n // next). For row 0, use index 0 instead so fields that are not full-width can still\n // be moved above the first row—there is no separate drop area above it in the UI.\n const insertIndex = overContainerIndex === 0 ? 0 : overContainerIndex + 1;\n\n /**\n * When inserting *after* the hovered row, reuse the following row if it only\n * contains spacers. Skip when inserting at index 0 — draft[0] is the hovered row.\n */\n if (insertIndex > overContainerIndex) {\n const existingRow = draft[insertIndex];\n\n if (existingRow) {\n const nonTempChildren = existingRow.children.filter(\n (child) => child.name !== TEMP_FIELD_NAME\n );\n const isNextRowEmpty = nonTempChildren.length === 0;\n\n // If the row directly after is empty (only spacers), reuse it\n // instead of creating yet another row.\n if (isNextRowEmpty) {\n existingRow.children = [draggedItem];\n return;\n }\n }\n }\n\n const newContainerPrototype = draft[overContainerIndex];\n\n // Using draft.length directly can collide with an existing container id\n // (e.g. after rows were removed), causing React key conflicts and flicker.\n const findFreeContainerId = (i: number): string =>\n containersAsDictionary[`container-${i}`]\n ? findFreeContainerId(i + 1)\n : `container-${i}`;\n const newContainerId = findFreeContainerId(draft.length);\n\n draft.splice(insertIndex, 0, {\n ...newContainerPrototype,\n dndId: newContainerId,\n children: [draggedItem],\n });\n\n return;\n }\n }\n\n // There is enough room in the target row\n if (isHoveringOverSpacer) {\n // We are over an invisible spacer, replace it with the dragged item\n targetChildren.splice(overIndex, 1, draggedItem);\n return;\n }\n\n // There is room for the item in the container, drop it\n targetChildren.splice(overIndex, 0, draggedItem);\n });\n\n setContainers(update.filter((container) => container.children.length > 0));\n }}\n onDragEnd={(event) => {\n const { active, over } = event;\n const { id } = active;\n const overId = over?.id;\n const containersAsDictionary = getContainersAsDictionary();\n const activeContainer = findContainer(id, containersAsDictionary);\n const overContainer = findContainer(overId!, containersAsDictionary);\n\n if (!activeContainer || !overContainer) {\n return;\n }\n\n const activeIndex = containersAsDictionary[activeContainer].children.findIndex(\n (children) => children.dndId === id\n );\n const overIndex = containersAsDictionary[overContainer].children.findIndex(\n (children) => children.dndId === overId\n );\n\n const movedContainerItems = produce(containersAsDictionary, (draft) => {\n if (\n activeIndex >= 0 &&\n overIndex >= 0 &&\n activeIndex !== overIndex &&\n activeContainer === overContainer\n ) {\n // Move items around inside their own container\n draft[activeContainer].children = arraySwap(\n draft[activeContainer].children,\n activeIndex,\n overIndex\n );\n }\n });\n\n // Remove properties the server does not expect before updating the form\n const updatedContainers = Object.values(movedContainerItems);\n const updatedContainersWithSpacers = createContainersWithSpacers(\n updatedContainers\n ) as typeof containers;\n const updatedLayout = updatedContainersWithSpacers.map(\n ({ dndId: _dndId, children, ...container }) => ({\n ...container,\n children: children.map(({ dndId: _dndId, formName: _formName, ...child }) => child),\n })\n );\n\n // Update the layout\n onChange('layout', updatedLayout);\n setActiveDragItem(null);\n }}\n >\n <Flex paddingTop={6} direction=\"column\" alignItems=\"stretch\" gap={4}>\n <Flex alignItems=\"flex-start\" direction=\"column\" justifyContent=\"space-between\">\n <Typography fontWeight=\"bold\">\n {formatMessage({\n id: getTranslation('containers.list.displayedFields'),\n defaultMessage: 'Displayed fields',\n })}\n </Typography>\n <Typography variant=\"pi\" textColor=\"neutral600\">\n {formatMessage({\n id: 'containers.SettingPage.editSettings.description',\n defaultMessage: 'Drag & drop the fields to build the layout',\n })}\n </Typography>\n </Flex>\n <Box padding={4} hasRadius borderStyle=\"dashed\" borderWidth=\"1px\" borderColor=\"neutral300\">\n <Flex direction=\"column\" alignItems=\"stretch\" gap={2}>\n {containers.map((container, containerIndex) => (\n <SortableContext\n key={container.dndId}\n id={container.dndId}\n items={container.children.map((child) => ({ id: child.dndId }))}\n strategy={rectSwappingStrategy}\n >\n <DroppableContainer id={container.dndId}>\n {({ setNodeRef }) => (\n <Grid.Root key={container.dndId} ref={setNodeRef} gap={2}>\n {container.children.map((child, childIndex) => (\n <Grid.Item\n col={child.size}\n xs={12}\n key={child.dndId}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n <SortableItem id={child.dndId}>\n <Field\n attribute={attributes[child.name]}\n components={components}\n name={child.formName}\n onRemoveField={handleRemoveField(containerIndex, childIndex)}\n dndId={child.dndId}\n />\n </SortableItem>\n </Grid.Item>\n ))}\n </Grid.Root>\n )}\n </DroppableContainer>\n </SortableContext>\n ))}\n <DragOverlay>\n {activeDragItem ? (\n <Field\n attribute={attributes[activeDragItem.name]}\n components={components}\n name={activeDragItem.formName}\n dndId={activeDragItem.dndId}\n />\n ) : null}\n </DragOverlay>\n <Menu.Root>\n <Menu.Trigger\n startIcon={<Plus />}\n endIcon={null}\n disabled={remainingFields.length === 0}\n fullWidth\n variant=\"secondary\"\n >\n {formatMessage({\n id: getTranslation('containers.SettingPage.add.field'),\n defaultMessage: 'Insert another field',\n })}\n </Menu.Trigger>\n <Menu.Content>\n {remainingFields.map((field) => (\n <Menu.Item key={field.name} onSelect={handleAddField(field)}>\n {field.label}\n </Menu.Item>\n ))}\n </Menu.Content>\n </Menu.Root>\n </Flex>\n </Box>\n </Flex>\n </DndContext>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Field\n * -----------------------------------------------------------------------------------------------*/\n\ninterface FieldProps extends Pick<EditFieldFormProps, 'name' | 'attribute'> {\n components: EditLayout['components'];\n dndId: string;\n onRemoveField?: React.MouseEventHandler<HTMLButtonElement>;\n}\n\nconst TEMP_FIELD_NAME = '_TEMP_';\n\n/**\n * Displays a field in the layout with drag options, also\n * opens a modal to edit the details of said field.\n */\nconst Field = ({ attribute, components, name, onRemoveField, dndId }: FieldProps) => {\n const isDesktop = useIsDesktop();\n const [isModalOpen, setIsModalOpen] = React.useState(false);\n const { formatMessage } = useIntl();\n const { value } = useField<FormField>(name);\n const { listeners, setActivatorNodeRef } = useSortable({\n id: dndId,\n });\n\n const handleRemoveField: React.MouseEventHandler<HTMLButtonElement> = (e) => {\n e.preventDefault();\n e.stopPropagation();\n if (onRemoveField) {\n onRemoveField?.(e);\n }\n };\n\n const onEditFieldMeta: React.MouseEventHandler<HTMLButtonElement> = (e) => {\n e.preventDefault();\n e.stopPropagation();\n setIsModalOpen(true);\n };\n\n if (!value) {\n return null;\n }\n\n if (value.name === TEMP_FIELD_NAME) {\n return <Flex tag=\"span\" height=\"100%\" style={{ opacity: 0 }} />;\n }\n\n if (!attribute) {\n return null;\n }\n\n return (\n <Modal.Root open={isModalOpen} onOpenChange={setIsModalOpen}>\n <Flex\n borderColor=\"neutral150\"\n background=\"neutral100\"\n hasRadius\n gap={3}\n cursor=\"pointer\"\n onClick={() => {\n setIsModalOpen(true);\n }}\n position=\"relative\"\n >\n {isDesktop && (\n <DragButton\n ref={setActivatorNodeRef}\n tag=\"span\"\n withTooltip={false}\n label={formatMessage(\n {\n id: getTranslation('components.DraggableCard.move.field'),\n defaultMessage: 'Move {item}',\n },\n { item: value.label }\n )}\n {...listeners}\n >\n <Drag />\n </DragButton>\n )}\n <Flex direction=\"column\" alignItems=\"flex-start\" grow={1} overflow=\"hidden\">\n <Flex gap={3} justifyContent=\"space-between\" width=\"100%\">\n <Typography ellipsis fontWeight=\"bold\">\n {value.label}\n </Typography>\n <Flex position=\"relative\">\n <IconButton\n type=\"button\"\n variant=\"ghost\"\n background=\"transparent\"\n onClick={onEditFieldMeta}\n withTooltip={false}\n label={formatMessage(\n {\n id: getTranslation('components.DraggableCard.edit.field'),\n defaultMessage: 'Edit {item}',\n },\n { item: value.label }\n )}\n >\n <Pencil />\n </IconButton>\n <IconButton\n type=\"button\"\n variant=\"ghost\"\n onClick={handleRemoveField}\n background=\"transparent\"\n withTooltip={false}\n label={formatMessage(\n {\n id: getTranslation('components.DraggableCard.delete.field'),\n defaultMessage: 'Delete {item}',\n },\n { item: value.label }\n )}\n >\n <Cross />\n </IconButton>\n </Flex>\n </Flex>\n {attribute?.type === 'component' ? (\n <Flex\n paddingTop={3}\n paddingRight={3}\n paddingBottom={3}\n paddingLeft={0}\n alignItems=\"flex-start\"\n direction=\"column\"\n gap={2}\n width=\"100%\"\n >\n <Grid.Root gap={4} width=\"100%\">\n {components[attribute.component].layout.map((row) =>\n row.map(({ size, ...field }) => (\n <Grid.Item\n key={field.name}\n col={size}\n xs={12}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n <Flex\n alignItems=\"center\"\n background=\"neutral0\"\n paddingTop={2}\n paddingBottom={2}\n paddingLeft={3}\n paddingRight={3}\n hasRadius\n borderColor=\"neutral200\"\n >\n <Typography textColor=\"neutral800\">{field.name}</Typography>\n </Flex>\n </Grid.Item>\n ))\n )}\n </Grid.Root>\n <Link\n // used to stop the edit form from appearing when we click here.\n onClick={(e) => e.stopPropagation()}\n startIcon={<Cog />}\n tag={NavLink}\n to={`../components/${attribute.component}/configurations/edit`}\n >\n {formatMessage({\n id: getTranslation('components.FieldItem.linkToComponentLayout'),\n defaultMessage: \"Set the component's layout\",\n })}\n </Link>\n </Flex>\n ) : null}\n {attribute?.type === 'dynamiczone' ? (\n <Flex\n paddingTop={3}\n paddingRight={3}\n paddingBottom={3}\n paddingLeft={0}\n alignItems=\"flex-start\"\n gap={2}\n width=\"100%\"\n wrap=\"wrap\"\n >\n {attribute?.components.map((uid) => (\n <ComponentLink\n // used to stop the edit form from appearing when we click here.\n onClick={(e) => e.stopPropagation()}\n key={uid}\n to={`../components/${uid}/configurations/edit`}\n >\n <ComponentIcon icon={components[uid].settings.icon} />\n <Typography fontSize={1} textColor=\"neutral600\" fontWeight=\"bold\">\n {components[uid].settings.displayName}\n </Typography>\n </ComponentLink>\n ))}\n </Flex>\n ) : null}\n </Flex>\n </Flex>\n {value.name !== TEMP_FIELD_NAME && (\n <EditFieldForm attribute={attribute} name={name} onClose={() => setIsModalOpen(false)} />\n )}\n </Modal.Root>\n );\n};\n\nconst DragButton = styled<IconButtonComponent<'span'>>(IconButton)`\n height: unset;\n align-self: stretch;\n display: flex;\n align-items: center;\n padding: 0;\n border: none;\n background-color: transparent;\n border-radius: 0px;\n border-right: 1px solid ${({ theme }) => theme.colors.neutral150};\n cursor: all-scroll;\n\n svg {\n width: 1.2rem;\n height: 1.2rem;\n }\n`;\n\nconst ComponentLink = styled(NavLink)`\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: ${({ theme }) => theme.spaces[1]};\n padding: ${(props) => props.theme.spaces[2]};\n border: 1px solid ${({ theme }) => theme.colors.neutral200};\n background: ${({ theme }) => theme.colors.neutral0};\n width: 14rem;\n border-radius: ${({ theme }) => theme.borderRadius};\n text-decoration: none;\n\n &:focus,\n &:hover {\n ${({ theme }) => `\n background-color: ${theme.colors.primary100};\n border-color: ${theme.colors.primary200};\n\n ${Typography} {\n color: ${theme.colors.primary600};\n }\n `}\n\n /* > ComponentIcon */\n > div:first-child {\n background: ${({ theme }) => theme.colors.primary200};\n color: ${({ theme }) => theme.colors.primary600};\n\n svg {\n path {\n fill: ${({ theme }) => theme.colors.primary600};\n }\n }\n }\n }\n`;\n\nexport { Fields, TEMP_FIELD_NAME };\nexport type { FieldsProps };\n"],"names":["GRID_COLUMNS","DroppableContainer","id","children","droppable","useDroppable","SortableItem","attributes","setNodeRef","transform","transition","isDragging","useSortable","style","CSS","Transform","toString","x","y","scaleX","scaleY","height","opacity","outlineOffset","_jsx","div","ref","createDragAndDropContainersFromLayout","layout","map","row","containerIndex","dndId","child","childIndex","formName","Fields","fieldSizes","components","metadatas","formatMessage","useIntl","useForm","state","values","onChange","addFieldRow","removeFieldRow","existingFields","field","name","flat","remainingFields","Object","entries","reduce","acc","current","visible","includes","type","size","push","label","handleRemoveField","rowIndex","fieldIndex","length","slice","handleAddField","containers","setContainers","React","useState","activeDragItem","setActiveDragItem","findContainer","containersAsDictionary","keys","find","key","getItemFromContainer","container","item","getContainersAsDictionary","fromEntries","createContainersWithSpacers","filter","TEMP_FIELD_NAME","totalSpaceTaken","curr","spacerKey","generateNKeysBetweenImpl","at","__temp_key__","undefined","useEffect","DndContext","onDragStart","event","activeContainer","active","activeItem","onDragOver","over","overContainer","activeContainerIndex","findIndex","overContainerIndex","draggedItem","overItem","overIndex","activeIndex","update","produce","draft","targetChildren","spaceTaken","isNotEnoughSpace","canSwapSameSizeItem","canCreateNewRowForItem","isHoveringOverSpacer","sourceChildren","splice","draftOverIndex","insertIndex","existingRow","nonTempChildren","isNextRowEmpty","newContainerPrototype","findFreeContainerId","i","newContainerId","onDragEnd","overId","movedContainerItems","arraySwap","updatedContainers","updatedContainersWithSpacers","updatedLayout","_dndId","_formName","_jsxs","Flex","paddingTop","direction","alignItems","gap","justifyContent","Typography","fontWeight","getTranslation","defaultMessage","variant","textColor","Box","padding","hasRadius","borderStyle","borderWidth","borderColor","SortableContext","items","strategy","rectSwappingStrategy","Grid","Root","Item","col","xs","Field","attribute","onRemoveField","DragOverlay","Menu","Trigger","startIcon","Plus","endIcon","disabled","fullWidth","Content","onSelect","isDesktop","useIsDesktop","isModalOpen","setIsModalOpen","value","useField","listeners","setActivatorNodeRef","e","preventDefault","stopPropagation","onEditFieldMeta","tag","Modal","open","onOpenChange","background","cursor","onClick","position","DragButton","withTooltip","Drag","grow","overflow","width","ellipsis","IconButton","Pencil","Cross","paddingRight","paddingBottom","paddingLeft","component","Link","Cog","NavLink","to","wrap","uid","ComponentLink","ComponentIcon","icon","settings","fontSize","displayName","EditFieldForm","onClose","styled","theme","colors","neutral150","spaces","props","neutral200","neutral0","borderRadius","primary100","primary200","primary600"],"mappings":";;;;;;;;;;;;;;;;;AAmCA,MAAMA,YAAAA,GAAe,EAAA;AAErB;;AAEkG,qGAElG,MAAMC,kBAAAA,GAAqB,CAAC,EAC1BC,EAAE,EACFC,QAAQ,EAIT,GAAA;AACC,IAAA,MAAMC,YAAYC,YAAAA,CAAa;AAC7BH,QAAAA;AACF,KAAA,CAAA;AAEA,IAAA,OAA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AUA,KAAAA,CAAMJ,KAAK,CAACG,MAAM,CAAC,EAAE,CAAC;oBAC1B,EAAE,CAAC,EAAEH,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAACI,UAAU,CAAC;cAC/C,EAAE,CAAC,EAAEL,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAACK,QAAQ,CAAC;;AAEpC,iBAAA,EAAE,CAAC,EAAEN,KAAK,EAAE,GAAKA,KAAAA,CAAMO,YAAY,CAAC;;;;;AAKjD,IAAA,EAAE,CAAC,EAAEP,KAAK,EAAE,GAAK;AACG,wBAAA,EAAEA,KAAAA,CAAMC,MAAM,CAACO,UAAU,CAAC;AAC9B,oBAAA,EAAER,KAAAA,CAAMC,MAAM,CAACQ,UAAU,CAAC;;AAExC,MAAA,EAAE5F,UAAAA,CAAW;AACF,iBAAA,EAAEmF,KAAAA,CAAMC,MAAM,CAACS,UAAU,CAAC;;AAEvC,IAAA,CAAC;;;;kBAIa,EAAE,CAAC,EAAEV,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAACQ,UAAU,CAAC;aAC9C,EAAE,CAAC,EAAET,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAACS,UAAU,CAAC;;;;gBAItC,EAAE,CAAC,EAAEV,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAACS,UAAU,CAAC;;;;;AAKzD,CAAC;;;;"}
|
|
@@ -68,6 +68,10 @@ const StyledAlert = styledComponents.styled(designSystem.Alert).attrs({
|
|
|
68
68
|
`;
|
|
69
69
|
const CustomRelationInput = (props)=>{
|
|
70
70
|
const { formatMessage } = reactIntl.useIntl();
|
|
71
|
+
const emptyLabel = formatMessage({
|
|
72
|
+
id: 'content-manager.containers.empty-label',
|
|
73
|
+
defaultMessage: 'Untitled'
|
|
74
|
+
});
|
|
71
75
|
const field = strapiAdmin.useField(props.name);
|
|
72
76
|
/**
|
|
73
77
|
* Ideally the server would return the correct shape, however, for admin user relations
|
|
@@ -122,7 +126,7 @@ const CustomRelationInput = (props)=>{
|
|
|
122
126
|
// @ts-expect-error - targetModel does exist on the attribute. But it's not typed.
|
|
123
127
|
const { targetModel } = props.attribute;
|
|
124
128
|
const href = `../${collections.COLLECTION_TYPES}/${targetModel}/${relationData.documentId}`;
|
|
125
|
-
const label = relations.getRelationLabel(relationData, props.mainField);
|
|
129
|
+
const label = relations.getRelationLabel(relationData, props.mainField, emptyLabel);
|
|
126
130
|
const isAdminUserRelation = targetModel === 'admin::user';
|
|
127
131
|
return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
|
128
132
|
paddingTop: 2,
|
|
@@ -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 field = useField<\n { results: RelationResult[]; meta: { missingCount: number } } | RelationResult[]\n >(props.name);\n\n /**\n * Ideally the server would return the correct shape, however, for admin user relations\n * it sanitizes everything out when it finds an object for the relation value.\n */\n let formattedFieldValue;\n if (field) {\n formattedFieldValue = Array.isArray(field.value)\n ? { results: field.value, meta: { missingCount: 0 } }\n : field.value;\n }\n\n // Be defensive about the shape: admin-user relations are sanitized to a\n // plain user object on the server, and historical version data can carry\n // shapes that pre-date the `{ results, meta }` contract. Treat anything\n // without an array `results` as \"no relations\".\n const hasResultsShape =\n !!formattedFieldValue &&\n typeof formattedFieldValue === 'object' &&\n Array.isArray((formattedFieldValue as { results?: unknown }).results);\n const missingCount =\n hasResultsShape &&\n typeof (formattedFieldValue as { meta?: { missingCount?: number } }).meta?.missingCount ===\n 'number'\n ? (formattedFieldValue as { meta: { missingCount: number } }).meta.missingCount\n : 0;\n\n if (\n !hasResultsShape ||\n ((formattedFieldValue as { results: unknown[] }).results.length === 0 && missingCount === 0)\n ) {\n return (\n <>\n <Field.Label action={props.labelAction}>{props.label}</Field.Label>\n <Box marginTop={1}>\n <StyledAlert variant=\"default\">\n {formatMessage({\n id: 'content-manager.history.content.no-relations',\n defaultMessage: 'No relations.',\n })}\n </StyledAlert>\n </Box>\n </>\n );\n }\n\n const { results, meta } = formattedFieldValue as {\n results: RelationResult[];\n meta: { missingCount: number };\n };\n\n return (\n <Box>\n <Field.Label>{props.label}</Field.Label>\n {results.length > 0 && (\n <Flex direction=\"column\" gap={2} marginTop={1} alignItems=\"stretch\">\n {results.map((relationData) => {\n // @ts-expect-error - targetModel does exist on the attribute. But it's not typed.\n const { targetModel } = props.attribute;\n const href = `../${COLLECTION_TYPES}/${targetModel}/${relationData.documentId}`;\n const label = getRelationLabel(relationData, props.mainField);\n const isAdminUserRelation = targetModel === 'admin::user';\n\n return (\n <Flex\n key={relationData.documentId ?? relationData.id}\n paddingTop={2}\n paddingBottom={2}\n paddingLeft={4}\n paddingRight={4}\n hasRadius\n borderColor=\"neutral200\"\n background=\"neutral150\"\n justifyContent=\"space-between\"\n >\n <Box minWidth={0} paddingTop={1} paddingBottom={1} paddingRight={4}>\n <Tooltip label={label}>\n {isAdminUserRelation ? (\n <Typography>{label}</Typography>\n ) : (\n <LinkEllipsis tag={NavLink} to={href}>\n {label}\n </LinkEllipsis>\n )}\n </Tooltip>\n </Box>\n <DocumentStatus status={relationData.status as string} />\n </Flex>\n );\n })}\n </Flex>\n )}\n {meta.missingCount > 0 && (\n <StyledAlert\n marginTop={1}\n variant=\"warning\"\n title={formatMessage(\n {\n id: 'content-manager.history.content.missing-relations.title',\n defaultMessage:\n '{number, plural, =1 {Missing relation} other {{number} missing relations}}',\n },\n { number: meta.missingCount }\n )}\n >\n {formatMessage(\n {\n id: 'content-manager.history.content.missing-relations.message',\n defaultMessage:\n \"{number, plural, =1 {It has} other {They have}} been deleted and can't be restored.\",\n },\n { number: meta.missingCount }\n )}\n </StyledAlert>\n )}\n </Box>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * CustomMediaInput\n * -----------------------------------------------------------------------------------------------*/\n\n// Create an object with value at key path (i.e. 'a.b.c')\nconst createInitialValuesForPath = (keyPath: string, value: 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","field","useField","name","formattedFieldValue","Array","isArray","value","results","meta","missingCount","hasResultsShape","length","_jsxs","_Fragment","_jsx","Field","Label","action","labelAction","label","Box","marginTop","variant","id","defaultMessage","Flex","direction","gap","alignItems","map","relationData","targetModel","attribute","href","COLLECTION_TYPES","documentId","getRelationLabel","mainField","isAdminUserRelation","paddingTop","paddingBottom","paddingLeft","paddingRight","hasRadius","borderColor","background","justifyContent","minWidth","Tooltip","Typography","tag","NavLink","to","DocumentStatus","status","title","number","createInitialValuesForPath","keyPath","keys","split","root","node","forEach","key","index","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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;IAC1B,MAAMC,KAAAA,GAAQC,oBAAAA,CAEZJ,KAAAA,CAAMK,IAAI,CAAA;AAEZ;;;AAGC,MACD,IAAIC,mBAAAA;AACJ,IAAA,IAAIH,KAAAA,EAAO;AACTG,QAAAA,mBAAAA,GAAsBC,KAAAA,CAAMC,OAAO,CAACL,KAAAA,CAAMM,KAAK,CAAA,GAC3C;AAAEC,YAAAA,OAAAA,EAASP,MAAMM,KAAK;YAAEE,IAAAA,EAAM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A,EAAMA,IAAAA;gBACN/E,WAAAA,EAAakF,iBAAAA;gBACbqD,OAAAA,EAAS5J,KAAAA,CAAMmC,SAAS,CAAC0H,IAAI,CAAC7H,GAAG,CAAC,CAACvB,KAAAA,IAAW;AAAEA,wBAAAA;qBAAM,CAAA,CAAA;;AAEtDoH,gBAAAA,IAAAA,EAAM7H,KAAAA,CAAMkI,WAAW,GAAG,cAAA,GAAiBlI,MAAM6H,IAAI;gBACrD/C,QAAAA,EAAU0D;;AAGhB,QAAA;;YAEE,MAAM,EAAEsB,QAAQC,OAAO,EAAEvH,WAAWwH,UAAU,EAAE,GAAGC,SAAAA,EAAW,GAAGjK,KAAAA;AACjE,YAAA,qBACEiB,cAAA,CAAC+H,yBAAAA,EAAAA;AACE,gBAAA,GAAGiB,SAAS;gBACb7D,IAAAA,EAAMA,IAAAA;gBACN/E,WAAAA,EAAakF,iBAAAA;;AAEbsB,gBAAAA,IAAAA,EAAM7H,KAAAA,CAAMkI,WAAW,GAAG,cAAA,GAAiBlI,MAAM6H,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};\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,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nI,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;;;;;;"}
|
|
@@ -46,6 +46,10 @@ const StyledAlert = styled(Alert).attrs({
|
|
|
46
46
|
`;
|
|
47
47
|
const CustomRelationInput = (props)=>{
|
|
48
48
|
const { formatMessage } = useIntl();
|
|
49
|
+
const emptyLabel = formatMessage({
|
|
50
|
+
id: 'content-manager.containers.empty-label',
|
|
51
|
+
defaultMessage: 'Untitled'
|
|
52
|
+
});
|
|
49
53
|
const field = useField(props.name);
|
|
50
54
|
/**
|
|
51
55
|
* Ideally the server would return the correct shape, however, for admin user relations
|
|
@@ -100,7 +104,7 @@ const CustomRelationInput = (props)=>{
|
|
|
100
104
|
// @ts-expect-error - targetModel does exist on the attribute. But it's not typed.
|
|
101
105
|
const { targetModel } = props.attribute;
|
|
102
106
|
const href = `../${COLLECTION_TYPES}/${targetModel}/${relationData.documentId}`;
|
|
103
|
-
const label = getRelationLabel(relationData, props.mainField);
|
|
107
|
+
const label = getRelationLabel(relationData, props.mainField, emptyLabel);
|
|
104
108
|
const isAdminUserRelation = targetModel === 'admin::user';
|
|
105
109
|
return /*#__PURE__*/ jsxs(Flex, {
|
|
106
110
|
paddingTop: 2,
|