mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Restrict extension version of ClusterStore (#2256)
This commit is contained in:
parent
bfc36b4d1d
commit
f401536efd
@ -99,7 +99,7 @@ describe("empty config", () => {
|
|||||||
|
|
||||||
it("removes cluster from store", async () => {
|
it("removes cluster from store", async () => {
|
||||||
await clusterStore.removeById("foo");
|
await clusterStore.removeById("foo");
|
||||||
expect(clusterStore.getById("foo")).toBeUndefined();
|
expect(clusterStore.getById("foo")).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("sets active cluster", () => {
|
it("sets active cluster", () => {
|
||||||
@ -248,7 +248,7 @@ describe("config with existing clusters", () => {
|
|||||||
expect(storedCluster).toBeTruthy();
|
expect(storedCluster).toBeTruthy();
|
||||||
const storedCluster2 = clusterStore.getById("cluster2");
|
const storedCluster2 = clusterStore.getById("cluster2");
|
||||||
|
|
||||||
expect(storedCluster2).toBeUndefined();
|
expect(storedCluster2).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("allows getting all of the clusters", async () => {
|
it("allows getting all of the clusters", async () => {
|
||||||
|
|||||||
@ -218,8 +218,12 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
setActive(id: ClusterId) {
|
setActive(clusterId: ClusterId) {
|
||||||
const clusterId = this.clusters.has(id) ? id : null;
|
const cluster = this.clusters.get(clusterId);
|
||||||
|
|
||||||
|
if (!cluster?.enabled) {
|
||||||
|
clusterId = null;
|
||||||
|
}
|
||||||
|
|
||||||
this.activeCluster = clusterId;
|
this.activeCluster = clusterId;
|
||||||
workspaceStore.setLastActiveClusterId(clusterId);
|
workspaceStore.setLastActiveClusterId(clusterId);
|
||||||
@ -251,8 +255,8 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
|
|||||||
return this.clusters.size > 0;
|
return this.clusters.size > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
getById(id: ClusterId): Cluster {
|
getById(id: ClusterId): Cluster | null {
|
||||||
return this.clusters.get(id);
|
return this.clusters.get(id) ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
getByWorkspaceId(workspaceId: string): Cluster[] {
|
getByWorkspaceId(workspaceId: string): Cluster[] {
|
||||||
|
|||||||
@ -25,7 +25,7 @@ export class ClusterStore extends Singleton {
|
|||||||
* Set active cluster id
|
* Set active cluster id
|
||||||
*/
|
*/
|
||||||
set activeClusterId(id : ClusterId) {
|
set activeClusterId(id : ClusterId) {
|
||||||
internalClusterStore.activeCluster = id;
|
internalClusterStore.setActive(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,12 +38,8 @@ export class ClusterStore extends Singleton {
|
|||||||
/**
|
/**
|
||||||
* Get active cluster (a cluster which is currently visible)
|
* Get active cluster (a cluster which is currently visible)
|
||||||
*/
|
*/
|
||||||
get activeCluster(): Cluster {
|
get activeCluster(): Cluster | null {
|
||||||
if (!this.activeClusterId) {
|
return internalClusterStore.active;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.getById(this.activeClusterId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -104,7 +100,7 @@ export class ClusterStore extends Singleton {
|
|||||||
* @param model cluster
|
* @param model cluster
|
||||||
*/
|
*/
|
||||||
async removeCluster(model: ClusterModel) {
|
async removeCluster(model: ClusterModel) {
|
||||||
return this.removeById(model.id);
|
return internalClusterStore.removeById(model.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user