@finos/legend-application-marketplace
Version:
Legend Marketplace application core
73 lines • 5.06 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useLegendMarketplaceBaseStore } from '../../application/providers/LegendMarketplaceFrameworkProvider.js';
import { isNonNullable, isValidUrl } from '@finos/legend-shared';
import { CopyIcon, Dialog, InfoCircleIcon, Modal, ModalBody, ModalHeader, ModalHeaderActions, ModalTitle, TimesIcon, } from '@finos/legend-art';
import { observer } from 'mobx-react-lite';
import { TextField } from '@mui/material';
export const LegendMarketplaceAppInfo = observer((props) => {
const { open, closeModal } = props;
const legendMarketplaceBaseStore = useLegendMarketplaceBaseStore();
const applicationStore = legendMarketplaceBaseStore.applicationStore;
const config = applicationStore.config;
const configData = [
{
label: 'Environment',
value: config.env,
},
{
label: 'Version',
value: config.appVersion,
},
{
label: 'Revision',
value: config.appVersionCommitId,
},
{
label: 'Build Time',
value: config.appVersionBuildTime,
},
];
const serverData = [
{
label: 'Engine Server',
value: config.engineServerUrl,
},
{
label: 'Depot Server',
value: config.depotServerUrl,
},
{
label: 'Marketplace Server',
value: legendMarketplaceBaseStore.marketplaceServerClient.baseUrl,
setter: (val) => legendMarketplaceBaseStore.marketplaceServerClient.setBaseUrl(val),
},
];
const copyInfo = () => {
applicationStore.clipboardService
.copyTextToClipboard([
[...configData, ...serverData].map((data) => `${data.label}: ${data.value}`),
]
.filter(isNonNullable)
.join('\n'))
.then(() => applicationStore.notificationService.notifySuccess('Copied application info to clipboard'))
.catch(applicationStore.alertUnhandledError);
};
const goToReleaseLog = () => {
applicationStore.releaseNotesService.setReleaseLog(true);
closeModal();
};
return (_jsx(Dialog, { onClose: closeModal, open: open, fullWidth: true, maxWidth: "sm", 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: [configData.map((data) => (_jsxs("div", { className: "app__info__entry", children: [_jsxs("div", { className: "app__info__entry__title", children: [data.label, ":"] }), _jsx("div", { className: "app__info__entry__value", children: data.value })] }, data.label))), _jsx("div", { className: "app__info__entry", children: _jsx("div", { onClick: goToReleaseLog, className: "app__info__entry__value__action", children: "Details of Released Versions" }) }), _jsx("div", { className: "app__info__group", children: serverData.map((data) => (_jsxs("div", { className: "app__info__entry", children: [_jsxs("div", { className: "app__info__entry__title", children: [data.label, ":"] }), _jsx("div", { className: "app__info__entry__value", children: data.setter === undefined ? (_jsx("a", { href: data.value, target: "_blank", rel: "noopener noreferrer", children: data.value })) : (_jsx(TextField, { value: data.value, spellCheck: false, onChange: (event) => {
const stringValue = event.target.value;
data.setter?.(stringValue ? stringValue : undefined);
}, placeholder: `${data.label} client base URL`, error: !isValidUrl(data.value ?? ''), helperText: !isValidUrl(data.value ?? '')
? 'Invalid URL'
: undefined, variant: "outlined", size: "small", fullWidth: true, className: "app__info__entry__value--editable", slotProps: {
htmlInput: {
className: 'app__info__entry__value--editable__input',
},
formHelperText: {
className: 'app__info__entry__value--editable__helper-text',
},
} })) })] }, data.label))) })] })] }) }));
});
//# sourceMappingURL=LegendMarketplaceAppInfo.js.map