migration additions -- part 3 (adding makeObservable to constructor)

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman committed 2021-04-20 13:45:35 +03:00
1 parent 95794af5b2
commit 08787dce1f
139 files changed
+732 -147

No files matched your search

+3 -1
View File
@@ -1,7 +1,7 @@
import "../common/cluster-ipc";
import type http from "http";
import { ipcMain } from "electron";
import { action, autorun, observable, reaction, toJS } from "mobx";
import { action, autorun, observable, reaction, toJS, makeObservable } from "mobx";
import { clusterStore, getClusterIdFromHost } from "../common/cluster-store";
import { Cluster } from "./cluster";
import logger from "./logger";
@@ -19,6 +19,8 @@ export class ClusterManager extends Singleton {
constructor(public readonly port: number) {
super();
makeObservable(this);
catalogEntityRegistry.addSource("lens:kubernetes-clusters", this.catalogSource);
// auto-init clusters
reaction(() => clusterStore.enabledClustersList, (clusters) => {
+6 -5
View File
@@ -1,9 +1,9 @@
import { ipcMain } from "electron";
import type { ClusterId, ClusterMetadata, ClusterModel, ClusterPreferences, ClusterPrometheusPreferences } from "../common/cluster-store";
import type { IMetricsReqParams } from "../renderer/api/endpoints/metrics.api";
import { action, comparer, computed, observable, reaction, toJS, when } from "mobx";
import { action, comparer, computed, makeObservable, observable, reaction, toJS, when } from "mobx";
import { apiKubePrefix } from "../common/vars";
import { broadcastMessage, InvalidKubeconfigChannel, ClusterListNamespaceForbiddenChannel } from "../common/ipc";
import { broadcastMessage, ClusterListNamespaceForbiddenChannel, InvalidKubeconfigChannel } from "../common/ipc";
import { ContextHandler } from "./context-handler";
import { AuthorizationV1Api, CoreV1Api, HttpError, KubeConfig, V1ResourceAttributes } from "@kubernetes/client-node";
import { Kubectl } from "./kubectl";
@@ -251,16 +251,17 @@ export class Cluster implements ClusterModel, ClusterState {
}
constructor(model: ClusterModel) {
makeObservable(this);
this.updateModel(model);
try {
const kubeconfig = this.getKubeconfig();
validateKubeConfig(kubeconfig, this.contextName, { validateCluster: true, validateUser: false, validateExec: false});
validateKubeConfig(kubeconfig, this.contextName, { validateCluster: true, validateUser: false, validateExec: false });
this.apiUrl = kubeconfig.getCluster(kubeconfig.getContextObject(this.contextName).cluster).server;
} catch(err) {
} catch (err) {
logger.error(err);
logger.error(`[CLUSTER] Failed to load kubeconfig for the cluster '${this.name || this.contextName}' (context: ${this.contextName}, kubeconfig: ${this.kubeConfigPath}).`);
logger.error(`[CLUSTER] Failed to load kubeconfig for the cluster '${this.name || this.contextName}' (context: ${this.contextName}, kubeconfig: ${this.kubeConfigPath}).`);
broadcastMessage(InvalidKubeconfigChannel, model.id);
}
}
+2 -1
View File
@@ -2,7 +2,7 @@ import { randomBytes } from "crypto";
import { SHA256 } from "crypto-js";
import { app, remote } from "electron";
import fse from "fs-extra";
import { action, observable, toJS } from "mobx";
import { action, observable, toJS, makeObservable } from "mobx";
import path from "path";
import { BaseStore } from "../common/base-store";
import { LensExtensionId } from "../extensions/lens-extension";
@@ -19,6 +19,7 @@ export class FilesystemProvisionerStore extends BaseStore<FSProvisionModel> {
configName: "lens-filesystem-provisioner-store",
accessPropertiesByDotNotation: false, // To make dots safe in cluster context names
});
makeObservable(this);
}
/**
+1 -1
View File
@@ -1,7 +1,7 @@
// Main process
import "../common/system-ca";
import "../common/libs-config"
import "../common/libs-config";
import "../common/prometheus-providers";
import * as Mobx from "mobx";
import * as LensExtensions from "../extensions/core-api";
+7 -1
View File
@@ -3,7 +3,7 @@ import * as proto from "../../common/protocol-handler";
import Url from "url-parse";
import { LensExtension } from "../../extensions/lens-extension";
import { broadcastMessage } from "../../common/ipc";
import { observable, when } from "mobx";
import { observable, when, makeObservable } from "mobx";
export interface FallbackHandler {
(name: string): Promise<boolean>;
@@ -15,6 +15,12 @@ export class LensProtocolRouterMain extends proto.LensProtocolRouter {
@observable rendererLoaded = false;
@observable extensionsLoaded = false;
constructor() {
super();
makeObservable(this);
}
/**
* Find the most specific registered handler, if it exists, and invoke it.
*
+2 -1
View File
@@ -1,5 +1,5 @@
import type { ClusterId } from "../common/cluster-store";
import { observable } from "mobx";
import { observable, makeObservable } from "mobx";
import { app, BrowserWindow, dialog, shell, webContents } from "electron";
import windowStateKeeper from "electron-window-state";
import { appEventBus } from "../common/event-bus";
@@ -21,6 +21,7 @@ export class WindowManager extends Singleton {
constructor(protected proxyPort: number) {
super();
makeObservable(this);
this.bindEvents();
this.initMenu();
this.initTray();