UNPKG

@finos/legend-extension-dsl-data-space-studio

Version:
53 lines 4.05 kB
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } 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 { useApplicationStore } from '@finos/legend-application'; import { MenuContentItem, BlankPanelContent, TimesCircleIcon, PanelLoadingIndicator, Dialog, TimesIcon, Modal, ModalHeader, ModalTitle, ModalHeaderActions, } from '@finos/legend-art'; import { flowResult } from 'mobx'; import { observer } from 'mobx-react-lite'; import { useEditorStore } from '@finos/legend-application-studio'; import { DataSpacePreviewState } from '../stores/DataSpacePreviewState.js'; import { DataSpaceViewer } from '@finos/legend-extension-dsl-data-space/application'; export const DataSpacePreviewAction = observer((props) => { const { dataSpace } = props; const editorStore = useEditorStore(); const applicationStore = useApplicationStore(); const dataSpacePreviewState = DataSpacePreviewState.retrieveNullableState(editorStore); if (!dataSpacePreviewState) { return null; } const previewDataSpace = () => { flowResult(dataSpacePreviewState.previewDataSpace(dataSpace)).catch(applicationStore.alertUnhandledError); }; return (_jsx(MenuContentItem, { onClick: previewDataSpace, children: "Preview" })); }); export const DataSpacePreviewDialog = observer(() => { const editorStore = useEditorStore(); const applicationStore = editorStore.applicationStore; const dataSpacePreviewState = DataSpacePreviewState.retrieveNullableState(editorStore); if (!dataSpacePreviewState) { return null; } const onClose = () => { dataSpacePreviewState.setDataSpace(undefined); }; return (_jsx(Dialog, { open: Boolean(dataSpacePreviewState.dataSpace), onClose: onClose, classes: { root: 'editor-modal__root-container', container: 'editor-modal__container', paper: 'editor-modal__content data-space-preview__dialog__container__content', }, children: _jsxs(Modal, { darkMode: !applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled, className: "editor-modal data-space-preview__dialog", children: [_jsxs(ModalHeader, { className: "data-space-preview__dialog__header", children: [_jsx(ModalTitle, { title: "Preview Data Product" }), _jsx(ModalHeaderActions, { children: _jsx("button", { className: "modal__header__action", title: "Close", onClick: onClose, children: _jsx(TimesIcon, {}) }) })] }), _jsxs("div", { className: "data-space-preview__dialog__content", children: [_jsx(PanelLoadingIndicator, { isLoading: dataSpacePreviewState.loadDataSpaceState.isInProgress }), dataSpacePreviewState.dataSpaceViewerState && (_jsx(DataSpaceViewer, { dataSpaceViewerState: dataSpacePreviewState.dataSpaceViewerState })), !dataSpacePreviewState.dataSpaceViewerState && (_jsxs(_Fragment, { children: [dataSpacePreviewState.loadDataSpaceState.isInProgress && (_jsx(BlankPanelContent, { children: dataSpacePreviewState.loadDataSpaceState.message })), dataSpacePreviewState.loadDataSpaceState.hasFailed && (_jsx(BlankPanelContent, { children: _jsxs("div", { className: "data-space-preview__dialog__content--failed", children: [_jsx("div", { className: "data-space-preview__dialog__content--failed__icon", children: _jsx(TimesCircleIcon, {}) }), _jsx("div", { className: "data-space-preview__dialog__content--failed__text", children: `Can't load data product` })] }) }))] }))] })] }) })); }); //# sourceMappingURL=DataSpacePreviewAction.js.map