/** * 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 { useEditorStore } from '@finos/legend-application-studio'; import { PanelContentLists } from '@finos/legend-art'; import { observer } from 'mobx-react-lite'; import { DATA_SPACE_TAB, DataSpaceEditorState, } from '../../stores/DataSpaceEditorState.js'; import { DataSpaceSidebar } from './DataSpaceSidebar.js'; import { DataSpaceHomeTab } from './DataSpaceHomeTab.js'; import { DataSpaceExecutionContextEditor } from '../DataSpaceExecutionContextEditor.js'; import { DataspaceExecutablesSection } from './DataSpaceExecutablesSection.js'; import { DataSpaceInfoTab } from './DataSpaceInfoTab.js'; import { dataSpaceNeedsExecutionContextOrExecutable, hasExecutionContextValidationError, } from './DataSpaceValidation.js'; export const DataSpaceGeneralEditor = observer(() => { const editorStore = useEditorStore(); const dataSpaceState = editorStore.tabManagerState.getCurrentEditorState(DataSpaceEditorState); const dataSpace = dataSpaceState.dataSpace; const executionContexts = dataSpace.executionContexts ?? []; const tabsWithIssues = [ dataSpaceNeedsExecutionContextOrExecutable(dataSpace) && DATA_SPACE_TAB.HOME, executionContexts.some(hasExecutionContextValidationError) && DATA_SPACE_TAB.EXECUTION_CONTEXTS, ].filter((tab): tab is DATA_SPACE_TAB => Boolean(tab)); const renderTab = (): React.ReactNode => { switch (dataSpaceState.selectedTab) { case DATA_SPACE_TAB.EXECUTION_CONTEXTS: return ; case DATA_SPACE_TAB.EXECUTABLES: return ; case DATA_SPACE_TAB.INFO: return ; case DATA_SPACE_TAB.HOME: default: return ; } }; return ( dataSpaceState.setSelectedTab(tab)} counts={{ [DATA_SPACE_TAB.EXECUTION_CONTEXTS]: executionContexts.length, [DATA_SPACE_TAB.EXECUTABLES]: dataSpace.executables?.length ?? 0, }} tabsWithIssues={tabsWithIssues} />
{renderTab()}
); });