From 8b5c65264129267ee51c67ade56392a390755474 Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Mon, 18 Jan 2021 11:31:54 +0200 Subject: [PATCH] use get/set Signed-off-by: Jari Kolehmainen --- src/common/workspace-store.ts | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/common/workspace-store.ts b/src/common/workspace-store.ts index 8f04bd9763..921a9126a9 100644 --- a/src/common/workspace-store.ts +++ b/src/common/workspace-store.ts @@ -58,14 +58,7 @@ export class Workspace implements WorkspaceModel, WorkspaceState { * @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 * @@ -73,6 +66,9 @@ export class Workspace implements WorkspaceModel, WorkspaceState { */ @observable lastActiveClusterId?: ClusterId; + + @observable private _enabled: boolean; + constructor(data: WorkspaceModel) { Object.assign(this, data); @@ -83,6 +79,21 @@ export class Workspace implements WorkspaceModel, WorkspaceState { } } + /** + * Is workspace enabled + * + * Workspaces that don't have ownerRef will be enabled by default. Workspaces with ownerRef need to explicitly enable a workspace. + * + * @observable + */ + get enabled(): boolean { + return !this.isManaged || this._enabled; + } + + set enabled(enabled: boolean) { + this._enabled = enabled; + } + /** * Is workspace managed by an extension */ @@ -141,13 +152,11 @@ export class WorkspaceStore extends BaseStore { super({ configName: "lens-workspace-store", }); - const defaultWorkspace = new Workspace({ + + this.workspaces.set(WorkspaceStore.defaultId, new Workspace({ id: WorkspaceStore.defaultId, name: "default" - }); - - defaultWorkspace.enabled = true; - this.workspaces.set(WorkspaceStore.defaultId, defaultWorkspace); + })); } async load() {