From a046272afde5a78a59736a50fd7002b2cd02c023 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 2 Feb 2021 19:13:47 +0200 Subject: [PATCH] responding to comments Signed-off-by: Roman --- src/main/cluster.ts | 8 ++++---- src/renderer/api/kube-watch-api.ts | 8 +------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/main/cluster.ts b/src/main/cluster.ts index 4a20e585fe..4921e84a20 100644 --- a/src/main/cluster.ts +++ b/src/main/cluster.ts @@ -48,7 +48,7 @@ export interface ClusterState { isAdmin: boolean; allowedNamespaces: string[] allowedResources: string[] - watchApiAllEnabled: boolean; + isGlobalWatchEnabled: boolean; } /** @@ -182,7 +182,7 @@ export class Cluster implements ClusterModel, ClusterState { * * @observable */ - @observable watchApiAllEnabled = false; + @observable isGlobalWatchEnabled = false; /** * Preferences * @@ -440,7 +440,7 @@ export class Cluster implements ClusterModel, ClusterState { */ async refreshAccessibility(): Promise { this.isAdmin = await this.isClusterAdmin(); - this.watchApiAllEnabled = await this.canUseWatchApi({ resource: "*" }); + this.isGlobalWatchEnabled = await this.canUseWatchApi({ resource: "*" }); await this.refreshAllowedResources(); @@ -629,7 +629,7 @@ export class Cluster implements ClusterModel, ClusterState { isAdmin: this.isAdmin, allowedNamespaces: this.allowedNamespaces, allowedResources: this.allowedResources, - watchApiAllEnabled: this.watchApiAllEnabled, + isGlobalWatchEnabled: this.isGlobalWatchEnabled, }; return toJS(state, { diff --git a/src/renderer/api/kube-watch-api.ts b/src/renderer/api/kube-watch-api.ts index e874a3d0af..da05c0f22a 100644 --- a/src/renderer/api/kube-watch-api.ts +++ b/src/renderer/api/kube-watch-api.ts @@ -52,12 +52,6 @@ export class KubeWatchApi { @observable subscribers = observable.map(); @observable isConnected = false; - @computed get watchAllEnabled(): boolean { - const { isAdmin, watchApiAllEnabled } = this?.cluster; - - return Boolean(isAdmin || watchApiAllEnabled); - } - @computed get isReady(): boolean { return Boolean(this.cluster && this.namespaces); } @@ -76,7 +70,7 @@ export class KubeWatchApi { return []; } - if (api.isNamespaced && !this.watchAllEnabled) { + if (api.isNamespaced && !this.cluster.isGlobalWatchEnabled) { return this.namespaces.map(namespace => api.getWatchUrl(namespace)); }