From 299eceaee4621a0bfeb663c0a87a400efee31c6d Mon Sep 17 00:00:00 2001 From: Lauri Nevala Date: Mon, 21 Sep 2020 13:20:50 +0300 Subject: [PATCH 1/8] Optimise cluster activate and refresh (#938) Signed-off-by: Lauri Nevala --- src/common/cluster-ipc.ts | 8 +++++++ src/main/cluster.ts | 15 ++++++++----- src/main/shell-session.ts | 2 +- .../+cluster-settings/cluster-settings.tsx | 22 +++++++++++++++++-- .../cluster-manager/cluster-status.tsx | 6 ++--- 5 files changed, 42 insertions(+), 11 deletions(-) diff --git a/src/common/cluster-ipc.ts b/src/common/cluster-ipc.ts index b8f9f5f84b..f48ce0f9c4 100644 --- a/src/common/cluster-ipc.ts +++ b/src/common/cluster-ipc.ts @@ -14,6 +14,14 @@ export const clusterIpc = { }, }), + refresh: createIpcChannel({ + channel: "cluster:refresh", + handle: (clusterId: ClusterId) => { + const cluster = clusterStore.getById(clusterId); + if (cluster) return cluster.refresh(); + }, + }), + disconnect: createIpcChannel({ channel: "cluster:disconnect", handle: (clusterId: ClusterId) => { diff --git a/src/main/cluster.ts b/src/main/cluster.ts index 48bf01ee02..9fc9172296 100644 --- a/src/main/cluster.ts +++ b/src/main/cluster.ts @@ -133,7 +133,13 @@ export class Cluster implements ClusterModel { if (this.disconnected || (!init && !this.accessible)) { await this.reconnect(); } - await this.refresh(); + await this.refreshConnectionStatus() + if (this.accessible) { + await this.refreshAllowedResources() + this.ready = true + this.kubeCtl = new Kubectl(this.version) + this.kubeCtl.ensureKubectl() // download kubectl in background, so it's not blocking dashboard + } return this.pushState(); } @@ -159,15 +165,14 @@ export class Cluster implements ClusterModel { @action async refresh() { logger.info(`[CLUSTER]: refresh`, this.getMeta()); - await this.refreshConnectionStatus(); // refresh "version", "online", etc. + await this.whenInitialized; + await this.refreshConnectionStatus(); if (this.accessible) { - this.kubeCtl = new Kubectl(this.version) this.distribution = this.detectKubernetesDistribution(this.version) const [features, isAdmin, nodesCount] = await Promise.all([ getFeatures(this), this.isClusterAdmin(), this.getNodeCount(), - this.kubeCtl.ensureKubectl() ]); this.features = features; this.isAdmin = isAdmin; @@ -176,8 +181,8 @@ export class Cluster implements ClusterModel { this.refreshEvents(), this.refreshAllowedResources(), ]); - this.ready = true } + this.pushState(); } @action diff --git a/src/main/shell-session.ts b/src/main/shell-session.ts index 704d97382a..1d9d722f57 100644 --- a/src/main/shell-session.ts +++ b/src/main/shell-session.ts @@ -39,7 +39,7 @@ export class ShellSession extends EventEmitter { public async open() { this.kubectlBinDir = await this.kubectl.binDir() const pathFromPreferences = userStore.preferences.kubectlBinariesPath || Kubectl.bundledKubectlPath - this.kubectlPathDir = userStore.preferences.downloadKubectlBinaries ? await this.kubectl.binDir() : path.dirname(pathFromPreferences) + this.kubectlPathDir = userStore.preferences.downloadKubectlBinaries ? this.kubectlBinDir : path.dirname(pathFromPreferences) this.helmBinDir = helmCli.getBinaryDir() const env = await this.getCachedShellEnv() const shell = env.PTYSHELL diff --git a/src/renderer/components/+cluster-settings/cluster-settings.tsx b/src/renderer/components/+cluster-settings/cluster-settings.tsx index 0cec665538..b284ed9c88 100644 --- a/src/renderer/components/+cluster-settings/cluster-settings.tsx +++ b/src/renderer/components/+cluster-settings/cluster-settings.tsx @@ -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 { } @observer export class ClusterSettings extends React.Component { + 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 { } } + 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 = ( <> diff --git a/src/renderer/components/cluster-manager/cluster-status.tsx b/src/renderer/components/cluster-manager/cluster-status.tsx index b0fae210dd..846b26a504 100644 --- a/src/renderer/components/cluster-manager/cluster-status.tsx +++ b/src/renderer/components/cluster-manager/cluster-status.tsx @@ -39,7 +39,7 @@ export class ClusterStatus extends React.Component { }); }) if (this.cluster.disconnected) { - await this.refreshCluster(); + await this.activateCluster(); } } @@ -47,13 +47,13 @@ export class ClusterStatus extends React.Component { 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; } From 25aac57a868b90f67216b6422d236b8132f19d3f Mon Sep 17 00:00:00 2001 From: Yangjun Wang Date: Mon, 21 Sep 2020 15:08:44 +0300 Subject: [PATCH 2/8] fix bug - deleted namespace does not get auto unselected (#930) * fix bug - deleted namespace does not get auto unselected Signed-off-by: Yangjun Wang --- src/renderer/components/+namespaces/namespace.store.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/renderer/components/+namespaces/namespace.store.ts b/src/renderer/components/+namespaces/namespace.store.ts index 624c823a52..c9f190be97 100644 --- a/src/renderer/components/+namespaces/namespace.store.ts +++ b/src/renderer/components/+namespaces/namespace.store.ts @@ -87,6 +87,11 @@ export class NamespaceStore extends KubeObjectStore { super.reset(); this.contextNs.clear(); } + + async remove(item: Namespace) { + await super.remove(item); + this.contextNs.remove(item.getName()); + } } export const namespaceStore = new NamespaceStore(); From 44190c7321534e52a94911d5eb0d39a0a1744cad Mon Sep 17 00:00:00 2001 From: Yangjun Wang Date: Mon, 21 Sep 2020 16:37:20 +0300 Subject: [PATCH 3/8] Get focus to dock tab content after resize (#935) Signed-off-by: Yangjun Wang Co-authored-by: Yangjun Wang --- src/renderer/components/dock/editor-panel.tsx | 1 + src/renderer/components/dock/terminal.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/renderer/components/dock/editor-panel.tsx b/src/renderer/components/dock/editor-panel.tsx index bf57eb10ca..c52630a89d 100644 --- a/src/renderer/components/dock/editor-panel.tsx +++ b/src/renderer/components/dock/editor-panel.tsx @@ -48,6 +48,7 @@ export class EditorPanel extends React.Component { onResize = () => { this.editor.resize(); + this.editor.focus(); } onCursorPosChange = (pos: Ace.Point) => { diff --git a/src/renderer/components/dock/terminal.ts b/src/renderer/components/dock/terminal.ts index f0685c0255..f02fd478f2 100644 --- a/src/renderer/components/dock/terminal.ts +++ b/src/renderer/components/dock/terminal.ts @@ -152,6 +152,7 @@ export class Terminal { onResize = () => { if (!this.isActive) return; this.fitLazy(); + this.focus(); } onActivate = () => { From 78ab6f016b6ccd6df244c9dc7b3e1706e4266343 Mon Sep 17 00:00:00 2001 From: Lauri Nevala Date: Mon, 21 Sep 2020 16:47:51 +0300 Subject: [PATCH 4/8] Fix background of What's New page with white theme (#940) Signed-off-by: Lauri Nevala --- .../components/+whats-new/whats-new.scss | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/renderer/components/+whats-new/whats-new.scss b/src/renderer/components/+whats-new/whats-new.scss index 9eef62cc13..8aa37fdf66 100644 --- a/src/renderer/components/+whats-new/whats-new.scss +++ b/src/renderer/components/+whats-new/whats-new.scss @@ -1,10 +1,24 @@ .WhatsNew { $spacing: $padding * 2; - background: $mainBackground url(../../components/icon/crane.svg) no-repeat; - background-position: 0 35%; - background-size: 85%; - background-clip: content-box; + &::after { + content: ""; + background: url(../../components/icon/crane.svg) no-repeat; + background-position: 0 35%; + background-size: 85%; + background-clip: content-box; + opacity: .75; + top: 0; + left: 0; + bottom: 0; + right: 0; + position: absolute; + z-index: -1; + + .theme-light & { + opacity: 0.2; + } + } .logo { width: 200px; From 9a10db837e5df23beb33f8b5583c69b7496f317e Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Mon, 21 Sep 2020 14:47:44 -0400 Subject: [PATCH 5/8] fix Notifications blocking items not visually under them from being interacted with (#915) * fix Notifications blocking items not visually under them from being interacted with Signed-off-by: Sebastian Malton --- src/renderer/components/dock/info-panel.tsx | 18 +++++++++--------- .../notifications/notifications.scss | 5 +++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/renderer/components/dock/info-panel.tsx b/src/renderer/components/dock/info-panel.tsx index 69e79ad8de..39d998d9d4 100644 --- a/src/renderer/components/dock/info-panel.tsx +++ b/src/renderer/components/dock/info-panel.tsx @@ -62,14 +62,13 @@ export class InfoPanel extends Component { this.error = ""; this.waiting = true; try { - this.result = await this.props.submit().finally(() => { - this.waiting = false; - }); + this.result = await this.props.submit() if (showNotifications) Notifications.ok(this.result); } catch (error) { this.error = error.toString(); if (showNotifications) Notifications.error(this.error); - throw error; + } finally { + this.waiting = false } } @@ -91,12 +90,13 @@ export class InfoPanel extends Component { <> {result && (
- {result} + + {result}
)} {errorInfo && (
- + {errorInfo}
)} @@ -114,9 +114,9 @@ export class InfoPanel extends Component { {controls}
- {waiting ? <> {submittingMessage} : this.renderInfo()} + {waiting ? <> {submittingMessage} : this.renderInfo()}
-