From e94cf372e723e8b26f49ef86735f0349afa712b0 Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Tue, 9 Mar 2021 12:11:46 +0200 Subject: [PATCH] combine left menu icons Signed-off-by: Jari Kolehmainen --- .../cluster-manager/clusters-menu.scss | 30 +++---------- .../cluster-manager/clusters-menu.tsx | 45 ++++++++++++------- 2 files changed, 36 insertions(+), 39 deletions(-) diff --git a/src/renderer/components/cluster-manager/clusters-menu.scss b/src/renderer/components/cluster-manager/clusters-menu.scss index b6a1e66d1a..8acaf51493 100644 --- a/src/renderer/components/cluster-manager/clusters-menu.scss +++ b/src/renderer/components/cluster-manager/clusters-menu.scss @@ -27,14 +27,16 @@ } } - > .add-cluster { + > .WorkspaceOverview { position: relative; + margin-bottom: $margin; .Icon { + margin-bottom: $margin * 1.5; border-radius: $radius; padding: $padding / 3; - color: $addClusterIconColor; - background: #ffffff66; + color: #ffffff66; + background: unset; cursor: pointer; &.active { @@ -43,28 +45,10 @@ &:hover { box-shadow: none; - background: #ffffff; + color: #ffffff; + background-color: unset; } } - - .Badge { - $boxSize: 17px; - - position: absolute; - bottom: 0px; - transform: translateX(-50%) translateY(50%); - font-size: $font-size-small; - line-height: $boxSize; - min-width: $boxSize; - min-height: $boxSize; - text-align: center; - color: white; - background: $colorSuccess; - font-weight: normal; - border-radius: $radius; - padding: 0; - pointer-events: none; - } } > .extensions { diff --git a/src/renderer/components/cluster-manager/clusters-menu.tsx b/src/renderer/components/cluster-manager/clusters-menu.tsx index d963438136..0ca95ab9de 100644 --- a/src/renderer/components/cluster-manager/clusters-menu.tsx +++ b/src/renderer/components/cluster-manager/clusters-menu.tsx @@ -6,18 +6,15 @@ import { requestMain } from "../../../common/ipc"; import type { Cluster } from "../../../main/cluster"; import { DragDropContext, Draggable, DraggableProvided, Droppable, DroppableProvided, DropResult } from "react-beautiful-dnd"; import { observer } from "mobx-react"; -import { userStore } from "../../../common/user-store"; import { ClusterId, clusterStore } from "../../../common/cluster-store"; import { workspaceStore } from "../../../common/workspace-store"; import { ClusterIcon } from "../cluster-icon"; import { Icon } from "../icon"; import { autobind, cssNames, IClassName } from "../../utils"; -import { Badge } from "../badge"; import { isActiveRoute, navigate } from "../../navigation"; import { addClusterURL } from "../+add-cluster"; import { clusterSettingsURL } from "../+cluster-settings"; import { landingURL } from "../+landing-page"; -import { Tooltip } from "../tooltip"; import { ConfirmDialog } from "../confirm-dialog"; import { clusterViewURL } from "./cluster-view.route"; import { getExtensionPageUrl, globalPageMenuRegistry, globalPageRegistry } from "../../../extensions/registries"; @@ -37,10 +34,6 @@ export class ClustersMenu extends React.Component { navigate(clusterViewURL({ params: { clusterId } })); }; - addCluster = () => { - navigate(addClusterURL()); - }; - showContextMenu = (cluster: Cluster) => { const { Menu, MenuItem } = remote; const menu = new Menu(); @@ -96,6 +89,32 @@ export class ClustersMenu extends React.Component { }); }; + showWorkspaceContextMenu() { + const { Menu, MenuItem } = remote; + const menu = new Menu(); + const workspace = workspaceStore.getById(workspaceStore.currentWorkspaceId); + + if (!workspace.isManaged) { + menu.append(new MenuItem({ + label: `Add cluster`, + click: () => { + navigate(addClusterURL()); + } + })); + } + + menu.append(new MenuItem({ + label: `Workspace Overview`, + click: () => { + navigate(landingURL()); + } + })); + + menu.popup({ + window: remote.getCurrentWindow() + }); + } + @autobind() swapClusterIconOrder(result: DropResult) { if (result.reason === "DROP") { @@ -111,7 +130,6 @@ export class ClustersMenu extends React.Component { render() { const { className } = this.props; - const { newContexts } = userStore; const workspace = workspaceStore.getById(workspaceStore.currentWorkspaceId); const clusters = clusterStore.getByWorkspaceId(workspace.id).filter(cluster => cluster.enabled); const activeClusterId = clusterStore.activeCluster; @@ -149,14 +167,9 @@ export class ClustersMenu extends React.Component { -
- - Add Cluster - - - {newContexts.size > 0 && ( - - )} + +
+
{globalPageMenuRegistry.getItems().map(({ title, target, components: { Icon } }) => {