From 11a969f44fe66e757b8cd8dcf6fa92cb9b2e00be Mon Sep 17 00:00:00 2001 From: Alan Ren Date: Tue, 31 May 2022 21:04:23 -0700 Subject: [PATCH] workaround for the dashboard resets zooming issue (#19576) --- .../browser/core/dashboardPage.component.ts | 17 +++++++++++++++-- .../pages/databaseDashboardPage.component.ts | 6 ++++-- .../pages/serverDashboardPage.component.ts | 6 ++++-- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/sql/workbench/contrib/dashboard/browser/core/dashboardPage.component.ts b/src/sql/workbench/contrib/dashboard/browser/core/dashboardPage.component.ts index ba115323dc..66fd88f966 100644 --- a/src/sql/workbench/contrib/dashboard/browser/core/dashboardPage.component.ts +++ b/src/sql/workbench/contrib/dashboard/browser/core/dashboardPage.component.ts @@ -31,7 +31,7 @@ import * as nls from 'vs/nls'; import * as objects from 'vs/base/common/objects'; import { Event, Emitter } from 'vs/base/common/event'; import { Action, IAction, SubmenuAction } from 'vs/base/common/actions'; -import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration'; +import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration'; import Severity from 'vs/base/common/severity'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { IContextKeyService, ContextKeyExpr, RawContextKey, IContextKey } from 'vs/platform/contextkey/common/contextkey'; @@ -54,9 +54,11 @@ import { LabeledMenuItemActionItem } from 'sql/platform/actions/browser/menuEntr import { DASHBOARD_BORDER, TOOLBAR_OVERFLOW_SHADOW } from 'sql/workbench/common/theme'; import { IActionViewItem } from 'vs/base/browser/ui/actionbar/actionbar'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; +import { onUnexpectedError } from 'vs/base/common/errors'; const dashboardRegistry = Registry.as(DashboardExtensions.DashboardContributions); const homeTabGroupId = 'home'; +const zoomLevelConfiguration = 'window.zoomLevel'; @Component({ selector: 'dashboard-page', @@ -130,7 +132,8 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig @Inject(IContextKeyService) contextKeyService: IContextKeyService, @Inject(IMenuService) private menuService: IMenuService, @Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService, - @Inject(IInstantiationService) private instantiationService: IInstantiationService + @Inject(IInstantiationService) private instantiationService: IInstantiationService, + @Inject(IConfigurationService) private configurationService: IConfigurationService ) { super(); this._tabName = DashboardPage.tabName.bindTo(contextKeyService); @@ -172,6 +175,16 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig this._register(this.themeService.onDidColorThemeChange((event: IColorTheme) => { this.updateTheme(event); })); + + // Workaround for issue: https://github.com/microsoft/azuredatastudio/issues/14128 + // While the Angular loads the dashboard components, the Electron's zoom level will be reset without going through + // the setZoomLevel API in VSCode. + // Before a permanent fix is available, to workaround the issue, we can get the current zoom level and + // set it so that the electron's zoom level is consistent with the vscode configuration. + const currentZoom: number = this.configurationService.getValue(zoomLevelConfiguration); + this.configurationService.updateValue(zoomLevelConfiguration, currentZoom - 1).then(() => { + return this.configurationService.updateValue(zoomLevelConfiguration, currentZoom); + }).catch(onUnexpectedError); } private getContributedTasks(tabId: string): ITaskbarContent[] { diff --git a/src/sql/workbench/contrib/dashboard/browser/pages/databaseDashboardPage.component.ts b/src/sql/workbench/contrib/dashboard/browser/pages/databaseDashboardPage.component.ts index 05099beb37..b19e8ea6f0 100644 --- a/src/sql/workbench/contrib/dashboard/browser/pages/databaseDashboardPage.component.ts +++ b/src/sql/workbench/contrib/dashboard/browser/pages/databaseDashboardPage.component.ts @@ -22,6 +22,7 @@ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IMenuService } from 'vs/platform/actions/common/actions'; import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; +import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; export class DatabaseDashboardPage extends DashboardPage implements OnInit { protected propertiesWidget: WidgetConfig = { @@ -52,9 +53,10 @@ export class DatabaseDashboardPage extends DashboardPage implements OnInit { @Inject(IContextKeyService) contextKeyService: IContextKeyService, @Inject(IMenuService) menuService: IMenuService, @Inject(IWorkbenchThemeService) themeService: IWorkbenchThemeService, - @Inject(IInstantiationService) instantiationService: IInstantiationService + @Inject(IInstantiationService) instantiationService: IInstantiationService, + @Inject(IConfigurationService) configurationService: IConfigurationService ) { - super(dashboardService, el, _cd, notificationService, angularEventingService, logService, commandService, contextKeyService, menuService, themeService, instantiationService); + super(dashboardService, el, _cd, notificationService, angularEventingService, logService, commandService, contextKeyService, menuService, themeService, instantiationService, configurationService); this._register(dashboardService.onUpdatePage(() => { this.refresh(true); this._cd.detectChanges(); diff --git a/src/sql/workbench/contrib/dashboard/browser/pages/serverDashboardPage.component.ts b/src/sql/workbench/contrib/dashboard/browser/pages/serverDashboardPage.component.ts index 961abed5d3..786909f0c9 100644 --- a/src/sql/workbench/contrib/dashboard/browser/pages/serverDashboardPage.component.ts +++ b/src/sql/workbench/contrib/dashboard/browser/pages/serverDashboardPage.component.ts @@ -24,6 +24,7 @@ import { IMenuService } from 'vs/platform/actions/common/actions'; import { onUnexpectedError } from 'vs/base/common/errors'; import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; +import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; export class ServerDashboardPage extends DashboardPage implements OnInit { protected propertiesWidget: WidgetConfig = { @@ -55,9 +56,10 @@ export class ServerDashboardPage extends DashboardPage implements OnInit { @Inject(IContextKeyService) contextKeyService: IContextKeyService, @Inject(IMenuService) menuService: IMenuService, @Inject(IWorkbenchThemeService) themeService: IWorkbenchThemeService, - @Inject(IInstantiationService) instantiationService: IInstantiationService + @Inject(IInstantiationService) instantiationService: IInstantiationService, + @Inject(IConfigurationService) configurationService: IConfigurationService ) { - super(dashboardService, el, _cd, notificationService, angularEventingService, logService, commandService, contextKeyService, menuService, themeService, instantiationService); + super(dashboardService, el, _cd, notificationService, angularEventingService, logService, commandService, contextKeyService, menuService, themeService, instantiationService, configurationService); // special-case handling for MSSQL data provider const connInfo = this.dashboardService.connectionManagementService.connectionInfo;