mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 13:29:44 +00:00
Merge commit 'refs/pull/75300/head' of github.com:Microsoft/vscode into pr/75300
This commit is contained in:
commit
0337567dfc
|
@ -98,7 +98,8 @@ export const enum MenuId {
|
|||
CommentThreadTitle,
|
||||
CommentThreadActions,
|
||||
CommentTitle,
|
||||
CommentActions
|
||||
CommentActions,
|
||||
GlobalActivity
|
||||
}
|
||||
|
||||
export interface IMenuActionOptions {
|
||||
|
|
|
@ -8,11 +8,11 @@ import * as nls from 'vs/nls';
|
|||
import * as DOM from 'vs/base/browser/dom';
|
||||
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { EventType as TouchEventType, GestureEvent } from 'vs/base/browser/touch';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import { Action, IAction } from 'vs/base/common/actions';
|
||||
import { KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { dispose } from 'vs/base/common/lifecycle';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
||||
import { SyncActionDescriptor, IMenuService, MenuId } from 'vs/platform/actions/common/actions';
|
||||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
|
@ -21,11 +21,13 @@ import { ICssStyleCollector, ITheme, IThemeService, registerThemingParticipant }
|
|||
import { ActivityAction, ActivityActionViewItem, ICompositeBar, ICompositeBarColors, ToggleCompositePinnedAction } from 'vs/workbench/browser/parts/compositeBarActions';
|
||||
import { ViewletDescriptor } from 'vs/workbench/browser/viewlet';
|
||||
import { Extensions as ActionExtensions, IWorkbenchActionRegistry } from 'vs/workbench/common/actions';
|
||||
import { IActivity, IGlobalActivity } from 'vs/workbench/common/activity';
|
||||
import { IActivity } from 'vs/workbench/common/activity';
|
||||
import { ACTIVITY_BAR_FOREGROUND } from 'vs/workbench/common/theme';
|
||||
import { IActivityBarService } from 'vs/workbench/services/activityBar/browser/activityBarService';
|
||||
import { IWorkbenchLayoutService, Parts } from 'vs/workbench/services/layout/browser/layoutService';
|
||||
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { fillInActionBarActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
|
||||
|
||||
export class ViewletActivityAction extends ActivityAction {
|
||||
|
||||
|
@ -104,20 +106,15 @@ export class ToggleViewletAction extends Action {
|
|||
}
|
||||
}
|
||||
|
||||
export class GlobalActivityAction extends ActivityAction {
|
||||
|
||||
constructor(activity: IGlobalActivity) {
|
||||
super(activity);
|
||||
}
|
||||
}
|
||||
|
||||
export class GlobalActivityActionViewItem extends ActivityActionViewItem {
|
||||
|
||||
constructor(
|
||||
action: GlobalActivityAction,
|
||||
action: ActivityAction,
|
||||
colors: (theme: ITheme) => ICompositeBarColors,
|
||||
@IThemeService themeService: IThemeService,
|
||||
@IContextMenuService protected contextMenuService: IContextMenuService
|
||||
@IMenuService private readonly menuService: IMenuService,
|
||||
@IContextMenuService protected contextMenuService: IContextMenuService,
|
||||
@IContextKeyService private readonly contextKeyService: IContextKeyService,
|
||||
) {
|
||||
super(action, { draggable: false, colors, icon: true }, themeService);
|
||||
}
|
||||
|
@ -148,16 +145,19 @@ export class GlobalActivityActionViewItem extends ActivityActionViewItem {
|
|||
}
|
||||
|
||||
private showContextMenu(): void {
|
||||
const globalAction = this._action as GlobalActivityAction;
|
||||
const activity = globalAction.activity as IGlobalActivity;
|
||||
const actions = activity.getActions();
|
||||
const globalActivityActions: IAction[] = [];
|
||||
const globalActivityMenu = this.menuService.createMenu(MenuId.GlobalActivity, this.contextKeyService);
|
||||
fillInActionBarActions(globalActivityMenu, undefined, { primary: [], secondary: globalActivityActions });
|
||||
|
||||
const containerPosition = DOM.getDomNodePagePosition(this.container);
|
||||
const location = { x: containerPosition.left + containerPosition.width / 2, y: containerPosition.top };
|
||||
|
||||
this.contextMenuService.showContextMenu({
|
||||
getAnchor: () => location,
|
||||
getActions: () => actions,
|
||||
onHide: () => dispose(actions)
|
||||
getActions: () => globalActivityActions,
|
||||
onHide: () => {
|
||||
globalActivityMenu.dispose();
|
||||
dispose(globalActivityActions);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,10 +7,10 @@ import 'vs/css!./media/activitybarpart';
|
|||
import * as nls from 'vs/nls';
|
||||
import { illegalArgument } from 'vs/base/common/errors';
|
||||
import { ActionsOrientation, ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { GlobalActivityExtensions, IGlobalActivityRegistry } from 'vs/workbench/common/activity';
|
||||
import { GLOBAL_ACTIVITY_ID } from 'vs/workbench/common/activity';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { Part } from 'vs/workbench/browser/part';
|
||||
import { GlobalActivityActionViewItem, GlobalActivityAction, ViewletActivityAction, ToggleViewletAction, PlaceHolderToggleCompositePinnedAction, PlaceHolderViewletActivityAction } from 'vs/workbench/browser/parts/activitybar/activitybarActions';
|
||||
import { GlobalActivityActionViewItem, ViewletActivityAction, ToggleViewletAction, PlaceHolderToggleCompositePinnedAction, PlaceHolderViewletActivityAction } from 'vs/workbench/browser/parts/activitybar/activitybarActions';
|
||||
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
||||
import { IBadge } from 'vs/workbench/services/activity/common/activity';
|
||||
import { IWorkbenchLayoutService, Parts, Position as SideBarPosition } from 'vs/workbench/services/layout/browser/layoutService';
|
||||
|
@ -25,7 +25,7 @@ import { Dimension, addClass } from 'vs/base/browser/dom';
|
|||
import { IStorageService, StorageScope, IWorkspaceStorageChangeEvent } from 'vs/platform/storage/common/storage';
|
||||
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { ToggleCompositePinnedAction, ICompositeBarColors } from 'vs/workbench/browser/parts/compositeBarActions';
|
||||
import { ToggleCompositePinnedAction, ICompositeBarColors, ActivityAction } from 'vs/workbench/browser/parts/compositeBarActions';
|
||||
import { ViewletDescriptor } from 'vs/workbench/browser/viewlet';
|
||||
import { IViewsService, IViewContainersRegistry, Extensions as ViewContainerExtensions, ViewContainer, TEST_VIEW_CONTAINER_ID, IViewDescriptorCollection } from 'vs/workbench/common/views';
|
||||
import { IContextKeyService, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
|
@ -60,8 +60,8 @@ export class ActivitybarPart extends Part implements IActivityBarService {
|
|||
|
||||
//#endregion
|
||||
|
||||
private globalActionBar: ActionBar;
|
||||
private globalActivityIdToActions: Map<string, GlobalActivityAction> = new Map();
|
||||
private globalActivityAction: ActivityAction;
|
||||
private globalActivityActionBar: ActionBar;
|
||||
|
||||
private cachedViewlets: ICachedViewlet[] = [];
|
||||
|
||||
|
@ -163,22 +163,16 @@ export class ActivitybarPart extends Part implements IActivityBarService {
|
|||
return this.compositeBar.showActivity(viewletOrActionId, badge, clazz, priority);
|
||||
}
|
||||
|
||||
return this.showGlobalActivity(viewletOrActionId, badge, clazz);
|
||||
if (viewletOrActionId === GLOBAL_ACTIVITY_ID) {
|
||||
return this.showGlobalActivity(badge, clazz);
|
||||
}
|
||||
|
||||
throw illegalArgument('globalActivityId');
|
||||
}
|
||||
|
||||
private showGlobalActivity(globalActivityId: string, badge: IBadge, clazz?: string): IDisposable {
|
||||
if (!badge) {
|
||||
throw illegalArgument('badge');
|
||||
}
|
||||
|
||||
const action = this.globalActivityIdToActions.get(globalActivityId);
|
||||
if (!action) {
|
||||
throw illegalArgument('globalActivityId');
|
||||
}
|
||||
|
||||
action.setBadge(badge, clazz);
|
||||
|
||||
return toDisposable(() => action.setBadge(undefined));
|
||||
private showGlobalActivity(badge: IBadge, clazz?: string): IDisposable {
|
||||
this.globalActivityAction.setBadge(badge, clazz);
|
||||
return toDisposable(() => this.globalActivityAction.setBadge(undefined));
|
||||
}
|
||||
|
||||
createContentArea(parent: HTMLElement): HTMLElement {
|
||||
|
@ -232,23 +226,19 @@ export class ActivitybarPart extends Part implements IActivityBarService {
|
|||
}
|
||||
|
||||
private createGlobalActivityActionBar(container: HTMLElement): void {
|
||||
const activityRegistry = Registry.as<IGlobalActivityRegistry>(GlobalActivityExtensions);
|
||||
const descriptors = activityRegistry.getActivities();
|
||||
const actions = descriptors
|
||||
.map(d => this.instantiationService.createInstance(d))
|
||||
.map(a => new GlobalActivityAction(a));
|
||||
|
||||
this.globalActionBar = this._register(new ActionBar(container, {
|
||||
this.globalActivityActionBar = this._register(new ActionBar(container, {
|
||||
actionViewItemProvider: a => this.instantiationService.createInstance(GlobalActivityActionViewItem, a, (theme: ITheme) => this.getActivitybarItemColors(theme)),
|
||||
orientation: ActionsOrientation.VERTICAL,
|
||||
ariaLabel: nls.localize('globalActions', "Global Actions"),
|
||||
ariaLabel: nls.localize('manage', "Manage"),
|
||||
animated: false
|
||||
}));
|
||||
|
||||
actions.forEach(a => {
|
||||
this.globalActivityIdToActions.set(a.id, a);
|
||||
this.globalActionBar.push(a);
|
||||
this.globalActivityAction = new ActivityAction({
|
||||
id: 'workbench.actions.manage',
|
||||
name: nls.localize('manage', "Manage"),
|
||||
cssClass: 'update-activity'
|
||||
});
|
||||
this.globalActivityActionBar.push(this.globalActivityAction);
|
||||
}
|
||||
|
||||
private getCompositeActions(compositeId: string): { activityAction: ViewletActivityAction, pinnedAction: ToggleCompositePinnedAction } {
|
||||
|
@ -382,8 +372,8 @@ export class ActivitybarPart extends Part implements IActivityBarService {
|
|||
|
||||
// Layout composite bar
|
||||
let availableHeight = contentAreaSize.height;
|
||||
if (this.globalActionBar) {
|
||||
availableHeight -= (this.globalActionBar.viewItems.length * ActivitybarPart.ACTION_HEIGHT); // adjust height for global actions showing
|
||||
if (this.globalActivityActionBar) {
|
||||
availableHeight -= (this.globalActivityActionBar.viewItems.length * ActivitybarPart.ACTION_HEIGHT); // adjust height for global actions showing
|
||||
}
|
||||
this.compositeBar.layout(new Dimension(width, availableHeight));
|
||||
}
|
||||
|
|
|
@ -25,4 +25,8 @@
|
|||
|
||||
.monaco-workbench .activitybar > .content > .composite-bar > .monaco-action-bar .action-label.toggle-more {
|
||||
-webkit-mask: url('ellipsis-global.svg') no-repeat 50% 50%;
|
||||
}
|
||||
|
||||
.monaco-workbench .activitybar .global-activity .monaco-action-bar .action-label.update-activity {
|
||||
-webkit-mask: url('update.svg') no-repeat 50% 50%;
|
||||
}
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
@ -3,10 +3,6 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IAction } from 'vs/base/common/actions';
|
||||
import { IConstructorSignature0 } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
export interface IActivity {
|
||||
id: string;
|
||||
name: string;
|
||||
|
@ -14,31 +10,4 @@ export interface IActivity {
|
|||
cssClass?: string;
|
||||
}
|
||||
|
||||
export interface IGlobalActivity extends IActivity {
|
||||
getActions(): IAction[];
|
||||
}
|
||||
|
||||
export const GlobalActivityExtensions = 'workbench.contributions.globalActivities';
|
||||
|
||||
export interface IGlobalActivityRegistry {
|
||||
registerActivity(descriptor: IConstructorSignature0<IGlobalActivity>): void;
|
||||
getActivities(): IConstructorSignature0<IGlobalActivity>[];
|
||||
}
|
||||
|
||||
export class GlobalActivityRegistry implements IGlobalActivityRegistry {
|
||||
|
||||
private readonly activityDescriptors = new Set<IConstructorSignature0<IGlobalActivity>>();
|
||||
|
||||
registerActivity(descriptor: IConstructorSignature0<IGlobalActivity>): void {
|
||||
this.activityDescriptors.add(descriptor);
|
||||
}
|
||||
|
||||
getActivities(): IConstructorSignature0<IGlobalActivity>[] {
|
||||
const result: IConstructorSignature0<IGlobalActivity>[] = [];
|
||||
this.activityDescriptors.forEach(d => result.push(d));
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Registry.add(GlobalActivityExtensions, new GlobalActivityRegistry());
|
||||
export const GLOBAL_ACTIVITY_ID = 'workbench.action.globalActivity';
|
|
@ -439,4 +439,13 @@ CommandsRegistry.registerCommand({
|
|||
onUnexpectedError(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
|
||||
group: '2_configuration',
|
||||
command: {
|
||||
id: VIEWLET_ID,
|
||||
title: localize('showExtensions', "Extensions")
|
||||
},
|
||||
order: 3
|
||||
});
|
|
@ -757,6 +757,15 @@ MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
|
|||
order: 1
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
|
||||
group: '2_configuration',
|
||||
command: {
|
||||
id: SETTINGS_COMMAND_OPEN_SETTINGS,
|
||||
title: nls.localize('settings', "Settings")
|
||||
},
|
||||
order: 1
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
|
||||
group: '1_settings',
|
||||
command: {
|
||||
|
@ -766,6 +775,15 @@ MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
|
|||
order: 2
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
|
||||
group: '2_configuration',
|
||||
command: {
|
||||
id: SETTINGS_EDITOR_COMMAND_FILTER_ONLINE,
|
||||
title: nls.localize('onlineServices', "Online Services Settings")
|
||||
},
|
||||
order: 2
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
|
||||
group: '2_keybindings',
|
||||
command: {
|
||||
|
@ -775,6 +793,15 @@ MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
|
|||
order: 1
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
|
||||
group: '2_configuration',
|
||||
command: {
|
||||
id: OpenGlobalKeybindingsAction.ID,
|
||||
title: nls.localize('keyboardShortcuts', "Keyboard Shortcuts")
|
||||
},
|
||||
order: 4
|
||||
});
|
||||
|
||||
// Editor tool items
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.EditorTitle, {
|
||||
|
|
|
@ -182,4 +182,13 @@ MenuRegistry.appendMenuItem(MenuId.MenubarGoMenu, {
|
|||
title: nls.localize({ key: 'miGotoLine', comment: ['&& denotes a mnemonic'] }, "Go to &&Line/Column...")
|
||||
},
|
||||
order: 1
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
|
||||
group: '1_command',
|
||||
command: {
|
||||
id: ShowAllCommandsAction.ID,
|
||||
title: nls.localize('commandPalette', "Command Palette...")
|
||||
},
|
||||
order: 1
|
||||
});
|
|
@ -272,3 +272,12 @@ MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
|
|||
},
|
||||
order: 1
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
|
||||
group: '3_snippets',
|
||||
command: {
|
||||
id,
|
||||
title: nls.localize('userSnippets', "User Snippets")
|
||||
},
|
||||
order: 1
|
||||
});
|
||||
|
|
|
@ -271,3 +271,21 @@ MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
|
|||
},
|
||||
order: 2
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
|
||||
group: '4_themes',
|
||||
command: {
|
||||
id: SelectColorThemeAction.ID,
|
||||
title: localize('selectTheme.label', "Color Theme")
|
||||
},
|
||||
order: 1
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
|
||||
group: '4_themes',
|
||||
command: {
|
||||
id: SelectIconThemeAction.ID,
|
||||
title: localize('themes.selectIconTheme.label', "File Icon Theme")
|
||||
},
|
||||
order: 2
|
||||
});
|
|
@ -1,8 +0,0 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
.update-activity {
|
||||
-webkit-mask: url('update.svg') no-repeat 50% 50%;
|
||||
}
|
|
@ -3,12 +3,10 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import 'vs/css!./media/update.contribution';
|
||||
import 'vs/platform/update/node/update.config.contribution';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
|
||||
import { IGlobalActivityRegistry, GlobalActivityExtensions } from 'vs/workbench/common/activity';
|
||||
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions';
|
||||
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
||||
import { ShowCurrentReleaseNotesAction, ProductContribution, UpdateContribution, Win3264BitContribution } from './update';
|
||||
|
@ -24,8 +22,7 @@ if (platform.isWindows) {
|
|||
}
|
||||
}
|
||||
|
||||
Registry.as<IGlobalActivityRegistry>(GlobalActivityExtensions)
|
||||
.registerActivity(UpdateContribution);
|
||||
workbench.registerWorkbenchContribution(UpdateContribution, LifecyclePhase.Restored);
|
||||
|
||||
// Editor
|
||||
Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions)
|
||||
|
|
|
@ -5,17 +5,15 @@
|
|||
|
||||
import * as nls from 'vs/nls';
|
||||
import severity from 'vs/base/common/severity';
|
||||
import { IAction, Action } from 'vs/base/common/actions';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import pkg from 'vs/platform/product/node/package';
|
||||
import product from 'vs/platform/product/node/product';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IActivityService, NumberBadge, IBadge, ProgressBadge } from 'vs/workbench/services/activity/common/activity';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IGlobalActivity } from 'vs/workbench/common/activity';
|
||||
import { GLOBAL_ACTIVITY_ID } from 'vs/workbench/common/activity';
|
||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
||||
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
|
||||
import { IUpdateService, State as UpdateState, StateType, IUpdate } from 'vs/platform/update/common/update';
|
||||
|
@ -27,6 +25,11 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/
|
|||
import { ReleaseNotesManager } from './releaseNotesEditor';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { RawContextKey, IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
|
||||
export const CONTEXT_UPDATE_STATE = new RawContextKey<string>('updateStateContext', '');
|
||||
|
||||
let releaseNotesManager: ReleaseNotesManager | undefined = undefined;
|
||||
|
||||
|
@ -212,47 +215,25 @@ export class Win3264BitContribution implements IWorkbenchContribution {
|
|||
}
|
||||
}
|
||||
|
||||
class CommandAction extends Action {
|
||||
|
||||
constructor(
|
||||
commandId: string,
|
||||
label: string,
|
||||
@ICommandService commandService: ICommandService
|
||||
) {
|
||||
super(`command-action:${commandId}`, label, undefined, true, () => commandService.executeCommand(commandId));
|
||||
}
|
||||
}
|
||||
|
||||
export class UpdateContribution extends Disposable implements IGlobalActivity {
|
||||
|
||||
private static readonly showCommandsId = 'workbench.action.showCommands';
|
||||
private static readonly openSettingsId = 'workbench.action.openSettings';
|
||||
private static readonly openKeybindingsId = 'workbench.action.openGlobalKeybindings';
|
||||
private static readonly openUserSnippets = 'workbench.action.openSnippets';
|
||||
private static readonly selectColorThemeId = 'workbench.action.selectTheme';
|
||||
private static readonly selectIconThemeId = 'workbench.action.selectIconTheme';
|
||||
private static readonly showExtensionsId = 'workbench.view.extensions';
|
||||
private static readonly showOnlineSettingsId = 'settings.filterByOnline';
|
||||
|
||||
get id() { return 'vs.update'; }
|
||||
get name() { return nls.localize('manage', "Manage"); }
|
||||
get cssClass() { return 'update-activity'; }
|
||||
export class UpdateContribution extends Disposable implements IWorkbenchContribution {
|
||||
|
||||
private state: UpdateState;
|
||||
private badgeDisposable: IDisposable = Disposable.None;
|
||||
private updateStateContextKey: IContextKey<string>;
|
||||
|
||||
constructor(
|
||||
@IStorageService private readonly storageService: IStorageService,
|
||||
@ICommandService private readonly commandService: ICommandService,
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
||||
@INotificationService private readonly notificationService: INotificationService,
|
||||
@IDialogService private readonly dialogService: IDialogService,
|
||||
@IUpdateService private readonly updateService: IUpdateService,
|
||||
@IActivityService private readonly activityService: IActivityService,
|
||||
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService
|
||||
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
|
||||
@IContextKeyService private readonly contextKeyService: IContextKeyService
|
||||
) {
|
||||
super();
|
||||
this.state = updateService.state;
|
||||
this.updateStateContextKey = CONTEXT_UPDATE_STATE.bindTo(this.contextKeyService);
|
||||
|
||||
this._register(updateService.onStateChange(this.onUpdateStateChange, this));
|
||||
this.onUpdateStateChange(this.updateService.state);
|
||||
|
@ -273,9 +254,12 @@ export class UpdateContribution extends Disposable implements IGlobalActivity {
|
|||
this.storageService.remove('update/lastKnownVersion', StorageScope.GLOBAL);
|
||||
this.storageService.remove('update/updateNotificationTime', StorageScope.GLOBAL);
|
||||
}
|
||||
|
||||
this.registerGlobalActivityActions();
|
||||
}
|
||||
|
||||
private onUpdateStateChange(state: UpdateState): void {
|
||||
this.updateStateContextKey.set(state.type);
|
||||
switch (state.type) {
|
||||
case StateType.Idle:
|
||||
if (state.error) {
|
||||
|
@ -315,7 +299,7 @@ export class UpdateContribution extends Disposable implements IGlobalActivity {
|
|||
this.badgeDisposable.dispose();
|
||||
|
||||
if (badge) {
|
||||
this.badgeDisposable = this.activityService.showActivity(this.id, badge, clazz);
|
||||
this.badgeDisposable = this.activityService.showActivity(GLOBAL_ACTIVITY_ID, badge, clazz);
|
||||
}
|
||||
|
||||
this.state = state;
|
||||
|
@ -472,62 +456,78 @@ export class UpdateContribution extends Disposable implements IGlobalActivity {
|
|||
return diffDays > 5;
|
||||
}
|
||||
|
||||
getActions(): IAction[] {
|
||||
const result: IAction[] = [
|
||||
new CommandAction(UpdateContribution.showCommandsId, nls.localize('commandPalette', "Command Palette..."), this.commandService),
|
||||
new Separator(),
|
||||
new CommandAction(UpdateContribution.openSettingsId, nls.localize('settings', "Settings"), this.commandService),
|
||||
new CommandAction(UpdateContribution.showOnlineSettingsId, nls.localize('onlineServices', "Online Services Settings"), this.commandService),
|
||||
new CommandAction(UpdateContribution.showExtensionsId, nls.localize('showExtensions', "Extensions"), this.commandService),
|
||||
new CommandAction(UpdateContribution.openKeybindingsId, nls.localize('keyboardShortcuts', "Keyboard Shortcuts"), this.commandService),
|
||||
new Separator(),
|
||||
new CommandAction(UpdateContribution.openUserSnippets, nls.localize('userSnippets', "User Snippets"), this.commandService),
|
||||
new Separator(),
|
||||
new CommandAction(UpdateContribution.selectColorThemeId, nls.localize('selectTheme.label', "Color Theme"), this.commandService),
|
||||
new CommandAction(UpdateContribution.selectIconThemeId, nls.localize('themes.selectIconTheme.label', "File Icon Theme"), this.commandService)
|
||||
];
|
||||
private registerGlobalActivityActions(): void {
|
||||
CommandsRegistry.registerCommand('update.check', () => this.updateService.checkForUpdates({ windowId: this.environmentService.configuration.windowId }));
|
||||
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
|
||||
group: '5_update',
|
||||
command: {
|
||||
id: 'update.check',
|
||||
title: nls.localize('checkForUpdates', "Check for Updates...")
|
||||
},
|
||||
when: CONTEXT_UPDATE_STATE.isEqualTo(StateType.Idle),
|
||||
});
|
||||
|
||||
const updateAction = this.getUpdateAction();
|
||||
CommandsRegistry.registerCommand('update.checking', () => { });
|
||||
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
|
||||
group: '5_update',
|
||||
command: {
|
||||
id: 'update.checking',
|
||||
title: nls.localize('checkingForUpdates', "Checking For Updates..."),
|
||||
precondition: CONTEXT_UPDATE_STATE.isEqualTo('')
|
||||
},
|
||||
when: CONTEXT_UPDATE_STATE.isEqualTo(StateType.CheckingForUpdates),
|
||||
});
|
||||
|
||||
if (updateAction) {
|
||||
result.push(new Separator(), updateAction);
|
||||
}
|
||||
CommandsRegistry.registerCommand('update.downloadNow', () => this.updateService.downloadUpdate());
|
||||
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
|
||||
group: '5_update',
|
||||
command: {
|
||||
id: 'update.downloadNow',
|
||||
title: nls.localize('download now', "Download Now")
|
||||
},
|
||||
when: CONTEXT_UPDATE_STATE.isEqualTo(StateType.AvailableForDownload),
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
CommandsRegistry.registerCommand('update.downloading', () => { });
|
||||
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
|
||||
group: '5_update',
|
||||
command: {
|
||||
id: 'update.downloading',
|
||||
title: nls.localize('DownloadingUpdate', "Downloading Update..."),
|
||||
precondition: CONTEXT_UPDATE_STATE.isEqualTo('')
|
||||
},
|
||||
when: CONTEXT_UPDATE_STATE.isEqualTo(StateType.Downloading),
|
||||
});
|
||||
|
||||
private getUpdateAction(): IAction | null {
|
||||
const state = this.updateService.state;
|
||||
CommandsRegistry.registerCommand('update.install', () => this.updateService.applyUpdate());
|
||||
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
|
||||
group: '5_update',
|
||||
command: {
|
||||
id: 'update.install',
|
||||
title: nls.localize('installUpdate...', "Install Update...")
|
||||
},
|
||||
when: CONTEXT_UPDATE_STATE.isEqualTo(StateType.Downloaded),
|
||||
});
|
||||
|
||||
switch (state.type) {
|
||||
case StateType.Uninitialized:
|
||||
return null;
|
||||
CommandsRegistry.registerCommand('update.updating', () => { });
|
||||
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
|
||||
group: '5_update',
|
||||
command: {
|
||||
id: 'update.updating',
|
||||
title: nls.localize('installingUpdate', "Installing Update..."),
|
||||
precondition: CONTEXT_UPDATE_STATE.isEqualTo('')
|
||||
},
|
||||
when: CONTEXT_UPDATE_STATE.isEqualTo(StateType.Updating),
|
||||
});
|
||||
|
||||
case StateType.Idle:
|
||||
const windowId = this.environmentService.configuration.windowId;
|
||||
return new Action('update.check', nls.localize('checkForUpdates', "Check for Updates..."), undefined, true, () =>
|
||||
this.updateService.checkForUpdates({ windowId }));
|
||||
|
||||
case StateType.CheckingForUpdates:
|
||||
return new Action('update.checking', nls.localize('checkingForUpdates', "Checking For Updates..."), undefined, false);
|
||||
|
||||
case StateType.AvailableForDownload:
|
||||
return new Action('update.downloadNow', nls.localize('download now', "Download Now"), undefined, true, () =>
|
||||
this.updateService.downloadUpdate());
|
||||
|
||||
case StateType.Downloading:
|
||||
return new Action('update.downloading', nls.localize('DownloadingUpdate', "Downloading Update..."), undefined, false);
|
||||
|
||||
case StateType.Downloaded:
|
||||
return new Action('update.install', nls.localize('installUpdate...', "Install Update..."), undefined, true, () =>
|
||||
this.updateService.applyUpdate());
|
||||
|
||||
case StateType.Updating:
|
||||
return new Action('update.updating', nls.localize('installingUpdate', "Installing Update..."), undefined, false);
|
||||
|
||||
case StateType.Ready:
|
||||
return new Action('update.restart', nls.localize('restartToUpdate', "Restart to Update"), undefined, true, () =>
|
||||
this.updateService.quitAndInstall());
|
||||
}
|
||||
CommandsRegistry.registerCommand('update.restart', () => this.updateService.quitAndInstall());
|
||||
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
|
||||
group: '5_update',
|
||||
command: {
|
||||
id: 'update.restart',
|
||||
title: nls.localize('restartToUpdate', "Restart to Update")
|
||||
},
|
||||
when: CONTEXT_UPDATE_STATE.isEqualTo(StateType.Ready),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue