From f5bbf725763307f10406c5538eb62cf245acaf9a Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Tue, 1 Dec 2020 11:31:03 +0200 Subject: [PATCH] use private static Signed-off-by: Jari Kolehmainen --- src/common/cluster-store.ts | 23 +++++++++++++++++--- src/common/workspace-store.ts | 40 ++++++++++++++++++++++++++++++++--- 2 files changed, 57 insertions(+), 6 deletions(-) diff --git a/src/common/cluster-store.ts b/src/common/cluster-store.ts index da8ab87a3a..5a9827eee5 100644 --- a/src/common/cluster-store.ts +++ b/src/common/cluster-store.ts @@ -40,13 +40,30 @@ export interface ClusterStoreModel { export type ClusterId = string; export interface ClusterModel { + /** Unique id for a cluster */ id: ClusterId; + + /** Path to cluster kubeconfig */ kubeConfigPath: string; + + /** Workspace id */ workspace?: WorkspaceId; + + /** User context in kubeconfig */ contextName?: string; + + /** Preferences */ preferences?: ClusterPreferences; + + /** Metadata */ metadata?: ClusterMetadata; + + /** + * If extension sets ownerRef it has to explicitly mark a cluster as enabled during onActive (or when cluster is saved) + */ ownerRef?: string; + + /** List of accessible namespaces */ accessibleNamespaces?: string[]; /** @deprecated */ @@ -89,7 +106,7 @@ export class ClusterStore extends BaseStore { @observable removedClusters = observable.map(); @observable clusters = observable.map(); - private stateRequestChannel = "cluster:states"; + private static stateRequestChannel = "cluster:states"; private constructor() { super({ @@ -112,7 +129,7 @@ export class ClusterStore extends BaseStore { }; if (ipcRenderer) { logger.info("[CLUSTER-STORE] requesting initial state sync"); - const clusterStates: clusterStateSync[] = await requestMain(this.stateRequestChannel); + const clusterStates: clusterStateSync[] = await requestMain(ClusterStore.stateRequestChannel); clusterStates.forEach((clusterState) => { const cluster = this.getById(clusterState.id); if (cluster) { @@ -120,7 +137,7 @@ export class ClusterStore extends BaseStore { } }); } else { - handleRequest(this.stateRequestChannel, (): clusterStateSync[] => { + handleRequest(ClusterStore.stateRequestChannel, (): clusterStateSync[] => { const states: clusterStateSync[] = []; this.clustersList.forEach((cluster) => { states.push({ diff --git a/src/common/workspace-store.ts b/src/common/workspace-store.ts index 2994adb4a9..4d5af6da98 100644 --- a/src/common/workspace-store.ts +++ b/src/common/workspace-store.ts @@ -27,11 +27,45 @@ export interface WorkspaceState { } export class Workspace implements WorkspaceModel, WorkspaceState { + /** + * Unique id for workspace + * + * @observable + */ @observable id: WorkspaceId; + /** + * Workspace name + * + * @observable + */ @observable name: string; + /** + * Workspace description + * + * @observable + */ @observable description?: string; + /** + * Workspace owner reference + * + * If extension sets ownerRef then it needs to explicitly mark workspace as enabled onActivate (or when workspace is saved) + * + * @observable + */ @observable ownerRef?: string; + /** + * Is workspace enabled + * + * Workspaces that don't have ownerRef will be enabled by default. Workspaces with ownerRef need to explicitly enable a workspace. + * + * @observable + */ @observable enabled: boolean; + /** + * Last active cluster id + * + * @observable + */ @observable lastActiveClusterId?: ClusterId; constructor(data: WorkspaceModel) { @@ -77,7 +111,7 @@ export class Workspace implements WorkspaceModel, WorkspaceState { export class WorkspaceStore extends BaseStore { static readonly defaultId: WorkspaceId = "default"; - private stateRequestChannel = "workspace:states"; + private static stateRequestChannel = "workspace:states"; private constructor() { super({ @@ -93,7 +127,7 @@ export class WorkspaceStore extends BaseStore { }; if (ipcRenderer) { logger.info("[WORKSPACE-STORE] requesting initial state sync"); - const workspaceStates: workspaceStateSync[] = await requestMain(this.stateRequestChannel); + const workspaceStates: workspaceStateSync[] = await requestMain(WorkspaceStore.stateRequestChannel); workspaceStates.forEach((workspaceState) => { const workspace = this.getById(workspaceState.id); if (workspace) { @@ -101,7 +135,7 @@ export class WorkspaceStore extends BaseStore { } }); } else { - handleRequest(this.stateRequestChannel, (): workspaceStateSync[] => { + handleRequest(WorkspaceStore.stateRequestChannel, (): workspaceStateSync[] => { const states: workspaceStateSync[] = []; this.workspacesList.forEach((workspace) => { states.push({