Skip to content

Commit

Permalink
feat: add advancedEditRelative to template links hash (#1273)
Browse files Browse the repository at this point in the history
- add advancedEditRelative url to template links hash
- update relevant tests
  • Loading branch information
juliannemarik authored Oct 16, 2023
1 parent bf7f290 commit cd87479
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/common/src/templates/_internal/computeLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};
}
2 changes: 2 additions & 0 deletions packages/common/test/templates/_internal/computeLinks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand All @@ -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", () => {
Expand Down

0 comments on commit cd87479

Please sign in to comment.