mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-02-20 01:28:45 +01:00
fix(ui): prevent crash when navigating between Applications and Appli… (#26245)
Signed-off-by: Peter Jiang <peterjiang823@gmail.com>
This commit is contained in:
@@ -223,7 +223,12 @@ export class ViewPreferencesService {
|
||||
}
|
||||
|
||||
public updatePreferences(change: Partial<ViewPreferences>) {
|
||||
const nextPref = Object.assign({}, this.preferencesSubj.getValue(), change, {version: minVer});
|
||||
const current = this.preferencesSubj.getValue();
|
||||
const nextPref = Object.assign({}, current, change, {version: minVer});
|
||||
// Normalize appList to ensure all filter arrays are initialized
|
||||
if (nextPref.appList) {
|
||||
this.normalizeAppListPreferences(nextPref.appList);
|
||||
}
|
||||
window.localStorage.setItem(VIEW_PREFERENCES_KEY, JSON.stringify(nextPref));
|
||||
this.preferencesSubj.next(nextPref);
|
||||
}
|
||||
@@ -243,6 +248,23 @@ export class ViewPreferencesService {
|
||||
} else {
|
||||
preferences = DEFAULT_PREFERENCES;
|
||||
}
|
||||
return deepMerge(DEFAULT_PREFERENCES, preferences);
|
||||
const merged = deepMerge(DEFAULT_PREFERENCES, preferences);
|
||||
// Ensure all filter arrays are initialized to prevent undefined errors
|
||||
this.normalizeAppListPreferences(merged.appList);
|
||||
return merged;
|
||||
}
|
||||
|
||||
private normalizeAppListPreferences(appList: AppsListPreferences): void {
|
||||
appList.labelsFilter = appList.labelsFilter || [];
|
||||
appList.annotationsFilter = appList.annotationsFilter || [];
|
||||
appList.projectsFilter = appList.projectsFilter || [];
|
||||
appList.namespacesFilter = appList.namespacesFilter || [];
|
||||
appList.clustersFilter = appList.clustersFilter || [];
|
||||
appList.reposFilter = appList.reposFilter || [];
|
||||
appList.syncFilter = appList.syncFilter || [];
|
||||
appList.autoSyncFilter = appList.autoSyncFilter || [];
|
||||
appList.healthFilter = appList.healthFilter || [];
|
||||
appList.operationFilter = appList.operationFilter || [];
|
||||
appList.favoritesAppList = appList.favoritesAppList || [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user