Skip to content

Commit ce2fa02

Browse files
authored
chore(greenhouse): make alerts plugin backward compatible (#1245)
* chore(greenhouse): make alerts plugin backward compatible * chore(ci): fix pr-preview workflow
1 parent efc87dc commit ce2fa02

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

.changeset/tasty-lions-speak.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cloudoperators/juno-app-greenhouse": patch
3+
---
4+
5+
Keep alerts plugin backward compatible after plugin name hamonization happened in the backend.

.github/workflows/deploy-pr-preview.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
uses: ./.github/workflows/shared-detect-pkg-changes.yaml
4848
with:
4949
paths: "packages apps"
50-
runs-on: [ ubuntu-latest ]
50+
runs-on: ubuntu-latest
5151

5252
build-deploy:
5353
# skip if the PR is from a forked repository

apps/greenhouse/src/routes/index.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ const searchSchema = z.object({
1616
activeApps: z.string().optional(),
1717
})
1818

19+
/**
20+
* Backend has harmonized name of alerts plugin across all organizations
21+
* which is now "alerts" instead of "alerts-<orgId>" which affects backward
22+
* compatibility in case people had bookmarked links with the old name.
23+
* In order to stay backward compatible we need to map "alerts-<orgId>" to "alerts".
24+
* This method will be removed once we stop supporting legacy URLs.
25+
**/
26+
const getBackwardCompatibleApp = (appId: string) => {
27+
if (!appId) return ""
28+
return /^alerts-.+/.test(appId) ? "alerts" : appId
29+
}
30+
1931
export const Route = createFileRoute("/")({
2032
validateSearch: searchSchema,
2133
beforeLoad: () => {
@@ -24,7 +36,7 @@ export const Route = createFileRoute("/")({
2436
const activeApps = legacyState?.[ACTIVE_APPS_KEY]
2537
const parsedActiveApps = activeApps?.split(",") || []
2638
return {
27-
activeApp: parsedActiveApps.length > 0 ? parsedActiveApps[0] : "",
39+
activeApp: parsedActiveApps.length > 0 ? getBackwardCompatibleApp(parsedActiveApps[0]) : "",
2840
}
2941
},
3042
component: RouteComponent,

0 commit comments

Comments
 (0)