Skip to content

Commit

Permalink
core: refactor manage sidebar menu
Browse files Browse the repository at this point in the history
The commit refactors the `manage` sidebar menu (previously settings) to
the same organization present in vscode with similar commands.

Signed-off-by: vince-fugnitto <vincent.fugnitto@ericsson.com>
  • Loading branch information
vince-fugnitto committed Sep 29, 2023
1 parent bb7cdbb commit d7dafe9
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 19 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

- [Previous Changelogs](https://github.com/eclipse-theia/theia/tree/master/doc/changelogs/)

## v1.43.0 - Unreleased

<a name="breaking_changes_1.42.0">[Breaking Changes:](#breaking_changes_1.42.0)</a>

- [core] removed `SETTINGS_OPEN` menupath constant - replaced by `MANAGE_GENERAL` [#12803](https://github.com/eclipse-theia/theia/pull/12803)
- [core] removed `SETTINGS__THEME` menupath constant - replaced by `MANAGE_SETTINGS` [#12803](https://github.com/eclipse-theia/theia/pull/12803)

## v1.42.0 - 09/28/2023

- [core] added `inversify` support in the frontend preload script [#12590](https://github.com/eclipse-theia/theia/pull/12590)
Expand Down Expand Up @@ -73,6 +80,11 @@
- [deps] bumped supported Node.js version from 16.x to >=18, you may need to update your environments [#12711](https://github.com/eclipse-theia/theia/pull/12711)
- [preferences] removed the `welcome.alwaysShowWelcomePage` preference in favor of `workbench.startupEditor` [#12813](https://github.com/eclipse-theia/theia/pull/12813)

<a name="breaking_changes_1.41.0">[Breaking Changes:](#breaking_changes_1.41.0)</a>

- [core] removed `SETTINGS_OPEN` menupath constant - replaced by `MANAGE_GENERAL` [#12803](https://github.com/eclipse-theia/theia/pull/12803)
- [core] removed `SETTINGS__THEME` menupath constant - replaced by `MANAGE_SETTINGS` [#12803](https://github.com/eclipse-theia/theia/pull/12803)

## v1.40.0 - 07/27/2023

- [application-package] bumped the default supported VS Code API from `1.78.0` to `1.79.0` [#12764](https://github.com/eclipse-theia/theia/pull/12764) - Contributed on behalf of STMicroelectronics
Expand Down
28 changes: 17 additions & 11 deletions packages/core/src/browser/common-frontend-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import debounce = require('lodash.debounce');
import { injectable, inject, optional } from 'inversify';
import { MAIN_MENU_BAR, SETTINGS_MENU, MenuContribution, MenuModelRegistry, ACCOUNTS_MENU } from '../common/menu';
import { MAIN_MENU_BAR, MANAGE_MENU, MenuContribution, MenuModelRegistry, ACCOUNTS_MENU } from '../common/menu';
import { KeybindingContribution, KeybindingRegistry } from './keybinding';
import { FrontendApplication, FrontendApplicationContribution, OnWillStopAction } from './frontend-application';
import { CommandContribution, CommandRegistry, Command } from '../common/command';
Expand Down Expand Up @@ -100,8 +100,10 @@ export namespace CommonMenus {
export const VIEW_LAYOUT = [...VIEW, '3_layout'];
export const VIEW_TOGGLE = [...VIEW, '4_toggle'];

export const SETTINGS_OPEN = [...SETTINGS_MENU, '1_settings_open'];
export const SETTINGS__THEME = [...SETTINGS_MENU, '2_settings_theme'];
export const MANAGE_GENERAL = [...MANAGE_MENU, '1_manage_general'];
export const MANAGE_SETTINGS = [...MANAGE_MENU, '2_manage_settings'];
export const MANAGE_SETTINGS_THEMES = [...MANAGE_SETTINGS, '1_manage_settings_themes'];

// last menu item
export const HELP = [...MAIN_MENU_BAR, '9_help'];

Expand All @@ -113,6 +115,7 @@ export namespace CommonCommands {
export const VIEW_CATEGORY = 'View';
export const CREATE_CATEGORY = 'Create';
export const PREFERENCES_CATEGORY = 'Preferences';
export const MANAGE_CATEGORY = 'Manage';
export const FILE_CATEGORY_KEY = nls.getDefaultKey(FILE_CATEGORY);
export const VIEW_CATEGORY_KEY = nls.getDefaultKey(VIEW_CATEGORY);
export const PREFERENCES_CATEGORY_KEY = nls.getDefaultKey(PREFERENCES_CATEGORY);
Expand Down Expand Up @@ -455,16 +458,16 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
app.shell.leftPanelHandler.addBottomMenu({
id: 'settings-menu',
iconClass: 'codicon codicon-settings-gear',
title: nls.localizeByDefault(CommonCommands.PREFERENCES_CATEGORY),
menuPath: SETTINGS_MENU,
order: 0,
title: nls.localizeByDefault(CommonCommands.MANAGE_CATEGORY),
menuPath: MANAGE_MENU,
order: 1,
});
const accountsMenu = {
id: 'accounts-menu',
iconClass: 'codicon codicon-person',
title: nls.localizeByDefault('Accounts'),
menuPath: ACCOUNTS_MENU,
order: 1,
order: 0,
};
this.authenticationService.onDidRegisterAuthenticationProvider(() => {
app.shell.leftPanelHandler.addBottomMenu(accountsMenu);
Expand Down Expand Up @@ -700,11 +703,14 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
commandId: CommonCommands.SELECT_ICON_THEME.id
});

registry.registerMenuAction(CommonMenus.SETTINGS__THEME, {
commandId: CommonCommands.SELECT_COLOR_THEME.id
registry.registerSubmenu(CommonMenus.MANAGE_SETTINGS_THEMES, nls.localizeByDefault('Themes'), { order: 'a50' });
registry.registerMenuAction(CommonMenus.MANAGE_SETTINGS_THEMES, {
commandId: CommonCommands.SELECT_COLOR_THEME.id,
order: '0'
});
registry.registerMenuAction(CommonMenus.SETTINGS__THEME, {
commandId: CommonCommands.SELECT_ICON_THEME.id
registry.registerMenuAction(CommonMenus.MANAGE_SETTINGS_THEMES, {
commandId: CommonCommands.SELECT_ICON_THEME.id,
order: '1'
});

registry.registerSubmenu(CommonMenus.VIEW_APPEARANCE_SUBMENU, nls.localizeByDefault('Appearance'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ export class QuickCommandFrontendContribution implements CommandContribution, Ke
commandId: quickCommand.id,
label: nls.localizeByDefault('Command Palette...')
});
menus.registerMenuAction(CommonMenus.MANAGE_GENERAL, {
commandId: quickCommand.id,
label: nls.localizeByDefault('Command Palette...'),
order: '0'
});
}

registerKeybindings(keybindings: KeybindingRegistry): void {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/common/menu/menu-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { isObject } from '../types';

export type MenuPath = string[];
export const MAIN_MENU_BAR: MenuPath = ['menubar'];
export const SETTINGS_MENU: MenuPath = ['settings_menu'];
export const MANAGE_MENU: MenuPath = ['manage_menu'];
export const ACCOUNTS_MENU: MenuPath = ['accounts_menu'];
export const ACCOUNTS_SUBMENU = [...ACCOUNTS_MENU, '1_accounts_submenu'];

Expand Down
4 changes: 2 additions & 2 deletions packages/keymaps/src/browser/keymaps-frontend-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ export class KeymapsFrontendContribution extends AbstractViewContribution<Keybin
label: nls.localizeByDefault('Keyboard Shortcuts'),
order: 'a20'
});
menus.registerMenuAction(CommonMenus.SETTINGS_OPEN, {
menus.registerMenuAction(CommonMenus.MANAGE_SETTINGS, {
commandId: KeymapsCommands.OPEN_KEYMAPS.id,
label: nls.localizeByDefault('Keyboard Shortcuts'),
order: 'a20'
order: 'a30'
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class PreferencesContribution extends AbstractViewContribution<Preference
label: nls.localizeByDefault('Settings'),
order: 'a10',
});
menus.registerMenuAction(CommonMenus.SETTINGS_OPEN, {
menus.registerMenuAction(CommonMenus.MANAGE_SETTINGS, {
commandId: CommonCommands.OPEN_PREFERENCES.id,
label: nls.localizeByDefault('Settings'),
order: 'a10',
Expand Down
8 changes: 7 additions & 1 deletion packages/task/src/browser/task-frontend-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { ILogger, ContributionProvider, CommandContribution, Command, CommandReg
import { QuickOpenTask, TaskTerminateQuickOpen, TaskRunningQuickOpen, TaskRestartRunningQuickOpen } from './quick-open-task';
import {
FrontendApplication, FrontendApplicationContribution, QuickAccessContribution,
KeybindingRegistry, KeybindingContribution, StorageService, StatusBar, StatusBarAlignment
KeybindingRegistry, KeybindingContribution, StorageService, StatusBar, StatusBarAlignment, CommonMenus
} from '@theia/core/lib/browser';
import { WidgetManager } from '@theia/core/lib/browser/widget-manager';
import { TaskContribution, TaskResolverRegistry, TaskProviderRegistry } from './task-contribution';
Expand Down Expand Up @@ -380,6 +380,12 @@ export class TaskFrontendContribution implements CommandContribution, MenuContri
commandId: TaskCommands.TASK_CONFIGURE.id,
order: '0'
});

menus.registerMenuAction(CommonMenus.MANAGE_SETTINGS, {
commandId: TaskCommands.TASK_OPEN_USER.id,
label: nls.localizeByDefault('User Tasks'),
order: 'a40'
});
}

registerQuickAccessProvider(): void {
Expand Down
17 changes: 14 additions & 3 deletions packages/vsx-registry/src/browser/vsx-extensions-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { DateTime } from 'luxon';
import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
import debounce = require('@theia/core/shared/lodash.debounce');
import { CommandRegistry } from '@theia/core/lib/common/command';
import { Command, CommandRegistry } from '@theia/core/lib/common/command';
import { AbstractViewContribution } from '@theia/core/lib/browser/shell/view-contribution';
import { VSXExtensionsViewContainer } from './vsx-extensions-view-container';
import { VSXExtensionsModel } from './vsx-extensions-model';
Expand All @@ -27,7 +27,7 @@ import { Color } from '@theia/core/lib/common/color';
import { FrontendApplicationContribution, FrontendApplication } from '@theia/core/lib/browser/frontend-application';
import { MenuModelRegistry, MessageService, nls } from '@theia/core/lib/common';
import { FileDialogService, OpenFileDialogProps } from '@theia/filesystem/lib/browser';
import { LabelProvider, PreferenceService, QuickPickItem, QuickInputService } from '@theia/core/lib/browser';
import { LabelProvider, PreferenceService, QuickPickItem, QuickInputService, CommonMenus } from '@theia/core/lib/browser';
import { VscodeCommands } from '@theia/plugin-ext-vscode/lib/browser/plugin-vscode-commands-contribution';
import { VSXExtensionsContextMenu, VSXExtension } from './vsx-extension';
import { ClipboardService } from '@theia/core/lib/browser/clipboard-service';
Expand All @@ -37,6 +37,12 @@ import { VSXExtensionsCommands } from './vsx-extension-commands';
import { VSXExtensionRaw, OVSXApiFilter } from '@theia/ovsx-client';
import { OVSXClientProvider } from '../common/ovsx-client-provider';

export namespace VSXCommands {
export const TOGGLE_EXTENSIONS: Command = {
id: 'vsxExtensions.toggle',
};
}

@injectable()
export class VSXExtensionsContribution extends AbstractViewContribution<VSXExtensionsViewContainer> implements ColorContribution, FrontendApplicationContribution {

Expand All @@ -59,7 +65,7 @@ export class VSXExtensionsContribution extends AbstractViewContribution<VSXExten
area: 'left',
rank: 500
},
toggleCommandId: 'vsxExtensions.toggle',
toggleCommandId: VSXCommands.TOGGLE_EXTENSIONS.id,
toggleKeybinding: 'ctrlcmd+shift+x'
});
}
Expand Down Expand Up @@ -117,6 +123,11 @@ export class VSXExtensionsContribution extends AbstractViewContribution<VSXExten

override registerMenus(menus: MenuModelRegistry): void {
super.registerMenus(menus);
menus.registerMenuAction(CommonMenus.MANAGE_SETTINGS, {
commandId: VSXCommands.TOGGLE_EXTENSIONS.id,
label: nls.localizeByDefault('Extensions'),
order: 'a20'
});
menus.registerMenuAction(VSXExtensionsContextMenu.COPY, {
commandId: VSXExtensionsCommands.COPY.id,
label: nls.localizeByDefault('Copy'),
Expand Down

0 comments on commit d7dafe9

Please sign in to comment.