mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
* Save and restore lastActiveClusterId Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Activate clusters from workspaces page Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Fix saving last cluster while jumping from tray Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Adding workspace switch tests Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Remove console.log() Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Cleaning up Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Clean duplicated ClusterId definition Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Moving lastActiveClusterId field into WorkspaceModel Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * fix extensionLoader error on dev environments where renderer might start early (#1447) Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * Add Search by Ip to Pod View (#1445) Signed-off-by: Pavel Ashevskii <pashevskii@mirantis.com> * Make BaseStore abstract (#1431) * make BaseStore abstract so that implementers are forced to decide how to store data Signed-off-by: Sebastian Malton <sebastian@malton.name> * Enforce semicolons in eslint Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com> * Add a few missing folders to be linted. Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com> * Use @typescript-eslint/semi. Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com> * Allow extension cluster menus to have a parent (#1452) Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix SwitchCase indent rule in eslint (#1454) Signed-off-by: Sebastian Malton <sebastian@malton.name> * Revert "fix SwitchCase indent rule in eslint (#1454)" This reverts commit082774fe6e. * Revert "Allow extension cluster menus to have a parent (#1452)" This reverts commit622c45cd6d. * Revert "Use @typescript-eslint/semi." This reverts commit890fa5dd9e. * Revert "Add a few missing folders to be linted." This reverts commitc7b24c2922. * Revert "Enforce semicolons in eslint" This reverts commitca67caea60. * Revert "Make BaseStore abstract (#1431)" This reverts commit4b56ab7c61. * Revert "Add Search by Ip to Pod View (#1445)" This reverts commit4079214dc1. * Revert "fix extensionLoader error on dev environments where renderer might start early (#1447)" This reverts commit8a3613ac6f. * Split workspace tests to smaller ones Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Missing semicolons Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Split workspace tests a bit more Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Adding extra click in Add Cluster button Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Adding more awaits to check running cluster Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Wait for minikube before running tests Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> Co-authored-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> Co-authored-by: pashevskii <53330707+pashevskii@users.noreply.github.com> Co-authored-by: Sebastian Malton <sebastian@malton.name> Co-authored-by: Panu Horsmalahti <phorsmalahti@mirantis.com>
65 lines
2.0 KiB
TypeScript
65 lines
2.0 KiB
TypeScript
import "./workspace-menu.scss";
|
|
import React from "react";
|
|
import { observer } from "mobx-react";
|
|
import { Link } from "react-router-dom";
|
|
import { workspacesURL } from "./workspaces.route";
|
|
import { Trans } from "@lingui/macro";
|
|
import { Menu, MenuItem, MenuProps } from "../menu";
|
|
import { Icon } from "../icon";
|
|
import { observable } from "mobx";
|
|
import { WorkspaceId, workspaceStore } from "../../../common/workspace-store";
|
|
import { cssNames } from "../../utils";
|
|
import { navigate } from "../../navigation";
|
|
import { clusterViewURL } from "../cluster-manager/cluster-view.route";
|
|
import { landingURL } from "../+landing-page";
|
|
|
|
interface Props extends Partial<MenuProps> {
|
|
}
|
|
|
|
@observer
|
|
export class WorkspaceMenu extends React.Component<Props> {
|
|
@observable menuVisible = false;
|
|
|
|
activateWorkspace = (id: WorkspaceId) => {
|
|
const clusterId = workspaceStore.getById(id).lastActiveClusterId;
|
|
workspaceStore.setActive(id);
|
|
if (clusterId) {
|
|
navigate(clusterViewURL({ params: { clusterId } }));
|
|
} else {
|
|
navigate(landingURL());
|
|
}
|
|
};
|
|
|
|
render() {
|
|
const { className, ...menuProps } = this.props;
|
|
const { enabledWorkspacesList, currentWorkspace } = workspaceStore;
|
|
return (
|
|
<Menu
|
|
{...menuProps}
|
|
usePortal
|
|
className={cssNames("WorkspaceMenu", className)}
|
|
isOpen={this.menuVisible}
|
|
open={() => this.menuVisible = true}
|
|
close={() => this.menuVisible = false}
|
|
>
|
|
<Link className="workspaces-title" to={workspacesURL()}>
|
|
<Trans>Workspaces</Trans>
|
|
</Link>
|
|
{enabledWorkspacesList.map(({ id: workspaceId, name, description }) => {
|
|
return (
|
|
<MenuItem
|
|
key={workspaceId}
|
|
title={description}
|
|
active={workspaceId === currentWorkspace.id}
|
|
onClick={() => this.activateWorkspace(workspaceId)}
|
|
>
|
|
<Icon small material="layers"/>
|
|
<span className="workspace">{name}</span>
|
|
</MenuItem>
|
|
);
|
|
})}
|
|
</Menu>
|
|
);
|
|
}
|
|
}
|