Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/unreleased/1104-cluster-view-nodes-tab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Cluster View nodes button opens the Nodes tab

On a cluster's Overview tab, **View nodes** now opens that cluster's own Nodes
tab instead of leaving for the separate Nodes page, so both ways to see a
cluster's nodes show the same screen. **View all nodes** on the Nodes tab still
opens the fleet-wide Nodes page. [PR #1104](https://github.com/GameplanePanel/Gameplane/pull/1104)
13 changes: 11 additions & 2 deletions web/src/pages/ClusterDetail.test.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { describe, expect, it, vi, afterEach } from "vitest";
import { http, HttpResponse } from "msw";
import { screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { server } from "@/test/server";
import { renderWithQuery } from "@/test/render";
import { setCurrentCluster } from "@/lib/cluster";
const route = vi.hoisted(() => ({ clusterId: "east", tab: "overview", ns: undefined as string | undefined }));
vi.mock("@tanstack/react-router", () => ({ useParams: () => ({ clusterId: route.clusterId }), useSearch: () => ({ tab: route.tab, ns: route.ns }), useNavigate: () => vi.fn() }));
const navigate = vi.hoisted(() => vi.fn());
vi.mock("@tanstack/react-router", () => ({ useParams: () => ({ clusterId: route.clusterId }), useSearch: () => ({ tab: route.tab, ns: route.ns }), useNavigate: () => navigate }));
vi.mock("@/components/nodes/NodeInventory", () => ({ NodeInventory: ({ clusterId }: { clusterId?: string }) => <div>Inventory for {clusterId}</div> }));
import { ClusterDetailPage } from "./ClusterDetail";

afterEach(() => { route.clusterId = "east"; route.tab = "overview"; route.ns = undefined; setCurrentCluster("local"); });
afterEach(() => { navigate.mockReset(); route.clusterId = "east"; route.tab = "overview"; route.ns = undefined; setCurrentCluster("local"); });
describe("ClusterDetailPage", () => {
it("uses its route registration independently of remembered selection", async () => {
setCurrentCluster("west");
Expand All @@ -20,6 +22,13 @@ describe("ClusterDetailPage", () => {
expect(screen.getByText("Inventory for east")).toBeInTheDocument();
});

it("opens the cluster's own Nodes tab from the overview View nodes button", async () => {
server.use(http.get("/clusters", () => HttpResponse.json({ items: [{ name: "east", displayName: "East", phase: "Healthy", canViewInventory: true }] })));
renderWithQuery(<ClusterDetailPage />);
await userEvent.click(await screen.findByRole("button", { name: "View nodes" }));
expect(navigate).toHaveBeenCalledWith({ to: "/clusters/$clusterId", params: { clusterId: "east" }, search: { tab: "nodes" } });
});

it("opens destination configuration in the namespace from a server link", async () => {
route.tab = "configuration";
route.ns = "games-east";
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/ClusterDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function ClusterOverview({ cluster }: { cluster: ClusterRegistry }) {
return <div className="grid gap-6 lg:grid-cols-2"><ClusterSection title={intl.formatMessage({ id: "web.cluster_detail.identity", defaultMessage: "Cluster identity", description: "Cluster overview identity section" })}>
<dl className="space-y-4 text-sm"><div><dt className="text-muted">{intl.formatMessage({ id: "web.cluster_detail.registration_id", defaultMessage: "Registration ID", description: "Cluster registration identifier label" })}</dt><dd className="break-all pt-1 font-mono">{cluster.name}</dd></div><div><dt className="text-muted">{intl.formatMessage({ id: "web.cluster_detail.kubernetes_version", defaultMessage: "Kubernetes version", description: "Cluster Kubernetes version label" })}</dt><dd className="pt-1 font-mono">{cluster.serverVersion || empty}</dd></div>{cluster.name !== "local" && <div><dt className="text-muted">{intl.formatMessage({ id: "web.clusters.control_plane_namespace_detail_label", defaultMessage: "Control-plane namespace", description: "Cluster overview: label for the namespace where this remote cluster's Gameplane operator runs" })}</dt><dd className="pt-1 font-mono">{cluster.controlPlaneNamespace || DEFAULT_CONTROL_PLANE_NAMESPACE}</dd></div>}</dl>
{cluster.name === "local" && <p className="text-sm text-muted">{intl.formatMessage({ id: "web.routes.clusters.central_cluster", defaultMessage: "Central cluster", description: "Clusters: note on the cluster card of the built-in local cluster that the panel itself runs in" })}</p>}
{cluster.canViewInventory === true && <Button variant="outline" onPress={() => void navigate({ to: "/nodes", search: { cluster: cluster.name } })}>{intl.formatMessage({ id: "web.routes.clusters.view_nodes", defaultMessage: "View nodes", description: "Clusters: button on a cluster card that opens the node inventory for that cluster; shown only when the user can view inventory; keep it short" })}</Button>}
{cluster.canViewInventory === true && <Button variant="outline" onPress={() => void navigate({ to: "/clusters/$clusterId", params: { clusterId: cluster.name }, search: { tab: "nodes" } })}>{intl.formatMessage({ id: "web.routes.clusters.view_nodes", defaultMessage: "View nodes", description: "Clusters: button on a cluster card that opens the node inventory for that cluster; shown only when the user can view inventory; keep it short" })}</Button>}
</ClusterSection><ClusterSection title={intl.formatMessage({ id: "web.cluster_detail.connectivity", defaultMessage: "API connectivity", description: "Cluster overview connectivity section" })} subtitle={intl.formatMessage({ id: "web.cluster_detail.connectivity_description", defaultMessage: "Status reports Kubernetes API connectivity, not game or gateway health.", description: "Cluster health scope explanation" })}>
<p className={cluster.phase === "Healthy" ? "font-medium text-success" : cluster.phase === "Unhealthy" ? "font-medium text-danger" : "font-medium text-muted"}>{phase}</p>
{cluster.message && <p className="break-words text-sm text-muted">{cluster.message}</p>}
Expand Down
Loading