-
Notifications
You must be signed in to change notification settings - Fork 1
feat(greenhouse): new Clusters dashboard #1634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
guoda-puidokaite
wants to merge
10
commits into
main
Choose a base branch
from
guoda-clusters
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
10099b3
clusters dashboard
guoda-puidokaite 3d64aa4
typo
guoda-puidokaite 961f48e
new requirements and design fixes
guoda-puidokaite 308a936
new requirements and design fixes
guoda-puidokaite aabae55
fix types
guoda-puidokaite 1d8765a
fix types
guoda-puidokaite 56f85f7
fix types
guoda-puidokaite 2661786
fix tests and improvements
guoda-puidokaite ccceb1d
fix tests and improvements
guoda-puidokaite c00a8fa
test fix
guoda-puidokaite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
apps/greenhouse/src/components/admin/ClusterDetail/Overview/Conditions.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and Juno contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import React from "react" | ||
| import { render, screen } from "@testing-library/react" | ||
| import { Conditions } from "./Conditions" | ||
| import { Cluster } from "../../types/k8sTypes" | ||
|
|
||
| describe("Conditions", () => { | ||
| it("should render conditions heading and readiness badges", () => { | ||
| const mockCluster: Cluster = { | ||
| apiVersion: "v1", | ||
| kind: "Cluster", | ||
| metadata: { name: "test-cluster", creationTimestamp: "" }, | ||
| spec: { | ||
| accessMode: "direct", | ||
| kubeConfig: { | ||
| maxTokenValidity: 72, | ||
| }, | ||
| }, | ||
| status: { | ||
| statusConditions: { | ||
| conditions: [ | ||
| { | ||
| type: "Ready", | ||
| status: "True", | ||
| lastTransitionTime: "2026-01-01T00:00:00Z", | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| render(<Conditions clusters={mockCluster} />) | ||
|
|
||
| expect(screen.getByText("Conditions")).toBeInTheDocument() | ||
| expect(screen.getByText("Ready")).toBeInTheDocument() | ||
| }) | ||
| }) |
21 changes: 21 additions & 0 deletions
21
apps/greenhouse/src/components/admin/ClusterDetail/Overview/Conditions.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and Juno contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import React from "react" | ||
| import { Stack, ContentHeading } from "@cloudoperators/juno-ui-components" | ||
|
|
||
| import { Cluster } from "../../types/k8sTypes" | ||
| import ReadinessConditions from "../../common/ReadinessConditions" | ||
|
|
||
| type ConditionsProps = { | ||
| clusters: Cluster | ||
| } | ||
|
|
||
| export const Conditions: React.FC<ConditionsProps> = ({ clusters }) => ( | ||
| <Stack direction="vertical" gap="4"> | ||
| <ContentHeading>Conditions</ContentHeading> | ||
| <ReadinessConditions conditions={clusters.status?.statusConditions?.conditions || []} enableDetailsView /> | ||
| </Stack> | ||
| ) |
56 changes: 56 additions & 0 deletions
56
apps/greenhouse/src/components/admin/ClusterDetail/Overview/Details.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and Juno contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import React from "react" | ||
| import { render, screen } from "@testing-library/react" | ||
| import { Details } from "./Details" | ||
| import { Cluster } from "../../types/k8sTypes" | ||
|
|
||
| describe("Details", () => { | ||
| it("should render cluster details", () => { | ||
| const mockCluster: Cluster = { | ||
| apiVersion: "greenhouse.sap/v1alpha1", | ||
| kind: "Cluster", | ||
| metadata: { | ||
| name: "test-cluster", | ||
| creationTimestamp: "2026-01-01T00:00:00Z", | ||
| labels: { | ||
| "greenhouse.sap/owned-by": "test-team", | ||
| }, | ||
| annotations: { | ||
| "greenhouse.sap/cluster-connectivity": "test-oidc", | ||
| }, | ||
| }, | ||
| spec: { | ||
| accessMode: "direct", | ||
| kubeConfig: { | ||
| maxTokenValidity: 72, | ||
| }, | ||
| }, | ||
| status: { | ||
| kubernetesVersion: "v1.20.0", | ||
| nodes: { | ||
| ready: 1, | ||
| total: 1, | ||
| }, | ||
| statusConditions: { | ||
| conditions: [ | ||
| { | ||
| type: "Ready", | ||
| status: "True", | ||
| lastTransitionTime: "2026-01-01T00:00:00Z", | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| render(<Details clusters={mockCluster} />) | ||
|
|
||
| expect(screen.getByText("Details")).toBeInTheDocument() | ||
| expect(screen.getByText("test-cluster")).toBeInTheDocument() | ||
| expect(screen.getByText("v1.20.0")).toBeInTheDocument() | ||
| }) | ||
| }) |
104 changes: 104 additions & 0 deletions
104
apps/greenhouse/src/components/admin/ClusterDetail/Overview/Details.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and Juno contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import React from "react" | ||
| import { | ||
| DataGrid, | ||
| DataGridRow, | ||
| DataGridHeadCell, | ||
| DataGridCell, | ||
| Pill, | ||
| Stack, | ||
| ContentHeading, | ||
| } from "@cloudoperators/juno-ui-components" | ||
|
|
||
| import { formatAge } from "../../utils" | ||
| import YamlViewer from "../../common/YamlViewer" | ||
| import { Cluster } from "../../types/k8sTypes" | ||
| import { CONNECTIVITY_LABEL, NO_VALUE_DEFAULT, SUPPORT_GROUP_LABEL } from "../../constants" | ||
|
|
||
| interface DetailsProps { | ||
| clusters: Cluster | ||
| } | ||
|
|
||
| interface NodesStatus { | ||
| ready: number | ||
| total: number | ||
| } | ||
|
|
||
| const NodeStatus: React.FC<{ nodes: NodesStatus }> = ({ nodes }) => { | ||
| const { ready, total } = nodes | ||
| const notReady = total - ready | ||
|
|
||
| // If not ready nodes exist, make the text red | ||
| const notReadyColor = notReady > 0 ? "text-theme-danger" : "" | ||
|
|
||
| return ( | ||
| <div className="inline-block"> | ||
| {total} nodes ({ready} ready, <span className={notReadyColor}>{notReady} not ready</span>) | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| export const Details: React.FC<DetailsProps> = ({ clusters }) => ( | ||
| <Stack gap="4" direction="vertical" className="flex-1"> | ||
| <ContentHeading>Details</ContentHeading> | ||
| <DataGrid columns={2} minContentColumns={[0]}> | ||
| <DataGridRow> | ||
| <DataGridHeadCell nowrap>Name</DataGridHeadCell> | ||
| <DataGridCell>{clusters.metadata?.name ?? NO_VALUE_DEFAULT}</DataGridCell> | ||
| </DataGridRow> | ||
| <DataGridRow> | ||
| <DataGridHeadCell nowrap>Age</DataGridHeadCell> | ||
| <DataGridCell>{formatAge(clusters.metadata?.creationTimestamp || 0) ?? NO_VALUE_DEFAULT}</DataGridCell> | ||
| </DataGridRow> | ||
| <DataGridRow> | ||
| <DataGridHeadCell nowrap>Version</DataGridHeadCell> | ||
| <DataGridCell>{clusters.status?.kubernetesVersion ?? NO_VALUE_DEFAULT}</DataGridCell> | ||
| </DataGridRow> | ||
| <DataGridRow> | ||
| <DataGridHeadCell nowrap>Connectivity</DataGridHeadCell> | ||
| <DataGridCell>{clusters.metadata?.annotations?.[CONNECTIVITY_LABEL] ?? NO_VALUE_DEFAULT}</DataGridCell> | ||
| </DataGridRow> | ||
| <DataGridRow> | ||
| <DataGridHeadCell nowrap>Support Group</DataGridHeadCell> | ||
| <DataGridCell>{clusters.metadata?.labels?.[SUPPORT_GROUP_LABEL] ?? NO_VALUE_DEFAULT}</DataGridCell> | ||
| </DataGridRow> | ||
| {clusters.metadata?.labels && Object.keys(clusters.metadata.labels).length > 0 && ( | ||
| <DataGridRow> | ||
| <DataGridHeadCell nowrap>Labels</DataGridHeadCell> | ||
| <DataGridCell> | ||
| <Stack gap="2" wrap={true}> | ||
| {Object.entries(clusters.metadata.labels).map(([key, value], index) => ( | ||
| <Pill key={key} pillKey={key} pillValue={value} /> | ||
| ))} | ||
| </Stack> | ||
| </DataGridCell> | ||
| </DataGridRow> | ||
| )} | ||
| <DataGridRow> | ||
| <DataGridHeadCell nowrap>Annotations</DataGridHeadCell> | ||
| <DataGridCell> | ||
| {clusters.metadata?.annotations && Object.keys(clusters.metadata.annotations).length > 0 ? ( | ||
| <YamlViewer value={clusters.metadata?.annotations} /> | ||
| ) : ( | ||
| "No Annotations" | ||
| )} | ||
| </DataGridCell> | ||
| </DataGridRow> | ||
| <DataGridRow> | ||
| <DataGridHeadCell nowrap>Nodes</DataGridHeadCell> | ||
| <DataGridCell> | ||
| <NodeStatus | ||
| nodes={{ | ||
| ready: clusters?.status?.nodes?.ready ?? 0, | ||
| total: clusters?.status?.nodes?.total ?? 0, | ||
| }} | ||
| /> | ||
| </DataGridCell> | ||
| </DataGridRow> | ||
| </DataGrid> | ||
| </Stack> | ||
| ) | ||
78 changes: 78 additions & 0 deletions
78
apps/greenhouse/src/components/admin/ClusterDetail/Overview/PluginInstances.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and Juno contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import React, { act, Suspense } from "react" | ||
| import { | ||
| createMemoryHistory, | ||
| createRootRoute, | ||
| createRoute, | ||
| createRouter, | ||
| Outlet, | ||
| RouterProvider, | ||
| } from "@tanstack/react-router" | ||
| import { render, screen } from "@testing-library/react" | ||
| import { QueryClient, QueryClientProvider } from "@tanstack/react-query" | ||
| import { PluginInstances } from "./PluginInstances" | ||
| import { mockPlugins, MockPluginsResponse } from "../../__mocks__/plugins" | ||
|
|
||
| const renderComponent = async (mockPromise: Promise<MockPluginsResponse | unknown>) => { | ||
| const rootRoute = createRootRoute({ | ||
| component: () => <Outlet />, | ||
| }) | ||
| const testRoute = createRoute({ | ||
| getParentRoute: () => rootRoute, | ||
| path: "/admin/clusters/$clusterName", | ||
| component: () => ( | ||
| <QueryClientProvider | ||
| client={ | ||
| new QueryClient({ | ||
| defaultOptions: { | ||
|
guoda-puidokaite marked this conversation as resolved.
|
||
| queries: { | ||
| retry: false, | ||
| }, | ||
| }, | ||
| }) | ||
| } | ||
| > | ||
| <Suspense fallback={<div>Loading...</div>}> | ||
| <PluginInstances /> | ||
| </Suspense> | ||
| </QueryClientProvider> | ||
| ), | ||
| }) | ||
| const routeTree = rootRoute.addChildren([testRoute]) | ||
| const router = createRouter({ | ||
| routeTree: routeTree, | ||
| defaultPendingMinMs: 0, | ||
| context: { | ||
| apiClient: { | ||
| get() { | ||
| return mockPromise | ||
| }, | ||
| }, | ||
| user: { | ||
| organization: "test-org", | ||
| supportGroups: [], | ||
| }, | ||
| }, | ||
| history: createMemoryHistory({ | ||
| initialEntries: ["/admin/clusters/test-cluster"], | ||
| }), | ||
| }) | ||
| return await act(async () => render(<RouterProvider router={router} />)) | ||
| } | ||
|
|
||
| describe("PluginInstances", () => { | ||
| it("should render plugin instances table", async () => { | ||
| await renderComponent(new Promise<MockPluginsResponse>((resolve) => resolve(mockPlugins))) | ||
|
|
||
| expect(screen.getByText("Plugin Instances")).toBeInTheDocument() | ||
| expect(screen.getByText("Plugin Name")).toBeInTheDocument() | ||
| expect(screen.getByText("Plugin Preset")).toBeInTheDocument() | ||
| expect(screen.getByText("Status")).toBeInTheDocument() | ||
| expect(screen.getByText("plugin-1")).toBeInTheDocument() | ||
| expect(screen.getByText("plugin-2")).toBeInTheDocument() | ||
| }, 20000) | ||
|
guoda-puidokaite marked this conversation as resolved.
|
||
| }) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.