diff --git a/web/e2e/project/content/content.spec.ts b/web/e2e/project/content/content.spec.ts index 6cd9a3ce55..57cb46426b 100644 --- a/web/e2e/project/content/content.spec.ts +++ b/web/e2e/project/content/content.spec.ts @@ -79,6 +79,45 @@ test("Publishing and Unpublishing item has succeeded", async ({ page }) => { await expect(page.getByText("DRAFT")).toBeVisible(); }); +test("Showing item title has succeeded", async ({ page }) => { + await page.locator("li").filter({ hasText: "Text" }).locator("div").first().click(); + await handleFieldForm(page, "text"); + await page.getByText("Content").click(); + await page.getByRole("button", { name: "plus New Item" }).click(); + await expect(page.getByTitle("e2e model name", { exact: true })).toBeVisible(); + await page.getByLabel("text").click(); + await page.getByLabel("text").fill("text"); + await page.getByRole("button", { name: "Save" }).click(); + await closeNotification(page); + const itemId = await page + .getByRole("main") + .locator("p") + .filter({ hasText: "ID" }) + .locator("div > span") + .innerText(); + await expect(page.getByTitle(`e2e model name / ${itemId}`, { exact: true })).toBeVisible(); + + await page.getByText("Schema").click(); + await page.getByRole("img", { name: "ellipsis" }).locator("svg").click(); + await page.getByLabel("Use as title").check(); + await page.getByRole("tab", { name: "Default value" }).click(); + await page.getByLabel("Set default value").click(); + await page.getByLabel("Set default value").fill("default text"); + await page.getByRole("button", { name: "OK" }).click(); + await closeNotification(page); + + await page.getByText("Content").click(); + await page.getByRole("cell").getByLabel("edit").locator("svg").click(); + await expect(page.getByTitle(`e2e model name / text`, { exact: true })).toBeVisible(); + await page.getByLabel("Back").click(); + + await page.getByRole("button", { name: "plus New Item" }).click(); + await expect(page.getByTitle("e2e model name", { exact: true })).toBeVisible(); + await page.getByRole("button", { name: "Save" }).click(); + await closeNotification(page); + await expect(page.getByTitle(`e2e model name / default text`, { exact: true })).toBeVisible(); +}); + test("Comment CRUD on Content page has succeeded", async ({ page }) => { await page.locator("li").filter({ hasText: "Text" }).locator("div").first().click(); await handleFieldForm(page, "text"); diff --git a/web/src/components/molecules/Content/Details/index.tsx b/web/src/components/molecules/Content/Details/index.tsx index c2a342b739..d3a1a2e328 100644 --- a/web/src/components/molecules/Content/Details/index.tsx +++ b/web/src/components/molecules/Content/Details/index.tsx @@ -27,6 +27,7 @@ type Props = { // eslint-disable-next-line @typescript-eslint/no-explicit-any initialFormValues: Record; initialMetaFormValues: Record; + title: string; item?: Item; itemId?: string; itemLoading: boolean; @@ -113,6 +114,7 @@ const ContentDetailsMolecule: React.FC = ({ modelsMenu, initialFormValues, initialMetaFormValues, + title, item, itemId, itemLoading, @@ -194,6 +196,7 @@ const ContentDetailsMolecule: React.FC = ({ ) : ( = ({ + title, item, loadingReference, linkedItemsModalList, @@ -484,7 +486,7 @@ const ContentForm: React.FC = ({ initialValues={initialFormValues} onValuesChange={handleValuesChange}> @@ -724,6 +726,7 @@ const FormItemsWrapper = styled.div` max-height: calc(100% - 72px); overflow-y: auto; padding: 36px; + border-top: 1px solid #00000008; `; const SideBarWrapper = styled.div` diff --git a/web/src/components/organisms/Project/Content/ContentDetails/hooks.ts b/web/src/components/organisms/Project/Content/ContentDetails/hooks.ts index 9b1430d74e..e670b5704a 100644 --- a/web/src/components/organisms/Project/Content/ContentDetails/hooks.ts +++ b/web/src/components/organisms/Project/Content/ContentDetails/hooks.ts @@ -576,6 +576,16 @@ export default () => { [checkIfItemIsReferenced], ); + const title = useMemo(() => { + let result = currentModel?.name ?? ""; + if (currentItem) { + const titleField = currentModel?.schema.fields.find(field => field.isTitle); + const titleValue = titleField && initialFormValues[titleField.id]; + result += ` / ${titleValue || currentItem.id}`; + } + return result; + }, [currentItem, currentModel?.name, currentModel?.schema.fields, initialFormValues]); + return { loadingReference, linkedItemsModalList, @@ -585,6 +595,7 @@ export default () => { itemLoading, requestCreationLoading, currentModel, + title, currentItem, initialFormValues, initialMetaFormValues, diff --git a/web/src/components/organisms/Project/Content/ContentDetails/index.tsx b/web/src/components/organisms/Project/Content/ContentDetails/index.tsx index 131074d0a1..00fffe5363 100644 --- a/web/src/components/organisms/Project/Content/ContentDetails/index.tsx +++ b/web/src/components/organisms/Project/Content/ContentDetails/index.tsx @@ -17,6 +17,7 @@ const ContentDetails: React.FC = () => { itemId, itemLoading, currentModel, + title, currentItem, initialFormValues, initialMetaFormValues, @@ -125,6 +126,7 @@ const ContentDetails: React.FC = () => { /> ) : undefined } + title={title} item={currentItem} itemId={itemId} itemLoading={itemLoading}