This commit is contained in:
Sandeep Somavarapu 2024-01-04 16:25:17 +05:30 committed by GitHub
parent 901ba0737a
commit 750117cf1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -66,12 +66,14 @@ export class GlobalCompositeBar extends Disposable {
super(); super();
this.element = document.createElement('div'); this.element = document.createElement('div');
const anchorAlignment = configurationService.getValue('workbench.sideBar.location') === 'left' ? AnchorAlignment.RIGHT : AnchorAlignment.LEFT; const contextMenuAlignmentOptions = () => ({
const anchorAxisAlignment = AnchorAxisAlignment.HORIZONTAL; anchorAlignment: configurationService.getValue('workbench.sideBar.location') === 'left' ? AnchorAlignment.RIGHT : AnchorAlignment.LEFT,
anchorAxisAlignment: AnchorAxisAlignment.HORIZONTAL
});
this.globalActivityActionBar = this._register(new ActionBar(this.element, { this.globalActivityActionBar = this._register(new ActionBar(this.element, {
actionViewItemProvider: action => { actionViewItemProvider: action => {
if (action.id === GLOBAL_ACTIVITY_ID) { if (action.id === GLOBAL_ACTIVITY_ID) {
return this.instantiationService.createInstance(GlobalActivityActionViewItem, this.contextMenuActionsProvider, { colors: this.colors, hoverOptions: this.activityHoverOptions }, anchorAlignment, anchorAxisAlignment); return this.instantiationService.createInstance(GlobalActivityActionViewItem, this.contextMenuActionsProvider, { colors: this.colors, hoverOptions: this.activityHoverOptions }, contextMenuAlignmentOptions);
} }
if (action.id === ACCOUNTS_ACTIVITY_ID) { if (action.id === ACCOUNTS_ACTIVITY_ID) {
@ -81,8 +83,7 @@ export class GlobalCompositeBar extends Disposable {
colors: this.colors, colors: this.colors,
hoverOptions: this.activityHoverOptions hoverOptions: this.activityHoverOptions
}, },
anchorAlignment, contextMenuAlignmentOptions,
anchorAxisAlignment,
(actions: IAction[]) => { (actions: IAction[]) => {
actions.unshift(...[ actions.unshift(...[
toAction({ id: 'hideAccounts', label: localize('hideAccounts', "Hide Accounts"), run: () => this.storageService.store(AccountsActivityActionViewItem.ACCOUNTS_VISIBILITY_PREFERENCE_KEY, false, StorageScope.PROFILE, StorageTarget.USER) }), toAction({ id: 'hideAccounts', label: localize('hideAccounts', "Hide Accounts"), run: () => this.storageService.store(AccountsActivityActionViewItem.ACCOUNTS_VISIBILITY_PREFERENCE_KEY, false, StorageScope.PROFILE, StorageTarget.USER) }),
@ -159,8 +160,7 @@ abstract class AbstractGlobalActivityActionViewItem extends CompoisteBarActionVi
action: CompositeBarAction, action: CompositeBarAction,
options: ICompositeBarActionViewItemOptions, options: ICompositeBarActionViewItemOptions,
private readonly contextMenuActionsProvider: () => IAction[], private readonly contextMenuActionsProvider: () => IAction[],
private readonly anchorAlignment: AnchorAlignment | undefined, private readonly contextMenuAlignmentOptions: () => Readonly<{ anchorAlignment: AnchorAlignment; anchorAxisAlignment: AnchorAxisAlignment }> | undefined,
private readonly anchorAxisAlignment: AnchorAxisAlignment | undefined,
@IThemeService themeService: IThemeService, @IThemeService themeService: IThemeService,
@IHoverService hoverService: IHoverService, @IHoverService hoverService: IHoverService,
@IMenuService private readonly menuService: IMenuService, @IMenuService private readonly menuService: IMenuService,
@ -258,11 +258,12 @@ abstract class AbstractGlobalActivityActionViewItem extends CompoisteBarActionVi
const disposables = new DisposableStore(); const disposables = new DisposableStore();
const menu = disposables.add(this.menuService.createMenu(this.menuId, this.contextKeyService)); const menu = disposables.add(this.menuService.createMenu(this.menuId, this.contextKeyService));
const actions = await this.resolveMainMenuActions(menu, disposables); const actions = await this.resolveMainMenuActions(menu, disposables);
const { anchorAlignment, anchorAxisAlignment } = this.contextMenuAlignmentOptions() ?? { anchorAlignment: undefined, anchorAxisAlignment: undefined };
this.contextMenuService.showContextMenu({ this.contextMenuService.showContextMenu({
getAnchor: () => this.label, getAnchor: () => this.label,
anchorAlignment: this.anchorAlignment, anchorAlignment,
anchorAxisAlignment: this.anchorAxisAlignment, anchorAxisAlignment,
getActions: () => actions, getActions: () => actions,
onHide: () => disposables.dispose(), onHide: () => disposables.dispose(),
menuActionOptions: { renderShortTitle: true }, menuActionOptions: { renderShortTitle: true },
@ -290,8 +291,7 @@ export class AccountsActivityActionViewItem extends AbstractGlobalActivityAction
constructor( constructor(
contextMenuActionsProvider: () => IAction[], contextMenuActionsProvider: () => IAction[],
options: ICompositeBarActionViewItemOptions, options: ICompositeBarActionViewItemOptions,
anchorAlignment: AnchorAlignment | undefined, contextMenuAlignmentOptions: () => Readonly<{ anchorAlignment: AnchorAlignment; anchorAxisAlignment: AnchorAxisAlignment }> | undefined,
anchorAxisAlignment: AnchorAxisAlignment | undefined,
private readonly fillContextMenuActions: (actions: IAction[]) => void, private readonly fillContextMenuActions: (actions: IAction[]) => void,
@IThemeService themeService: IThemeService, @IThemeService themeService: IThemeService,
@ILifecycleService private readonly lifecycleService: ILifecycleService, @ILifecycleService private readonly lifecycleService: ILifecycleService,
@ -314,7 +314,7 @@ export class AccountsActivityActionViewItem extends AbstractGlobalActivityAction
name: localize('accounts', "Accounts"), name: localize('accounts', "Accounts"),
classNames: ThemeIcon.asClassNameArray(GlobalCompositeBar.ACCOUNTS_ICON) classNames: ThemeIcon.asClassNameArray(GlobalCompositeBar.ACCOUNTS_ICON)
}); });
super(MenuId.AccountsContext, action, options, contextMenuActionsProvider, anchorAlignment, anchorAxisAlignment, themeService, hoverService, menuService, contextMenuService, contextKeyService, configurationService, keybindingService, activityService); super(MenuId.AccountsContext, action, options, contextMenuActionsProvider, contextMenuAlignmentOptions, themeService, hoverService, menuService, contextMenuService, contextKeyService, configurationService, keybindingService, activityService);
this._register(action); this._register(action);
this.registerListeners(); this.registerListeners();
this.initialize(); this.initialize();
@ -536,8 +536,7 @@ export class GlobalActivityActionViewItem extends AbstractGlobalActivityActionVi
constructor( constructor(
contextMenuActionsProvider: () => IAction[], contextMenuActionsProvider: () => IAction[],
options: ICompositeBarActionViewItemOptions, options: ICompositeBarActionViewItemOptions,
anchorAlignment: AnchorAlignment | undefined, contextMenuAlignmentOptions: () => Readonly<{ anchorAlignment: AnchorAlignment; anchorAxisAlignment: AnchorAxisAlignment }> | undefined,
anchorAxisAlignment: AnchorAxisAlignment | undefined,
@IUserDataProfileService private readonly userDataProfileService: IUserDataProfileService, @IUserDataProfileService private readonly userDataProfileService: IUserDataProfileService,
@IThemeService themeService: IThemeService, @IThemeService themeService: IThemeService,
@IHoverService hoverService: IHoverService, @IHoverService hoverService: IHoverService,
@ -555,7 +554,7 @@ export class GlobalActivityActionViewItem extends AbstractGlobalActivityActionVi
name: localize('manage', "Manage"), name: localize('manage', "Manage"),
classNames: ThemeIcon.asClassNameArray(userDataProfileService.currentProfile.icon ? ThemeIcon.fromId(userDataProfileService.currentProfile.icon) : DEFAULT_ICON) classNames: ThemeIcon.asClassNameArray(userDataProfileService.currentProfile.icon ? ThemeIcon.fromId(userDataProfileService.currentProfile.icon) : DEFAULT_ICON)
}); });
super(MenuId.GlobalActivity, action, options, contextMenuActionsProvider, anchorAlignment, anchorAxisAlignment, themeService, hoverService, menuService, contextMenuService, contextKeyService, configurationService, keybindingService, activityService); super(MenuId.GlobalActivity, action, options, contextMenuActionsProvider, contextMenuAlignmentOptions, themeService, hoverService, menuService, contextMenuService, contextKeyService, configurationService, keybindingService, activityService);
this._register(action); this._register(action);
this._register(this.userDataProfileService.onDidChangeCurrentProfile(e => { this._register(this.userDataProfileService.onDidChangeCurrentProfile(e => {
action.compositeBarActionItem = { action.compositeBarActionItem = {
@ -635,7 +634,7 @@ export class SimpleAccountActivityActionViewItem extends AccountsActivityActionV
}), }),
hoverOptions, hoverOptions,
compact: true, compact: true,
}, undefined, undefined, actions => actions, themeService, lifecycleService, hoverService, contextMenuService, menuService, contextKeyService, authenticationService, environmentService, productService, configurationService, keybindingService, secretStorageService, logService, activityService, instantiationService); }, () => undefined, actions => actions, themeService, lifecycleService, hoverService, contextMenuService, menuService, contextKeyService, authenticationService, environmentService, productService, configurationService, keybindingService, secretStorageService, logService, activityService, instantiationService);
} }
} }
@ -662,6 +661,6 @@ export class SimpleGlobalActivityActionViewItem extends GlobalActivityActionView
}), }),
hoverOptions, hoverOptions,
compact: true, compact: true,
}, undefined, undefined, userDataProfileService, themeService, hoverService, menuService, contextMenuService, contextKeyService, configurationService, environmentService, keybindingService, instantiationService, activityService); }, () => undefined, userDataProfileService, themeService, hoverService, menuService, contextMenuService, contextKeyService, configurationService, environmentService, keybindingService, instantiationService, activityService);
} }
} }