From 722f5e56cd3efa024ec45f7e85f9a43f7f444dc5 Mon Sep 17 00:00:00 2001 From: Anthony Dresser Date: Tue, 13 Mar 2018 13:54:37 -0700 Subject: [PATCH] Add dashboard context (database vs server) to scoped context (#893) * explicitly add dashboard context to scoped context * formatting --- src/sql/parts/dashboard/common/dashboardPage.component.ts | 1 + .../dashboard/pages/databaseDashboardPage.component.ts | 1 - .../dashboard/services/dashboardServiceInterface.service.ts | 6 +++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/sql/parts/dashboard/common/dashboardPage.component.ts b/src/sql/parts/dashboard/common/dashboardPage.component.ts index 0ee8147898..85a67f861c 100644 --- a/src/sql/parts/dashboard/common/dashboardPage.component.ts +++ b/src/sql/parts/dashboard/common/dashboardPage.component.ts @@ -95,6 +95,7 @@ export abstract class DashboardPage extends AngularDisposable { } protected init() { + this.dashboardService.dashboardContextKey.set(this.context); if (!this.dashboardService.connectionManagementService.connectionInfo) { this.dashboardService.messageService.show(Severity.Warning, nls.localize('missingConnectionInfo', 'No connection information could be found for this dashboard')); } else { diff --git a/src/sql/parts/dashboard/pages/databaseDashboardPage.component.ts b/src/sql/parts/dashboard/pages/databaseDashboardPage.component.ts index e03fb9d382..66124f8b79 100644 --- a/src/sql/parts/dashboard/pages/databaseDashboardPage.component.ts +++ b/src/sql/parts/dashboard/pages/databaseDashboardPage.component.ts @@ -44,7 +44,6 @@ export class DatabaseDashboardPage extends DashboardPage implements OnInit { this.refresh(true); this._cd.detectChanges(); })); - } ngOnInit() { diff --git a/src/sql/parts/dashboard/services/dashboardServiceInterface.service.ts b/src/sql/parts/dashboard/services/dashboardServiceInterface.service.ts index f44f2bea31..c7cd17db31 100644 --- a/src/sql/parts/dashboard/services/dashboardServiceInterface.service.ts +++ b/src/sql/parts/dashboard/services/dashboardServiceInterface.service.ts @@ -44,7 +44,7 @@ import * as nls from 'vs/nls'; import { IPartService } from 'vs/workbench/services/part/common/partService'; import { deepClone } from 'vs/base/common/objects'; import { ICommandService } from 'vs/platform/commands/common/commands'; -import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; +import { IContextKeyService, RawContextKey, IContextKey } from 'vs/platform/contextkey/common/contextkey'; const DASHBOARD_SETTINGS = 'dashboard'; @@ -157,6 +157,9 @@ export class DashboardServiceInterface extends AngularDisposable { private _onCloseTab = new Emitter(); public readonly onCloseTab: Event = this._onCloseTab.event; + private _dashboardContextKey = new RawContextKey('dashboardContext', undefined); + public dashboardContextKey: IContextKey; + private _numberOfPageNavigations = 0; constructor( @@ -250,6 +253,7 @@ export class DashboardServiceInterface extends AngularDisposable { this._bootstrapParams = this._bootstrapService.getBootstrapParams(this._uniqueSelector); this.uri = this._bootstrapParams.ownerUri; this._contextKeyService = this._bootstrapParams.scopedContextService; + this.dashboardContextKey = this._dashboardContextKey.bindTo(this._contextKeyService); } /**