1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

cluster-store refactoring -- part 2

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2020-07-06 17:07:17 +03:00
parent 9f9701544b
commit 17cd886ce6

View File

@ -55,6 +55,13 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
return toJS(this.data.clusters).map(model => new Cluster(model)); return toJS(this.data.clusters).map(model => new Cluster(model));
} }
@computed get clustersMap(): Map<string, Cluster> {
return this.clusters.reduce((map, cluster) => {
map.set(cluster.id, cluster);
return map;
}, new Map);
}
getById(clusterId: ClusterId): Cluster { getById(clusterId: ClusterId): Cluster {
return this.clusters.find(cluster => cluster.id === clusterId) return this.clusters.find(cluster => cluster.id === clusterId)
} }
@ -79,6 +86,21 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
} }
}) })
} }
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(); export const clusterStore: ClusterStore = ClusterStore.getInstance();