1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Reset active cluster when leaving dashboard

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2021-04-26 15:19:22 +03:00
parent 6c7d3efb3c
commit 720f62cc1f
3 changed files with 9 additions and 3 deletions

View File

@ -64,7 +64,7 @@ export class KubernetesCluster implements CatalogEntity {
},
];
if (this.status.active) {
if (this.status.phase == "connected") {
context.menuItems.unshift({
icon: "link_off",
title: "Disconnect",

View File

@ -27,6 +27,7 @@ export class ClusterManager extends React.Component {
reaction(getMatchedClusterId, initView, {
fireImmediately: true
}),
reaction(() => !getMatchedClusterId(), () => ClusterStore.getInstance().setActive(null)),
reaction(() => [
getMatchedClusterId(), // refresh when active cluster-view changed
hasLoadedView(getMatchedClusterId()), // refresh when cluster's webview loaded

View File

@ -7,11 +7,12 @@ import { HotbarIcon } from "./hotbar-icon";
import { cssNames, IClassName } from "../../utils";
import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
import { defaultHotbarCells, HotbarItem, HotbarStore } from "../../../common/hotbar-store";
import { catalogEntityRunContext } from "../../api/catalog-entity";
import { CatalogEntity, catalogEntityRunContext } from "../../api/catalog-entity";
import { Icon } from "../icon";
import { Badge } from "../badge";
import { CommandOverlay } from "../command-palette";
import { HotbarSwitchCommand } from "./hotbar-switch-command";
import { ClusterStore } from "../../../common/cluster-store";
interface Props {
className?: IClassName;
@ -23,6 +24,10 @@ export class HotbarMenu extends React.Component<Props> {
return HotbarStore.getInstance().getActive();
}
isActive(item: CatalogEntity) {
return ClusterStore.getInstance().activeClusterId == item.getId();
}
getEntity(item: HotbarItem) {
const hotbar = HotbarStore.getInstance().getActive();
@ -58,7 +63,7 @@ export class HotbarMenu extends React.Component<Props> {
key={index}
index={index}
entity={entity}
isActive={entity.status.active}
isActive={this.isActive(entity)}
onClick={() => entity.onRun(catalogEntityRunContext)}
/>
)}