Skip to content

Commit 4f9f4c3

Browse files
author
Benjamin Pasero
committed
1 parent b8974b0 commit 4f9f4c3

8 files changed

Lines changed: 73 additions & 134 deletions

File tree

src/vs/platform/notification/common/notification.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ export interface INotificationProperties {
3737
neverShowAgain?: INeverShowAgainOptions;
3838
}
3939

40+
export enum NeverShowAgainScope {
41+
42+
/**
43+
* Will never show this notification on the current workspace again.
44+
*/
45+
WORKSPACE,
46+
47+
/**
48+
* Will never show this notification on any workspace again.
49+
*/
50+
GLOBAL
51+
}
52+
4053
export interface INeverShowAgainOptions {
4154

4255
/**
@@ -49,6 +62,12 @@ export interface INeverShowAgainOptions {
4962
* make it a secondary action instead.
5063
*/
5164
isSecondary?: boolean;
65+
66+
/**
67+
* Wether to persist the choice in the current workspace or for all workspaces. By
68+
* default it will be persisted for all workspaces.
69+
*/
70+
scope?: NeverShowAgainScope;
5271
}
5372

5473
export interface INotification extends INotificationProperties {

src/vs/workbench/contrib/files/browser/saveErrorHandler.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ class ResolveSaveConflictAction extends Action {
236236
@IEditorService private readonly editorService: IEditorService,
237237
@INotificationService private readonly notificationService: INotificationService,
238238
@IInstantiationService private readonly instantiationService: IInstantiationService,
239-
@IStorageService private readonly storageService: IStorageService,
240239
@IEnvironmentService private readonly environmentService: IEnvironmentService
241240
) {
242241
super('workbench.files.action.resolveConflict', nls.localize('compareChanges', "Compare"));
@@ -250,21 +249,15 @@ class ResolveSaveConflictAction extends Action {
250249

251250
await TextFileContentProvider.open(resource, CONFLICT_RESOLUTION_SCHEME, editorLabel, this.editorService, { pinned: true });
252251

253-
if (this.storageService.getBoolean(LEARN_MORE_DIRTY_WRITE_IGNORE_KEY, StorageScope.GLOBAL)) {
254-
return; // return if this message is ignored
255-
}
256-
257252
// Show additional help how to resolve the save conflict
258-
const primaryActions: IAction[] = [
259-
this.instantiationService.createInstance(ResolveConflictLearnMoreAction)
260-
];
261-
const secondaryActions: IAction[] = [
262-
this.instantiationService.createInstance(DoNotShowResolveConflictLearnMoreAction)
263-
];
264-
265-
const actions: INotificationActions = { primary: primaryActions, secondary: secondaryActions };
266-
const handle = this.notificationService.notify({ severity: Severity.Info, message: conflictEditorHelp, actions });
267-
Event.once(handle.onDidClose)(() => { dispose(primaryActions); dispose(secondaryActions); });
253+
const actions: INotificationActions = { primary: [this.instantiationService.createInstance(ResolveConflictLearnMoreAction)] };
254+
const handle = this.notificationService.notify({
255+
severity: Severity.Info,
256+
message: conflictEditorHelp,
257+
actions,
258+
neverShowAgain: { id: LEARN_MORE_DIRTY_WRITE_IGNORE_KEY, isSecondary: true }
259+
});
260+
Event.once(handle.onDidClose)(() => dispose(actions.primary!));
268261
pendingResolveSaveConflictMessages.push(handle);
269262
}
270263

src/vs/workbench/contrib/localizations/browser/localizations.contribution.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ export class LocalizationWorkbenchContribution extends Disposable implements IWo
6868
}
6969

7070
private onDidInstallExtension(e: DidInstallExtensionEvent): void {
71-
const donotAskUpdateKey = 'langugage.update.donotask';
72-
if (!this.storageService.getBoolean(donotAskUpdateKey, StorageScope.GLOBAL) && e.local && e.operation === InstallOperation.Install && e.local.manifest.contributes && e.local.manifest.contributes.localizations && e.local.manifest.contributes.localizations.length) {
71+
if (e.local && e.operation === InstallOperation.Install && e.local.manifest.contributes && e.local.manifest.contributes.localizations && e.local.manifest.contributes.localizations.length) {
7372
const locale = e.local.manifest.contributes.localizations[0].languageId;
7473
if (platform.language !== locale) {
7574
const updateAndRestart = platform.locale !== locale;
@@ -83,12 +82,11 @@ export class LocalizationWorkbenchContribution extends Disposable implements IWo
8382
const updatePromise = updateAndRestart ? this.jsonEditingService.write(this.environmentService.localeResource, { key: 'locale', value: locale }, true) : Promise.resolve(undefined);
8483
updatePromise.then(() => this.windowsService.relaunch({}), e => this.notificationService.error(e));
8584
}
86-
}, {
87-
label: localize('neverAgain', "Don't Show Again"),
88-
isSecondary: true,
89-
run: () => this.storageService.store(donotAskUpdateKey, true, StorageScope.GLOBAL)
9085
}],
91-
{ sticky: true }
86+
{
87+
sticky: true,
88+
neverShowAgain: { id: 'langugage.update.donotask', isSecondary: true }
89+
}
9290
);
9391
}
9492
}
@@ -302,4 +300,4 @@ ExtensionsRegistry.registerExtensionPoint({
302300
}
303301
}
304302
}
305-
});
303+
});

