UNPKG

6.21 kBJavaScriptView Raw
1"use strict";
2// *****************************************************************************
3// Copyright (C) 2018 Ericsson and others.
4//
5// This program and the accompanying materials are made available under the
6// terms of the Eclipse Public License v. 2.0 which is available at
7// http://www.eclipse.org/legal/epl-2.0.
8//
9// This Source Code may also be made available under the following Secondary
10// Licenses when the conditions for such availability set forth in the Eclipse
11// Public License v. 2.0 are satisfied: GNU General Public License, version 2
12// with the GNU Classpath Exception which is available at
13// https://www.gnu.org/software/classpath/license.html.
14//
15// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16// *****************************************************************************
17Object.defineProperty(exports, "__esModule", { value: true });
18exports.AboutDialog = exports.AboutDialogProps = exports.ABOUT_EXTENSIONS_CLASS = exports.ABOUT_CONTENT_CLASS = void 0;
19const tslib_1 = require("tslib");
20const React = require("react");
21const inversify_1 = require("inversify");
22const dialogs_1 = require("./dialogs");
23const react_dialog_1 = require("./dialogs/react-dialog");
24const application_protocol_1 = require("../common/application-protocol");
25const frontend_application_config_provider_1 = require("./frontend-application-config-provider");
26const api_1 = require("@theia/application-package/lib/api");
27const window_service_1 = require("./window/window-service");
28const keys_1 = require("./keys");
29const nls_1 = require("../common/nls");
30exports.ABOUT_CONTENT_CLASS = 'theia-aboutDialog';
31exports.ABOUT_EXTENSIONS_CLASS = 'theia-aboutExtensions';
32let AboutDialogProps = class AboutDialogProps extends dialogs_1.DialogProps {
33};
34AboutDialogProps = (0, tslib_1.__decorate)([
35 (0, inversify_1.injectable)()
36], AboutDialogProps);
37exports.AboutDialogProps = AboutDialogProps;
38let AboutDialog = class AboutDialog extends react_dialog_1.ReactDialog {
39 constructor(props) {
40 super({
41 title: frontend_application_config_provider_1.FrontendApplicationConfigProvider.get().applicationName,
42 });
43 this.props = props;
44 this.extensionsInfos = [];
45 /**
46 * Open a link in an external window.
47 * @param url the link.
48 */
49 this.doOpenExternalLink = (url) => this.windowService.openNewWindow(url, { external: true });
50 this.doOpenExternalLinkEnter = (e, url) => {
51 if (this.isEnterKey(e)) {
52 this.doOpenExternalLink(url);
53 }
54 };
55 this.appendAcceptButton(dialogs_1.Dialog.OK);
56 }
57 init() {
58 this.doInit();
59 }
60 async doInit() {
61 this.applicationInfo = await this.appServer.getApplicationInfo();
62 this.extensionsInfos = await this.appServer.getExtensionsInfos();
63 this.update();
64 }
65 renderHeader() {
66 const applicationInfo = this.applicationInfo;
67 const compatibilityUrl = 'https://eclipse-theia.github.io/vscode-theia-comparator/status.html';
68 const detailsLabel = nls_1.nls.localizeByDefault('Details');
69 const versionLabel = nls_1.nls.localize('theia/core/about/version', 'Version');
70 const defaultApiLabel = nls_1.nls.localize('theia/core/about/defaultApi', 'Default {0} API', 'VS Code');
71 const compatibilityLabel = nls_1.nls.localize('theia/core/about/compatibility', '{0} Compatibility', 'VS Code');
72 return React.createElement(React.Fragment, null,
73 React.createElement("h3", null, detailsLabel),
74 React.createElement("div", { className: 'about-details' },
75 applicationInfo && React.createElement("p", null, `${versionLabel}: ${applicationInfo.version}`),
76 React.createElement("p", null, `${defaultApiLabel}: ${api_1.DEFAULT_SUPPORTED_API_VERSION}`),
77 React.createElement("p", null,
78 React.createElement("a", { role: 'button', tabIndex: 0, onClick: () => this.doOpenExternalLink(compatibilityUrl), onKeyDown: (e) => this.doOpenExternalLinkEnter(e, compatibilityUrl) }, compatibilityLabel))));
79 }
80 renderExtensions() {
81 const extensionsInfos = this.extensionsInfos;
82 return React.createElement(React.Fragment, null,
83 React.createElement("h3", null, "List of extensions"),
84 React.createElement("ul", { className: exports.ABOUT_EXTENSIONS_CLASS }, extensionsInfos
85 .sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase()))
86 .map((extension) => React.createElement("li", { key: extension.name },
87 extension.name,
88 " ",
89 extension.version))));
90 }
91 render() {
92 return React.createElement("div", { className: exports.ABOUT_CONTENT_CLASS },
93 this.renderHeader(),
94 this.renderExtensions());
95 }
96 onAfterAttach(msg) {
97 super.onAfterAttach(msg);
98 this.update();
99 }
100 isEnterKey(e) {
101 var _a;
102 return keys_1.Key.ENTER.keyCode === ((_a = keys_1.KeyCode.createKeyCode(e.nativeEvent).key) === null || _a === void 0 ? void 0 : _a.keyCode);
103 }
104 get value() { return undefined; }
105};
106(0, tslib_1.__decorate)([
107 (0, inversify_1.inject)(application_protocol_1.ApplicationServer),
108 (0, tslib_1.__metadata)("design:type", Object)
109], AboutDialog.prototype, "appServer", void 0);
110(0, tslib_1.__decorate)([
111 (0, inversify_1.inject)(window_service_1.WindowService),
112 (0, tslib_1.__metadata)("design:type", Object)
113], AboutDialog.prototype, "windowService", void 0);
114(0, tslib_1.__decorate)([
115 (0, inversify_1.postConstruct)(),
116 (0, tslib_1.__metadata)("design:type", Function),
117 (0, tslib_1.__metadata)("design:paramtypes", []),
118 (0, tslib_1.__metadata)("design:returntype", void 0)
119], AboutDialog.prototype, "init", null);
120AboutDialog = (0, tslib_1.__decorate)([
121 (0, inversify_1.injectable)(),
122 (0, tslib_1.__param)(0, (0, inversify_1.inject)(AboutDialogProps)),
123 (0, tslib_1.__metadata)("design:paramtypes", [AboutDialogProps])
124], AboutDialog);
125exports.AboutDialog = AboutDialog;
126//# sourceMappingURL=about-dialog.js.map
\No newline at end of file