/** * 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, EnvelopeIcon, Panel, PanelContent, PanelHeader, } from '@finos/legend-art'; import { DataSpaceEditorState, onConvertDataSpaceToDataProduct, } 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'; import { DSL_DATA_SPACE_LEGEND_STUDIO_APPLICATION_NAVIGATION_CONTEXT_KEY } from '../__lib__/DSL_DataSpace_LegendStudioDocumentation.js'; import { useApplicationNavigationContext } from '@finos/legend-application'; 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 = (): boolean => { const stubDefault = Boolean( isStubbed_PackageableElement( dataSpace.defaultExecutionContext.defaultRuntime.value, ) && isStubbed_PackageableElement( dataSpace.defaultExecutionContext.mapping.value, ), ); return Boolean(!stubDefault); }; const previewDataSpace = (): void => { flowResult( dataSpacePreviewState.previewDataSpace(dataSpaceState.dataSpace), ).catch(editorStore.applicationStore.alertUnhandledError); }; const convertDataSpace = (): void => { flowResult( onConvertDataSpaceToDataProduct(dataSpace, editorStore, dataSpaceState), ).catch(editorStore.applicationStore.alertUnhandledError); }; useApplicationNavigationContext( DSL_DATA_SPACE_LEGEND_STUDIO_APPLICATION_NAVIGATION_CONTEXT_KEY.DATA_SPACE_EDITOR, ); return (
); });