Skip to content

Commit

Permalink
feat: [CCM-19101]: Handle All URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
rajarshee-harness committed Sep 9, 2024
1 parent 26dc03b commit 1c371e8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@harnessio/backstage-plugin-harness-srm": "^0.2.0",
"@harnessio/backstage-plugin-harness-chaos": "^0.1.0",
"@harnessio/backstage-plugin-harness-iacm": "0.1.0-beta",
"@harnessio/backstage-plugin-harness-ccm": "^0.1.0",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
"history": "^5.0.0",
Expand Down
33 changes: 27 additions & 6 deletions plugins/harness-ccm/src/hooks/useResourceSlugFromEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,33 @@ export const useResourceSlugFromEntity = (perspectiveUrl?: string) => {
let projectId;
let perspectiveId;

const urlMatch = match(
'(.*)/account/:accountId/module/:module/perspectives/:perspectiveId/(.*)',
{
decode: decodeURIComponent,
},
);
let urlMatch;

const containsModule = perspectiveUrl.includes('/module/');
const containsAll = perspectiveUrl.includes('/all/');

if (containsModule) {
urlMatch = match(
'(.*)/account/:accountId/module/:module/perspectives/:perspectiveId/(.*)',
{
decode: decodeURIComponent,
},
);
} else if (containsAll) {
urlMatch = match(
'(.*)/account/:accountId/all/:module/perspectives/:perspectiveId/(.*)',
{
decode: decodeURIComponent,
},
);
} else {
urlMatch = match(
'(.*)/account/:accountId/:module/perspectives/:perspectiveId/(.*)',
{
decode: decodeURIComponent,
},
);
}

if (cleanedString) {
const hostname = new URL(cleanedString).hostname;
Expand Down

0 comments on commit 1c371e8

Please sign in to comment.