@finos/legend-studio
Version:
32 lines • 3.35 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 { FileGenerationViewerState, getTextContent, getEditorLanguageFromFormat, } from '../../../stores/editor-state/FileGenerationViewerState.js';
import { LockIcon, FireIcon, StickArrowCircleRightIcon, } from '@finos/legend-art';
import { useEditorStore } from '../EditorStoreProvider.js';
import { StudioTextInputEditor } from '../../shared/StudioTextInputEditor.js';
export const FileGenerationViewer = observer(() => {
const editorStore = useEditorStore();
const generatedFileState = editorStore.getCurrentEditorState(FileGenerationViewerState);
const generatedFile = generatedFileState.generatedFile;
const fileGeneration = generatedFile.parentId
? editorStore.graphManagerState.graph.getNullableFileGeneration(generatedFile.parentId)
: undefined;
const visitFileGeneration = (fg) => editorStore.openElement(fg);
return (_jsx("div", { className: "file-generation-viewer", children: _jsxs("div", { className: "panel", children: [_jsx("div", { className: "panel__header", children: _jsxs("div", { className: "panel__header__title", children: [_jsx("div", { className: "uml-element-editor__header__lock", children: _jsx(LockIcon, {}) }), _jsx("div", { className: "panel__header__title__label", children: "generated-file" }), _jsx("div", { className: "panel__header__title__content", children: generatedFile.name })] }) }), _jsxs("div", { className: "panel file-generation-viewer__content", children: [_jsxs("div", { className: "panel__header", children: [_jsx("div", { className: "panel__header__title", children: _jsx("div", { className: "panel__header__title__label", children: fileGeneration?.type }) }), _jsx("div", { className: "panel__header__actions", children: fileGeneration && (_jsxs("button", { className: "uml-element-editor__header__generation-origin", onClick: () => visitFileGeneration(fileGeneration), tabIndex: -1, title: `Visit generation parent '${fileGeneration.path}'`, children: [_jsx("div", { className: "uml-element-editor__header__generation-origin__label", children: _jsx(FireIcon, {}) }), _jsx("div", { className: "uml-element-editor__header__generation-origin__parent-name", children: fileGeneration.name }), _jsx("div", { className: "uml-element-editor__header__generation-origin__visit-btn", children: _jsx(StickArrowCircleRightIcon, {}) })] })) })] }), _jsx("div", { className: "panel__content", children: _jsx(StudioTextInputEditor, { inputValue: getTextContent(generatedFile.content, generatedFile.format), isReadOnly: true, language: getEditorLanguageFromFormat(generatedFile.format) }) })] })] }) }));
});
//# sourceMappingURL=FileGenerationViewer.js.map