UNPKG

@finos/legend-studio

Version:
66 lines 2.94 kB
import { jsx as _jsx } 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 { CustomSelectorInput } from '@finos/legend-art'; import { SchemaSet } from '@finos/legend-graph'; import { guaranteeNonNullable } from '@finos/legend-shared'; import { makeObservable, observable, action } from 'mobx'; import { observer } from 'mobx-react-lite'; import { useEditorStore } from '../../EditorStoreProvider.js'; import { externalFormat_schemaSet_setFormat } from '../../../../stores/graphModifier/DSLExternalFormat_GraphModifierHelper.js'; import { NewElementDriver } from '../../../../stores/editor/NewElementState.js'; export class NewSchemaSetDriver extends NewElementDriver { formatOption; constructor(editorStore) { super(editorStore); makeObservable(this, { formatOption: observable, setFormatOption: action, }); this.formatOption = editorStore.graphState.graphGenerationState .externalFormatState.formatTypeOptions.length ? editorStore.graphState.graphGenerationState.externalFormatState .formatTypeOptions[0] : undefined; } setFormatOption(typeOption) { this.formatOption = typeOption; } get isValid() { return Boolean(this.formatOption); } createElement(name) { const schemaSet = new SchemaSet(name); externalFormat_schemaSet_setFormat(schemaSet, guaranteeNonNullable(this.formatOption).value); return schemaSet; } } export const NewSchemaSetDriverEditor = observer(() => { const editorStore = useEditorStore(); const newConnectionDriver = editorStore.newElementState.getNewElementDriver(NewSchemaSetDriver); const options = editorStore.graphState.graphGenerationState.externalFormatState .formatTypeOptions; const onTypeSelectionChange = (val) => { if (!val) { newConnectionDriver.setFormatOption(undefined); } else { newConnectionDriver.setFormatOption(val); } }; return (_jsx("div", { children: _jsx("div", { className: "", children: _jsx(CustomSelectorInput, { className: "sub-panel__content__form__section__dropdown", options: options, onChange: onTypeSelectionChange, value: newConnectionDriver.formatOption }) }) })); }); //# sourceMappingURL=NewSchemaSetDriver.js.map