enable 'New Notebook' entry points for PG SQL (#5194)

* enable 'New Notebook' entry points for PG SQL

* fix comment

* permanent fix for context menu entry point
This commit is contained in:
Alan Ren
2019-04-25 16:23:01 -07:00
committed by GitHub
parent 6528c0817d
commit 705e7b30bc
6 changed files with 23 additions and 8 deletions

View File

@@ -5,6 +5,7 @@
import { RawContextKey, IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IConnectionProfile } from 'azdata';
import { IQueryManagementService } from 'sql/platform/query/common/queryManagement';
export class ConnectionContextKey implements IContextKey<IConnectionProfile> {
@@ -12,26 +13,32 @@ export class ConnectionContextKey implements IContextKey<IConnectionProfile> {
static Server = new RawContextKey<string>('serverName', undefined);
static Database = new RawContextKey<string>('databaseName', undefined);
static Connection = new RawContextKey<IConnectionProfile>('connection', undefined);
static IsQueryProvider = new RawContextKey<boolean>('isQueryProvider', false);
private _providerKey: IContextKey<string>;
private _serverKey: IContextKey<string>;
private _databaseKey: IContextKey<string>;
private _connectionKey: IContextKey<IConnectionProfile>;
private _isQueryProviderKey: IContextKey<boolean>;
constructor(
@IContextKeyService contextKeyService: IContextKeyService
@IContextKeyService contextKeyService: IContextKeyService,
@IQueryManagementService private queryManagementService: IQueryManagementService
) {
this._providerKey = ConnectionContextKey.Provider.bindTo(contextKeyService);
this._serverKey = ConnectionContextKey.Server.bindTo(contextKeyService);
this._databaseKey = ConnectionContextKey.Database.bindTo(contextKeyService);
this._connectionKey = ConnectionContextKey.Connection.bindTo(contextKeyService);
this._isQueryProviderKey = ConnectionContextKey.IsQueryProvider.bindTo(contextKeyService);
}
set(value: IConnectionProfile) {
let queryProviders = this.queryManagementService.getRegisteredProviders();
this._connectionKey.set(value);
this._providerKey.set(value && value.providerName);
this._serverKey.set(value && value.serverName);
this._databaseKey.set(value && value.databaseName);
this._isQueryProviderKey.set(value && value.providerName && queryProviders.indexOf(value.providerName) !== -1);
}
reset(): void {
@@ -39,6 +46,7 @@ export class ConnectionContextKey implements IContextKey<IConnectionProfile> {
this._serverKey.reset();
this._databaseKey.reset();
this._connectionKey.reset();
this._isQueryProviderKey.reset();
}
public get(): IConnectionProfile {