import "./clusters-menu.scss" import { remote } from "electron" import React from "react"; import { observer } from "mobx-react"; import { _i18n } from "../../i18n"; import { t, Trans } from "@lingui/macro"; import type { Cluster } from "../../../main/cluster"; import { userStore } from "../../../common/user-store"; import { ClusterId, clusterStore } from "../../../common/cluster-store"; import { workspaceStore } from "../../../common/workspace-store"; import { ClusterIcon } from "../+cluster-settings/cluster-icon"; import { Icon } from "../icon"; import { cssNames, IClassName } from "../../utils"; import { Badge } from "../badge"; import { navigate } from "../../navigation"; import { addClusterURL } from "../+add-cluster"; import { clusterSettingsURL } from "../+cluster-settings"; // fixme: allow to rearrange clusters with drag&drop // fixme: make add-icon's tooltip visible on init interface Props { className?: IClassName; } @observer export class ClustersMenu extends React.Component { showCluster = (clusterId: ClusterId) => { if (clusterStore.activeClusterId === clusterId) { navigate("/"); // redirect to index } else { clusterStore.activeClusterId = clusterId; } } addCluster = () => { navigate(addClusterURL()); } showContextMenu = (cluster: Cluster) => { const { Menu, MenuItem } = remote const menu = new Menu(); menu.append(new MenuItem({ label: _i18n._(t`Settings`), click: () => navigate(clusterSettingsURL()) })); if (cluster.initialized) { menu.append(new MenuItem({ label: _i18n._(t`Disconnect`), click: () => { console.log(`//fixme: disconnect cluster`, cluster); navigate("/"); } })) } menu.popup({ window: remote.getCurrentWindow() }) } render() { const { className } = this.props; const { newContexts } = userStore; const { currentWorkspaceId } = workspaceStore; const clusters = clusterStore.getByWorkspaceId(currentWorkspaceId); return (
{clusters.map(cluster => { return ( this.showCluster(cluster.id)} onContextMenu={() => this.showContextMenu(cluster)} /> ) })}

This is the quick launch menu.

Associate clusters and choose the ones you want to access via quick launch menu by clicking the + button.

)} /> {newContexts.length > 0 && ( )}
); } }