Skip to content

Commit

Permalink
fix(hub-common): workspace route for content is /workspace/content/:i…
Browse files Browse the repository at this point in the history
…d not /workspace/contents/:id (#1250)

affects: @esri/hub-common
  • Loading branch information
mjuniper authored Sep 28, 2023
1 parent 8e45b7f commit f2c6679
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 19 deletions.
48 changes: 30 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion packages/common/src/core/getRelativeWorkspaceUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 16 additions & 0 deletions packages/common/test/core/getRelativeWorkspaceUrl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f2c6679

Please sign in to comment.