src/vs/workbench/contrib/stats/electron-browser/workspaceStatsService.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ import { IFileService, IResolveFileResult, IFileStat } from 'vs/platform/files/c
88
import { IWorkspaceContextService, WorkbenchState, IWorkspace } from 'vs/platform/workspace/common/workspace';
99
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
1010
import { IWindowService, IWindowConfiguration } from 'vs/platform/windows/common/windows';
11-
import { INotificationService, IPromptChoice } from 'vs/platform/notification/common/notification';
11+
import { INotificationService, NeverShowAgainScope, INeverShowAgainOptions } from 'vs/platform/notification/common/notification';
1212
import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput';
13-
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
1413
import { ITextFileService, ITextFileContent } from 'vs/workbench/services/textfile/common/textfiles';
1514
import { URI } from 'vs/base/common/uri';
1615
import { Schemas } from 'vs/base/common/network';
@@ -22,8 +21,6 @@ import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
2221
import { IWorkspaceStatsService, Tags } from 'vs/workbench/contrib/stats/common/workspaceStats';
2322
import { getHashedRemotesFromConfig } from 'vs/workbench/contrib/stats/electron-browser/workspaceStats';
2423

25-
const DISABLE_WORKSPACE_PROMPT_KEY = 'workspaces.dontPromptToOpen';
26-
2724
const ModulesToLookFor = [
2825
// Packages that suggest a node server
2926
'express',
@@ -103,7 +100,6 @@ export class WorkspaceStatsService implements IWorkspaceStatsService {
103100
@IWindowService private readonly windowService: IWindowService,
104101
@INotificationService private readonly notificationService: INotificationService,
105102
@IQuickInputService private readonly quickInputService: IQuickInputService,
106-
@IStorageService private readonly storageService: IStorageService,
107103
@ITextFileService private readonly textFileService: ITextFileService
108104
) { }
109105

@@ -449,15 +445,7 @@ export class WorkspaceStatsService implements IWorkspaceStatsService {
449445
}
450446

451447
private doHandleWorkspaceFiles(folder: URI, workspaces: string[]): void {
452-
if (this.storageService.getBoolean(DISABLE_WORKSPACE_PROMPT_KEY, StorageScope.WORKSPACE)) {
453-
return; // prompt disabled by user
454-
}
455-
456-
const doNotShowAgain: IPromptChoice = {
457-
label: localize('never again', "Don't Show Again"),
458-
isSecondary: true,
459-
run: () => this.storageService.store(DISABLE_WORKSPACE_PROMPT_KEY, true, StorageScope.WORKSPACE)
460-
};
448+
const neverShowAgain: INeverShowAgainOptions = { id: 'workspaces.dontPromptToOpen', scope: NeverShowAgainScope.WORKSPACE, isSecondary: true };
461449

462450
// Prompt to open one workspace
463451
if (workspaces.length === 1) {
@@ -466,7 +454,7 @@ export class WorkspaceStatsService implements IWorkspaceStatsService {
466454
this.notificationService.prompt(Severity.Info, localize('workspaceFound', "This folder contains a workspace file '{0}'. Do you want to open it? [Learn more]({1}) about workspace files.", workspaceFile, 'https://go.microsoft.com/fwlink/?linkid=2025315'), [{
467455
label: localize('openWorkspace', "Open Workspace"),
468456
run: () => this.windowService.openWindow([{ workspaceUri: joinPath(folder, workspaceFile) }])
469-
}, doNotShowAgain]);
457+
}], { neverShowAgain });
470458
}
471459

