diff --git a/cypress/e2e/content/item-list-table.spec.js b/cypress/e2e/content/item-list-table.spec.js new file mode 100644 index 0000000000..64a4fbd6ce --- /dev/null +++ b/cypress/e2e/content/item-list-table.spec.js @@ -0,0 +1,13 @@ +describe("Content item list table", () => { + it("Resolves internal link zuids", () => { + cy.waitOn("/search/items*", () => { + cy.waitOn("/v1/content/models*", () => { + cy.visit("/content/6-a1a600-k0b6f0"); + }); + }); + + cy.getBySelector("SingleRelationshipCell", { timeout: 10000 }) + .first() + .contains("All Field Types"); + }); +}); diff --git a/src/apps/content-editor/src/app/views/ItemList/TableCells/SingleRelationshipCell.tsx b/src/apps/content-editor/src/app/views/ItemList/TableCells/SingleRelationshipCell.tsx index 5963905d67..4458274cea 100644 --- a/src/apps/content-editor/src/app/views/ItemList/TableCells/SingleRelationshipCell.tsx +++ b/src/apps/content-editor/src/app/views/ItemList/TableCells/SingleRelationshipCell.tsx @@ -1,10 +1,24 @@ import { GridRenderCellParams } from "@mui/x-data-grid-pro"; import { Chip } from "@mui/material"; +import { useDispatch } from "react-redux"; +import { useEffect } from "react"; + +import { searchItems } from "../../../../../../../shell/store/content"; export const SingleRelationshipCell = ({ params, }: { params: GridRenderCellParams; }) => { - return ; + const dispatch = useDispatch(); + useEffect(() => { + // If value starts with '7-', that means it was unable to find the item in the store so we need to fetch it + if (params.value?.startsWith("7-")) { + dispatch(searchItems(params.value)); + } + }, [params.value, dispatch]); + + return ( + + ); }; diff --git a/src/apps/content-editor/src/app/views/ItemList/index.tsx b/src/apps/content-editor/src/app/views/ItemList/index.tsx index 73f9fcf42a..1065cbf03d 100644 --- a/src/apps/content-editor/src/app/views/ItemList/index.tsx +++ b/src/apps/content-editor/src/app/views/ItemList/index.tsx @@ -141,6 +141,14 @@ export const ItemList = () => { return; } + // Internal link has a simpler way of deriving the value + if (fieldDataType === "internal_link") { + return ( + allItems?.[relatedContentItemZUID]?.web?.metaTitle || + relatedContentItemZUID + ); + } + // Finds the related field zuid that's stored in the specific field's data const fieldData = fields?.find( (field) =>