mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-24 17:23:05 -05:00
Make azure portal work from server area (#10699)
This commit is contained in:
@@ -5,14 +5,45 @@
|
||||
import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
|
||||
import { localize } from 'vs/nls';
|
||||
import { MssqlNodeContext } from 'sql/workbench/services/objectExplorer/browser/mssqlNodeContext';
|
||||
import { ConnectionContextKey } from 'sql/workbench/services/connection/common/connectionContextKey';
|
||||
import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { TreeViewItemHandleArg } from 'sql/workbench/common/views';
|
||||
import { ObjectExplorerActionsContext } from 'sql/workbench/services/objectExplorer/browser/objectExplorerActions';
|
||||
|
||||
const openInAzureDECommandId: string = 'azure.openInAzureCoreDE';
|
||||
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||
group: 'z-azurecore',
|
||||
order: 1,
|
||||
command: {
|
||||
id: 'azure.resource.openInAzurePortal',
|
||||
id: openInAzureDECommandId,
|
||||
title: localize('azure.openInAzurePortal.title', "Open in Azure Portal")
|
||||
},
|
||||
when: MssqlNodeContext.CanOpenInAzurePortal
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand({
|
||||
id: openInAzureDECommandId,
|
||||
handler: (accessor, args: TreeViewItemHandleArg) => {
|
||||
const commandService = accessor.get(ICommandService);
|
||||
return commandService.executeCommand('azure.resource.openInAzurePortal', args.$treeItem.payload);
|
||||
}
|
||||
});
|
||||
|
||||
const openInAzureOECommandId: string = 'azure.openInAzureCoreOE';
|
||||
MenuRegistry.appendMenuItem(MenuId.ObjectExplorerItemContext, {
|
||||
group: 'z-azurecore',
|
||||
order: 1,
|
||||
command: {
|
||||
id: openInAzureOECommandId,
|
||||
title: localize('azure.openInAzurePortal.title', "Open in Azure Portal")
|
||||
},
|
||||
when: ConnectionContextKey.CanOpenInAzurePortal
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand({
|
||||
id: openInAzureOECommandId,
|
||||
handler: (accessor, args: ObjectExplorerActionsContext) => {
|
||||
const commandService = accessor.get(ICommandService);
|
||||
return commandService.executeCommand('azure.resource.openInAzurePortal', args.connectionProfile);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user