mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-17 23:35:54 +01:00
Use static product info for Show Release Notes command (#296708)
This commit is contained in:
@@ -9,7 +9,7 @@ import { Registry } from '../../../../platform/registry/common/platform.js';
|
||||
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from '../../../common/contributions.js';
|
||||
import { Categories } from '../../../../platform/action/common/actionCommonCategories.js';
|
||||
import { MenuId, registerAction2, Action2 } from '../../../../platform/actions/common/actions.js';
|
||||
import { ProductContribution, UpdateContribution, CONTEXT_UPDATE_STATE, SwitchProductQualityContribution, RELEASE_NOTES_URL, showReleaseNotesInEditor, DOWNLOAD_URL, DefaultAccountUpdateContribution } from './update.js';
|
||||
import { ProductContribution, UpdateContribution, CONTEXT_UPDATE_STATE, SwitchProductQualityContribution, showReleaseNotesInEditor, DefaultAccountUpdateContribution } from './update.js';
|
||||
import { UpdateStatusBarEntryContribution } from './updateStatusBarEntry.js';
|
||||
import { LifecyclePhase } from '../../../services/lifecycle/common/lifecycle.js';
|
||||
import product from '../../../../platform/product/common/product.js';
|
||||
@@ -23,7 +23,6 @@ import { IsWebContext } from '../../../../platform/contextkey/common/contextkeys
|
||||
import { IOpenerService } from '../../../../platform/opener/common/opener.js';
|
||||
import { IProductService } from '../../../../platform/product/common/productService.js';
|
||||
import { URI } from '../../../../base/common/uri.js';
|
||||
import { ContextKeyExpr } from '../../../../platform/contextkey/common/contextkey.js';
|
||||
|
||||
const workbench = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
|
||||
|
||||
@@ -37,6 +36,8 @@ workbench.registerWorkbenchContribution(UpdateStatusBarEntryContribution, Lifecy
|
||||
|
||||
export class ShowReleaseNotesAction extends Action2 {
|
||||
|
||||
static readonly AVAILABLE = !!product.releaseNotesUrl;
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
id: ShowCurrentReleaseNotesActionId,
|
||||
@@ -46,12 +47,10 @@ export class ShowReleaseNotesAction extends Action2 {
|
||||
},
|
||||
category: { value: product.nameShort, original: product.nameShort },
|
||||
f1: true,
|
||||
precondition: RELEASE_NOTES_URL,
|
||||
menu: [{
|
||||
id: MenuId.MenubarHelpMenu,
|
||||
group: '1_welcome',
|
||||
order: 5,
|
||||
when: RELEASE_NOTES_URL,
|
||||
}]
|
||||
});
|
||||
}
|
||||
@@ -100,7 +99,9 @@ export class ShowCurrentReleaseNotesFromCurrentFileAction extends Action2 {
|
||||
}
|
||||
}
|
||||
|
||||
registerAction2(ShowReleaseNotesAction);
|
||||
if (ShowReleaseNotesAction.AVAILABLE) {
|
||||
registerAction2(ShowReleaseNotesAction);
|
||||
}
|
||||
registerAction2(ShowCurrentReleaseNotesFromCurrentFileAction);
|
||||
|
||||
// Update
|
||||
@@ -174,16 +175,17 @@ class RestartToUpdateAction extends Action2 {
|
||||
class DownloadAction extends Action2 {
|
||||
|
||||
static readonly ID = 'workbench.action.download';
|
||||
static readonly AVAILABLE = !!product.downloadUrl;
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
id: DownloadAction.ID,
|
||||
title: localize2('openDownloadPage', "Download {0}", product.nameLong),
|
||||
precondition: ContextKeyExpr.and(IsWebContext, DOWNLOAD_URL), // Only show when running in a web browser and a download url is available
|
||||
precondition: IsWebContext, // Only show when running in a web browser
|
||||
f1: true,
|
||||
menu: [{
|
||||
id: MenuId.StatusBarWindowIndicatorMenu,
|
||||
when: ContextKeyExpr.and(IsWebContext, DOWNLOAD_URL)
|
||||
when: IsWebContext
|
||||
}]
|
||||
});
|
||||
}
|
||||
@@ -198,7 +200,9 @@ class DownloadAction extends Action2 {
|
||||
}
|
||||
}
|
||||
|
||||
registerAction2(DownloadAction);
|
||||
if (DownloadAction.AVAILABLE) {
|
||||
registerAction2(DownloadAction);
|
||||
}
|
||||
registerAction2(CheckForUpdateAction);
|
||||
registerAction2(DownloadUpdateAction);
|
||||
registerAction2(InstallUpdateAction);
|
||||
|
||||
@@ -34,8 +34,6 @@ import { IDefaultAccountService } from '../../../../platform/defaultAccount/comm
|
||||
|
||||
export const CONTEXT_UPDATE_STATE = new RawContextKey<string>('updateState', StateType.Uninitialized);
|
||||
export const MAJOR_MINOR_UPDATE_AVAILABLE = new RawContextKey<boolean>('majorMinorUpdateAvailable', false);
|
||||
export const RELEASE_NOTES_URL = new RawContextKey<string>('releaseNotesUrl', '');
|
||||
export const DOWNLOAD_URL = new RawContextKey<string>('downloadUrl', '');
|
||||
|
||||
let releaseNotesManager: ReleaseNotesManager | undefined = undefined;
|
||||
|
||||
@@ -184,17 +182,7 @@ export class ProductContribution implements IWorkbenchContribution {
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IHostService hostService: IHostService,
|
||||
@IProductService productService: IProductService,
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
) {
|
||||
if (productService.releaseNotesUrl) {
|
||||
const releaseNotesUrlKey = RELEASE_NOTES_URL.bindTo(contextKeyService);
|
||||
releaseNotesUrlKey.set(productService.releaseNotesUrl);
|
||||
}
|
||||
if (productService.downloadUrl) {
|
||||
const downloadUrlKey = DOWNLOAD_URL.bindTo(contextKeyService);
|
||||
downloadUrlKey.set(productService.downloadUrl);
|
||||
}
|
||||
|
||||
if (isWeb) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user