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

change to getting instance itself in helper functions

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2020-11-26 12:33:52 -05:00
parent ecd0db6f0b
commit 66a3746d42

View File

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