From f2c667933c1a9faf4ddf8e4087267f6f6aa22814 Mon Sep 17 00:00:00 2001 From: Mike Juniper Date: Thu, 28 Sep 2023 10:01:48 -0600 Subject: [PATCH] fix(hub-common): workspace route for content is /workspace/content/:id not /workspace/contents/:id (#1250) affects: @esri/hub-common --- package-lock.json | 48 ++++++++++++------- .../src/core/getRelativeWorkspaceUrl.ts | 6 ++- .../test/core/getRelativeWorkspaceUrl.test.ts | 16 +++++++ 3 files changed, 51 insertions(+), 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5da8753852f..af93d620f8c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22659,9 +22659,10 @@ }, "node_modules/cz-lerna-changelog/node_modules/npm/node_modules/lodash._baseindexof": { "version": "3.1.0", - "extraneous": true, + "dev": true, "inBundle": true, - "license": "MIT" + "license": "MIT", + "peer": true }, "node_modules/cz-lerna-changelog/node_modules/npm/node_modules/lodash._baseuniq": { "version": "4.6.0", @@ -22676,21 +22677,24 @@ }, "node_modules/cz-lerna-changelog/node_modules/npm/node_modules/lodash._bindcallback": { "version": "3.0.1", - "extraneous": true, + "dev": true, "inBundle": true, - "license": "MIT" + "license": "MIT", + "peer": true }, "node_modules/cz-lerna-changelog/node_modules/npm/node_modules/lodash._cacheindexof": { "version": "3.0.2", - "extraneous": true, + "dev": true, "inBundle": true, - "license": "MIT" + "license": "MIT", + "peer": true }, "node_modules/cz-lerna-changelog/node_modules/npm/node_modules/lodash._createcache": { "version": "3.1.2", - "extraneous": true, + "dev": true, "inBundle": true, "license": "MIT", + "peer": true, "dependencies": { "lodash._getnative": "^3.0.0" } @@ -22704,9 +22708,10 @@ }, "node_modules/cz-lerna-changelog/node_modules/npm/node_modules/lodash._getnative": { "version": "3.9.1", - "extraneous": true, + "dev": true, "inBundle": true, - "license": "MIT" + "license": "MIT", + "peer": true }, "node_modules/cz-lerna-changelog/node_modules/npm/node_modules/lodash._root": { "version": "3.0.1", @@ -22724,9 +22729,10 @@ }, "node_modules/cz-lerna-changelog/node_modules/npm/node_modules/lodash.restparam": { "version": "3.6.1", - "extraneous": true, + "dev": true, "inBundle": true, - "license": "MIT" + "license": "MIT", + "peer": true }, "node_modules/cz-lerna-changelog/node_modules/npm/node_modules/lodash.union": { "version": "4.6.0", @@ -64981,7 +64987,7 @@ }, "packages/common": { "name": "@esri/hub-common", - "version": "14.21.1", + "version": "14.22.0", "license": "Apache-2.0", "dependencies": { "abab": "^2.0.5", @@ -83401,7 +83407,8 @@ "lodash._baseindexof": { "version": "3.1.0", "bundled": true, - "extraneous": true + "dev": true, + "peer": true }, "lodash._baseuniq": { "version": "4.6.0", @@ -83416,17 +83423,20 @@ "lodash._bindcallback": { "version": "3.0.1", "bundled": true, - "extraneous": true + "dev": true, + "peer": true }, "lodash._cacheindexof": { "version": "3.0.2", "bundled": true, - "extraneous": true + "dev": true, + "peer": true }, "lodash._createcache": { "version": "3.1.2", "bundled": true, - "extraneous": true, + "dev": true, + "peer": true, "requires": { "lodash._getnative": "^3.0.0" } @@ -83440,7 +83450,8 @@ "lodash._getnative": { "version": "3.9.1", "bundled": true, - "extraneous": true + "dev": true, + "peer": true }, "lodash._root": { "version": "3.0.1", @@ -83457,7 +83468,8 @@ "lodash.restparam": { "version": "3.6.1", "bundled": true, - "extraneous": true + "dev": true, + "peer": true }, "lodash.union": { "version": "4.6.0", diff --git a/packages/common/src/core/getRelativeWorkspaceUrl.ts b/packages/common/src/core/getRelativeWorkspaceUrl.ts index 47abf98fa41..c9bec2df182 100644 --- a/packages/common/src/core/getRelativeWorkspaceUrl.ts +++ b/packages/common/src/core/getRelativeWorkspaceUrl.ts @@ -22,7 +22,11 @@ export const getRelativeWorkspaceUrl = ( * 2. handle entity variation */ if (isValidEntityType(entityType)) { - url = `/workspace/${entityType}s/${identifier}`; + let typeSegment = entityType as string; + if (typeSegment !== "content") { + typeSegment = `${typeSegment}s`; + } + url = `/workspace/${typeSegment}/${identifier}`; } return url; diff --git a/packages/common/test/core/getRelativeWorkspaceUrl.test.ts b/packages/common/test/core/getRelativeWorkspaceUrl.test.ts index 80ac0f8ace7..5c16ae3c583 100644 --- a/packages/common/test/core/getRelativeWorkspaceUrl.test.ts +++ b/packages/common/test/core/getRelativeWorkspaceUrl.test.ts @@ -21,6 +21,22 @@ describe("getRelativeWorkspaceUrl", () => { expect(isValidEntityTypeSpy).toHaveBeenCalledTimes(1); expect(result).toBe("/workspace/projects/123"); }); + it("returns the relative workspace url if provided entity type content", () => { + const getTypeFromEntitySpy = spyOn( + getTypeFromEntityModule, + "getTypeFromEntity" + ).and.returnValue("content"); + const isValidEntityTypeSpy = spyOn( + isValidEntityTypeModule, + "isValidEntityType" + ).and.returnValue(true); + + result = getRelativeWorkspaceUrl("Web Mapping Application", "123"); + + expect(getTypeFromEntitySpy).toHaveBeenCalledTimes(1); + expect(isValidEntityTypeSpy).toHaveBeenCalledTimes(1); + expect(result).toBe("/workspace/content/123"); + }); it('returns "/" if provided an invalid entity type', () => { const getTypeFromEntitySpy = spyOn( getTypeFromEntityModule,