Skip to content

Commit

Permalink
fixup! Fix context-keys ScmProvider update, add submenu plugin contri…
Browse files Browse the repository at this point in the history
…bution
  • Loading branch information
vinokurig committed Feb 2, 2021
1 parent 8bbc696 commit 6bb4ec2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
13 changes: 8 additions & 5 deletions packages/core/src/browser/shell/tab-bar-toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,14 @@ export class TabBarToolbar extends ReactWidget {
const menuPath = ['TAB_BAR_TOOLBAR_CONTEXT_MENU'];
const toDisposeOnHide = new DisposableCollection();
for (const [, item] of this.more) {
// Register a submenu for the item, if the group is in format `<group>/<submenu name>/<group in the submenu>`
if (/.*\/.*\/.*/g.test(item.group!)) {
// Register a submenu for the item, if the group is in format `<submenu group>/<submenu name>/.../<item group>`
if (item.group!.indexOf('/') !== -1) {
const split = item.group!.split('/');
split.splice(2);
toDisposeOnHide.push(this.menus.registerSubmenu([...menuPath, ...split], split![1]));
const groups: string[] = [];
for (let i = 0; i < split.length - 1; i += 2) {
groups.push(split[i], split[i + 1]);
toDisposeOnHide.push(this.menus.registerSubmenu([...menuPath, ...groups], split[i + 1]));
}
}
toDisposeOnHide.push(this.menus.registerMenuAction([...menuPath, ...item.group!.split('/')], {
label: item.tooltip,
Expand Down Expand Up @@ -272,7 +275,7 @@ export interface TabBarToolbarItem {
/**
* Optional group for the item. Default `navigation`.
* `navigation` group will be inlined, while all the others will be within the `...` dropdown.
* A group in format `group/submenu/subgroup` means that the item will be located in a submenu of the `...` dropdown.
* A group in format `submenu_group_1/submenu 1/.../submenu_group_n/ submenu n/item_group` means that the item will be located in a submenu(s) of the `...` dropdown.
* The submenu's title is named by the submenu section name, e.g. `group/<submenu name>/subgroup`.
*/
readonly group?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,20 @@ export class MenusContributionPointHandler {
toDispose.push(this.registerTreeMenuAction(menuPath, menu));
}
} else if (location === 'scm/title') {
for (const action of allMenus[location]) {
if (action.submenu) {
const submenu: Submenu = allSubmenus!.find(s => s.id === action.submenu)!;
for (const submenuAction of allMenus[action.submenu]) {
submenuAction.group = `${action.group!.split('@')[0]}/${submenu.label}/${submenuAction.group ? submenuAction.group.split('@')[0] : '_'}`;
toDispose.push(this.registerScmTitleAction(location, submenuAction));
const registerActions = (menus: Menu[], group: string | undefined) => {
for (const action of menus) {
if (group) {
action.group = group + (action.group ? '/' + action.group.split('@')[0] : '/_');
}
if (action.submenu) {
const submenu: Submenu = allSubmenus!.find(s => s.id === action.submenu)!;
registerActions(allMenus[action.submenu], action.group!.split('@')[0] + '/' + submenu.label);
} else {
toDispose.push(this.registerScmTitleAction(location, action));
}
} else if (action.command) {
toDispose.push(this.registerScmTitleAction(location, action));
}
}
};
registerActions(allMenus[location], undefined);
} else if (location === 'scm/resourceGroup/context') {
for (const menu of allMenus[location]) {
const inline = menu.group && /^inline/.test(menu.group) || false;
Expand Down

0 comments on commit 6bb4ec2

Please sign in to comment.