master-merge fixes, upgrading packages: mobx-observable-history@2.0, mobx@6.3, mobx-react

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman committed 2021-05-03 16:41:36 +03:00
1 parent 04ea4120ed
commit 264af63fad
9 files changed
+60 -49

No files matched your search

+2 -2
View File
@@ -15,13 +15,13 @@ export class CatalogPusher {
const disposers: Disposer[] = [];
disposers.push(reaction(() => this.catalog.items, (items) => {
broadcastMessage("catalog:items", toJS(items, { recurseEverything: true }));
broadcastMessage("catalog:items", toJS(items));
}, {
fireImmediately: true,
}));
const listener = subscribeToBroadcast("catalog:broadcast", () => {
broadcastMessage("catalog:items", toJS(this.catalog.items, { recurseEverything: true }));
broadcastMessage("catalog:items", toJS(this.catalog.items));
});
disposers.push(() => unsubscribeFromBroadcast("catalog:broadcast", listener));
+2 -2
View File
@@ -1,4 +1,4 @@
import { action, observable, IComputedValue, computed, ObservableMap, runInAction } from "mobx";
import { action, computed, IComputedValue, observable, ObservableMap, runInAction } from "mobx";
import { CatalogEntity, catalogEntityRegistry } from "../../common/catalog";
import { watch } from "chokidar";
import fs from "fs";
@@ -47,7 +47,7 @@ export class KubeconfigSyncManager extends Singleton {
this.startNewSync(filePath, port);
}
this.syncListDisposer = UserStore.getInstance().syncKubeconfigEntries.observe(change => {
this.syncListDisposer = UserStore.getInstance().syncKubeconfigEntries.observe_(change => {
switch (change.type) {
case "add":
this.startNewSync(change.name, port);
+8 -10
View File
@@ -1,8 +1,8 @@
import "../common/cluster-ipc";
import type http from "http";
import { ipcMain } from "electron";
import { action, autorun, observable, reaction, makeObservable } from "mobx";
import { Singleton, toJS } from "../common/utils";
import { action, autorun, makeObservable, observable, reaction } from "mobx";
import { Singleton } from "../common/utils";
import { ClusterStore, getClusterIdFromHost } from "../common/cluster-store";
import { Cluster } from "./cluster";
import logger from "./logger";
@@ -32,15 +32,14 @@ export class ClusterManager extends Singleton {
}, { fireImmediately: true });
reaction(() => toJS(ClusterStore.getInstance().enabledClustersList, { recurseEverything: true }), () => {
this.updateCatalogSource(ClusterStore.getInstance().enabledClustersList);
reaction(() => ClusterStore.getInstance().enabledClustersList, (enabledClusters) => {
this.updateCatalogSource(enabledClusters);
}, { fireImmediately: true });
reaction(() => catalogEntityRegistry.getItemsForApiKind<KubernetesCluster>("entity.k8slens.dev/v1alpha1", "KubernetesCluster"), (entities) => {
this.syncClustersFromCatalog(entities);
});
// auto-stop removed clusters
autorun(() => {
const removedClusters = Array.from(ClusterStore.getInstance().removedClusters.values());
@@ -60,7 +59,8 @@ export class ClusterManager extends Singleton {
ipcMain.on("network:online", () => { this.onNetworkOnline(); });
}
@action protected updateCatalogSource(clusters: Cluster[]) {
@action
protected updateCatalogSource(clusters: Cluster[]) {
this.catalogSource.replace(this.catalogSource.filter(entity => (
clusters.find((cluster) => entity.metadata.uid === cluster.id)
)));
@@ -175,9 +175,7 @@ export class ClusterManager extends Singleton {
}
export function catalogEntityFromCluster(cluster: Cluster) {
return new KubernetesCluster(toJS({
apiVersion: "entity.k8slens.dev/v1alpha1",
kind: "KubernetesCluster",
return new KubernetesCluster({
metadata: {
uid: cluster.id,
name: cluster.name,
@@ -196,5 +194,5 @@ export function catalogEntityFromCluster(cluster: Cluster) {
message: "",
active: !cluster.disconnected
}
}));
});
}