Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/browser/parts/dialogs/dialog.ts
13401 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { EventHelper } from '../../../../base/browser/dom.js';
7
import { StandardKeyboardEvent } from '../../../../base/browser/keyboardEvent.js';
8
import { IDialogOptions } from '../../../../base/browser/ui/dialog/dialog.js';
9
import { fromNow } from '../../../../base/common/date.js';
10
import { localize } from '../../../../nls.js';
11
import { IHostService } from '../../../services/host/browser/host.js';
12
import { IKeybindingService } from '../../../../platform/keybinding/common/keybinding.js';
13
import { ResultKind } from '../../../../platform/keybinding/common/keybindingResolver.js';
14
import { ILayoutService } from '../../../../platform/layout/browser/layoutService.js';
15
import { IProductService } from '../../../../platform/product/common/productService.js';
16
import { defaultButtonStyles, defaultCheckboxStyles, defaultInputBoxStyles, defaultDialogStyles } from '../../../../platform/theme/browser/defaultStyles.js';
17
18
const defaultDialogAllowableCommands = new Set([
19
'workbench.action.quit',
20
'workbench.action.reloadWindow',
21
'copy',
22
'cut',
23
'editor.action.selectAll',
24
'editor.action.clipboardCopyAction',
25
'editor.action.clipboardCutAction',
26
'editor.action.clipboardPasteAction'
27
]);
28
29
export function createWorkbenchDialogOptions(options: Partial<IDialogOptions>, keybindingService: IKeybindingService, layoutService: ILayoutService, hostService: IHostService, allowableCommands = defaultDialogAllowableCommands): IDialogOptions {
30
return {
31
keyEventProcessor: (event: StandardKeyboardEvent) => {
32
const resolved = keybindingService.softDispatch(event, layoutService.activeContainer);
33
if (resolved.kind === ResultKind.KbFound && resolved.commandId) {
34
if (!allowableCommands.has(resolved.commandId)) {
35
EventHelper.stop(event, true);
36
}
37
}
38
},
39
buttonStyles: defaultButtonStyles,
40
checkboxStyles: defaultCheckboxStyles,
41
inputBoxStyles: defaultInputBoxStyles,
42
dialogStyles: defaultDialogStyles,
43
onVisibilityChange: (window, visible) => hostService.setWindowDimmed(window, visible),
44
...options
45
};
46
}
47
48
export function createBrowserAboutDialogDetails(productService: IProductService): { title: string; details: string; detailsToCopy: string } {
49
const detailString = (useAgo: boolean): string => {
50
return localize('aboutDetail',
51
"Version: {0}\nCommit: {1}\nDate: {2}\nBrowser: {3}",
52
productService.version || 'Unknown',
53
productService.commit || 'Unknown',
54
productService.date ? `${productService.date}${useAgo ? ' (' + fromNow(new Date(productService.date), true) + ')' : ''}` : 'Unknown',
55
navigator.userAgent
56
);
57
};
58
59
const details = detailString(true);
60
const detailsToCopy = detailString(false);
61
62
return {
63
title: productService.nameLong,
64
details: details,
65
detailsToCopy: detailsToCopy
66
};
67
}
68
69
70