Fix zoom reset behavior when adding new connection (#21040)

This commit is contained in:
Cheena Malhotra
2022-11-01 09:53:58 -07:00
committed by GitHub
parent 7ee9a22f03
commit 1de199dbd6
8 changed files with 22 additions and 33 deletions

View File

@@ -6,7 +6,7 @@
import 'vs/css!./media/breadcrumb'; import 'vs/css!./media/breadcrumb';
import { Component, Inject, forwardRef, OnInit, OnDestroy, ChangeDetectorRef } from '@angular/core'; import { Component, Inject, forwardRef, OnInit, OnDestroy, ChangeDetectorRef } from '@angular/core';
import { Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { IBreadcrumbService, MenuItem } from './interfaces'; import { IBreadcrumbService, MenuItem } from './interfaces';
@@ -36,6 +36,7 @@ export class BreadcrumbComponent implements OnInit, OnDestroy {
constructor( constructor(
@Inject(forwardRef(() => IBreadcrumbService)) private _breadcrumbService: IBreadcrumbService, @Inject(forwardRef(() => IBreadcrumbService)) private _breadcrumbService: IBreadcrumbService,
@Inject(forwardRef(() => Router)) private _router: Router, @Inject(forwardRef(() => Router)) private _router: Router,
@Inject(forwardRef(() => ActivatedRoute)) private _activeRoute: ActivatedRoute,
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef @Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef
) { } ) { }
@@ -53,6 +54,6 @@ export class BreadcrumbComponent implements OnInit, OnDestroy {
} }
public route(link: any[]): Promise<boolean> { public route(link: any[]): Promise<boolean> {
return this._router.navigate(link); return this._router.navigate(link, { relativeTo: this._activeRoute, skipLocationChange: true });
} }
} }

View File

