/**
* 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 {
type ModelImporterEditorState,
ModelImporterState,
ExtensionModelImporterEditorState,
MODEL_IMPORT_NATIVE_INPUT_TYPE,
NativeModelImporterEditorState,
ExternalFormatModelImporterState,
ExecuteInputDebugModelImporterEditorState,
} from '../../../stores/editor/editor-state/ModelImporterState.js';
import { prettyCONSTName } from '@finos/legend-shared';
import {
ControlledDropdownMenu,
MenuContent,
MenuContentItem,
CaretDownIcon,
CheckSquareIcon,
TruckLoadingIcon,
EmptySquareIcon,
BlankPanelContent,
PanelLoadingIndicator,
clsx,
Button,
Panel,
PanelHeader,
PanelContent,
} from '@finos/legend-art';
import { flowResult } from 'mobx';
import { useEditorStore } from '../EditorStoreProvider.js';
import {
useApplicationStore,
useApplicationNavigationContext,
} from '@finos/legend-application';
import type { ModelImporterExtensionConfiguration } from '../../../stores/LegendStudioApplicationPlugin.js';
import { LEGEND_STUDIO_APPLICATION_NAVIGATION_CONTEXT_KEY } from '../../../__lib__/LegendStudioApplicationNavigationContext.js';
import { SCHEMA_SET_TAB_TYPE } from '../../../stores/editor/editor-state/element-editor-state/external-format/DSL_ExternalFormat_SchemaSetEditorState.js';
import { SchemaSetModelGenerationEditor } from './external-format-editor/DSL_ExternalFormat_SchemaSetModelGenerationEditor.js';
import { SchemaSetGeneralEditor } from './external-format-editor/DSL_ExternalFormat_SchemaSetElementEditor.js';
import { CODE_EDITOR_LANGUAGE } from '@finos/legend-code-editor';
import { CodeEditor } from '@finos/legend-lego/code-editor';
const ExternalFormatModelImporterEditor = observer(
(props: { externalFormatState: ExternalFormatModelImporterState }) => {
const { externalFormatState } = props;
const schemaSetEditorState = externalFormatState.schemaSetEditorState;
const editorStore = schemaSetEditorState.editorStore;
const schemaSet = schemaSetEditorState.schemaSet;
const currentTab = schemaSetEditorState.selectedTab;
const isFetchingDescriptions =
editorStore.graphState.graphGenerationState.externalFormatState
.fetchingDescriptionsState.isInProgress;
const changeTab =
(tab: SCHEMA_SET_TAB_TYPE): (() => void) =>
(): void =>
schemaSetEditorState.setSelectedTab(tab);
const renderMainEditPanel = (): React.ReactNode => {
if (isFetchingDescriptions) {
return (
Fetching format descriptions
);
}
if (currentTab === SCHEMA_SET_TAB_TYPE.SCHEMAS) {
return (
);
}
const supportsModelGeneraiton =
schemaSetEditorState.schemaSetModelGenerationState.description
?.supportsModelGeneration;
return supportsModelGeneraiton ? (
) : (
Format {schemaSet.format} does not support Model Generation
);
};
useApplicationNavigationContext(
LEGEND_STUDIO_APPLICATION_NAVIGATION_CONTEXT_KEY.MODEL_LOADER_EXTERNAL_FORMAT_IMPORTER,
);
return (