diff --git a/src/renderer/components/layout/__test__/main-layout-header.test.tsx b/src/renderer/components/layout/__test__/main-layout-header.test.tsx new file mode 100644 index 0000000000..91fcc5dc7f --- /dev/null +++ b/src/renderer/components/layout/__test__/main-layout-header.test.tsx @@ -0,0 +1,49 @@ +jest.mock("../../../../common/ipc"); + +import React from "react"; +import { fireEvent, render } from "@testing-library/react"; +import "@testing-library/jest-dom/extend-expect"; + +import { MainLayoutHeader } from "../main-layout-header"; +import { Cluster } from "../../../../main/cluster"; +import { workspaceStore } from "../../../../common/workspace-store"; +import { broadcastMessage } from "../../../../common/ipc"; + +const mockBroadcastIpc = broadcastMessage as jest.MockedFunction; + +const cluster: Cluster = new Cluster({ + id: "foo", + contextName: "minikube", + kubeConfigPath: "minikube-config.yml", + workspace: workspaceStore.currentWorkspaceId +}); + +describe("", () => { + it("renders w/o errors", () => { + const { container } = render(); + + expect(container).toBeInstanceOf(HTMLElement); + }); + + it("renders gear icon", () => { + const { container } = render(); + const icon = container.querySelector(".Icon .icon"); + + expect(icon).toBeInstanceOf(HTMLElement); + expect(icon).toHaveTextContent("settings"); + }); + + it("navigates to cluster settings", () => { + const { container } = render(); + const icon = container.querySelector(".Icon"); + + fireEvent.click(icon); + expect(mockBroadcastIpc).toBeCalledWith("renderer:navigate", "/cluster/foo/settings"); + }); + + it("renders cluster name", async () => { + const { getByText } = render(); + + expect(await getByText("minikube")).toBeTruthy(); + }); +}); \ No newline at end of file diff --git a/src/renderer/components/layout/main-layout-header.tsx b/src/renderer/components/layout/main-layout-header.tsx new file mode 100644 index 0000000000..d48d52634f --- /dev/null +++ b/src/renderer/components/layout/main-layout-header.tsx @@ -0,0 +1,33 @@ +import React from "react"; +import { Trans } from "@lingui/macro"; + +import { clusterSettingsURL } from "../+cluster-settings"; +import { broadcastMessage } from "../../../common/ipc"; +import { Cluster } from "../../../main/cluster"; +import { cssNames } from "../../utils"; +import { Icon } from "../icon"; + +interface Props { + cluster: Cluster + className?: string +} + +export function MainLayoutHeader({ cluster, className }: Props) { + return ( +
+ {cluster.name} + Open cluster settings} + interactive + onClick={() => { + broadcastMessage("renderer:navigate", clusterSettingsURL({ + params: { + clusterId: cluster.id + } + })); + }} + /> +
+ ); +} \ No newline at end of file diff --git a/src/renderer/components/layout/main-layout.scss b/src/renderer/components/layout/main-layout.scss index d423b0388f..92f1173b7a 100755 --- a/src/renderer/components/layout/main-layout.scss +++ b/src/renderer/components/layout/main-layout.scss @@ -14,15 +14,6 @@ grid-area: header; background: $layoutBackground; padding: $padding $padding * 2; - - span + .lens-version { - margin-left: $margin; - } - - .lens-version { - font-size: x-small; - text-transform: uppercase; - } } > aside { diff --git a/src/renderer/components/layout/main-layout.tsx b/src/renderer/components/layout/main-layout.tsx index d02d7077aa..7be6148e3e 100755 --- a/src/renderer/components/layout/main-layout.tsx +++ b/src/renderer/components/layout/main-layout.tsx @@ -3,12 +3,13 @@ import "./main-layout.scss"; import React from "react"; import { observable, reaction } from "mobx"; import { disposeOnUnmount, observer } from "mobx-react"; -import { autobind, createStorage, cssNames } from "../../utils"; -import { Sidebar } from "./sidebar"; -import { ErrorBoundary } from "../error-boundary"; -import { Dock } from "../dock"; import { getHostedCluster } from "../../../common/cluster-store"; +import { autobind, createStorage, cssNames } from "../../utils"; +import { Dock } from "../dock"; +import { ErrorBoundary } from "../error-boundary"; import { ResizeDirection, ResizeGrowthDirection, ResizeSide, ResizingAnchor } from "../resizing-anchor"; +import { MainLayoutHeader } from "./main-layout-header"; +import { Sidebar } from "./sidebar"; export interface MainLayoutProps { className?: any; @@ -66,9 +67,7 @@ export class MainLayout extends React.Component { return (
-
- {cluster.name} -
+