Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve internal link zuids #3014

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions cypress/e2e/content/item-list-table.spec.js
Original file line number Diff line number Diff line change
@@ -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");
});
});
Original file line number Diff line number Diff line change
@@ -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 <Chip label={params.value} size="small" />;
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 (
<Chip data-cy="SingleRelationshipCell" label={params.value} size="small" />
);
};
8 changes: 8 additions & 0 deletions src/apps/content-editor/src/app/views/ItemList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
Loading