mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Move account management icon to action bar (#11173)
This commit is contained in:
@@ -0,0 +1,52 @@
|
|||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
import * as DOM from 'vs/base/browser/dom';
|
||||||
|
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||||
|
import { EventType as TouchEventType, GestureEvent } from 'vs/base/browser/touch';
|
||||||
|
import { KeyCode } from 'vs/base/common/keyCodes';
|
||||||
|
import { IMenuService } from 'vs/platform/actions/common/actions';
|
||||||
|
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||||
|
import { IColorTheme, IThemeService } from 'vs/platform/theme/common/themeService';
|
||||||
|
import { ActivityAction, ActivityActionViewItem, ICompositeBarColors } from 'vs/workbench/browser/parts/compositeBarActions';
|
||||||
|
import { IAccountManagementService } from 'sql/platform/accounts/common/interfaces';
|
||||||
|
|
||||||
|
export class AccountsActionViewItem extends ActivityActionViewItem {
|
||||||
|
constructor(
|
||||||
|
action: ActivityAction,
|
||||||
|
colors: (theme: IColorTheme) => ICompositeBarColors,
|
||||||
|
@IThemeService themeService: IThemeService,
|
||||||
|
@IContextMenuService protected contextMenuService: IContextMenuService,
|
||||||
|
@IMenuService protected menuService: IMenuService,
|
||||||
|
@IAccountManagementService private readonly accountManagementService: IAccountManagementService
|
||||||
|
) {
|
||||||
|
super(action, { draggable: false, colors, icon: true }, themeService);
|
||||||
|
}
|
||||||
|
|
||||||
|
render(container: HTMLElement): void {
|
||||||
|
super.render(container);
|
||||||
|
|
||||||
|
// Context menus are triggered on mouse down so that an item can be picked
|
||||||
|
// and executed with releasing the mouse over it
|
||||||
|
|
||||||
|
this._register(DOM.addDisposableListener(this.container, DOM.EventType.MOUSE_DOWN, (e: MouseEvent) => {
|
||||||
|
DOM.EventHelper.stop(e, true);
|
||||||
|
this.accountManagementService.openAccountListDialog();
|
||||||
|
}));
|
||||||
|
|
||||||
|
this._register(DOM.addDisposableListener(this.container, DOM.EventType.KEY_UP, (e: KeyboardEvent) => {
|
||||||
|
let event = new StandardKeyboardEvent(e);
|
||||||
|
if (event.equals(KeyCode.Enter) || event.equals(KeyCode.Space)) {
|
||||||
|
DOM.EventHelper.stop(e, true);
|
||||||
|
this.accountManagementService.openAccountListDialog();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
this._register(DOM.addDisposableListener(this.container, TouchEventType.Tap, (e: GestureEvent) => {
|
||||||
|
DOM.EventHelper.stop(e, true);
|
||||||
|
this.accountManagementService.openAccountListDialog();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,39 +3,11 @@
|
|||||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import { Registry } from 'vs/platform/registry/common/platform';
|
|
||||||
import { Disposable } from 'vs/base/common/lifecycle';
|
|
||||||
import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
|
|
||||||
import { IStatusbarService, StatusbarAlignment } from 'vs/workbench/services/statusbar/common/statusbar';
|
|
||||||
import { localize } from 'vs/nls';
|
|
||||||
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
|
||||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||||
import { IAccountManagementService } from 'sql/platform/accounts/common/interfaces';
|
import { IAccountManagementService } from 'sql/platform/accounts/common/interfaces';
|
||||||
|
|
||||||
const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
|
|
||||||
|
|
||||||
CommandsRegistry.registerCommand('workbench.actions.modal.linkedAccount', accessor => {
|
CommandsRegistry.registerCommand('workbench.actions.modal.linkedAccount', accessor => {
|
||||||
const accountManagementService = accessor.get(IAccountManagementService);
|
const accountManagementService = accessor.get(IAccountManagementService);
|
||||||
accountManagementService.openAccountListDialog();
|
accountManagementService.openAccountListDialog();
|
||||||
});
|
});
|
||||||
|
|
||||||
class AccountsStatusBarContributions extends Disposable implements IWorkbenchContribution {
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
@IStatusbarService private readonly statusbarService: IStatusbarService
|
|
||||||
) {
|
|
||||||
super();
|
|
||||||
this._register(
|
|
||||||
this.statusbarService.addEntry({
|
|
||||||
command: 'workbench.actions.modal.linkedAccount',
|
|
||||||
text: '$(person-filled)',
|
|
||||||
ariaLabel: 'Accounts'
|
|
||||||
},
|
|
||||||
'status.accountList',
|
|
||||||
localize('status.problems', "Problems"),
|
|
||||||
StatusbarAlignment.LEFT, 15000 /* Highest Priority */)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
workbenchRegistry.registerWorkbenchContribution(AccountsStatusBarContributions, LifecyclePhase.Restored);
|
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ import * as nls from 'vs/nls';
|
|||||||
import { ActionsOrientation, ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
|
import { ActionsOrientation, ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||||
import { GLOBAL_ACTIVITY_ID, IActivity, ACCOUNTS_ACTIIVTY_ID } from 'vs/workbench/common/activity';
|
import { GLOBAL_ACTIVITY_ID, IActivity, ACCOUNTS_ACTIIVTY_ID } from 'vs/workbench/common/activity';
|
||||||
import { Part } from 'vs/workbench/browser/part';
|
import { Part } from 'vs/workbench/browser/part';
|
||||||
import { GlobalActivityActionViewItem, ViewContainerActivityAction, PlaceHolderToggleCompositePinnedAction, PlaceHolderViewContainerActivityAction, AccountsActionViewItem, HomeAction, HomeActionViewItem, DeprecatedHomeAction } from 'vs/workbench/browser/parts/activitybar/activitybarActions';
|
import { GlobalActivityActionViewItem, ViewContainerActivityAction, PlaceHolderToggleCompositePinnedAction, PlaceHolderViewContainerActivityAction, HomeAction, HomeActionViewItem, DeprecatedHomeAction } from 'vs/workbench/browser/parts/activitybar/activitybarActions';
|
||||||
|
import { AccountsActionViewItem } from 'sql/workbench/browser/parts/activitybar/activitybarActions'; // {{ SQL CARBON EDIT }} - use the ADS account management action
|
||||||
import { IBadge, NumberBadge } from 'vs/workbench/services/activity/common/activity';
|
import { IBadge, NumberBadge } from 'vs/workbench/services/activity/common/activity';
|
||||||
import { IWorkbenchLayoutService, Parts } from 'vs/workbench/services/layout/browser/layoutService';
|
import { IWorkbenchLayoutService, Parts } from 'vs/workbench/services/layout/browser/layoutService';
|
||||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||||
|
|||||||
Reference in New Issue
Block a user