log when actions are executed from custom menu bar

This commit is contained in:
SteVen Batten 2021-11-10 16:22:04 -08:00
parent 4c00e6de08
commit b1651e3dd5
No known key found for this signature in database
GPG key ID: 49BCA7901CAC9BF6
4 changed files with 15 additions and 6 deletions

View file

@ -34,6 +34,7 @@ export interface IMenuBarOptions {
getKeybinding?: (action: IAction) => ResolvedKeybinding | undefined;
alwaysOnMnemonics?: boolean;
compactMode?: Direction;
actionRunner?: IActionRunner;
getCompactMenuActions?: () => IAction[]
}
@ -109,7 +110,7 @@ export class MenuBar extends Disposable {
this.menuUpdater = this._register(new RunOnceScheduler(() => this.update(), 200));
this.actionRunner = this._register(new ActionRunner());
this.actionRunner = this.options.actionRunner ?? this._register(new ActionRunner());
this._register(this.actionRunner.onBeforeRun(() => {
this.setUnfocusedState();
}));

View file

@ -9,7 +9,7 @@ import { MenuId, MenuRegistry, SyncActionDescriptor } from 'vs/platform/actions/
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { Registry } from 'vs/platform/registry/common/platform';
import { CATEGORIES, Extensions as WorkbenchExtensions, IWorkbenchActionRegistry } from 'vs/workbench/common/actions';
import { ActiveAuxiliaryContext, AuxiliaryBarVisibleContext } from 'vs/workbench/common/auxiliarybar';
import { AuxiliaryBarVisibleContext } from 'vs/workbench/common/auxiliarybar';
import { ViewContainerLocation, ViewContainerLocationToString } from 'vs/workbench/common/views';
import { IWorkbenchLayoutService, Parts } from 'vs/workbench/services/layout/browser/layoutService';
import { IPaneCompositePartService } from 'vs/workbench/services/panecomposite/browser/panecomposite';
@ -69,7 +69,7 @@ MenuRegistry.appendMenuItems([
command: {
id: ToggleAuxiliaryBarAction.ID,
title: localize({ key: 'miShowAuxiliaryBar', comment: ['&& denotes a mnemonic'] }, "Show Si&&de Panel"),
toggled: ActiveAuxiliaryContext
toggled: AuxiliaryBarVisibleContext
},
when: ContextKeyExpr.equals('config.workbench.experimental.sidePanel.enabled', true),
order: 4
@ -82,7 +82,7 @@ MenuRegistry.appendMenuItems([
command: {
id: ToggleAuxiliaryBarAction.ID,
title: localize({ key: 'miShowAuxiliaryBar', comment: ['&& denotes a mnemonic'] }, "Show Si&&de Panel"),
toggled: ActiveAuxiliaryContext
toggled: AuxiliaryBarVisibleContext
},
when: ContextKeyExpr.equals('config.workbench.experimental.sidePanel.enabled', true),
order: 5

View file

@ -8,7 +8,7 @@ import { IMenuService, MenuId, IMenu, SubmenuItemAction, registerAction2, Action
import { registerThemingParticipant, IThemeService } from 'vs/platform/theme/common/themeService';
import { MenuBarVisibility, getTitleBarStyle, IWindowOpenable, getMenuBarVisibility } from 'vs/platform/windows/common/windows';
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IAction, Action, SubmenuAction, Separator } from 'vs/base/common/actions';
import { IAction, Action, SubmenuAction, Separator, IActionRunner, ActionRunner, WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification } from 'vs/base/common/actions';
import { addDisposableListener, Dimension, EventType } from 'vs/base/browser/dom';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { isMacintosh, isWeb, isIOS, isNative } from 'vs/base/common/platform';
@ -38,6 +38,7 @@ import { KeyCode } from 'vs/base/common/keyCodes';
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { IsMacNativeContext, IsWebContext } from 'vs/platform/contextkey/common/contextkeys';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
export type IOpenRecentAction = IAction & { uri: URI, remoteAuthority?: string };
@ -374,6 +375,7 @@ export class CustomMenubarControl extends MenubarControl {
private alwaysOnMnemonics: boolean = false;
private focusInsideMenubar: boolean = false;
private visible: boolean = true;
private actionRunner: IActionRunner;
private readonly webNavigationMenu = this._register(this.menuService.createMenu(MenuId.MenubarHomeMenu, this.contextKeyService));
private readonly _onVisibilityChange: Emitter<boolean>;
@ -394,6 +396,7 @@ export class CustomMenubarControl extends MenubarControl {
@IAccessibilityService accessibilityService: IAccessibilityService,
@IThemeService private readonly themeService: IThemeService,
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService,
@ITelemetryService private readonly telemetryService: ITelemetryService,
@IHostService hostService: IHostService,
@ICommandService commandService: ICommandService
) {
@ -402,6 +405,11 @@ export class CustomMenubarControl extends MenubarControl {
this._onVisibilityChange = this._register(new Emitter<boolean>());
this._onFocusStateChange = this._register(new Emitter<boolean>());
this.actionRunner = this._register(new ActionRunner());
this.actionRunner.onDidRun(e => {
this.telemetryService.publicLog2<WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification>('workbenchActionExecuted', { id: e.action.id, from: 'menu' });
});
this.workspacesService.getRecentlyOpened().then((recentlyOpened) => {
this.recentlyOpened = recentlyOpened;
});
@ -811,6 +819,7 @@ export class CustomMenubarControl extends MenubarControl {
enableMnemonics: this.currentEnableMenuBarMnemonics,
disableAltFocus: this.currentDisableMenuBarAltFocus,
visibility: this.currentMenubarVisibility,
actionRunner: this.actionRunner,
getKeybinding: (action) => this.keybindingService.lookupKeybinding(action.id),
alwaysOnMnemonics: this.alwaysOnMnemonics,
compactMode: this.currentCompactMenuMode,

View file

@ -418,7 +418,6 @@ export class TitlebarPart extends Part implements ITitleService {
actionViewItemProvider: action => {
if (action instanceof SubmenuAction) {
return new DropdownMenuActionViewItem(action, action.actions, this.contextMenuService, {
classNames: Codicon.editorLayout.classNamesArray,
anchorAlignmentProvider: () => AnchorAlignment.RIGHT,
keybindingProvider: action => this.keybindingService.lookupKeybinding(action.id)