mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Optimise cluster activate and refresh (#938)
Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
1 parent
bddc6b33e3
commit
299eceaee4
5 files changed
+42
-11
No files matched your search
@@ -1,11 +1,12 @@
|
||||
import "./cluster-settings.scss";
|
||||
|
||||
import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { observer, disposeOnUnmount } from "mobx-react";
|
||||
import { Features } from "./features";
|
||||
import { Removal } from "./removal";
|
||||
import { Status } from "./status";
|
||||
import { General } from "./general";
|
||||
import { Cluster } from "../../../main/cluster";
|
||||
import { WizardLayout } from "../layout/wizard-layout";
|
||||
import { ClusterIcon } from "../cluster-icon";
|
||||
import { Icon } from "../icon";
|
||||
@@ -13,14 +14,25 @@ import { navigate } from "../../navigation";
|
||||
import { IClusterSettingsRouteParams } from "./cluster-settings.route";
|
||||
import { clusterStore } from "../../../common/cluster-store";
|
||||
import { RouteComponentProps } from "react-router";
|
||||
import { clusterIpc } from "../../../common/cluster-ipc";
|
||||
import { autorun } from "mobx";
|
||||
|
||||
interface Props extends RouteComponentProps<IClusterSettingsRouteParams> {
|
||||
}
|
||||
|
||||
@observer
|
||||
export class ClusterSettings extends React.Component<Props> {
|
||||
get cluster(): Cluster {
|
||||
return clusterStore.getById(this.props.match.params.clusterId);
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
window.addEventListener('keydown', this.onEscapeKey);
|
||||
disposeOnUnmount(this,
|
||||
autorun(() => {
|
||||
this.refreshCluster();
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
@@ -34,12 +46,18 @@ export class ClusterSettings extends React.Component<Props> {
|
||||
}
|
||||
}
|
||||
|
||||
refreshCluster = () => {
|
||||
if(this.cluster) {
|
||||
clusterIpc.refresh.invokeFromRenderer(this.cluster.id);
|
||||
}
|
||||
}
|
||||
|
||||
close() {
|
||||
navigate("/");
|
||||
}
|
||||
|
||||
render() {
|
||||
const cluster = clusterStore.getById(this.props.match.params.clusterId);
|
||||
const cluster = this.cluster
|
||||
if (!cluster) return null;
|
||||
const header = (
|
||||
<>
|
||||
|
||||
@@ -39,7 +39,7 @@ export class ClusterStatus extends React.Component<Props> {
|
||||
});
|
||||
})
|
||||
if (this.cluster.disconnected) {
|
||||
await this.refreshCluster();
|
||||
await this.activateCluster();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,13 +47,13 @@ export class ClusterStatus extends React.Component<Props> {
|
||||
ipcRenderer.removeAllListeners(`kube-auth:${this.props.clusterId}`);
|
||||
}
|
||||
|
||||
refreshCluster = async () => {
|
||||
activateCluster = async () => {
|
||||
await clusterIpc.activate.invokeFromRenderer(this.props.clusterId);
|
||||
}
|
||||
|
||||
reconnect = async () => {
|
||||
this.isReconnecting = true;
|
||||
await this.refreshCluster();
|
||||
await this.activateCluster();
|
||||
this.isReconnecting = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user