Skip to content

Commit 12ea19f

Browse files
committed
chore(greenhouse): reroute old admin area to new one
1 parent d98d06a commit 12ea19f

9 files changed

Lines changed: 105 additions & 29 deletions

File tree

.changeset/polite-jars-train.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": minor
3+
---
4+
5+
Replace old admin area with the new one.

apps/greenhouse/src/components/Extension.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ const getApp = (appName: string) => {
2020
return doop
2121
case "heureka":
2222
return heureka
23-
case "org-admin":
24-
return admin
2523
default:
2624
return null
2725
}

apps/greenhouse/src/components/core-apps/org-admin/components/clusters/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,4 @@ const StyledApp = (props: any) => {
4646
}
4747

4848
export default StyledApp
49+
export { App as ClustersAppWithoutShadowDOM }

apps/greenhouse/src/components/core-apps/org-admin/components/clusters/AppContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const AppContent = ({ expires }: any) => {
4040
}
4141

4242
return (
43-
<Container>
43+
<Container px={false}>
4444
<>
4545
<DataGridToolbar>
4646
<ButtonRow>

apps/greenhouse/src/components/nav/PluginNav.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const AppIcon = ({ name }: any) => {
2424
return <DoopIcon />
2525
case "heureka":
2626
return <HeurekaIcon />
27+
case "admin":
2728
default:
2829
return <Icon icon="autoAwesomeMosaic" />
2930
}
@@ -65,7 +66,10 @@ const PluginNav = () => {
6566
const mngConfig = usePlugin().mngConfig()
6667
const navigate = useNavigate({ from: "/" })
6768
const matches = useMatches()
68-
const activeApp = matches.find((match) => match.routeId === "/$extensionId/$")?.params.extensionId
69+
const extensionIdMatch = matches.find((match) => match.routeId === "/$extensionId/$")?.params.extensionId
70+
const isAdminRoute = matches.some((match) => match.routeId.startsWith("/admin"))
71+
// If we're on /admin route, set activeApp to "admin", otherwise use extension ID
72+
const activeApp = isAdminRoute ? "admin" : extensionIdMatch
6973
// @ts-expect-error TS(2339): Property 'data' does not exist on type 'unknown'.
7074
const { data: authData, loggedIn, login, logout } = useAuth()
7175

@@ -106,6 +110,19 @@ const PluginNav = () => {
106110
alignment="center"
107111
className="mt-4 py-4 border-theme-background-lvl-1 border-y-2"
108112
>
113+
{/* Static Organization/Admin navigation item */}
114+
<Stack
115+
direction="vertical"
116+
gap="3"
117+
alignment="center"
118+
className={`greenhouse-nav-item ${navItem(activeApp === "admin")}`}
119+
role="button"
120+
onClick={() => navigateToApp("admin")}
121+
>
122+
<AppIcon name="admin" />
123+
<span className={appNameStyles}>Organization</span>
124+
</Stack>
125+
109126
{mngConfig.map((appConf: any, i: any) => (
110127
<Stack
111128
direction="vertical"

apps/greenhouse/src/lib/plugin.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,7 @@ const Plugin = ({ environment, apiEndpoint, currentHost }: any) => {
9191
const store = createStore<PluginState>()(
9292
devtools(() => ({
9393
active: [],
94-
config: {
95-
[`org-admin`]: createPluginConfig({
96-
id: "org-admin",
97-
core: true,
98-
name: "org-admin",
99-
displayName: "Organization",
100-
navType: NAV_TYPES.MNG,
101-
props: {
102-
assetsUrl: currentHost,
103-
apiEndpoint: apiEndpoint,
104-
environment: environment,
105-
},
106-
}),
107-
},
94+
config: {},
10895
appConfig: [], // kube app configs
10996
mngConfig: [], // management app configs
11097
isFetching: false,

apps/greenhouse/src/routeTree.gen.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
1010

1111
import { Route as rootRouteImport } from './routes/__root'
12+
import { Route as OrgAdminRouteImport } from './routes/org-admin'
1213
import { Route as AdminRouteRouteImport } from './routes/admin/route'
1314
import { Route as IndexRouteImport } from './routes/index'
1415
import { Route as AdminIndexRouteImport } from './routes/admin/index'
@@ -21,6 +22,11 @@ import { Route as AdminPluginPresetsPluginPresetNameIndexRouteImport } from './r
2122
import { Route as AdminPluginPresetsPluginPresetNamePluginInstancesRouteRouteImport } from './routes/admin/plugin-presets/$pluginPresetName/plugin-instances/route'
2223
import { Route as AdminPluginPresetsPluginPresetNamePluginInstancesPluginInstanceRouteImport } from './routes/admin/plugin-presets/$pluginPresetName/plugin-instances/$pluginInstance'
2324

25+
const OrgAdminRoute = OrgAdminRouteImport.update({
26+
id: '/org-admin',
27+
path: '/org-admin',
28+
getParentRoute: () => rootRouteImport,
29+
} as any)
2430
const AdminRouteRoute = AdminRouteRouteImport.update({
2531
id: '/admin',
2632
path: '/admin',
@@ -87,6 +93,7 @@ const AdminPluginPresetsPluginPresetNamePluginInstancesPluginInstanceRoute =
8793
export interface FileRoutesByFullPath {
8894
'/': typeof IndexRoute
8995
'/admin': typeof AdminRouteRouteWithChildren
96+
'/org-admin': typeof OrgAdminRoute
9097
'/admin/plugin-presets': typeof AdminPluginPresetsRouteRouteWithChildren
9198
'/$extensionId/$': typeof ExtensionIdSplatRoute
9299
'/admin/clusters': typeof AdminClustersRoute
@@ -99,6 +106,7 @@ export interface FileRoutesByFullPath {
99106
}
100107
export interface FileRoutesByTo {
101108
'/': typeof IndexRoute
109+
'/org-admin': typeof OrgAdminRoute
102110
'/$extensionId/$': typeof ExtensionIdSplatRoute
103111
'/admin/clusters': typeof AdminClustersRoute
104112
'/admin': typeof AdminIndexRoute
@@ -111,6 +119,7 @@ export interface FileRoutesById {
111119
__root__: typeof rootRouteImport
112120
'/': typeof IndexRoute
113121
'/admin': typeof AdminRouteRouteWithChildren
122+
'/org-admin': typeof OrgAdminRoute
114123
'/admin/plugin-presets': typeof AdminPluginPresetsRouteRouteWithChildren
115124
'/$extensionId/$': typeof ExtensionIdSplatRoute
116125
'/admin/clusters': typeof AdminClustersRoute
@@ -126,6 +135,7 @@ export interface FileRouteTypes {
126135
fullPaths:
127136
| '/'
128137
| '/admin'
138+
| '/org-admin'
129139
| '/admin/plugin-presets'
130140
| '/$extensionId/$'
131141
| '/admin/clusters'
@@ -138,6 +148,7 @@ export interface FileRouteTypes {
138148
fileRoutesByTo: FileRoutesByTo
139149
to:
140150
| '/'
151+
| '/org-admin'
141152
| '/$extensionId/$'
142153
| '/admin/clusters'
143154
| '/admin'
@@ -149,6 +160,7 @@ export interface FileRouteTypes {
149160
| '__root__'
150161
| '/'
151162
| '/admin'
163+
| '/org-admin'
152164
| '/admin/plugin-presets'
153165
| '/$extensionId/$'
154166
| '/admin/clusters'
@@ -163,11 +175,19 @@ export interface FileRouteTypes {
163175
export interface RootRouteChildren {
164176
IndexRoute: typeof IndexRoute
165177
AdminRouteRoute: typeof AdminRouteRouteWithChildren
178+
OrgAdminRoute: typeof OrgAdminRoute
166179
ExtensionIdSplatRoute: typeof ExtensionIdSplatRoute
167180
}
168181

169182
declare module '@tanstack/react-router' {
170183
interface FileRoutesByPath {
184+
'/org-admin': {
185+
id: '/org-admin'
186+
path: '/org-admin'
187+
fullPath: '/org-admin'
188+
preLoaderRoute: typeof OrgAdminRouteImport
189+
parentRoute: typeof rootRouteImport
190+
}
171191
'/admin': {
172192
id: '/admin'
173193
path: '/admin'
@@ -317,6 +337,7 @@ const AdminRouteRouteWithChildren = AdminRouteRoute._addFileChildren(
317337
const rootRouteChildren: RootRouteChildren = {
318338
IndexRoute: IndexRoute,
319339
AdminRouteRoute: AdminRouteRouteWithChildren,
340+
OrgAdminRoute: OrgAdminRoute,
320341
ExtensionIdSplatRoute: ExtensionIdSplatRoute,
321342
}
322343
export const routeTree = rootRouteImport

apps/greenhouse/src/routes/admin/clusters.tsx

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,54 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import React from "react"
7-
import { createFileRoute } from "@tanstack/react-router"
8-
import { Crumb } from "../-types"
6+
import React, { useEffect } from "react"
7+
import { createFileRoute, useRouteContext } from "@tanstack/react-router"
8+
import { Container, ContentHeading, Stack } from "@cloudoperators/juno-ui-components"
9+
import { useAuth } from "../../components/AuthProvider"
10+
import { useGlobalsApiEndpoint } from "../../components/StoreProvider"
11+
import { ClustersAppWithoutShadowDOM } from "../../components/core-apps/org-admin/components/clusters/App"
12+
import { useActions } from "@cloudoperators/juno-messages-provider"
913

1014
export const Route = createFileRoute("/admin/clusters")({
1115
component: RouteComponent,
12-
loader: () => {
13-
const crumb: Crumb = {
16+
loader: () => ({
17+
crumb: {
1418
label: "Clusters",
15-
}
16-
return {
17-
crumb,
18-
}
19-
},
19+
icon: "home",
20+
},
21+
}),
2022
})
2123

2224
function RouteComponent() {
23-
return <div>Hello "/admin/clusters"!</div>
25+
// @ts-expect-error TS(2339): Property 'data' does not exist on type 'unknown'.
26+
const { data: authData } = useAuth()
27+
const { addMessage, removeMessage } = useActions()
28+
const apiEndpoint = useGlobalsApiEndpoint()
29+
const { user } = useRouteContext({ from: "/admin/clusters" })
30+
const token = authData?.JWT
31+
const namespace = user.organization
32+
33+
useEffect(() => {
34+
const messageId = addMessage({
35+
variant: "warning",
36+
text: "This view is from the legacy interface and will be updated with a modern design and improved functionality.",
37+
dismissible: false,
38+
})
39+
return () => {
40+
if (messageId) {
41+
removeMessage(messageId)
42+
}
43+
}
44+
}, [addMessage, removeMessage])
45+
46+
return (
47+
<Stack direction="vertical" gap="4">
48+
<Container px={false} py={false}>
49+
<ContentHeading>Clusters Overview</ContentHeading>
50+
<p>Manage and monitor clusters</p>
51+
</Container>
52+
{/* @ts-expect-error TS(2339): Property 'data' does not exist on type 'unknown'. */}
53+
<ClustersAppWithoutShadowDOM apiEndpoint={apiEndpoint} token={token} namespace={namespace} />
54+
</Stack>
55+
)
2456
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and Juno contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import { createFileRoute, redirect } from "@tanstack/react-router"
7+
8+
export const Route = createFileRoute("/org-admin")({
9+
beforeLoad: () => {
10+
// eslint-disable-next-line @typescript-eslint/only-throw-error
11+
throw redirect({
12+
to: "/admin",
13+
})
14+
},
15+
})

0 commit comments

Comments
 (0)