Skip to content

Commit

Permalink
Use MenuRegistry to register menu items
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Jul 24, 2018
1 parent f490af7 commit 7fef11f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
4 changes: 0 additions & 4 deletions src/vs/code/electron-main/menus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,6 @@ export class CodeMenu {
const snippetsSettings = this.createMenuItem(nls.localize({ key: 'miOpenSnippets', comment: ['&& denotes a mnemonic'] }, "User &&Snippets"), 'workbench.action.openSnippets');
const colorThemeSelection = this.createMenuItem(nls.localize({ key: 'miSelectColorTheme', comment: ['&& denotes a mnemonic'] }, "&&Color Theme"), 'workbench.action.selectTheme');
const iconThemeSelection = this.createMenuItem(nls.localize({ key: 'miSelectIconTheme', comment: ['&& denotes a mnemonic'] }, "File &&Icon Theme"), 'workbench.action.selectIconTheme');
const enableOfflineMode = this.createMenuItem(nls.localize({ key: 'miEnableOfflineMode', comment: ['&& denotes a mnemonic'] }, "Enable Offline Mode"), 'workbench.action.enableOfflineMode');
const disableOfflineMode = this.createMenuItem(nls.localize({ key: 'miDisableOfflineMode', comment: ['&& denotes a mnemonic'] }, "Disable Offline Mode"), 'workbench.action.disableOfflineMode');

const preferencesMenu = new Menu();
preferencesMenu.append(settings);
Expand All @@ -456,8 +454,6 @@ export class CodeMenu {
preferencesMenu.append(__separator__());
preferencesMenu.append(colorThemeSelection);
preferencesMenu.append(iconThemeSelection);
preferencesMenu.append(__separator__());
preferencesMenu.append(this.configurationService.getValue(offlineModeSetting) === true ? disableOfflineMode : enableOfflineMode);

return new MenuItem({ label: this.mnemonicLabel(nls.localize({ key: 'miPreferences', comment: ['&& denotes a mnemonic'] }, "&&Preferences")), submenu: preferencesMenu });
}
Expand Down
24 changes: 23 additions & 1 deletion src/vs/platform/actions/common/offlineMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { localize } from 'vs/nls';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { TPromise } from 'vs/base/common/winjs.base';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';

export const offlineModeSetting = 'workbench.enableOfflineMode';

Expand Down Expand Up @@ -83,4 +85,24 @@ export class NotifyUnsupportedFeatureInOfflineMode extends Action {
]);
return TPromise.as(null);
}
}
}

MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
group: '5_offline',
command: {
id: EnableOfflineMode.ID,
title: localize({ key: 'miEnableOfflineMode', comment: ['&& denotes a mnemonic'] }, "Enable &&Offline Mode")
},
order: 1,
when: ContextKeyExpr.not('config.' + offlineModeSetting)
});

MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
group: '5_offline',
command: {
id: DisableOfflineMode.ID,
title: localize({ key: 'miDisableOfflineMode', comment: ['&& denotes a mnemonic'] }, "Disable &&Offline Mode")
},
order: 1,
when: ContextKeyExpr.has('config.' + offlineModeSetting)
});

0 comments on commit 7fef11f

Please sign in to comment.