472460
// Prompt to select a workspace from many
@@ -482,7 +470,7 @@ export class WorkspaceStatsService implements IWorkspaceStatsService {
482470
}
483471
});
484472
}
485-
}, doNotShowAgain]);
473+
}], { neverShowAgain });
486474
}
487475
}
488476

src/vs/workbench/contrib/terminal/browser/terminalConfigHelper.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storag
1111
import { ITerminalConfiguration, ITerminalFont, IS_WORKSPACE_SHELL_ALLOWED_STORAGE_KEY, TERMINAL_CONFIG_SECTION, DEFAULT_LETTER_SPACING, DEFAULT_LINE_HEIGHT, MINIMUM_LETTER_SPACING, LinuxDistro, IShellLaunchConfig } from 'vs/workbench/contrib/terminal/common/terminal';
1212
import Severity from 'vs/base/common/severity';
1313
import { Terminal as XTermTerminal } from 'xterm';
14-
import { INotificationService } from 'vs/platform/notification/common/notification';
14+
import { INotificationService, NeverShowAgainScope } from 'vs/platform/notification/common/notification';
1515
import { IBrowserTerminalConfigHelper } from 'vs/workbench/contrib/terminal/browser/terminal';
1616
import { Emitter, Event } from 'vs/base/common/event';
1717
import { basename } from 'vs/base/common/path';
@@ -254,7 +254,6 @@ export class TerminalConfigHelper implements IBrowserTerminalConfigHelper {
254254
return r;
255255
}
256256

257-
private readonly NO_RECOMMENDATIONS_KEY = 'terminalConfigHelper/launchRecommendationsIgnore';
258257
private recommendationsShown = false;
259258

