Skip to content

Commit 859f16a

Browse files
authored
Move some more menu registration into registerAction2 (microsoft#163330)
refs microsoft#162713
1 parent 2043494 commit 859f16a

File tree

3 files changed

+53
-71
lines changed

3 files changed

+53
-71
lines changed

src/vs/workbench/browser/actions/layoutActions.ts

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -359,12 +359,29 @@ class ToggleSidebarVisibilityAction extends Action2 {
359359
super({
360360
id: ToggleSidebarVisibilityAction.ID,
361361
title: { value: localize('toggleSidebar', "Toggle Primary Side Bar Visibility"), original: 'Toggle Primary Side Bar Visibility' },
362+
toggled: {
363+
condition: SideBarVisibleContext,
364+
title: localize('primary sidebar', "Primary Side Bar"),
365+
mnemonicTitle: localize('primary sidebar mnemonic', "&&Primary Side Bar"),
366+
},
362367
category: Categories.View,
363368
f1: true,
364369
keybinding: {
365370
weight: KeybindingWeight.WorkbenchContrib,
366371
primary: KeyMod.CtrlCmd | KeyCode.KeyB
367-
}
372+
},
373+
menu: [
374+
{
375+
id: MenuId.LayoutControlMenuSubmenu,
376+
group: '0_workbench_layout',
377+
order: 0
378+
},
379+
{
380+
id: MenuId.MenubarAppearanceMenu,
381+
group: '2_workbench_layout',
382+
order: 1
383+
}
384+
]
368385
});
369386
}
370387

