From cd874797faed04a0fe9bc326376fa1342d9bbd0f Mon Sep 17 00:00:00 2001 From: Julianne Crawford Date: Mon, 16 Oct 2023 11:08:24 -0500 Subject: [PATCH] feat: add advancedEditRelative to template links hash (#1273) - add advancedEditRelative url to template links hash - update relevant tests --- .../src/templates/_internal/computeLinks.ts | 15 ++++++++++----- .../test/templates/_internal/computeLinks.test.ts | 2 ++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/common/src/templates/_internal/computeLinks.ts b/packages/common/src/templates/_internal/computeLinks.ts index c92ae045163..84a8228b68d 100644 --- a/packages/common/src/templates/_internal/computeLinks.ts +++ b/packages/common/src/templates/_internal/computeLinks.ts @@ -29,16 +29,21 @@ export function computeLinks( // managing it in the workspace, so we kick users to AGO const isDeployed = item.typeKeywords?.includes("Deployed"); const itemHomeUrl = getItemHomeUrl(item.id, requestOptions); + const siteRelativeUrl = getHubRelativeUrl( + item.type, + getItemIdentifier(item), + item.typeKeywords + ); return { self: itemHomeUrl, - siteRelative: getHubRelativeUrl( - item.type, - getItemIdentifier(item), - item.typeKeywords - ), + siteRelative: siteRelativeUrl, workspaceRelative: isDeployed ? itemHomeUrl : getRelativeWorkspaceUrl(item.type, getItemIdentifier(item)), + advancedEditRelative: `${siteRelativeUrl + .split("/") + .slice(0, -1) + .join("/")}/edit/advanced`, thumbnail: getItemThumbnailUrl(item, requestOptions, token), }; } diff --git a/packages/common/test/templates/_internal/computeLinks.test.ts b/packages/common/test/templates/_internal/computeLinks.test.ts index 60621b0d18b..e27c9ced537 100644 --- a/packages/common/test/templates/_internal/computeLinks.test.ts +++ b/packages/common/test/templates/_internal/computeLinks.test.ts @@ -38,6 +38,7 @@ describe("templates: computeLinks", () => { expect(chk.self).toBe("/some-item-home-url"); expect(chk.siteRelative).toBe("/templates/mock-slug/about"); expect(chk.workspaceRelative).toBe("/workspace/templates/mock-slug"); + expect(chk.advancedEditRelative).toBe("/templates/mock-slug/edit/advanced"); expect(chk.thumbnail).toBe("/some-thumbnail-url"); }); it("generates a links hash using the templates's id when no slug is available", () => { @@ -46,6 +47,7 @@ describe("templates: computeLinks", () => { expect(chk.self).toBe("/some-item-home-url"); expect(chk.siteRelative).toBe("/templates/00c/about"); expect(chk.workspaceRelative).toBe("/workspace/templates/00c"); + expect(chk.advancedEditRelative).toBe("/templates/00c/edit/advanced"); expect(chk.thumbnail).toBe("/some-thumbnail-url"); }); describe("Deployed templates", () => {