@finos/legend-extension-dsl-data-space-studio
Version:
Legend extension for Data Space DSL - Studio
43 lines • 2.97 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 { observer } from 'mobx-react-lite';
import { useEditorStore } from '@finos/legend-application-studio';
import { EyeIcon, Panel, PanelContent, PanelHeader } from '@finos/legend-art';
import { DataSpaceEditorState } from '../stores/DataSpaceEditorState.js';
import { DataSpaceGeneralEditor } from './DataSpaceGeneralEditor/DataSpaceGeneralEditor.js';
import { DataSpacePreviewState } from '../stores/DataSpacePreviewState.js';
import { flowResult } from 'mobx';
import { isStubbed_PackageableElement } from '@finos/legend-graph';
export const DataSpaceEditor = observer(() => {
const editorStore = useEditorStore();
const dataSpaceState = editorStore.tabManagerState.getCurrentEditorState(DataSpaceEditorState);
const dataSpace = dataSpaceState.dataSpace;
const dataSpacePreviewState = DataSpacePreviewState.retrieveNullableState(editorStore);
if (!dataSpacePreviewState) {
return null;
}
const validPreviewState = () => {
const stubDefault = Boolean(isStubbed_PackageableElement(dataSpace.defaultExecutionContext.defaultRuntime.value) &&
isStubbed_PackageableElement(dataSpace.defaultExecutionContext.mapping.value));
return Boolean(!stubDefault);
};
const previewDataSpace = () => {
flowResult(dataSpacePreviewState.previewDataSpace(dataSpaceState.dataSpace)).catch(editorStore.applicationStore.alertUnhandledError);
};
return (_jsxs(Panel, { className: "dataSpace-editor", children: [_jsx(PanelHeader, { title: "Data Product", titleContent: dataSpaceState.dataSpace.name, darkMode: true, isReadOnly: dataSpaceState.isReadOnly }), _jsx(PanelHeader, { title: "General", darkMode: true, children: _jsx("div", { className: "panel__header__actions", children: _jsx("div", { className: "btn__dropdown-combo btn__dropdown-combo--primary", children: _jsxs("button", { className: "btn__dropdown-combo__label", onClick: previewDataSpace, title: "Preview Data Product", tabIndex: -1, disabled: !validPreviewState(), children: [_jsx(EyeIcon, { className: "btn__dropdown-combo__label__icon" }), _jsx("div", { className: "btn__dropdown-combo__label__title", children: "Preview" })] }) }) }) }), _jsx(PanelContent, { children: _jsx(DataSpaceGeneralEditor, {}) })] }));
});
//# sourceMappingURL=DataSpaceEditor.js.map