260259
public async showRecommendations(shellLaunchConfig: IShellLaunchConfig): Promise<void> {
@@ -264,10 +263,6 @@ export class TerminalConfigHelper implements IBrowserTerminalConfigHelper {
264263
this.recommendationsShown = true;
265264

266265
if (platform.isWindows && shellLaunchConfig.executable && basename(shellLaunchConfig.executable).toLowerCase() === 'wsl.exe') {
267-
if (this._storageService.getBoolean(this.NO_RECOMMENDATIONS_KEY, StorageScope.WORKSPACE, false)) {
268-
return;
269-
}
270-
271266
if (! await this.isExtensionInstalled('ms-vscode-remote.remote-wsl')) {
272267
this._notificationService.prompt(
273268
Severity.Info,
@@ -276,16 +271,10 @@ export class TerminalConfigHelper implements IBrowserTerminalConfigHelper {
276271
"Check out the 'Visual Studio Code Remote - WSL' extension for a great development experience in WSL. Click [here]({0}) to learn more.",
277272
'https://go.microsoft.com/fwlink/?linkid=2097212'
278273
),
279-
[
280-
{
281-
label: nls.localize('doNotShowAgain', "Don't Show Again"),
282-
run: () => {
283-
this._storageService.store(this.NO_RECOMMENDATIONS_KEY, true, StorageScope.WORKSPACE);
284-
}
285-
}
286-
],
274+
[],
287275
{
288-
sticky: true
276+
sticky: true,
277+
neverShowAgain: { id: 'terminalConfigHelper/launchRecommendationsIgnore', scope: NeverShowAgainScope.WORKSPACE }
289278
}
290279
);
291280
}

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

Lines changed: 12 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storag
1919
import { IUpdateService, State as UpdateState, StateType, IUpdate } from 'vs/platform/update/common/update';
2020
import * as semver from 'semver-umd';
2121
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
22-
import { INotificationService, INotificationHandle, Severity } from 'vs/platform/notification/common/notification';
22+
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
2323
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
2424
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
2525
import { ReleaseNotesManager } from './releaseNotesEditor';
@@ -162,32 +162,8 @@ export class ProductContribution implements IWorkbenchContribution {
162162
}
163163
}
164164

165-
class NeverShowAgain {
166-
167-
private readonly key: string;
168-
169-
readonly action = new Action(`neverShowAgain:${this.key}`, nls.localize('neveragain', "Don't Show Again"), undefined, true, (notification: INotificationHandle) => {
170-
171-
// Hide notification
172-
notification.close();
173-
174-
this.storageService.store(this.key, true, StorageScope.GLOBAL);
175-
176-
return Promise.resolve(true);
177-
});
178-
179-
constructor(key: string, @IStorageService private readonly storageService: IStorageService) {
180-
this.key = `neverShowAgain:${key}`;
181-
}
182-
183-
shouldShow(): boolean {
184-
return !this.storageService.getBoolean(this.key, StorageScope.GLOBAL, false);
185-
}
186-
}
187-
188165
export class Win3264BitContribution implements IWorkbenchContribution {
189166

190-
private static readonly KEY = 'update/win32-64bits';
191167
private static readonly URL = 'https://code.visualstudio.com/updates/v1_15#_windows-64-bit';
192168
private static readonly INSIDER_URL = 'https://github.com/Microsoft/vscode-docs/blob/vnext/release-notes/v1_15.md#windows-64-bit';
193169

@@ -200,28 +176,18 @@ export class Win3264BitContribution implements IWorkbenchContribution {
200176
return;
201177
}
202178

203-
const neverShowAgain = new NeverShowAgain(Win3264BitContribution.KEY, storageService);
204-
205-
if (!neverShowAgain.shouldShow()) {
206-
return;
207-
}
208-
209179
const url = product.quality === 'insider'
210180
? Win3264BitContribution.INSIDER_URL
211181
: Win3264BitContribution.URL;
212182

213-
const handle = notificationService.prompt(
183+
notificationService.prompt(
214184
severity.Info,
215185
nls.localize('64bitisavailable', "{0} for 64-bit Windows is now available! Click [here]({1}) to learn more.", product.nameShort, url),
216-
[{
217-
label: nls.localize('neveragain', "Don't Show Again"),
218-
isSecondary: true,
219-
run: () => {
220-
neverShowAgain.action.run(handle);
221-
neverShowAgain.action.dispose();
222-
}
223-
}],
224-
{ sticky: true }
186+
[],
187+
{
188+
sticky: true,
189+
neverShowAgain: { id: 'neverShowAgain:update/win32-64bits', isSecondary: true }
190+
}
225191
);
226192
}
227193
}
@@ -396,23 +362,13 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu
396362
}
397363

398364
// windows fast updates (target === system)
399-
const neverShowAgain = new NeverShowAgain('update/win32-fast-updates', this.storageService);
400-
401-
if (!neverShowAgain.shouldShow()) {
402-
return;
403-
}
404-
405-
const handle = this.notificationService.prompt(
365+
this.notificationService.prompt(
406366
severity.Info,
407367
nls.localize('updateInstalling', "{0} {1} is being installed in the background; we'll let you know when it's done.", product.nameLong, update.productVersion),
408-
[{
409-
label: nls.localize('neveragain', "Don't Show Again"),
410-
isSecondary: true,
411-
run: () => {
412-
neverShowAgain.action.run(handle);
413-
neverShowAgain.action.dispose();
414-
}
415-
}]
368+
[],
369+
{
370+
neverShowAgain: { id: 'neverShowAgain:update/win32-fast-updates', isSecondary: true }
371+
}
416372
);
417373
}
418374

src/vs/workbench/services/files/common/workspaceWatcher.ts

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
1313
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
1414
import { ResourceMap } from 'vs/base/common/map';
1515
import { onUnexpectedError } from 'vs/base/common/errors';
16-
import { StorageScope, IStorageService } from 'vs/platform/storage/common/storage';
17-
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
16+
import { INotificationService, Severity, NeverShowAgainScope } from 'vs/platform/notification/common/notification';
1817
import { localize } from 'vs/nls';
1918
import { FileService } from 'vs/platform/files/common/fileService';
2019

@@ -26,8 +25,7 @@ export class WorkspaceWatcher extends Disposable {
2625
@IFileService private readonly fileService: FileService,
2726
@IConfigurationService private readonly configurationService: IConfigurationService,
2827
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
29-
@INotificationService private readonly notificationService: INotificationService,
30-
@IStorageService private readonly storageService: IStorageService
28+
@INotificationService private readonly notificationService: INotificationService
3129
) {
3230
super();
3331

@@ -73,38 +71,34 @@ export class WorkspaceWatcher extends Disposable {
7371
onUnexpectedError(msg);
7472

7573
// Detect if we run < .NET Framework 4.5
76-
if (msg.indexOf('System.MissingMethodException') >= 0 && !this.storageService.getBoolean('ignoreNetVersionError', StorageScope.WORKSPACE)) {
74+
if (msg.indexOf('System.MissingMethodException') >= 0) {
7775
this.notificationService.prompt(
7876
Severity.Warning,
7977
localize('netVersionError', "The Microsoft .NET Framework 4.5 is required. Please follow the link to install it."),
8078
[{
8179
label: localize('installNet', "Download .NET Framework 4.5"),
8280
run: () => window.open('https://go.microsoft.com/fwlink/?LinkId=786533')
83-
},
84-
{
85-
label: localize('neverShowAgain', "Don't Show Again"),
86-
isSecondary: true,
87-
run: () => this.storageService.store('ignoreNetVersionError', true, StorageScope.WORKSPACE)
8881
}],
89-
{ sticky: true }
82+
{
83+
sticky: true,
84+
neverShowAgain: { id: 'ignoreNetVersionError', isSecondary: true, scope: NeverShowAgainScope.WORKSPACE }
85+
}
9086
);
9187
}
9288

9389
// Detect if we run into ENOSPC issues
94-
if (msg.indexOf('ENOSPC') >= 0 && !this.storageService.getBoolean('ignoreEnospcError', StorageScope.WORKSPACE)) {
90+
if (msg.indexOf('ENOSPC') >= 0) {
9591
this.notificationService.prompt(
9692
Severity.Warning,
9793
localize('enospcError', "Unable to watch for file changes in this large workspace. Please follow the instructions link to resolve this issue."),
9894
[{
9995
label: localize('learnMore', "Instructions"),
10096
run: () => window.open('https://go.microsoft.com/fwlink/?linkid=867693')
101-
},
102-
{
103-
label: localize('neverShowAgain', "Don't Show Again"),
104-
isSecondary: true,
105-
run: () => this.storageService.store('ignoreEnospcError', true, StorageScope.WORKSPACE)
10697
}],
107-
{ sticky: true }
98+
{
99+
sticky: true,
100+
neverShowAgain: { id: 'ignoreEnospcError', isSecondary: true, scope: NeverShowAgainScope.WORKSPACE }
101+
}
108102
);
109103
}
110104
}
@@ -157,4 +151,4 @@ export class WorkspaceWatcher extends Disposable {
157151
}
158152
}
159153

160-
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(WorkspaceWatcher, LifecyclePhase.Restored);
154+
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(WorkspaceWatcher, LifecyclePhase.Restored);

0 commit comments

Comments
 (0)