mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix not being able to clear set cluster icon (#4555)
This commit is contained in:
parent
56e72b3a74
commit
d775d53078
@ -90,7 +90,11 @@ export interface ClusterPreferences extends ClusterPrometheusPreferences {
|
||||
terminalCWD?: string;
|
||||
clusterName?: string;
|
||||
iconOrder?: number;
|
||||
icon?: string;
|
||||
/**
|
||||
* The <img> 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;
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -65,7 +65,11 @@ export class ClusterIconSetting extends React.Component<Props> {
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user