Restrict extension version of ClusterStore (#2256)

This commit is contained in:
Sebastian Malton authored and GitHub committed 2021-03-30 10:13:15 -04:00
1 parent 4529b1ec33
commit a4ba77c58b
3 files changed
+14 -14

No files matched your search

+2 -2
View File
@@ -99,7 +99,7 @@ describe("empty config", () => {
it("removes cluster from store", async () => {
await clusterStore.removeById("foo");
expect(clusterStore.getById("foo")).toBeUndefined();
expect(clusterStore.getById("foo")).toBeNull();
});
it("sets active cluster", () => {
@@ -248,7 +248,7 @@ describe("config with existing clusters", () => {
expect(storedCluster).toBeTruthy();
const storedCluster2 = clusterStore.getById("cluster2");
expect(storedCluster2).toBeUndefined();
expect(storedCluster2).toBeNull();
});
it("allows getting all of the clusters", async () => {
+8 -4
View File
@@ -218,8 +218,12 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
}
@action
setActive(id: ClusterId) {
const clusterId = this.clusters.has(id) ? id : null;
setActive(clusterId: ClusterId) {
const cluster = this.clusters.get(clusterId);
if (!cluster?.enabled) {
clusterId = null;
}
this.activeCluster = clusterId;
workspaceStore.setLastActiveClusterId(clusterId);
@@ -251,8 +255,8 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
return this.clusters.size > 0;
}
getById(id: ClusterId): Cluster {
return this.clusters.get(id);
getById(id: ClusterId): Cluster | null {
return this.clusters.get(id) ?? null;
}
getByWorkspaceId(workspaceId: string): Cluster[] {