Make azure portal work from server area (#10699)

This commit is contained in:
Amir Omidi
2020-06-03 14:02:23 -07:00
committed by GitHub
parent 61dce39f5a
commit 3860f07cab
4 changed files with 74 additions and 13 deletions

View File

@@ -14,12 +14,15 @@ export class ConnectionContextKey implements IContextKey<IConnectionProfile> {
static Database = new RawContextKey<string>('databaseName', undefined);
static Connection = new RawContextKey<IConnectionProfile>('connection', undefined);
static IsQueryProvider = new RawContextKey<boolean>('isQueryProvider', false);
static CanOpenInAzurePortal = new RawContextKey<boolean>('canOpenInAzurePortal', false);
private _providerKey: IContextKey<string>;
private _serverKey: IContextKey<string>;
private _databaseKey: IContextKey<string>;
private _connectionKey: IContextKey<IConnectionProfile>;
private _isQueryProviderKey: IContextKey<boolean>;
private _canOpenInAzurePortal: IContextKey<boolean>;
constructor(
@IContextKeyService contextKeyService: IContextKeyService,
@@ -30,9 +33,11 @@ export class ConnectionContextKey implements IContextKey<IConnectionProfile> {
this._databaseKey = ConnectionContextKey.Database.bindTo(contextKeyService);
this._connectionKey = ConnectionContextKey.Connection.bindTo(contextKeyService);
this._isQueryProviderKey = ConnectionContextKey.IsQueryProvider.bindTo(contextKeyService);
this._canOpenInAzurePortal = ConnectionContextKey.CanOpenInAzurePortal.bindTo(contextKeyService);
}
set(value: IConnectionProfile) {
this.setCanOpenInPortal(value);
let queryProviders = this.queryManagementService.getRegisteredProviders();
this._connectionKey.set(value);
this._providerKey.set(value && value.providerName);
@@ -41,12 +46,22 @@ export class ConnectionContextKey implements IContextKey<IConnectionProfile> {
this._isQueryProviderKey.set(value && value.providerName && queryProviders.indexOf(value.providerName) !== -1);
}
private setCanOpenInPortal(connectionProfile: IConnectionProfile): void {
if (connectionProfile &&
connectionProfile.azureResourceId &&
connectionProfile.azureTenantId &&
connectionProfile.azurePortalEndpoint) {
this._canOpenInAzurePortal.set(true);
}
}
reset(): void {
this._providerKey.reset();
this._serverKey.reset();
this._databaseKey.reset();
this._connectionKey.reset();
this._isQueryProviderKey.reset();
this._canOpenInAzurePortal.reset();
}
public get(): IConnectionProfile {