From f0b51daf3677c774f01188e2c4c2675ef87c21ce Mon Sep 17 00:00:00 2001 From: Keith Chong Date: Thu, 10 Mar 2022 16:45:26 -0500 Subject: [PATCH] fix: Make zoom level a user preference (#7183) (#8460) Signed-off-by: Keith Chong --- .../application-details/application-details.tsx | 11 +++++------ .../app/shared/services/view-preferences-service.ts | 4 +++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ui/src/app/applications/components/application-details/application-details.tsx b/ui/src/app/applications/components/application-details/application-details.tsx index 7f8895a0dcfbe..25cafc74f9111 100644 --- a/ui/src/app/applications/components/application-details/application-details.tsx +++ b/ui/src/app/applications/components/application-details/application-details.tsx @@ -34,7 +34,6 @@ interface ApplicationDetailsState { revision?: string; groupedResources?: ResourceStatus[]; slidingPanelPage?: number; - zoom?: number; filteredGraph?: any[]; } @@ -70,7 +69,7 @@ export class ApplicationDetails extends React.Component) { super(props); - this.state = {page: 0, groupedResources: [], slidingPanelPage: 0, zoom: 1.0, filteredGraph: []}; + this.state = {page: 0, groupedResources: [], slidingPanelPage: 0, filteredGraph: []}; } private get showOperationState() { @@ -213,15 +212,15 @@ export class ApplicationDetails extends React.Component { - let targetZoom: number = this.state.zoom + s; + let targetZoom: number = pref.zoom + s; if (targetZoom <= 0.05) { targetZoom = 0.1; } else if (targetZoom > 2.0) { targetZoom = 2.0; } - this.setState({zoom: targetZoom}); + services.viewPreferences.updatePreferences({appDetails: {...pref, zoom: targetZoom}}); }; const setFilterGraph = (filterGraph: any[]) => { this.setState({filteredGraph: filterGraph}); @@ -322,7 +321,7 @@ export class ApplicationDetails extends React.Component openGroupNodeDetails(groupdedNodeIds)} - zoom={this.state.zoom} + zoom={pref.zoom || 1.0} filters={pref.resourceFilter} setTreeFilterGraph={setFilterGraph} /> diff --git a/ui/src/app/shared/services/view-preferences-service.ts b/ui/src/app/shared/services/view-preferences-service.ts index b38e73821eafb..e9b11b04421d7 100644 --- a/ui/src/app/shared/services/view-preferences-service.ts +++ b/ui/src/app/shared/services/view-preferences-service.ts @@ -24,6 +24,7 @@ export interface AppDetailsPreferences { hideFilters: boolean; wrapLines: boolean; groupNodes?: boolean; + zoom?: number; } export interface PodViewPreferences { @@ -110,7 +111,8 @@ const DEFAULT_PREFERENCES: ViewPreferences = { }, darkMode: false, followLogs: false, - wrapLines: false + wrapLines: false, + zoom: 1.0 }, appList: { view: 'tiles' as AppsListViewType,