diff --git a/src/sql/parts/connection/common/connectionContextKey.ts b/src/sql/parts/connection/common/connectionContextKey.ts index cf7d5e0fe9..35930f00c6 100644 --- a/src/sql/parts/connection/common/connectionContextKey.ts +++ b/src/sql/parts/connection/common/connectionContextKey.ts @@ -12,7 +12,7 @@ export class ConnectionContextkey implements IContextKey { static Provider = new RawContextKey('connectionProvider', undefined); static Server = new RawContextKey('serverName', undefined); - static Database = new RawContextKey('databasename', undefined); + static Database = new RawContextKey('databaseName', undefined); static Connection = new RawContextKey('connection', undefined); private _providerKey: IContextKey; diff --git a/src/sql/parts/dashboard/dashboardEditor.ts b/src/sql/parts/dashboard/dashboardEditor.ts index 68a660c3d0..0dd4a1c924 100644 --- a/src/sql/parts/dashboard/dashboardEditor.ts +++ b/src/sql/parts/dashboard/dashboardEditor.ts @@ -20,8 +20,8 @@ import { DashboardComponentParams } from 'sql/services/bootstrap/bootstrapParams import { DASHBOARD_SELECTOR } from 'sql/parts/dashboard/dashboard.component'; import { ConnectionContextkey } from 'sql/parts/connection/common/connectionContextKey'; import { IDashboardService } from 'sql/services/dashboard/common/dashboardService'; -import { ConnectionProfile } from '../connection/common/connectionProfile'; -import { IConnectionProfile } from 'sqlops'; +import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile'; +import { IConnectionProfile } from 'sql/parts/connection/common/interfaces'; import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement'; export class DashboardEditor extends BaseEditor { @@ -117,7 +117,8 @@ export class DashboardEditor extends BaseEditor { let params: DashboardComponentParams = { connection: input.connectionProfile, ownerUri: input.uri, - scopedContextService: scopedContextService + scopedContextService, + connectionContextKey }; input.hasBootstrapped = true; diff --git a/src/sql/parts/dashboard/services/dashboardServiceInterface.service.ts b/src/sql/parts/dashboard/services/dashboardServiceInterface.service.ts index c7cd17db31..32babd7add 100644 --- a/src/sql/parts/dashboard/services/dashboardServiceInterface.service.ts +++ b/src/sql/parts/dashboard/services/dashboardServiceInterface.service.ts @@ -25,6 +25,7 @@ import { IDashboardTab } from 'sql/platform/dashboard/common/dashboardRegistry'; import { TabSettingConfig } from 'sql/parts/dashboard/common/dashboardWidget'; import { IDashboardWebviewService } from 'sql/services/dashboardWebview/common/dashboardWebviewService'; import { AngularDisposable } from 'sql/base/common/lifecycle'; +import { ConnectionContextkey } from 'sql/parts/connection/common/connectionContextKey'; import { ProviderMetadata, DatabaseInfo, SimpleExecuteResult } from 'sqlops'; @@ -70,11 +71,16 @@ export class SingleConnectionManagementService { constructor( private _connectionService: IConnectionManagementService, - private _uri: string + private _uri: string, + private _contextKey: ConnectionContextkey ) { } public changeDatabase(name: string): Thenable { - return this._connectionService.changeDatabase(this._uri, name); + return this._connectionService.changeDatabase(this._uri, name).then(e => { + // we need to update our context + this._contextKey.set(this.connectionInfo.connectionProfile); + return e; + }); } public get connectionInfo(): ConnectionManagementInfo { @@ -160,6 +166,8 @@ export class DashboardServiceInterface extends AngularDisposable { private _dashboardContextKey = new RawContextKey('dashboardContext', undefined); public dashboardContextKey: IContextKey; + private _connectionContextKey: ConnectionContextkey; + private _numberOfPageNavigations = 0; constructor( @@ -251,9 +259,10 @@ export class DashboardServiceInterface extends AngularDisposable { private _getbootstrapParams(): void { this._bootstrapParams = this._bootstrapService.getBootstrapParams(this._uniqueSelector); - this.uri = this._bootstrapParams.ownerUri; this._contextKeyService = this._bootstrapParams.scopedContextService; + this._connectionContextKey = this._bootstrapParams.connectionContextKey; this.dashboardContextKey = this._dashboardContextKey.bindTo(this._contextKeyService); + this.uri = this._bootstrapParams.ownerUri; } /** @@ -263,7 +272,7 @@ export class DashboardServiceInterface extends AngularDisposable { private set uri(uri: string) { this._uri = uri; this._metadataService = new SingleConnectionMetadataService(this._bootstrapService.metadataService, this._uri); - this._connectionManagementService = new SingleConnectionManagementService(this._bootstrapService.connectionManagementService, this._uri); + this._connectionManagementService = new SingleConnectionManagementService(this._bootstrapService.connectionManagementService, this._uri, this._connectionContextKey); this._adminService = new SingleAdminService(this._bootstrapService.adminService, this._uri); this._queryManagementService = new SingleQueryManagementService(this._bootstrapService.queryManagementService, this._uri); this._register(toDisposableSubscription(this._bootstrapService.angularEventingService.onAngularEvent(this._uri, (event) => this.handleDashboardEvent(event)))); diff --git a/src/sql/services/bootstrap/bootstrapParams.ts b/src/sql/services/bootstrap/bootstrapParams.ts index e035024676..a2a69496d3 100644 --- a/src/sql/services/bootstrap/bootstrapParams.ts +++ b/src/sql/services/bootstrap/bootstrapParams.ts @@ -5,7 +5,8 @@ import { DataService } from 'sql/parts/grid/services/dataService'; import { IConnectionProfile } from 'sql/parts/connection/common/interfaces'; -import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; +import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey'; +import { ConnectionContextkey } from 'sql/parts/connection/common/connectionContextKey'; export interface BootstrapParams { } @@ -22,6 +23,7 @@ export interface DashboardComponentParams extends BootstrapParams { connection: IConnectionProfile; ownerUri: string; scopedContextService: IContextKeyService; + connectionContextKey: ConnectionContextkey; } export interface TaskDialogComponentParams extends BootstrapParams {