stores sync fixes, refactoring

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman committed 2020-07-14 19:36:18 +03:00
1 parent b8eaa657a2
commit a305b04292
14 files changed
+91 -81

No files matched your search

+5 -5
View File
@@ -160,11 +160,11 @@ export class ClusterManager {
static ipcListen(clusterManager: ClusterManager) {
const handlers = {
[ClusterIpcMessage.CLUSTER_ADD]: clusterManager.addCluster,
[ClusterIpcMessage.CLUSTER_STOP]: clusterManager.stopCluster,
[ClusterIpcMessage.CLUSTER_REMOVE]: clusterManager.removeCluster,
[ClusterIpcMessage.CLUSTER_REMOVE_WORKSPACE]: clusterManager.removeAllByWorkspace,
[ClusterIpcMessage.CLUSTER_REFRESH]: clusterManager.refreshCluster,
[ClusterIpcMessage.ADD]: clusterManager.addCluster,
[ClusterIpcMessage.STOP]: clusterManager.stopCluster,
[ClusterIpcMessage.REMOVE]: clusterManager.removeCluster,
[ClusterIpcMessage.REMOVE_WORKSPACE]: clusterManager.removeAllByWorkspace,
[ClusterIpcMessage.REFRESH]: clusterManager.refreshCluster,
[ClusterIpcMessage.FEATURE_INSTALL]: clusterManager.installFeature,
[ClusterIpcMessage.FEATURE_UPGRADE]: clusterManager.upgradeFeature,
[ClusterIpcMessage.FEATURE_REMOVE]: clusterManager.uninstallFeature,
+2 -2
View File
@@ -62,14 +62,14 @@ export class Cluster implements ClusterModel {
this.kubeProxyUrl = `http://localhost:${port}${apiKubePrefix}`;
this.webContentUrl = `http://${this.id}.localhost:${port}`;
this.initialized = true;
logger.info(`✅ ️Cluster init success`, {
logger.info(`[CLUSTER]: init success`, {
id: this.id,
serverUrl: this.apiUrl,
webContentUrl: this.webContentUrl,
kubeProxyUrl: this.kubeProxyUrl,
});
} catch (err) {
logger.error(`💣 Cluster init failed: ${err}`, {
logger.error(`[CLUSTER]: init failed: ${err}`, {
id: this.id,
error: err,
});
+2 -2
View File
@@ -1,6 +1,6 @@
import { ChildProcess, spawn } from "child_process"
import { waitUntilUsed } from "tcp-port-used";
import { sendMessage } from "../common/ipc-helpers";
import { broadcastMessage } from "../common/ipc-helpers";
import type { Cluster } from "./cluster"
import { bundledKubectl, Kubectl } from "./kubectl"
import logger from "./logger"
@@ -84,7 +84,7 @@ export class KubeAuthProxy {
const channel = `kube-auth:${this.cluster.id}`
const message = { data, stream };
logger.debug(channel, message);
sendMessage(channel, message);
broadcastMessage(channel, message);
}
public exit() {
+7 -8
View File
@@ -42,13 +42,8 @@ export class WindowManager {
});
}),
// auto-show active cluster view
reaction(() => clusterStore.activeCluster, activeCluster => {
if (activeCluster) {
this.activateView(activeCluster.id);
}
}, {
reaction(() => clusterStore.activeClusterId, clusterId => this.activateView(clusterId), {
fireImmediately: true,
delay: 250,
})
)
}
@@ -71,10 +66,14 @@ export class WindowManager {
if (!cluster) return;
try {
const activeView = this.activeView;
const isFresh = !this.getView(clusterId);
const isLoadedBefore = !!this.getView(clusterId);
const view = this.initView(clusterId);
logger.info(`Activating cluster(${cluster.id}) view`, {
contextName: cluster.contextName,
isLoadedBefore: isLoadedBefore,
});
if (view !== activeView) {
if (isFresh) {
if (!isLoadedBefore) {
await cluster.whenReady;
await view.loadURL(cluster.webContentUrl);
}