From 9664dcd58cb525de34699b9d7c8c69198d388985 Mon Sep 17 00:00:00 2001 From: Vivian Zhang Date: Fri, 24 May 2024 14:18:58 -0700 Subject: [PATCH] Revert "fix: add siteRelativeEntityType link to multiple entities (#1522)" This reverts commit 6557279ab9dfe23dc8a781cda41a48dbc880c5aa. --- .../src/content/_internal/computeProps.ts | 1 - .../content/_internal/internalContentUtils.ts | 29 ++------ .../common/src/core/types/IHubEntityBase.ts | 3 - .../src/events/_internal/computeLinks.ts | 1 - .../src/groups/_internal/computeLinks.ts | 2 - .../_internal/computeLinks.ts | 1 - .../src/initiatives/_internal/computeLinks.ts | 1 - .../src/pages/_internal/computeProps.ts | 2 - .../src/projects/_internal/computeLinks.ts | 1 - .../src/sites/_internal/computeLinks.ts | 1 - .../src/templates/_internal/computeLinks.ts | 1 - .../_internal/internalContentUtils.test.ts | 73 ------------------- .../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 - 20 files changed, 7 insertions(+), 119 deletions(-) diff --git a/packages/common/src/content/_internal/computeProps.ts b/packages/common/src/content/_internal/computeProps.ts index 7d373971680..b777c573299 100644 --- a/packages/common/src/content/_internal/computeProps.ts +++ b/packages/common/src/content/_internal/computeProps.ts @@ -45,7 +45,6 @@ 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/_internal/internalContentUtils.ts b/packages/common/src/content/_internal/internalContentUtils.ts index 88188acebf4..d19e75b77b6 100644 --- a/packages/common/src/content/_internal/internalContentUtils.ts +++ b/packages/common/src/content/_internal/internalContentUtils.ts @@ -16,12 +16,7 @@ import { ISpatialReference, IUser, } from "@esri/arcgis-rest-types"; -import { - IHubContent, - IHubLocation, - PublisherSource, - getTypeFromEntity, -} from "../../core"; +import { IHubContent, IHubLocation, PublisherSource } from "../../core"; import { IHubGeography, GeographyProvenance, @@ -231,25 +226,22 @@ export const isProxiedCSV = ( /** * Get the relative URL to use for the item in a hub site * @param type - * @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 identifier * @param typeKeywords * @returns * @private */ export const getHubRelativeUrl = ( type: string, - identifier?: string, + identifier: string, typeKeywords?: string[] ): string => { // solution types have their own logic let contentUrl = getSolutionUrl(type, identifier, typeKeywords) || getInitiativeTemplateUrl(type, identifier, typeKeywords); - const family = getFamily(type); if (!contentUrl) { + const family = getFamily(type); const familiesWithPluralizedRoute = [ "app", "dataset", @@ -263,9 +255,9 @@ export const getHubRelativeUrl = ( ]; // default to the catchall content route let path = "/content"; - // the exception if (family === "feedback") { - path = identifier ? "/feedback/surveys" : ""; + // the exception + path = "/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 +267,7 @@ export const getHubRelativeUrl = ( // the rule: route name is plural of family name path = `/${family}s`; } - contentUrl = identifier ? `${path}/${identifier}` : `${path}`; - } - // 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 = ""; + contentUrl = `${path}/${identifier}`; } return contentUrl; }; diff --git a/packages/common/src/core/types/IHubEntityBase.ts b/packages/common/src/core/types/IHubEntityBase.ts index 8c836a0e648..ff2933ee69c 100644 --- a/packages/common/src/core/types/IHubEntityBase.ts +++ b/packages/common/src/core/types/IHubEntityBase.ts @@ -31,9 +31,6 @@ 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/events/_internal/computeLinks.ts b/packages/common/src/events/_internal/computeLinks.ts index a84ac9c599f..685d41204be 100644 --- a/packages/common/src/events/_internal/computeLinks.ts +++ b/packages/common/src/events/_internal/computeLinks.ts @@ -16,7 +16,6 @@ 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 80176b302d7..bf45b4ffa50 100644 --- a/packages/common/src/groups/_internal/computeLinks.ts +++ b/packages/common/src/groups/_internal/computeLinks.ts @@ -5,7 +5,6 @@ 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 @@ -27,7 +26,6 @@ export function computeLinks( return { self: getGroupHomeUrl(group.id, requestOptions), siteRelative: `/groups/${group.id}`, - siteRelativeEntityType: getHubRelativeUrl("Group"), 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 27ab6f85475..7a26c4c2497 100644 --- a/packages/common/src/initiative-templates/_internal/computeLinks.ts +++ b/packages/common/src/initiative-templates/_internal/computeLinks.ts @@ -28,7 +28,6 @@ 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 e69abb6ca1e..6949350d0c2 100644 --- a/packages/common/src/initiatives/_internal/computeLinks.ts +++ b/packages/common/src/initiatives/_internal/computeLinks.ts @@ -28,7 +28,6 @@ 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 8ee15bfedae..0f52346b106 100644 --- a/packages/common/src/pages/_internal/computeProps.ts +++ b/packages/common/src/pages/_internal/computeProps.ts @@ -9,7 +9,6 @@ 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 @@ -38,7 +37,6 @@ export function computeProps( page.links = { self: getItemHomeUrl(page.id, requestOptions), siteRelative: `/pages/${page.id}`, - siteRelativeEntityType: getHubRelativeUrl("page"), workspaceRelative: getRelativeWorkspaceUrl("page", page.id), layoutRelative: `/pages/${page.id}/edit`, thumbnail: thumbnailUrl, diff --git a/packages/common/src/projects/_internal/computeLinks.ts b/packages/common/src/projects/_internal/computeLinks.ts index 9c88350d549..8f910ca5511 100644 --- a/packages/common/src/projects/_internal/computeLinks.ts +++ b/packages/common/src/projects/_internal/computeLinks.ts @@ -28,7 +28,6 @@ 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/sites/_internal/computeLinks.ts b/packages/common/src/sites/_internal/computeLinks.ts index 8a9c7f6d6d9..7a3ec7f8226 100644 --- a/packages/common/src/sites/_internal/computeLinks.ts +++ b/packages/common/src/sites/_internal/computeLinks.ts @@ -27,7 +27,6 @@ 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 fb3c8a05e26..84a8228b68d 100644 --- a/packages/common/src/templates/_internal/computeLinks.ts +++ b/packages/common/src/templates/_internal/computeLinks.ts @@ -37,7 +37,6 @@ export function computeLinks( return { self: itemHomeUrl, siteRelative: siteRelativeUrl, - siteRelativeEntityType: getHubRelativeUrl(item.type), workspaceRelative: isDeployed ? itemHomeUrl : getRelativeWorkspaceUrl(item.type, getItemIdentifier(item)), diff --git a/packages/common/test/content/_internal/internalContentUtils.test.ts b/packages/common/test/content/_internal/internalContentUtils.test.ts index 94bf7320979..dc2355d2391 100644 --- a/packages/common/test/content/_internal/internalContentUtils.test.ts +++ b/packages/common/test/content/_internal/internalContentUtils.test.ts @@ -3,7 +3,6 @@ import { getContentEditUrl, getExtentObject, deriveLocationFromItem, - getHubRelativeUrl, } from "../../../src/content/_internal/internalContentUtils"; import * as internalContentUtils from "../../../src/content/_internal/internalContentUtils"; import * as Compose from "../../../src/content/compose"; @@ -488,75 +487,3 @@ 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 23323d2a57f..7c6e5825b8e 100644 --- a/packages/common/test/events/_internal/PropertyMapper.test.ts +++ b/packages/common/test/events/_internal/PropertyMapper.test.ts @@ -150,7 +150,6 @@ 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 2e2ae2ceed1..db6a0b9ea7f 100644 --- a/packages/common/test/events/_internal/computeLinks.test.ts +++ b/packages/common/test/events/_internal/computeLinks.test.ts @@ -11,7 +11,6 @@ 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 501e8ca6ec7..f757189ad9e 100644 --- a/packages/common/test/groups/_internal/computeLinks.test.ts +++ b/packages/common/test/groups/_internal/computeLinks.test.ts @@ -31,7 +31,6 @@ 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 edbe9b1d199..19c3e8ff34d 100644 --- a/packages/common/test/initiative-templates/_internal/computeLinks.test.ts +++ b/packages/common/test/initiative-templates/_internal/computeLinks.test.ts @@ -33,7 +33,6 @@ 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 4f40f2259e8..55ebc16d35c 100644 --- a/packages/common/test/initiatives/_internal/computeLinks.test.ts +++ b/packages/common/test/initiatives/_internal/computeLinks.test.ts @@ -33,14 +33,12 @@ 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 8850031ede0..fb5bfe6c3ec 100644 --- a/packages/common/test/projects/_internal/computeLinks.test.ts +++ b/packages/common/test/projects/_internal/computeLinks.test.ts @@ -39,7 +39,6 @@ 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 6a035cc3746..2e1da8317a3 100644 --- a/packages/common/test/search/_internal/hubEventsHelpers/eventToSearchResult.test.ts +++ b/packages/common/test/search/_internal/hubEventsHelpers/eventToSearchResult.test.ts @@ -59,7 +59,6 @@ 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, @@ -94,7 +93,6 @@ 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 56f96cc4e2e..20238067d2a 100644 --- a/packages/common/test/sites/_internal/computeLinks.test.ts +++ b/packages/common/test/sites/_internal/computeLinks.test.ts @@ -34,7 +34,6 @@ 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"); });