@finos/legend-application-studio
Version:
Legend Studio application core
109 lines • 9.18 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
* Copyright (c) 2020-present, Goldman Sachs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { useState } from 'react';
import { BlankPanelContent, BundleIcon, ChevronDownIcon, ChevronRightIcon, CopyIcon, Dialog, InfoCircleIcon, Modal, ModalBody, ModalHeader, ModalHeaderActions, ModalTitle, PluginIcon, TimesIcon, TreeView, } from '@finos/legend-art';
import { addUniqueEntry, isNonNullable, PresetInfo, } from '@finos/legend-shared';
import { useLegendStudioApplicationStore } from './LegendStudioFrameworkProvider.js';
class AppExtensionInfoTreeNodeData {
id;
label;
isSelected;
isOpen;
childrenIds;
info;
constructor(id, label, info) {
this.id = id;
this.label = label;
this.info = info;
}
}
const buildAppExtensionInfoTreeData = (pluginManagerInfo) => {
const rootIds = [];
const nodes = new Map();
// NOTE: the returned plugin manager extension info is already sorted
// so we don't need to do that anymore
pluginManagerInfo.presets.forEach((preset) => {
const node = new AppExtensionInfoTreeNodeData(preset.signature, preset.name, preset);
addUniqueEntry(rootIds, node.id);
nodes.set(node.id, node);
if (preset.plugins.length) {
node.childrenIds = [];
preset.plugins.forEach((plugin) => {
const childNode = new AppExtensionInfoTreeNodeData(plugin.signature, plugin.name, plugin);
addUniqueEntry(node.childrenIds, childNode.id);
nodes.set(childNode.id, childNode);
});
}
});
pluginManagerInfo.plugins.forEach((plugin) => {
const node = new AppExtensionInfoTreeNodeData(plugin.signature, plugin.name, plugin);
addUniqueEntry(rootIds, node.id);
nodes.set(node.id, node);
});
return { rootIds, nodes };
};
const AppExtensionInfoTreeNodeContainer = (props) => {
const { node, level, stepPaddingInRem, onNodeSelect } = props;
const isExpandable = Boolean(node.childrenIds?.length);
const nodeTypeIcon = node.info instanceof PresetInfo ? _jsx(BundleIcon, {}) : _jsx(PluginIcon, {});
const selectNode = () => onNodeSelect?.(node);
const nodeExpandIcon = isExpandable ? (node.isOpen ? (_jsx(ChevronDownIcon, {})) : (_jsx(ChevronRightIcon, {}))) : (_jsx("div", {}));
return (_jsxs("div", { className: "tree-view__node__container", onClick: selectNode, style: {
paddingLeft: `${(level - 1) * (stepPaddingInRem ?? 2)}rem`,
display: 'flex',
}, children: [_jsxs("div", { className: "app__info__extensions__tree__node__icon", children: [_jsx("div", { className: "app__info__extensions__tree__node__icon__expand", children: nodeExpandIcon }), _jsx("div", { className: "app__info__extensions__tree__node__icon__type", children: nodeTypeIcon })] }), _jsxs("div", { className: "tree-view__node__label app__info__extensions__tree__node__label", children: [_jsx("div", { className: "app__info__extensions__tree__node__label__title", children: node.label }), _jsx("div", { className: "app__info__extensions__tree__node__label__version", children: _jsx("div", { className: "app__info__extensions__tree__node__label__version__label", children: node.info.version }) })] })] }));
};
export const LegendStudioAppInfo = (props) => {
const { open, closeModal } = props;
const applicationStore = useLegendStudioApplicationStore();
const config = applicationStore.config;
const copyInfo = () => {
applicationStore.clipboardService
.copyTextToClipboard([
`Environment: ${config.env}`,
`Version: ${config.appVersion}`,
`Revision: ${config.appVersionCommitId}`,
`Build Time: ${config.appVersionBuildTime}`,
`SDLC Server: ${config.sdlcServerUrl}`,
`Engine Server: ${config.engineServerUrl}`,
`Depot Server: ${config.depotServerUrl}`,
]
.filter(isNonNullable)
.join('\n'))
.then(() => applicationStore.notificationService.notifySuccess('Copied application info to clipboard'))
.catch(applicationStore.alertUnhandledError);
};
const [appExtensionInfoTreeData, setAppExtensionInfoTreeData] = useState(buildAppExtensionInfoTreeData(applicationStore.pluginManager.getInfo()));
const onAppExtensionInfoTreeNodeSelect = (node) => {
if (node.childrenIds?.length) {
node.isOpen = !node.isOpen;
}
setAppExtensionInfoTreeData({ ...appExtensionInfoTreeData });
};
const getAppExtensionInfoTreeChildNodes = (node) => node.childrenIds
?.map((id) => appExtensionInfoTreeData.nodes.get(id))
.filter(isNonNullable) ?? [];
const isAppExtensionInfoEmpty = !appExtensionInfoTreeData.nodes.size;
const goToReleaseLog = () => {
applicationStore.releaseNotesService.setReleaseLog(true);
closeModal();
};
return (_jsx(Dialog, { onClose: closeModal, open: open, children: _jsxs(Modal, { darkMode: !applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled, className: "modal--scrollable app__info", children: [_jsxs(ModalHeader, { children: [_jsx(ModalTitle, { icon: _jsx(InfoCircleIcon, {}), title: "About" }), _jsxs(ModalHeaderActions, { children: [_jsx("button", { className: "modal__header__action", tabIndex: -1, onClick: copyInfo, title: "Copy application info", children: _jsx(CopyIcon, {}) }), _jsx("button", { className: "modal__header__action", tabIndex: -1, onClick: closeModal, children: _jsx(TimesIcon, {}) })] })] }), _jsxs(ModalBody, { children: [_jsxs("div", { className: "app__info__entry", children: [_jsx("div", { className: "app__info__entry__title", children: "Environment:" }), _jsx("div", { className: "app__info__entry__value", children: config.env })] }), _jsxs("div", { className: "app__info__entry", children: [_jsx("div", { className: "app__info__entry__title", children: "Version:" }), _jsx("div", { className: "app__info__entry__value", children: config.appVersion })] }), _jsxs("div", { className: "app__info__entry", children: [_jsx("div", { className: "app__info__entry__title", children: "Revision:" }), _jsx("div", { className: "app__info__entry__value", children: config.appVersionCommitId })] }), _jsxs("div", { className: "app__info__entry", children: [_jsx("div", { className: "app__info__entry__title", children: "Build Time:" }), _jsx("div", { className: "app__info__entry__value", children: config.appVersionBuildTime })] }), _jsx("div", { className: "app__info__entry", children: _jsx("div", { onClick: goToReleaseLog, className: "app__info__entry__value app__info__entry__value__action", children: "Details of Released Versions" }) }), _jsxs("div", { className: "app__info__group", children: [_jsxs("div", { className: "app__info__entry", children: [_jsx("div", { className: "app__info__entry__title", children: "SDLC Server:" }), _jsx("div", { className: "app__info__entry__value", children: _jsx("a", { href: config.sdlcServerUrl, target: "_blank", rel: "noopener noreferrer", children: config.sdlcServerUrl }) })] }), _jsxs("div", { className: "app__info__entry", children: [_jsx("div", { className: "app__info__entry__title", children: "Engine Server:" }), _jsx("div", { className: "app__info__entry__value", children: _jsx("a", { href: config.engineServerUrl, target: "_blank", rel: "noopener noreferrer", children: config.engineServerUrl }) })] }), _jsxs("div", { className: "app__info__entry", children: [_jsx("div", { className: "app__info__entry__title", children: "Depot Server:" }), _jsx("div", { className: "app__info__entry__value", children: _jsx("a", { href: config.depotServerUrl, target: "_blank", rel: "noopener noreferrer", children: config.depotServerUrl }) })] })] }), _jsxs("div", { className: "app__info__extensions", children: [_jsx("div", { className: "app__info__extensions__header", children: _jsx("div", { className: "app__info__extensions__header__title", children: "EXTENSIONS" }) }), _jsxs("div", { className: "app__info__extensions__content", children: [isAppExtensionInfoEmpty && (_jsx(BlankPanelContent, { children: "no extensions available" })), !isAppExtensionInfoEmpty && (_jsx(TreeView, { components: {
TreeNodeContainer: AppExtensionInfoTreeNodeContainer,
}, treeData: appExtensionInfoTreeData, getChildNodes: getAppExtensionInfoTreeChildNodes, onNodeSelect: onAppExtensionInfoTreeNodeSelect, innerProps: {} }))] })] })] })] }) }));
};
//# sourceMappingURL=LegendStudioAppInfo.js.map