diff --git a/src/common/cluster-store.ts b/src/common/cluster-store.ts index b9d77bd2de..c914c42d74 100644 --- a/src/common/cluster-store.ts +++ b/src/common/cluster-store.ts @@ -182,10 +182,10 @@ export class ClusterStore extends BaseStore { } move.mutate(clusters, from, to); - for (const i in clusters) { - // This resets the iconOrder to the current display order - clusters[i].preferences.iconOrder = +i; - } + clusters.map((cluster, index) => { + cluster.preferences ??= {}; + cluster.preferences.iconOrder = index; + }); } hasClusters() { @@ -336,8 +336,11 @@ export class ClusterStore extends BaseStore { export const clusterStore = ClusterStore.getInstance(); export function getRendererInfoByWorkspace(workspaceId: string): ClusterRenderInfo[] { - const aliveClusters: ClusterRenderInfo[] = clusterStore.clustersList.filter(c => c.workspace === workspaceId); - const deadClusters: ClusterRenderInfo[] = clusterStore.deadClustersList + const aliveClusters: ClusterRenderInfo[] = ClusterStore.getInstance() + .clustersList + .filter(c => c.workspace === workspaceId); + const deadClusters: ClusterRenderInfo[] = ClusterStore.getInstance() + .deadClustersList .filter(([c]) => c.workspace === workspaceId) .map(([cluster, error]) => ({ DeadError: error, @@ -350,8 +353,11 @@ export function getRendererInfoByWorkspace(workspaceId: string): ClusterRenderIn } export function getClusterModelByWorkspace(workspaceId: string): ClusterModel[] { - const aliveClusters: ClusterModel[] = clusterStore.clustersList.filter(c => c.workspace === workspaceId); - const deadClusters: ClusterModel[] = clusterStore.deadClustersList + const aliveClusters: ClusterModel[] = ClusterStore.getInstance() + .clustersList + .filter(c => c.workspace === workspaceId); + const deadClusters: ClusterModel[] = ClusterStore.getInstance() + .deadClustersList .filter(([c]) => c.workspace === workspaceId) .map(([cluster]) => cluster); @@ -372,5 +378,5 @@ export function getHostedClusterId() { } export function getHostedCluster(): Cluster { - return clusterStore.getById(getHostedClusterId()); + return ClusterStore.getInstance().getById(getHostedClusterId()); }