From 1510091cd239c5ea9446aba010fc466cdd135b03 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 21 Jul 2020 11:28:36 +0300 Subject: [PATCH] fix: terminal was broken at some point during refactoring Signed-off-by: Roman --- src/main/cluster.ts | 6 +++--- src/main/lens-proxy.ts | 6 +++--- src/main/node-shell-session.ts | 10 +++++++--- src/main/shell-session.ts | 2 -- src/renderer/config.store.ts | 2 ++ 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main/cluster.ts b/src/main/cluster.ts index 88b8e9ac93..be4417242e 100644 --- a/src/main/cluster.ts +++ b/src/main/cluster.ts @@ -109,7 +109,7 @@ export class Cluster implements ClusterModel { this.disposers.push( () => clearInterval(refreshStatusTimer), () => clearInterval(refreshEventsTimer), - reaction(() => this.getState(), this.pushState, { + reaction(this.getState, this.pushState, { fireImmediately: true }) ); @@ -319,8 +319,8 @@ export class Cluster implements ClusterModel { }) } - // serializable cluster-info for push-notifications - getState(): ClusterState { + // serializable cluster-state (mostly used for push-notifications) + getState = (): ClusterState => { const state: ClusterState = { ...this.toJSON(), initialized: this.initialized, diff --git a/src/main/lens-proxy.ts b/src/main/lens-proxy.ts index 9c6690f45c..7951ad2162 100644 --- a/src/main/lens-proxy.ts +++ b/src/main/lens-proxy.ts @@ -3,7 +3,7 @@ import http from "http"; import httpProxy from "http-proxy"; import url from "url"; import * as WebSocket from "ws" -import * as nodeShell from "./node-shell-session" +import { openShell } from "./node-shell-session"; import { Router } from "./router" import { ClusterManager } from "./cluster-manager" import { ContextHandler } from "./context-handler"; @@ -96,10 +96,10 @@ export class LensProxy { protected createWsListener(): WebSocket.Server { const ws = new WebSocket.Server({ noServer: true }) - return ws.on("connection", (async (socket: WebSocket, req: http.IncomingMessage) => { + return ws.on("connection", ((socket: WebSocket, req: http.IncomingMessage) => { const cluster = this.clusterManager.getClusterForRequest(req); const nodeParam = url.parse(req.url, true).query["node"]?.toString(); - await nodeShell.open(socket, cluster, nodeParam); + openShell(socket, cluster, nodeParam); })); } diff --git a/src/main/node-shell-session.ts b/src/main/node-shell-session.ts index bc89b5fb25..b669c262eb 100644 --- a/src/main/node-shell-session.ts +++ b/src/main/node-shell-session.ts @@ -133,9 +133,13 @@ export class NodeShellSession extends ShellSession { } } -export async function open(socket: WebSocket, cluster: Cluster, nodeName?: string): Promise { +export async function openShell(socket: WebSocket, cluster: Cluster, nodeName?: string): Promise { + let shell: ShellSession; if (nodeName) { - return new NodeShellSession(socket, cluster, nodeName) + shell = new NodeShellSession(socket, cluster, nodeName) + } else { + shell = new ShellSession(socket, cluster); } - return new ShellSession(socket, cluster); + shell.open() + return shell; } diff --git a/src/main/shell-session.ts b/src/main/shell-session.ts index 6071428b26..4b82b2d77d 100644 --- a/src/main/shell-session.ts +++ b/src/main/shell-session.ts @@ -11,8 +11,6 @@ import { helmCli } from "./helm/helm-cli" import { isWindows } from "../common/vars"; import { tracker } from "../common/tracker"; -// fixme: terminal doesn't work in ui - export class ShellSession extends EventEmitter { static shellEnvs: Map = new Map() diff --git a/src/renderer/config.store.ts b/src/renderer/config.store.ts index 05d881dbf3..54b45d2622 100755 --- a/src/renderer/config.store.ts +++ b/src/renderer/config.store.ts @@ -3,6 +3,8 @@ import { observable, when } from "mobx"; import { autobind, interval } from "./utils"; import { apiBase } from "./api"; +// todo: use user-store.ts as isomorphic-store with config/settings for ui + @autobind() export class ConfigStore { protected updater = interval(60, this.load);