@@ -31,7 +31,7 @@ import * as nls from 'vs/nls';
import * as objects from 'vs/base/common/objects'; import * as objects from 'vs/base/common/objects';
import { Event, Emitter } from 'vs/base/common/event'; import { Event, Emitter } from 'vs/base/common/event';
import { Action, IAction, SubmenuAction } from 'vs/base/common/actions'; import { Action, IAction, SubmenuAction } from 'vs/base/common/actions';
import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
import Severity from 'vs/base/common/severity'; import Severity from 'vs/base/common/severity';
import { INotificationService } from 'vs/platform/notification/common/notification'; import { INotificationService } from 'vs/platform/notification/common/notification';
import { IContextKeyService, ContextKeyExpr, RawContextKey, IContextKey } from 'vs/platform/contextkey/common/contextkey'; import { IContextKeyService, ContextKeyExpr, RawContextKey, IContextKey } from 'vs/platform/contextkey/common/contextkey';
@@ -54,11 +54,9 @@ import { LabeledMenuItemActionItem } from 'sql/platform/actions/browser/menuEntr
import { DASHBOARD_BORDER, TOOLBAR_OVERFLOW_SHADOW } from 'sql/workbench/common/theme'; import { DASHBOARD_BORDER, TOOLBAR_OVERFLOW_SHADOW } from 'sql/workbench/common/theme';
import { IActionViewItem } from 'vs/base/browser/ui/actionbar/actionbar'; import { IActionViewItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { onUnexpectedError } from 'vs/base/common/errors';
const dashboardRegistry = Registry.as<IDashboardRegistry>(DashboardExtensions.DashboardContributions); const dashboardRegistry = Registry.as<IDashboardRegistry>(DashboardExtensions.DashboardContributions);
const homeTabGroupId = 'home'; const homeTabGroupId = 'home';
const zoomLevelConfiguration = 'window.zoomLevel';
@Component({ @Component({
selector: 'dashboard-page', selector: 'dashboard-page',
@@ -132,8 +130,7 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
@Inject(IContextKeyService) contextKeyService: IContextKeyService, @Inject(IContextKeyService) contextKeyService: IContextKeyService,
@Inject(IMenuService) private menuService: IMenuService, @Inject(IMenuService) private menuService: IMenuService,
@Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService, @Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService,
@Inject(IInstantiationService) private instantiationService: IInstantiationService, @Inject(IInstantiationService) private instantiationService: IInstantiationService
@Inject(IConfigurationService) private configurationService: IConfigurationService
) { ) {
super(); super();
this._tabName = DashboardPage.tabName.bindTo(contextKeyService); this._tabName = DashboardPage.tabName.bindTo(contextKeyService);
@@ -175,16 +172,6 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
this._register(this.themeService.onDidColorThemeChange((event: IColorTheme) => { this._register(this.themeService.onDidColorThemeChange((event: IColorTheme) => {
this.updateTheme(event); 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[] { private getContributedTasks(tabId: string): ITaskbarContent[] {

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information. * Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { OnInit, Component, Inject, forwardRef, ElementRef, ViewChild } from '@angular/core'; import { OnInit, Component, Inject, forwardRef, ElementRef, ViewChild } from '@angular/core';
import { Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { CommonServiceInterface } from 'sql/workbench/services/bootstrap/browser/commonServiceInterface.service'; import { CommonServiceInterface } from 'sql/workbench/services/bootstrap/browser/commonServiceInterface.service';
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces'; import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
@@ -31,6 +31,7 @@ export class DashboardComponent extends AngularDisposable implements OnInit {
constructor( constructor(
@Inject(forwardRef(() => CommonServiceInterface)) private _bootstrapService: CommonServiceInterface, @Inject(forwardRef(() => CommonServiceInterface)) private _bootstrapService: CommonServiceInterface,
@Inject(forwardRef(() => Router)) private _router: Router, @Inject(forwardRef(() => Router)) private _router: Router,
@Inject(forwardRef(() => ActivatedRoute)) private _activeRoute: ActivatedRoute,
@Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService @Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService
) { ) {
super(); super();
@@ -42,7 +43,7 @@ export class DashboardComponent extends AngularDisposable implements OnInit {
const profile: IConnectionProfile = this._bootstrapService.getOriginalConnectionProfile(); const profile: IConnectionProfile = this._bootstrapService.getOriginalConnectionProfile();
if (profile && (!profile.databaseName || Utils.isServerConnection(profile))) { if (profile && (!profile.databaseName || Utils.isServerConnection(profile))) {
// Route to the server page as this is the default database // Route to the server page as this is the default database
this._router.navigate(['server-dashboard']).catch(onUnexpectedError); this._router.navigate(['server-dashboard'], { relativeTo: this._activeRoute, skipLocationChange: true }).catch(onUnexpectedError);
} }
} }

View File

@@ -22,7 +22,6 @@ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IMenuService } from 'vs/platform/actions/common/actions'; import { IMenuService } from 'vs/platform/actions/common/actions';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
export class DatabaseDashboardPage extends DashboardPage implements OnInit { export class DatabaseDashboardPage extends DashboardPage implements OnInit {
protected propertiesWidget: WidgetConfig = { protected propertiesWidget: WidgetConfig = {
@@ -53,10 +52,9 @@ export class DatabaseDashboardPage extends DashboardPage implements OnInit {
@Inject(IContextKeyService) contextKeyService: IContextKeyService, @Inject(IContextKeyService) contextKeyService: IContextKeyService,
@Inject(IMenuService) menuService: IMenuService, @Inject(IMenuService) menuService: IMenuService,
@Inject(IWorkbenchThemeService) themeService: IWorkbenchThemeService, @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, configurationService); super(dashboardService, el, _cd, notificationService, angularEventingService, logService, commandService, contextKeyService, menuService, themeService, instantiationService);
this._register(dashboardService.onUpdatePage(() => { this._register(dashboardService.onUpdatePage(() => {
this.refresh(true); this.refresh(true);
this._cd.detectChanges(); this._cd.detectChanges();

View File

@@ -24,7 +24,6 @@ import { IMenuService } from 'vs/platform/actions/common/actions';
import { onUnexpectedError } from 'vs/base/common/errors'; import { onUnexpectedError } from 'vs/base/common/errors';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
export class ServerDashboardPage extends DashboardPage implements OnInit { export class ServerDashboardPage extends DashboardPage implements OnInit {
protected propertiesWidget: WidgetConfig = { protected propertiesWidget: WidgetConfig = {
@@ -56,10 +55,9 @@ export class ServerDashboardPage extends DashboardPage implements OnInit {
@Inject(IContextKeyService) contextKeyService: IContextKeyService, @Inject(IContextKeyService) contextKeyService: IContextKeyService,
@Inject(IMenuService) menuService: IMenuService, @Inject(IMenuService) menuService: IMenuService,
@Inject(IWorkbenchThemeService) themeService: IWorkbenchThemeService, @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, configurationService); super(dashboardService, el, _cd, notificationService, angularEventingService, logService, commandService, contextKeyService, menuService, themeService, instantiationService);
// special-case handling for MSSQL data provider // special-case handling for MSSQL data provider
const connInfo = this.dashboardService.connectionManagementService.connectionInfo; const connInfo = this.dashboardService.connectionManagementService.connectionInfo;

View File

@@ -5,7 +5,7 @@
/* Node Modules */ /* Node Modules */
import { Injectable, Inject, forwardRef } from '@angular/core'; import { Injectable, Inject, forwardRef } from '@angular/core';
import { Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
/* SQL imports */ /* SQL imports */
import { IDashboardComponentParams, IBootstrapParams } from 'sql/workbench/services/bootstrap/common/bootstrapParams'; import { IDashboardComponentParams, IBootstrapParams } from 'sql/workbench/services/bootstrap/common/bootstrapParams';
@@ -69,6 +69,7 @@ export class DashboardServiceInterface extends CommonServiceInterface {
@Inject(IQueryManagementService) queryManagementService: IQueryManagementService, @Inject(IQueryManagementService) queryManagementService: IQueryManagementService,
@Inject(IBootstrapParams) params: IDashboardComponentParams, @Inject(IBootstrapParams) params: IDashboardComponentParams,
@Inject(forwardRef(() => Router)) private _router: Router, @Inject(forwardRef(() => Router)) private _router: Router,
@Inject(forwardRef(() => ActivatedRoute)) private _activeRoute: ActivatedRoute,
@Inject(INotificationService) private _notificationService: INotificationService, @Inject(INotificationService) private _notificationService: INotificationService,
@Inject(IAngularEventingService) private angularEventingService: IAngularEventingService, @Inject(IAngularEventingService) private angularEventingService: IAngularEventingService,
@Inject(IConfigurationService) private _configService: IConfigurationService @Inject(IConfigurationService) private _configService: IConfigurationService
@@ -117,7 +118,7 @@ export class DashboardServiceInterface extends CommonServiceInterface {
if (this._router.url === '/database-dashboard') { if (this._router.url === '/database-dashboard') {
this._updatePage.fire(); this._updatePage.fire();
} else { } else {
this._router.navigate(['database-dashboard']).catch(onUnexpectedError); this._router.navigate(['database-dashboard'], { relativeTo: this._activeRoute, skipLocationChange: true }).catch(onUnexpectedError);
} }
} else { } else {
this._notificationService.notify({ this._notificationService.notify({
@@ -135,7 +136,7 @@ export class DashboardServiceInterface extends CommonServiceInterface {
); );
break; break;
case AngularEventType.NAV_SERVER: case AngularEventType.NAV_SERVER:
this._router.navigate(['server-dashboard']).catch(onUnexpectedError); this._router.navigate(['server-dashboard'], { relativeTo: this._activeRoute, skipLocationChange: true }).catch(onUnexpectedError);
break; break;
case AngularEventType.DELETE_WIDGET: case AngularEventType.DELETE_WIDGET:
this._onDeleteWidget.fire(event.payload.id); this._onDeleteWidget.fire(event.payload.id);

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information. * Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { ButtonColumn } from 'sql/base/browser/ui/table/plugins/buttonColumn.plugin'; import { ButtonColumn } from 'sql/base/browser/ui/table/plugins/buttonColumn.plugin';
import { RowSelectionModel } from 'sql/base/browser/ui/table/plugins/rowSelectionModel.plugin'; import { RowSelectionModel } from 'sql/base/browser/ui/table/plugins/rowSelectionModel.plugin';
import { IconCellValue } from 'sql/base/browser/ui/table/plugins/tableColumn'; import { IconCellValue } from 'sql/base/browser/ui/table/plugins/tableColumn';
@@ -53,6 +53,7 @@ export class ExplorerTable extends Disposable {
private _propertiesToDisplay: ObjectListViewProperty[]; private _propertiesToDisplay: ObjectListViewProperty[];
constructor(private parentElement: HTMLElement, constructor(private parentElement: HTMLElement,
private readonly activeRoute: ActivatedRoute,
private readonly router: Router, private readonly router: Router,
private readonly context: string, private readonly context: string,
private readonly bootStrapService: CommonServiceInterface, private readonly bootStrapService: CommonServiceInterface,
@@ -150,7 +151,7 @@ export class ExplorerTable extends Disposable {
private handleDoubleClick(item: Slick.SlickData): void { private handleDoubleClick(item: Slick.SlickData): void {
if (this.context === 'server') { if (this.context === 'server') {
this.progressService.showWhile(this.bootStrapService.connectionManagementService.changeDatabase(item[NameProperty]).then(result => { this.progressService.showWhile(this.bootStrapService.connectionManagementService.changeDatabase(item[NameProperty]).then(result => {
this.router.navigate(['database-dashboard']).catch(onUnexpectedError); this.router.navigate(['database-dashboard'], { relativeTo: this.activeRoute, skipLocationChange: true }).catch(onUnexpectedError);
})); }));
} }
} }

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { ChangeDetectorRef, Component, ElementRef, forwardRef, Inject, OnInit, ViewChild } from '@angular/core'; import { ChangeDetectorRef, Component, ElementRef, forwardRef, Inject, OnInit, ViewChild } from '@angular/core';
import { Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { DatabaseInfo } from 'azdata'; import { DatabaseInfo } from 'azdata';
import { subscriptionToDisposable } from 'sql/base/browser/lifecycle'; import { subscriptionToDisposable } from 'sql/base/browser/lifecycle';
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService'; import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
@@ -46,6 +46,7 @@ export class ExplorerWidget extends DashboardWidget implements IDashboardWidget,
constructor( constructor(
@Inject(forwardRef(() => CommonServiceInterface)) private readonly _bootstrap: CommonServiceInterface, @Inject(forwardRef(() => CommonServiceInterface)) private readonly _bootstrap: CommonServiceInterface,
@Inject(forwardRef(() => ActivatedRoute)) private _activeRoute: ActivatedRoute,
@Inject(forwardRef(() => Router)) private readonly _router: Router, @Inject(forwardRef(() => Router)) private readonly _router: Router,
@Inject(WIDGET_CONFIG) _config: WidgetConfig, @Inject(WIDGET_CONFIG) _config: WidgetConfig,
@Inject(forwardRef(() => ElementRef)) private readonly _el: ElementRef, @Inject(forwardRef(() => ElementRef)) private readonly _el: ElementRef,
@@ -81,6 +82,7 @@ export class ExplorerWidget extends DashboardWidget implements IDashboardWidget,
}; };
this._input = new InputBox(this._inputContainer.nativeElement, this.contextViewService, inputOptions); this._input = new InputBox(this._inputContainer.nativeElement, this.contextViewService, inputOptions);
this._table = new ExplorerTable(this._tableContainer.nativeElement, this._table = new ExplorerTable(this._tableContainer.nativeElement,
this._activeRoute,
this._router, this._router,
this._config.context, this._config.context,
this._bootstrap, this._bootstrap,