@codingame/monaco-vscode-api 1.68.7 → 1.69.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/README.md +102 -7
- package/dist/api.js +481 -9583
- package/dist/configuration.d.ts +488 -0
- package/dist/configuration.js +582 -0
- package/dist/extHost.js +14881 -0
- package/dist/files.js +1325 -0
- package/dist/injection.js +15 -0
- package/dist/jsonErrorMessages.js +17 -0
- package/dist/keybindings.d.ts +502 -0
- package/dist/keybindings.js +2352 -0
- package/dist/languageConfiguration.d.ts +8 -0
- package/dist/languageConfiguration.js +925 -0
- package/dist/languageService.js +340 -0
- package/dist/languages.d.ts +477 -0
- package/dist/languages.js +21 -0
- package/dist/layoutService.js +4 -0
- package/dist/messages.d.ts +7 -0
- package/dist/messages.js +3624 -0
- package/dist/missing-services.js +7778 -0
- package/dist/modelEditor.d.ts +164 -0
- package/dist/modelEditor.js +739 -0
- package/dist/monaco.d.ts +4914 -0
- package/dist/monaco.js +261 -0
- package/dist/services.d.ts +14806 -2098
- package/dist/services.js +22 -25
- package/dist/services2.js +423 -0
- package/dist/snippets.d.ts +466 -0
- package/dist/snippets.js +864 -0
- package/dist/textmate.d.ts +683 -0
- package/dist/textmate.js +739 -0
- package/dist/theme.d.ts +23 -0
- package/dist/theme.js +4167 -0
- package/dist/tokenClassification.d.ts +479 -0
- package/dist/tokenClassification.js +302 -0
- package/dist/tokenClassificationRegistry.js +472 -0
- package/dist/tools.js +31 -0
- package/dist/tslib.es6.js +21 -0
- package/dist/workbenchThemeService.js +46 -0
- package/dist/workspaceContext.js +49 -0
- package/package.json +107 -24
package/dist/messages.js
ADDED
|
@@ -0,0 +1,3624 @@
|
|
|
1
|
+
import { e as ILifecycleService, E as Emitter, f as IntervalCounter, g as assertAllDefined, u as unsupported } from './missing-services.js';
|
|
2
|
+
import { _ as __decorate, a as __param } from './tslib.es6.js';
|
|
3
|
+
import { focusBorder, registerColor, textLinkForeground, editorErrorForeground, editorWarningForeground, editorInfoForeground, widgetShadow, contrastBorder, editorWidgetBackground, editorWidgetForeground, buttonForeground, buttonSeparator, buttonBackground, buttonHoverBackground, buttonSecondaryForeground, buttonSecondaryBackground, buttonSecondaryHoverBackground, buttonBorder, progressBarBackground, resolveColorValue, checkboxBorder, checkboxBackground, checkboxForeground, problemsErrorIconForeground, problemsWarningIconForeground, problemsInfoIconForeground, inputBackground, inputForeground, inputBorder } from 'monaco-editor/esm/vs/platform/theme/common/colorRegistry.js';
|
|
4
|
+
import { localize } from 'monaco-editor/esm/vs/nls.js';
|
|
5
|
+
import { I as IFileService, f as IEditorGroupsService, l as IHostService, j as IProductService, g as IWorkbenchEnvironmentService, w as NotificationsFilter, x as NeverShowAgainScope } from './services2.js';
|
|
6
|
+
import { Disposable, toDisposable, DisposableStore, dispose } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
7
|
+
import { Event } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
8
|
+
import { NoOpNotification, Severity, INotificationService } from 'monaco-editor/esm/vs/platform/notification/common/notification.js';
|
|
9
|
+
import { isCancellationError } from 'monaco-editor/esm/vs/base/common/errors.js';
|
|
10
|
+
import { toErrorMessage } from 'monaco-editor/esm/vs/base/common/errorMessage.js';
|
|
11
|
+
import { equals, isNonEmptyArray } from 'monaco-editor/esm/vs/base/common/arrays.js';
|
|
12
|
+
import { Action, ActionRunner } from 'monaco-editor/esm/vs/base/common/actions.js';
|
|
13
|
+
import { hash } from 'monaco-editor/esm/vs/base/common/hash.js';
|
|
14
|
+
import { RawContextKey, IContextKeyService, ContextKeyExpr } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
|
|
15
|
+
import { ILanguageService } from 'monaco-editor/esm/vs/editor/common/languages/language.js';
|
|
16
|
+
import { IModelService } from 'monaco-editor/esm/vs/editor/common/services/model.js';
|
|
17
|
+
import { isEqual, basename, dirname, extname } from 'monaco-editor/esm/vs/base/common/resources.js';
|
|
18
|
+
import { ICommandService } from 'monaco-editor/esm/vs/platform/commands/common/commands.js';
|
|
19
|
+
import { KeybindingsRegistry } from 'monaco-editor/esm/vs/platform/keybinding/common/keybindingsRegistry.js';
|
|
20
|
+
import { ITelemetryService } from 'monaco-editor/esm/vs/platform/telemetry/common/telemetry.js';
|
|
21
|
+
import { WorkbenchList, IListService } from 'monaco-editor/esm/vs/platform/list/browser/listService.js';
|
|
22
|
+
import { MenuRegistry, MenuId } from 'monaco-editor/esm/vs/platform/actions/common/actions.js';
|
|
23
|
+
import { registerIcon } from 'monaco-editor/esm/vs/platform/theme/common/iconRegistry.js';
|
|
24
|
+
import { Codicon, CSSIcon } from 'monaco-editor/esm/vs/base/common/codicons.js';
|
|
25
|
+
import { IClipboardService } from 'monaco-editor/esm/vs/platform/clipboard/common/clipboardService.js';
|
|
26
|
+
import { registerThemingParticipant, ThemeIcon, IThemeService, Themable } from 'monaco-editor/esm/vs/platform/theme/common/themeService.js';
|
|
27
|
+
import { addDisposableListener, EventType, EventHelper, clearNode, Dimension, scheduleAtNextAnimationFrame, isAncestor, $, trackFocus, getClientArea, reset, hide, show } from 'monaco-editor/esm/vs/base/browser/dom.js';
|
|
28
|
+
import { mixin } from 'monaco-editor/esm/vs/base/common/objects.js';
|
|
29
|
+
import { Gesture, EventType as EventType$1 } from 'monaco-editor/esm/vs/base/browser/touch.js';
|
|
30
|
+
import { renderLabelWithIcons } from 'monaco-editor/esm/vs/base/browser/ui/iconLabel/iconLabels.js';
|
|
31
|
+
import { StandardKeyboardEvent } from 'monaco-editor/esm/vs/base/browser/keyboardEvent.js';
|
|
32
|
+
import { Color } from 'monaco-editor/esm/vs/base/common/color.js';
|
|
33
|
+
import { DomEmitter } from 'monaco-editor/esm/vs/base/browser/event.js';
|
|
34
|
+
import { ActionBar } from 'monaco-editor/esm/vs/base/browser/ui/actionbar/actionbar.js';
|
|
35
|
+
import { ProgressBar } from 'monaco-editor/esm/vs/base/browser/ui/progressbar/progressbar.js';
|
|
36
|
+
import { IContextMenuService } from 'monaco-editor/esm/vs/platform/contextview/browser/contextView.js';
|
|
37
|
+
import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
38
|
+
import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
|
|
39
|
+
import { IOpenerService } from 'monaco-editor/esm/vs/platform/opener/common/opener.js';
|
|
40
|
+
import { IKeybindingService } from 'monaco-editor/esm/vs/platform/keybinding/common/keybinding.js';
|
|
41
|
+
import { DropdownMenuActionViewItem } from 'monaco-editor/esm/vs/base/browser/ui/dropdown/dropdownActionViewItem.js';
|
|
42
|
+
import { assertIsDefined } from 'monaco-editor/esm/vs/base/common/types.js';
|
|
43
|
+
import { I as IWorkbenchLayoutService } from './layoutService.js';
|
|
44
|
+
import { IStorageService } from 'monaco-editor/esm/vs/platform/storage/common/storage.js';
|
|
45
|
+
import { Widget } from 'monaco-editor/esm/vs/base/browser/ui/widget.js';
|
|
46
|
+
import { isMacintosh, isLinux, isWindows } from 'monaco-editor/esm/vs/base/common/platform.js';
|
|
47
|
+
import { InputBox } from 'monaco-editor/esm/vs/base/browser/ui/inputbox/inputBox.js';
|
|
48
|
+
import { MarkdownRenderer } from 'monaco-editor/esm/vs/editor/contrib/markdownRenderer/browser/markdownRenderer.js';
|
|
49
|
+
import Severity$1 from 'monaco-editor/esm/vs/base/common/severity.js';
|
|
50
|
+
import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
|
|
51
|
+
import { ILayoutService } from 'monaco-editor/esm/vs/platform/layout/browser/layoutService.js';
|
|
52
|
+
import { IDialogService } from 'monaco-editor/esm/vs/platform/dialogs/common/dialogs.js';
|
|
53
|
+
import { DeferredPromise } from 'monaco-editor/esm/vs/base/common/async.js';
|
|
54
|
+
import { SyncDescriptor } from 'monaco-editor/esm/vs/platform/instantiation/common/descriptors.js';
|
|
55
|
+
import { StandaloneServices } from 'monaco-editor/esm/vs/editor/standalone/browser/standaloneServices.js';
|
|
56
|
+
import { ICodeEditorService } from 'monaco-editor/esm/vs/editor/browser/services/codeEditorService.js';
|
|
57
|
+
import { o as onServicesInitialized } from './tools.js';
|
|
58
|
+
function isErrorWithActions(obj) {
|
|
59
|
+
const candidate = obj;
|
|
60
|
+
return candidate instanceof Error && Array.isArray(candidate.actions);
|
|
61
|
+
}
|
|
62
|
+
var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=( Object.keys(r.attributes)),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
|
|
63
|
+
const defaultOpts = {
|
|
64
|
+
inputActiveOptionBorder: ( (Color.fromHex('#007ACC00'))),
|
|
65
|
+
inputActiveOptionForeground: ( (Color.fromHex('#FFFFFF'))),
|
|
66
|
+
inputActiveOptionBackground: ( (Color.fromHex('#0E639C50')))
|
|
67
|
+
};
|
|
68
|
+
class Toggle extends Widget {
|
|
69
|
+
constructor(opts) {
|
|
70
|
+
super();
|
|
71
|
+
this._onChange = this._register(( (new Emitter())));
|
|
72
|
+
this.onChange = this._onChange.event;
|
|
73
|
+
this._onKeyDown = this._register(( (new Emitter())));
|
|
74
|
+
this.onKeyDown = this._onKeyDown.event;
|
|
75
|
+
this._opts = { ...defaultOpts, ...opts };
|
|
76
|
+
this._checked = this._opts.isChecked;
|
|
77
|
+
const classes = ['monaco-custom-toggle'];
|
|
78
|
+
if (this._opts.icon) {
|
|
79
|
+
this._icon = this._opts.icon;
|
|
80
|
+
classes.push(...CSSIcon.asClassNameArray(this._icon));
|
|
81
|
+
}
|
|
82
|
+
if (this._opts.actionClassName) {
|
|
83
|
+
classes.push(...this._opts.actionClassName.split(' '));
|
|
84
|
+
}
|
|
85
|
+
if (this._checked) {
|
|
86
|
+
classes.push('checked');
|
|
87
|
+
}
|
|
88
|
+
this.domNode = document.createElement('div');
|
|
89
|
+
this.domNode.title = this._opts.title;
|
|
90
|
+
this.domNode.classList.add(...classes);
|
|
91
|
+
if (!this._opts.notFocusable) {
|
|
92
|
+
this.domNode.tabIndex = 0;
|
|
93
|
+
}
|
|
94
|
+
this.domNode.setAttribute('role', 'checkbox');
|
|
95
|
+
this.domNode.setAttribute('aria-checked', String(this._checked));
|
|
96
|
+
this.domNode.setAttribute('aria-label', this._opts.title);
|
|
97
|
+
this.applyStyles();
|
|
98
|
+
this.onclick(this.domNode, (ev) => {
|
|
99
|
+
if (this.enabled) {
|
|
100
|
+
this.checked = !this._checked;
|
|
101
|
+
this._onChange.fire(false);
|
|
102
|
+
ev.preventDefault();
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
this.ignoreGesture(this.domNode);
|
|
106
|
+
this.onkeydown(this.domNode, (keyboardEvent) => {
|
|
107
|
+
if (keyboardEvent.keyCode === 10 || keyboardEvent.keyCode === 3 ) {
|
|
108
|
+
this.checked = !this._checked;
|
|
109
|
+
this._onChange.fire(true);
|
|
110
|
+
keyboardEvent.preventDefault();
|
|
111
|
+
keyboardEvent.stopPropagation();
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
this._onKeyDown.fire(keyboardEvent);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
get enabled() {
|
|
118
|
+
return this.domNode.getAttribute('aria-disabled') !== 'true';
|
|
119
|
+
}
|
|
120
|
+
focus() {
|
|
121
|
+
this.domNode.focus();
|
|
122
|
+
}
|
|
123
|
+
get checked() {
|
|
124
|
+
return this._checked;
|
|
125
|
+
}
|
|
126
|
+
set checked(newIsChecked) {
|
|
127
|
+
this._checked = newIsChecked;
|
|
128
|
+
this.domNode.setAttribute('aria-checked', String(this._checked));
|
|
129
|
+
this.domNode.classList.toggle('checked', this._checked);
|
|
130
|
+
this.applyStyles();
|
|
131
|
+
}
|
|
132
|
+
setIcon(icon) {
|
|
133
|
+
if (this._icon) {
|
|
134
|
+
this.domNode.classList.remove(...CSSIcon.asClassNameArray(this._icon));
|
|
135
|
+
}
|
|
136
|
+
this._icon = icon;
|
|
137
|
+
if (this._icon) {
|
|
138
|
+
this.domNode.classList.add(...CSSIcon.asClassNameArray(this._icon));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
width() {
|
|
142
|
+
return 2 + 2 + 2 + 16 ;
|
|
143
|
+
}
|
|
144
|
+
style(styles) {
|
|
145
|
+
if (styles.inputActiveOptionBorder) {
|
|
146
|
+
this._opts.inputActiveOptionBorder = styles.inputActiveOptionBorder;
|
|
147
|
+
}
|
|
148
|
+
if (styles.inputActiveOptionForeground) {
|
|
149
|
+
this._opts.inputActiveOptionForeground = styles.inputActiveOptionForeground;
|
|
150
|
+
}
|
|
151
|
+
if (styles.inputActiveOptionBackground) {
|
|
152
|
+
this._opts.inputActiveOptionBackground = styles.inputActiveOptionBackground;
|
|
153
|
+
}
|
|
154
|
+
this.applyStyles();
|
|
155
|
+
}
|
|
156
|
+
applyStyles() {
|
|
157
|
+
if (this.domNode) {
|
|
158
|
+
this.domNode.style.borderColor = this._checked && this._opts.inputActiveOptionBorder ? ( (this._opts.inputActiveOptionBorder.toString())) : '';
|
|
159
|
+
this.domNode.style.color = this._checked && this._opts.inputActiveOptionForeground ? ( (this._opts.inputActiveOptionForeground.toString())) : 'inherit';
|
|
160
|
+
this.domNode.style.backgroundColor = this._checked && this._opts.inputActiveOptionBackground ? ( (this._opts.inputActiveOptionBackground.toString())) : '';
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
enable() {
|
|
164
|
+
this.domNode.setAttribute('aria-disabled', String(false));
|
|
165
|
+
}
|
|
166
|
+
disable() {
|
|
167
|
+
this.domNode.setAttribute('aria-disabled', String(true));
|
|
168
|
+
}
|
|
169
|
+
setTitle(newTitle) {
|
|
170
|
+
this.domNode.title = newTitle;
|
|
171
|
+
this.domNode.setAttribute('aria-label', newTitle);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
class Checkbox extends Widget {
|
|
175
|
+
constructor(title, isChecked) {
|
|
176
|
+
super();
|
|
177
|
+
this.title = title;
|
|
178
|
+
this.isChecked = isChecked;
|
|
179
|
+
this.checkbox = ( (new Toggle(
|
|
180
|
+
{ title: this.title, isChecked: this.isChecked, icon: Codicon.check, actionClassName: 'monaco-checkbox' }
|
|
181
|
+
)));
|
|
182
|
+
this.domNode = this.checkbox.domNode;
|
|
183
|
+
this.styles = {};
|
|
184
|
+
this.checkbox.onChange(() => {
|
|
185
|
+
this.applyStyles();
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
get checked() {
|
|
189
|
+
return this.checkbox.checked;
|
|
190
|
+
}
|
|
191
|
+
set checked(newIsChecked) {
|
|
192
|
+
this.checkbox.checked = newIsChecked;
|
|
193
|
+
this.applyStyles();
|
|
194
|
+
}
|
|
195
|
+
focus() {
|
|
196
|
+
this.domNode.focus();
|
|
197
|
+
}
|
|
198
|
+
hasFocus() {
|
|
199
|
+
return this.domNode === document.activeElement;
|
|
200
|
+
}
|
|
201
|
+
style(styles) {
|
|
202
|
+
this.styles = styles;
|
|
203
|
+
this.applyStyles();
|
|
204
|
+
}
|
|
205
|
+
applyStyles() {
|
|
206
|
+
this.domNode.style.color = this.styles.checkboxForeground ? ( (this.styles.checkboxForeground.toString())) : '';
|
|
207
|
+
this.domNode.style.backgroundColor = this.styles.checkboxBackground ? ( (this.styles.checkboxBackground.toString())) : '';
|
|
208
|
+
this.domNode.style.borderColor = this.styles.checkboxBorder ? ( (this.styles.checkboxBorder.toString())) : '';
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
function computeStyles(theme, styleMap) {
|
|
212
|
+
const styles = Object.create(null);
|
|
213
|
+
for (const key in styleMap) {
|
|
214
|
+
const value = styleMap[key];
|
|
215
|
+
if (value) {
|
|
216
|
+
styles[key] = resolveColorValue(value, theme);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return styles;
|
|
220
|
+
}
|
|
221
|
+
function attachStyler(themeService, styleMap, widgetOrCallback) {
|
|
222
|
+
function applyStyles() {
|
|
223
|
+
const styles = computeStyles(themeService.getColorTheme(), styleMap);
|
|
224
|
+
if (typeof widgetOrCallback === 'function') {
|
|
225
|
+
widgetOrCallback(styles);
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
widgetOrCallback.style(styles);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
applyStyles();
|
|
232
|
+
return themeService.onDidColorThemeChange(applyStyles);
|
|
233
|
+
}
|
|
234
|
+
function attachButtonStyler(widget, themeService, style) {
|
|
235
|
+
return attachStyler(themeService, {
|
|
236
|
+
buttonForeground: style?.buttonForeground || buttonForeground,
|
|
237
|
+
buttonSeparator: style?.buttonSeparator || buttonSeparator,
|
|
238
|
+
buttonBackground: style?.buttonBackground || buttonBackground,
|
|
239
|
+
buttonHoverBackground: style?.buttonHoverBackground || buttonHoverBackground,
|
|
240
|
+
buttonSecondaryForeground: style?.buttonSecondaryForeground || buttonSecondaryForeground,
|
|
241
|
+
buttonSecondaryBackground: style?.buttonSecondaryBackground || buttonSecondaryBackground,
|
|
242
|
+
buttonSecondaryHoverBackground: style?.buttonSecondaryHoverBackground || buttonSecondaryHoverBackground,
|
|
243
|
+
buttonBorder: style?.buttonBorder || buttonBorder,
|
|
244
|
+
}, widget);
|
|
245
|
+
}
|
|
246
|
+
function attachProgressBarStyler(widget, themeService, style) {
|
|
247
|
+
return attachStyler(themeService, {
|
|
248
|
+
progressBarBackground: style?.progressBarBackground || progressBarBackground
|
|
249
|
+
}, widget);
|
|
250
|
+
}
|
|
251
|
+
const defaultDialogStyles = {
|
|
252
|
+
dialogBackground: editorWidgetBackground,
|
|
253
|
+
dialogForeground: editorWidgetForeground,
|
|
254
|
+
dialogShadow: widgetShadow,
|
|
255
|
+
dialogBorder: contrastBorder,
|
|
256
|
+
buttonForeground: buttonForeground,
|
|
257
|
+
buttonSeparator: buttonSeparator,
|
|
258
|
+
buttonBackground: buttonBackground,
|
|
259
|
+
buttonSecondaryBackground: buttonSecondaryBackground,
|
|
260
|
+
buttonSecondaryForeground: buttonSecondaryForeground,
|
|
261
|
+
buttonSecondaryHoverBackground: buttonSecondaryHoverBackground,
|
|
262
|
+
buttonHoverBackground: buttonHoverBackground,
|
|
263
|
+
buttonBorder: buttonBorder,
|
|
264
|
+
checkboxBorder: checkboxBorder,
|
|
265
|
+
checkboxBackground: checkboxBackground,
|
|
266
|
+
checkboxForeground: checkboxForeground,
|
|
267
|
+
errorIconForeground: problemsErrorIconForeground,
|
|
268
|
+
warningIconForeground: problemsWarningIconForeground,
|
|
269
|
+
infoIconForeground: problemsInfoIconForeground,
|
|
270
|
+
inputBackground: inputBackground,
|
|
271
|
+
inputForeground: inputForeground,
|
|
272
|
+
inputBorder: inputBorder,
|
|
273
|
+
textLinkForeground: textLinkForeground
|
|
274
|
+
};
|
|
275
|
+
function attachDialogStyler(widget, themeService, style) {
|
|
276
|
+
return attachStyler(themeService, { ...defaultDialogStyles, ...style }, widget);
|
|
277
|
+
}
|
|
278
|
+
var css$3 = "/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\n.monaco-workbench > .notifications-toasts {\n\tposition: absolute;\n\tz-index: 1000;\n\tright: 3px;\n\tbottom: 26px;\n\tdisplay: none;\n\toverflow: hidden;\n}\n\n.monaco-workbench.nostatusbar > .notifications-toasts {\n\tbottom: 3px;\n}\n\n.monaco-workbench > .notifications-toasts.visible {\n\tdisplay: flex;\n\tflex-direction: column;\n}\n\n.monaco-workbench > .notifications-toasts .notification-toast-container {\n\toverflow: hidden; /* this ensures that the notification toast does not shine through */\n}\n\n.monaco-workbench > .notifications-toasts .notification-toast-container > .notification-toast {\n\tmargin: 8px; /* enables separation and drop shadows around toasts */\n\ttransform: translate3d(0px, 100%, 0px); /* move the notification 50px to the bottom (to prevent bleed through) */\n\topacity: 0; /* fade the toast in */\n\ttransition:\ttransform 300ms ease-out, opacity 300ms ease-out;\n}\n\n.monaco-workbench.reduce-motion > .notifications-toasts .notification-toast-container > .notification-toast {\n\ttransition:\ttransform 0ms ease-out, opacity 0ms ease-out;\n}\n\n.monaco-workbench > .notifications-toasts .notification-toast-container > .notification-toast.notification-fade-in {\n\topacity: 1;\n\ttransform: none;\n}\n\n.monaco-workbench > .notifications-toasts .notification-toast-container > .notification-toast.notification-fade-in-done {\n\topacity: 1;\n\ttransform: none;\n\ttransition:\tnone;\n}\n";
|
|
279
|
+
n(css$3,{});
|
|
280
|
+
var css$2 = "/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\n/** Notification: Container */\n\n.monaco-workbench .notifications-list-container .notification-list-item {\n\tdisplay: flex;\n\tflex-direction: column;\n\tflex-direction: column-reverse; /* the details row appears first in order for better keyboard access to notification buttons */\n\tpadding: 10px 5px;\n\theight: 100%;\n\tbox-sizing: border-box;\n}\n\n.monaco-workbench .notifications-list-container .notification-offset-helper {\n\topacity: 0;\n\tposition: absolute;\n\tline-height: 22px;\n\tword-wrap: break-word; /* never overflow long words, but break to next line */\n}\n\n/** Notification: Main Row */\n\n.monaco-workbench .notifications-list-container .notification-list-item > .notification-list-item-main-row {\n\tdisplay: flex;\n\tflex-grow: 1;\n}\n\n/** Notification: Icon */\n\n.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-icon {\n\tdisplay: flex;\n\talign-items: center;\n\tflex: 0 0 16px;\n\theight: 22px;\n\tmargin-right: 4px;\n\tmargin-left: 4px;\n\tfont-size: 18px;\n\tbackground-position: center;\n\tbackground-repeat: no-repeat;\n}\n\n/** Notification: Message */\n\n.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-message {\n\tline-height: 22px;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\tflex: 1; /* let the message always grow */\n\tuser-select: text;\n\t-webkit-user-select: text;\n}\n\n.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-message a:focus {\n\toutline-width: 1px;\n\toutline-style: solid;\n}\n\n.monaco-workbench .notifications-list-container .notification-list-item.expanded .notification-list-item-message {\n\twhite-space: normal;\n\tword-wrap: break-word; /* never overflow long words, but break to next line */\n}\n\n/** Notification: Toolbar Container */\n\n.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-toolbar-container {\n\tdisplay: none;\n\theight: 22px;\n}\n\n.monaco-workbench .notifications-list-container .notification-list-item:hover .notification-list-item-toolbar-container,\n.monaco-workbench .notifications-list-container .monaco-list-row.focused .notification-list-item .notification-list-item-toolbar-container,\n.monaco-workbench .notifications-list-container .notification-list-item.expanded .notification-list-item-toolbar-container {\n\tdisplay: block;\n}\n\n/** Notification: Details Row */\n\n.monaco-workbench .notifications-list-container .notification-list-item > .notification-list-item-details-row {\n\tdisplay: none;\n\talign-items: center;\n\tpadding-left: 5px;\n\toverflow: hidden; /* details row should never overflow */\n}\n\n.monaco-workbench .notifications-list-container .notification-list-item.expanded > .notification-list-item-details-row {\n\tdisplay: flex;\n}\n\n/** Notification: Source */\n\n.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-source {\n\tflex: 1;\n\tfont-size: 12px;\n\toverflow: hidden; /* always give away space to buttons container */\n\ttext-overflow: ellipsis;\n}\n\n/** Notification: Buttons */\n\n.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-buttons-container {\n\tdisplay: flex;\n\toverflow: hidden;\n}\n\n.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-buttons-container > .monaco-button-dropdown,\n.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-buttons-container > .monaco-button {\n\tmargin: 4px 5px; /* allows button focus outline to be visible */\n}\n\n.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-buttons-container .monaco-button {\n\toutline-offset: 2px !important;\n}\n\n.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-buttons-container .monaco-text-button {\n\twidth: fit-content;\n\twidth: -moz-fit-content;\n\tpadding: 5px 10px;\n\tdisplay: inline-block;\t/* to enable ellipsis in text overflow */\n\tfont-size: 12px;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n}\n\n.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-buttons-container .monaco-dropdown-button {\n\tpadding: 5px\n}\n\n/** Notification: Progress */\n\n.monaco-workbench .notifications-list-container .progress-bit {\n\theight: 2px;\n\tbottom: 0;\n}\n";
|
|
281
|
+
n(css$2,{});
|
|
282
|
+
const NOTIFICATIONS_TOAST_BORDER = ( (registerColor('notificationToast.border', {
|
|
283
|
+
dark: null,
|
|
284
|
+
light: null,
|
|
285
|
+
hcDark: contrastBorder,
|
|
286
|
+
hcLight: contrastBorder
|
|
287
|
+
}, (localize(
|
|
288
|
+
'notificationToastBorder',
|
|
289
|
+
"Notification toast border color. Notifications slide in from the bottom right of the window."
|
|
290
|
+
)))));
|
|
291
|
+
const NOTIFICATIONS_FOREGROUND = ( (registerColor('notifications.foreground', {
|
|
292
|
+
dark: editorWidgetForeground,
|
|
293
|
+
light: editorWidgetForeground,
|
|
294
|
+
hcDark: editorWidgetForeground,
|
|
295
|
+
hcLight: editorWidgetForeground
|
|
296
|
+
}, (localize(
|
|
297
|
+
'notificationsForeground',
|
|
298
|
+
"Notifications foreground color. Notifications slide in from the bottom right of the window."
|
|
299
|
+
)))));
|
|
300
|
+
const NOTIFICATIONS_BACKGROUND = ( (registerColor('notifications.background', {
|
|
301
|
+
dark: editorWidgetBackground,
|
|
302
|
+
light: editorWidgetBackground,
|
|
303
|
+
hcDark: editorWidgetBackground,
|
|
304
|
+
hcLight: editorWidgetBackground
|
|
305
|
+
}, (localize(
|
|
306
|
+
'notificationsBackground',
|
|
307
|
+
"Notifications background color. Notifications slide in from the bottom right of the window."
|
|
308
|
+
)))));
|
|
309
|
+
const NOTIFICATIONS_LINKS = ( (registerColor('notificationLink.foreground', {
|
|
310
|
+
dark: textLinkForeground,
|
|
311
|
+
light: textLinkForeground,
|
|
312
|
+
hcDark: textLinkForeground,
|
|
313
|
+
hcLight: textLinkForeground
|
|
314
|
+
}, (localize(
|
|
315
|
+
'notificationsLink',
|
|
316
|
+
"Notification links foreground color. Notifications slide in from the bottom right of the window."
|
|
317
|
+
)))));
|
|
318
|
+
const NOTIFICATIONS_ERROR_ICON_FOREGROUND = ( (registerColor('notificationsErrorIcon.foreground', {
|
|
319
|
+
dark: editorErrorForeground,
|
|
320
|
+
light: editorErrorForeground,
|
|
321
|
+
hcDark: editorErrorForeground,
|
|
322
|
+
hcLight: editorErrorForeground
|
|
323
|
+
}, (localize(
|
|
324
|
+
'notificationsErrorIconForeground',
|
|
325
|
+
"The color used for the icon of error notifications. Notifications slide in from the bottom right of the window."
|
|
326
|
+
)))));
|
|
327
|
+
const NOTIFICATIONS_WARNING_ICON_FOREGROUND = ( (registerColor('notificationsWarningIcon.foreground', {
|
|
328
|
+
dark: editorWarningForeground,
|
|
329
|
+
light: editorWarningForeground,
|
|
330
|
+
hcDark: editorWarningForeground,
|
|
331
|
+
hcLight: editorWarningForeground
|
|
332
|
+
}, (localize(
|
|
333
|
+
'notificationsWarningIconForeground',
|
|
334
|
+
"The color used for the icon of warning notifications. Notifications slide in from the bottom right of the window."
|
|
335
|
+
)))));
|
|
336
|
+
const NOTIFICATIONS_INFO_ICON_FOREGROUND = ( (registerColor('notificationsInfoIcon.foreground', {
|
|
337
|
+
dark: editorInfoForeground,
|
|
338
|
+
light: editorInfoForeground,
|
|
339
|
+
hcDark: editorInfoForeground,
|
|
340
|
+
hcLight: editorInfoForeground
|
|
341
|
+
}, (localize(
|
|
342
|
+
'notificationsInfoIconForeground',
|
|
343
|
+
"The color used for the icon of info notifications. Notifications slide in from the bottom right of the window."
|
|
344
|
+
)))));
|
|
345
|
+
const defaultOptions = {
|
|
346
|
+
buttonBackground: ( (Color.fromHex('#0E639C'))),
|
|
347
|
+
buttonHoverBackground: ( (Color.fromHex('#006BB3'))),
|
|
348
|
+
buttonSeparator: Color.white,
|
|
349
|
+
buttonForeground: Color.white
|
|
350
|
+
};
|
|
351
|
+
class Button extends Disposable {
|
|
352
|
+
constructor(container, options) {
|
|
353
|
+
super();
|
|
354
|
+
this._onDidClick = this._register(( (new Emitter())));
|
|
355
|
+
this.options = options || Object.create(null);
|
|
356
|
+
mixin(this.options, defaultOptions, false);
|
|
357
|
+
this.buttonForeground = this.options.buttonForeground;
|
|
358
|
+
this.buttonBackground = this.options.buttonBackground;
|
|
359
|
+
this.buttonHoverBackground = this.options.buttonHoverBackground;
|
|
360
|
+
this.buttonSecondaryForeground = this.options.buttonSecondaryForeground;
|
|
361
|
+
this.buttonSecondaryBackground = this.options.buttonSecondaryBackground;
|
|
362
|
+
this.buttonSecondaryHoverBackground = this.options.buttonSecondaryHoverBackground;
|
|
363
|
+
this.buttonBorder = this.options.buttonBorder;
|
|
364
|
+
this._element = document.createElement('a');
|
|
365
|
+
this._element.classList.add('monaco-button');
|
|
366
|
+
this._element.tabIndex = 0;
|
|
367
|
+
this._element.setAttribute('role', 'button');
|
|
368
|
+
container.appendChild(this._element);
|
|
369
|
+
this._register(Gesture.addTarget(this._element));
|
|
370
|
+
[EventType.CLICK, EventType$1.Tap].forEach(eventType => {
|
|
371
|
+
this._register(addDisposableListener(this._element, eventType, e => {
|
|
372
|
+
if (!this.enabled) {
|
|
373
|
+
EventHelper.stop(e);
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
this._onDidClick.fire(e);
|
|
377
|
+
}));
|
|
378
|
+
});
|
|
379
|
+
this._register(addDisposableListener(this._element, EventType.KEY_DOWN, e => {
|
|
380
|
+
const event = ( (new StandardKeyboardEvent(e)));
|
|
381
|
+
let eventHandled = false;
|
|
382
|
+
if (this.enabled && (event.equals(3 ) || event.equals(10 ))) {
|
|
383
|
+
this._onDidClick.fire(e);
|
|
384
|
+
eventHandled = true;
|
|
385
|
+
}
|
|
386
|
+
else if (event.equals(9 )) {
|
|
387
|
+
this._element.blur();
|
|
388
|
+
eventHandled = true;
|
|
389
|
+
}
|
|
390
|
+
if (eventHandled) {
|
|
391
|
+
EventHelper.stop(event, true);
|
|
392
|
+
}
|
|
393
|
+
}));
|
|
394
|
+
this._register(addDisposableListener(this._element, EventType.MOUSE_OVER, e => {
|
|
395
|
+
if (!this._element.classList.contains('disabled')) {
|
|
396
|
+
this.setHoverBackground();
|
|
397
|
+
}
|
|
398
|
+
}));
|
|
399
|
+
this._register(addDisposableListener(this._element, EventType.MOUSE_OUT, e => {
|
|
400
|
+
this.applyStyles();
|
|
401
|
+
}));
|
|
402
|
+
this.focusTracker = this._register(trackFocus(this._element));
|
|
403
|
+
this._register(this.focusTracker.onDidFocus(() => { if (this.enabled) {
|
|
404
|
+
this.setHoverBackground();
|
|
405
|
+
} }));
|
|
406
|
+
this._register(this.focusTracker.onDidBlur(() => { if (this.enabled) {
|
|
407
|
+
this.applyStyles();
|
|
408
|
+
} }));
|
|
409
|
+
this.applyStyles();
|
|
410
|
+
}
|
|
411
|
+
get onDidClick() { return this._onDidClick.event; }
|
|
412
|
+
setHoverBackground() {
|
|
413
|
+
let hoverBackground;
|
|
414
|
+
if (this.options.secondary) {
|
|
415
|
+
hoverBackground = this.buttonSecondaryHoverBackground ? ( (this.buttonSecondaryHoverBackground.toString())) : null;
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
hoverBackground = this.buttonHoverBackground ? ( (this.buttonHoverBackground.toString())) : null;
|
|
419
|
+
}
|
|
420
|
+
if (hoverBackground) {
|
|
421
|
+
this._element.style.backgroundColor = hoverBackground;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
style(styles) {
|
|
425
|
+
this.buttonForeground = styles.buttonForeground;
|
|
426
|
+
this.buttonBackground = styles.buttonBackground;
|
|
427
|
+
this.buttonHoverBackground = styles.buttonHoverBackground;
|
|
428
|
+
this.buttonSecondaryForeground = styles.buttonSecondaryForeground;
|
|
429
|
+
this.buttonSecondaryBackground = styles.buttonSecondaryBackground;
|
|
430
|
+
this.buttonSecondaryHoverBackground = styles.buttonSecondaryHoverBackground;
|
|
431
|
+
this.buttonBorder = styles.buttonBorder;
|
|
432
|
+
this.applyStyles();
|
|
433
|
+
}
|
|
434
|
+
applyStyles() {
|
|
435
|
+
if (this._element) {
|
|
436
|
+
let background, foreground;
|
|
437
|
+
if (this.options.secondary) {
|
|
438
|
+
foreground = this.buttonSecondaryForeground ? ( (this.buttonSecondaryForeground.toString())) : '';
|
|
439
|
+
background = this.buttonSecondaryBackground ? ( (this.buttonSecondaryBackground.toString())) : '';
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
foreground = this.buttonForeground ? ( (this.buttonForeground.toString())) : '';
|
|
443
|
+
background = this.buttonBackground ? ( (this.buttonBackground.toString())) : '';
|
|
444
|
+
}
|
|
445
|
+
const border = this.buttonBorder ? ( (this.buttonBorder.toString())) : '';
|
|
446
|
+
this._element.style.color = foreground;
|
|
447
|
+
this._element.style.backgroundColor = background;
|
|
448
|
+
this._element.style.borderWidth = border ? '1px' : '';
|
|
449
|
+
this._element.style.borderStyle = border ? 'solid' : '';
|
|
450
|
+
this._element.style.borderColor = border;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
get element() {
|
|
454
|
+
return this._element;
|
|
455
|
+
}
|
|
456
|
+
set label(value) {
|
|
457
|
+
this._element.classList.add('monaco-text-button');
|
|
458
|
+
if (this.options.supportIcons) {
|
|
459
|
+
reset(this._element, ...renderLabelWithIcons(value));
|
|
460
|
+
}
|
|
461
|
+
else {
|
|
462
|
+
this._element.textContent = value;
|
|
463
|
+
}
|
|
464
|
+
if (typeof this.options.title === 'string') {
|
|
465
|
+
this._element.title = this.options.title;
|
|
466
|
+
}
|
|
467
|
+
else if (this.options.title) {
|
|
468
|
+
this._element.title = value;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
set icon(icon) {
|
|
472
|
+
this._element.classList.add(...CSSIcon.asClassNameArray(icon));
|
|
473
|
+
}
|
|
474
|
+
set enabled(value) {
|
|
475
|
+
if (value) {
|
|
476
|
+
this._element.classList.remove('disabled');
|
|
477
|
+
this._element.setAttribute('aria-disabled', String(false));
|
|
478
|
+
this._element.tabIndex = 0;
|
|
479
|
+
}
|
|
480
|
+
else {
|
|
481
|
+
this._element.classList.add('disabled');
|
|
482
|
+
this._element.setAttribute('aria-disabled', String(true));
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
get enabled() {
|
|
486
|
+
return !this._element.classList.contains('disabled');
|
|
487
|
+
}
|
|
488
|
+
focus() {
|
|
489
|
+
this._element.focus();
|
|
490
|
+
}
|
|
491
|
+
hasFocus() {
|
|
492
|
+
return this._element === document.activeElement;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
class ButtonWithDropdown extends Disposable {
|
|
496
|
+
constructor(container, options) {
|
|
497
|
+
super();
|
|
498
|
+
this._onDidClick = this._register(( (new Emitter())));
|
|
499
|
+
this.onDidClick = this._onDidClick.event;
|
|
500
|
+
this.element = document.createElement('div');
|
|
501
|
+
this.element.classList.add('monaco-button-dropdown');
|
|
502
|
+
container.appendChild(this.element);
|
|
503
|
+
this.button = this._register(( (new Button(this.element, options))));
|
|
504
|
+
this._register(this.button.onDidClick(e => this._onDidClick.fire(e)));
|
|
505
|
+
this.action = this._register(( (new Action(
|
|
506
|
+
'primaryAction',
|
|
507
|
+
this.button.label,
|
|
508
|
+
undefined,
|
|
509
|
+
true,
|
|
510
|
+
async () => this._onDidClick.fire(undefined)
|
|
511
|
+
))));
|
|
512
|
+
this.separatorContainer = document.createElement('div');
|
|
513
|
+
this.separatorContainer.classList.add('monaco-button-dropdown-separator');
|
|
514
|
+
this.separator = document.createElement('div');
|
|
515
|
+
this.separatorContainer.appendChild(this.separator);
|
|
516
|
+
this.element.appendChild(this.separatorContainer);
|
|
517
|
+
this.dropdownButton = this._register(( (new Button(this.element, { ...options, title: false, supportIcons: true }))));
|
|
518
|
+
this.dropdownButton.element.title = ( (localize("button dropdown more actions", 'More Actions...')));
|
|
519
|
+
this.dropdownButton.element.setAttribute('aria-haspopup', 'true');
|
|
520
|
+
this.dropdownButton.element.setAttribute('aria-expanded', 'false');
|
|
521
|
+
this.dropdownButton.element.classList.add('monaco-dropdown-button');
|
|
522
|
+
this.dropdownButton.icon = Codicon.dropDownButton;
|
|
523
|
+
this._register(this.dropdownButton.onDidClick(e => {
|
|
524
|
+
options.contextMenuProvider.showContextMenu({
|
|
525
|
+
getAnchor: () => this.dropdownButton.element,
|
|
526
|
+
getActions: () => options.addPrimaryActionToDropdown === false ? [...options.actions] : [this.action, ...options.actions],
|
|
527
|
+
actionRunner: options.actionRunner,
|
|
528
|
+
onHide: () => this.dropdownButton.element.setAttribute('aria-expanded', 'false')
|
|
529
|
+
});
|
|
530
|
+
this.dropdownButton.element.setAttribute('aria-expanded', 'true');
|
|
531
|
+
}));
|
|
532
|
+
}
|
|
533
|
+
set label(value) {
|
|
534
|
+
this.button.label = value;
|
|
535
|
+
this.action.label = value;
|
|
536
|
+
}
|
|
537
|
+
set icon(icon) {
|
|
538
|
+
this.button.icon = icon;
|
|
539
|
+
}
|
|
540
|
+
set enabled(enabled) {
|
|
541
|
+
this.button.enabled = enabled;
|
|
542
|
+
this.dropdownButton.enabled = enabled;
|
|
543
|
+
this.element.classList.toggle('disabled', !enabled);
|
|
544
|
+
}
|
|
545
|
+
get enabled() {
|
|
546
|
+
return this.button.enabled;
|
|
547
|
+
}
|
|
548
|
+
style(styles) {
|
|
549
|
+
this.button.style(styles);
|
|
550
|
+
this.dropdownButton.style(styles);
|
|
551
|
+
const border = styles.buttonBorder ? ( (styles.buttonBorder.toString())) : '';
|
|
552
|
+
this.separatorContainer.style.borderTopWidth = border ? '1px' : '';
|
|
553
|
+
this.separatorContainer.style.borderTopStyle = border ? 'solid' : '';
|
|
554
|
+
this.separatorContainer.style.borderTopColor = border;
|
|
555
|
+
this.separatorContainer.style.borderBottomWidth = border ? '1px' : '';
|
|
556
|
+
this.separatorContainer.style.borderBottomStyle = border ? 'solid' : '';
|
|
557
|
+
this.separatorContainer.style.borderBottomColor = border;
|
|
558
|
+
this.separatorContainer.style.backgroundColor = styles.buttonBackground?.toString() ?? '';
|
|
559
|
+
this.separator.style.backgroundColor = styles.buttonSeparator?.toString() ?? '';
|
|
560
|
+
}
|
|
561
|
+
focus() {
|
|
562
|
+
this.button.focus();
|
|
563
|
+
}
|
|
564
|
+
hasFocus() {
|
|
565
|
+
return this.button.hasFocus() || this.dropdownButton.hasFocus();
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
class ButtonWithDescription extends Button {
|
|
569
|
+
constructor(container, options) {
|
|
570
|
+
super(container, options);
|
|
571
|
+
this._element.classList.add('monaco-description-button');
|
|
572
|
+
this._labelElement = document.createElement('div');
|
|
573
|
+
this._labelElement.classList.add('monaco-button-label');
|
|
574
|
+
this._element.appendChild(this._labelElement);
|
|
575
|
+
this._descriptionElement = document.createElement('div');
|
|
576
|
+
this._descriptionElement.classList.add('monaco-button-description');
|
|
577
|
+
this._element.appendChild(this._descriptionElement);
|
|
578
|
+
}
|
|
579
|
+
set label(value) {
|
|
580
|
+
this._element.classList.add('monaco-text-button');
|
|
581
|
+
if (this.options.supportIcons) {
|
|
582
|
+
reset(this._labelElement, ...renderLabelWithIcons(value));
|
|
583
|
+
}
|
|
584
|
+
else {
|
|
585
|
+
this._labelElement.textContent = value;
|
|
586
|
+
}
|
|
587
|
+
if (typeof this.options.title === 'string') {
|
|
588
|
+
this._element.title = this.options.title;
|
|
589
|
+
}
|
|
590
|
+
else if (this.options.title) {
|
|
591
|
+
this._element.title = value;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
set description(value) {
|
|
595
|
+
if (this.options.supportIcons) {
|
|
596
|
+
reset(this._descriptionElement, ...renderLabelWithIcons(value));
|
|
597
|
+
}
|
|
598
|
+
else {
|
|
599
|
+
this._descriptionElement.textContent = value;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
class ButtonBar extends Disposable {
|
|
604
|
+
constructor(container) {
|
|
605
|
+
super();
|
|
606
|
+
this.container = container;
|
|
607
|
+
this._buttons = [];
|
|
608
|
+
}
|
|
609
|
+
get buttons() {
|
|
610
|
+
return this._buttons;
|
|
611
|
+
}
|
|
612
|
+
addButton(options) {
|
|
613
|
+
const button = this._register(( (new Button(this.container, options))));
|
|
614
|
+
this.pushButton(button);
|
|
615
|
+
return button;
|
|
616
|
+
}
|
|
617
|
+
addButtonWithDescription(options) {
|
|
618
|
+
const button = this._register(( (new ButtonWithDescription(this.container, options))));
|
|
619
|
+
this.pushButton(button);
|
|
620
|
+
return button;
|
|
621
|
+
}
|
|
622
|
+
addButtonWithDropdown(options) {
|
|
623
|
+
const button = this._register(( (new ButtonWithDropdown(this.container, options))));
|
|
624
|
+
this.pushButton(button);
|
|
625
|
+
return button;
|
|
626
|
+
}
|
|
627
|
+
pushButton(button) {
|
|
628
|
+
this._buttons.push(button);
|
|
629
|
+
const index = this._buttons.length - 1;
|
|
630
|
+
this._register(addDisposableListener(button.element, EventType.KEY_DOWN, e => {
|
|
631
|
+
const event = ( (new StandardKeyboardEvent(e)));
|
|
632
|
+
let eventHandled = true;
|
|
633
|
+
let buttonIndexToFocus;
|
|
634
|
+
if (event.equals(15 )) {
|
|
635
|
+
buttonIndexToFocus = index > 0 ? index - 1 : this._buttons.length - 1;
|
|
636
|
+
}
|
|
637
|
+
else if (event.equals(17 )) {
|
|
638
|
+
buttonIndexToFocus = index === this._buttons.length - 1 ? 0 : index + 1;
|
|
639
|
+
}
|
|
640
|
+
else {
|
|
641
|
+
eventHandled = false;
|
|
642
|
+
}
|
|
643
|
+
if (eventHandled && typeof buttonIndexToFocus === 'number') {
|
|
644
|
+
this._buttons[buttonIndexToFocus].focus();
|
|
645
|
+
EventHelper.stop(e, true);
|
|
646
|
+
}
|
|
647
|
+
}));
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
class LinkedText {
|
|
651
|
+
constructor(nodes) {
|
|
652
|
+
this.nodes = nodes;
|
|
653
|
+
}
|
|
654
|
+
toString() {
|
|
655
|
+
return this.nodes.map(node => typeof node === 'string' ? node : node.label).join('');
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
const LINK_REGEX = /\[([^\]]+)\]\(((?:https?:\/\/|command:|file:)[^\)\s]+)(?: ("|')([^\3]+)(\3))?\)/gi;
|
|
659
|
+
function parseLinkedText(text) {
|
|
660
|
+
const result = [];
|
|
661
|
+
let index = 0;
|
|
662
|
+
let match;
|
|
663
|
+
while (match = LINK_REGEX.exec(text)) {
|
|
664
|
+
if (match.index - index > 0) {
|
|
665
|
+
result.push(text.substring(index, match.index));
|
|
666
|
+
}
|
|
667
|
+
const [, label, href, , title] = match;
|
|
668
|
+
if (title) {
|
|
669
|
+
result.push({ label, href, title });
|
|
670
|
+
}
|
|
671
|
+
else {
|
|
672
|
+
result.push({ label, href });
|
|
673
|
+
}
|
|
674
|
+
index = match.index + match[0].length;
|
|
675
|
+
}
|
|
676
|
+
if (index < text.length) {
|
|
677
|
+
result.push(text.substring(index));
|
|
678
|
+
}
|
|
679
|
+
return (
|
|
680
|
+
(new LinkedText(result))
|
|
681
|
+
);
|
|
682
|
+
}
|
|
683
|
+
class NotificationHandle extends Disposable {
|
|
684
|
+
constructor(item, onClose) {
|
|
685
|
+
super();
|
|
686
|
+
this.item = item;
|
|
687
|
+
this.onClose = onClose;
|
|
688
|
+
this._onDidClose = this._register(( (new Emitter())));
|
|
689
|
+
this.onDidClose = this._onDidClose.event;
|
|
690
|
+
this._onDidChangeVisibility = this._register(( (new Emitter())));
|
|
691
|
+
this.onDidChangeVisibility = this._onDidChangeVisibility.event;
|
|
692
|
+
this.registerListeners();
|
|
693
|
+
}
|
|
694
|
+
registerListeners() {
|
|
695
|
+
this._register(this.item.onDidChangeVisibility(visible => this._onDidChangeVisibility.fire(visible)));
|
|
696
|
+
Event.once(this.item.onDidClose)(() => {
|
|
697
|
+
this._onDidClose.fire();
|
|
698
|
+
this.dispose();
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
get progress() {
|
|
702
|
+
return this.item.progress;
|
|
703
|
+
}
|
|
704
|
+
updateSeverity(severity) {
|
|
705
|
+
this.item.updateSeverity(severity);
|
|
706
|
+
}
|
|
707
|
+
updateMessage(message) {
|
|
708
|
+
this.item.updateMessage(message);
|
|
709
|
+
}
|
|
710
|
+
updateActions(actions) {
|
|
711
|
+
this.item.updateActions(actions);
|
|
712
|
+
}
|
|
713
|
+
close() {
|
|
714
|
+
this.onClose(this.item);
|
|
715
|
+
this.dispose();
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
class NotificationsModel extends Disposable {
|
|
719
|
+
constructor() {
|
|
720
|
+
super(...arguments);
|
|
721
|
+
this._onDidChangeNotification = this._register(( (new Emitter())));
|
|
722
|
+
this.onDidChangeNotification = this._onDidChangeNotification.event;
|
|
723
|
+
this._onDidChangeStatusMessage = this._register(( (new Emitter())));
|
|
724
|
+
this.onDidChangeStatusMessage = this._onDidChangeStatusMessage.event;
|
|
725
|
+
this._onDidChangeFilter = this._register(( (new Emitter())));
|
|
726
|
+
this.onDidChangeFilter = this._onDidChangeFilter.event;
|
|
727
|
+
this._notifications = [];
|
|
728
|
+
this.filter = NotificationsFilter.OFF;
|
|
729
|
+
}
|
|
730
|
+
get notifications() { return this._notifications; }
|
|
731
|
+
get statusMessage() { return this._statusMessage; }
|
|
732
|
+
setFilter(filter) {
|
|
733
|
+
this.filter = filter;
|
|
734
|
+
this._onDidChangeFilter.fire(filter);
|
|
735
|
+
}
|
|
736
|
+
addNotification(notification) {
|
|
737
|
+
const item = this.createViewItem(notification);
|
|
738
|
+
if (!item) {
|
|
739
|
+
return NotificationsModel.NO_OP_NOTIFICATION;
|
|
740
|
+
}
|
|
741
|
+
const duplicate = this.findNotification(item);
|
|
742
|
+
if (duplicate) {
|
|
743
|
+
duplicate.close();
|
|
744
|
+
}
|
|
745
|
+
this._notifications.splice(0, 0, item);
|
|
746
|
+
this._onDidChangeNotification.fire({ item, index: 0, kind: 0 });
|
|
747
|
+
return (
|
|
748
|
+
(new NotificationHandle(item, item => this.onClose(item)))
|
|
749
|
+
);
|
|
750
|
+
}
|
|
751
|
+
onClose(item) {
|
|
752
|
+
const liveItem = this.findNotification(item);
|
|
753
|
+
if (liveItem && liveItem !== item) {
|
|
754
|
+
liveItem.close();
|
|
755
|
+
}
|
|
756
|
+
else {
|
|
757
|
+
item.close();
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
findNotification(item) {
|
|
761
|
+
return this._notifications.find(notification => notification.equals(item));
|
|
762
|
+
}
|
|
763
|
+
createViewItem(notification) {
|
|
764
|
+
const item = NotificationViewItem.create(notification, this.filter);
|
|
765
|
+
if (!item) {
|
|
766
|
+
return undefined;
|
|
767
|
+
}
|
|
768
|
+
const fireNotificationChangeEvent = (kind, detail) => {
|
|
769
|
+
const index = this._notifications.indexOf(item);
|
|
770
|
+
if (index >= 0) {
|
|
771
|
+
this._onDidChangeNotification.fire({ item, index, kind, detail });
|
|
772
|
+
}
|
|
773
|
+
};
|
|
774
|
+
const itemExpansionChangeListener = item.onDidChangeExpansion(() => fireNotificationChangeEvent(2 ));
|
|
775
|
+
const itemContentChangeListener = item.onDidChangeContent(e => fireNotificationChangeEvent(1 , e.kind));
|
|
776
|
+
Event.once(item.onDidClose)(() => {
|
|
777
|
+
itemExpansionChangeListener.dispose();
|
|
778
|
+
itemContentChangeListener.dispose();
|
|
779
|
+
const index = this._notifications.indexOf(item);
|
|
780
|
+
if (index >= 0) {
|
|
781
|
+
this._notifications.splice(index, 1);
|
|
782
|
+
this._onDidChangeNotification.fire({ item, index, kind: 3 });
|
|
783
|
+
}
|
|
784
|
+
});
|
|
785
|
+
return item;
|
|
786
|
+
}
|
|
787
|
+
showStatusMessage(message, options) {
|
|
788
|
+
const item = StatusMessageViewItem.create(message, options);
|
|
789
|
+
if (!item) {
|
|
790
|
+
return Disposable.None;
|
|
791
|
+
}
|
|
792
|
+
this._statusMessage = item;
|
|
793
|
+
this._onDidChangeStatusMessage.fire({ kind: 0 , item });
|
|
794
|
+
return toDisposable(() => {
|
|
795
|
+
if (this._statusMessage === item) {
|
|
796
|
+
this._statusMessage = undefined;
|
|
797
|
+
this._onDidChangeStatusMessage.fire({ kind: 1 , item });
|
|
798
|
+
}
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
NotificationsModel.NO_OP_NOTIFICATION = ( (new NoOpNotification()));
|
|
803
|
+
function isNotificationViewItem(obj) {
|
|
804
|
+
return obj instanceof NotificationViewItem;
|
|
805
|
+
}
|
|
806
|
+
class NotificationViewItemProgress extends Disposable {
|
|
807
|
+
constructor() {
|
|
808
|
+
super();
|
|
809
|
+
this._onDidChange = this._register(( (new Emitter())));
|
|
810
|
+
this.onDidChange = this._onDidChange.event;
|
|
811
|
+
this._state = Object.create(null);
|
|
812
|
+
}
|
|
813
|
+
get state() {
|
|
814
|
+
return this._state;
|
|
815
|
+
}
|
|
816
|
+
infinite() {
|
|
817
|
+
if (this._state.infinite) {
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
820
|
+
this._state.infinite = true;
|
|
821
|
+
this._state.total = undefined;
|
|
822
|
+
this._state.worked = undefined;
|
|
823
|
+
this._state.done = undefined;
|
|
824
|
+
this._onDidChange.fire();
|
|
825
|
+
}
|
|
826
|
+
done() {
|
|
827
|
+
if (this._state.done) {
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
830
|
+
this._state.done = true;
|
|
831
|
+
this._state.infinite = undefined;
|
|
832
|
+
this._state.total = undefined;
|
|
833
|
+
this._state.worked = undefined;
|
|
834
|
+
this._onDidChange.fire();
|
|
835
|
+
}
|
|
836
|
+
total(value) {
|
|
837
|
+
if (this._state.total === value) {
|
|
838
|
+
return;
|
|
839
|
+
}
|
|
840
|
+
this._state.total = value;
|
|
841
|
+
this._state.infinite = undefined;
|
|
842
|
+
this._state.done = undefined;
|
|
843
|
+
this._onDidChange.fire();
|
|
844
|
+
}
|
|
845
|
+
worked(value) {
|
|
846
|
+
if (typeof this._state.worked === 'number') {
|
|
847
|
+
this._state.worked += value;
|
|
848
|
+
}
|
|
849
|
+
else {
|
|
850
|
+
this._state.worked = value;
|
|
851
|
+
}
|
|
852
|
+
this._state.infinite = undefined;
|
|
853
|
+
this._state.done = undefined;
|
|
854
|
+
this._onDidChange.fire();
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
class NotificationViewItem extends Disposable {
|
|
858
|
+
constructor(id, _severity, _sticky, _silent, _message, _source, progress, actions) {
|
|
859
|
+
super();
|
|
860
|
+
this.id = id;
|
|
861
|
+
this._severity = _severity;
|
|
862
|
+
this._sticky = _sticky;
|
|
863
|
+
this._silent = _silent;
|
|
864
|
+
this._message = _message;
|
|
865
|
+
this._source = _source;
|
|
866
|
+
this._visible = false;
|
|
867
|
+
this._onDidChangeExpansion = this._register(( (new Emitter())));
|
|
868
|
+
this.onDidChangeExpansion = this._onDidChangeExpansion.event;
|
|
869
|
+
this._onDidClose = this._register(( (new Emitter())));
|
|
870
|
+
this.onDidClose = this._onDidClose.event;
|
|
871
|
+
this._onDidChangeContent = this._register(( (new Emitter())));
|
|
872
|
+
this.onDidChangeContent = this._onDidChangeContent.event;
|
|
873
|
+
this._onDidChangeVisibility = this._register(( (new Emitter())));
|
|
874
|
+
this.onDidChangeVisibility = this._onDidChangeVisibility.event;
|
|
875
|
+
if (progress) {
|
|
876
|
+
this.setProgress(progress);
|
|
877
|
+
}
|
|
878
|
+
this.setActions(actions);
|
|
879
|
+
}
|
|
880
|
+
static create(notification, filter = NotificationsFilter.OFF) {
|
|
881
|
+
if (!notification || !notification.message || isCancellationError(notification.message)) {
|
|
882
|
+
return undefined;
|
|
883
|
+
}
|
|
884
|
+
let severity;
|
|
885
|
+
if (typeof notification.severity === 'number') {
|
|
886
|
+
severity = notification.severity;
|
|
887
|
+
}
|
|
888
|
+
else {
|
|
889
|
+
severity = Severity.Info;
|
|
890
|
+
}
|
|
891
|
+
const message = NotificationViewItem.parseNotificationMessage(notification.message);
|
|
892
|
+
if (!message) {
|
|
893
|
+
return undefined;
|
|
894
|
+
}
|
|
895
|
+
let actions;
|
|
896
|
+
if (notification.actions) {
|
|
897
|
+
actions = notification.actions;
|
|
898
|
+
}
|
|
899
|
+
else if (isErrorWithActions(notification.message)) {
|
|
900
|
+
actions = { primary: notification.message.actions };
|
|
901
|
+
}
|
|
902
|
+
return (
|
|
903
|
+
(new NotificationViewItem(
|
|
904
|
+
notification.id,
|
|
905
|
+
severity,
|
|
906
|
+
notification.sticky,
|
|
907
|
+
notification.silent || filter === NotificationsFilter.SILENT || (filter === NotificationsFilter.ERROR && notification.severity !== Severity.Error),
|
|
908
|
+
message,
|
|
909
|
+
notification.source,
|
|
910
|
+
notification.progress,
|
|
911
|
+
actions
|
|
912
|
+
))
|
|
913
|
+
);
|
|
914
|
+
}
|
|
915
|
+
static parseNotificationMessage(input) {
|
|
916
|
+
let message;
|
|
917
|
+
if (input instanceof Error) {
|
|
918
|
+
message = toErrorMessage(input, false);
|
|
919
|
+
}
|
|
920
|
+
else if (typeof input === 'string') {
|
|
921
|
+
message = input;
|
|
922
|
+
}
|
|
923
|
+
if (!message) {
|
|
924
|
+
return undefined;
|
|
925
|
+
}
|
|
926
|
+
const raw = message;
|
|
927
|
+
if (message.length > NotificationViewItem.MAX_MESSAGE_LENGTH) {
|
|
928
|
+
message = `${message.substr(0, NotificationViewItem.MAX_MESSAGE_LENGTH)}...`;
|
|
929
|
+
}
|
|
930
|
+
message = message.replace(/(\r\n|\n|\r)/gm, ' ').trim();
|
|
931
|
+
const linkedText = parseLinkedText(message);
|
|
932
|
+
return { raw, linkedText, original: input };
|
|
933
|
+
}
|
|
934
|
+
setProgress(progress) {
|
|
935
|
+
if (progress.infinite) {
|
|
936
|
+
this.progress.infinite();
|
|
937
|
+
}
|
|
938
|
+
else if (progress.total) {
|
|
939
|
+
this.progress.total(progress.total);
|
|
940
|
+
if (progress.worked) {
|
|
941
|
+
this.progress.worked(progress.worked);
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
setActions(actions = { primary: [], secondary: [] }) {
|
|
946
|
+
this._actions = {
|
|
947
|
+
primary: Array.isArray(actions.primary) ? actions.primary : [],
|
|
948
|
+
secondary: Array.isArray(actions.secondary) ? actions.secondary : []
|
|
949
|
+
};
|
|
950
|
+
this._expanded = actions.primary && actions.primary.length > 0;
|
|
951
|
+
}
|
|
952
|
+
get canCollapse() {
|
|
953
|
+
return !this.hasActions;
|
|
954
|
+
}
|
|
955
|
+
get expanded() {
|
|
956
|
+
return !!this._expanded;
|
|
957
|
+
}
|
|
958
|
+
get severity() {
|
|
959
|
+
return this._severity;
|
|
960
|
+
}
|
|
961
|
+
get sticky() {
|
|
962
|
+
if (this._sticky) {
|
|
963
|
+
return true;
|
|
964
|
+
}
|
|
965
|
+
const hasActions = this.hasActions;
|
|
966
|
+
if ((hasActions && this._severity === Severity.Error) ||
|
|
967
|
+
(!hasActions && this._expanded) ||
|
|
968
|
+
(this._progress && !this._progress.state.done)
|
|
969
|
+
) {
|
|
970
|
+
return true;
|
|
971
|
+
}
|
|
972
|
+
return false;
|
|
973
|
+
}
|
|
974
|
+
get silent() {
|
|
975
|
+
return !!this._silent;
|
|
976
|
+
}
|
|
977
|
+
get hasActions() {
|
|
978
|
+
if (!this._actions) {
|
|
979
|
+
return false;
|
|
980
|
+
}
|
|
981
|
+
if (!this._actions.primary) {
|
|
982
|
+
return false;
|
|
983
|
+
}
|
|
984
|
+
return this._actions.primary.length > 0;
|
|
985
|
+
}
|
|
986
|
+
get hasProgress() {
|
|
987
|
+
return !!this._progress;
|
|
988
|
+
}
|
|
989
|
+
get progress() {
|
|
990
|
+
if (!this._progress) {
|
|
991
|
+
this._progress = this._register(( (new NotificationViewItemProgress())));
|
|
992
|
+
this._register(this._progress.onDidChange(() => this._onDidChangeContent.fire({ kind: 3 })));
|
|
993
|
+
}
|
|
994
|
+
return this._progress;
|
|
995
|
+
}
|
|
996
|
+
get message() {
|
|
997
|
+
return this._message;
|
|
998
|
+
}
|
|
999
|
+
get source() {
|
|
1000
|
+
return typeof this._source === 'string' ? this._source : (this._source ? this._source.label : undefined);
|
|
1001
|
+
}
|
|
1002
|
+
get sourceId() {
|
|
1003
|
+
return (this._source && typeof this._source !== 'string' && 'id' in this._source) ? this._source.id : undefined;
|
|
1004
|
+
}
|
|
1005
|
+
get actions() {
|
|
1006
|
+
return this._actions;
|
|
1007
|
+
}
|
|
1008
|
+
get visible() {
|
|
1009
|
+
return this._visible;
|
|
1010
|
+
}
|
|
1011
|
+
updateSeverity(severity) {
|
|
1012
|
+
if (severity === this._severity) {
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
this._severity = severity;
|
|
1016
|
+
this._onDidChangeContent.fire({ kind: 0 });
|
|
1017
|
+
}
|
|
1018
|
+
updateMessage(input) {
|
|
1019
|
+
const message = NotificationViewItem.parseNotificationMessage(input);
|
|
1020
|
+
if (!message || message.raw === this._message.raw) {
|
|
1021
|
+
return;
|
|
1022
|
+
}
|
|
1023
|
+
this._message = message;
|
|
1024
|
+
this._onDidChangeContent.fire({ kind: 1 });
|
|
1025
|
+
}
|
|
1026
|
+
updateActions(actions) {
|
|
1027
|
+
this.setActions(actions);
|
|
1028
|
+
this._onDidChangeContent.fire({ kind: 2 });
|
|
1029
|
+
}
|
|
1030
|
+
updateVisibility(visible) {
|
|
1031
|
+
if (this._visible !== visible) {
|
|
1032
|
+
this._visible = visible;
|
|
1033
|
+
this._onDidChangeVisibility.fire(visible);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
expand() {
|
|
1037
|
+
if (this._expanded || !this.canCollapse) {
|
|
1038
|
+
return;
|
|
1039
|
+
}
|
|
1040
|
+
this._expanded = true;
|
|
1041
|
+
this._onDidChangeExpansion.fire();
|
|
1042
|
+
}
|
|
1043
|
+
collapse(skipEvents) {
|
|
1044
|
+
if (!this._expanded || !this.canCollapse) {
|
|
1045
|
+
return;
|
|
1046
|
+
}
|
|
1047
|
+
this._expanded = false;
|
|
1048
|
+
if (!skipEvents) {
|
|
1049
|
+
this._onDidChangeExpansion.fire();
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
toggle() {
|
|
1053
|
+
if (this._expanded) {
|
|
1054
|
+
this.collapse();
|
|
1055
|
+
}
|
|
1056
|
+
else {
|
|
1057
|
+
this.expand();
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
close() {
|
|
1061
|
+
this._onDidClose.fire();
|
|
1062
|
+
this.dispose();
|
|
1063
|
+
}
|
|
1064
|
+
equals(other) {
|
|
1065
|
+
if (this.hasProgress || other.hasProgress) {
|
|
1066
|
+
return false;
|
|
1067
|
+
}
|
|
1068
|
+
if (typeof this.id === 'string' || typeof other.id === 'string') {
|
|
1069
|
+
return this.id === other.id;
|
|
1070
|
+
}
|
|
1071
|
+
if (typeof this._source === 'object') {
|
|
1072
|
+
if (this._source.label !== other.source || this._source.id !== other.sourceId) {
|
|
1073
|
+
return false;
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
else if (this._source !== other.source) {
|
|
1077
|
+
return false;
|
|
1078
|
+
}
|
|
1079
|
+
if (this._message.raw !== other.message.raw) {
|
|
1080
|
+
return false;
|
|
1081
|
+
}
|
|
1082
|
+
const primaryActions = (this._actions && this._actions.primary) || [];
|
|
1083
|
+
const otherPrimaryActions = (other.actions && other.actions.primary) || [];
|
|
1084
|
+
return equals(primaryActions, otherPrimaryActions, (action, otherAction) => (action.id + action.label) === (otherAction.id + otherAction.label));
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
NotificationViewItem.MAX_MESSAGE_LENGTH = 1000;
|
|
1088
|
+
class ChoiceAction extends Action {
|
|
1089
|
+
constructor(id, choice) {
|
|
1090
|
+
super(id, choice.label, undefined, true, async () => {
|
|
1091
|
+
choice.run();
|
|
1092
|
+
this._onDidRun.fire();
|
|
1093
|
+
});
|
|
1094
|
+
this._onDidRun = this._register(( (new Emitter())));
|
|
1095
|
+
this.onDidRun = this._onDidRun.event;
|
|
1096
|
+
this._keepOpen = !!choice.keepOpen;
|
|
1097
|
+
this._menu = !choice.isSecondary && choice.menu ? choice.menu.map((c, index) => ( (new ChoiceAction(`${id}.${index}`, c)))) : undefined;
|
|
1098
|
+
}
|
|
1099
|
+
get menu() {
|
|
1100
|
+
return this._menu;
|
|
1101
|
+
}
|
|
1102
|
+
get keepOpen() {
|
|
1103
|
+
return this._keepOpen;
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
class StatusMessageViewItem {
|
|
1107
|
+
static create(notification, options) {
|
|
1108
|
+
if (!notification || isCancellationError(notification)) {
|
|
1109
|
+
return undefined;
|
|
1110
|
+
}
|
|
1111
|
+
let message;
|
|
1112
|
+
if (notification instanceof Error) {
|
|
1113
|
+
message = toErrorMessage(notification, false);
|
|
1114
|
+
}
|
|
1115
|
+
else if (typeof notification === 'string') {
|
|
1116
|
+
message = notification;
|
|
1117
|
+
}
|
|
1118
|
+
if (!message) {
|
|
1119
|
+
return undefined;
|
|
1120
|
+
}
|
|
1121
|
+
return { message, options };
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
var css$1 = "/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\n.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-toolbar-container .action-item,\n.monaco-workbench > .notifications-center > .notifications-center-header > .notifications-center-header-toolbar .action-item {\n\tmargin-right: 4px;\n}\n\n.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-toolbar-container .action-item:first-child,\n.monaco-workbench > .notifications-center > .notifications-center-header > .notifications-center-header-toolbar .action-item:first-child {\n\tmargin-left: 4px;\n}\n";
|
|
1125
|
+
n(css$1,{});
|
|
1126
|
+
function notificationToMetrics(message, source, silent) {
|
|
1127
|
+
return {
|
|
1128
|
+
id: ( (hash(( (message.toString()))).toString())),
|
|
1129
|
+
silent,
|
|
1130
|
+
source: source || 'core'
|
|
1131
|
+
};
|
|
1132
|
+
}
|
|
1133
|
+
const MultipleEditorGroupsContext = ( (new RawContextKey(
|
|
1134
|
+
'multipleEditorGroups',
|
|
1135
|
+
false,
|
|
1136
|
+
(localize('multipleEditorGroups', "Whether there are multiple editor groups opened"))
|
|
1137
|
+
)));
|
|
1138
|
+
MultipleEditorGroupsContext.toNegated();
|
|
1139
|
+
const NotificationFocusedContext = ( (new RawContextKey(
|
|
1140
|
+
'notificationFocus',
|
|
1141
|
+
true,
|
|
1142
|
+
(localize('notificationFocus', "Whether a notification has keyboard focus"))
|
|
1143
|
+
)));
|
|
1144
|
+
const NotificationsCenterVisibleContext = ( (new RawContextKey(
|
|
1145
|
+
'notificationCenterVisible',
|
|
1146
|
+
false,
|
|
1147
|
+
(localize('notificationCenterVisible', "Whether the notifications center is visible"))
|
|
1148
|
+
)));
|
|
1149
|
+
const NotificationsToastsVisibleContext = ( (new RawContextKey(
|
|
1150
|
+
'notificationToastsVisible',
|
|
1151
|
+
false,
|
|
1152
|
+
(localize('notificationToastsVisible', "Whether a notification toast is visible"))
|
|
1153
|
+
)));
|
|
1154
|
+
let ResourceContextKey = class ResourceContextKey {
|
|
1155
|
+
constructor(_contextKeyService, _fileService, _languageService, _modelService) {
|
|
1156
|
+
this._contextKeyService = _contextKeyService;
|
|
1157
|
+
this._fileService = _fileService;
|
|
1158
|
+
this._languageService = _languageService;
|
|
1159
|
+
this._modelService = _modelService;
|
|
1160
|
+
this._disposables = ( (new DisposableStore()));
|
|
1161
|
+
this._schemeKey = ResourceContextKey.Scheme.bindTo(this._contextKeyService);
|
|
1162
|
+
this._filenameKey = ResourceContextKey.Filename.bindTo(this._contextKeyService);
|
|
1163
|
+
this._dirnameKey = ResourceContextKey.Dirname.bindTo(this._contextKeyService);
|
|
1164
|
+
this._pathKey = ResourceContextKey.Path.bindTo(this._contextKeyService);
|
|
1165
|
+
this._langIdKey = ResourceContextKey.LangId.bindTo(this._contextKeyService);
|
|
1166
|
+
this._resourceKey = ResourceContextKey.Resource.bindTo(this._contextKeyService);
|
|
1167
|
+
this._extensionKey = ResourceContextKey.Extension.bindTo(this._contextKeyService);
|
|
1168
|
+
this._hasResource = ResourceContextKey.HasResource.bindTo(this._contextKeyService);
|
|
1169
|
+
this._isFileSystemResource = ResourceContextKey.IsFileSystemResource.bindTo(this._contextKeyService);
|
|
1170
|
+
this._disposables.add(_fileService.onDidChangeFileSystemProviderRegistrations(() => {
|
|
1171
|
+
const resource = this.get();
|
|
1172
|
+
this._isFileSystemResource.set(Boolean(resource && _fileService.hasProvider(resource)));
|
|
1173
|
+
}));
|
|
1174
|
+
this._disposables.add(_modelService.onModelAdded(model => {
|
|
1175
|
+
if (isEqual(model.uri, this.get())) {
|
|
1176
|
+
this._setLangId();
|
|
1177
|
+
}
|
|
1178
|
+
}));
|
|
1179
|
+
this._disposables.add(_modelService.onModelLanguageChanged(e => {
|
|
1180
|
+
if (isEqual(e.model.uri, this.get())) {
|
|
1181
|
+
this._setLangId();
|
|
1182
|
+
}
|
|
1183
|
+
}));
|
|
1184
|
+
}
|
|
1185
|
+
dispose() {
|
|
1186
|
+
this._disposables.dispose();
|
|
1187
|
+
}
|
|
1188
|
+
_setLangId() {
|
|
1189
|
+
const value = this.get();
|
|
1190
|
+
if (!value) {
|
|
1191
|
+
this._langIdKey.set(null);
|
|
1192
|
+
return;
|
|
1193
|
+
}
|
|
1194
|
+
const langId = this._modelService.getModel(value)?.getLanguageId() ?? this._languageService.guessLanguageIdByFilepathOrFirstLine(value);
|
|
1195
|
+
this._langIdKey.set(langId);
|
|
1196
|
+
}
|
|
1197
|
+
set(value) {
|
|
1198
|
+
value = value ?? undefined;
|
|
1199
|
+
if (isEqual(this._value, value)) {
|
|
1200
|
+
return;
|
|
1201
|
+
}
|
|
1202
|
+
this._value = value;
|
|
1203
|
+
this._contextKeyService.bufferChangeEvents(() => {
|
|
1204
|
+
this._resourceKey.set(value ? ( (value.toString())) : null);
|
|
1205
|
+
this._schemeKey.set(value ? value.scheme : null);
|
|
1206
|
+
this._filenameKey.set(value ? basename(value) : null);
|
|
1207
|
+
this._dirnameKey.set(value ? dirname(value).fsPath : null);
|
|
1208
|
+
this._pathKey.set(value ? value.fsPath : null);
|
|
1209
|
+
this._setLangId();
|
|
1210
|
+
this._extensionKey.set(value ? extname(value) : null);
|
|
1211
|
+
this._hasResource.set(Boolean(value));
|
|
1212
|
+
this._isFileSystemResource.set(value ? this._fileService.hasProvider(value) : false);
|
|
1213
|
+
});
|
|
1214
|
+
}
|
|
1215
|
+
reset() {
|
|
1216
|
+
this._value = undefined;
|
|
1217
|
+
this._contextKeyService.bufferChangeEvents(() => {
|
|
1218
|
+
this._resourceKey.reset();
|
|
1219
|
+
this._schemeKey.reset();
|
|
1220
|
+
this._filenameKey.reset();
|
|
1221
|
+
this._dirnameKey.reset();
|
|
1222
|
+
this._pathKey.reset();
|
|
1223
|
+
this._langIdKey.reset();
|
|
1224
|
+
this._extensionKey.reset();
|
|
1225
|
+
this._hasResource.reset();
|
|
1226
|
+
this._isFileSystemResource.reset();
|
|
1227
|
+
});
|
|
1228
|
+
}
|
|
1229
|
+
get() {
|
|
1230
|
+
return this._value;
|
|
1231
|
+
}
|
|
1232
|
+
};
|
|
1233
|
+
ResourceContextKey.Scheme = ( (new RawContextKey(
|
|
1234
|
+
'resourceScheme',
|
|
1235
|
+
undefined,
|
|
1236
|
+
{ type: 'string', description: ( (localize('resourceScheme', "The scheme of the resource"))) }
|
|
1237
|
+
)));
|
|
1238
|
+
ResourceContextKey.Filename = ( (new RawContextKey(
|
|
1239
|
+
'resourceFilename',
|
|
1240
|
+
undefined,
|
|
1241
|
+
{ type: 'string', description: ( (localize('resourceFilename', "The file name of the resource"))) }
|
|
1242
|
+
)));
|
|
1243
|
+
ResourceContextKey.Dirname = ( (new RawContextKey(
|
|
1244
|
+
'resourceDirname',
|
|
1245
|
+
undefined,
|
|
1246
|
+
{ type: 'string', description: ( (localize('resourceDirname', "The folder name the resource is contained in"))) }
|
|
1247
|
+
)));
|
|
1248
|
+
ResourceContextKey.Path = ( (new RawContextKey(
|
|
1249
|
+
'resourcePath',
|
|
1250
|
+
undefined,
|
|
1251
|
+
{ type: 'string', description: ( (localize('resourcePath', "The full path of the resource"))) }
|
|
1252
|
+
)));
|
|
1253
|
+
ResourceContextKey.LangId = ( (new RawContextKey(
|
|
1254
|
+
'resourceLangId',
|
|
1255
|
+
undefined,
|
|
1256
|
+
{ type: 'string', description: ( (localize('resourceLangId', "The language identifier of the resource"))) }
|
|
1257
|
+
)));
|
|
1258
|
+
ResourceContextKey.Resource = ( (new RawContextKey(
|
|
1259
|
+
'resource',
|
|
1260
|
+
undefined,
|
|
1261
|
+
{ type: 'URI', description: ( (localize('resource', "The full value of the resource including scheme and path"))) }
|
|
1262
|
+
)));
|
|
1263
|
+
ResourceContextKey.Extension = ( (new RawContextKey(
|
|
1264
|
+
'resourceExtname',
|
|
1265
|
+
undefined,
|
|
1266
|
+
{ type: 'string', description: ( (localize('resourceExtname', "The extension name of the resource"))) }
|
|
1267
|
+
)));
|
|
1268
|
+
ResourceContextKey.HasResource = ( (new RawContextKey(
|
|
1269
|
+
'resourceSet',
|
|
1270
|
+
undefined,
|
|
1271
|
+
{ type: 'boolean', description: ( (localize('resourceSet', "Whether a resource is present or not"))) }
|
|
1272
|
+
)));
|
|
1273
|
+
ResourceContextKey.IsFileSystemResource = ( (new RawContextKey(
|
|
1274
|
+
'isFileSystemResource',
|
|
1275
|
+
undefined,
|
|
1276
|
+
{ type: 'boolean', description: ( (localize(
|
|
1277
|
+
'isFileSystemResource',
|
|
1278
|
+
"Whether the resource is backed by a file system provider"
|
|
1279
|
+
))) }
|
|
1280
|
+
)));
|
|
1281
|
+
ResourceContextKey = ( (__decorate([
|
|
1282
|
+
( (__param(0, IContextKeyService))),
|
|
1283
|
+
( (__param(1, IFileService))),
|
|
1284
|
+
( (__param(2, ILanguageService))),
|
|
1285
|
+
( (__param(3, IModelService)))
|
|
1286
|
+
], ResourceContextKey)));
|
|
1287
|
+
const SHOW_NOTIFICATIONS_CENTER = 'notifications.showList';
|
|
1288
|
+
const HIDE_NOTIFICATIONS_CENTER = 'notifications.hideList';
|
|
1289
|
+
const HIDE_NOTIFICATION_TOAST = 'notifications.hideToasts';
|
|
1290
|
+
const FOCUS_NOTIFICATION_TOAST = 'notifications.focusToasts';
|
|
1291
|
+
const FOCUS_NEXT_NOTIFICATION_TOAST = 'notifications.focusNextToast';
|
|
1292
|
+
const FOCUS_PREVIOUS_NOTIFICATION_TOAST = 'notifications.focusPreviousToast';
|
|
1293
|
+
const FOCUS_FIRST_NOTIFICATION_TOAST = 'notifications.focusFirstToast';
|
|
1294
|
+
const FOCUS_LAST_NOTIFICATION_TOAST = 'notifications.focusLastToast';
|
|
1295
|
+
const COLLAPSE_NOTIFICATION = 'notification.collapse';
|
|
1296
|
+
const EXPAND_NOTIFICATION = 'notification.expand';
|
|
1297
|
+
const TOGGLE_NOTIFICATION = 'notification.toggle';
|
|
1298
|
+
const CLEAR_NOTIFICATION = 'notification.clear';
|
|
1299
|
+
const CLEAR_ALL_NOTIFICATIONS = 'notifications.clearAll';
|
|
1300
|
+
const TOGGLE_DO_NOT_DISTURB_MODE = 'notifications.toggleDoNotDisturbMode';
|
|
1301
|
+
function registerNotificationCommands(center, toasts, model) {
|
|
1302
|
+
function getNotificationFromContext(listService, context) {
|
|
1303
|
+
if (isNotificationViewItem(context)) {
|
|
1304
|
+
return context;
|
|
1305
|
+
}
|
|
1306
|
+
const list = listService.lastFocusedList;
|
|
1307
|
+
if (list instanceof WorkbenchList) {
|
|
1308
|
+
const focusedElement = list.getFocusedElements()[0];
|
|
1309
|
+
if (isNotificationViewItem(focusedElement)) {
|
|
1310
|
+
return focusedElement;
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
return undefined;
|
|
1314
|
+
}
|
|
1315
|
+
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|
1316
|
+
id: HIDE_NOTIFICATIONS_CENTER,
|
|
1317
|
+
weight: 200 + 50,
|
|
1318
|
+
when: NotificationsCenterVisibleContext,
|
|
1319
|
+
primary: 9 ,
|
|
1320
|
+
handler: accessor => {
|
|
1321
|
+
const telemetryService = accessor.get(ITelemetryService);
|
|
1322
|
+
for (const notification of model.notifications) {
|
|
1323
|
+
if (notification.visible) {
|
|
1324
|
+
telemetryService.publicLog2('notification:hide', notificationToMetrics(notification.message.original, notification.sourceId, notification.silent));
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
center.hide();
|
|
1328
|
+
}
|
|
1329
|
+
});
|
|
1330
|
+
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|
1331
|
+
id: CLEAR_NOTIFICATION,
|
|
1332
|
+
weight: 200 ,
|
|
1333
|
+
when: NotificationFocusedContext,
|
|
1334
|
+
primary: 20 ,
|
|
1335
|
+
mac: {
|
|
1336
|
+
primary: 2048 | 1
|
|
1337
|
+
},
|
|
1338
|
+
handler: (accessor, args) => {
|
|
1339
|
+
const notification = getNotificationFromContext(accessor.get(IListService), args);
|
|
1340
|
+
if (notification && !notification.hasProgress) {
|
|
1341
|
+
notification.close();
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
});
|
|
1345
|
+
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|
1346
|
+
id: EXPAND_NOTIFICATION,
|
|
1347
|
+
weight: 200 ,
|
|
1348
|
+
when: NotificationFocusedContext,
|
|
1349
|
+
primary: 17 ,
|
|
1350
|
+
handler: (accessor, args) => {
|
|
1351
|
+
const notification = getNotificationFromContext(accessor.get(IListService), args);
|
|
1352
|
+
if (notification) {
|
|
1353
|
+
notification.expand();
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
});
|
|
1357
|
+
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|
1358
|
+
id: COLLAPSE_NOTIFICATION,
|
|
1359
|
+
weight: 200 ,
|
|
1360
|
+
when: NotificationFocusedContext,
|
|
1361
|
+
primary: 15 ,
|
|
1362
|
+
handler: (accessor, args) => {
|
|
1363
|
+
const notification = getNotificationFromContext(accessor.get(IListService), args);
|
|
1364
|
+
if (notification) {
|
|
1365
|
+
notification.collapse();
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
});
|
|
1369
|
+
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|
1370
|
+
id: TOGGLE_NOTIFICATION,
|
|
1371
|
+
weight: 200 ,
|
|
1372
|
+
when: NotificationFocusedContext,
|
|
1373
|
+
primary: 10 ,
|
|
1374
|
+
secondary: [3 ],
|
|
1375
|
+
handler: accessor => {
|
|
1376
|
+
const notification = getNotificationFromContext(accessor.get(IListService));
|
|
1377
|
+
if (notification) {
|
|
1378
|
+
notification.toggle();
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
});
|
|
1382
|
+
KeybindingsRegistry.registerKeybindingRule({
|
|
1383
|
+
id: HIDE_NOTIFICATION_TOAST,
|
|
1384
|
+
weight: 200 - 50,
|
|
1385
|
+
when: NotificationsToastsVisibleContext,
|
|
1386
|
+
primary: 9
|
|
1387
|
+
});
|
|
1388
|
+
KeybindingsRegistry.registerKeybindingRule({
|
|
1389
|
+
id: HIDE_NOTIFICATION_TOAST,
|
|
1390
|
+
weight: 200 + 100,
|
|
1391
|
+
when: ContextKeyExpr.and(NotificationsToastsVisibleContext, NotificationFocusedContext),
|
|
1392
|
+
primary: 9
|
|
1393
|
+
});
|
|
1394
|
+
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|
1395
|
+
id: FOCUS_NEXT_NOTIFICATION_TOAST,
|
|
1396
|
+
weight: 200 ,
|
|
1397
|
+
when: ContextKeyExpr.and(NotificationFocusedContext, NotificationsToastsVisibleContext),
|
|
1398
|
+
primary: 18 ,
|
|
1399
|
+
handler: (accessor) => {
|
|
1400
|
+
toasts.focusNext();
|
|
1401
|
+
}
|
|
1402
|
+
});
|
|
1403
|
+
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|
1404
|
+
id: FOCUS_PREVIOUS_NOTIFICATION_TOAST,
|
|
1405
|
+
weight: 200 ,
|
|
1406
|
+
when: ContextKeyExpr.and(NotificationFocusedContext, NotificationsToastsVisibleContext),
|
|
1407
|
+
primary: 16 ,
|
|
1408
|
+
handler: (accessor) => {
|
|
1409
|
+
toasts.focusPrevious();
|
|
1410
|
+
}
|
|
1411
|
+
});
|
|
1412
|
+
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|
1413
|
+
id: FOCUS_FIRST_NOTIFICATION_TOAST,
|
|
1414
|
+
weight: 200 ,
|
|
1415
|
+
when: ContextKeyExpr.and(NotificationFocusedContext, NotificationsToastsVisibleContext),
|
|
1416
|
+
primary: 11 ,
|
|
1417
|
+
secondary: [14 ],
|
|
1418
|
+
handler: (accessor) => {
|
|
1419
|
+
toasts.focusFirst();
|
|
1420
|
+
}
|
|
1421
|
+
});
|
|
1422
|
+
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|
1423
|
+
id: FOCUS_LAST_NOTIFICATION_TOAST,
|
|
1424
|
+
weight: 200 ,
|
|
1425
|
+
when: ContextKeyExpr.and(NotificationFocusedContext, NotificationsToastsVisibleContext),
|
|
1426
|
+
primary: 12 ,
|
|
1427
|
+
secondary: [13 ],
|
|
1428
|
+
handler: (accessor) => {
|
|
1429
|
+
toasts.focusLast();
|
|
1430
|
+
}
|
|
1431
|
+
});
|
|
1432
|
+
const category = { value: ( (localize('notifications', "Notifications"))), original: 'Notifications' };
|
|
1433
|
+
MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { id: SHOW_NOTIFICATIONS_CENTER, title: { value: ( (localize('showNotifications', "Show Notifications"))), original: 'Show Notifications' }, category } });
|
|
1434
|
+
MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { id: HIDE_NOTIFICATIONS_CENTER, title: { value: ( (localize('hideNotifications', "Hide Notifications"))), original: 'Hide Notifications' }, category }, when: NotificationsCenterVisibleContext });
|
|
1435
|
+
MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { id: CLEAR_ALL_NOTIFICATIONS, title: { value: ( (localize('clearAllNotifications', "Clear All Notifications"))), original: 'Clear All Notifications' }, category } });
|
|
1436
|
+
MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { id: TOGGLE_DO_NOT_DISTURB_MODE, title: { value: ( (localize('toggleDoNotDisturbMode', "Toggle Do Not Disturb Mode"))), original: 'Toggle Do Not Disturb Mode' }, category } });
|
|
1437
|
+
MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { id: FOCUS_NOTIFICATION_TOAST, title: { value: ( (localize('focusNotificationToasts', "Focus Notification Toast"))), original: 'Focus Notification Toast' }, category }, when: NotificationsToastsVisibleContext });
|
|
1438
|
+
}
|
|
1439
|
+
const clearIcon = registerIcon('notifications-clear', Codicon.close, ( (localize('clearIcon', 'Icon for the clear action in notifications.'))));
|
|
1440
|
+
const clearAllIcon = registerIcon('notifications-clear-all', Codicon.clearAll, ( (localize('clearAllIcon', 'Icon for the clear all action in notifications.'))));
|
|
1441
|
+
const hideIcon = registerIcon('notifications-hide', Codicon.chevronDown, ( (localize('hideIcon', 'Icon for the hide action in notifications.'))));
|
|
1442
|
+
const expandIcon = registerIcon('notifications-expand', Codicon.chevronUp, ( (localize('expandIcon', 'Icon for the expand action in notifications.'))));
|
|
1443
|
+
const collapseIcon = registerIcon('notifications-collapse', Codicon.chevronDown, ( (localize('collapseIcon', 'Icon for the collapse action in notifications.'))));
|
|
1444
|
+
const configureIcon = registerIcon('notifications-configure', Codicon.gear, ( (localize('configureIcon', 'Icon for the configure action in notifications.'))));
|
|
1445
|
+
const doNotDisturbIcon = registerIcon('notifications-do-not-disturb', Codicon.bellSlash, ( (localize('doNotDisturbIcon', 'Icon for the mute all action in notifications.'))));
|
|
1446
|
+
let ClearNotificationAction = class ClearNotificationAction extends Action {
|
|
1447
|
+
constructor(id, label, commandService) {
|
|
1448
|
+
super(id, label, ThemeIcon.asClassName(clearIcon));
|
|
1449
|
+
this.commandService = commandService;
|
|
1450
|
+
}
|
|
1451
|
+
async run(notification) {
|
|
1452
|
+
this.commandService.executeCommand(CLEAR_NOTIFICATION, notification);
|
|
1453
|
+
}
|
|
1454
|
+
};
|
|
1455
|
+
ClearNotificationAction.ID = CLEAR_NOTIFICATION;
|
|
1456
|
+
ClearNotificationAction.LABEL = ( (localize('clearNotification', "Clear Notification")));
|
|
1457
|
+
ClearNotificationAction = ( (__decorate([
|
|
1458
|
+
( (__param(2, ICommandService)))
|
|
1459
|
+
], ClearNotificationAction)));
|
|
1460
|
+
let ClearAllNotificationsAction = class ClearAllNotificationsAction extends Action {
|
|
1461
|
+
constructor(id, label, commandService) {
|
|
1462
|
+
super(id, label, ThemeIcon.asClassName(clearAllIcon));
|
|
1463
|
+
this.commandService = commandService;
|
|
1464
|
+
}
|
|
1465
|
+
async run() {
|
|
1466
|
+
this.commandService.executeCommand(CLEAR_ALL_NOTIFICATIONS);
|
|
1467
|
+
}
|
|
1468
|
+
};
|
|
1469
|
+
ClearAllNotificationsAction.ID = CLEAR_ALL_NOTIFICATIONS;
|
|
1470
|
+
ClearAllNotificationsAction.LABEL = ( (localize('clearNotifications', "Clear All Notifications")));
|
|
1471
|
+
ClearAllNotificationsAction = ( (__decorate([
|
|
1472
|
+
( (__param(2, ICommandService)))
|
|
1473
|
+
], ClearAllNotificationsAction)));
|
|
1474
|
+
let ToggleDoNotDisturbAction = class ToggleDoNotDisturbAction extends Action {
|
|
1475
|
+
constructor(id, label, commandService) {
|
|
1476
|
+
super(id, label, ThemeIcon.asClassName(doNotDisturbIcon));
|
|
1477
|
+
this.commandService = commandService;
|
|
1478
|
+
}
|
|
1479
|
+
async run() {
|
|
1480
|
+
this.commandService.executeCommand(TOGGLE_DO_NOT_DISTURB_MODE);
|
|
1481
|
+
}
|
|
1482
|
+
};
|
|
1483
|
+
ToggleDoNotDisturbAction.ID = TOGGLE_DO_NOT_DISTURB_MODE;
|
|
1484
|
+
ToggleDoNotDisturbAction.LABEL = ( (localize('toggleDoNotDisturbMode', "Toggle Do Not Disturb Mode")));
|
|
1485
|
+
ToggleDoNotDisturbAction = ( (__decorate([
|
|
1486
|
+
( (__param(2, ICommandService)))
|
|
1487
|
+
], ToggleDoNotDisturbAction)));
|
|
1488
|
+
let HideNotificationsCenterAction = class HideNotificationsCenterAction extends Action {
|
|
1489
|
+
constructor(id, label, commandService) {
|
|
1490
|
+
super(id, label, ThemeIcon.asClassName(hideIcon));
|
|
1491
|
+
this.commandService = commandService;
|
|
1492
|
+
}
|
|
1493
|
+
async run() {
|
|
1494
|
+
this.commandService.executeCommand(HIDE_NOTIFICATIONS_CENTER);
|
|
1495
|
+
}
|
|
1496
|
+
};
|
|
1497
|
+
HideNotificationsCenterAction.ID = HIDE_NOTIFICATIONS_CENTER;
|
|
1498
|
+
HideNotificationsCenterAction.LABEL = ( (localize('hideNotificationsCenter', "Hide Notifications")));
|
|
1499
|
+
HideNotificationsCenterAction = ( (__decorate([
|
|
1500
|
+
( (__param(2, ICommandService)))
|
|
1501
|
+
], HideNotificationsCenterAction)));
|
|
1502
|
+
let ExpandNotificationAction = class ExpandNotificationAction extends Action {
|
|
1503
|
+
constructor(id, label, commandService) {
|
|
1504
|
+
super(id, label, ThemeIcon.asClassName(expandIcon));
|
|
1505
|
+
this.commandService = commandService;
|
|
1506
|
+
}
|
|
1507
|
+
async run(notification) {
|
|
1508
|
+
this.commandService.executeCommand(EXPAND_NOTIFICATION, notification);
|
|
1509
|
+
}
|
|
1510
|
+
};
|
|
1511
|
+
ExpandNotificationAction.ID = EXPAND_NOTIFICATION;
|
|
1512
|
+
ExpandNotificationAction.LABEL = ( (localize('expandNotification', "Expand Notification")));
|
|
1513
|
+
ExpandNotificationAction = ( (__decorate([
|
|
1514
|
+
( (__param(2, ICommandService)))
|
|
1515
|
+
], ExpandNotificationAction)));
|
|
1516
|
+
let CollapseNotificationAction = class CollapseNotificationAction extends Action {
|
|
1517
|
+
constructor(id, label, commandService) {
|
|
1518
|
+
super(id, label, ThemeIcon.asClassName(collapseIcon));
|
|
1519
|
+
this.commandService = commandService;
|
|
1520
|
+
}
|
|
1521
|
+
async run(notification) {
|
|
1522
|
+
this.commandService.executeCommand(COLLAPSE_NOTIFICATION, notification);
|
|
1523
|
+
}
|
|
1524
|
+
};
|
|
1525
|
+
CollapseNotificationAction.ID = COLLAPSE_NOTIFICATION;
|
|
1526
|
+
CollapseNotificationAction.LABEL = ( (localize('collapseNotification', "Collapse Notification")));
|
|
1527
|
+
CollapseNotificationAction = ( (__decorate([
|
|
1528
|
+
( (__param(2, ICommandService)))
|
|
1529
|
+
], CollapseNotificationAction)));
|
|
1530
|
+
class ConfigureNotificationAction extends Action {
|
|
1531
|
+
constructor(id, label, configurationActions) {
|
|
1532
|
+
super(id, label, ThemeIcon.asClassName(configureIcon));
|
|
1533
|
+
this.configurationActions = configurationActions;
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
ConfigureNotificationAction.ID = 'workbench.action.configureNotification';
|
|
1537
|
+
ConfigureNotificationAction.LABEL = ( (localize('configureNotification', "Configure Notification")));
|
|
1538
|
+
let CopyNotificationMessageAction = class CopyNotificationMessageAction extends Action {
|
|
1539
|
+
constructor(id, label, clipboardService) {
|
|
1540
|
+
super(id, label);
|
|
1541
|
+
this.clipboardService = clipboardService;
|
|
1542
|
+
}
|
|
1543
|
+
run(notification) {
|
|
1544
|
+
return this.clipboardService.writeText(notification.message.raw);
|
|
1545
|
+
}
|
|
1546
|
+
};
|
|
1547
|
+
CopyNotificationMessageAction.ID = 'workbench.action.copyNotificationMessage';
|
|
1548
|
+
CopyNotificationMessageAction.LABEL = ( (localize('copyNotification', "Copy Text")));
|
|
1549
|
+
CopyNotificationMessageAction = ( (__decorate([
|
|
1550
|
+
( (__param(2, IClipboardService)))
|
|
1551
|
+
], CopyNotificationMessageAction)));
|
|
1552
|
+
let NotificationActionRunner = class NotificationActionRunner extends ActionRunner {
|
|
1553
|
+
constructor(telemetryService, notificationService) {
|
|
1554
|
+
super();
|
|
1555
|
+
this.telemetryService = telemetryService;
|
|
1556
|
+
this.notificationService = notificationService;
|
|
1557
|
+
}
|
|
1558
|
+
async runAction(action, context) {
|
|
1559
|
+
this.telemetryService.publicLog2('workbenchActionExecuted', { id: action.id, from: 'message' });
|
|
1560
|
+
if (isNotificationViewItem(context)) {
|
|
1561
|
+
this.telemetryService.publicLog2('notification:actionExecuted', {
|
|
1562
|
+
id: ( (hash(( (context.message.original.toString()))).toString())),
|
|
1563
|
+
actionLabel: action.label,
|
|
1564
|
+
source: context.sourceId || 'core',
|
|
1565
|
+
silent: context.silent
|
|
1566
|
+
});
|
|
1567
|
+
}
|
|
1568
|
+
try {
|
|
1569
|
+
await super.runAction(action, context);
|
|
1570
|
+
}
|
|
1571
|
+
catch (error) {
|
|
1572
|
+
this.notificationService.error(error);
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
};
|
|
1576
|
+
NotificationActionRunner = ( (__decorate([
|
|
1577
|
+
( (__param(0, ITelemetryService))),
|
|
1578
|
+
( (__param(1, INotificationService)))
|
|
1579
|
+
], NotificationActionRunner)));
|
|
1580
|
+
class NotificationsListDelegate {
|
|
1581
|
+
constructor(container) {
|
|
1582
|
+
this.offsetHelper = this.createOffsetHelper(container);
|
|
1583
|
+
}
|
|
1584
|
+
createOffsetHelper(container) {
|
|
1585
|
+
const offsetHelper = document.createElement('div');
|
|
1586
|
+
offsetHelper.classList.add('notification-offset-helper');
|
|
1587
|
+
container.appendChild(offsetHelper);
|
|
1588
|
+
return offsetHelper;
|
|
1589
|
+
}
|
|
1590
|
+
getHeight(notification) {
|
|
1591
|
+
if (!notification.expanded) {
|
|
1592
|
+
return NotificationsListDelegate.ROW_HEIGHT;
|
|
1593
|
+
}
|
|
1594
|
+
let expandedHeight = NotificationsListDelegate.ROW_HEIGHT;
|
|
1595
|
+
const preferredMessageHeight = this.computePreferredHeight(notification);
|
|
1596
|
+
const messageOverflows = NotificationsListDelegate.LINE_HEIGHT < preferredMessageHeight;
|
|
1597
|
+
if (messageOverflows) {
|
|
1598
|
+
const overflow = preferredMessageHeight - NotificationsListDelegate.LINE_HEIGHT;
|
|
1599
|
+
expandedHeight += overflow;
|
|
1600
|
+
}
|
|
1601
|
+
if (notification.source || isNonEmptyArray(notification.actions && notification.actions.primary)) {
|
|
1602
|
+
expandedHeight += NotificationsListDelegate.ROW_HEIGHT;
|
|
1603
|
+
}
|
|
1604
|
+
if (expandedHeight === NotificationsListDelegate.ROW_HEIGHT) {
|
|
1605
|
+
notification.collapse(true );
|
|
1606
|
+
}
|
|
1607
|
+
return expandedHeight;
|
|
1608
|
+
}
|
|
1609
|
+
computePreferredHeight(notification) {
|
|
1610
|
+
let actions = 1;
|
|
1611
|
+
if (notification.canCollapse) {
|
|
1612
|
+
actions++;
|
|
1613
|
+
}
|
|
1614
|
+
if (isNonEmptyArray(notification.actions && notification.actions.secondary)) {
|
|
1615
|
+
actions++;
|
|
1616
|
+
}
|
|
1617
|
+
this.offsetHelper.style.width = `${450 - ((10 + 26 + (actions * (24 + 8)) - 4) )}px`;
|
|
1618
|
+
const renderedMessage = NotificationMessageRenderer.render(notification.message);
|
|
1619
|
+
this.offsetHelper.appendChild(renderedMessage);
|
|
1620
|
+
const preferredHeight = Math.max(this.offsetHelper.offsetHeight, this.offsetHelper.scrollHeight);
|
|
1621
|
+
clearNode(this.offsetHelper);
|
|
1622
|
+
return preferredHeight;
|
|
1623
|
+
}
|
|
1624
|
+
getTemplateId(element) {
|
|
1625
|
+
if (element instanceof NotificationViewItem) {
|
|
1626
|
+
return NotificationRenderer.TEMPLATE_ID;
|
|
1627
|
+
}
|
|
1628
|
+
throw new Error('unknown element type: ' + element);
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
NotificationsListDelegate.ROW_HEIGHT = 42;
|
|
1632
|
+
NotificationsListDelegate.LINE_HEIGHT = 22;
|
|
1633
|
+
class NotificationMessageRenderer {
|
|
1634
|
+
static render(message, actionHandler) {
|
|
1635
|
+
const messageContainer = document.createElement('span');
|
|
1636
|
+
for (const node of message.linkedText.nodes) {
|
|
1637
|
+
if (typeof node === 'string') {
|
|
1638
|
+
messageContainer.appendChild(document.createTextNode(node));
|
|
1639
|
+
}
|
|
1640
|
+
else {
|
|
1641
|
+
let title = node.title;
|
|
1642
|
+
if (!title && node.href.startsWith('command:')) {
|
|
1643
|
+
title = ( (localize(
|
|
1644
|
+
'executeCommand',
|
|
1645
|
+
"Click to execute command '{0}'",
|
|
1646
|
+
node.href.substr('command:'.length)
|
|
1647
|
+
)));
|
|
1648
|
+
}
|
|
1649
|
+
else if (!title) {
|
|
1650
|
+
title = node.href;
|
|
1651
|
+
}
|
|
1652
|
+
const anchor = $('a', { href: node.href, title: title, }, node.label);
|
|
1653
|
+
if (actionHandler) {
|
|
1654
|
+
const onPointer = (e) => {
|
|
1655
|
+
EventHelper.stop(e, true);
|
|
1656
|
+
actionHandler.callback(node.href);
|
|
1657
|
+
};
|
|
1658
|
+
const onClick = actionHandler.toDispose.add(( (new DomEmitter(anchor, 'click')))).event;
|
|
1659
|
+
actionHandler.toDispose.add(Gesture.addTarget(anchor));
|
|
1660
|
+
const onTap = actionHandler.toDispose.add(( (new DomEmitter(anchor, EventType$1.Tap)))).event;
|
|
1661
|
+
Event.any(onClick, onTap)(onPointer, null, actionHandler.toDispose);
|
|
1662
|
+
}
|
|
1663
|
+
messageContainer.appendChild(anchor);
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
return messageContainer;
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
let NotificationRenderer = class NotificationRenderer {
|
|
1670
|
+
constructor(actionRunner, themeService, contextMenuService, instantiationService) {
|
|
1671
|
+
this.actionRunner = actionRunner;
|
|
1672
|
+
this.themeService = themeService;
|
|
1673
|
+
this.contextMenuService = contextMenuService;
|
|
1674
|
+
this.instantiationService = instantiationService;
|
|
1675
|
+
}
|
|
1676
|
+
get templateId() {
|
|
1677
|
+
return NotificationRenderer.TEMPLATE_ID;
|
|
1678
|
+
}
|
|
1679
|
+
renderTemplate(container) {
|
|
1680
|
+
const data = Object.create(null);
|
|
1681
|
+
data.toDispose = ( (new DisposableStore()));
|
|
1682
|
+
data.container = document.createElement('div');
|
|
1683
|
+
data.container.classList.add('notification-list-item');
|
|
1684
|
+
data.mainRow = document.createElement('div');
|
|
1685
|
+
data.mainRow.classList.add('notification-list-item-main-row');
|
|
1686
|
+
data.icon = document.createElement('div');
|
|
1687
|
+
data.icon.classList.add('notification-list-item-icon', 'codicon');
|
|
1688
|
+
data.message = document.createElement('div');
|
|
1689
|
+
data.message.classList.add('notification-list-item-message');
|
|
1690
|
+
const toolbarContainer = document.createElement('div');
|
|
1691
|
+
toolbarContainer.classList.add('notification-list-item-toolbar-container');
|
|
1692
|
+
data.toolbar = ( (new ActionBar(toolbarContainer, {
|
|
1693
|
+
ariaLabel: ( (localize('notificationActions', "Notification Actions"))),
|
|
1694
|
+
actionViewItemProvider: action => {
|
|
1695
|
+
if (action && action instanceof ConfigureNotificationAction) {
|
|
1696
|
+
const item = ( (new DropdownMenuActionViewItem(
|
|
1697
|
+
action,
|
|
1698
|
+
action.configurationActions,
|
|
1699
|
+
this.contextMenuService,
|
|
1700
|
+
{ actionRunner: this.actionRunner, classNames: action.class }
|
|
1701
|
+
)));
|
|
1702
|
+
data.toDispose.add(item);
|
|
1703
|
+
return item;
|
|
1704
|
+
}
|
|
1705
|
+
return undefined;
|
|
1706
|
+
},
|
|
1707
|
+
actionRunner: this.actionRunner
|
|
1708
|
+
})));
|
|
1709
|
+
data.toDispose.add(data.toolbar);
|
|
1710
|
+
data.detailsRow = document.createElement('div');
|
|
1711
|
+
data.detailsRow.classList.add('notification-list-item-details-row');
|
|
1712
|
+
data.source = document.createElement('div');
|
|
1713
|
+
data.source.classList.add('notification-list-item-source');
|
|
1714
|
+
data.buttonsContainer = document.createElement('div');
|
|
1715
|
+
data.buttonsContainer.classList.add('notification-list-item-buttons-container');
|
|
1716
|
+
container.appendChild(data.container);
|
|
1717
|
+
data.container.appendChild(data.detailsRow);
|
|
1718
|
+
data.detailsRow.appendChild(data.source);
|
|
1719
|
+
data.detailsRow.appendChild(data.buttonsContainer);
|
|
1720
|
+
data.container.appendChild(data.mainRow);
|
|
1721
|
+
data.mainRow.appendChild(data.icon);
|
|
1722
|
+
data.mainRow.appendChild(data.message);
|
|
1723
|
+
data.mainRow.appendChild(toolbarContainer);
|
|
1724
|
+
data.progress = ( (new ProgressBar(container)));
|
|
1725
|
+
data.toDispose.add(attachProgressBarStyler(data.progress, this.themeService));
|
|
1726
|
+
data.toDispose.add(data.progress);
|
|
1727
|
+
data.renderer = this.instantiationService.createInstance(NotificationTemplateRenderer, data, this.actionRunner);
|
|
1728
|
+
data.toDispose.add(data.renderer);
|
|
1729
|
+
return data;
|
|
1730
|
+
}
|
|
1731
|
+
renderElement(notification, index, data) {
|
|
1732
|
+
data.renderer.setInput(notification);
|
|
1733
|
+
}
|
|
1734
|
+
disposeTemplate(templateData) {
|
|
1735
|
+
dispose(templateData.toDispose);
|
|
1736
|
+
}
|
|
1737
|
+
};
|
|
1738
|
+
NotificationRenderer.TEMPLATE_ID = 'notification';
|
|
1739
|
+
NotificationRenderer = ( (__decorate([
|
|
1740
|
+
( (__param(1, IThemeService))),
|
|
1741
|
+
( (__param(2, IContextMenuService))),
|
|
1742
|
+
( (__param(3, IInstantiationService)))
|
|
1743
|
+
], NotificationRenderer)));
|
|
1744
|
+
let NotificationTemplateRenderer = class NotificationTemplateRenderer extends Disposable {
|
|
1745
|
+
constructor(template, actionRunner, openerService, instantiationService, themeService, keybindingService, contextMenuService) {
|
|
1746
|
+
super();
|
|
1747
|
+
this.template = template;
|
|
1748
|
+
this.actionRunner = actionRunner;
|
|
1749
|
+
this.openerService = openerService;
|
|
1750
|
+
this.instantiationService = instantiationService;
|
|
1751
|
+
this.themeService = themeService;
|
|
1752
|
+
this.keybindingService = keybindingService;
|
|
1753
|
+
this.contextMenuService = contextMenuService;
|
|
1754
|
+
this.inputDisposables = this._register(( (new DisposableStore())));
|
|
1755
|
+
if (!NotificationTemplateRenderer.closeNotificationAction) {
|
|
1756
|
+
NotificationTemplateRenderer.closeNotificationAction = instantiationService.createInstance(ClearNotificationAction, ClearNotificationAction.ID, ClearNotificationAction.LABEL);
|
|
1757
|
+
NotificationTemplateRenderer.expandNotificationAction = instantiationService.createInstance(ExpandNotificationAction, ExpandNotificationAction.ID, ExpandNotificationAction.LABEL);
|
|
1758
|
+
NotificationTemplateRenderer.collapseNotificationAction = instantiationService.createInstance(CollapseNotificationAction, CollapseNotificationAction.ID, CollapseNotificationAction.LABEL);
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
setInput(notification) {
|
|
1762
|
+
this.inputDisposables.clear();
|
|
1763
|
+
this.render(notification);
|
|
1764
|
+
}
|
|
1765
|
+
render(notification) {
|
|
1766
|
+
this.template.container.classList.toggle('expanded', notification.expanded);
|
|
1767
|
+
this.inputDisposables.add(addDisposableListener(this.template.container, EventType.MOUSE_UP, e => {
|
|
1768
|
+
if (e.button === 1 ) {
|
|
1769
|
+
EventHelper.stop(e, true);
|
|
1770
|
+
}
|
|
1771
|
+
}));
|
|
1772
|
+
this.inputDisposables.add(addDisposableListener(this.template.container, EventType.AUXCLICK, e => {
|
|
1773
|
+
if (!notification.hasProgress && e.button === 1 ) {
|
|
1774
|
+
EventHelper.stop(e, true);
|
|
1775
|
+
notification.close();
|
|
1776
|
+
}
|
|
1777
|
+
}));
|
|
1778
|
+
this.renderSeverity(notification);
|
|
1779
|
+
const messageOverflows = this.renderMessage(notification);
|
|
1780
|
+
this.renderSecondaryActions(notification, messageOverflows);
|
|
1781
|
+
this.renderSource(notification);
|
|
1782
|
+
this.renderButtons(notification);
|
|
1783
|
+
this.renderProgress(notification);
|
|
1784
|
+
this.inputDisposables.add(notification.onDidChangeContent(event => {
|
|
1785
|
+
switch (event.kind) {
|
|
1786
|
+
case 0 :
|
|
1787
|
+
this.renderSeverity(notification);
|
|
1788
|
+
break;
|
|
1789
|
+
case 3 :
|
|
1790
|
+
this.renderProgress(notification);
|
|
1791
|
+
break;
|
|
1792
|
+
case 1 :
|
|
1793
|
+
this.renderMessage(notification);
|
|
1794
|
+
break;
|
|
1795
|
+
}
|
|
1796
|
+
}));
|
|
1797
|
+
}
|
|
1798
|
+
renderSeverity(notification) {
|
|
1799
|
+
NotificationTemplateRenderer.SEVERITIES.forEach(severity => {
|
|
1800
|
+
if (notification.severity !== severity) {
|
|
1801
|
+
this.template.icon.classList.remove(...this.toSeverityIcon(severity).classNamesArray);
|
|
1802
|
+
}
|
|
1803
|
+
});
|
|
1804
|
+
this.template.icon.classList.add(...this.toSeverityIcon(notification.severity).classNamesArray);
|
|
1805
|
+
}
|
|
1806
|
+
renderMessage(notification) {
|
|
1807
|
+
clearNode(this.template.message);
|
|
1808
|
+
this.template.message.appendChild(NotificationMessageRenderer.render(notification.message, {
|
|
1809
|
+
callback: link => this.openerService.open(( (URI.parse(link))), { allowCommands: true }),
|
|
1810
|
+
toDispose: this.inputDisposables
|
|
1811
|
+
}));
|
|
1812
|
+
const messageOverflows = notification.canCollapse && !notification.expanded && this.template.message.scrollWidth > this.template.message.clientWidth;
|
|
1813
|
+
if (messageOverflows) {
|
|
1814
|
+
this.template.message.title = this.template.message.textContent + '';
|
|
1815
|
+
}
|
|
1816
|
+
else {
|
|
1817
|
+
this.template.message.removeAttribute('title');
|
|
1818
|
+
}
|
|
1819
|
+
const links = this.template.message.querySelectorAll('a');
|
|
1820
|
+
for (let i = 0; i < links.length; i++) {
|
|
1821
|
+
links.item(i).tabIndex = -1;
|
|
1822
|
+
}
|
|
1823
|
+
return messageOverflows;
|
|
1824
|
+
}
|
|
1825
|
+
renderSecondaryActions(notification, messageOverflows) {
|
|
1826
|
+
const actions = [];
|
|
1827
|
+
const secondaryActions = notification.actions ? notification.actions.secondary : undefined;
|
|
1828
|
+
if (isNonEmptyArray(secondaryActions)) {
|
|
1829
|
+
const configureNotificationAction = this.instantiationService.createInstance(ConfigureNotificationAction, ConfigureNotificationAction.ID, ConfigureNotificationAction.LABEL, secondaryActions);
|
|
1830
|
+
actions.push(configureNotificationAction);
|
|
1831
|
+
this.inputDisposables.add(configureNotificationAction);
|
|
1832
|
+
}
|
|
1833
|
+
let showExpandCollapseAction = false;
|
|
1834
|
+
if (notification.canCollapse) {
|
|
1835
|
+
if (notification.expanded) {
|
|
1836
|
+
showExpandCollapseAction = true;
|
|
1837
|
+
}
|
|
1838
|
+
else if (notification.source) {
|
|
1839
|
+
showExpandCollapseAction = true;
|
|
1840
|
+
}
|
|
1841
|
+
else if (messageOverflows) {
|
|
1842
|
+
showExpandCollapseAction = true;
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
if (showExpandCollapseAction) {
|
|
1846
|
+
actions.push(notification.expanded ? NotificationTemplateRenderer.collapseNotificationAction : NotificationTemplateRenderer.expandNotificationAction);
|
|
1847
|
+
}
|
|
1848
|
+
if (!notification.hasProgress) {
|
|
1849
|
+
actions.push(NotificationTemplateRenderer.closeNotificationAction);
|
|
1850
|
+
}
|
|
1851
|
+
this.template.toolbar.clear();
|
|
1852
|
+
this.template.toolbar.context = notification;
|
|
1853
|
+
actions.forEach(action => this.template.toolbar.push(action, { icon: true, label: false, keybinding: this.getKeybindingLabel(action) }));
|
|
1854
|
+
}
|
|
1855
|
+
renderSource(notification) {
|
|
1856
|
+
if (notification.expanded && notification.source) {
|
|
1857
|
+
this.template.source.textContent = ( (localize('notificationSource', "Source: {0}", notification.source)));
|
|
1858
|
+
this.template.source.title = notification.source;
|
|
1859
|
+
}
|
|
1860
|
+
else {
|
|
1861
|
+
this.template.source.textContent = '';
|
|
1862
|
+
this.template.source.removeAttribute('title');
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
renderButtons(notification) {
|
|
1866
|
+
clearNode(this.template.buttonsContainer);
|
|
1867
|
+
const primaryActions = notification.actions ? notification.actions.primary : undefined;
|
|
1868
|
+
if (notification.expanded && isNonEmptyArray(primaryActions)) {
|
|
1869
|
+
const that = this;
|
|
1870
|
+
const actionRunner = new (class extends ActionRunner {
|
|
1871
|
+
async runAction(action) {
|
|
1872
|
+
that.actionRunner.run(action, notification);
|
|
1873
|
+
if (!(action instanceof ChoiceAction) || !action.keepOpen) {
|
|
1874
|
+
notification.close();
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
})();
|
|
1878
|
+
const buttonToolbar = this.inputDisposables.add(( (new ButtonBar(this.template.buttonsContainer))));
|
|
1879
|
+
for (let i = 0; i < primaryActions.length; i++) {
|
|
1880
|
+
const action = primaryActions[i];
|
|
1881
|
+
const options = {
|
|
1882
|
+
title: true,
|
|
1883
|
+
secondary: i > 0
|
|
1884
|
+
};
|
|
1885
|
+
const dropdownActions = action instanceof ChoiceAction ? action.menu : undefined;
|
|
1886
|
+
const button = this.inputDisposables.add(dropdownActions ?
|
|
1887
|
+
buttonToolbar.addButtonWithDropdown({
|
|
1888
|
+
...options,
|
|
1889
|
+
contextMenuProvider: this.contextMenuService,
|
|
1890
|
+
actions: dropdownActions,
|
|
1891
|
+
actionRunner
|
|
1892
|
+
}) :
|
|
1893
|
+
buttonToolbar.addButton(options));
|
|
1894
|
+
button.label = action.label;
|
|
1895
|
+
this.inputDisposables.add(button.onDidClick(e => {
|
|
1896
|
+
if (e) {
|
|
1897
|
+
EventHelper.stop(e, true);
|
|
1898
|
+
}
|
|
1899
|
+
actionRunner.run(action);
|
|
1900
|
+
}));
|
|
1901
|
+
this.inputDisposables.add(attachButtonStyler(button, this.themeService));
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
renderProgress(notification) {
|
|
1906
|
+
if (!notification.hasProgress) {
|
|
1907
|
+
this.template.progress.stop().hide();
|
|
1908
|
+
return;
|
|
1909
|
+
}
|
|
1910
|
+
const state = notification.progress.state;
|
|
1911
|
+
if (state.infinite) {
|
|
1912
|
+
this.template.progress.infinite().show();
|
|
1913
|
+
}
|
|
1914
|
+
else if (typeof state.total === 'number' || typeof state.worked === 'number') {
|
|
1915
|
+
if (typeof state.total === 'number' && !this.template.progress.hasTotal()) {
|
|
1916
|
+
this.template.progress.total(state.total);
|
|
1917
|
+
}
|
|
1918
|
+
if (typeof state.worked === 'number') {
|
|
1919
|
+
this.template.progress.setWorked(state.worked).show();
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
else {
|
|
1923
|
+
this.template.progress.done().hide();
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
toSeverityIcon(severity) {
|
|
1927
|
+
switch (severity) {
|
|
1928
|
+
case Severity.Warning:
|
|
1929
|
+
return Codicon.warning;
|
|
1930
|
+
case Severity.Error:
|
|
1931
|
+
return Codicon.error;
|
|
1932
|
+
}
|
|
1933
|
+
return Codicon.info;
|
|
1934
|
+
}
|
|
1935
|
+
getKeybindingLabel(action) {
|
|
1936
|
+
const keybinding = this.keybindingService.lookupKeybinding(action.id);
|
|
1937
|
+
return keybinding ? keybinding.getLabel() : null;
|
|
1938
|
+
}
|
|
1939
|
+
};
|
|
1940
|
+
NotificationTemplateRenderer.SEVERITIES = [Severity.Info, Severity.Warning, Severity.Error];
|
|
1941
|
+
NotificationTemplateRenderer = ( (__decorate([
|
|
1942
|
+
( (__param(2, IOpenerService))),
|
|
1943
|
+
( (__param(3, IInstantiationService))),
|
|
1944
|
+
( (__param(4, IThemeService))),
|
|
1945
|
+
( (__param(5, IKeybindingService))),
|
|
1946
|
+
( (__param(6, IContextMenuService)))
|
|
1947
|
+
], NotificationTemplateRenderer)));
|
|
1948
|
+
let NotificationsList = class NotificationsList extends Themable {
|
|
1949
|
+
constructor(container, options, instantiationService, themeService, contextMenuService) {
|
|
1950
|
+
super(themeService);
|
|
1951
|
+
this.container = container;
|
|
1952
|
+
this.options = options;
|
|
1953
|
+
this.instantiationService = instantiationService;
|
|
1954
|
+
this.contextMenuService = contextMenuService;
|
|
1955
|
+
this.viewModel = [];
|
|
1956
|
+
}
|
|
1957
|
+
show(focus) {
|
|
1958
|
+
if (this.isVisible) {
|
|
1959
|
+
if (focus) {
|
|
1960
|
+
const list = assertIsDefined(this.list);
|
|
1961
|
+
list.domFocus();
|
|
1962
|
+
}
|
|
1963
|
+
return;
|
|
1964
|
+
}
|
|
1965
|
+
if (!this.list) {
|
|
1966
|
+
this.createNotificationsList();
|
|
1967
|
+
}
|
|
1968
|
+
this.isVisible = true;
|
|
1969
|
+
if (focus) {
|
|
1970
|
+
const list = assertIsDefined(this.list);
|
|
1971
|
+
list.domFocus();
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
createNotificationsList() {
|
|
1975
|
+
this.listContainer = document.createElement('div');
|
|
1976
|
+
this.listContainer.classList.add('notifications-list-container');
|
|
1977
|
+
const actionRunner = this._register(this.instantiationService.createInstance(NotificationActionRunner));
|
|
1978
|
+
const renderer = this.instantiationService.createInstance(NotificationRenderer, actionRunner);
|
|
1979
|
+
const listDelegate = this.listDelegate = ( (new NotificationsListDelegate(this.listContainer)));
|
|
1980
|
+
const options = this.options;
|
|
1981
|
+
const list = this.list = this._register(this.instantiationService.createInstance(WorkbenchList, 'NotificationsList', this.listContainer, listDelegate, [renderer], {
|
|
1982
|
+
...options,
|
|
1983
|
+
setRowLineHeight: false,
|
|
1984
|
+
horizontalScrolling: false,
|
|
1985
|
+
overrideStyles: {
|
|
1986
|
+
listBackground: NOTIFICATIONS_BACKGROUND
|
|
1987
|
+
},
|
|
1988
|
+
accessibilityProvider: {
|
|
1989
|
+
getAriaLabel(element) {
|
|
1990
|
+
if (!element.source) {
|
|
1991
|
+
return (
|
|
1992
|
+
(localize('notificationAriaLabel', "{0}, notification", element.message.raw))
|
|
1993
|
+
);
|
|
1994
|
+
}
|
|
1995
|
+
return (
|
|
1996
|
+
(localize(
|
|
1997
|
+
'notificationWithSourceAriaLabel',
|
|
1998
|
+
"{0}, source: {1}, notification",
|
|
1999
|
+
element.message.raw,
|
|
2000
|
+
element.source
|
|
2001
|
+
))
|
|
2002
|
+
);
|
|
2003
|
+
},
|
|
2004
|
+
getWidgetAriaLabel() {
|
|
2005
|
+
return options.widgetAriaLabel ?? ( (localize('notificationsList', "Notifications List")));
|
|
2006
|
+
},
|
|
2007
|
+
getRole() {
|
|
2008
|
+
return 'dialog';
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
2011
|
+
}));
|
|
2012
|
+
const copyAction = this._register(this.instantiationService.createInstance(CopyNotificationMessageAction, CopyNotificationMessageAction.ID, CopyNotificationMessageAction.LABEL));
|
|
2013
|
+
this._register((list.onContextMenu(e => {
|
|
2014
|
+
if (!e.element) {
|
|
2015
|
+
return;
|
|
2016
|
+
}
|
|
2017
|
+
this.contextMenuService.showContextMenu({
|
|
2018
|
+
getAnchor: () => e.anchor,
|
|
2019
|
+
getActions: () => [copyAction],
|
|
2020
|
+
getActionsContext: () => e.element,
|
|
2021
|
+
actionRunner
|
|
2022
|
+
});
|
|
2023
|
+
})));
|
|
2024
|
+
this._register((list.onMouseDblClick(event => event.element.toggle())));
|
|
2025
|
+
const listFocusTracker = this._register(trackFocus(list.getHTMLElement()));
|
|
2026
|
+
this._register(listFocusTracker.onDidBlur(() => {
|
|
2027
|
+
if (document.hasFocus()) {
|
|
2028
|
+
list.setFocus([]);
|
|
2029
|
+
}
|
|
2030
|
+
}));
|
|
2031
|
+
NotificationFocusedContext.bindTo(list.contextKeyService);
|
|
2032
|
+
this._register(list.onDidChangeSelection(e => {
|
|
2033
|
+
if (e.indexes.length > 0) {
|
|
2034
|
+
list.setSelection([]);
|
|
2035
|
+
}
|
|
2036
|
+
}));
|
|
2037
|
+
this.container.appendChild(this.listContainer);
|
|
2038
|
+
this.updateStyles();
|
|
2039
|
+
}
|
|
2040
|
+
updateNotificationsList(start, deleteCount, items = []) {
|
|
2041
|
+
const [list, listContainer] = assertAllDefined(this.list, this.listContainer);
|
|
2042
|
+
const listHasDOMFocus = isAncestor(document.activeElement, listContainer);
|
|
2043
|
+
const focusedIndex = list.getFocus()[0];
|
|
2044
|
+
const focusedItem = this.viewModel[focusedIndex];
|
|
2045
|
+
let focusRelativeTop = null;
|
|
2046
|
+
if (typeof focusedIndex === 'number') {
|
|
2047
|
+
focusRelativeTop = list.getRelativeTop(focusedIndex);
|
|
2048
|
+
}
|
|
2049
|
+
this.viewModel.splice(start, deleteCount, ...items);
|
|
2050
|
+
list.splice(start, deleteCount, items);
|
|
2051
|
+
list.layout();
|
|
2052
|
+
if (this.viewModel.length === 0) {
|
|
2053
|
+
this.hide();
|
|
2054
|
+
}
|
|
2055
|
+
else if (typeof focusedIndex === 'number') {
|
|
2056
|
+
let indexToFocus = 0;
|
|
2057
|
+
if (focusedItem) {
|
|
2058
|
+
let indexToFocusCandidate = this.viewModel.indexOf(focusedItem);
|
|
2059
|
+
if (indexToFocusCandidate === -1) {
|
|
2060
|
+
indexToFocusCandidate = focusedIndex - 1;
|
|
2061
|
+
}
|
|
2062
|
+
if (indexToFocusCandidate < this.viewModel.length && indexToFocusCandidate >= 0) {
|
|
2063
|
+
indexToFocus = indexToFocusCandidate;
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
if (typeof focusRelativeTop === 'number') {
|
|
2067
|
+
list.reveal(indexToFocus, focusRelativeTop);
|
|
2068
|
+
}
|
|
2069
|
+
list.setFocus([indexToFocus]);
|
|
2070
|
+
}
|
|
2071
|
+
if (this.isVisible && listHasDOMFocus) {
|
|
2072
|
+
list.domFocus();
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
updateNotificationHeight(item) {
|
|
2076
|
+
const index = this.viewModel.indexOf(item);
|
|
2077
|
+
if (index === -1) {
|
|
2078
|
+
return;
|
|
2079
|
+
}
|
|
2080
|
+
const [list, listDelegate] = assertAllDefined(this.list, this.listDelegate);
|
|
2081
|
+
list.updateElementHeight(index, listDelegate.getHeight(item));
|
|
2082
|
+
list.layout();
|
|
2083
|
+
}
|
|
2084
|
+
hide() {
|
|
2085
|
+
if (!this.isVisible || !this.list) {
|
|
2086
|
+
return;
|
|
2087
|
+
}
|
|
2088
|
+
this.isVisible = false;
|
|
2089
|
+
this.list.splice(0, this.viewModel.length);
|
|
2090
|
+
this.viewModel = [];
|
|
2091
|
+
}
|
|
2092
|
+
focusFirst() {
|
|
2093
|
+
if (!this.isVisible || !this.list) {
|
|
2094
|
+
return;
|
|
2095
|
+
}
|
|
2096
|
+
this.list.focusFirst();
|
|
2097
|
+
this.list.domFocus();
|
|
2098
|
+
}
|
|
2099
|
+
hasFocus() {
|
|
2100
|
+
if (!this.isVisible || !this.listContainer) {
|
|
2101
|
+
return false;
|
|
2102
|
+
}
|
|
2103
|
+
return isAncestor(document.activeElement, this.listContainer);
|
|
2104
|
+
}
|
|
2105
|
+
updateStyles() {
|
|
2106
|
+
if (this.listContainer) {
|
|
2107
|
+
const foreground = this.getColor(NOTIFICATIONS_FOREGROUND);
|
|
2108
|
+
this.listContainer.style.color = foreground ? foreground : '';
|
|
2109
|
+
const background = this.getColor(NOTIFICATIONS_BACKGROUND);
|
|
2110
|
+
this.listContainer.style.background = background ? background : '';
|
|
2111
|
+
const outlineColor = this.getColor(contrastBorder);
|
|
2112
|
+
this.listContainer.style.outlineColor = outlineColor ? outlineColor : '';
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
layout(width, maxHeight) {
|
|
2116
|
+
if (this.listContainer && this.list) {
|
|
2117
|
+
this.listContainer.style.width = `${width}px`;
|
|
2118
|
+
if (typeof maxHeight === 'number') {
|
|
2119
|
+
this.list.getHTMLElement().style.maxHeight = `${maxHeight}px`;
|
|
2120
|
+
}
|
|
2121
|
+
this.list.layout();
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
dispose() {
|
|
2125
|
+
this.hide();
|
|
2126
|
+
super.dispose();
|
|
2127
|
+
}
|
|
2128
|
+
};
|
|
2129
|
+
NotificationsList = ( (__decorate([
|
|
2130
|
+
( (__param(2, IInstantiationService))),
|
|
2131
|
+
( (__param(3, IThemeService))),
|
|
2132
|
+
( (__param(4, IContextMenuService)))
|
|
2133
|
+
], NotificationsList)));
|
|
2134
|
+
registerThemingParticipant((theme, collector) => {
|
|
2135
|
+
const linkColor = theme.getColor(NOTIFICATIONS_LINKS);
|
|
2136
|
+
if (linkColor) {
|
|
2137
|
+
collector.addRule(`.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-message a { color: ${linkColor}; }`);
|
|
2138
|
+
}
|
|
2139
|
+
const focusOutline = theme.getColor(focusBorder);
|
|
2140
|
+
if (focusOutline) {
|
|
2141
|
+
collector.addRule(`
|
|
2142
|
+
.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-message a:focus {
|
|
2143
|
+
outline-color: ${focusOutline};
|
|
2144
|
+
}`);
|
|
2145
|
+
}
|
|
2146
|
+
const notificationErrorIconForegroundColor = theme.getColor(NOTIFICATIONS_ERROR_ICON_FOREGROUND);
|
|
2147
|
+
if (notificationErrorIconForegroundColor) {
|
|
2148
|
+
collector.addRule(`
|
|
2149
|
+
.monaco-workbench .notifications-center ${Codicon.error.cssSelector},
|
|
2150
|
+
.monaco-workbench .notifications-toasts ${Codicon.error.cssSelector} {
|
|
2151
|
+
color: ${notificationErrorIconForegroundColor};
|
|
2152
|
+
}`);
|
|
2153
|
+
}
|
|
2154
|
+
const notificationWarningIconForegroundColor = theme.getColor(NOTIFICATIONS_WARNING_ICON_FOREGROUND);
|
|
2155
|
+
if (notificationWarningIconForegroundColor) {
|
|
2156
|
+
collector.addRule(`
|
|
2157
|
+
.monaco-workbench .notifications-center ${Codicon.warning.cssSelector},
|
|
2158
|
+
.monaco-workbench .notifications-toasts ${Codicon.warning.cssSelector} {
|
|
2159
|
+
color: ${notificationWarningIconForegroundColor};
|
|
2160
|
+
}`);
|
|
2161
|
+
}
|
|
2162
|
+
const notificationInfoIconForegroundColor = theme.getColor(NOTIFICATIONS_INFO_ICON_FOREGROUND);
|
|
2163
|
+
if (notificationInfoIconForegroundColor) {
|
|
2164
|
+
collector.addRule(`
|
|
2165
|
+
.monaco-workbench .notifications-center ${Codicon.info.cssSelector},
|
|
2166
|
+
.monaco-workbench .notifications-toasts ${Codicon.info.cssSelector} {
|
|
2167
|
+
color: ${notificationInfoIconForegroundColor};
|
|
2168
|
+
}`);
|
|
2169
|
+
}
|
|
2170
|
+
});
|
|
2171
|
+
var ToastVisibility;
|
|
2172
|
+
( ((function(ToastVisibility) {
|
|
2173
|
+
ToastVisibility[ToastVisibility["HIDDEN_OR_VISIBLE"] = 0] = "HIDDEN_OR_VISIBLE";
|
|
2174
|
+
ToastVisibility[ToastVisibility["HIDDEN"] = 1] = "HIDDEN";
|
|
2175
|
+
ToastVisibility[ToastVisibility["VISIBLE"] = 2] = "VISIBLE";
|
|
2176
|
+
})(ToastVisibility || (ToastVisibility = {}))));
|
|
2177
|
+
let NotificationsToasts = class NotificationsToasts extends Themable {
|
|
2178
|
+
constructor(container, model, instantiationService, layoutService, themeService, editorGroupService, contextKeyService, lifecycleService, hostService) {
|
|
2179
|
+
super(themeService);
|
|
2180
|
+
this.container = container;
|
|
2181
|
+
this.model = model;
|
|
2182
|
+
this.instantiationService = instantiationService;
|
|
2183
|
+
this.layoutService = layoutService;
|
|
2184
|
+
this.editorGroupService = editorGroupService;
|
|
2185
|
+
this.contextKeyService = contextKeyService;
|
|
2186
|
+
this.lifecycleService = lifecycleService;
|
|
2187
|
+
this.hostService = hostService;
|
|
2188
|
+
this._onDidChangeVisibility = this._register(( (new Emitter())));
|
|
2189
|
+
this.onDidChangeVisibility = this._onDidChangeVisibility.event;
|
|
2190
|
+
this._isVisible = false;
|
|
2191
|
+
this.mapNotificationToToast = ( (new Map()));
|
|
2192
|
+
this.mapNotificationToDisposable = ( (new Map()));
|
|
2193
|
+
this.notificationsToastsVisibleContextKey = NotificationsToastsVisibleContext.bindTo(this.contextKeyService);
|
|
2194
|
+
this.addedToastsIntervalCounter = ( (new IntervalCounter(NotificationsToasts.SPAM_PROTECTION.interval)));
|
|
2195
|
+
this.registerListeners();
|
|
2196
|
+
}
|
|
2197
|
+
get isVisible() { return !!this._isVisible; }
|
|
2198
|
+
registerListeners() {
|
|
2199
|
+
this._register(this.layoutService.onDidLayout(dimension => this.layout(Dimension.lift(dimension))));
|
|
2200
|
+
this.lifecycleService.when(3 ).then(() => {
|
|
2201
|
+
this.model.notifications.forEach(notification => this.addToast(notification));
|
|
2202
|
+
this._register(this.model.onDidChangeNotification(e => this.onDidChangeNotification(e)));
|
|
2203
|
+
});
|
|
2204
|
+
this._register(this.model.onDidChangeFilter(filter => {
|
|
2205
|
+
if (filter === NotificationsFilter.SILENT || filter === NotificationsFilter.ERROR) {
|
|
2206
|
+
this.hide();
|
|
2207
|
+
}
|
|
2208
|
+
}));
|
|
2209
|
+
}
|
|
2210
|
+
onDidChangeNotification(e) {
|
|
2211
|
+
switch (e.kind) {
|
|
2212
|
+
case 0 :
|
|
2213
|
+
return this.addToast(e.item);
|
|
2214
|
+
case 3 :
|
|
2215
|
+
return this.removeToast(e.item);
|
|
2216
|
+
}
|
|
2217
|
+
}
|
|
2218
|
+
addToast(item) {
|
|
2219
|
+
if (this.isNotificationsCenterVisible) {
|
|
2220
|
+
return;
|
|
2221
|
+
}
|
|
2222
|
+
if (item.silent) {
|
|
2223
|
+
return;
|
|
2224
|
+
}
|
|
2225
|
+
if (this.addedToastsIntervalCounter.increment() > NotificationsToasts.SPAM_PROTECTION.limit) {
|
|
2226
|
+
return;
|
|
2227
|
+
}
|
|
2228
|
+
const itemDisposables = ( (new DisposableStore()));
|
|
2229
|
+
this.mapNotificationToDisposable.set(item, itemDisposables);
|
|
2230
|
+
itemDisposables.add(scheduleAtNextAnimationFrame(() => this.doAddToast(item, itemDisposables)));
|
|
2231
|
+
}
|
|
2232
|
+
doAddToast(item, itemDisposables) {
|
|
2233
|
+
let notificationsToastsContainer = this.notificationsToastsContainer;
|
|
2234
|
+
if (!notificationsToastsContainer) {
|
|
2235
|
+
notificationsToastsContainer = this.notificationsToastsContainer = document.createElement('div');
|
|
2236
|
+
notificationsToastsContainer.classList.add('notifications-toasts');
|
|
2237
|
+
this.container.appendChild(notificationsToastsContainer);
|
|
2238
|
+
}
|
|
2239
|
+
notificationsToastsContainer.classList.add('visible');
|
|
2240
|
+
const notificationToastContainer = document.createElement('div');
|
|
2241
|
+
notificationToastContainer.classList.add('notification-toast-container');
|
|
2242
|
+
const firstToast = notificationsToastsContainer.firstChild;
|
|
2243
|
+
if (firstToast) {
|
|
2244
|
+
notificationsToastsContainer.insertBefore(notificationToastContainer, firstToast);
|
|
2245
|
+
}
|
|
2246
|
+
else {
|
|
2247
|
+
notificationsToastsContainer.appendChild(notificationToastContainer);
|
|
2248
|
+
}
|
|
2249
|
+
const notificationToast = document.createElement('div');
|
|
2250
|
+
notificationToast.classList.add('notification-toast');
|
|
2251
|
+
notificationToastContainer.appendChild(notificationToast);
|
|
2252
|
+
const notificationList = this.instantiationService.createInstance(NotificationsList, notificationToast, {
|
|
2253
|
+
verticalScrollMode: 2 ,
|
|
2254
|
+
widgetAriaLabel: (() => {
|
|
2255
|
+
if (!item.source) {
|
|
2256
|
+
return (
|
|
2257
|
+
(localize('notificationAriaLabel', "{0}, notification", item.message.raw))
|
|
2258
|
+
);
|
|
2259
|
+
}
|
|
2260
|
+
return (
|
|
2261
|
+
(localize(
|
|
2262
|
+
'notificationWithSourceAriaLabel',
|
|
2263
|
+
"{0}, source: {1}, notification",
|
|
2264
|
+
item.message.raw,
|
|
2265
|
+
item.source
|
|
2266
|
+
))
|
|
2267
|
+
);
|
|
2268
|
+
})()
|
|
2269
|
+
});
|
|
2270
|
+
itemDisposables.add(notificationList);
|
|
2271
|
+
const toast = { item, list: notificationList, container: notificationToastContainer, toast: notificationToast };
|
|
2272
|
+
this.mapNotificationToToast.set(item, toast);
|
|
2273
|
+
itemDisposables.add(toDisposable(() => this.updateToastVisibility(toast, false)));
|
|
2274
|
+
notificationList.show();
|
|
2275
|
+
const maxDimensions = this.computeMaxDimensions();
|
|
2276
|
+
this.layoutLists(maxDimensions.width);
|
|
2277
|
+
notificationList.updateNotificationsList(0, 0, [item]);
|
|
2278
|
+
this.layoutContainer(maxDimensions.height);
|
|
2279
|
+
itemDisposables.add(item.onDidChangeExpansion(() => {
|
|
2280
|
+
notificationList.updateNotificationsList(0, 1, [item]);
|
|
2281
|
+
}));
|
|
2282
|
+
itemDisposables.add(item.onDidChangeContent(e => {
|
|
2283
|
+
switch (e.kind) {
|
|
2284
|
+
case 2 :
|
|
2285
|
+
notificationList.updateNotificationsList(0, 1, [item]);
|
|
2286
|
+
break;
|
|
2287
|
+
case 1 :
|
|
2288
|
+
if (item.expanded) {
|
|
2289
|
+
notificationList.updateNotificationHeight(item);
|
|
2290
|
+
}
|
|
2291
|
+
break;
|
|
2292
|
+
}
|
|
2293
|
+
}));
|
|
2294
|
+
Event.once(item.onDidClose)(() => {
|
|
2295
|
+
this.removeToast(item);
|
|
2296
|
+
});
|
|
2297
|
+
this.purgeNotification(item, notificationToastContainer, notificationList, itemDisposables);
|
|
2298
|
+
this.updateStyles();
|
|
2299
|
+
this.notificationsToastsVisibleContextKey.set(true);
|
|
2300
|
+
notificationToast.classList.add('notification-fade-in');
|
|
2301
|
+
itemDisposables.add(addDisposableListener(notificationToast, 'transitionend', () => {
|
|
2302
|
+
notificationToast.classList.remove('notification-fade-in');
|
|
2303
|
+
notificationToast.classList.add('notification-fade-in-done');
|
|
2304
|
+
}));
|
|
2305
|
+
item.updateVisibility(true);
|
|
2306
|
+
if (!this._isVisible) {
|
|
2307
|
+
this._isVisible = true;
|
|
2308
|
+
this._onDidChangeVisibility.fire();
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
purgeNotification(item, notificationToastContainer, notificationList, disposables) {
|
|
2312
|
+
let isMouseOverToast = false;
|
|
2313
|
+
disposables.add(addDisposableListener(notificationToastContainer, EventType.MOUSE_OVER, () => isMouseOverToast = true));
|
|
2314
|
+
disposables.add(addDisposableListener(notificationToastContainer, EventType.MOUSE_OUT, () => isMouseOverToast = false));
|
|
2315
|
+
let purgeTimeoutHandle;
|
|
2316
|
+
let listener;
|
|
2317
|
+
const hideAfterTimeout = () => {
|
|
2318
|
+
purgeTimeoutHandle = setTimeout(() => {
|
|
2319
|
+
if (!this.hostService.hasFocus) {
|
|
2320
|
+
if (!listener) {
|
|
2321
|
+
listener = this.hostService.onDidChangeFocus(focus => {
|
|
2322
|
+
if (focus) {
|
|
2323
|
+
hideAfterTimeout();
|
|
2324
|
+
}
|
|
2325
|
+
});
|
|
2326
|
+
disposables.add(listener);
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
else if (item.sticky ||
|
|
2330
|
+
notificationList.hasFocus() ||
|
|
2331
|
+
isMouseOverToast
|
|
2332
|
+
) {
|
|
2333
|
+
hideAfterTimeout();
|
|
2334
|
+
}
|
|
2335
|
+
else {
|
|
2336
|
+
this.removeToast(item);
|
|
2337
|
+
}
|
|
2338
|
+
}, NotificationsToasts.PURGE_TIMEOUT[item.severity]);
|
|
2339
|
+
};
|
|
2340
|
+
hideAfterTimeout();
|
|
2341
|
+
disposables.add(toDisposable(() => clearTimeout(purgeTimeoutHandle)));
|
|
2342
|
+
}
|
|
2343
|
+
removeToast(item) {
|
|
2344
|
+
let focusEditor = false;
|
|
2345
|
+
const notificationToast = this.mapNotificationToToast.get(item);
|
|
2346
|
+
if (notificationToast) {
|
|
2347
|
+
const toastHasDOMFocus = isAncestor(document.activeElement, notificationToast.container);
|
|
2348
|
+
if (toastHasDOMFocus) {
|
|
2349
|
+
focusEditor = !(this.focusNext() || this.focusPrevious());
|
|
2350
|
+
}
|
|
2351
|
+
this.mapNotificationToToast.delete(item);
|
|
2352
|
+
}
|
|
2353
|
+
const notificationDisposables = this.mapNotificationToDisposable.get(item);
|
|
2354
|
+
if (notificationDisposables) {
|
|
2355
|
+
dispose(notificationDisposables);
|
|
2356
|
+
this.mapNotificationToDisposable.delete(item);
|
|
2357
|
+
}
|
|
2358
|
+
if (this.mapNotificationToToast.size > 0) {
|
|
2359
|
+
this.layout(this.workbenchDimensions);
|
|
2360
|
+
}
|
|
2361
|
+
else {
|
|
2362
|
+
this.doHide();
|
|
2363
|
+
if (focusEditor) {
|
|
2364
|
+
this.editorGroupService.activeGroup.focus();
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
removeToasts() {
|
|
2369
|
+
this.mapNotificationToToast.clear();
|
|
2370
|
+
this.mapNotificationToDisposable.forEach(disposable => dispose(disposable));
|
|
2371
|
+
this.mapNotificationToDisposable.clear();
|
|
2372
|
+
this.doHide();
|
|
2373
|
+
}
|
|
2374
|
+
doHide() {
|
|
2375
|
+
this.notificationsToastsContainer?.classList.remove('visible');
|
|
2376
|
+
this.notificationsToastsVisibleContextKey.set(false);
|
|
2377
|
+
if (this._isVisible) {
|
|
2378
|
+
this._isVisible = false;
|
|
2379
|
+
this._onDidChangeVisibility.fire();
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
hide() {
|
|
2383
|
+
const focusEditor = this.notificationsToastsContainer ? isAncestor(document.activeElement, this.notificationsToastsContainer) : false;
|
|
2384
|
+
this.removeToasts();
|
|
2385
|
+
if (focusEditor) {
|
|
2386
|
+
this.editorGroupService.activeGroup.focus();
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2389
|
+
focus() {
|
|
2390
|
+
const toasts = this.getToasts(ToastVisibility.VISIBLE);
|
|
2391
|
+
if (toasts.length > 0) {
|
|
2392
|
+
toasts[0].list.focusFirst();
|
|
2393
|
+
return true;
|
|
2394
|
+
}
|
|
2395
|
+
return false;
|
|
2396
|
+
}
|
|
2397
|
+
focusNext() {
|
|
2398
|
+
const toasts = this.getToasts(ToastVisibility.VISIBLE);
|
|
2399
|
+
for (let i = 0; i < toasts.length; i++) {
|
|
2400
|
+
const toast = toasts[i];
|
|
2401
|
+
if (toast.list.hasFocus()) {
|
|
2402
|
+
const nextToast = toasts[i + 1];
|
|
2403
|
+
if (nextToast) {
|
|
2404
|
+
nextToast.list.focusFirst();
|
|
2405
|
+
return true;
|
|
2406
|
+
}
|
|
2407
|
+
break;
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2410
|
+
return false;
|
|
2411
|
+
}
|
|
2412
|
+
focusPrevious() {
|
|
2413
|
+
const toasts = this.getToasts(ToastVisibility.VISIBLE);
|
|
2414
|
+
for (let i = 0; i < toasts.length; i++) {
|
|
2415
|
+
const toast = toasts[i];
|
|
2416
|
+
if (toast.list.hasFocus()) {
|
|
2417
|
+
const previousToast = toasts[i - 1];
|
|
2418
|
+
if (previousToast) {
|
|
2419
|
+
previousToast.list.focusFirst();
|
|
2420
|
+
return true;
|
|
2421
|
+
}
|
|
2422
|
+
break;
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
return false;
|
|
2426
|
+
}
|
|
2427
|
+
focusFirst() {
|
|
2428
|
+
const toast = this.getToasts(ToastVisibility.VISIBLE)[0];
|
|
2429
|
+
if (toast) {
|
|
2430
|
+
toast.list.focusFirst();
|
|
2431
|
+
return true;
|
|
2432
|
+
}
|
|
2433
|
+
return false;
|
|
2434
|
+
}
|
|
2435
|
+
focusLast() {
|
|
2436
|
+
const toasts = this.getToasts(ToastVisibility.VISIBLE);
|
|
2437
|
+
if (toasts.length > 0) {
|
|
2438
|
+
toasts[toasts.length - 1].list.focusFirst();
|
|
2439
|
+
return true;
|
|
2440
|
+
}
|
|
2441
|
+
return false;
|
|
2442
|
+
}
|
|
2443
|
+
update(isCenterVisible) {
|
|
2444
|
+
if (this.isNotificationsCenterVisible !== isCenterVisible) {
|
|
2445
|
+
this.isNotificationsCenterVisible = isCenterVisible;
|
|
2446
|
+
if (this.isNotificationsCenterVisible) {
|
|
2447
|
+
this.removeToasts();
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
updateStyles() {
|
|
2452
|
+
this.mapNotificationToToast.forEach(({ toast }) => {
|
|
2453
|
+
const backgroundColor = this.getColor(NOTIFICATIONS_BACKGROUND);
|
|
2454
|
+
toast.style.background = backgroundColor ? backgroundColor : '';
|
|
2455
|
+
const widgetShadowColor = this.getColor(widgetShadow);
|
|
2456
|
+
toast.style.boxShadow = widgetShadowColor ? `0 0 8px 2px ${widgetShadowColor}` : '';
|
|
2457
|
+
const borderColor = this.getColor(NOTIFICATIONS_TOAST_BORDER);
|
|
2458
|
+
toast.style.border = borderColor ? `1px solid ${borderColor}` : '';
|
|
2459
|
+
});
|
|
2460
|
+
}
|
|
2461
|
+
getToasts(state) {
|
|
2462
|
+
const notificationToasts = [];
|
|
2463
|
+
this.mapNotificationToToast.forEach(toast => {
|
|
2464
|
+
switch (state) {
|
|
2465
|
+
case ToastVisibility.HIDDEN_OR_VISIBLE:
|
|
2466
|
+
notificationToasts.push(toast);
|
|
2467
|
+
break;
|
|
2468
|
+
case ToastVisibility.HIDDEN:
|
|
2469
|
+
if (!this.isToastInDOM(toast)) {
|
|
2470
|
+
notificationToasts.push(toast);
|
|
2471
|
+
}
|
|
2472
|
+
break;
|
|
2473
|
+
case ToastVisibility.VISIBLE:
|
|
2474
|
+
if (this.isToastInDOM(toast)) {
|
|
2475
|
+
notificationToasts.push(toast);
|
|
2476
|
+
}
|
|
2477
|
+
break;
|
|
2478
|
+
}
|
|
2479
|
+
});
|
|
2480
|
+
return notificationToasts.reverse();
|
|
2481
|
+
}
|
|
2482
|
+
layout(dimension) {
|
|
2483
|
+
this.workbenchDimensions = dimension;
|
|
2484
|
+
const maxDimensions = this.computeMaxDimensions();
|
|
2485
|
+
if (maxDimensions.height) {
|
|
2486
|
+
this.layoutContainer(maxDimensions.height);
|
|
2487
|
+
}
|
|
2488
|
+
this.layoutLists(maxDimensions.width);
|
|
2489
|
+
}
|
|
2490
|
+
computeMaxDimensions() {
|
|
2491
|
+
const maxWidth = NotificationsToasts.MAX_WIDTH;
|
|
2492
|
+
let availableWidth = maxWidth;
|
|
2493
|
+
let availableHeight;
|
|
2494
|
+
if (this.workbenchDimensions) {
|
|
2495
|
+
availableWidth = this.workbenchDimensions.width;
|
|
2496
|
+
availableWidth -= (2 * 8);
|
|
2497
|
+
availableHeight = this.workbenchDimensions.height;
|
|
2498
|
+
if (this.layoutService.isVisible("workbench.parts.statusbar" )) {
|
|
2499
|
+
availableHeight -= 22;
|
|
2500
|
+
}
|
|
2501
|
+
if (this.layoutService.isVisible("workbench.parts.titlebar" )) {
|
|
2502
|
+
availableHeight -= 22;
|
|
2503
|
+
}
|
|
2504
|
+
availableHeight -= (2 * 12);
|
|
2505
|
+
}
|
|
2506
|
+
availableHeight = typeof availableHeight === 'number'
|
|
2507
|
+
? Math.round(availableHeight * 0.618)
|
|
2508
|
+
: 0;
|
|
2509
|
+
return (
|
|
2510
|
+
(new Dimension(Math.min(maxWidth, availableWidth), availableHeight))
|
|
2511
|
+
);
|
|
2512
|
+
}
|
|
2513
|
+
layoutLists(width) {
|
|
2514
|
+
this.mapNotificationToToast.forEach(({ list }) => list.layout(width));
|
|
2515
|
+
}
|
|
2516
|
+
layoutContainer(heightToGive) {
|
|
2517
|
+
let visibleToasts = 0;
|
|
2518
|
+
for (const toast of this.getToasts(ToastVisibility.HIDDEN_OR_VISIBLE)) {
|
|
2519
|
+
toast.container.style.opacity = '0';
|
|
2520
|
+
this.updateToastVisibility(toast, true);
|
|
2521
|
+
heightToGive -= toast.container.offsetHeight;
|
|
2522
|
+
let makeVisible = false;
|
|
2523
|
+
if (visibleToasts === NotificationsToasts.MAX_NOTIFICATIONS) {
|
|
2524
|
+
makeVisible = false;
|
|
2525
|
+
}
|
|
2526
|
+
else if (heightToGive >= 0) {
|
|
2527
|
+
makeVisible = true;
|
|
2528
|
+
}
|
|
2529
|
+
this.updateToastVisibility(toast, makeVisible);
|
|
2530
|
+
toast.container.style.opacity = '';
|
|
2531
|
+
if (makeVisible) {
|
|
2532
|
+
visibleToasts++;
|
|
2533
|
+
}
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
updateToastVisibility(toast, visible) {
|
|
2537
|
+
if (this.isToastInDOM(toast) === visible) {
|
|
2538
|
+
return;
|
|
2539
|
+
}
|
|
2540
|
+
const notificationsToastsContainer = assertIsDefined(this.notificationsToastsContainer);
|
|
2541
|
+
if (visible) {
|
|
2542
|
+
notificationsToastsContainer.appendChild(toast.container);
|
|
2543
|
+
}
|
|
2544
|
+
else {
|
|
2545
|
+
notificationsToastsContainer.removeChild(toast.container);
|
|
2546
|
+
}
|
|
2547
|
+
toast.item.updateVisibility(visible);
|
|
2548
|
+
}
|
|
2549
|
+
isToastInDOM(toast) {
|
|
2550
|
+
return !!toast.container.parentElement;
|
|
2551
|
+
}
|
|
2552
|
+
};
|
|
2553
|
+
NotificationsToasts.MAX_WIDTH = 450;
|
|
2554
|
+
NotificationsToasts.MAX_NOTIFICATIONS = 3;
|
|
2555
|
+
NotificationsToasts.PURGE_TIMEOUT = {
|
|
2556
|
+
[Severity.Info]: 15000,
|
|
2557
|
+
[Severity.Warning]: 18000,
|
|
2558
|
+
[Severity.Error]: 20000
|
|
2559
|
+
};
|
|
2560
|
+
NotificationsToasts.SPAM_PROTECTION = {
|
|
2561
|
+
interval: 800,
|
|
2562
|
+
limit: NotificationsToasts.MAX_NOTIFICATIONS
|
|
2563
|
+
};
|
|
2564
|
+
NotificationsToasts = ( (__decorate([
|
|
2565
|
+
( (__param(2, IInstantiationService))),
|
|
2566
|
+
( (__param(3, IWorkbenchLayoutService))),
|
|
2567
|
+
( (__param(4, IThemeService))),
|
|
2568
|
+
( (__param(5, IEditorGroupsService))),
|
|
2569
|
+
( (__param(6, IContextKeyService))),
|
|
2570
|
+
( (__param(7, ILifecycleService))),
|
|
2571
|
+
( (__param(8, IHostService)))
|
|
2572
|
+
], NotificationsToasts)));
|
|
2573
|
+
let NotificationService = class NotificationService extends Disposable {
|
|
2574
|
+
constructor(storageService) {
|
|
2575
|
+
super();
|
|
2576
|
+
this.storageService = storageService;
|
|
2577
|
+
this.model = this._register(( (new NotificationsModel())));
|
|
2578
|
+
this._onDidAddNotification = this._register(( (new Emitter())));
|
|
2579
|
+
this.onDidAddNotification = this._onDidAddNotification.event;
|
|
2580
|
+
this._onDidRemoveNotification = this._register(( (new Emitter())));
|
|
2581
|
+
this.onDidRemoveNotification = this._onDidRemoveNotification.event;
|
|
2582
|
+
this._onDidChangeDoNotDisturbMode = this._register(( (new Emitter())));
|
|
2583
|
+
this.onDidChangeDoNotDisturbMode = this._onDidChangeDoNotDisturbMode.event;
|
|
2584
|
+
this._doNotDisturbMode = this.storageService.getBoolean(NotificationService.DND_SETTINGS_KEY, -1 , false);
|
|
2585
|
+
this.updateDoNotDisturbFilters();
|
|
2586
|
+
this.registerListeners();
|
|
2587
|
+
}
|
|
2588
|
+
registerListeners() {
|
|
2589
|
+
this._register(this.model.onDidChangeNotification(e => {
|
|
2590
|
+
switch (e.kind) {
|
|
2591
|
+
case 0 :
|
|
2592
|
+
case 3 : {
|
|
2593
|
+
const notification = {
|
|
2594
|
+
message: e.item.message.original,
|
|
2595
|
+
severity: e.item.severity,
|
|
2596
|
+
source: typeof e.item.sourceId === 'string' && typeof e.item.source === 'string' ? { id: e.item.sourceId, label: e.item.source } : e.item.source,
|
|
2597
|
+
silent: e.item.silent
|
|
2598
|
+
};
|
|
2599
|
+
if (e.kind === 0 ) {
|
|
2600
|
+
this._onDidAddNotification.fire(notification);
|
|
2601
|
+
}
|
|
2602
|
+
if (e.kind === 3 ) {
|
|
2603
|
+
this._onDidRemoveNotification.fire(notification);
|
|
2604
|
+
}
|
|
2605
|
+
break;
|
|
2606
|
+
}
|
|
2607
|
+
}
|
|
2608
|
+
}));
|
|
2609
|
+
}
|
|
2610
|
+
get doNotDisturbMode() {
|
|
2611
|
+
return this._doNotDisturbMode;
|
|
2612
|
+
}
|
|
2613
|
+
set doNotDisturbMode(enabled) {
|
|
2614
|
+
if (this._doNotDisturbMode === enabled) {
|
|
2615
|
+
return;
|
|
2616
|
+
}
|
|
2617
|
+
this.storageService.store(NotificationService.DND_SETTINGS_KEY, enabled, -1 , 1 );
|
|
2618
|
+
this._doNotDisturbMode = enabled;
|
|
2619
|
+
this.updateDoNotDisturbFilters();
|
|
2620
|
+
this._onDidChangeDoNotDisturbMode.fire();
|
|
2621
|
+
}
|
|
2622
|
+
updateDoNotDisturbFilters() {
|
|
2623
|
+
let filter;
|
|
2624
|
+
if (this._doNotDisturbMode) {
|
|
2625
|
+
filter = NotificationsFilter.ERROR;
|
|
2626
|
+
}
|
|
2627
|
+
else {
|
|
2628
|
+
filter = NotificationsFilter.OFF;
|
|
2629
|
+
}
|
|
2630
|
+
this.model.setFilter(filter);
|
|
2631
|
+
}
|
|
2632
|
+
info(message) {
|
|
2633
|
+
if (Array.isArray(message)) {
|
|
2634
|
+
message.forEach(m => this.info(m));
|
|
2635
|
+
return;
|
|
2636
|
+
}
|
|
2637
|
+
this.model.addNotification({ severity: Severity.Info, message });
|
|
2638
|
+
}
|
|
2639
|
+
warn(message) {
|
|
2640
|
+
if (Array.isArray(message)) {
|
|
2641
|
+
message.forEach(m => this.warn(m));
|
|
2642
|
+
return;
|
|
2643
|
+
}
|
|
2644
|
+
this.model.addNotification({ severity: Severity.Warning, message });
|
|
2645
|
+
}
|
|
2646
|
+
error(message) {
|
|
2647
|
+
if (Array.isArray(message)) {
|
|
2648
|
+
message.forEach(m => this.error(m));
|
|
2649
|
+
return;
|
|
2650
|
+
}
|
|
2651
|
+
this.model.addNotification({ severity: Severity.Error, message });
|
|
2652
|
+
}
|
|
2653
|
+
notify(notification) {
|
|
2654
|
+
const toDispose = ( (new DisposableStore()));
|
|
2655
|
+
if (notification.neverShowAgain) {
|
|
2656
|
+
const scope = this.toStorageScope(notification.neverShowAgain);
|
|
2657
|
+
const id = notification.neverShowAgain.id;
|
|
2658
|
+
if (this.storageService.getBoolean(id, scope)) {
|
|
2659
|
+
return (
|
|
2660
|
+
(new NoOpNotification())
|
|
2661
|
+
);
|
|
2662
|
+
}
|
|
2663
|
+
const neverShowAgainAction = toDispose.add(( (new Action(
|
|
2664
|
+
'workbench.notification.neverShowAgain',
|
|
2665
|
+
(localize('neverShowAgain', "Don't Show Again")),
|
|
2666
|
+
undefined,
|
|
2667
|
+
true,
|
|
2668
|
+
async () => {
|
|
2669
|
+
handle.close();
|
|
2670
|
+
this.storageService.store(id, true, scope, 0 );
|
|
2671
|
+
}
|
|
2672
|
+
))));
|
|
2673
|
+
const actions = {
|
|
2674
|
+
primary: notification.actions?.primary || [],
|
|
2675
|
+
secondary: notification.actions?.secondary || []
|
|
2676
|
+
};
|
|
2677
|
+
if (!notification.neverShowAgain.isSecondary) {
|
|
2678
|
+
actions.primary = [neverShowAgainAction, ...actions.primary];
|
|
2679
|
+
}
|
|
2680
|
+
else {
|
|
2681
|
+
actions.secondary = [...actions.secondary, neverShowAgainAction];
|
|
2682
|
+
}
|
|
2683
|
+
notification.actions = actions;
|
|
2684
|
+
}
|
|
2685
|
+
const handle = this.model.addNotification(notification);
|
|
2686
|
+
Event.once(handle.onDidClose)(() => toDispose.dispose());
|
|
2687
|
+
return handle;
|
|
2688
|
+
}
|
|
2689
|
+
toStorageScope(options) {
|
|
2690
|
+
switch (options.scope) {
|
|
2691
|
+
case NeverShowAgainScope.APPLICATION:
|
|
2692
|
+
return -1 ;
|
|
2693
|
+
case NeverShowAgainScope.PROFILE:
|
|
2694
|
+
return 0 ;
|
|
2695
|
+
case NeverShowAgainScope.WORKSPACE:
|
|
2696
|
+
return 1 ;
|
|
2697
|
+
default:
|
|
2698
|
+
return -1 ;
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2701
|
+
prompt(severity, message, choices, options) {
|
|
2702
|
+
const toDispose = ( (new DisposableStore()));
|
|
2703
|
+
if (options?.neverShowAgain) {
|
|
2704
|
+
const scope = this.toStorageScope(options.neverShowAgain);
|
|
2705
|
+
const id = options.neverShowAgain.id;
|
|
2706
|
+
if (this.storageService.getBoolean(id, scope)) {
|
|
2707
|
+
return (
|
|
2708
|
+
(new NoOpNotification())
|
|
2709
|
+
);
|
|
2710
|
+
}
|
|
2711
|
+
const neverShowAgainChoice = {
|
|
2712
|
+
label: ( (localize('neverShowAgain', "Don't Show Again"))),
|
|
2713
|
+
run: () => this.storageService.store(id, true, scope, 0 ),
|
|
2714
|
+
isSecondary: options.neverShowAgain.isSecondary
|
|
2715
|
+
};
|
|
2716
|
+
if (!options.neverShowAgain.isSecondary) {
|
|
2717
|
+
choices = [neverShowAgainChoice, ...choices];
|
|
2718
|
+
}
|
|
2719
|
+
else {
|
|
2720
|
+
choices = [...choices, neverShowAgainChoice];
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
let choiceClicked = false;
|
|
2724
|
+
const primaryActions = [];
|
|
2725
|
+
const secondaryActions = [];
|
|
2726
|
+
choices.forEach((choice, index) => {
|
|
2727
|
+
const action = ( (new ChoiceAction(`workbench.dialog.choice.${index}`, choice)));
|
|
2728
|
+
if (!choice.isSecondary) {
|
|
2729
|
+
primaryActions.push(action);
|
|
2730
|
+
}
|
|
2731
|
+
else {
|
|
2732
|
+
secondaryActions.push(action);
|
|
2733
|
+
}
|
|
2734
|
+
toDispose.add(action.onDidRun(() => {
|
|
2735
|
+
choiceClicked = true;
|
|
2736
|
+
if (!choice.keepOpen) {
|
|
2737
|
+
handle.close();
|
|
2738
|
+
}
|
|
2739
|
+
}));
|
|
2740
|
+
toDispose.add(action);
|
|
2741
|
+
});
|
|
2742
|
+
const actions = { primary: primaryActions, secondary: secondaryActions };
|
|
2743
|
+
const handle = this.notify({ severity, message, actions, sticky: options?.sticky, silent: options?.silent });
|
|
2744
|
+
Event.once(handle.onDidClose)(() => {
|
|
2745
|
+
toDispose.dispose();
|
|
2746
|
+
if (options && typeof options.onCancel === 'function' && !choiceClicked) {
|
|
2747
|
+
options.onCancel();
|
|
2748
|
+
}
|
|
2749
|
+
});
|
|
2750
|
+
return handle;
|
|
2751
|
+
}
|
|
2752
|
+
status(message, options) {
|
|
2753
|
+
return this.model.showStatusMessage(message, options);
|
|
2754
|
+
}
|
|
2755
|
+
};
|
|
2756
|
+
NotificationService.DND_SETTINGS_KEY = 'notifications.doNotDisturbMode';
|
|
2757
|
+
NotificationService = ( (__decorate([
|
|
2758
|
+
( (__param(0, IStorageService)))
|
|
2759
|
+
], NotificationService)));
|
|
2760
|
+
function mnemonicButtonLabel(label, forceDisableMnemonics) {
|
|
2761
|
+
if (isMacintosh || forceDisableMnemonics) {
|
|
2762
|
+
return label.replace(/\(&&\w\)|&&/g, '');
|
|
2763
|
+
}
|
|
2764
|
+
if (isWindows) {
|
|
2765
|
+
return label.replace(/&&|&/g, m => m === '&' ? '&&' : '&');
|
|
2766
|
+
}
|
|
2767
|
+
return label.replace(/&&/g, '_');
|
|
2768
|
+
}
|
|
2769
|
+
var css = "/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\n/** Dialog: Modal Block */\n.monaco-dialog-modal-block {\n\tposition: fixed;\n\theight: 100%;\n\twidth: 100%;\n\tleft:0;\n\ttop:0;\n\tz-index: 2600;\n\tdisplay: flex;\n\tjustify-content: center;\n\talign-items: center;\n}\n\n.monaco-dialog-modal-block.dimmed {\n\tbackground: rgba(0, 0, 0, 0.3);\n}\n\n/** Dialog: Container */\n.monaco-dialog-box {\n\tdisplay: flex;\n\tflex-direction: column-reverse;\n\twidth: min-content;\n\tmin-width: 500px;\n\tmax-width: 90vw;\n\tmin-height: 75px;\n\tpadding: 10px;\n\ttransform: translate3d(0px, 0px, 0px);\n}\n\n/** Dialog: Title Actions Row */\n.monaco-dialog-box .dialog-toolbar-row {\n\theight: 22px;\n\tpadding-bottom: 4px;\n}\n\n.monaco-dialog-box .dialog-toolbar-row .actions-container {\n\tjustify-content: flex-end;\n}\n\n/** Dialog: Message Row */\n.monaco-dialog-box .dialog-message-row {\n\tdisplay: flex;\n\tflex-grow: 1;\n\talign-items: center;\n\tpadding: 0 10px;\n}\n\n.monaco-dialog-box .dialog-message-row > .dialog-icon.codicon {\n\tflex: 0 0 48px;\n\theight: 48px;\n\talign-self: baseline;\n\tfont-size: 48px;\n}\n\n/** Dialog: Message Container */\n.monaco-dialog-box .dialog-message-row .dialog-message-container {\n\tdisplay: flex;\n\tflex-direction: column;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\tpadding-left: 24px;\n\tuser-select: text;\n\t-webkit-user-select: text;\n\t-ms-user-select: text;\n\tword-wrap: break-word; /* never overflow long words, but break to next line */\n\twhite-space: normal;\n}\n\n/** Dialog: Message */\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message {\n\tline-height: 22px;\n\tfont-size: 18px;\n\tflex: 1; /* let the message always grow */\n\twhite-space: normal;\n\tword-wrap: break-word; /* never overflow long words, but break to next line */\n\tmin-height: 48px; /* matches icon height */\n\tmargin-bottom: 8px;\n\tdisplay: flex;\n\talign-items: center;\n}\n\n/** Dialog: Details */\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message-detail {\n\tline-height: 22px;\n\tflex: 1; /* let the message always grow */\n}\n\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message a:focus {\n\toutline-width: 1px;\n\toutline-style: solid;\n}\n\n/** Dialog: Checkbox */\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-checkbox-row {\n\tpadding: 15px 0px 0px;\n\tdisplay: flex;\n}\n\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-checkbox-row .dialog-checkbox-message {\n\tcursor: pointer;\n\tuser-select: none;\n\t-webkit-user-select: none;\n\t-ms-user-select: none;\n}\n\n/** Dialog: Input */\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message-input {\n\tpadding: 15px 0px 0px;\n\tdisplay: flex;\n}\n\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message-input .monaco-inputbox {\n\tflex: 1;\n}\n\n/** Dialog: File Path */\n.monaco-dialog-box code {\n\tfont-family: var(--monaco-monospace-font);\n}\n\n/** Dialog: Buttons Row */\n.monaco-dialog-box > .dialog-buttons-row {\n\tdisplay: flex;\n\talign-items: center;\n\tpadding-right: 1px;\n\toverflow: hidden; /* buttons row should never overflow */\n}\n\n.monaco-dialog-box > .dialog-buttons-row {\n\tdisplay: flex;\n\twhite-space: nowrap;\n\tpadding: 20px 10px 10px;\n}\n\n/** Dialog: Buttons */\n.monaco-dialog-box > .dialog-buttons-row > .dialog-buttons {\n\tdisplay: flex;\n\twidth: 100%;\n\tjustify-content: flex-end;\n\toverflow: hidden;\n\tmargin-left: 67px; /* for long buttons, force align with text */\n}\n\n.monaco-dialog-box > .dialog-buttons-row > .dialog-buttons > .monaco-button {\n\twidth: fit-content;\n\twidth: -moz-fit-content;\n\tpadding: 5px 10px;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\tmargin: 4px 5px; /* allows button focus outline to be visible */\n\toutline-offset: 2px !important;\n}\n";
|
|
2770
|
+
n(css,{});
|
|
2771
|
+
class Dialog extends Disposable {
|
|
2772
|
+
constructor(container, message, buttons, options) {
|
|
2773
|
+
super();
|
|
2774
|
+
this.container = container;
|
|
2775
|
+
this.message = message;
|
|
2776
|
+
this.options = options;
|
|
2777
|
+
this.modalElement = this.container.appendChild($(`.monaco-dialog-modal-block.dimmed`));
|
|
2778
|
+
this.shadowElement = this.modalElement.appendChild($('.dialog-shadow'));
|
|
2779
|
+
this.element = this.shadowElement.appendChild($('.monaco-dialog-box'));
|
|
2780
|
+
this.element.setAttribute('role', 'dialog');
|
|
2781
|
+
this.element.tabIndex = -1;
|
|
2782
|
+
hide(this.element);
|
|
2783
|
+
if (Array.isArray(buttons) && buttons.length > 0) {
|
|
2784
|
+
this.buttons = buttons;
|
|
2785
|
+
}
|
|
2786
|
+
else if (!this.options.disableDefaultAction) {
|
|
2787
|
+
this.buttons = [( (localize('ok', "OK")))];
|
|
2788
|
+
}
|
|
2789
|
+
else {
|
|
2790
|
+
this.buttons = [];
|
|
2791
|
+
}
|
|
2792
|
+
const buttonsRowElement = this.element.appendChild($('.dialog-buttons-row'));
|
|
2793
|
+
this.buttonsContainer = buttonsRowElement.appendChild($('.dialog-buttons'));
|
|
2794
|
+
const messageRowElement = this.element.appendChild($('.dialog-message-row'));
|
|
2795
|
+
this.iconElement = messageRowElement.appendChild($('#monaco-dialog-icon.dialog-icon'));
|
|
2796
|
+
this.iconElement.setAttribute('aria-label', this.getIconAriaLabel());
|
|
2797
|
+
this.messageContainer = messageRowElement.appendChild($('.dialog-message-container'));
|
|
2798
|
+
if (this.options.detail || this.options.renderBody) {
|
|
2799
|
+
const messageElement = this.messageContainer.appendChild($('.dialog-message'));
|
|
2800
|
+
const messageTextElement = messageElement.appendChild($('#monaco-dialog-message-text.dialog-message-text'));
|
|
2801
|
+
messageTextElement.innerText = this.message;
|
|
2802
|
+
}
|
|
2803
|
+
this.messageDetailElement = this.messageContainer.appendChild($('#monaco-dialog-message-detail.dialog-message-detail'));
|
|
2804
|
+
if (this.options.detail || !this.options.renderBody) {
|
|
2805
|
+
this.messageDetailElement.innerText = this.options.detail ? this.options.detail : message;
|
|
2806
|
+
}
|
|
2807
|
+
else {
|
|
2808
|
+
this.messageDetailElement.style.display = 'none';
|
|
2809
|
+
}
|
|
2810
|
+
if (this.options.renderBody) {
|
|
2811
|
+
const customBody = this.messageContainer.appendChild($('#monaco-dialog-message-body.dialog-message-body'));
|
|
2812
|
+
this.options.renderBody(customBody);
|
|
2813
|
+
for (const el of this.messageContainer.querySelectorAll('a')) {
|
|
2814
|
+
el.tabIndex = 0;
|
|
2815
|
+
}
|
|
2816
|
+
}
|
|
2817
|
+
if (this.options.inputs) {
|
|
2818
|
+
this.inputs = this.options.inputs.map(input => {
|
|
2819
|
+
const inputRowElement = this.messageContainer.appendChild($('.dialog-message-input'));
|
|
2820
|
+
const inputBox = this._register(( (new InputBox(inputRowElement, undefined, {
|
|
2821
|
+
placeholder: input.placeholder,
|
|
2822
|
+
type: input.type ?? 'text',
|
|
2823
|
+
}))));
|
|
2824
|
+
if (input.value) {
|
|
2825
|
+
inputBox.value = input.value;
|
|
2826
|
+
}
|
|
2827
|
+
return inputBox;
|
|
2828
|
+
});
|
|
2829
|
+
}
|
|
2830
|
+
else {
|
|
2831
|
+
this.inputs = [];
|
|
2832
|
+
}
|
|
2833
|
+
if (this.options.checkboxLabel) {
|
|
2834
|
+
const checkboxRowElement = this.messageContainer.appendChild($('.dialog-checkbox-row'));
|
|
2835
|
+
const checkbox = this.checkbox = this._register(( (new Checkbox(this.options.checkboxLabel, !!this.options.checkboxChecked))));
|
|
2836
|
+
checkboxRowElement.appendChild(checkbox.domNode);
|
|
2837
|
+
const checkboxMessageElement = checkboxRowElement.appendChild($('.dialog-checkbox-message'));
|
|
2838
|
+
checkboxMessageElement.innerText = this.options.checkboxLabel;
|
|
2839
|
+
this._register(addDisposableListener(checkboxMessageElement, EventType.CLICK, () => checkbox.checked = !checkbox.checked));
|
|
2840
|
+
}
|
|
2841
|
+
const toolbarRowElement = this.element.appendChild($('.dialog-toolbar-row'));
|
|
2842
|
+
this.toolbarContainer = toolbarRowElement.appendChild($('.dialog-toolbar'));
|
|
2843
|
+
}
|
|
2844
|
+
getIconAriaLabel() {
|
|
2845
|
+
const typeLabel = ( (localize('dialogInfoMessage', 'Info')));
|
|
2846
|
+
return typeLabel;
|
|
2847
|
+
}
|
|
2848
|
+
updateMessage(message) {
|
|
2849
|
+
this.messageDetailElement.innerText = message;
|
|
2850
|
+
}
|
|
2851
|
+
async show() {
|
|
2852
|
+
this.focusToReturn = document.activeElement;
|
|
2853
|
+
return (
|
|
2854
|
+
(new Promise((resolve) => {
|
|
2855
|
+
clearNode(this.buttonsContainer);
|
|
2856
|
+
const buttonBar = this.buttonBar = this._register(( (new ButtonBar(this.buttonsContainer))));
|
|
2857
|
+
const buttonMap = this.rearrangeButtons(this.buttons, this.options.cancelId);
|
|
2858
|
+
buttonMap.forEach((entry, index) => {
|
|
2859
|
+
const primary = buttonMap[index].index === 0;
|
|
2860
|
+
const button = this.options.buttonDetails ? this._register(buttonBar.addButtonWithDescription({ title: true, secondary: !primary })) : this._register(buttonBar.addButton({ title: true, secondary: !primary }));
|
|
2861
|
+
button.label = mnemonicButtonLabel(buttonMap[index].label, true);
|
|
2862
|
+
if (button instanceof ButtonWithDescription) {
|
|
2863
|
+
button.description = this.options.buttonDetails[buttonMap[index].index];
|
|
2864
|
+
}
|
|
2865
|
+
this._register(button.onDidClick(e => {
|
|
2866
|
+
if (e) {
|
|
2867
|
+
EventHelper.stop(e);
|
|
2868
|
+
}
|
|
2869
|
+
resolve({
|
|
2870
|
+
button: buttonMap[index].index,
|
|
2871
|
+
checkboxChecked: this.checkbox ? this.checkbox.checked : undefined,
|
|
2872
|
+
values: this.inputs.length > 0 ? this.inputs.map(input => input.value) : undefined
|
|
2873
|
+
});
|
|
2874
|
+
}));
|
|
2875
|
+
});
|
|
2876
|
+
this._register(addDisposableListener(window, 'keydown', e => {
|
|
2877
|
+
const evt = ( (new StandardKeyboardEvent(e)));
|
|
2878
|
+
if (evt.equals(512 )) {
|
|
2879
|
+
evt.preventDefault();
|
|
2880
|
+
}
|
|
2881
|
+
if (evt.equals(3 )) {
|
|
2882
|
+
if (this.inputs.some(input => input.hasFocus())) {
|
|
2883
|
+
EventHelper.stop(e);
|
|
2884
|
+
resolve({
|
|
2885
|
+
button: buttonMap.find(button => button.index !== this.options.cancelId)?.index ?? 0,
|
|
2886
|
+
checkboxChecked: this.checkbox ? this.checkbox.checked : undefined,
|
|
2887
|
+
values: this.inputs.length > 0 ? this.inputs.map(input => input.value) : undefined
|
|
2888
|
+
});
|
|
2889
|
+
}
|
|
2890
|
+
return;
|
|
2891
|
+
}
|
|
2892
|
+
if (evt.equals(10 )) {
|
|
2893
|
+
return;
|
|
2894
|
+
}
|
|
2895
|
+
let eventHandled = false;
|
|
2896
|
+
if (evt.equals(2 ) || evt.equals(17 ) || evt.equals(1024 | 2 ) || evt.equals(15 )) {
|
|
2897
|
+
const focusableElements = [];
|
|
2898
|
+
let focusedIndex = -1;
|
|
2899
|
+
if (this.messageContainer) {
|
|
2900
|
+
const links = this.messageContainer.querySelectorAll('a');
|
|
2901
|
+
for (const link of links) {
|
|
2902
|
+
focusableElements.push(link);
|
|
2903
|
+
if (link === document.activeElement) {
|
|
2904
|
+
focusedIndex = focusableElements.length - 1;
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
}
|
|
2908
|
+
for (const input of this.inputs) {
|
|
2909
|
+
focusableElements.push(input);
|
|
2910
|
+
if (input.hasFocus()) {
|
|
2911
|
+
focusedIndex = focusableElements.length - 1;
|
|
2912
|
+
}
|
|
2913
|
+
}
|
|
2914
|
+
if (this.checkbox) {
|
|
2915
|
+
focusableElements.push(this.checkbox);
|
|
2916
|
+
if (this.checkbox.hasFocus()) {
|
|
2917
|
+
focusedIndex = focusableElements.length - 1;
|
|
2918
|
+
}
|
|
2919
|
+
}
|
|
2920
|
+
if (this.buttonBar) {
|
|
2921
|
+
for (const button of this.buttonBar.buttons) {
|
|
2922
|
+
focusableElements.push(button);
|
|
2923
|
+
if (button.hasFocus()) {
|
|
2924
|
+
focusedIndex = focusableElements.length - 1;
|
|
2925
|
+
}
|
|
2926
|
+
}
|
|
2927
|
+
}
|
|
2928
|
+
if (evt.equals(2 ) || evt.equals(17 )) {
|
|
2929
|
+
if (focusedIndex === -1) {
|
|
2930
|
+
focusedIndex = 0;
|
|
2931
|
+
}
|
|
2932
|
+
const newFocusedIndex = (focusedIndex + 1) % focusableElements.length;
|
|
2933
|
+
focusableElements[newFocusedIndex].focus();
|
|
2934
|
+
}
|
|
2935
|
+
else {
|
|
2936
|
+
if (focusedIndex === -1) {
|
|
2937
|
+
focusedIndex = focusableElements.length;
|
|
2938
|
+
}
|
|
2939
|
+
let newFocusedIndex = focusedIndex - 1;
|
|
2940
|
+
if (newFocusedIndex === -1) {
|
|
2941
|
+
newFocusedIndex = focusableElements.length - 1;
|
|
2942
|
+
}
|
|
2943
|
+
focusableElements[newFocusedIndex].focus();
|
|
2944
|
+
}
|
|
2945
|
+
eventHandled = true;
|
|
2946
|
+
}
|
|
2947
|
+
if (eventHandled) {
|
|
2948
|
+
EventHelper.stop(e, true);
|
|
2949
|
+
}
|
|
2950
|
+
else if (this.options.keyEventProcessor) {
|
|
2951
|
+
this.options.keyEventProcessor(evt);
|
|
2952
|
+
}
|
|
2953
|
+
}, true));
|
|
2954
|
+
this._register(addDisposableListener(window, 'keyup', e => {
|
|
2955
|
+
EventHelper.stop(e, true);
|
|
2956
|
+
const evt = ( (new StandardKeyboardEvent(e)));
|
|
2957
|
+
if (!this.options.disableCloseAction && evt.equals(9 )) {
|
|
2958
|
+
resolve({
|
|
2959
|
+
button: this.options.cancelId || 0,
|
|
2960
|
+
checkboxChecked: this.checkbox ? this.checkbox.checked : undefined
|
|
2961
|
+
});
|
|
2962
|
+
}
|
|
2963
|
+
}, true));
|
|
2964
|
+
this._register(addDisposableListener(this.element, 'focusout', e => {
|
|
2965
|
+
if (!!e.relatedTarget && !!this.element) {
|
|
2966
|
+
if (!isAncestor(e.relatedTarget, this.element)) {
|
|
2967
|
+
this.focusToReturn = e.relatedTarget;
|
|
2968
|
+
if (e.target) {
|
|
2969
|
+
e.target.focus();
|
|
2970
|
+
EventHelper.stop(e, true);
|
|
2971
|
+
}
|
|
2972
|
+
}
|
|
2973
|
+
}
|
|
2974
|
+
}, false));
|
|
2975
|
+
const spinModifierClassName = 'codicon-modifier-spin';
|
|
2976
|
+
this.iconElement.classList.remove(...Codicon.dialogError.classNamesArray, ...Codicon.dialogWarning.classNamesArray, ...Codicon.dialogInfo.classNamesArray, ...Codicon.loading.classNamesArray, spinModifierClassName);
|
|
2977
|
+
if (this.options.icon) {
|
|
2978
|
+
this.iconElement.classList.add(...this.options.icon.classNamesArray);
|
|
2979
|
+
}
|
|
2980
|
+
else {
|
|
2981
|
+
switch (this.options.type) {
|
|
2982
|
+
case 'error':
|
|
2983
|
+
this.iconElement.classList.add(...Codicon.dialogError.classNamesArray);
|
|
2984
|
+
break;
|
|
2985
|
+
case 'warning':
|
|
2986
|
+
this.iconElement.classList.add(...Codicon.dialogWarning.classNamesArray);
|
|
2987
|
+
break;
|
|
2988
|
+
case 'pending':
|
|
2989
|
+
this.iconElement.classList.add(...Codicon.loading.classNamesArray, spinModifierClassName);
|
|
2990
|
+
break;
|
|
2991
|
+
case 'none':
|
|
2992
|
+
case 'info':
|
|
2993
|
+
case 'question':
|
|
2994
|
+
default:
|
|
2995
|
+
this.iconElement.classList.add(...Codicon.dialogInfo.classNamesArray);
|
|
2996
|
+
break;
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2999
|
+
if (!this.options.disableCloseAction) {
|
|
3000
|
+
const actionBar = this._register(( (new ActionBar(this.toolbarContainer, {}))));
|
|
3001
|
+
const action = this._register(( (new Action(
|
|
3002
|
+
'dialog.close',
|
|
3003
|
+
(localize('dialogClose', "Close Dialog")),
|
|
3004
|
+
Codicon.dialogClose.classNames,
|
|
3005
|
+
true,
|
|
3006
|
+
async () => {
|
|
3007
|
+
resolve({
|
|
3008
|
+
button: this.options.cancelId || 0,
|
|
3009
|
+
checkboxChecked: this.checkbox ? this.checkbox.checked : undefined
|
|
3010
|
+
});
|
|
3011
|
+
}
|
|
3012
|
+
))));
|
|
3013
|
+
actionBar.push(action, { icon: true, label: false, });
|
|
3014
|
+
}
|
|
3015
|
+
this.applyStyles();
|
|
3016
|
+
this.element.setAttribute('aria-modal', 'true');
|
|
3017
|
+
this.element.setAttribute('aria-labelledby', 'monaco-dialog-icon monaco-dialog-message-text');
|
|
3018
|
+
this.element.setAttribute('aria-describedby', 'monaco-dialog-icon monaco-dialog-message-text monaco-dialog-message-detail monaco-dialog-message-body');
|
|
3019
|
+
show(this.element);
|
|
3020
|
+
if (this.inputs.length > 0) {
|
|
3021
|
+
this.inputs[0].focus();
|
|
3022
|
+
this.inputs[0].select();
|
|
3023
|
+
}
|
|
3024
|
+
else {
|
|
3025
|
+
buttonMap.forEach((value, index) => {
|
|
3026
|
+
if (value.index === 0) {
|
|
3027
|
+
buttonBar.buttons[index].focus();
|
|
3028
|
+
}
|
|
3029
|
+
});
|
|
3030
|
+
}
|
|
3031
|
+
}))
|
|
3032
|
+
);
|
|
3033
|
+
}
|
|
3034
|
+
applyStyles() {
|
|
3035
|
+
if (this.styles) {
|
|
3036
|
+
const style = this.styles;
|
|
3037
|
+
const fgColor = style.dialogForeground;
|
|
3038
|
+
const bgColor = style.dialogBackground;
|
|
3039
|
+
const shadowColor = style.dialogShadow ? `0 0px 8px ${style.dialogShadow}` : '';
|
|
3040
|
+
const border = style.dialogBorder ? `1px solid ${style.dialogBorder}` : '';
|
|
3041
|
+
const linkFgColor = style.textLinkForeground;
|
|
3042
|
+
this.shadowElement.style.boxShadow = shadowColor;
|
|
3043
|
+
this.element.style.color = fgColor?.toString() ?? '';
|
|
3044
|
+
this.element.style.backgroundColor = bgColor?.toString() ?? '';
|
|
3045
|
+
this.element.style.border = border;
|
|
3046
|
+
this.buttonBar?.buttons.forEach(button => button.style(style));
|
|
3047
|
+
this.checkbox?.style(style);
|
|
3048
|
+
if (fgColor && bgColor) {
|
|
3049
|
+
const messageDetailColor = ( (fgColor.transparent(.9)));
|
|
3050
|
+
this.messageDetailElement.style.color = ( (messageDetailColor.makeOpaque(bgColor).toString()));
|
|
3051
|
+
}
|
|
3052
|
+
if (linkFgColor) {
|
|
3053
|
+
for (const el of this.messageContainer.getElementsByTagName('a')) {
|
|
3054
|
+
el.style.color = ( (linkFgColor.toString()));
|
|
3055
|
+
}
|
|
3056
|
+
}
|
|
3057
|
+
let color;
|
|
3058
|
+
switch (this.options.type) {
|
|
3059
|
+
case 'error':
|
|
3060
|
+
color = style.errorIconForeground;
|
|
3061
|
+
break;
|
|
3062
|
+
case 'warning':
|
|
3063
|
+
color = style.warningIconForeground;
|
|
3064
|
+
break;
|
|
3065
|
+
default:
|
|
3066
|
+
color = style.infoIconForeground;
|
|
3067
|
+
break;
|
|
3068
|
+
}
|
|
3069
|
+
if (color) {
|
|
3070
|
+
this.iconElement.style.color = ( (color.toString()));
|
|
3071
|
+
}
|
|
3072
|
+
for (const input of this.inputs) {
|
|
3073
|
+
input.style(style);
|
|
3074
|
+
}
|
|
3075
|
+
}
|
|
3076
|
+
}
|
|
3077
|
+
style(style) {
|
|
3078
|
+
this.styles = style;
|
|
3079
|
+
this.applyStyles();
|
|
3080
|
+
}
|
|
3081
|
+
dispose() {
|
|
3082
|
+
super.dispose();
|
|
3083
|
+
if (this.modalElement) {
|
|
3084
|
+
this.modalElement.remove();
|
|
3085
|
+
this.modalElement = undefined;
|
|
3086
|
+
}
|
|
3087
|
+
if (this.focusToReturn && isAncestor(this.focusToReturn, document.body)) {
|
|
3088
|
+
this.focusToReturn.focus();
|
|
3089
|
+
this.focusToReturn = undefined;
|
|
3090
|
+
}
|
|
3091
|
+
}
|
|
3092
|
+
rearrangeButtons(buttons, cancelId) {
|
|
3093
|
+
const buttonMap = [];
|
|
3094
|
+
if (buttons.length === 0) {
|
|
3095
|
+
return buttonMap;
|
|
3096
|
+
}
|
|
3097
|
+
buttons.forEach((button, index) => {
|
|
3098
|
+
buttonMap.push({ label: button, index });
|
|
3099
|
+
});
|
|
3100
|
+
if (isMacintosh || isLinux) {
|
|
3101
|
+
if (cancelId !== undefined && cancelId < buttons.length) {
|
|
3102
|
+
const cancelButton = buttonMap.splice(cancelId, 1)[0];
|
|
3103
|
+
buttonMap.reverse();
|
|
3104
|
+
buttonMap.splice(buttonMap.length - 1, 0, cancelButton);
|
|
3105
|
+
}
|
|
3106
|
+
}
|
|
3107
|
+
return buttonMap;
|
|
3108
|
+
}
|
|
3109
|
+
}
|
|
3110
|
+
const minute = 60;
|
|
3111
|
+
const hour = minute * 60;
|
|
3112
|
+
const day = hour * 24;
|
|
3113
|
+
const week = day * 7;
|
|
3114
|
+
const month = day * 30;
|
|
3115
|
+
const year = day * 365;
|
|
3116
|
+
function fromNow(date, appendAgoLabel, useFullTimeWords) {
|
|
3117
|
+
if (typeof date !== 'number') {
|
|
3118
|
+
date = date.getTime();
|
|
3119
|
+
}
|
|
3120
|
+
const seconds = Math.round((( (new Date())).getTime() - date) / 1000);
|
|
3121
|
+
if (seconds < -30) {
|
|
3122
|
+
return (
|
|
3123
|
+
(localize(
|
|
3124
|
+
'date.fromNow.in',
|
|
3125
|
+
'in {0}',
|
|
3126
|
+
fromNow(( (new Date())).getTime() + seconds * 1000, false)
|
|
3127
|
+
))
|
|
3128
|
+
);
|
|
3129
|
+
}
|
|
3130
|
+
if (seconds < 30) {
|
|
3131
|
+
return (
|
|
3132
|
+
(localize('date.fromNow.now', 'now'))
|
|
3133
|
+
);
|
|
3134
|
+
}
|
|
3135
|
+
let value;
|
|
3136
|
+
if (seconds < minute) {
|
|
3137
|
+
value = seconds;
|
|
3138
|
+
if (appendAgoLabel) {
|
|
3139
|
+
if (value === 1) {
|
|
3140
|
+
return useFullTimeWords
|
|
3141
|
+
? ( (localize('date.fromNow.seconds.singular.ago.fullWord', '{0} second ago', value)))
|
|
3142
|
+
: ( (localize('date.fromNow.seconds.singular.ago', '{0} sec ago', value)));
|
|
3143
|
+
}
|
|
3144
|
+
else {
|
|
3145
|
+
return useFullTimeWords
|
|
3146
|
+
? ( (localize('date.fromNow.seconds.plural.ago.fullWord', '{0} seconds ago', value)))
|
|
3147
|
+
: ( (localize('date.fromNow.seconds.plural.ago', '{0} secs ago', value)));
|
|
3148
|
+
}
|
|
3149
|
+
}
|
|
3150
|
+
else {
|
|
3151
|
+
if (value === 1) {
|
|
3152
|
+
return useFullTimeWords
|
|
3153
|
+
? ( (localize('date.fromNow.seconds.singular.fullWord', '{0} second', value)))
|
|
3154
|
+
: ( (localize('date.fromNow.seconds.singular', '{0} sec', value)));
|
|
3155
|
+
}
|
|
3156
|
+
else {
|
|
3157
|
+
return useFullTimeWords
|
|
3158
|
+
? ( (localize('date.fromNow.seconds.plural.fullWord', '{0} seconds', value)))
|
|
3159
|
+
: ( (localize('date.fromNow.seconds.plural', '{0} secs', value)));
|
|
3160
|
+
}
|
|
3161
|
+
}
|
|
3162
|
+
}
|
|
3163
|
+
if (seconds < hour) {
|
|
3164
|
+
value = Math.floor(seconds / minute);
|
|
3165
|
+
if (appendAgoLabel) {
|
|
3166
|
+
if (value === 1) {
|
|
3167
|
+
return useFullTimeWords
|
|
3168
|
+
? ( (localize('date.fromNow.minutes.singular.ago.fullWord', '{0} minute ago', value)))
|
|
3169
|
+
: ( (localize('date.fromNow.minutes.singular.ago', '{0} min ago', value)));
|
|
3170
|
+
}
|
|
3171
|
+
else {
|
|
3172
|
+
return useFullTimeWords
|
|
3173
|
+
? ( (localize('date.fromNow.minutes.plural.ago.fullWord', '{0} minutes ago', value)))
|
|
3174
|
+
: ( (localize('date.fromNow.minutes.plural.ago', '{0} mins ago', value)));
|
|
3175
|
+
}
|
|
3176
|
+
}
|
|
3177
|
+
else {
|
|
3178
|
+
if (value === 1) {
|
|
3179
|
+
return useFullTimeWords
|
|
3180
|
+
? ( (localize('date.fromNow.minutes.singular.fullWord', '{0} minute', value)))
|
|
3181
|
+
: ( (localize('date.fromNow.minutes.singular', '{0} min', value)));
|
|
3182
|
+
}
|
|
3183
|
+
else {
|
|
3184
|
+
return useFullTimeWords
|
|
3185
|
+
? ( (localize('date.fromNow.minutes.plural.fullWord', '{0} minutes', value)))
|
|
3186
|
+
: ( (localize('date.fromNow.minutes.plural', '{0} mins', value)));
|
|
3187
|
+
}
|
|
3188
|
+
}
|
|
3189
|
+
}
|
|
3190
|
+
if (seconds < day) {
|
|
3191
|
+
value = Math.floor(seconds / hour);
|
|
3192
|
+
if (appendAgoLabel) {
|
|
3193
|
+
if (value === 1) {
|
|
3194
|
+
return useFullTimeWords
|
|
3195
|
+
? ( (localize('date.fromNow.hours.singular.ago.fullWord', '{0} hour ago', value)))
|
|
3196
|
+
: ( (localize('date.fromNow.hours.singular.ago', '{0} hr ago', value)));
|
|
3197
|
+
}
|
|
3198
|
+
else {
|
|
3199
|
+
return useFullTimeWords
|
|
3200
|
+
? ( (localize('date.fromNow.hours.plural.ago.fullWord', '{0} hours ago', value)))
|
|
3201
|
+
: ( (localize('date.fromNow.hours.plural.ago', '{0} hrs ago', value)));
|
|
3202
|
+
}
|
|
3203
|
+
}
|
|
3204
|
+
else {
|
|
3205
|
+
if (value === 1) {
|
|
3206
|
+
return useFullTimeWords
|
|
3207
|
+
? ( (localize('date.fromNow.hours.singular.fullWord', '{0} hour', value)))
|
|
3208
|
+
: ( (localize('date.fromNow.hours.singular', '{0} hr', value)));
|
|
3209
|
+
}
|
|
3210
|
+
else {
|
|
3211
|
+
return useFullTimeWords
|
|
3212
|
+
? ( (localize('date.fromNow.hours.plural.fullWord', '{0} hours', value)))
|
|
3213
|
+
: ( (localize('date.fromNow.hours.plural', '{0} hrs', value)));
|
|
3214
|
+
}
|
|
3215
|
+
}
|
|
3216
|
+
}
|
|
3217
|
+
if (seconds < week) {
|
|
3218
|
+
value = Math.floor(seconds / day);
|
|
3219
|
+
if (appendAgoLabel) {
|
|
3220
|
+
return value === 1
|
|
3221
|
+
? ( (localize('date.fromNow.days.singular.ago', '{0} day ago', value)))
|
|
3222
|
+
: ( (localize('date.fromNow.days.plural.ago', '{0} days ago', value)));
|
|
3223
|
+
}
|
|
3224
|
+
else {
|
|
3225
|
+
return value === 1
|
|
3226
|
+
? ( (localize('date.fromNow.days.singular', '{0} day', value)))
|
|
3227
|
+
: ( (localize('date.fromNow.days.plural', '{0} days', value)));
|
|
3228
|
+
}
|
|
3229
|
+
}
|
|
3230
|
+
if (seconds < month) {
|
|
3231
|
+
value = Math.floor(seconds / week);
|
|
3232
|
+
if (appendAgoLabel) {
|
|
3233
|
+
if (value === 1) {
|
|
3234
|
+
return useFullTimeWords
|
|
3235
|
+
? ( (localize('date.fromNow.weeks.singular.ago.fullWord', '{0} week ago', value)))
|
|
3236
|
+
: ( (localize('date.fromNow.weeks.singular.ago', '{0} wk ago', value)));
|
|
3237
|
+
}
|
|
3238
|
+
else {
|
|
3239
|
+
return useFullTimeWords
|
|
3240
|
+
? ( (localize('date.fromNow.weeks.plural.ago.fullWord', '{0} weeks ago', value)))
|
|
3241
|
+
: ( (localize('date.fromNow.weeks.plural.ago', '{0} wks ago', value)));
|
|
3242
|
+
}
|
|
3243
|
+
}
|
|
3244
|
+
else {
|
|
3245
|
+
if (value === 1) {
|
|
3246
|
+
return useFullTimeWords
|
|
3247
|
+
? ( (localize('date.fromNow.weeks.singular.fullWord', '{0} week', value)))
|
|
3248
|
+
: ( (localize('date.fromNow.weeks.singular', '{0} wk', value)));
|
|
3249
|
+
}
|
|
3250
|
+
else {
|
|
3251
|
+
return useFullTimeWords
|
|
3252
|
+
? ( (localize('date.fromNow.weeks.plural.fullWord', '{0} weeks', value)))
|
|
3253
|
+
: ( (localize('date.fromNow.weeks.plural', '{0} wks', value)));
|
|
3254
|
+
}
|
|
3255
|
+
}
|
|
3256
|
+
}
|
|
3257
|
+
if (seconds < year) {
|
|
3258
|
+
value = Math.floor(seconds / month);
|
|
3259
|
+
if (appendAgoLabel) {
|
|
3260
|
+
if (value === 1) {
|
|
3261
|
+
return useFullTimeWords
|
|
3262
|
+
? ( (localize('date.fromNow.months.singular.ago.fullWord', '{0} month ago', value)))
|
|
3263
|
+
: ( (localize('date.fromNow.months.singular.ago', '{0} mo ago', value)));
|
|
3264
|
+
}
|
|
3265
|
+
else {
|
|
3266
|
+
return useFullTimeWords
|
|
3267
|
+
? ( (localize('date.fromNow.months.plural.ago.fullWord', '{0} months ago', value)))
|
|
3268
|
+
: ( (localize('date.fromNow.months.plural.ago', '{0} mos ago', value)));
|
|
3269
|
+
}
|
|
3270
|
+
}
|
|
3271
|
+
else {
|
|
3272
|
+
if (value === 1) {
|
|
3273
|
+
return useFullTimeWords
|
|
3274
|
+
? ( (localize('date.fromNow.months.singular.fullWord', '{0} month', value)))
|
|
3275
|
+
: ( (localize('date.fromNow.months.singular', '{0} mo', value)));
|
|
3276
|
+
}
|
|
3277
|
+
else {
|
|
3278
|
+
return useFullTimeWords
|
|
3279
|
+
? ( (localize('date.fromNow.months.plural.fullWord', '{0} months', value)))
|
|
3280
|
+
: ( (localize('date.fromNow.months.plural', '{0} mos', value)));
|
|
3281
|
+
}
|
|
3282
|
+
}
|
|
3283
|
+
}
|
|
3284
|
+
value = Math.floor(seconds / year);
|
|
3285
|
+
if (appendAgoLabel) {
|
|
3286
|
+
if (value === 1) {
|
|
3287
|
+
return useFullTimeWords
|
|
3288
|
+
? ( (localize('date.fromNow.years.singular.ago.fullWord', '{0} year ago', value)))
|
|
3289
|
+
: ( (localize('date.fromNow.years.singular.ago', '{0} yr ago', value)));
|
|
3290
|
+
}
|
|
3291
|
+
else {
|
|
3292
|
+
return useFullTimeWords
|
|
3293
|
+
? ( (localize('date.fromNow.years.plural.ago.fullWord', '{0} years ago', value)))
|
|
3294
|
+
: ( (localize('date.fromNow.years.plural.ago', '{0} yrs ago', value)));
|
|
3295
|
+
}
|
|
3296
|
+
}
|
|
3297
|
+
else {
|
|
3298
|
+
if (value === 1) {
|
|
3299
|
+
return useFullTimeWords
|
|
3300
|
+
? ( (localize('date.fromNow.years.singular.fullWord', '{0} year', value)))
|
|
3301
|
+
: ( (localize('date.fromNow.years.singular', '{0} yr', value)));
|
|
3302
|
+
}
|
|
3303
|
+
else {
|
|
3304
|
+
return useFullTimeWords
|
|
3305
|
+
? ( (localize('date.fromNow.years.plural.fullWord', '{0} years', value)))
|
|
3306
|
+
: ( (localize('date.fromNow.years.plural', '{0} yrs', value)));
|
|
3307
|
+
}
|
|
3308
|
+
}
|
|
3309
|
+
}
|
|
3310
|
+
let BrowserDialogHandler = class BrowserDialogHandler {
|
|
3311
|
+
constructor(logService, layoutService, themeService, keybindingService, instantiationService, productService, clipboardService) {
|
|
3312
|
+
this.logService = logService;
|
|
3313
|
+
this.layoutService = layoutService;
|
|
3314
|
+
this.themeService = themeService;
|
|
3315
|
+
this.keybindingService = keybindingService;
|
|
3316
|
+
this.instantiationService = instantiationService;
|
|
3317
|
+
this.productService = productService;
|
|
3318
|
+
this.clipboardService = clipboardService;
|
|
3319
|
+
this.markdownRenderer = this.instantiationService.createInstance(MarkdownRenderer, {});
|
|
3320
|
+
}
|
|
3321
|
+
async confirm(confirmation) {
|
|
3322
|
+
this.logService.trace('DialogService#confirm', confirmation.message);
|
|
3323
|
+
const buttons = [];
|
|
3324
|
+
if (confirmation.primaryButton) {
|
|
3325
|
+
buttons.push(confirmation.primaryButton);
|
|
3326
|
+
}
|
|
3327
|
+
else {
|
|
3328
|
+
buttons.push(( (localize({ key: 'yesButton', comment: ['&& denotes a mnemonic'] }, "&&Yes"))));
|
|
3329
|
+
}
|
|
3330
|
+
if (confirmation.secondaryButton) {
|
|
3331
|
+
buttons.push(confirmation.secondaryButton);
|
|
3332
|
+
}
|
|
3333
|
+
else if (typeof confirmation.secondaryButton === 'undefined') {
|
|
3334
|
+
buttons.push(( (localize('cancelButton', "Cancel"))));
|
|
3335
|
+
}
|
|
3336
|
+
const result = await this.doShow(confirmation.type, confirmation.message, buttons, confirmation.detail, 1, confirmation.checkbox);
|
|
3337
|
+
return { confirmed: result.button === 0, checkboxChecked: result.checkboxChecked };
|
|
3338
|
+
}
|
|
3339
|
+
getDialogType(severity) {
|
|
3340
|
+
return (severity === Severity$1.Info) ? 'question' : (severity === Severity$1.Error) ? 'error' : (severity === Severity$1.Warning) ? 'warning' : 'none';
|
|
3341
|
+
}
|
|
3342
|
+
async show(severity, message, buttons, options) {
|
|
3343
|
+
this.logService.trace('DialogService#show', message);
|
|
3344
|
+
const result = await this.doShow(this.getDialogType(severity), message, buttons, options?.detail, options?.cancelId, options?.checkbox, undefined, typeof options?.custom === 'object' ? options.custom : undefined);
|
|
3345
|
+
return {
|
|
3346
|
+
choice: result.button,
|
|
3347
|
+
checkboxChecked: result.checkboxChecked
|
|
3348
|
+
};
|
|
3349
|
+
}
|
|
3350
|
+
async doShow(type, message, buttons, detail, cancelId, checkbox, inputs, customOptions) {
|
|
3351
|
+
const dialogDisposables = ( (new DisposableStore()));
|
|
3352
|
+
const renderBody = customOptions ? (parent) => {
|
|
3353
|
+
parent.classList.add(...(customOptions.classes || []));
|
|
3354
|
+
customOptions.markdownDetails?.forEach(markdownDetail => {
|
|
3355
|
+
const result = this.markdownRenderer.render(markdownDetail.markdown);
|
|
3356
|
+
parent.appendChild(result.element);
|
|
3357
|
+
result.element.classList.add(...(markdownDetail.classes || []));
|
|
3358
|
+
dialogDisposables.add(result);
|
|
3359
|
+
});
|
|
3360
|
+
} : undefined;
|
|
3361
|
+
const dialog = ( (new Dialog(this.layoutService.container, message, buttons, {
|
|
3362
|
+
detail,
|
|
3363
|
+
cancelId,
|
|
3364
|
+
type,
|
|
3365
|
+
keyEventProcessor: (event) => {
|
|
3366
|
+
const resolved = this.keybindingService.softDispatch(event, this.layoutService.container);
|
|
3367
|
+
if (resolved?.commandId) {
|
|
3368
|
+
if (BrowserDialogHandler.ALLOWABLE_COMMANDS.indexOf(resolved.commandId) === -1) {
|
|
3369
|
+
EventHelper.stop(event, true);
|
|
3370
|
+
}
|
|
3371
|
+
}
|
|
3372
|
+
},
|
|
3373
|
+
renderBody,
|
|
3374
|
+
icon: customOptions?.icon,
|
|
3375
|
+
disableCloseAction: customOptions?.disableCloseAction,
|
|
3376
|
+
buttonDetails: customOptions?.buttonDetails,
|
|
3377
|
+
checkboxLabel: checkbox?.label,
|
|
3378
|
+
checkboxChecked: checkbox?.checked,
|
|
3379
|
+
inputs
|
|
3380
|
+
})));
|
|
3381
|
+
dialogDisposables.add(dialog);
|
|
3382
|
+
dialogDisposables.add(attachDialogStyler(dialog, this.themeService));
|
|
3383
|
+
const result = await dialog.show();
|
|
3384
|
+
dialogDisposables.dispose();
|
|
3385
|
+
return result;
|
|
3386
|
+
}
|
|
3387
|
+
async input(severity, message, buttons, inputs, options) {
|
|
3388
|
+
this.logService.trace('DialogService#input', message);
|
|
3389
|
+
const result = await this.doShow(this.getDialogType(severity), message, buttons, options?.detail, options?.cancelId, options?.checkbox, inputs);
|
|
3390
|
+
return {
|
|
3391
|
+
choice: result.button,
|
|
3392
|
+
checkboxChecked: result.checkboxChecked,
|
|
3393
|
+
values: result.values
|
|
3394
|
+
};
|
|
3395
|
+
}
|
|
3396
|
+
async about() {
|
|
3397
|
+
const detailString = (useAgo) => {
|
|
3398
|
+
return (
|
|
3399
|
+
(localize(
|
|
3400
|
+
'aboutDetail',
|
|
3401
|
+
"Version: {0}\nCommit: {1}\nDate: {2}\nBrowser: {3}",
|
|
3402
|
+
this.productService.version || 'Unknown',
|
|
3403
|
+
this.productService.commit || 'Unknown',
|
|
3404
|
+
this.productService.date ? `${this.productService.date}${useAgo ? ' (' + fromNow(( new Date(this.productService.date)), true) + ')' : ''}` : 'Unknown',
|
|
3405
|
+
navigator.userAgent
|
|
3406
|
+
))
|
|
3407
|
+
);
|
|
3408
|
+
};
|
|
3409
|
+
const detail = detailString(true);
|
|
3410
|
+
const detailToCopy = detailString(false);
|
|
3411
|
+
const { choice } = await this.show(Severity$1.Info, this.productService.nameLong, [( (localize('copy', "Copy"))), ( (localize('ok', "OK")))], { detail, cancelId: 1 });
|
|
3412
|
+
if (choice === 0) {
|
|
3413
|
+
this.clipboardService.writeText(detailToCopy);
|
|
3414
|
+
}
|
|
3415
|
+
}
|
|
3416
|
+
};
|
|
3417
|
+
BrowserDialogHandler.ALLOWABLE_COMMANDS = [
|
|
3418
|
+
'copy',
|
|
3419
|
+
'cut',
|
|
3420
|
+
'editor.action.selectAll',
|
|
3421
|
+
'editor.action.clipboardCopyAction',
|
|
3422
|
+
'editor.action.clipboardCutAction',
|
|
3423
|
+
'editor.action.clipboardPasteAction'
|
|
3424
|
+
];
|
|
3425
|
+
BrowserDialogHandler = ( (__decorate([
|
|
3426
|
+
( (__param(0, ILogService))),
|
|
3427
|
+
( (__param(1, ILayoutService))),
|
|
3428
|
+
( (__param(2, IThemeService))),
|
|
3429
|
+
( (__param(3, IKeybindingService))),
|
|
3430
|
+
( (__param(4, IInstantiationService))),
|
|
3431
|
+
( (__param(5, IProductService))),
|
|
3432
|
+
( (__param(6, IClipboardService)))
|
|
3433
|
+
], BrowserDialogHandler)));
|
|
3434
|
+
let DialogHandlerContribution = class DialogHandlerContribution extends Disposable {
|
|
3435
|
+
constructor(dialogService, logService, layoutService, themeService, keybindingService, instantiationService, productService, clipboardService) {
|
|
3436
|
+
super();
|
|
3437
|
+
this.dialogService = dialogService;
|
|
3438
|
+
this.impl = ( (new BrowserDialogHandler(
|
|
3439
|
+
logService,
|
|
3440
|
+
layoutService,
|
|
3441
|
+
themeService,
|
|
3442
|
+
keybindingService,
|
|
3443
|
+
instantiationService,
|
|
3444
|
+
productService,
|
|
3445
|
+
clipboardService
|
|
3446
|
+
)));
|
|
3447
|
+
this.model = this.dialogService.model;
|
|
3448
|
+
this._register(this.model.onWillShowDialog(() => {
|
|
3449
|
+
if (!this.currentDialog) {
|
|
3450
|
+
this.processDialogs();
|
|
3451
|
+
}
|
|
3452
|
+
}));
|
|
3453
|
+
this.processDialogs();
|
|
3454
|
+
}
|
|
3455
|
+
async processDialogs() {
|
|
3456
|
+
while (this.model.dialogs.length) {
|
|
3457
|
+
this.currentDialog = this.model.dialogs[0];
|
|
3458
|
+
let result = undefined;
|
|
3459
|
+
if (this.currentDialog.args.confirmArgs) {
|
|
3460
|
+
const args = this.currentDialog.args.confirmArgs;
|
|
3461
|
+
result = await this.impl.confirm(args.confirmation);
|
|
3462
|
+
}
|
|
3463
|
+
else if (this.currentDialog.args.inputArgs) {
|
|
3464
|
+
const args = this.currentDialog.args.inputArgs;
|
|
3465
|
+
result = await this.impl.input(args.severity, args.message, args.buttons, args.inputs, args.options);
|
|
3466
|
+
}
|
|
3467
|
+
else if (this.currentDialog.args.showArgs) {
|
|
3468
|
+
const args = this.currentDialog.args.showArgs;
|
|
3469
|
+
result = await this.impl.show(args.severity, args.message, args.buttons, args.options);
|
|
3470
|
+
}
|
|
3471
|
+
else {
|
|
3472
|
+
await this.impl.about();
|
|
3473
|
+
}
|
|
3474
|
+
this.currentDialog.close(result);
|
|
3475
|
+
this.currentDialog = undefined;
|
|
3476
|
+
}
|
|
3477
|
+
}
|
|
3478
|
+
};
|
|
3479
|
+
DialogHandlerContribution = ( (__decorate([
|
|
3480
|
+
( (__param(0, IDialogService))),
|
|
3481
|
+
( (__param(1, ILogService))),
|
|
3482
|
+
( (__param(2, ILayoutService))),
|
|
3483
|
+
( (__param(3, IThemeService))),
|
|
3484
|
+
( (__param(4, IKeybindingService))),
|
|
3485
|
+
( (__param(5, IInstantiationService))),
|
|
3486
|
+
( (__param(6, IProductService))),
|
|
3487
|
+
( (__param(7, IClipboardService)))
|
|
3488
|
+
], DialogHandlerContribution)));
|
|
3489
|
+
class DialogsModel extends Disposable {
|
|
3490
|
+
constructor() {
|
|
3491
|
+
super(...arguments);
|
|
3492
|
+
this.dialogs = [];
|
|
3493
|
+
this._onWillShowDialog = this._register(( (new Emitter())));
|
|
3494
|
+
this.onWillShowDialog = this._onWillShowDialog.event;
|
|
3495
|
+
this._onDidShowDialog = this._register(( (new Emitter())));
|
|
3496
|
+
this.onDidShowDialog = this._onDidShowDialog.event;
|
|
3497
|
+
}
|
|
3498
|
+
show(dialog) {
|
|
3499
|
+
const promise = ( (new DeferredPromise()));
|
|
3500
|
+
const item = {
|
|
3501
|
+
args: dialog,
|
|
3502
|
+
close: result => {
|
|
3503
|
+
this.dialogs.splice(0, 1);
|
|
3504
|
+
promise.complete(result);
|
|
3505
|
+
this._onDidShowDialog.fire();
|
|
3506
|
+
}
|
|
3507
|
+
};
|
|
3508
|
+
this.dialogs.push(item);
|
|
3509
|
+
this._onWillShowDialog.fire();
|
|
3510
|
+
return {
|
|
3511
|
+
item,
|
|
3512
|
+
result: promise.p
|
|
3513
|
+
};
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3516
|
+
let DialogService = class DialogService extends Disposable {
|
|
3517
|
+
constructor(environmentService, logService) {
|
|
3518
|
+
super();
|
|
3519
|
+
this.environmentService = environmentService;
|
|
3520
|
+
this.logService = logService;
|
|
3521
|
+
this.model = this._register(( (new DialogsModel())));
|
|
3522
|
+
this.onWillShowDialog = this.model.onWillShowDialog;
|
|
3523
|
+
this.onDidShowDialog = this.model.onDidShowDialog;
|
|
3524
|
+
}
|
|
3525
|
+
skipDialogs() {
|
|
3526
|
+
if (this.environmentService.isExtensionDevelopment && this.environmentService.extensionTestsLocationURI) {
|
|
3527
|
+
return true;
|
|
3528
|
+
}
|
|
3529
|
+
return !!this.environmentService.enableSmokeTestDriver;
|
|
3530
|
+
}
|
|
3531
|
+
async confirm(confirmation) {
|
|
3532
|
+
if (this.skipDialogs()) {
|
|
3533
|
+
this.logService.trace('DialogService: refused to show confirmation dialog in tests.');
|
|
3534
|
+
return { confirmed: true };
|
|
3535
|
+
}
|
|
3536
|
+
const handle = this.model.show({ confirmArgs: { confirmation } });
|
|
3537
|
+
return await handle.result;
|
|
3538
|
+
}
|
|
3539
|
+
async show(severity, message, buttons, options) {
|
|
3540
|
+
if (this.skipDialogs()) {
|
|
3541
|
+
throw new Error('DialogService: refused to show dialog in tests.');
|
|
3542
|
+
}
|
|
3543
|
+
const handle = this.model.show({ showArgs: { severity, message, buttons, options } });
|
|
3544
|
+
return await handle.result;
|
|
3545
|
+
}
|
|
3546
|
+
async input(severity, message, buttons, inputs, options) {
|
|
3547
|
+
if (this.skipDialogs()) {
|
|
3548
|
+
throw new Error('DialogService: refused to show input dialog in tests.');
|
|
3549
|
+
}
|
|
3550
|
+
const handle = this.model.show({ inputArgs: { severity, message, buttons, inputs, options } });
|
|
3551
|
+
return await handle.result;
|
|
3552
|
+
}
|
|
3553
|
+
async about() {
|
|
3554
|
+
if (this.skipDialogs()) {
|
|
3555
|
+
throw new Error('DialogService: refused to show about dialog in tests.');
|
|
3556
|
+
}
|
|
3557
|
+
const handle = this.model.show({});
|
|
3558
|
+
await handle.result;
|
|
3559
|
+
}
|
|
3560
|
+
};
|
|
3561
|
+
DialogService = ( (__decorate([
|
|
3562
|
+
( (__param(0, IWorkbenchEnvironmentService))),
|
|
3563
|
+
( (__param(1, ILogService)))
|
|
3564
|
+
], DialogService)));
|
|
3565
|
+
class LayoutService {
|
|
3566
|
+
constructor(container) {
|
|
3567
|
+
this.container = container;
|
|
3568
|
+
this.offset = { top: 0, quickPickTop: 0 };
|
|
3569
|
+
this._onDidLayout = new Emitter();
|
|
3570
|
+
this.onDidLayout = this._onDidLayout.event;
|
|
3571
|
+
window.addEventListener('resize', () => this.layout());
|
|
3572
|
+
this.layout();
|
|
3573
|
+
}
|
|
3574
|
+
isVisible() {
|
|
3575
|
+
return false;
|
|
3576
|
+
}
|
|
3577
|
+
get dimension() { return this._dimension; }
|
|
3578
|
+
layout() {
|
|
3579
|
+
this._dimension = getClientArea(window.document.body);
|
|
3580
|
+
this._onDidLayout.fire(this._dimension);
|
|
3581
|
+
}
|
|
3582
|
+
get hasContainer() {
|
|
3583
|
+
return true;
|
|
3584
|
+
}
|
|
3585
|
+
focus() {
|
|
3586
|
+
StandaloneServices.get(ICodeEditorService).getFocusedCodeEditor()?.focus();
|
|
3587
|
+
}
|
|
3588
|
+
}
|
|
3589
|
+
function getServiceOverride$1(container = document.body) {
|
|
3590
|
+
return {
|
|
3591
|
+
[( ILayoutService.toString())]: new SyncDescriptor(LayoutService, [container]),
|
|
3592
|
+
[( IWorkbenchLayoutService.toString())]: new SyncDescriptor(LayoutService, [container])
|
|
3593
|
+
};
|
|
3594
|
+
}
|
|
3595
|
+
function initialize(instantiationService) {
|
|
3596
|
+
const container = StandaloneServices.get(ILayoutService).container;
|
|
3597
|
+
container.classList.add('monaco-workbench');
|
|
3598
|
+
const model = instantiationService.invokeFunction((accessor) => accessor.get(INotificationService)).model;
|
|
3599
|
+
const notificationsToasts = instantiationService.createInstance(NotificationsToasts, container, model);
|
|
3600
|
+
notificationsToasts.layout(getClientArea(container));
|
|
3601
|
+
const notificationsCenter = {
|
|
3602
|
+
isVisible: false,
|
|
3603
|
+
show: unsupported,
|
|
3604
|
+
hide: unsupported,
|
|
3605
|
+
clearAll: function () {
|
|
3606
|
+
for (const notification of [...model.notifications] ) {
|
|
3607
|
+
if (!notification.hasProgress) {
|
|
3608
|
+
notification.close();
|
|
3609
|
+
}
|
|
3610
|
+
}
|
|
3611
|
+
}
|
|
3612
|
+
};
|
|
3613
|
+
registerNotificationCommands(notificationsCenter, notificationsToasts, model);
|
|
3614
|
+
instantiationService.createInstance(DialogHandlerContribution);
|
|
3615
|
+
}
|
|
3616
|
+
function getServiceOverride(container) {
|
|
3617
|
+
onServicesInitialized(initialize);
|
|
3618
|
+
return {
|
|
3619
|
+
[( IDialogService.toString())]: new SyncDescriptor(DialogService),
|
|
3620
|
+
[( INotificationService.toString())]: new SyncDescriptor(NotificationService),
|
|
3621
|
+
...getServiceOverride$1(container)
|
|
3622
|
+
};
|
|
3623
|
+
}
|
|
3624
|
+
export { getServiceOverride as default };
|