@codingame/monaco-vscode-notifications-service-override 2.0.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsActions.js +33 -4
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsCenter.js +72 -13
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsStatus.js +3 -3
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsToasts.js +9 -2
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsViewer.js +44 -16
- package/vscode/src/vs/workbench/services/notification/common/notificationService.js +81 -26
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-notifications-service-override",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "CodinGame",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"module": "index.js",
|
|
19
19
|
"types": "index.d.ts",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"vscode": "npm:@codingame/monaco-vscode-api@2.0
|
|
21
|
+
"vscode": "npm:@codingame/monaco-vscode-api@2.1.0",
|
|
22
22
|
"vscode-marked": "npm:marked@=3.0.2",
|
|
23
|
-
"@codingame/monaco-vscode-layout-service-override": "2.0
|
|
23
|
+
"@codingame/monaco-vscode-layout-service-override": "2.1.0"
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -2,7 +2,7 @@ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.e
|
|
|
2
2
|
import './media/notificationsActions.css.js';
|
|
3
3
|
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
4
4
|
import { Action } from 'vscode/vscode/vs/base/common/actions';
|
|
5
|
-
import { CLEAR_NOTIFICATION, CLEAR_ALL_NOTIFICATIONS, TOGGLE_DO_NOT_DISTURB_MODE, HIDE_NOTIFICATIONS_CENTER, EXPAND_NOTIFICATION, COLLAPSE_NOTIFICATION } from 'vscode/vscode/vs/workbench/browser/parts/notifications/notificationsCommands';
|
|
5
|
+
import { CLEAR_NOTIFICATION, CLEAR_ALL_NOTIFICATIONS, TOGGLE_DO_NOT_DISTURB_MODE, TOGGLE_DO_NOT_DISTURB_MODE_BY_SOURCE, HIDE_NOTIFICATIONS_CENTER, EXPAND_NOTIFICATION, COLLAPSE_NOTIFICATION } from 'vscode/vscode/vs/workbench/browser/parts/notifications/notificationsCommands';
|
|
6
6
|
import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands';
|
|
7
7
|
import { IClipboardService } from 'vscode/vscode/vs/platform/clipboard/common/clipboardService';
|
|
8
8
|
import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
|
|
@@ -98,6 +98,35 @@ let ToggleDoNotDisturbAction = class ToggleDoNotDisturbAction extends Action {
|
|
|
98
98
|
ToggleDoNotDisturbAction = ( __decorate([
|
|
99
99
|
( __param(2, ICommandService))
|
|
100
100
|
], ToggleDoNotDisturbAction));
|
|
101
|
+
let ToggleDoNotDisturbBySourceAction = class ToggleDoNotDisturbBySourceAction extends Action {
|
|
102
|
+
static { this.ID = TOGGLE_DO_NOT_DISTURB_MODE_BY_SOURCE; }
|
|
103
|
+
static { this.LABEL = ( localizeWithPath(
|
|
104
|
+
'vs/workbench/browser/parts/notifications/notificationsActions',
|
|
105
|
+
'toggleDoNotDisturbModeBySource',
|
|
106
|
+
"Toggle Do Not Disturb Mode By Source..."
|
|
107
|
+
)); }
|
|
108
|
+
constructor(id, label, commandService) {
|
|
109
|
+
super(id, label);
|
|
110
|
+
this.commandService = commandService;
|
|
111
|
+
}
|
|
112
|
+
async run() {
|
|
113
|
+
this.commandService.executeCommand(TOGGLE_DO_NOT_DISTURB_MODE_BY_SOURCE);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
ToggleDoNotDisturbBySourceAction = ( __decorate([
|
|
117
|
+
( __param(2, ICommandService))
|
|
118
|
+
], ToggleDoNotDisturbBySourceAction));
|
|
119
|
+
class ConfigureDoNotDisturbAction extends Action {
|
|
120
|
+
static { this.ID = 'workbench.action.configureDoNotDisturbMode'; }
|
|
121
|
+
static { this.LABEL = ( localizeWithPath(
|
|
122
|
+
'vs/workbench/browser/parts/notifications/notificationsActions',
|
|
123
|
+
'configureDoNotDisturbMode',
|
|
124
|
+
"Configure Do Not Disturb..."
|
|
125
|
+
)); }
|
|
126
|
+
constructor(id, label) {
|
|
127
|
+
super(id, label, ThemeIcon.asClassName(doNotDisturbIcon));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
101
130
|
let HideNotificationsCenterAction = class HideNotificationsCenterAction extends Action {
|
|
102
131
|
static { this.ID = HIDE_NOTIFICATIONS_CENTER; }
|
|
103
132
|
static { this.LABEL = ( localizeWithPath(
|
|
@@ -159,9 +188,9 @@ class ConfigureNotificationAction extends Action {
|
|
|
159
188
|
'configureNotification',
|
|
160
189
|
"More Actions..."
|
|
161
190
|
)); }
|
|
162
|
-
constructor(id, label,
|
|
191
|
+
constructor(id, label, notification) {
|
|
163
192
|
super(id, label, ThemeIcon.asClassName(configureIcon));
|
|
164
|
-
this.
|
|
193
|
+
this.notification = notification;
|
|
165
194
|
}
|
|
166
195
|
}
|
|
167
196
|
let CopyNotificationMessageAction = class CopyNotificationMessageAction extends Action {
|
|
@@ -183,4 +212,4 @@ CopyNotificationMessageAction = ( __decorate([
|
|
|
183
212
|
( __param(2, IClipboardService))
|
|
184
213
|
], CopyNotificationMessageAction));
|
|
185
214
|
|
|
186
|
-
export { ClearAllNotificationsAction, ClearNotificationAction, CollapseNotificationAction, ConfigureNotificationAction, CopyNotificationMessageAction, ExpandNotificationAction, HideNotificationsCenterAction, ToggleDoNotDisturbAction };
|
|
215
|
+
export { ClearAllNotificationsAction, ClearNotificationAction, CollapseNotificationAction, ConfigureDoNotDisturbAction, ConfigureNotificationAction, CopyNotificationMessageAction, ExpandNotificationAction, HideNotificationsCenterAction, ToggleDoNotDisturbAction, ToggleDoNotDisturbBySourceAction };
|
|
@@ -14,19 +14,23 @@ import { widgetShadow } from 'vscode/vscode/vs/platform/theme/common/colorRegist
|
|
|
14
14
|
import { IEditorGroupsService } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService';
|
|
15
15
|
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
16
16
|
import { ActionBar } from 'vscode/vscode/vs/base/browser/ui/actionbar/actionbar';
|
|
17
|
-
import {
|
|
17
|
+
import { ConfigureDoNotDisturbAction, ToggleDoNotDisturbAction, ToggleDoNotDisturbBySourceAction, ClearAllNotificationsAction, HideNotificationsCenterAction } from './notificationsActions.js';
|
|
18
|
+
import { toAction, Separator } from 'vscode/vscode/vs/base/common/actions';
|
|
18
19
|
import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding';
|
|
19
20
|
import { assertIsDefined, assertAllDefined } from 'vscode/vscode/vs/base/common/types';
|
|
20
21
|
import { NotificationsCenterVisibleContext } from 'vscode/vscode/vs/workbench/common/contextkeys';
|
|
21
|
-
import { INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification';
|
|
22
|
-
import { IAccessibleNotificationService } from 'vscode/vscode/vs/platform/accessibility/common/accessibility';
|
|
22
|
+
import { NotificationsFilter, INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification';
|
|
23
23
|
import { mainWindow } from 'vscode/vscode/vs/base/browser/window';
|
|
24
|
+
import { IContextMenuService } from 'vscode/vscode/vs/platform/contextview/browser/contextView';
|
|
25
|
+
import { DropdownMenuActionViewItem } from 'vscode/vscode/vs/base/browser/ui/dropdown/dropdownActionViewItem';
|
|
26
|
+
import { AudioCue, IAudioCueService } from 'vscode/vscode/vs/platform/audioCues/browser/audioCueService';
|
|
24
27
|
|
|
25
28
|
var NotificationsCenter_1;
|
|
26
29
|
let NotificationsCenter = class NotificationsCenter extends Themable {
|
|
27
30
|
static { NotificationsCenter_1 = this; }
|
|
28
31
|
static { this.MAX_DIMENSIONS = ( new Dimension(450, 400)); }
|
|
29
|
-
|
|
32
|
+
static { this.MAX_NOTIFICATION_SOURCES = 10; }
|
|
33
|
+
constructor(container, model, themeService, instantiationService, layoutService, contextKeyService, editorGroupService, keybindingService, notificationService, audioCueService, contextMenuService) {
|
|
30
34
|
super(themeService);
|
|
31
35
|
this.container = container;
|
|
32
36
|
this.model = model;
|
|
@@ -36,7 +40,8 @@ let NotificationsCenter = class NotificationsCenter extends Themable {
|
|
|
36
40
|
this.editorGroupService = editorGroupService;
|
|
37
41
|
this.keybindingService = keybindingService;
|
|
38
42
|
this.notificationService = notificationService;
|
|
39
|
-
this.
|
|
43
|
+
this.audioCueService = audioCueService;
|
|
44
|
+
this.contextMenuService = contextMenuService;
|
|
40
45
|
this._onDidChangeVisibility = this._register(( new Emitter()));
|
|
41
46
|
this.onDidChangeVisibility = this._onDidChangeVisibility.event;
|
|
42
47
|
this.notificationsCenterVisibleContextKey = NotificationsCenterVisibleContext.bindTo(this.contextKeyService);
|
|
@@ -46,10 +51,12 @@ let NotificationsCenter = class NotificationsCenter extends Themable {
|
|
|
46
51
|
registerListeners() {
|
|
47
52
|
this._register(this.model.onDidChangeNotification(e => this.onDidChangeNotification(e)));
|
|
48
53
|
this._register(this.layoutService.onDidLayoutMainContainer(dimension => this.layout(Dimension.lift(dimension))));
|
|
49
|
-
this._register(this.notificationService.
|
|
54
|
+
this._register(this.notificationService.onDidChangeFilter(() => this.onDidChangeFilter()));
|
|
50
55
|
}
|
|
51
|
-
|
|
52
|
-
this.
|
|
56
|
+
onDidChangeFilter() {
|
|
57
|
+
if (this.notificationService.getFilter() === NotificationsFilter.ERROR) {
|
|
58
|
+
this.hide();
|
|
59
|
+
}
|
|
53
60
|
}
|
|
54
61
|
get isVisible() {
|
|
55
62
|
return !!this._isVisible;
|
|
@@ -109,18 +116,69 @@ let NotificationsCenter = class NotificationsCenter extends Themable {
|
|
|
109
116
|
toolbarContainer.classList.add('notifications-center-header-toolbar');
|
|
110
117
|
this.notificationsCenterHeader.appendChild(toolbarContainer);
|
|
111
118
|
const actionRunner = this._register(this.instantiationService.createInstance(NotificationActionRunner));
|
|
119
|
+
const that = this;
|
|
112
120
|
const notificationsToolBar = this._register(( new ActionBar(toolbarContainer, {
|
|
113
121
|
ariaLabel: ( localizeWithPath(
|
|
114
122
|
'vs/workbench/browser/parts/notifications/notificationsCenter',
|
|
115
123
|
'notificationsToolbar',
|
|
116
124
|
"Notification Center Actions"
|
|
117
125
|
)),
|
|
118
|
-
actionRunner
|
|
126
|
+
actionRunner,
|
|
127
|
+
actionViewItemProvider: action => {
|
|
128
|
+
if (action.id === ConfigureDoNotDisturbAction.ID) {
|
|
129
|
+
return this._register(this.instantiationService.createInstance(DropdownMenuActionViewItem, action, {
|
|
130
|
+
getActions() {
|
|
131
|
+
const actions = [toAction({
|
|
132
|
+
id: ToggleDoNotDisturbAction.ID,
|
|
133
|
+
label: that.notificationService.getFilter() === NotificationsFilter.OFF ? ( localizeWithPath(
|
|
134
|
+
'vs/workbench/browser/parts/notifications/notificationsCenter',
|
|
135
|
+
'turnOnNotifications',
|
|
136
|
+
"Enable Do Not Disturb Mode"
|
|
137
|
+
)) : ( localizeWithPath(
|
|
138
|
+
'vs/workbench/browser/parts/notifications/notificationsCenter',
|
|
139
|
+
'turnOffNotifications',
|
|
140
|
+
"Disable Do Not Disturb Mode"
|
|
141
|
+
)),
|
|
142
|
+
run: () => that.notificationService.setFilter(that.notificationService.getFilter() === NotificationsFilter.OFF ? NotificationsFilter.ERROR : NotificationsFilter.OFF)
|
|
143
|
+
})];
|
|
144
|
+
const sortedFilters = that.notificationService.getFilters().sort((a, b) => a.label.localeCompare(b.label));
|
|
145
|
+
for (const source of sortedFilters.slice(0, NotificationsCenter_1.MAX_NOTIFICATION_SOURCES)) {
|
|
146
|
+
if (actions.length === 1) {
|
|
147
|
+
actions.push(( new Separator()));
|
|
148
|
+
}
|
|
149
|
+
actions.push(toAction({
|
|
150
|
+
id: `${ToggleDoNotDisturbAction.ID}.${source.id}`,
|
|
151
|
+
label: source.label,
|
|
152
|
+
checked: source.filter !== NotificationsFilter.ERROR,
|
|
153
|
+
run: () => that.notificationService.setFilter({
|
|
154
|
+
...source,
|
|
155
|
+
filter: source.filter === NotificationsFilter.ERROR ? NotificationsFilter.OFF : NotificationsFilter.ERROR
|
|
156
|
+
})
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
159
|
+
if (sortedFilters.length > NotificationsCenter_1.MAX_NOTIFICATION_SOURCES) {
|
|
160
|
+
actions.push(( new Separator()));
|
|
161
|
+
actions.push(that._register(that.instantiationService.createInstance(ToggleDoNotDisturbBySourceAction, ToggleDoNotDisturbBySourceAction.ID, ( localizeWithPath(
|
|
162
|
+
'vs/workbench/browser/parts/notifications/notificationsCenter',
|
|
163
|
+
'moreSources',
|
|
164
|
+
"More…"
|
|
165
|
+
)))));
|
|
166
|
+
}
|
|
167
|
+
return actions;
|
|
168
|
+
},
|
|
169
|
+
}, this.contextMenuService, {
|
|
170
|
+
actionRunner,
|
|
171
|
+
classNames: action.class,
|
|
172
|
+
keybindingProvider: action => this.keybindingService.lookupKeybinding(action.id)
|
|
173
|
+
}));
|
|
174
|
+
}
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
119
177
|
})));
|
|
120
178
|
this.clearAllAction = this._register(this.instantiationService.createInstance(ClearAllNotificationsAction, ClearAllNotificationsAction.ID, ClearAllNotificationsAction.LABEL));
|
|
121
179
|
notificationsToolBar.push(this.clearAllAction, { icon: true, label: false, keybinding: this.getKeybindingLabel(this.clearAllAction) });
|
|
122
|
-
this.
|
|
123
|
-
notificationsToolBar.push(this.
|
|
180
|
+
this.configureDoNotDisturbAction = this._register(this.instantiationService.createInstance(ConfigureDoNotDisturbAction, ConfigureDoNotDisturbAction.ID, ConfigureDoNotDisturbAction.LABEL));
|
|
181
|
+
notificationsToolBar.push(this.configureDoNotDisturbAction, { icon: true, label: false });
|
|
124
182
|
const hideAllAction = this._register(this.instantiationService.createInstance(HideNotificationsCenterAction, HideNotificationsCenterAction.ID, HideNotificationsCenterAction.LABEL));
|
|
125
183
|
notificationsToolBar.push(hideAllAction, { icon: true, label: false, keybinding: this.getKeybindingLabel(hideAllAction) });
|
|
126
184
|
this.notificationsList = this.instantiationService.createInstance(NotificationsList, this.notificationsCenterContainer, {
|
|
@@ -232,7 +290,7 @@ let NotificationsCenter = class NotificationsCenter extends Themable {
|
|
|
232
290
|
if (!notification.hasProgress) {
|
|
233
291
|
notification.close();
|
|
234
292
|
}
|
|
235
|
-
this.
|
|
293
|
+
this.audioCueService.playAudioCue(AudioCue.clear);
|
|
236
294
|
}
|
|
237
295
|
}
|
|
238
296
|
};
|
|
@@ -244,7 +302,8 @@ NotificationsCenter = NotificationsCenter_1 = ( __decorate([
|
|
|
244
302
|
( __param(6, IEditorGroupsService)),
|
|
245
303
|
( __param(7, IKeybindingService)),
|
|
246
304
|
( __param(8, INotificationService)),
|
|
247
|
-
( __param(9,
|
|
305
|
+
( __param(9, IAudioCueService)),
|
|
306
|
+
( __param(10, IContextMenuService))
|
|
248
307
|
], NotificationsCenter));
|
|
249
308
|
|
|
250
309
|
export { NotificationsCenter };
|
|
@@ -3,7 +3,7 @@ import { IStatusbarService } from 'vscode/vscode/vs/workbench/services/statusbar
|
|
|
3
3
|
import { Disposable, dispose } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
4
4
|
import { HIDE_NOTIFICATIONS_CENTER, SHOW_NOTIFICATIONS_CENTER } from 'vscode/vscode/vs/workbench/browser/parts/notifications/notificationsCommands';
|
|
5
5
|
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
6
|
-
import { INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification';
|
|
6
|
+
import { NotificationsFilter, INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification';
|
|
7
7
|
|
|
8
8
|
let NotificationsStatus = class NotificationsStatus extends Disposable {
|
|
9
9
|
constructor(model, statusbarService, notificationService) {
|
|
@@ -23,7 +23,7 @@ let NotificationsStatus = class NotificationsStatus extends Disposable {
|
|
|
23
23
|
registerListeners() {
|
|
24
24
|
this._register(this.model.onDidChangeNotification(e => this.onDidChangeNotification(e)));
|
|
25
25
|
this._register(this.model.onDidChangeStatusMessage(e => this.onDidChangeStatusMessage(e)));
|
|
26
|
-
this._register(this.notificationService.
|
|
26
|
+
this._register(this.notificationService.onDidChangeFilter(() => this.updateNotificationsCenterStatusItem()));
|
|
27
27
|
}
|
|
28
28
|
onDidChangeNotification(e) {
|
|
29
29
|
if (!this.isNotificationsCenterVisible) {
|
|
@@ -61,7 +61,7 @@ let NotificationsStatus = class NotificationsStatus extends Disposable {
|
|
|
61
61
|
tooltip: this.getTooltip(notificationsInProgress),
|
|
62
62
|
showBeak: this.isNotificationsCenterVisible
|
|
63
63
|
};
|
|
64
|
-
if (this.notificationService.
|
|
64
|
+
if (this.notificationService.getFilter() === NotificationsFilter.ERROR) {
|
|
65
65
|
statusProperties = {
|
|
66
66
|
...statusProperties,
|
|
67
67
|
text: `${notificationsInProgress > 0 || this.newNotificationsCount > 0 ? '$(bell-slash-dot)' : '$(bell-slash)'}`,
|
|
@@ -66,10 +66,17 @@ let NotificationsToasts = class NotificationsToasts extends Themable {
|
|
|
66
66
|
this.model.notifications.forEach(notification => this.addToast(notification));
|
|
67
67
|
this._register(this.model.onDidChangeNotification(e => this.onDidChangeNotification(e)));
|
|
68
68
|
});
|
|
69
|
-
this._register(this.model.onDidChangeFilter(
|
|
70
|
-
if (
|
|
69
|
+
this._register(this.model.onDidChangeFilter(({ global, sources }) => {
|
|
70
|
+
if (global === NotificationsFilter.ERROR) {
|
|
71
71
|
this.hide();
|
|
72
72
|
}
|
|
73
|
+
else if (sources) {
|
|
74
|
+
for (const [notification] of this.mapNotificationToToast) {
|
|
75
|
+
if (typeof notification.sourceId === 'string' && sources.get(notification.sourceId) === NotificationsFilter.ERROR && notification.severity !== Severity.Error && notification.priority !== NotificationPriority.URGENT) {
|
|
76
|
+
this.removeToast(notification);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
73
80
|
}));
|
|
74
81
|
}
|
|
75
82
|
onDidChangeNotification(e) {
|
|
@@ -5,7 +5,7 @@ import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
|
5
5
|
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
6
6
|
import { ButtonBar } from 'vscode/vscode/vs/base/browser/ui/button/button';
|
|
7
7
|
import { ActionBar } from 'vscode/vscode/vs/base/browser/ui/actionbar/actionbar';
|
|
8
|
-
import { ActionRunner } from 'vscode/vscode/vs/base/common/actions';
|
|
8
|
+
import { toAction, Separator, ActionRunner } from 'vscode/vscode/vs/base/common/actions';
|
|
9
9
|
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
10
10
|
import { DisposableStore, dispose, Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
11
11
|
import { IContextMenuService } from 'vscode/vscode/vs/platform/contextview/browser/contextView';
|
|
@@ -13,7 +13,7 @@ import { NotificationViewItem, ChoiceAction } from 'vscode/vscode/vs/workbench/c
|
|
|
13
13
|
import { ConfigureNotificationAction, ClearNotificationAction, ExpandNotificationAction, CollapseNotificationAction } from './notificationsActions.js';
|
|
14
14
|
import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding';
|
|
15
15
|
import { ProgressBar } from 'vscode/vscode/vs/base/browser/ui/progressbar/progressbar';
|
|
16
|
-
import { Severity } from 'vscode/vscode/vs/platform/notification/common/notification';
|
|
16
|
+
import { isNotificationSource, NotificationsFilter, Severity, INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification';
|
|
17
17
|
import { isNonEmptyArray } from 'vscode/vscode/vs/base/common/arrays';
|
|
18
18
|
import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
|
|
19
19
|
import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
|
|
@@ -128,10 +128,11 @@ class NotificationMessageRenderer {
|
|
|
128
128
|
let NotificationRenderer = class NotificationRenderer {
|
|
129
129
|
static { NotificationRenderer_1 = this; }
|
|
130
130
|
static { this.TEMPLATE_ID = 'notification'; }
|
|
131
|
-
constructor(actionRunner, contextMenuService, instantiationService) {
|
|
131
|
+
constructor(actionRunner, contextMenuService, instantiationService, notificationService) {
|
|
132
132
|
this.actionRunner = actionRunner;
|
|
133
133
|
this.contextMenuService = contextMenuService;
|
|
134
134
|
this.instantiationService = instantiationService;
|
|
135
|
+
this.notificationService = notificationService;
|
|
135
136
|
}
|
|
136
137
|
get templateId() {
|
|
137
138
|
return NotificationRenderer_1.TEMPLATE_ID;
|
|
@@ -147,6 +148,7 @@ let NotificationRenderer = class NotificationRenderer {
|
|
|
147
148
|
data.icon.classList.add('notification-list-item-icon', 'codicon');
|
|
148
149
|
data.message = document.createElement('div');
|
|
149
150
|
data.message.classList.add('notification-list-item-message');
|
|
151
|
+
const that = this;
|
|
150
152
|
const toolbarContainer = document.createElement('div');
|
|
151
153
|
toolbarContainer.classList.add('notification-list-item-toolbar-container');
|
|
152
154
|
data.toolbar = ( new ActionBar(toolbarContainer, {
|
|
@@ -156,15 +158,41 @@ let NotificationRenderer = class NotificationRenderer {
|
|
|
156
158
|
"Notification Actions"
|
|
157
159
|
)),
|
|
158
160
|
actionViewItemProvider: action => {
|
|
159
|
-
if (action
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
161
|
+
if (action instanceof ConfigureNotificationAction) {
|
|
162
|
+
return data.toDispose.add(( new DropdownMenuActionViewItem(action, {
|
|
163
|
+
getActions() {
|
|
164
|
+
const actions = [];
|
|
165
|
+
const source = { id: action.notification.sourceId, label: action.notification.source };
|
|
166
|
+
if (isNotificationSource(source)) {
|
|
167
|
+
const isSourceFiltered = that.notificationService.getFilter(source) === NotificationsFilter.ERROR;
|
|
168
|
+
actions.push(toAction({
|
|
169
|
+
id: source.id,
|
|
170
|
+
label: isSourceFiltered ? ( localizeWithPath(
|
|
171
|
+
'vs/workbench/browser/parts/notifications/notificationsViewer',
|
|
172
|
+
'turnOnNotifications',
|
|
173
|
+
"Turn On Notifications from '{0}'",
|
|
174
|
+
source.label
|
|
175
|
+
)) : ( localizeWithPath(
|
|
176
|
+
'vs/workbench/browser/parts/notifications/notificationsViewer',
|
|
177
|
+
'turnOffNotifications',
|
|
178
|
+
"Turn Off Notifications from '{0}'",
|
|
179
|
+
source.label
|
|
180
|
+
)),
|
|
181
|
+
run: () => that.notificationService.setFilter({ ...source, filter: isSourceFiltered ? NotificationsFilter.OFF : NotificationsFilter.ERROR })
|
|
182
|
+
}));
|
|
183
|
+
if (action.notification.actions?.secondary?.length) {
|
|
184
|
+
actions.push(( new Separator()));
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (Array.isArray(action.notification.actions?.secondary)) {
|
|
188
|
+
actions.push(...action.notification.actions.secondary);
|
|
189
|
+
}
|
|
190
|
+
return actions;
|
|
191
|
+
},
|
|
192
|
+
}, this.contextMenuService, {
|
|
193
|
+
actionRunner: this.actionRunner,
|
|
194
|
+
classNames: action.class
|
|
195
|
+
})));
|
|
168
196
|
}
|
|
169
197
|
return undefined;
|
|
170
198
|
},
|
|
@@ -200,7 +228,8 @@ let NotificationRenderer = class NotificationRenderer {
|
|
|
200
228
|
};
|
|
201
229
|
NotificationRenderer = NotificationRenderer_1 = ( __decorate([
|
|
202
230
|
( __param(1, IContextMenuService)),
|
|
203
|
-
( __param(2, IInstantiationService))
|
|
231
|
+
( __param(2, IInstantiationService)),
|
|
232
|
+
( __param(3, INotificationService))
|
|
204
233
|
], NotificationRenderer));
|
|
205
234
|
let NotificationTemplateRenderer = class NotificationTemplateRenderer extends Disposable {
|
|
206
235
|
static { NotificationTemplateRenderer_1 = this; }
|
|
@@ -282,9 +311,8 @@ let NotificationTemplateRenderer = class NotificationTemplateRenderer extends Di
|
|
|
282
311
|
}
|
|
283
312
|
renderSecondaryActions(notification, messageOverflows) {
|
|
284
313
|
const actions = [];
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
const configureNotificationAction = this.instantiationService.createInstance(ConfigureNotificationAction, ConfigureNotificationAction.ID, ConfigureNotificationAction.LABEL, secondaryActions);
|
|
314
|
+
if (isNonEmptyArray(notification.actions?.secondary)) {
|
|
315
|
+
const configureNotificationAction = this.instantiationService.createInstance(ConfigureNotificationAction, ConfigureNotificationAction.ID, ConfigureNotificationAction.LABEL, notification);
|
|
288
316
|
actions.push(configureNotificationAction);
|
|
289
317
|
this.inputDisposables.add(configureNotificationAction);
|
|
290
318
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
2
|
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
3
|
-
import { NotificationsFilter, Severity, NoOpNotification, NeverShowAgainScope } from 'vscode/vscode/vs/platform/notification/common/notification';
|
|
3
|
+
import { isNotificationSource, NotificationsFilter, Severity, NoOpNotification, NeverShowAgainScope } from 'vscode/vscode/vs/platform/notification/common/notification';
|
|
4
4
|
import { NotificationsModel, ChoiceAction } from 'vscode/vscode/vs/workbench/common/notifications';
|
|
5
5
|
import { Disposable, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
6
6
|
import { Emitter, Event } from 'vscode/vscode/vs/base/common/event';
|
|
@@ -18,10 +18,17 @@ let NotificationService = class NotificationService extends Disposable {
|
|
|
18
18
|
this.onDidAddNotification = this._onDidAddNotification.event;
|
|
19
19
|
this._onDidRemoveNotification = this._register(( new Emitter()));
|
|
20
20
|
this.onDidRemoveNotification = this._onDidRemoveNotification.event;
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
24
|
-
this.
|
|
21
|
+
this._onDidChangeFilter = this._register(( new Emitter()));
|
|
22
|
+
this.onDidChangeFilter = this._onDidChangeFilter.event;
|
|
23
|
+
this.globalFilterEnabled = this.storageService.getBoolean(NotificationService_1.GLOBAL_FILTER_SETTINGS_KEY, -1 , false);
|
|
24
|
+
this.mapSourceToFilter = (() => {
|
|
25
|
+
const map = ( new Map());
|
|
26
|
+
for (const sourceFilter of this.storageService.getObject(NotificationService_1.PER_SOURCE_FILTER_SETTINGS_KEY, -1 , [])) {
|
|
27
|
+
map.set(sourceFilter.id, sourceFilter);
|
|
28
|
+
}
|
|
29
|
+
return map;
|
|
30
|
+
})();
|
|
31
|
+
this.updateFilters();
|
|
25
32
|
this.registerListeners();
|
|
26
33
|
}
|
|
27
34
|
registerListeners() {
|
|
@@ -29,13 +36,22 @@ let NotificationService = class NotificationService extends Disposable {
|
|
|
29
36
|
switch (e.kind) {
|
|
30
37
|
case 0 :
|
|
31
38
|
case 3 : {
|
|
39
|
+
const source = typeof e.item.sourceId === 'string' && typeof e.item.source === 'string' ? { id: e.item.sourceId, label: e.item.source } : e.item.source;
|
|
32
40
|
const notification = {
|
|
33
41
|
message: e.item.message.original,
|
|
34
42
|
severity: e.item.severity,
|
|
35
|
-
source
|
|
43
|
+
source,
|
|
36
44
|
priority: e.item.priority
|
|
37
45
|
};
|
|
38
46
|
if (e.kind === 0 ) {
|
|
47
|
+
if (isNotificationSource(source)) {
|
|
48
|
+
if (!( this.mapSourceToFilter.has(source.id))) {
|
|
49
|
+
this.setFilter({ ...source, filter: NotificationsFilter.OFF });
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
this.updateSourceFilter(source);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
39
55
|
this._onDidAddNotification.fire(notification);
|
|
40
56
|
}
|
|
41
57
|
if (e.kind === 3 ) {
|
|
@@ -46,46 +62,85 @@ let NotificationService = class NotificationService extends Disposable {
|
|
|
46
62
|
}
|
|
47
63
|
}));
|
|
48
64
|
}
|
|
49
|
-
static { this.
|
|
50
|
-
|
|
51
|
-
|
|
65
|
+
static { this.GLOBAL_FILTER_SETTINGS_KEY = 'notifications.doNotDisturbMode'; }
|
|
66
|
+
static { this.PER_SOURCE_FILTER_SETTINGS_KEY = 'notifications.perSourceDoNotDisturbMode'; }
|
|
67
|
+
setFilter(filter) {
|
|
68
|
+
if (typeof filter === 'number') {
|
|
69
|
+
if (this.globalFilterEnabled === (filter === NotificationsFilter.ERROR)) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
this.globalFilterEnabled = filter === NotificationsFilter.ERROR;
|
|
73
|
+
this.storageService.store(NotificationService_1.GLOBAL_FILTER_SETTINGS_KEY, this.globalFilterEnabled, -1 , 1 );
|
|
74
|
+
this.updateFilters();
|
|
75
|
+
this._onDidChangeFilter.fire();
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
const existing = this.mapSourceToFilter.get(filter.id);
|
|
79
|
+
if (existing?.filter === filter.filter && existing.label === filter.label) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
this.mapSourceToFilter.set(filter.id, { id: filter.id, label: filter.label, filter: filter.filter });
|
|
83
|
+
this.saveSourceFilters();
|
|
84
|
+
this.updateFilters();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
getFilter(source) {
|
|
88
|
+
if (source) {
|
|
89
|
+
return this.mapSourceToFilter.get(source.id)?.filter ?? NotificationsFilter.OFF;
|
|
90
|
+
}
|
|
91
|
+
return this.globalFilterEnabled ? NotificationsFilter.ERROR : NotificationsFilter.OFF;
|
|
52
92
|
}
|
|
53
|
-
|
|
54
|
-
|
|
93
|
+
updateSourceFilter(source) {
|
|
94
|
+
const existing = this.mapSourceToFilter.get(source.id);
|
|
95
|
+
if (!existing) {
|
|
55
96
|
return;
|
|
56
97
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
this._onDidChangeDoNotDisturbMode.fire();
|
|
61
|
-
}
|
|
62
|
-
updateDoNotDisturbFilters() {
|
|
63
|
-
let filter;
|
|
64
|
-
if (this._doNotDisturbMode) {
|
|
65
|
-
filter = NotificationsFilter.ERROR;
|
|
98
|
+
if (existing.label !== source.label) {
|
|
99
|
+
this.mapSourceToFilter.set(source.id, { id: source.id, label: source.label, filter: existing.filter });
|
|
100
|
+
this.saveSourceFilters();
|
|
66
101
|
}
|
|
67
|
-
|
|
68
|
-
|
|
102
|
+
}
|
|
103
|
+
saveSourceFilters() {
|
|
104
|
+
this.storageService.store(NotificationService_1.PER_SOURCE_FILTER_SETTINGS_KEY, JSON.stringify([...( this.mapSourceToFilter.values())]), -1 , 1 );
|
|
105
|
+
}
|
|
106
|
+
getFilters() {
|
|
107
|
+
return [...( this.mapSourceToFilter.values())];
|
|
108
|
+
}
|
|
109
|
+
updateFilters() {
|
|
110
|
+
this.model.setFilter({
|
|
111
|
+
global: this.globalFilterEnabled ? NotificationsFilter.ERROR : NotificationsFilter.OFF,
|
|
112
|
+
sources: ( new Map(( [...( this.mapSourceToFilter.values())].map(source => [source.id, source.filter]))))
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
removeFilter(sourceId) {
|
|
116
|
+
if (this.mapSourceToFilter.delete(sourceId)) {
|
|
117
|
+
this.saveSourceFilters();
|
|
118
|
+
this.updateFilters();
|
|
69
119
|
}
|
|
70
|
-
this.model.setFilter(filter);
|
|
71
120
|
}
|
|
72
121
|
info(message) {
|
|
73
122
|
if (Array.isArray(message)) {
|
|
74
|
-
|
|
123
|
+
for (const messageEntry of message) {
|
|
124
|
+
this.info(messageEntry);
|
|
125
|
+
}
|
|
75
126
|
return;
|
|
76
127
|
}
|
|
77
128
|
this.model.addNotification({ severity: Severity.Info, message });
|
|
78
129
|
}
|
|
79
130
|
warn(message) {
|
|
80
131
|
if (Array.isArray(message)) {
|
|
81
|
-
|
|
132
|
+
for (const messageEntry of message) {
|
|
133
|
+
this.warn(messageEntry);
|
|
134
|
+
}
|
|
82
135
|
return;
|
|
83
136
|
}
|
|
84
137
|
this.model.addNotification({ severity: Severity.Warning, message });
|
|
85
138
|
}
|
|
86
139
|
error(message) {
|
|
87
140
|
if (Array.isArray(message)) {
|
|
88
|
-
|
|
141
|
+
for (const messageEntry of message) {
|
|
142
|
+
this.error(messageEntry);
|
|
143
|
+
}
|
|
89
144
|
return;
|
|
90
145
|
}
|
|
91
146
|
this.model.addNotification({ severity: Severity.Error, message });
|