UNPKG

@theia/core

Version:

Theia is a cloud & desktop IDE framework implemented in TypeScript.

127 lines • 6.29 kB
"use strict"; // ***************************************************************************** // Copyright (C) 2018 Ericsson and others. // // This program and the accompanying materials are made available under the // terms of the Eclipse Public License v. 2.0 which is available at // http://www.eclipse.org/legal/epl-2.0. // // This Source Code may also be made available under the following Secondary // Licenses when the conditions for such availability set forth in the Eclipse // Public License v. 2.0 are satisfied: GNU General Public License, version 2 // with the GNU Classpath Exception which is available at // https://www.gnu.org/software/classpath/license.html. // // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 // ***************************************************************************** Object.defineProperty(exports, "__esModule", { value: true }); exports.AboutDialog = exports.AboutDialogProps = exports.ABOUT_EXTENSIONS_CLASS = exports.ABOUT_CONTENT_CLASS = void 0; const tslib_1 = require("tslib"); const React = require("react"); const inversify_1 = require("inversify"); const dialogs_1 = require("./dialogs"); const react_dialog_1 = require("./dialogs/react-dialog"); const application_protocol_1 = require("../common/application-protocol"); const frontend_application_config_provider_1 = require("./frontend-application-config-provider"); const api_1 = require("@theia/application-package/lib/api"); const window_service_1 = require("./window/window-service"); const keys_1 = require("./keys"); const nls_1 = require("../common/nls"); exports.ABOUT_CONTENT_CLASS = 'theia-aboutDialog'; exports.ABOUT_EXTENSIONS_CLASS = 'theia-aboutExtensions'; let AboutDialogProps = class AboutDialogProps extends dialogs_1.DialogProps { }; exports.AboutDialogProps = AboutDialogProps; exports.AboutDialogProps = AboutDialogProps = tslib_1.__decorate([ (0, inversify_1.injectable)() ], AboutDialogProps); let AboutDialog = class AboutDialog extends react_dialog_1.ReactDialog { constructor(props) { super({ title: frontend_application_config_provider_1.FrontendApplicationConfigProvider.get().applicationName, }); this.props = props; this.extensionsInfos = []; /** * Open a link in an external window. * @param url the link. */ this.doOpenExternalLink = (url) => this.windowService.openNewWindow(url, { external: true }); this.doOpenExternalLinkEnter = (e, url) => { if (this.isEnterKey(e)) { this.doOpenExternalLink(url); } }; this.appendAcceptButton(dialogs_1.Dialog.OK); } init() { this.doInit(); } async doInit() { this.applicationInfo = await this.appServer.getApplicationInfo(); this.extensionsInfos = await this.appServer.getExtensionsInfos(); this.update(); } renderHeader() { const applicationInfo = this.applicationInfo; const compatibilityUrl = 'https://eclipse-theia.github.io/vscode-theia-comparator/status.html'; const detailsLabel = nls_1.nls.localizeByDefault('Details'); const versionLabel = nls_1.nls.localizeByDefault('Version'); const defaultApiLabel = nls_1.nls.localize('theia/core/about/defaultApi', 'Default {0} API', 'VS Code'); const compatibilityLabel = nls_1.nls.localize('theia/core/about/compatibility', '{0} Compatibility', 'VS Code'); return React.createElement(React.Fragment, null, React.createElement("h3", null, detailsLabel), React.createElement("div", { className: 'about-details' }, applicationInfo && React.createElement("p", null, `${versionLabel}: ${applicationInfo.version}`), React.createElement("p", null, `${defaultApiLabel}: ${api_1.DEFAULT_SUPPORTED_API_VERSION}`), React.createElement("p", null, React.createElement("a", { role: 'button', tabIndex: 0, onClick: () => this.doOpenExternalLink(compatibilityUrl), onKeyDown: (e) => this.doOpenExternalLinkEnter(e, compatibilityUrl) }, compatibilityLabel)))); } renderExtensions() { const extensionsInfos = this.extensionsInfos; const listOfExtensions = nls_1.nls.localize('theia/core/about/listOfExtensions', 'List of extensions'); return React.createElement(React.Fragment, null, React.createElement("h3", null, listOfExtensions), React.createElement("ul", { className: exports.ABOUT_EXTENSIONS_CLASS }, extensionsInfos .sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase())) .map((extension) => React.createElement("li", { key: extension.name }, extension.name, " ", extension.version)))); } render() { return React.createElement("div", { className: exports.ABOUT_CONTENT_CLASS }, this.renderHeader(), this.renderExtensions()); } onAfterAttach(msg) { super.onAfterAttach(msg); this.update(); } isEnterKey(e) { var _a; return keys_1.Key.ENTER.keyCode === ((_a = keys_1.KeyCode.createKeyCode(e.nativeEvent).key) === null || _a === void 0 ? void 0 : _a.keyCode); } get value() { return undefined; } }; exports.AboutDialog = AboutDialog; tslib_1.__decorate([ (0, inversify_1.inject)(application_protocol_1.ApplicationServer), tslib_1.__metadata("design:type", Object) ], AboutDialog.prototype, "appServer", void 0); tslib_1.__decorate([ (0, inversify_1.inject)(window_service_1.WindowService), tslib_1.__metadata("design:type", Object) ], AboutDialog.prototype, "windowService", void 0); tslib_1.__decorate([ (0, inversify_1.postConstruct)(), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", []), tslib_1.__metadata("design:returntype", void 0) ], AboutDialog.prototype, "init", null); exports.AboutDialog = AboutDialog = tslib_1.__decorate([ (0, inversify_1.injectable)(), tslib_1.__param(0, (0, inversify_1.inject)(AboutDialogProps)), tslib_1.__metadata("design:paramtypes", [AboutDialogProps]) ], AboutDialog); //# sourceMappingURL=about-dialog.js.map