UNPKG

@theia/core

Version:

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

90 lines • 4.58 kB
import { __decorate, __param } from "tslib"; import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; import { inject, injectable, postConstruct } from 'inversify'; import { Dialog, DialogProps } from './dialogs.js'; import { ReactDialog } from './dialogs/react-dialog.js'; import { ApplicationServer } from '../common/application-protocol.js'; import { FrontendApplicationConfigProvider } from './frontend-application-config-provider.js'; import { DEFAULT_SUPPORTED_API_VERSION, DEFAULT_SUPPORTED_MONACO_VERSION } from '@theia/application-package/lib/api'; import { WindowService } from './window/window-service.js'; import { Key, KeyCode } from './keys.js'; import { nls } from '../common/nls.js'; export const ABOUT_CONTENT_CLASS = 'theia-aboutDialog'; export const ABOUT_EXTENSIONS_CLASS = 'theia-aboutExtensions'; let AboutDialogProps = class AboutDialogProps extends DialogProps { }; AboutDialogProps = __decorate([ injectable() ], AboutDialogProps); export { AboutDialogProps }; let AboutDialog = class AboutDialog extends ReactDialog { constructor(props) { super({ title: 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(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.localizeByDefault('Details'); const versionLabel = nls.localizeByDefault('Version'); const defaultApiLabel = nls.localize('theia/core/about/defaultApi', 'Default {0} API', 'VS Code'); const compatibilityLabel = nls.localize('theia/core/about/compatibility', '{0} Compatibility', 'VS Code'); const monacoLabel = nls.localize('theia/core/about/monacoEditor', 'Monaco Editor Version'); return _jsxs(_Fragment, { children: [_jsx("h3", { children: detailsLabel }), _jsxs("div", { className: 'about-details', children: [applicationInfo && _jsx("p", { children: `${versionLabel}: ${applicationInfo.version}` }), _jsx("p", { children: `${defaultApiLabel}: ${DEFAULT_SUPPORTED_API_VERSION}` }), _jsx("p", { children: _jsx("a", { role: 'button', tabIndex: 0, onClick: () => this.doOpenExternalLink(compatibilityUrl), onKeyDown: (e) => this.doOpenExternalLinkEnter(e, compatibilityUrl), children: compatibilityLabel }) }), _jsx("p", { children: `${monacoLabel}: ${DEFAULT_SUPPORTED_MONACO_VERSION}` })] })] }); } renderExtensions() { const extensionsInfos = this.extensionsInfos; const listOfExtensions = nls.localize('theia/core/about/listOfExtensions', 'List of extensions'); return _jsxs(_Fragment, { children: [_jsx("h3", { children: listOfExtensions }), _jsx("ul", { className: ABOUT_EXTENSIONS_CLASS, children: extensionsInfos .sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase())) .map((extension) => _jsxs("li", { children: [extension.name, " ", extension.version] }, extension.name)) })] }); } render() { return _jsxs("div", { className: ABOUT_CONTENT_CLASS, children: [this.renderHeader(), this.renderExtensions()] }); } onAfterAttach(msg) { super.onAfterAttach(msg); this.update(); } isEnterKey(e) { return Key.ENTER.keyCode === KeyCode.createKeyCode(e.nativeEvent).key?.keyCode; } get value() { return undefined; } }; __decorate([ inject(ApplicationServer) ], AboutDialog.prototype, "appServer", void 0); __decorate([ inject(WindowService) ], AboutDialog.prototype, "windowService", void 0); __decorate([ postConstruct() ], AboutDialog.prototype, "init", null); AboutDialog = __decorate([ injectable(), __param(0, inject(AboutDialogProps)) ], AboutDialog); export { AboutDialog }; //# sourceMappingURL=about-dialog.js.map