diff --git a/src/common/cluster-types.ts b/src/common/cluster-types.ts index cb958953f6..09e4435530 100644 --- a/src/common/cluster-types.ts +++ b/src/common/cluster-types.ts @@ -90,7 +90,11 @@ export interface ClusterPreferences extends ClusterPrometheusPreferences { terminalCWD?: string; clusterName?: string; iconOrder?: number; - icon?: string; + /** + * The src for the cluster. If set to `null` that means that it was + * cleared by preferences. + */ + icon?: string | null; httpsProxy?: string; hiddenMetrics?: string[]; nodeShellImage?: string; diff --git a/src/main/cluster-manager.ts b/src/main/cluster-manager.ts index 9336809bed..850b87c7b8 100644 --- a/src/main/cluster-manager.ts +++ b/src/main/cluster-manager.ts @@ -136,11 +136,16 @@ export class ClusterManager extends Singleton { entity.spec.metrics.prometheus = prometheus; } - // Only set the icon if the preference is set. If the preference is not set - // then let the source determine if a cluster has an icon. if (cluster.preferences.icon) { entity.spec.icon ??= {}; entity.spec.icon.src = cluster.preferences.icon; + } else if (cluster.preferences.icon === null) { + /** + * NOTE: only clear the icon if set to `null` by ClusterIconSettings. + * We can then also clear that value too + */ + entity.spec.icon = undefined; + cluster.preferences.icon = undefined; } catalogEntityRegistry.items.splice(index, 1, entity); @@ -177,7 +182,8 @@ export class ClusterManager extends Singleton { } } - @action syncClustersFromCatalog(entities: KubernetesCluster[]) { + @action + protected syncClustersFromCatalog(entities: KubernetesCluster[]) { for (const entity of entities) { const cluster = this.store.getById(entity.metadata.uid); diff --git a/src/renderer/components/cluster-settings/components/cluster-icon-settings.tsx b/src/renderer/components/cluster-settings/components/cluster-icon-settings.tsx index 4fb37dc1a2..a27860863e 100644 --- a/src/renderer/components/cluster-settings/components/cluster-icon-settings.tsx +++ b/src/renderer/components/cluster-settings/components/cluster-icon-settings.tsx @@ -65,7 +65,11 @@ export class ClusterIconSetting extends React.Component { } clearIcon() { - this.props.cluster.preferences.icon = undefined; + /** + * NOTE: this needs to be `null` rather than `undefined` so that we can + * tell the difference between it not being there and being cleared. + */ + this.props.cluster.preferences.icon = null; } @boundMethod