mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
auto-refresh status only for active (selected) cluster
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
1 parent
e7fc6b4a35
commit
aab91863fc
7 files changed
+37
-26
No files matched your search
@@ -48,11 +48,15 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
|
||||
});
|
||||
}
|
||||
|
||||
@observable activeCluster: ClusterId; // todo: current-context from kube-config?
|
||||
@observable activeClusterId: ClusterId;
|
||||
@observable removedClusters = observable.map<ClusterId, Cluster>();
|
||||
@observable clusters = observable.map<ClusterId, Cluster>();
|
||||
|
||||
@computed get clustersList() {
|
||||
@computed get activeCluster(): Cluster {
|
||||
return this.clusters.get(this.activeClusterId);
|
||||
}
|
||||
|
||||
@computed get clustersList(): Cluster[] {
|
||||
return Array.from(this.clusters.values());
|
||||
}
|
||||
|
||||
@@ -74,8 +78,8 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
|
||||
|
||||
@action
|
||||
removeById(clusterId: ClusterId): void {
|
||||
if (this.activeCluster === clusterId) {
|
||||
this.activeCluster = null;
|
||||
if (this.activeClusterId === clusterId) {
|
||||
this.activeClusterId = null;
|
||||
}
|
||||
this.clusters.delete(clusterId);
|
||||
}
|
||||
@@ -111,14 +115,19 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
|
||||
}
|
||||
});
|
||||
|
||||
this.activeCluster = newClusters.has(activeCluster) ? activeCluster : null;
|
||||
this.activeClusterId = newClusters.has(activeCluster) ? activeCluster : null;
|
||||
this.clusters.replace(newClusters);
|
||||
this.removedClusters.replace(removedClusters);
|
||||
|
||||
// "auto-select" first cluster if not available or invalid from config file
|
||||
if (!this.activeClusterId && newClusters.size) {
|
||||
this.activeClusterId = Array.from(newClusters.values())[0].id;
|
||||
}
|
||||
}
|
||||
|
||||
toJSON(): ClusterStoreModel {
|
||||
return toJS({
|
||||
activeCluster: this.activeCluster,
|
||||
activeCluster: this.activeClusterId,
|
||||
clusters: this.clustersList.map(cluster => cluster.toJSON()),
|
||||
}, {
|
||||
recurseEverything: true
|
||||
|
||||
@@ -5,7 +5,7 @@ export enum ClusterIpcMessage {
|
||||
CLUSTER_STOP = "cluster-stop",
|
||||
CLUSTER_REMOVE = "cluster-remove",
|
||||
CLUSTER_REMOVE_WORKSPACE = "cluster-remove-all-from-workspace",
|
||||
CLUSTER_REFRESH = "cluster-refresh", // todo: remove, possibly won't needed
|
||||
CLUSTER_REFRESH = "cluster-refresh",
|
||||
FEATURE_INSTALL = "cluster-feature-install",
|
||||
FEATURE_UPGRADE = "cluster-feature-upgrade",
|
||||
FEATURE_REMOVE = "cluster-feature-remove",
|
||||
|
||||
Reference in new issue
Block a user