From e649069552bf753376a677076fbf03464d1d7907 Mon Sep 17 00:00:00 2001 From: Vivian Zhang Date: Tue, 21 May 2024 09:47:54 -0700 Subject: [PATCH 1/8] fix: add siteRelativeEntityType to project links affects: @esri/hub-common --- .../content/_internal/internalContentUtils.ts | 29 +++++++++++++++---- .../common/src/core/types/IHubEntityBase.ts | 3 ++ .../src/projects/_internal/computeLinks.ts | 1 + 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/packages/common/src/content/_internal/internalContentUtils.ts b/packages/common/src/content/_internal/internalContentUtils.ts index 70fbde19212..54a6b86c5f2 100644 --- a/packages/common/src/content/_internal/internalContentUtils.ts +++ b/packages/common/src/content/_internal/internalContentUtils.ts @@ -16,7 +16,12 @@ import { ISpatialReference, IUser, } from "@esri/arcgis-rest-types"; -import { IHubContent, IHubLocation, PublisherSource } from "../../core"; +import { + IHubContent, + IHubLocation, + PublisherSource, + getTypeFromEntity, +} from "../../core"; import { IHubGeography, GeographyProvenance, @@ -231,9 +236,10 @@ export const isProxiedCSV = ( */ export const getHubRelativeUrl = ( type: string, - identifier: string, + identifier?: string, typeKeywords?: string[] ): string => { + const entityType = getTypeFromEntity({ type }); // solution types have their own logic let contentUrl = getSolutionUrl(type, identifier, typeKeywords) || @@ -254,8 +260,12 @@ export const getHubRelativeUrl = ( // default to the catchall content route let path = "/content"; if (family === "feedback") { - // the exception - path = "/feedback/surveys"; + if (identifier) { + // the exception + path = "/feedback/surveys"; + } else { + path = ""; + } } else if (isPageType(type, typeKeywords)) { // pages are in the document family, // but instead of showing the page's metadata on /documents/about @@ -265,7 +275,16 @@ export const getHubRelativeUrl = ( // the rule: route name is plural of family name path = `/${family}s`; } - contentUrl = `${path}/${identifier}`; + if (identifier) { + contentUrl = `${path}/${identifier}`; + } else { + contentUrl = `${path}`; + } + const entitiesHaveEntityTypeView = ["initiative", "project", "content"]; + + if (!identifier && !entitiesHaveEntityTypeView.includes(entityType)) { + contentUrl = ""; + } } return contentUrl; }; diff --git a/packages/common/src/core/types/IHubEntityBase.ts b/packages/common/src/core/types/IHubEntityBase.ts index ff2933ee69c..8c836a0e648 100644 --- a/packages/common/src/core/types/IHubEntityBase.ts +++ b/packages/common/src/core/types/IHubEntityBase.ts @@ -31,6 +31,9 @@ export interface IHubEntityLinks { * Relative url of the entity, within a site */ siteRelative?: string; + + siteRelativeEntityType?: string; + /** * Relative workspace url of the entity, within a site */ diff --git a/packages/common/src/projects/_internal/computeLinks.ts b/packages/common/src/projects/_internal/computeLinks.ts index 8f910ca5511..9c88350d549 100644 --- a/packages/common/src/projects/_internal/computeLinks.ts +++ b/packages/common/src/projects/_internal/computeLinks.ts @@ -28,6 +28,7 @@ export function computeLinks( return { self: getItemHomeUrl(item.id, requestOptions), siteRelative: getHubRelativeUrl(item.type, getItemIdentifier(item)), + siteRelativeEntityType: getHubRelativeUrl(item.type), workspaceRelative: getRelativeWorkspaceUrl( item.type, getItemIdentifier(item) From f82a3566b8bb79f037c5cecdaa756cda4f69eb16 Mon Sep 17 00:00:00 2001 From: Vivian Zhang Date: Tue, 21 May 2024 10:34:17 -0700 Subject: [PATCH 2/8] fix: add siteRelativeEntityType link to events, groups, initiative-templates, initiatives, pages, si affects: @esri/hub-common --- packages/common/src/events/_internal/computeLinks.ts | 1 + packages/common/src/groups/_internal/computeLinks.ts | 2 ++ .../common/src/initiative-templates/_internal/computeLinks.ts | 1 + packages/common/src/initiatives/_internal/computeLinks.ts | 1 + packages/common/src/pages/_internal/computeProps.ts | 2 ++ packages/common/src/sites/_internal/computeLinks.ts | 1 + packages/common/src/templates/_internal/computeLinks.ts | 1 + 7 files changed, 9 insertions(+) diff --git a/packages/common/src/events/_internal/computeLinks.ts b/packages/common/src/events/_internal/computeLinks.ts index 685d41204be..a84ac9c599f 100644 --- a/packages/common/src/events/_internal/computeLinks.ts +++ b/packages/common/src/events/_internal/computeLinks.ts @@ -16,6 +16,7 @@ export function computeLinks(event: IEvent): IHubEntityLinks { return { self: siteRelative, siteRelative, + siteRelativeEntityType: getHubRelativeUrl("event"), workspaceRelative: getRelativeWorkspaceUrl("Event", event.id), // TODO // thumbnail: "", diff --git a/packages/common/src/groups/_internal/computeLinks.ts b/packages/common/src/groups/_internal/computeLinks.ts index bf45b4ffa50..ac4e7e2e84a 100644 --- a/packages/common/src/groups/_internal/computeLinks.ts +++ b/packages/common/src/groups/_internal/computeLinks.ts @@ -5,6 +5,7 @@ import { IHubEntityLinks } from "../../core/types"; import { getRelativeWorkspaceUrl } from "../../core/getRelativeWorkspaceUrl"; import { getGroupHomeUrl } from "../../urls/getGroupHomeUrl"; import { getGroupThumbnailUrl } from "../../search/utils"; +import { getHubRelativeUrl } from "../../content/_internal/internalContentUtils"; /** * Compute the links that get appended to a Hub Group @@ -26,6 +27,7 @@ export function computeLinks( return { self: getGroupHomeUrl(group.id, requestOptions), siteRelative: `/groups/${group.id}`, + siteRelativeEntityType: getHubRelativeUrl(group.type), workspaceRelative: getRelativeWorkspaceUrl("Group", group.id), thumbnail: getGroupThumbnailUrl(requestOptions.portal, group, token), }; diff --git a/packages/common/src/initiative-templates/_internal/computeLinks.ts b/packages/common/src/initiative-templates/_internal/computeLinks.ts index 7a26c4c2497..27ab6f85475 100644 --- a/packages/common/src/initiative-templates/_internal/computeLinks.ts +++ b/packages/common/src/initiative-templates/_internal/computeLinks.ts @@ -28,6 +28,7 @@ export function computeLinks( return { self: getItemHomeUrl(item.id, requestOptions), siteRelative: getHubRelativeUrl(item.type, getItemIdentifier(item)), + siteRelativeEntityType: getHubRelativeUrl(item.type), workspaceRelative: getRelativeWorkspaceUrl( item.type, getItemIdentifier(item) diff --git a/packages/common/src/initiatives/_internal/computeLinks.ts b/packages/common/src/initiatives/_internal/computeLinks.ts index 6949350d0c2..e69abb6ca1e 100644 --- a/packages/common/src/initiatives/_internal/computeLinks.ts +++ b/packages/common/src/initiatives/_internal/computeLinks.ts @@ -28,6 +28,7 @@ export function computeLinks( return { self: getItemHomeUrl(item.id, requestOptions), siteRelative: getHubRelativeUrl(item.type, getItemIdentifier(item)), + siteRelativeEntityType: getHubRelativeUrl(item.type), workspaceRelative: getRelativeWorkspaceUrl( item.type, getItemIdentifier(item) diff --git a/packages/common/src/pages/_internal/computeProps.ts b/packages/common/src/pages/_internal/computeProps.ts index 0f52346b106..51538afaf33 100644 --- a/packages/common/src/pages/_internal/computeProps.ts +++ b/packages/common/src/pages/_internal/computeProps.ts @@ -9,6 +9,7 @@ import { getItemHomeUrl } from "../../urls/get-item-home-url"; import { IHubPage } from "../../core/types/IHubPage"; import { getRelativeWorkspaceUrl } from "../../core/getRelativeWorkspaceUrl"; import { computeBaseProps } from "../../core/_internal/computeBaseProps"; +import { getHubRelativeUrl } from "../../content/_internal/internalContentUtils"; /** * Given a model and a page, set various computed properties that can't be directly mapped @@ -37,6 +38,7 @@ export function computeProps( page.links = { self: getItemHomeUrl(page.id, requestOptions), siteRelative: `/pages/${page.id}`, + siteRelativeEntityType: getHubRelativeUrl(page.type), workspaceRelative: getRelativeWorkspaceUrl("page", page.id), layoutRelative: `/pages/${page.id}/edit`, thumbnail: thumbnailUrl, diff --git a/packages/common/src/sites/_internal/computeLinks.ts b/packages/common/src/sites/_internal/computeLinks.ts index 7a3ec7f8226..8a9c7f6d6d9 100644 --- a/packages/common/src/sites/_internal/computeLinks.ts +++ b/packages/common/src/sites/_internal/computeLinks.ts @@ -27,6 +27,7 @@ export function computeLinks( return { self: item.url, siteRelative: getHubRelativeUrl(item.type, item.id, item.typeKeywords), + siteRelativeEntityType: getHubRelativeUrl(item.type), layoutRelative: "/edit", workspaceRelative: getRelativeWorkspaceUrl( item.type, diff --git a/packages/common/src/templates/_internal/computeLinks.ts b/packages/common/src/templates/_internal/computeLinks.ts index 84a8228b68d..fb3c8a05e26 100644 --- a/packages/common/src/templates/_internal/computeLinks.ts +++ b/packages/common/src/templates/_internal/computeLinks.ts @@ -37,6 +37,7 @@ export function computeLinks( return { self: itemHomeUrl, siteRelative: siteRelativeUrl, + siteRelativeEntityType: getHubRelativeUrl(item.type), workspaceRelative: isDeployed ? itemHomeUrl : getRelativeWorkspaceUrl(item.type, getItemIdentifier(item)), From 9f9485832a60435df6d0327d7c777df8b472e7c0 Mon Sep 17 00:00:00 2001 From: Vivian Zhang Date: Wed, 22 May 2024 10:05:39 -0700 Subject: [PATCH 3/8] chore: add siteRelativeEntityType to content affects: @esri/hub-common --- packages/common/src/content/_internal/computeProps.ts | 1 + packages/common/src/content/get-family.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/common/src/content/_internal/computeProps.ts b/packages/common/src/content/_internal/computeProps.ts index b777c573299..7d373971680 100644 --- a/packages/common/src/content/_internal/computeProps.ts +++ b/packages/common/src/content/_internal/computeProps.ts @@ -45,6 +45,7 @@ export function computeProps( content.slug || content.id, content.typeKeywords ), + siteRelativeEntityType: getHubRelativeUrl(content.type), workspaceRelative: getRelativeWorkspaceUrl("content", content.id), thumbnail: thumbnailUrl, contentEditUrl: getContentEditUrl(model.item, requestOptions), diff --git a/packages/common/src/content/get-family.ts b/packages/common/src/content/get-family.ts index 1b9f6e63c6e..8bcdb415cad 100644 --- a/packages/common/src/content/get-family.ts +++ b/packages/common/src/content/get-family.ts @@ -19,7 +19,7 @@ export function getFamily(type: string) { let family; // override default behavior for the rows that are highlighted in yellow here: // https://esriis.sharepoint.com/:x:/r/sites/ArcGISHub/_layouts/15/Doc.aspx?sourcedoc=%7BADA1C9DC-4F6C-4DE4-92C6-693EF9571CFA%7D&file=Hub%20Routes.xlsx&nav=MTBfe0VENEREQzI4LUZFMDctNEI0Ri04NjcyLThCQUE2MTA0MEZGRn1fezIwMTIwMEJFLTA4MEQtNEExRC05QzA4LTE5MTAzOUQwMEE1RH0&action=default&mobileredirect=true&cid=df1c874b-c367-4cea-bc13-7bebfad3f2ac - switch (type.toLowerCase()) { + switch (type?.toLowerCase()) { // NOTE: we really want to put tiled image services in the maps family // but we would need the typekeywords to differentiate them // for now send them to the maps route here: From cd0f4de69f5253e4a3ee33f301b72ef5c2fbc554 Mon Sep 17 00:00:00 2001 From: Vivian Zhang Date: Wed, 22 May 2024 10:34:48 -0700 Subject: [PATCH 4/8] chore: clean up and add comments affects: @esri/hub-common --- .../content/_internal/internalContentUtils.ts | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/packages/common/src/content/_internal/internalContentUtils.ts b/packages/common/src/content/_internal/internalContentUtils.ts index 54a6b86c5f2..ba9b9aba006 100644 --- a/packages/common/src/content/_internal/internalContentUtils.ts +++ b/packages/common/src/content/_internal/internalContentUtils.ts @@ -229,7 +229,10 @@ export const isProxiedCSV = ( /** * Get the relative URL to use for the item in a hub site * @param type - * @param identifier + * @param identifier optional, if not pass, will return a URL to the entities, + * e.g. /initiatives, /projects + * NOTE: not all entities have the entities route set up, in that case, we will + * not return an URL, so they will be redirected back to the site home * @param typeKeywords * @returns * @private @@ -239,7 +242,6 @@ export const getHubRelativeUrl = ( identifier?: string, typeKeywords?: string[] ): string => { - const entityType = getTypeFromEntity({ type }); // solution types have their own logic let contentUrl = getSolutionUrl(type, identifier, typeKeywords) || @@ -259,13 +261,9 @@ export const getHubRelativeUrl = ( ]; // default to the catchall content route let path = "/content"; + // the exception if (family === "feedback") { - if (identifier) { - // the exception - path = "/feedback/surveys"; - } else { - path = ""; - } + path = identifier ? "/feedback/surveys" : ""; } else if (isPageType(type, typeKeywords)) { // pages are in the document family, // but instead of showing the page's metadata on /documents/about @@ -275,14 +273,13 @@ export const getHubRelativeUrl = ( // the rule: route name is plural of family name path = `/${family}s`; } - if (identifier) { - contentUrl = `${path}/${identifier}`; - } else { - contentUrl = `${path}`; - } - const entitiesHaveEntityTypeView = ["initiative", "project", "content"]; - if (!identifier && !entitiesHaveEntityTypeView.includes(entityType)) { + contentUrl = identifier ? `${path}/${identifier}` : `${path}`; + const entitiesHaveEntitiesRoute = ["initiative", "project", "content"]; + const entityType = getTypeFromEntity({ type }); + // if there is no identifier and the entity does not have the entities route + // set up, do not return an url + if (!identifier && !entitiesHaveEntitiesRoute.includes(entityType)) { contentUrl = ""; } } From d0c557333eda85f6a5cd406c6ebd75e43caa0a01 Mon Sep 17 00:00:00 2001 From: Vivian Zhang Date: Wed, 22 May 2024 11:49:02 -0700 Subject: [PATCH 5/8] chore: remove content from entitiesHaveEntitiesRoute list affects: @esri/hub-common --- .../content/_internal/internalContentUtils.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/common/src/content/_internal/internalContentUtils.ts b/packages/common/src/content/_internal/internalContentUtils.ts index ba9b9aba006..cb8a477e4f9 100644 --- a/packages/common/src/content/_internal/internalContentUtils.ts +++ b/packages/common/src/content/_internal/internalContentUtils.ts @@ -246,8 +246,8 @@ export const getHubRelativeUrl = ( let contentUrl = getSolutionUrl(type, identifier, typeKeywords) || getInitiativeTemplateUrl(type, identifier, typeKeywords); + const family = getFamily(type); if (!contentUrl) { - const family = getFamily(type); const familiesWithPluralizedRoute = [ "app", "dataset", @@ -273,15 +273,14 @@ export const getHubRelativeUrl = ( // the rule: route name is plural of family name path = `/${family}s`; } - contentUrl = identifier ? `${path}/${identifier}` : `${path}`; - const entitiesHaveEntitiesRoute = ["initiative", "project", "content"]; - const entityType = getTypeFromEntity({ type }); - // if there is no identifier and the entity does not have the entities route - // set up, do not return an url - if (!identifier && !entitiesHaveEntitiesRoute.includes(entityType)) { - contentUrl = ""; - } + } + // TODO: once an entity has its entities route set up, add it to this list + const entitiesHaveEntitiesRoute = ["initiative", "project"]; + // if there is no identifier and the entity does not have the entities route + // set up, do not return an url + if (!identifier && !entitiesHaveEntitiesRoute.includes(family)) { + contentUrl = ""; } return contentUrl; }; From 8329395ef6e7b308c490e4110c4829d95ba8f277 Mon Sep 17 00:00:00 2001 From: Vivian Zhang Date: Wed, 22 May 2024 15:27:30 -0700 Subject: [PATCH 6/8] chore: add tests affects: @esri/hub-common --- .../_internal/internalContentUtils.test.ts | 74 ++++++++++++++++++- .../events/_internal/PropertyMapper.test.ts | 1 + .../events/_internal/computeLinks.test.ts | 1 + .../groups/_internal/computeLinks.test.ts | 1 + .../_internal/computeLinks.test.ts | 1 + .../_internal/computeLinks.test.ts | 2 + .../projects/_internal/computeLinks.test.ts | 1 + .../eventToSearchResult.test.ts | 2 + .../test/sites/_internal/computeLinks.test.ts | 1 + 9 files changed, 83 insertions(+), 1 deletion(-) diff --git a/packages/common/test/content/_internal/internalContentUtils.test.ts b/packages/common/test/content/_internal/internalContentUtils.test.ts index d9ece282630..410589b642a 100644 --- a/packages/common/test/content/_internal/internalContentUtils.test.ts +++ b/packages/common/test/content/_internal/internalContentUtils.test.ts @@ -3,6 +3,7 @@ import { getContentEditUrl, getExtentObject, deriveLocationFromItem, + getHubRelativeUrl, } from "../../../src/content/_internal/internalContentUtils"; import * as internalContentUtils from "../../../src/content/_internal/internalContentUtils"; import { IHubRequestOptions } from "../../../src/types"; @@ -10,7 +11,6 @@ import { cloneObject } from "../../../src/util"; import { MOCK_HUB_REQOPTS } from "../../mocks/mock-auth"; import { IHubLocation } from "../../../src"; import * as _enrichmentsModule from "../../../src/items/_enrichments"; -import { IHubAdditionalResource } from "../../../src/core/types/IHubAdditionalResource"; describe("getContentEditUrl", () => { let requestOptions: IHubRequestOptions; @@ -471,3 +471,75 @@ describe("deriveLocationFromItem", () => { }); }); }); + +describe("getHubRelativeUrl", () => { + describe("handle when there is an identifier", () => { + const identifier = "a-slug"; + it("should handle a family that does not have a puralized route", () => { + // 'report template' should be in the 'content' family + const result = getHubRelativeUrl("report template", identifier); + expect(result).toBe(`/content/${identifier}`); + }); + it("should handle initiatives", () => { + const result = getHubRelativeUrl("Hub Initiative", identifier); + expect(result).toBe(`/initiatives/${identifier}`); + }); + it("should handle projects", () => { + const result = getHubRelativeUrl("Hub Project", identifier); + expect(result).toBe(`/projects/${identifier}`); + }); + it("should handle initiative templates", () => { + let result = getHubRelativeUrl("Hub Initiative", identifier, [ + "hubInitiativeTemplate", + ]); + expect(result).toBe(`/initiatives/templates/${identifier}/about`); + result = getHubRelativeUrl("Hub Initiative Template", identifier); + expect(result).toBe(`/initiatives/templates/${identifier}/about`); + }); + it("should handle solution templates", () => { + let result = getHubRelativeUrl("Web Mapping Application", identifier, [ + "hubSolutionTemplate", + ]); + expect(result).toBe(`/templates/${identifier}/about`); + result = getHubRelativeUrl("Web Mapping Application", identifier); + expect(result).toBe(`/apps/${identifier}`); + result = getHubRelativeUrl("Solution", identifier); + expect(result).toBe(`/templates/${identifier}/about`); + result = getHubRelativeUrl("Solution", identifier, ["Deployed"]); + expect(result).toBe(`/content/${identifier}/about`); + }); + it("should handle feedback", () => { + const result = getHubRelativeUrl("Form", identifier); + expect(result).toBe(`/feedback/surveys/${identifier}`); + }); + it("should handle discussion", () => { + const result = getHubRelativeUrl("Discussion", identifier); + expect(result).toBe(`/discussions/${identifier}`); + }); + }); + describe("handle when there is no identifier", () => { + it("should handle a family that does not have a puralized route", () => { + // 'report template' should be in the 'content' family + let result = getHubRelativeUrl("report template"); + expect(result).toBe(""); + result = getHubRelativeUrl("StoryMap"); + expect(result).toBe(""); + }); + it("should handle initiatives", () => { + const result = getHubRelativeUrl("Hub Initiative"); + expect(result).toBe(`/initiatives`); + }); + it("should handle projects", () => { + const result = getHubRelativeUrl("Hub Project"); + expect(result).toBe(`/projects`); + }); + it("should handle feedback", () => { + const result = getHubRelativeUrl("Form"); + expect(result).toBe(""); + }); + it("should handle discussion", () => { + const result = getHubRelativeUrl("Discussion"); + expect(result).toBe(""); + }); + }); +}); diff --git a/packages/common/test/events/_internal/PropertyMapper.test.ts b/packages/common/test/events/_internal/PropertyMapper.test.ts index 7c6e5825b8e..23323d2a57f 100644 --- a/packages/common/test/events/_internal/PropertyMapper.test.ts +++ b/packages/common/test/events/_internal/PropertyMapper.test.ts @@ -150,6 +150,7 @@ describe("PropertyMapper", () => { links: { self: "/events/event-title-31c", siteRelative: "/events/event-title-31c", + siteRelativeEntityType: "", workspaceRelative: "/workspace/events/31c", }, slug: "event-title-31c", diff --git a/packages/common/test/events/_internal/computeLinks.test.ts b/packages/common/test/events/_internal/computeLinks.test.ts index db6a0b9ea7f..2e2ae2ceed1 100644 --- a/packages/common/test/events/_internal/computeLinks.test.ts +++ b/packages/common/test/events/_internal/computeLinks.test.ts @@ -11,6 +11,7 @@ describe("computeLinks", () => { expect(results).toEqual({ self: "/events/my-events-are-awesome-123-31c", siteRelative: "/events/my-events-are-awesome-123-31c", + siteRelativeEntityType: "", workspaceRelative: "/workspace/events/31c", }); }); diff --git a/packages/common/test/groups/_internal/computeLinks.test.ts b/packages/common/test/groups/_internal/computeLinks.test.ts index f757189ad9e..501e8ca6ec7 100644 --- a/packages/common/test/groups/_internal/computeLinks.test.ts +++ b/packages/common/test/groups/_internal/computeLinks.test.ts @@ -31,6 +31,7 @@ describe("computeLinks", () => { const chk = computeLinks(group, authdCtxMgr.context.requestOptions); expect(chk.siteRelative).toBe("/groups/00c"); + expect(chk.siteRelativeEntityType).toBe(""); expect(chk.workspaceRelative).toBe("/workspace/groups/00c"); }); }); diff --git a/packages/common/test/initiative-templates/_internal/computeLinks.test.ts b/packages/common/test/initiative-templates/_internal/computeLinks.test.ts index 19c3e8ff34d..edbe9b1d199 100644 --- a/packages/common/test/initiative-templates/_internal/computeLinks.test.ts +++ b/packages/common/test/initiative-templates/_internal/computeLinks.test.ts @@ -33,6 +33,7 @@ describe("computeLinks", () => { const chk = computeLinks(item, authdCtxMgr.context.requestOptions); expect(chk.siteRelative).toBe("/initiatives/templates/mock-slug/about"); + expect(chk.siteRelativeEntityType).toBe(""); expect(chk.workspaceRelative).toBe( "/workspace/initiativeTemplates/mock-slug" ); diff --git a/packages/common/test/initiatives/_internal/computeLinks.test.ts b/packages/common/test/initiatives/_internal/computeLinks.test.ts index 55ebc16d35c..4f40f2259e8 100644 --- a/packages/common/test/initiatives/_internal/computeLinks.test.ts +++ b/packages/common/test/initiatives/_internal/computeLinks.test.ts @@ -33,12 +33,14 @@ describe("computeLinks", () => { const chk = computeLinks(item, authdCtxMgr.context.requestOptions); expect(chk.siteRelative).toBe("/initiatives/mock-slug"); + expect(chk.siteRelativeEntityType).toBe("/initiatives"); expect(chk.workspaceRelative).toBe("/workspace/initiatives/mock-slug"); }); it("generates a links hash using the initiative's id when no slug is available", () => { const chk = computeLinks(item, authdCtxMgr.context.requestOptions); expect(chk.siteRelative).toBe("/initiatives/00c"); + expect(chk.siteRelativeEntityType).toBe("/initiatives"); expect(chk.workspaceRelative).toBe("/workspace/initiatives/00c"); }); }); diff --git a/packages/common/test/projects/_internal/computeLinks.test.ts b/packages/common/test/projects/_internal/computeLinks.test.ts index fb5bfe6c3ec..8850031ede0 100644 --- a/packages/common/test/projects/_internal/computeLinks.test.ts +++ b/packages/common/test/projects/_internal/computeLinks.test.ts @@ -39,6 +39,7 @@ describe("computeLinks", () => { const chk = computeLinks(item, authdCtxMgr.context.requestOptions); expect(chk.siteRelative).toBe("/projects/00c"); + expect(chk.siteRelativeEntityType).toBe("/projects"); expect(chk.workspaceRelative).toBe("/workspace/projects/00c"); }); }); diff --git a/packages/common/test/search/_internal/hubEventsHelpers/eventToSearchResult.test.ts b/packages/common/test/search/_internal/hubEventsHelpers/eventToSearchResult.test.ts index 2e1da8317a3..6a035cc3746 100644 --- a/packages/common/test/search/_internal/hubEventsHelpers/eventToSearchResult.test.ts +++ b/packages/common/test/search/_internal/hubEventsHelpers/eventToSearchResult.test.ts @@ -59,6 +59,7 @@ describe("eventToSearchResult", () => { links: { self: `/events/my-event-title-${event.id}`, siteRelative: `/events/my-event-title-${event.id}`, + siteRelativeEntityType: "", workspaceRelative: `/workspace/events/${event.id}`, }, tags: event.tags, @@ -93,6 +94,7 @@ describe("eventToSearchResult", () => { links: { self: `/events/my-event-title-${event.id}`, siteRelative: `/events/my-event-title-${event.id}`, + siteRelativeEntityType: "", workspaceRelative: `/workspace/events/${event.id}`, }, tags: event.tags, diff --git a/packages/common/test/sites/_internal/computeLinks.test.ts b/packages/common/test/sites/_internal/computeLinks.test.ts index 20238067d2a..56f96cc4e2e 100644 --- a/packages/common/test/sites/_internal/computeLinks.test.ts +++ b/packages/common/test/sites/_internal/computeLinks.test.ts @@ -34,6 +34,7 @@ describe("computeLinks", () => { expect(chk.self).toBe("https://some-url.com"); expect(chk.siteRelative).toBe("/content/00c"); + expect(chk.siteRelativeEntityType).toBe(""); expect(chk.workspaceRelative).toBe("/workspace/sites/00c"); expect(chk.layoutRelative).toBe("/edit"); }); From cb69510af09542283c1d08533e588ee32fee584c Mon Sep 17 00:00:00 2001 From: Vivian Zhang Date: Wed, 22 May 2024 15:43:30 -0700 Subject: [PATCH 7/8] chore: clean up affects: @esri/hub-common --- packages/common/src/groups/_internal/computeLinks.ts | 2 +- packages/common/src/pages/_internal/computeProps.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/common/src/groups/_internal/computeLinks.ts b/packages/common/src/groups/_internal/computeLinks.ts index ac4e7e2e84a..80176b302d7 100644 --- a/packages/common/src/groups/_internal/computeLinks.ts +++ b/packages/common/src/groups/_internal/computeLinks.ts @@ -27,7 +27,7 @@ export function computeLinks( return { self: getGroupHomeUrl(group.id, requestOptions), siteRelative: `/groups/${group.id}`, - siteRelativeEntityType: getHubRelativeUrl(group.type), + siteRelativeEntityType: getHubRelativeUrl("Group"), workspaceRelative: getRelativeWorkspaceUrl("Group", group.id), thumbnail: getGroupThumbnailUrl(requestOptions.portal, group, token), }; diff --git a/packages/common/src/pages/_internal/computeProps.ts b/packages/common/src/pages/_internal/computeProps.ts index 51538afaf33..8ee15bfedae 100644 --- a/packages/common/src/pages/_internal/computeProps.ts +++ b/packages/common/src/pages/_internal/computeProps.ts @@ -38,7 +38,7 @@ export function computeProps( page.links = { self: getItemHomeUrl(page.id, requestOptions), siteRelative: `/pages/${page.id}`, - siteRelativeEntityType: getHubRelativeUrl(page.type), + siteRelativeEntityType: getHubRelativeUrl("page"), workspaceRelative: getRelativeWorkspaceUrl("page", page.id), layoutRelative: `/pages/${page.id}/edit`, thumbnail: thumbnailUrl, From 7112b4605dc53ecb6871c84efd2a8c907850dcfa Mon Sep 17 00:00:00 2001 From: Vivian Zhang Date: Wed, 22 May 2024 16:50:27 -0700 Subject: [PATCH 8/8] chore: revert change in getFamily affects: @esri/hub-common --- packages/common/src/content/get-family.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/common/src/content/get-family.ts b/packages/common/src/content/get-family.ts index 8bcdb415cad..1b9f6e63c6e 100644 --- a/packages/common/src/content/get-family.ts +++ b/packages/common/src/content/get-family.ts @@ -19,7 +19,7 @@ export function getFamily(type: string) { let family; // override default behavior for the rows that are highlighted in yellow here: // https://esriis.sharepoint.com/:x:/r/sites/ArcGISHub/_layouts/15/Doc.aspx?sourcedoc=%7BADA1C9DC-4F6C-4DE4-92C6-693EF9571CFA%7D&file=Hub%20Routes.xlsx&nav=MTBfe0VENEREQzI4LUZFMDctNEI0Ri04NjcyLThCQUE2MTA0MEZGRn1fezIwMTIwMEJFLTA4MEQtNEExRC05QzA4LTE5MTAzOUQwMEE1RH0&action=default&mobileredirect=true&cid=df1c874b-c367-4cea-bc13-7bebfad3f2ac - switch (type?.toLowerCase()) { + switch (type.toLowerCase()) { // NOTE: we really want to put tiled image services in the maps family // but we would need the typekeywords to differentiate them // for now send them to the maps route here: