mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
remove top-right cluster menu for now
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
f78c876d5d
commit
efa70e4dce
@ -1,18 +1,11 @@
|
||||
jest.mock("../../../../common/ipc");
|
||||
|
||||
import React from "react";
|
||||
import { fireEvent, render } from "@testing-library/react";
|
||||
import { render } from "@testing-library/react";
|
||||
import "@testing-library/jest-dom/extend-expect";
|
||||
|
||||
import { MainLayoutHeader } from "../main-layout-header";
|
||||
import { Cluster } from "../../../../main/cluster";
|
||||
import { broadcastMessage, requestMain } from "../../../../common/ipc";
|
||||
import { clusterDisconnectHandler } from "../../../../common/cluster-ipc";
|
||||
import { ConfirmDialog } from "../../confirm-dialog";
|
||||
import { IpcRendererNavigationEvents } from "../../../navigation/events";
|
||||
|
||||
const mockBroadcastIpc = broadcastMessage as jest.MockedFunction<typeof broadcastMessage>;
|
||||
const mockRequestMain = requestMain as jest.MockedFunction<typeof requestMain>;
|
||||
|
||||
const cluster: Cluster = new Cluster({
|
||||
id: "foo",
|
||||
@ -40,60 +33,4 @@ describe("<MainLayoutHeader />", () => {
|
||||
|
||||
expect(getByText("minikube")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
describe("Cluster Actions Menu", () => {
|
||||
let settingsBtn: Element;
|
||||
let disconnectBtn: Element;
|
||||
let removeBtn: Element;
|
||||
|
||||
beforeEach(() => {
|
||||
const { container } = render(<div>
|
||||
<MainLayoutHeader cluster={cluster} />
|
||||
<ConfirmDialog />
|
||||
</div>);
|
||||
const icon = container.querySelector(".Icon");
|
||||
|
||||
cluster.online = true;
|
||||
fireEvent.click(icon);
|
||||
|
||||
[settingsBtn, disconnectBtn, removeBtn] = Array.from(document.querySelectorAll("ul.ClusterActionsMenu > li"))
|
||||
.map(el => el.querySelector("span"));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cluster.online = false;
|
||||
});
|
||||
|
||||
it("renders cluster menu items", () => {
|
||||
expect(settingsBtn).toBeDefined();
|
||||
expect(settingsBtn.textContent).toBe("Settings");
|
||||
expect(disconnectBtn).toBeDefined();
|
||||
expect(disconnectBtn.textContent).toBe("Disconnect");
|
||||
expect(removeBtn).toBeDefined();
|
||||
expect(removeBtn.textContent).toBe("Remove");
|
||||
});
|
||||
|
||||
it("navigates to cluster settings", () => {
|
||||
fireEvent.click(settingsBtn);
|
||||
expect(mockBroadcastIpc).toBeCalledWith(IpcRendererNavigationEvents.NAVIGATE_IN_APP, "/cluster/foo/settings");
|
||||
});
|
||||
|
||||
it("disconnects from cluster", () => {
|
||||
fireEvent.click(disconnectBtn);
|
||||
expect(mockRequestMain).toBeCalledWith(clusterDisconnectHandler, cluster.id);
|
||||
});
|
||||
|
||||
it("opens 'Remove cluster' dialog", async () => {
|
||||
fireEvent.click(removeBtn);
|
||||
|
||||
const dialog = document.querySelector(".ConfirmDialog");
|
||||
|
||||
expect(dialog).toBeDefined();
|
||||
expect(dialog).not.toBe(null);
|
||||
|
||||
const okBtn = dialog.querySelector("button.ok");
|
||||
|
||||
expect(okBtn.textContent).toBe("Remove");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,10 +1,7 @@
|
||||
import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
|
||||
import { ClusterActions } from "../cluster-manager";
|
||||
import { Cluster } from "../../../main/cluster";
|
||||
import { cssNames } from "../../utils";
|
||||
import { MenuActions, MenuItem } from "../menu";
|
||||
|
||||
interface Props {
|
||||
cluster: Cluster
|
||||
@ -12,28 +9,9 @@ interface Props {
|
||||
}
|
||||
|
||||
export const MainLayoutHeader = observer(({ cluster, className }: Props) => {
|
||||
const actions = ClusterActions(cluster);
|
||||
const renderMenu = () => (
|
||||
<MenuActions autoCloseOnSelect className="ClusterActionsMenu">
|
||||
<MenuItem onClick={actions.showSettings}>
|
||||
<span>Settings</span>
|
||||
</MenuItem>
|
||||
<MenuItem onClick={actions.disconnect}>
|
||||
<span>Disconnect</span>
|
||||
</MenuItem>
|
||||
{
|
||||
!cluster.isManaged && (
|
||||
<MenuItem onClick={actions.remove}>
|
||||
<span>Remove</span>
|
||||
</MenuItem>
|
||||
)
|
||||
}
|
||||
</MenuActions>);
|
||||
|
||||
return (
|
||||
<header className={cssNames("flex gaps align-center justify-space-between", className)}>
|
||||
<span className="cluster">{cluster.name}</span>
|
||||
{renderMenu()}
|
||||
</header>
|
||||
);
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user