Skip to content

Commit 0403d69

Browse files
committed
use FalseContext, change Download Update label
1 parent 0337567 commit 0403d69

2 files changed

Lines changed: 18 additions & 14 deletions

File tree

src/vs/platform/contextkey/common/contextkeys.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
6+
import { RawContextKey, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
77

88
export const InputFocusedContextKey = 'inputFocus';
99
export const InputFocusedContext = new RawContextKey<boolean>(InputFocusedContextKey, false);
10+
11+
export const FalseContext: ContextKeyExpr = new RawContextKey<boolean>('__false', false);

src/vs/workbench/contrib/update/electron-browser/update.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
2828
import { RawContextKey, IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
2929
import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
3030
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
31+
import { FalseContext } from 'vs/platform/contextkey/common/contextkeys';
3132

32-
export const CONTEXT_UPDATE_STATE = new RawContextKey<string>('updateStateContext', '');
33+
const CONTEXT_UPDATE_STATE = new RawContextKey<string>('updateState', StateType.Uninitialized);
3334

3435
let releaseNotesManager: ReleaseNotesManager | undefined = undefined;
3536

@@ -260,6 +261,7 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu
260261

261262
private onUpdateStateChange(state: UpdateState): void {
262263
this.updateStateContextKey.set(state.type);
264+
263265
switch (state.type) {
264266
case StateType.Idle:
265267
if (state.error) {
@@ -333,7 +335,7 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu
333335
severity.Info,
334336
nls.localize('thereIsUpdateAvailable', "There is an available update."),
335337
[{
336-
label: nls.localize('download now', "Download Now"),
338+
label: nls.localize('download update', "Download Update"),
337339
run: () => this.updateService.downloadUpdate()
338340
}, {
339341
label: nls.localize('later', "Later"),
@@ -464,7 +466,7 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu
464466
id: 'update.check',
465467
title: nls.localize('checkForUpdates', "Check for Updates...")
466468
},
467-
when: CONTEXT_UPDATE_STATE.isEqualTo(StateType.Idle),
469+
when: CONTEXT_UPDATE_STATE.isEqualTo(StateType.Idle)
468470
});
469471

470472
CommandsRegistry.registerCommand('update.checking', () => { });
@@ -473,19 +475,19 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu
473475
command: {
474476
id: 'update.checking',
475477
title: nls.localize('checkingForUpdates', "Checking For Updates..."),
476-
precondition: CONTEXT_UPDATE_STATE.isEqualTo('')
478+
precondition: FalseContext
477479
},
478-
when: CONTEXT_UPDATE_STATE.isEqualTo(StateType.CheckingForUpdates),
480+
when: CONTEXT_UPDATE_STATE.isEqualTo(StateType.CheckingForUpdates)
479481
});
480482

481483
CommandsRegistry.registerCommand('update.downloadNow', () => this.updateService.downloadUpdate());
482484
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
483485
group: '5_update',
484486
command: {
485487
id: 'update.downloadNow',
486-
title: nls.localize('download now', "Download Now")
488+
title: nls.localize('download update', "Download Update")
487489
},
488-
when: CONTEXT_UPDATE_STATE.isEqualTo(StateType.AvailableForDownload),
490+
when: CONTEXT_UPDATE_STATE.isEqualTo(StateType.AvailableForDownload)
489491
});
490492

491493
CommandsRegistry.registerCommand('update.downloading', () => { });
@@ -494,9 +496,9 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu
494496
command: {
495497
id: 'update.downloading',
496498
title: nls.localize('DownloadingUpdate', "Downloading Update..."),
497-
precondition: CONTEXT_UPDATE_STATE.isEqualTo('')
499+
precondition: FalseContext
498500
},
499-
when: CONTEXT_UPDATE_STATE.isEqualTo(StateType.Downloading),
501+
when: CONTEXT_UPDATE_STATE.isEqualTo(StateType.Downloading)
500502
});
501503

502504
CommandsRegistry.registerCommand('update.install', () => this.updateService.applyUpdate());
@@ -506,7 +508,7 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu
506508
id: 'update.install',
507509
title: nls.localize('installUpdate...', "Install Update...")
508510
},
509-
when: CONTEXT_UPDATE_STATE.isEqualTo(StateType.Downloaded),
511+
when: CONTEXT_UPDATE_STATE.isEqualTo(StateType.Downloaded)
510512
});
511513

512514
CommandsRegistry.registerCommand('update.updating', () => { });
@@ -515,9 +517,9 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu
515517
command: {
516518
id: 'update.updating',
517519
title: nls.localize('installingUpdate', "Installing Update..."),
518-
precondition: CONTEXT_UPDATE_STATE.isEqualTo('')
520+
precondition: FalseContext
519521
},
520-
when: CONTEXT_UPDATE_STATE.isEqualTo(StateType.Updating),
522+
when: CONTEXT_UPDATE_STATE.isEqualTo(StateType.Updating)
521523
});
522524

523525
CommandsRegistry.registerCommand('update.restart', () => this.updateService.quitAndInstall());
@@ -527,7 +529,7 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu
527529
id: 'update.restart',
528530
title: nls.localize('restartToUpdate', "Restart to Update")
529531
},
530-
when: CONTEXT_UPDATE_STATE.isEqualTo(StateType.Ready),
532+
when: CONTEXT_UPDATE_STATE.isEqualTo(StateType.Ready)
531533
});
532534
}
533535
}

0 commit comments

Comments
 (0)