@codingame/monaco-vscode-notifications-service-override 2.1.4 → 2.2.0-next.2
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/notifications.js +5 -7
- package/package.json +3 -4
- package/external/rollup-plugin-styles/dist/runtime/inject-css.js +0 -3
- package/vscode/src/vs/workbench/browser/parts/notifications/media/notificationsActions.css.js +0 -6
- package/vscode/src/vs/workbench/browser/parts/notifications/media/notificationsCenter.css.js +0 -6
- package/vscode/src/vs/workbench/browser/parts/notifications/media/notificationsList.css.js +0 -6
- package/vscode/src/vs/workbench/browser/parts/notifications/media/notificationsToasts.css.js +0 -6
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsActions.js +0 -215
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsAlerts.js +0 -75
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsCenter.js +0 -309
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsList.js +0 -228
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsStatus.js +0 -220
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsToasts.js +0 -435
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsViewer.js +0 -438
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import './media/notificationsCenter.css.js';
|
|
3
|
-
import './media/notificationsActions.css.js';
|
|
4
|
-
import { NOTIFICATIONS_CENTER_BORDER, NOTIFICATIONS_CENTER_HEADER_FOREGROUND, NOTIFICATIONS_CENTER_HEADER_BACKGROUND } from 'vscode/vscode/vs/workbench/common/theme';
|
|
5
|
-
import { Themable, IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService';
|
|
6
|
-
import { IWorkbenchLayoutService } from 'vscode/vscode/vs/workbench/services/layout/browser/layoutService';
|
|
7
|
-
import { Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
8
|
-
import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
9
|
-
import { NotificationActionRunner } from 'vscode/vscode/vs/workbench/browser/parts/notifications/notificationsCommands';
|
|
10
|
-
import { NotificationsList } from './notificationsList.js';
|
|
11
|
-
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
12
|
-
import { Dimension, isAncestorOfActiveElement } from 'vscode/vscode/vs/base/browser/dom';
|
|
13
|
-
import { widgetShadow } from 'vscode/vscode/vs/platform/theme/common/colorRegistry';
|
|
14
|
-
import { IEditorGroupsService } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService';
|
|
15
|
-
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
16
|
-
import { ActionBar } from 'vscode/vscode/vs/base/browser/ui/actionbar/actionbar';
|
|
17
|
-
import { ConfigureDoNotDisturbAction, ToggleDoNotDisturbAction, ToggleDoNotDisturbBySourceAction, ClearAllNotificationsAction, HideNotificationsCenterAction } from './notificationsActions.js';
|
|
18
|
-
import { toAction, Separator } from 'vscode/vscode/vs/base/common/actions';
|
|
19
|
-
import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding';
|
|
20
|
-
import { assertIsDefined, assertAllDefined } from 'vscode/vscode/vs/base/common/types';
|
|
21
|
-
import { NotificationsCenterVisibleContext } from 'vscode/vscode/vs/workbench/common/contextkeys';
|
|
22
|
-
import { NotificationsFilter, INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification';
|
|
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';
|
|
27
|
-
|
|
28
|
-
var NotificationsCenter_1;
|
|
29
|
-
let NotificationsCenter = class NotificationsCenter extends Themable {
|
|
30
|
-
static { NotificationsCenter_1 = this; }
|
|
31
|
-
static { this.MAX_DIMENSIONS = ( new Dimension(450, 400)); }
|
|
32
|
-
static { this.MAX_NOTIFICATION_SOURCES = 10; }
|
|
33
|
-
constructor(container, model, themeService, instantiationService, layoutService, contextKeyService, editorGroupService, keybindingService, notificationService, audioCueService, contextMenuService) {
|
|
34
|
-
super(themeService);
|
|
35
|
-
this.container = container;
|
|
36
|
-
this.model = model;
|
|
37
|
-
this.instantiationService = instantiationService;
|
|
38
|
-
this.layoutService = layoutService;
|
|
39
|
-
this.contextKeyService = contextKeyService;
|
|
40
|
-
this.editorGroupService = editorGroupService;
|
|
41
|
-
this.keybindingService = keybindingService;
|
|
42
|
-
this.notificationService = notificationService;
|
|
43
|
-
this.audioCueService = audioCueService;
|
|
44
|
-
this.contextMenuService = contextMenuService;
|
|
45
|
-
this._onDidChangeVisibility = this._register(( new Emitter()));
|
|
46
|
-
this.onDidChangeVisibility = this._onDidChangeVisibility.event;
|
|
47
|
-
this.notificationsCenterVisibleContextKey = NotificationsCenterVisibleContext.bindTo(this.contextKeyService);
|
|
48
|
-
this.notificationsCenterVisibleContextKey = NotificationsCenterVisibleContext.bindTo(contextKeyService);
|
|
49
|
-
this.registerListeners();
|
|
50
|
-
}
|
|
51
|
-
registerListeners() {
|
|
52
|
-
this._register(this.model.onDidChangeNotification(e => this.onDidChangeNotification(e)));
|
|
53
|
-
this._register(this.layoutService.onDidLayoutMainContainer(dimension => this.layout(Dimension.lift(dimension))));
|
|
54
|
-
this._register(this.notificationService.onDidChangeFilter(() => this.onDidChangeFilter()));
|
|
55
|
-
}
|
|
56
|
-
onDidChangeFilter() {
|
|
57
|
-
if (this.notificationService.getFilter() === NotificationsFilter.ERROR) {
|
|
58
|
-
this.hide();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
get isVisible() {
|
|
62
|
-
return !!this._isVisible;
|
|
63
|
-
}
|
|
64
|
-
show() {
|
|
65
|
-
if (this._isVisible) {
|
|
66
|
-
const notificationsList = assertIsDefined(this.notificationsList);
|
|
67
|
-
notificationsList.show();
|
|
68
|
-
notificationsList.focusFirst();
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
if (!this.notificationsCenterContainer) {
|
|
72
|
-
this.create();
|
|
73
|
-
}
|
|
74
|
-
this.updateTitle();
|
|
75
|
-
const [notificationsList, notificationsCenterContainer] = assertAllDefined(this.notificationsList, this.notificationsCenterContainer);
|
|
76
|
-
this._isVisible = true;
|
|
77
|
-
notificationsCenterContainer.classList.add('visible');
|
|
78
|
-
notificationsList.show();
|
|
79
|
-
this.layout(this.workbenchDimensions);
|
|
80
|
-
notificationsList.updateNotificationsList(0, 0, this.model.notifications);
|
|
81
|
-
notificationsList.focusFirst();
|
|
82
|
-
this.updateStyles();
|
|
83
|
-
this.model.notifications.forEach(notification => notification.updateVisibility(true));
|
|
84
|
-
this.notificationsCenterVisibleContextKey.set(true);
|
|
85
|
-
this._onDidChangeVisibility.fire();
|
|
86
|
-
}
|
|
87
|
-
updateTitle() {
|
|
88
|
-
const [notificationsCenterTitle, clearAllAction] = assertAllDefined(this.notificationsCenterTitle, this.clearAllAction);
|
|
89
|
-
if (this.model.notifications.length === 0) {
|
|
90
|
-
notificationsCenterTitle.textContent = ( localizeWithPath(
|
|
91
|
-
'vs/workbench/browser/parts/notifications/notificationsCenter',
|
|
92
|
-
'notificationsEmpty',
|
|
93
|
-
"No new notifications"
|
|
94
|
-
));
|
|
95
|
-
clearAllAction.enabled = false;
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
notificationsCenterTitle.textContent = ( localizeWithPath(
|
|
99
|
-
'vs/workbench/browser/parts/notifications/notificationsCenter',
|
|
100
|
-
'notifications',
|
|
101
|
-
"Notifications"
|
|
102
|
-
));
|
|
103
|
-
clearAllAction.enabled = ( this.model.notifications.some(notification => !notification.hasProgress));
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
create() {
|
|
107
|
-
this.notificationsCenterContainer = document.createElement('div');
|
|
108
|
-
this.notificationsCenterContainer.classList.add('notifications-center');
|
|
109
|
-
this.notificationsCenterHeader = document.createElement('div');
|
|
110
|
-
this.notificationsCenterHeader.classList.add('notifications-center-header');
|
|
111
|
-
this.notificationsCenterContainer.appendChild(this.notificationsCenterHeader);
|
|
112
|
-
this.notificationsCenterTitle = document.createElement('span');
|
|
113
|
-
this.notificationsCenterTitle.classList.add('notifications-center-header-title');
|
|
114
|
-
this.notificationsCenterHeader.appendChild(this.notificationsCenterTitle);
|
|
115
|
-
const toolbarContainer = document.createElement('div');
|
|
116
|
-
toolbarContainer.classList.add('notifications-center-header-toolbar');
|
|
117
|
-
this.notificationsCenterHeader.appendChild(toolbarContainer);
|
|
118
|
-
const actionRunner = this._register(this.instantiationService.createInstance(NotificationActionRunner));
|
|
119
|
-
const that = this;
|
|
120
|
-
const notificationsToolBar = this._register(( new ActionBar(toolbarContainer, {
|
|
121
|
-
ariaLabel: ( localizeWithPath(
|
|
122
|
-
'vs/workbench/browser/parts/notifications/notificationsCenter',
|
|
123
|
-
'notificationsToolbar',
|
|
124
|
-
"Notification Center Actions"
|
|
125
|
-
)),
|
|
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
|
-
}
|
|
177
|
-
})));
|
|
178
|
-
this.clearAllAction = this._register(this.instantiationService.createInstance(ClearAllNotificationsAction, ClearAllNotificationsAction.ID, ClearAllNotificationsAction.LABEL));
|
|
179
|
-
notificationsToolBar.push(this.clearAllAction, { icon: true, label: false, keybinding: this.getKeybindingLabel(this.clearAllAction) });
|
|
180
|
-
this.configureDoNotDisturbAction = this._register(this.instantiationService.createInstance(ConfigureDoNotDisturbAction, ConfigureDoNotDisturbAction.ID, ConfigureDoNotDisturbAction.LABEL));
|
|
181
|
-
notificationsToolBar.push(this.configureDoNotDisturbAction, { icon: true, label: false });
|
|
182
|
-
const hideAllAction = this._register(this.instantiationService.createInstance(HideNotificationsCenterAction, HideNotificationsCenterAction.ID, HideNotificationsCenterAction.LABEL));
|
|
183
|
-
notificationsToolBar.push(hideAllAction, { icon: true, label: false, keybinding: this.getKeybindingLabel(hideAllAction) });
|
|
184
|
-
this.notificationsList = this.instantiationService.createInstance(NotificationsList, this.notificationsCenterContainer, {
|
|
185
|
-
widgetAriaLabel: ( localizeWithPath(
|
|
186
|
-
'vs/workbench/browser/parts/notifications/notificationsCenter',
|
|
187
|
-
'notificationsCenterWidgetAriaLabel',
|
|
188
|
-
"Notifications Center"
|
|
189
|
-
))
|
|
190
|
-
});
|
|
191
|
-
this.container.appendChild(this.notificationsCenterContainer);
|
|
192
|
-
}
|
|
193
|
-
getKeybindingLabel(action) {
|
|
194
|
-
const keybinding = this.keybindingService.lookupKeybinding(action.id);
|
|
195
|
-
return keybinding ? keybinding.getLabel() : null;
|
|
196
|
-
}
|
|
197
|
-
onDidChangeNotification(e) {
|
|
198
|
-
if (!this._isVisible) {
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
let focusEditor = false;
|
|
202
|
-
const [notificationsList, notificationsCenterContainer] = assertAllDefined(this.notificationsList, this.notificationsCenterContainer);
|
|
203
|
-
switch (e.kind) {
|
|
204
|
-
case 0 :
|
|
205
|
-
notificationsList.updateNotificationsList(e.index, 0, [e.item]);
|
|
206
|
-
e.item.updateVisibility(true);
|
|
207
|
-
break;
|
|
208
|
-
case 1 :
|
|
209
|
-
switch (e.detail) {
|
|
210
|
-
case 2 :
|
|
211
|
-
notificationsList.updateNotificationsList(e.index, 1, [e.item]);
|
|
212
|
-
break;
|
|
213
|
-
case 1 :
|
|
214
|
-
if (e.item.expanded) {
|
|
215
|
-
notificationsList.updateNotificationHeight(e.item);
|
|
216
|
-
}
|
|
217
|
-
break;
|
|
218
|
-
}
|
|
219
|
-
break;
|
|
220
|
-
case 2 :
|
|
221
|
-
notificationsList.updateNotificationsList(e.index, 1, [e.item]);
|
|
222
|
-
break;
|
|
223
|
-
case 3 :
|
|
224
|
-
focusEditor = isAncestorOfActiveElement(notificationsCenterContainer);
|
|
225
|
-
notificationsList.updateNotificationsList(e.index, 1);
|
|
226
|
-
e.item.updateVisibility(false);
|
|
227
|
-
break;
|
|
228
|
-
}
|
|
229
|
-
this.updateTitle();
|
|
230
|
-
if (this.model.notifications.length === 0) {
|
|
231
|
-
this.hide();
|
|
232
|
-
if (focusEditor) {
|
|
233
|
-
this.editorGroupService.activeGroup.focus();
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
hide() {
|
|
238
|
-
if (!this._isVisible || !this.notificationsCenterContainer || !this.notificationsList) {
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
const focusEditor = isAncestorOfActiveElement(this.notificationsCenterContainer);
|
|
242
|
-
this._isVisible = false;
|
|
243
|
-
this.notificationsCenterContainer.classList.remove('visible');
|
|
244
|
-
this.notificationsList.hide();
|
|
245
|
-
this.model.notifications.forEach(notification => notification.updateVisibility(false));
|
|
246
|
-
this.notificationsCenterVisibleContextKey.set(false);
|
|
247
|
-
this._onDidChangeVisibility.fire();
|
|
248
|
-
if (focusEditor) {
|
|
249
|
-
this.editorGroupService.activeGroup.focus();
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
updateStyles() {
|
|
253
|
-
if (this.notificationsCenterContainer && this.notificationsCenterHeader) {
|
|
254
|
-
const widgetShadowColor = this.getColor(widgetShadow);
|
|
255
|
-
this.notificationsCenterContainer.style.boxShadow = widgetShadowColor ? `0 0 8px 2px ${widgetShadowColor}` : '';
|
|
256
|
-
const borderColor = this.getColor(NOTIFICATIONS_CENTER_BORDER);
|
|
257
|
-
this.notificationsCenterContainer.style.border = borderColor ? `1px solid ${borderColor}` : '';
|
|
258
|
-
const headerForeground = this.getColor(NOTIFICATIONS_CENTER_HEADER_FOREGROUND);
|
|
259
|
-
this.notificationsCenterHeader.style.color = headerForeground ?? '';
|
|
260
|
-
const headerBackground = this.getColor(NOTIFICATIONS_CENTER_HEADER_BACKGROUND);
|
|
261
|
-
this.notificationsCenterHeader.style.background = headerBackground ?? '';
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
layout(dimension) {
|
|
265
|
-
this.workbenchDimensions = dimension;
|
|
266
|
-
if (this._isVisible && this.notificationsCenterContainer) {
|
|
267
|
-
const maxWidth = NotificationsCenter_1.MAX_DIMENSIONS.width;
|
|
268
|
-
const maxHeight = NotificationsCenter_1.MAX_DIMENSIONS.height;
|
|
269
|
-
let availableWidth = maxWidth;
|
|
270
|
-
let availableHeight = maxHeight;
|
|
271
|
-
if (this.workbenchDimensions) {
|
|
272
|
-
availableWidth = this.workbenchDimensions.width;
|
|
273
|
-
availableWidth -= (2 * 8);
|
|
274
|
-
availableHeight = this.workbenchDimensions.height - 35 ;
|
|
275
|
-
if (this.layoutService.isVisible("workbench.parts.statusbar" , mainWindow)) {
|
|
276
|
-
availableHeight -= 22;
|
|
277
|
-
}
|
|
278
|
-
if (this.layoutService.isVisible("workbench.parts.titlebar" , mainWindow)) {
|
|
279
|
-
availableHeight -= 22;
|
|
280
|
-
}
|
|
281
|
-
availableHeight -= (2 * 12);
|
|
282
|
-
}
|
|
283
|
-
const notificationsList = assertIsDefined(this.notificationsList);
|
|
284
|
-
notificationsList.layout(Math.min(maxWidth, availableWidth), Math.min(maxHeight, availableHeight));
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
clearAll() {
|
|
288
|
-
this.hide();
|
|
289
|
-
for (const notification of [...this.model.notifications] ) {
|
|
290
|
-
if (!notification.hasProgress) {
|
|
291
|
-
notification.close();
|
|
292
|
-
}
|
|
293
|
-
this.audioCueService.playAudioCue(AudioCue.clear);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
NotificationsCenter = NotificationsCenter_1 = ( __decorate([
|
|
298
|
-
( __param(2, IThemeService)),
|
|
299
|
-
( __param(3, IInstantiationService)),
|
|
300
|
-
( __param(4, IWorkbenchLayoutService)),
|
|
301
|
-
( __param(5, IContextKeyService)),
|
|
302
|
-
( __param(6, IEditorGroupsService)),
|
|
303
|
-
( __param(7, IKeybindingService)),
|
|
304
|
-
( __param(8, INotificationService)),
|
|
305
|
-
( __param(9, IAudioCueService)),
|
|
306
|
-
( __param(10, IContextMenuService))
|
|
307
|
-
], NotificationsCenter));
|
|
308
|
-
|
|
309
|
-
export { NotificationsCenter };
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import './media/notificationsList.css.js';
|
|
3
|
-
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
4
|
-
import { trackFocus, getWindow, isAncestorOfActiveElement } from 'vscode/vscode/vs/base/browser/dom';
|
|
5
|
-
import { WorkbenchList } from 'vscode/vscode/vs/platform/list/browser/listService';
|
|
6
|
-
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
7
|
-
import { NOTIFICATIONS_BACKGROUND } from 'vscode/vscode/vs/workbench/common/theme';
|
|
8
|
-
import { NotificationRenderer, NotificationsListDelegate } from './notificationsViewer.js';
|
|
9
|
-
import { CopyNotificationMessageAction } from './notificationsActions.js';
|
|
10
|
-
import { IContextMenuService } from 'vscode/vscode/vs/platform/contextview/browser/contextView';
|
|
11
|
-
import { assertAllDefined } from 'vscode/vscode/vs/base/common/types';
|
|
12
|
-
import { NotificationFocusedContext } from 'vscode/vscode/vs/workbench/common/contextkeys';
|
|
13
|
-
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
14
|
-
import { NotificationActionRunner } from 'vscode/vscode/vs/workbench/browser/parts/notifications/notificationsCommands';
|
|
15
|
-
import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding';
|
|
16
|
-
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
|
|
17
|
-
|
|
18
|
-
let NotificationsList = class NotificationsList extends Disposable {
|
|
19
|
-
constructor(container, options, instantiationService, contextMenuService) {
|
|
20
|
-
super();
|
|
21
|
-
this.container = container;
|
|
22
|
-
this.options = options;
|
|
23
|
-
this.instantiationService = instantiationService;
|
|
24
|
-
this.contextMenuService = contextMenuService;
|
|
25
|
-
this.viewModel = [];
|
|
26
|
-
}
|
|
27
|
-
show() {
|
|
28
|
-
if (this.isVisible) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
if (!this.list) {
|
|
32
|
-
this.createNotificationsList();
|
|
33
|
-
}
|
|
34
|
-
this.isVisible = true;
|
|
35
|
-
}
|
|
36
|
-
createNotificationsList() {
|
|
37
|
-
this.listContainer = document.createElement('div');
|
|
38
|
-
this.listContainer.classList.add('notifications-list-container');
|
|
39
|
-
const actionRunner = this._register(this.instantiationService.createInstance(NotificationActionRunner));
|
|
40
|
-
const renderer = this.instantiationService.createInstance(NotificationRenderer, actionRunner);
|
|
41
|
-
const listDelegate = this.listDelegate = ( new NotificationsListDelegate(this.listContainer));
|
|
42
|
-
const options = this.options;
|
|
43
|
-
const list = this.list = this._register(this.instantiationService.createInstance(WorkbenchList, 'NotificationsList', this.listContainer, listDelegate, [renderer], {
|
|
44
|
-
...options,
|
|
45
|
-
setRowLineHeight: false,
|
|
46
|
-
horizontalScrolling: false,
|
|
47
|
-
overrideStyles: {
|
|
48
|
-
listBackground: NOTIFICATIONS_BACKGROUND
|
|
49
|
-
},
|
|
50
|
-
accessibilityProvider: this.instantiationService.createInstance(NotificationAccessibilityProvider, options)
|
|
51
|
-
}));
|
|
52
|
-
const copyAction = this._register(this.instantiationService.createInstance(CopyNotificationMessageAction, CopyNotificationMessageAction.ID, CopyNotificationMessageAction.LABEL));
|
|
53
|
-
this._register((list.onContextMenu(e => {
|
|
54
|
-
if (!e.element) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
this.contextMenuService.showContextMenu({
|
|
58
|
-
getAnchor: () => e.anchor,
|
|
59
|
-
getActions: () => [copyAction],
|
|
60
|
-
getActionsContext: () => e.element,
|
|
61
|
-
actionRunner
|
|
62
|
-
});
|
|
63
|
-
})));
|
|
64
|
-
this._register((list.onMouseDblClick(event => event.element.toggle())));
|
|
65
|
-
const listFocusTracker = this._register(trackFocus(list.getHTMLElement()));
|
|
66
|
-
this._register(listFocusTracker.onDidBlur(() => {
|
|
67
|
-
if (getWindow(this.listContainer).document.hasFocus()) {
|
|
68
|
-
list.setFocus([]);
|
|
69
|
-
}
|
|
70
|
-
}));
|
|
71
|
-
NotificationFocusedContext.bindTo(list.contextKeyService);
|
|
72
|
-
this._register(list.onDidChangeSelection(e => {
|
|
73
|
-
if (e.indexes.length > 0) {
|
|
74
|
-
list.setSelection([]);
|
|
75
|
-
}
|
|
76
|
-
}));
|
|
77
|
-
this.container.appendChild(this.listContainer);
|
|
78
|
-
}
|
|
79
|
-
updateNotificationsList(start, deleteCount, items = []) {
|
|
80
|
-
const [list, listContainer] = assertAllDefined(this.list, this.listContainer);
|
|
81
|
-
const listHasDOMFocus = isAncestorOfActiveElement(listContainer);
|
|
82
|
-
const focusedIndex = list.getFocus()[0];
|
|
83
|
-
const focusedItem = this.viewModel[focusedIndex];
|
|
84
|
-
let focusRelativeTop = null;
|
|
85
|
-
if (typeof focusedIndex === 'number') {
|
|
86
|
-
focusRelativeTop = list.getRelativeTop(focusedIndex);
|
|
87
|
-
}
|
|
88
|
-
this.viewModel.splice(start, deleteCount, ...items);
|
|
89
|
-
list.splice(start, deleteCount, items);
|
|
90
|
-
list.layout();
|
|
91
|
-
if (this.viewModel.length === 0) {
|
|
92
|
-
this.hide();
|
|
93
|
-
}
|
|
94
|
-
else if (typeof focusedIndex === 'number') {
|
|
95
|
-
let indexToFocus = 0;
|
|
96
|
-
if (focusedItem) {
|
|
97
|
-
let indexToFocusCandidate = this.viewModel.indexOf(focusedItem);
|
|
98
|
-
if (indexToFocusCandidate === -1) {
|
|
99
|
-
indexToFocusCandidate = focusedIndex - 1;
|
|
100
|
-
}
|
|
101
|
-
if (indexToFocusCandidate < this.viewModel.length && indexToFocusCandidate >= 0) {
|
|
102
|
-
indexToFocus = indexToFocusCandidate;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
if (typeof focusRelativeTop === 'number') {
|
|
106
|
-
list.reveal(indexToFocus, focusRelativeTop);
|
|
107
|
-
}
|
|
108
|
-
list.setFocus([indexToFocus]);
|
|
109
|
-
}
|
|
110
|
-
if (this.isVisible && listHasDOMFocus) {
|
|
111
|
-
list.domFocus();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
updateNotificationHeight(item) {
|
|
115
|
-
const index = this.viewModel.indexOf(item);
|
|
116
|
-
if (index === -1) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
const [list, listDelegate] = assertAllDefined(this.list, this.listDelegate);
|
|
120
|
-
list.updateElementHeight(index, listDelegate.getHeight(item));
|
|
121
|
-
list.layout();
|
|
122
|
-
}
|
|
123
|
-
hide() {
|
|
124
|
-
if (!this.isVisible || !this.list) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
this.isVisible = false;
|
|
128
|
-
this.list.splice(0, this.viewModel.length);
|
|
129
|
-
this.viewModel = [];
|
|
130
|
-
}
|
|
131
|
-
focusFirst() {
|
|
132
|
-
if (!this.list) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
this.list.focusFirst();
|
|
136
|
-
this.list.domFocus();
|
|
137
|
-
}
|
|
138
|
-
hasFocus() {
|
|
139
|
-
if (!this.listContainer) {
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
return isAncestorOfActiveElement(this.listContainer);
|
|
143
|
-
}
|
|
144
|
-
layout(width, maxHeight) {
|
|
145
|
-
if (this.listContainer && this.list) {
|
|
146
|
-
this.listContainer.style.width = `${width}px`;
|
|
147
|
-
if (typeof maxHeight === 'number') {
|
|
148
|
-
this.list.getHTMLElement().style.maxHeight = `${maxHeight}px`;
|
|
149
|
-
}
|
|
150
|
-
this.list.layout();
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
dispose() {
|
|
154
|
-
this.hide();
|
|
155
|
-
super.dispose();
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
NotificationsList = ( __decorate([
|
|
159
|
-
( __param(2, IInstantiationService)),
|
|
160
|
-
( __param(3, IContextMenuService))
|
|
161
|
-
], NotificationsList));
|
|
162
|
-
let NotificationAccessibilityProvider = class NotificationAccessibilityProvider {
|
|
163
|
-
constructor(_options, _keybindingService, _configurationService) {
|
|
164
|
-
this._options = _options;
|
|
165
|
-
this._keybindingService = _keybindingService;
|
|
166
|
-
this._configurationService = _configurationService;
|
|
167
|
-
}
|
|
168
|
-
getAriaLabel(element) {
|
|
169
|
-
let accessibleViewHint;
|
|
170
|
-
const keybinding = this._keybindingService.lookupKeybinding('editor.action.accessibleView')?.getAriaLabel();
|
|
171
|
-
if (this._configurationService.getValue('accessibility.verbosity.notification')) {
|
|
172
|
-
accessibleViewHint = keybinding ? ( localizeWithPath(
|
|
173
|
-
'vs/workbench/browser/parts/notifications/notificationsList',
|
|
174
|
-
'notificationAccessibleViewHint',
|
|
175
|
-
"Inspect the response in the accessible view with {0}",
|
|
176
|
-
keybinding
|
|
177
|
-
)) : ( localizeWithPath(
|
|
178
|
-
'vs/workbench/browser/parts/notifications/notificationsList',
|
|
179
|
-
'notificationAccessibleViewHintNoKb',
|
|
180
|
-
"Inspect the response in the accessible view via the command Open Accessible View which is currently not triggerable via keybinding"
|
|
181
|
-
));
|
|
182
|
-
}
|
|
183
|
-
if (!element.source) {
|
|
184
|
-
return accessibleViewHint ? ( localizeWithPath(
|
|
185
|
-
'vs/workbench/browser/parts/notifications/notificationsList',
|
|
186
|
-
'notificationAriaLabelHint',
|
|
187
|
-
"{0}, notification, {1}",
|
|
188
|
-
element.message.raw,
|
|
189
|
-
accessibleViewHint
|
|
190
|
-
)) : ( localizeWithPath(
|
|
191
|
-
'vs/workbench/browser/parts/notifications/notificationsList',
|
|
192
|
-
'notificationAriaLabel',
|
|
193
|
-
"{0}, notification",
|
|
194
|
-
element.message.raw
|
|
195
|
-
));
|
|
196
|
-
}
|
|
197
|
-
return accessibleViewHint ? ( localizeWithPath(
|
|
198
|
-
'vs/workbench/browser/parts/notifications/notificationsList',
|
|
199
|
-
'notificationWithSourceAriaLabelHint',
|
|
200
|
-
"{0}, source: {1}, notification, {2}",
|
|
201
|
-
element.message.raw,
|
|
202
|
-
element.source,
|
|
203
|
-
accessibleViewHint
|
|
204
|
-
)) : ( localizeWithPath(
|
|
205
|
-
'vs/workbench/browser/parts/notifications/notificationsList',
|
|
206
|
-
'notificationWithSourceAriaLabel',
|
|
207
|
-
"{0}, source: {1}, notification",
|
|
208
|
-
element.message.raw,
|
|
209
|
-
element.source
|
|
210
|
-
));
|
|
211
|
-
}
|
|
212
|
-
getWidgetAriaLabel() {
|
|
213
|
-
return this._options.widgetAriaLabel ?? ( localizeWithPath(
|
|
214
|
-
'vs/workbench/browser/parts/notifications/notificationsList',
|
|
215
|
-
'notificationsList',
|
|
216
|
-
"Notifications List"
|
|
217
|
-
));
|
|
218
|
-
}
|
|
219
|
-
getRole() {
|
|
220
|
-
return 'dialog';
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
NotificationAccessibilityProvider = ( __decorate([
|
|
224
|
-
( __param(1, IKeybindingService)),
|
|
225
|
-
( __param(2, IConfigurationService))
|
|
226
|
-
], NotificationAccessibilityProvider));
|
|
227
|
-
|
|
228
|
-
export { NotificationsList };
|