@@ -400,28 +417,6 @@ MenuRegistry.appendMenuItems([
400417
when: ContextKeyExpr.and(SideBarVisibleContext, ContextKeyExpr.equals('viewLocation', ViewContainerLocationToString(ViewContainerLocation.Sidebar))),
401418
order: 2
402419
}
403-
}, {
404-
id: MenuId.MenubarAppearanceMenu,
405-
item: {
406-
group: '2_workbench_layout',
407-
command: {
408-
id: ToggleSidebarVisibilityAction.ID,
409-
title: localize({ key: 'miShowSidebar', comment: ['&& denotes a mnemonic'] }, "&&Primary Side Bar"),
410-
toggled: SideBarVisibleContext
411-
},
412-
order: 1
413-
}
414-
}, {
415-
id: MenuId.LayoutControlMenuSubmenu,
416-
item: {
417-
group: '0_workbench_layout',
418-
command: {
419-
id: ToggleSidebarVisibilityAction.ID,
420-
title: localize('miSidebarNoMnnemonic', "Primary Side Bar"),
421-
toggled: SideBarVisibleContext
422-
},
423-
order: 0
424-
}
425420
}, {
426421
id: MenuId.LayoutControlMenu,
427422
item: {

src/vs/workbench/browser/parts/auxiliarybar/auxiliaryBarActions.ts

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,26 @@ export class ToggleAuxiliaryBarAction extends Action2 {
3030
super({
3131
id: ToggleAuxiliaryBarAction.ID,
3232
title: { value: ToggleAuxiliaryBarAction.LABEL, original: 'Toggle Secondary Side Bar Visibility' },
33+
toggled: {
34+
condition: AuxiliaryBarVisibleContext,
35+
title: localize('secondary sidebar', "Secondary Side Bar"),
36+
mnemonicTitle: localize('secondary sidebar mnemonic', "Secondary Si&&de Bar"),
37+
},
38+
3339
category: Categories.View,
3440
f1: true,
41+
menu: [
42+
{
43+
id: MenuId.LayoutControlMenuSubmenu,
44+
group: '0_workbench_layout',
45+
order: 1
46+
},
47+
{
48+
id: MenuId.MenubarAppearanceMenu,
49+
group: '2_workbench_layout',
50+
order: 2
51+
}
52+
]
3553
});
3654
}
3755

@@ -74,18 +92,6 @@ registerAction2(class FocusAuxiliaryBarAction extends Action2 {
7492
});
7593

7694
MenuRegistry.appendMenuItems([
77-
{
78-
id: MenuId.LayoutControlMenuSubmenu,
79-
item: {
80-
group: '0_workbench_layout',
81-
command: {
82-
id: ToggleAuxiliaryBarAction.ID,
83-
title: localize('miAuxiliaryBarNoMnemonic', "Secondary Side Bar"),
84-
toggled: AuxiliaryBarVisibleContext
85-
},
86-
order: 2
87-
}
88-
},
8995
{
9096
id: MenuId.LayoutControlMenu,
9197
item: {
@@ -99,8 +105,7 @@ MenuRegistry.appendMenuItems([
99105
when: ContextKeyExpr.and(ContextKeyExpr.or(ContextKeyExpr.equals('config.workbench.layoutControl.type', 'toggles'), ContextKeyExpr.equals('config.workbench.layoutControl.type', 'both')), ContextKeyExpr.equals('config.workbench.sideBar.location', 'right')),
100106
order: 0
101107
}
102-
},
103-
{
108+
}, {
104109
id: MenuId.LayoutControlMenu,
105110
item: {
106111
group: '0_workbench_toggles',
@@ -113,18 +118,6 @@ MenuRegistry.appendMenuItems([
113118
when: ContextKeyExpr.and(ContextKeyExpr.or(ContextKeyExpr.equals('config.workbench.layoutControl.type', 'toggles'), ContextKeyExpr.equals('config.workbench.layoutControl.type', 'both')), ContextKeyExpr.equals('config.workbench.sideBar.location', 'left')),
114119
order: 2
115120
}
116-
},
117-
{
118-
id: MenuId.MenubarAppearanceMenu,
119-
item: {
120-
group: '2_workbench_layout',
121-
command: {
122-
id: ToggleAuxiliaryBarAction.ID,
123-
title: localize({ key: 'miAuxiliaryBar', comment: ['&& denotes a mnemonic'] }, "Secondary Si&&de Bar"),
124-
toggled: AuxiliaryBarVisibleContext
125-
},
126-
order: 2
127-
}
128121
}, {
129122
id: MenuId.ViewTitleContext,
130123
item: {

src/vs/workbench/browser/parts/panel/panelActions.ts

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,25 @@ export class TogglePanelAction extends Action2 {
3838
super({
3939
id: TogglePanelAction.ID,
4040
title: { value: TogglePanelAction.LABEL, original: 'Toggle Panel Visibility' },
41+
toggled: {
42+
condition: PanelVisibleContext,
43+
title: localize('toggle panel', "Panel"),
44+
mnemonicTitle: localize('toggle panel mnemonic', "&&Panel"),
45+
},
4146
f1: true,
4247
category: Categories.View,
4348
keybinding: { primary: KeyMod.CtrlCmd | KeyCode.KeyJ, weight: KeybindingWeight.WorkbenchContrib },
49+
menu: [
50+
{
51+
id: MenuId.MenubarAppearanceMenu,
52+
group: '2_workbench_layout',
53+
order: 5
54+
}, {
55+
id: MenuId.LayoutControlMenuSubmenu,
56+
group: '0_workbench_layout',
57+
order: 4
58+
},
59+
]
4460
});
4561
}
4662

@@ -408,28 +424,6 @@ registerAction2(class extends Action2 {
408424

409425
MenuRegistry.appendMenuItems([
410426
{
411-
id: MenuId.MenubarAppearanceMenu,
412-
item: {
413-
group: '2_workbench_layout',
414-
command: {
415-
id: TogglePanelAction.ID,
416-
title: localize({ key: 'miPanel', comment: ['&& denotes a mnemonic'] }, "&&Panel"),
417-
toggled: PanelVisibleContext
418-
},
419-
order: 5
420-
}
421-
}, {
422-
id: MenuId.LayoutControlMenuSubmenu,
423-
item: {
424-
group: '0_workbench_layout',
425-
command: {
426-
id: TogglePanelAction.ID,
427-
title: localize('miPanelNoMnemonic', "Panel"),
428-
toggled: PanelVisibleContext
429-
},
430-
order: 4
431-
}
432-
}, {
433427
id: MenuId.LayoutControlMenu,
434428
item: {
435429
group: '0_workbench_toggles',

0 commit comments

Comments
 (0)