diff --git a/src/common/cluster-store.ts b/src/common/cluster-store.ts index 3d7483db09..9a008c9551 100644 --- a/src/common/cluster-store.ts +++ b/src/common/cluster-store.ts @@ -55,6 +55,13 @@ export class ClusterStore extends BaseStore { return toJS(this.data.clusters).map(model => new Cluster(model)); } + @computed get clustersMap(): Map { + return this.clusters.reduce((map, cluster) => { + map.set(cluster.id, cluster); + return map; + }, new Map); + } + getById(clusterId: ClusterId): Cluster { return this.clusters.find(cluster => cluster.id === clusterId) } @@ -79,6 +86,21 @@ export class ClusterStore extends BaseStore { } }) } + + toJSON(): ClusterStoreModel { + const clusters: ClusterModel[] = this.clusters.map(cluster => { + return { + id: cluster.id, + contextName: cluster.contextName, + kubeConfigPath: cluster.kubeConfigPath, + preferences: cluster.preferences, + workspace: cluster.workspace, + } + }) + return { + clusters + } + } } export const clusterStore: ClusterStore = ClusterStore.getInstance();