mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-18 09:35:39 -05:00
Fix missing add azure account button in accountDialog (#15852)
* fix missing add azure account button in accoundDialog * add sql edit note * fix other getActions overrides * use registerAction2 for adding account button * fix icon and cleanup * fix big add account button * lint
This commit is contained in:
@@ -11,17 +11,18 @@ import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { attachButtonStyler, attachListStyler } from 'vs/platform/theme/common/styler';
|
||||
import { IAction } from 'vs/base/common/actions';
|
||||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { SplitView, Sizing } from 'vs/base/browser/ui/splitview/splitview';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { MenuId, Action2, registerAction2 } from 'vs/platform/actions/common/actions';
|
||||
import { IContextKeyService, ContextKeyEqualsExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
|
||||
import { Button } from 'sql/base/browser/ui/button/button';
|
||||
import { SqlIconId } from 'sql/base/common/codicons';
|
||||
import { HideReason, Modal } from 'sql/workbench/browser/modal/modal';
|
||||
import { AccountViewModel } from 'sql/platform/accounts/common/accountViewModel';
|
||||
import { AddAccountAction } from 'sql/platform/accounts/common/accountActions';
|
||||
@@ -66,7 +67,7 @@ class AccountPanel extends ViewPane {
|
||||
|
||||
|
||||
constructor(
|
||||
private options: IViewPaneOptions,
|
||||
options: IViewPaneOptions,
|
||||
@IKeybindingService keybindingService: IKeybindingService,
|
||||
@IContextMenuService contextMenuService: IContextMenuService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@@ -115,13 +116,6 @@ class AccountPanel extends ViewPane {
|
||||
private updateTenants(account: azdata.Account) {
|
||||
this.tenantList!.splice(0, this.tenantList!.length, account.properties?.tenants ?? []);
|
||||
}
|
||||
|
||||
public getActions(): IAction[] {
|
||||
return [this.instantiationService.createInstance(
|
||||
AddAccountAction,
|
||||
this.options.id
|
||||
)];
|
||||
}
|
||||
}
|
||||
|
||||
export interface IProviderViewUiComponent {
|
||||
@@ -231,33 +225,7 @@ export class AccountDialog extends Modal {
|
||||
this._addAccountButton.label = localize('accountDialog.addConnection', "Add an account");
|
||||
|
||||
this._register(this._addAccountButton.onDidClick(async () => {
|
||||
const vals = Iterable.consume(this._providerViewsMap.values())[0];
|
||||
|
||||
let pickedValue: string | undefined;
|
||||
if (vals.length === 0) {
|
||||
this._notificationService.error(localize('accountDialog.noCloudsRegistered', "You have no clouds enabled. Go to Settings -> Search Azure Account Configuration -> Enable at least one cloud"));
|
||||
return;
|
||||
}
|
||||
if (vals.length > 1) {
|
||||
const buttons: IQuickPickItem[] = vals.map(v => {
|
||||
return { label: v.view.title } as IQuickPickItem;
|
||||
});
|
||||
|
||||
const picked = await this._quickInputService.pick(buttons, { canPickMany: false });
|
||||
|
||||
pickedValue = picked?.label;
|
||||
} else {
|
||||
pickedValue = vals[0].view.title;
|
||||
}
|
||||
|
||||
const v = vals.filter(v => v.view.title === pickedValue)?.[0];
|
||||
|
||||
if (!v) {
|
||||
this._notificationService.error(localize('accountDialog.didNotPickAuthProvider', "You didn't select any authentication provider. Please try again."));
|
||||
return;
|
||||
}
|
||||
|
||||
v.addAccountAction.run();
|
||||
await this.runAddAccountAction();
|
||||
}));
|
||||
|
||||
DOM.append(container, this._noaccountViewContainer);
|
||||
@@ -374,6 +342,8 @@ export class AccountDialog extends Modal {
|
||||
ctorDescriptor: new SyncDescriptor(AccountPanel),
|
||||
}], ACCOUNT_VIEW_CONTAINER);
|
||||
|
||||
this.registerActions(newProvider.addedProvider.id);
|
||||
|
||||
attachPanelStyler(providerView, this._themeService);
|
||||
|
||||
const insertIndex = this._splitView!.length;
|
||||
@@ -431,4 +401,58 @@ export class AccountDialog extends Modal {
|
||||
|
||||
this.layout();
|
||||
}
|
||||
|
||||
private registerActions(viewId: string) {
|
||||
const that = this;
|
||||
registerAction2(class extends Action2 {
|
||||
constructor() {
|
||||
super({
|
||||
id: `workbench.actions.accountDialog.${viewId}.addAccount`,
|
||||
title: { value: localize('accountDialog.addConnection', "Add an account"), original: 'Add an account' },
|
||||
f1: true,
|
||||
icon: { id: SqlIconId.addAccountAction },
|
||||
menu: {
|
||||
id: MenuId.ViewTitle,
|
||||
group: 'navigation',
|
||||
when: ContextKeyEqualsExpr.create('view', viewId),
|
||||
order: 1
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async run() {
|
||||
await that.runAddAccountAction();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private async runAddAccountAction() {
|
||||
const vals = Iterable.consume(this._providerViewsMap.values())[0];
|
||||
|
||||
let pickedValue: string | undefined;
|
||||
if (vals.length === 0) {
|
||||
this._notificationService.error(localize('accountDialog.noCloudsRegistered', "You have no clouds enabled. Go to Settings -> Search Azure Account Configuration -> Enable at least one cloud"));
|
||||
return;
|
||||
}
|
||||
if (vals.length > 1) {
|
||||
const buttons: IQuickPickItem[] = vals.map(v => {
|
||||
return { label: v.view.title } as IQuickPickItem;
|
||||
});
|
||||
|
||||
const picked = await this._quickInputService.pick(buttons, { canPickMany: false });
|
||||
|
||||
pickedValue = picked?.label;
|
||||
} else {
|
||||
pickedValue = vals[0].view.title;
|
||||
}
|
||||
|
||||
const v = vals.filter(v => v.view.title === pickedValue)?.[0];
|
||||
|
||||
if (!v) {
|
||||
this._notificationService.error(localize('accountDialog.didNotPickAuthProvider', "You didn't select any authentication provider. Please try again."));
|
||||
return;
|
||||
}
|
||||
|
||||
v.addAccountAction.run();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/* Icons for various account actions */
|
||||
.vs .action-item .codicon.add-linked-account-action {
|
||||
background-image: url('new_account.svg');
|
||||
.monaco-workbench .account-view .actions-container .action-label.codicon-add-linked-account-action {
|
||||
background-image: url('new_account.svg') !important;
|
||||
}
|
||||
|
||||
.vs-dark .action-item .codicon.add-linked-account-action,
|
||||
.hc-black .action-item .codicon.add-linked-account-action {
|
||||
background-image: url('new_account_inverse.svg');
|
||||
.monaco-workbench.vs-dark .account-view .actions-container .action-label.codicon-add-linked-account-action,
|
||||
.monaco-workbench.hc-black .account-view .actions-container .action-label.codicon-add-linked-account-action {
|
||||
background-image: url('new_account_inverse.svg') !important;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user