@finos/legend-application-studio 27.1.1 → 27.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/__lib__/LegendStudioApplicationNavigationContext.d.ts +1 -1
- package/lib/__lib__/LegendStudioApplicationNavigationContext.d.ts.map +1 -1
- package/lib/__lib__/LegendStudioApplicationNavigationContext.js +1 -1
- package/lib/__lib__/LegendStudioApplicationNavigationContext.js.map +1 -1
- package/lib/__lib__/LegendStudioDocumentation.d.ts +3 -1
- package/lib/__lib__/LegendStudioDocumentation.d.ts.map +1 -1
- package/lib/__lib__/LegendStudioDocumentation.js +3 -0
- package/lib/__lib__/LegendStudioDocumentation.js.map +1 -1
- package/lib/__lib__/LegendStudioTesting.d.ts +1 -0
- package/lib/__lib__/LegendStudioTesting.d.ts.map +1 -1
- package/lib/__lib__/LegendStudioTesting.js +1 -0
- package/lib/__lib__/LegendStudioTesting.js.map +1 -1
- package/lib/application/LegendStudioApplicationConfig.d.ts.map +1 -1
- package/lib/application/LegendStudioApplicationConfig.js +1 -1
- package/lib/application/LegendStudioApplicationConfig.js.map +1 -1
- package/lib/components/editor/editor-group/FunctionEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/FunctionEditor.js +29 -25
- package/lib/components/editor/editor-group/FunctionEditor.js.map +1 -1
- package/lib/components/editor/editor-group/connection-editor/{DatabaseBuilder.d.ts → DatabaseBuilderWizard.d.ts} +4 -11
- package/lib/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.d.ts.map +1 -0
- package/lib/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.js +48 -0
- package/lib/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.js.map +1 -0
- package/lib/components/editor/editor-group/connection-editor/DatabaseSchemaExplorer.d.ts +32 -0
- package/lib/components/editor/editor-group/connection-editor/DatabaseSchemaExplorer.d.ts.map +1 -0
- package/lib/components/editor/editor-group/connection-editor/DatabaseSchemaExplorer.js +99 -0
- package/lib/components/editor/editor-group/connection-editor/DatabaseSchemaExplorer.js.map +1 -0
- package/lib/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.js +1 -1
- package/lib/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.js.map +1 -1
- package/lib/components/editor/editor-group/mapping-editor/MappingEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/mapping-editor/MappingEditor.js +2 -2
- package/lib/components/editor/editor-group/mapping-editor/MappingEditor.js.map +1 -1
- package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.js +47 -12
- package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.js.map +1 -1
- package/lib/components/editor/editor-group/project-configuration-editor/ProjectConfigurationEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/project-configuration-editor/ProjectConfigurationEditor.js +61 -11
- package/lib/components/editor/editor-group/project-configuration-editor/ProjectConfigurationEditor.js.map +1 -1
- package/lib/components/editor/editor-group/project-configuration-editor/ProjectDependencyEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/project-configuration-editor/ProjectDependencyEditor.js +1 -1
- package/lib/components/editor/editor-group/project-configuration-editor/ProjectDependencyEditor.js.map +1 -1
- package/lib/components/editor/editor-group/uml-editor/ClassEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/uml-editor/ClassEditor.js +24 -25
- package/lib/components/editor/editor-group/uml-editor/ClassEditor.js.map +1 -1
- package/lib/components/editor/editor-group/uml-editor/EnumerationEditor.js +2 -2
- package/lib/components/editor/editor-group/uml-editor/EnumerationEditor.js.map +1 -1
- package/lib/components/editor/editor-group/uml-editor/ProfileEditor.js +3 -3
- package/lib/components/editor/editor-group/uml-editor/ProfileEditor.js.map +1 -1
- package/lib/components/editor/editor-group/uml-editor/StereotypeSelector.js +2 -2
- package/lib/components/editor/editor-group/uml-editor/StereotypeSelector.js.map +1 -1
- package/lib/components/editor/editor-group/uml-editor/TaggedValueEditor.js +2 -2
- package/lib/components/editor/editor-group/uml-editor/TaggedValueEditor.js.map +1 -1
- package/lib/components/editor/panel-group/SQLPlaygroundPanel.d.ts +0 -7
- package/lib/components/editor/panel-group/SQLPlaygroundPanel.d.ts.map +1 -1
- package/lib/components/editor/panel-group/SQLPlaygroundPanel.js +20 -77
- package/lib/components/editor/panel-group/SQLPlaygroundPanel.js.map +1 -1
- package/lib/components/editor/side-bar/Explorer.js +3 -3
- package/lib/components/editor/side-bar/Explorer.js.map +1 -1
- package/lib/components/editor/side-bar/ProjectOverview.d.ts.map +1 -1
- package/lib/components/editor/side-bar/ProjectOverview.js +7 -1
- package/lib/components/editor/side-bar/ProjectOverview.js.map +1 -1
- package/lib/components/editor/side-bar/WorkflowManager.d.ts.map +1 -1
- package/lib/components/editor/side-bar/WorkflowManager.js +6 -1
- package/lib/components/editor/side-bar/WorkflowManager.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/package.json +3 -3
- package/lib/stores/editor/ExplorerTreeState.d.ts +4 -4
- package/lib/stores/editor/ExplorerTreeState.d.ts.map +1 -1
- package/lib/stores/editor/ExplorerTreeState.js +4 -4
- package/lib/stores/editor/ExplorerTreeState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.d.ts +12 -12
- package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.js +46 -47
- package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.d.ts +20 -29
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.js +60 -141
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.d.ts +33 -0
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.d.ts.map +1 -0
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.js +71 -0
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.js.map +1 -0
- package/lib/stores/editor/editor-state/element-editor-state/mapping/DEPRECATED__MappingTestState.js +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/mapping/DEPRECATED__MappingTestState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/mapping/MappingEditorState.d.ts +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/mapping/MappingEditorState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/mapping/MappingEditorState.js +2 -2
- package/lib/stores/editor/editor-state/element-editor-state/mapping/MappingEditorState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/mapping/MappingExecutionState.js +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/mapping/MappingExecutionState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/ServiceExecutionState.js +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/ServiceExecutionState.js.map +1 -1
- package/lib/stores/editor/editor-state/project-configuration-editor-state/ProjectConfigurationEditorState.d.ts +6 -2
- package/lib/stores/editor/editor-state/project-configuration-editor-state/ProjectConfigurationEditorState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/project-configuration-editor-state/ProjectConfigurationEditorState.js +39 -3
- package/lib/stores/editor/editor-state/project-configuration-editor-state/ProjectConfigurationEditorState.js.map +1 -1
- package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.d.ts +3 -48
- package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.d.ts.map +1 -1
- package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.js +12 -350
- package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.js.map +1 -1
- package/lib/stores/editor/sidebar-state/WorkflowManagerState.d.ts +5 -0
- package/lib/stores/editor/sidebar-state/WorkflowManagerState.d.ts.map +1 -1
- package/lib/stores/editor/sidebar-state/WorkflowManagerState.js +26 -0
- package/lib/stores/editor/sidebar-state/WorkflowManagerState.js.map +1 -1
- package/lib/stores/editor/utils/TestableUtils.js +2 -2
- package/lib/stores/editor/utils/TestableUtils.js.map +1 -1
- package/package.json +10 -10
- package/src/__lib__/LegendStudioApplicationNavigationContext.ts +1 -1
- package/src/__lib__/LegendStudioDocumentation.ts +4 -0
- package/src/__lib__/LegendStudioTesting.ts +1 -0
- package/src/application/LegendStudioApplicationConfig.ts +1 -1
- package/src/components/editor/editor-group/FunctionEditor.tsx +137 -122
- package/src/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.tsx +191 -0
- package/src/components/editor/editor-group/connection-editor/DatabaseSchemaExplorer.tsx +227 -0
- package/src/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.tsx +1 -1
- package/src/components/editor/editor-group/mapping-editor/MappingEditor.tsx +5 -2
- package/src/components/editor/editor-group/mapping-editor/MappingTestableEditor.tsx +68 -17
- package/src/components/editor/editor-group/project-configuration-editor/ProjectConfigurationEditor.tsx +137 -12
- package/src/components/editor/editor-group/project-configuration-editor/ProjectDependencyEditor.tsx +0 -1
- package/src/components/editor/editor-group/uml-editor/ClassEditor.tsx +354 -362
- package/src/components/editor/editor-group/uml-editor/EnumerationEditor.tsx +4 -4
- package/src/components/editor/editor-group/uml-editor/ProfileEditor.tsx +7 -7
- package/src/components/editor/editor-group/uml-editor/StereotypeSelector.tsx +4 -4
- package/src/components/editor/editor-group/uml-editor/TaggedValueEditor.tsx +4 -4
- package/src/components/editor/panel-group/SQLPlaygroundPanel.tsx +47 -211
- package/src/components/editor/side-bar/Explorer.tsx +3 -3
- package/src/components/editor/side-bar/ProjectOverview.tsx +14 -3
- package/src/components/editor/side-bar/WorkflowManager.tsx +10 -0
- package/src/stores/editor/ExplorerTreeState.ts +6 -9
- package/src/stores/editor/editor-state/element-editor-state/FunctionEditorState.ts +45 -51
- package/src/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.ts +88 -212
- package/src/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.ts +102 -0
- package/src/stores/editor/editor-state/element-editor-state/mapping/DEPRECATED__MappingTestState.ts +1 -1
- package/src/stores/editor/editor-state/element-editor-state/mapping/MappingEditorState.ts +2 -2
- package/src/stores/editor/editor-state/element-editor-state/mapping/MappingExecutionState.ts +1 -1
- package/src/stores/editor/editor-state/element-editor-state/service/ServiceExecutionState.ts +1 -1
- package/src/stores/editor/editor-state/project-configuration-editor-state/ProjectConfigurationEditorState.ts +59 -2
- package/src/stores/editor/panel-group/SQLPlaygroundPanelState.ts +13 -533
- package/src/stores/editor/sidebar-state/WorkflowManagerState.ts +47 -0
- package/src/stores/editor/utils/TestableUtils.ts +2 -2
- package/tsconfig.json +3 -1
- package/lib/components/editor/editor-group/connection-editor/DatabaseBuilder.d.ts.map +0 -1
- package/lib/components/editor/editor-group/connection-editor/DatabaseBuilder.js +0 -133
- package/lib/components/editor/editor-group/connection-editor/DatabaseBuilder.js.map +0 -1
- package/src/components/editor/editor-group/connection-editor/DatabaseBuilder.tsx +0 -397
@@ -74,7 +74,7 @@ export const validateTestableId = (
|
|
74
74
|
if (!id) {
|
75
75
|
return 'ID is required';
|
76
76
|
} else if (id.includes(' ')) {
|
77
|
-
return `ID can't contain
|
77
|
+
return `ID can't contain spaces`;
|
78
78
|
} else if (possibleIds?.includes(id)) {
|
79
79
|
return `ID '${id}' already exists`;
|
80
80
|
}
|
@@ -138,7 +138,7 @@ export class EmbeddedDataCreatorFromEmbeddedData
|
|
138
138
|
visit_ExternalFormatData(data: ExternalFormatData): EmbeddedData {
|
139
139
|
const val = new ExternalFormatData();
|
140
140
|
val.contentType = data.contentType;
|
141
|
-
val.data =
|
141
|
+
val.data = data.data;
|
142
142
|
return val;
|
143
143
|
}
|
144
144
|
visit_ModelStoreData(data: ModelStoreData): EmbeddedData {
|
package/tsconfig.json
CHANGED
@@ -95,6 +95,7 @@
|
|
95
95
|
"./src/stores/editor/editor-state/element-editor-state/UMLEditorState.ts",
|
96
96
|
"./src/stores/editor/editor-state/element-editor-state/connection/ConnectionEditorState.ts",
|
97
97
|
"./src/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.ts",
|
98
|
+
"./src/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.ts",
|
98
99
|
"./src/stores/editor/editor-state/element-editor-state/connection/PostProcessorEditorState.ts",
|
99
100
|
"./src/stores/editor/editor-state/element-editor-state/data/DataEditorState.ts",
|
100
101
|
"./src/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.ts",
|
@@ -192,8 +193,9 @@
|
|
192
193
|
"./src/components/editor/editor-group/RuntimeEditor.tsx",
|
193
194
|
"./src/components/editor/editor-group/UnsupportedElementEditor.tsx",
|
194
195
|
"./src/components/editor/editor-group/connection-editor/ConnectionEditor.tsx",
|
195
|
-
"./src/components/editor/editor-group/connection-editor/
|
196
|
+
"./src/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.tsx",
|
196
197
|
"./src/components/editor/editor-group/connection-editor/DatabaseEditorHelper.tsx",
|
198
|
+
"./src/components/editor/editor-group/connection-editor/DatabaseSchemaExplorer.tsx",
|
197
199
|
"./src/components/editor/editor-group/connection-editor/FlatDataConnectionEditor.tsx",
|
198
200
|
"./src/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.tsx",
|
199
201
|
"./src/components/editor/editor-group/connection-editor/post-processor-editor/MapperPostProcessorEditor.tsx",
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"DatabaseBuilder.d.ts","sourceRoot":"","sources":["../../../../../src/components/editor/editor-group/connection-editor/DatabaseBuilder.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAiCH,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAK7B,MAAM,gGAAgG,CAAC;AAmIxG,eAAO,MAAM,uBAAuB,WAC1B;IACN,QAAQ,EAAE,uBAAuB,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;IACpB,oBAAoB,EAAE,oBAAoB,CAAC;CAC5C;;CAmDF,CAAC;AAEF,eAAO,MAAM,eAAe,WAClB;IACN,oBAAoB,EAAE,oBAAoB,CAAC;IAC3C,UAAU,EAAE,OAAO,CAAC;CACrB;;CAqJF,CAAC"}
|
@@ -1,133 +0,0 @@
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
-
/**
|
3
|
-
* Copyright (c) 2020-present, Goldman Sachs
|
4
|
-
*
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
* you may not use this file except in compliance with the License.
|
7
|
-
* You may obtain a copy of the License at
|
8
|
-
*
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
*
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
* See the License for the specific language governing permissions and
|
15
|
-
* limitations under the License.
|
16
|
-
*/
|
17
|
-
import { observer } from 'mobx-react-lite';
|
18
|
-
import { Dialog, ResizablePanelGroup, ResizablePanel, ResizablePanelSplitter, PanelLoadingIndicator, TreeView, PURE_DatabaseSchemaIcon, PURE_DatabaseTableIcon, CircleIcon, ChevronDownIcon, ChevronRightIcon, CheckCircleIcon, EmptyCircleIcon, PanelContent, Modal, ModalHeader, ModalBody, ModalFooter, ModalTitle, ModalHeaderActions, TimesIcon, ModalFooterButton, BlankPanelContent, KeyIcon, PanelHeader, Panel, } from '@finos/legend-art';
|
19
|
-
import { useEffect } from 'react';
|
20
|
-
import { ColumnDatabaseBuilderTreeNodeData, SchemaDatabaseBuilderTreeNodeData, TableDatabaseBuilderTreeNodeData, } from '../../../../stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.js';
|
21
|
-
import { noop } from '@finos/legend-shared';
|
22
|
-
import { useApplicationStore, useConditionedApplicationNavigationContext, } from '@finos/legend-application';
|
23
|
-
import { renderColumnTypeIcon } from './DatabaseEditorHelper.js';
|
24
|
-
import { flowResult } from 'mobx';
|
25
|
-
import { LEGEND_STUDIO_APPLICATION_NAVIGATION_CONTEXT_KEY } from '../../../../__lib__/LegendStudioApplicationNavigationContext.js';
|
26
|
-
import { CODE_EDITOR_LANGUAGE, CodeEditor, } from '@finos/legend-lego/code-editor';
|
27
|
-
import { stringifyDataType } from '@finos/legend-graph';
|
28
|
-
const getDatabaseSchemaNodeIcon = (node) => {
|
29
|
-
if (node instanceof SchemaDatabaseBuilderTreeNodeData) {
|
30
|
-
return (_jsx("div", { className: "database-builder-tree__icon--schema", children: _jsx(PURE_DatabaseSchemaIcon, {}) }));
|
31
|
-
}
|
32
|
-
else if (node instanceof TableDatabaseBuilderTreeNodeData) {
|
33
|
-
return (_jsx("div", { className: "database-builder-tree__icon--table", children: _jsx(PURE_DatabaseTableIcon, {}) }));
|
34
|
-
}
|
35
|
-
else if (node instanceof ColumnDatabaseBuilderTreeNodeData) {
|
36
|
-
return renderColumnTypeIcon(node.column.type);
|
37
|
-
}
|
38
|
-
return null;
|
39
|
-
};
|
40
|
-
const DatabaseBuilderTreeNodeContainer = observer((props) => {
|
41
|
-
const { node, level, stepPaddingInRem, onNodeSelect, innerProps } = props;
|
42
|
-
const { toggleCheckedNode, isPartiallySelected } = innerProps;
|
43
|
-
const isExpandable = Boolean(!node.childrenIds || node.childrenIds.length) &&
|
44
|
-
!(node instanceof ColumnDatabaseBuilderTreeNodeData);
|
45
|
-
const nodeExpandIcon = isExpandable ? (node.isOpen ? (_jsx(ChevronDownIcon, {})) : (_jsx(ChevronRightIcon, {}))) : (_jsx("div", {}));
|
46
|
-
const nodeTypeIcon = getDatabaseSchemaNodeIcon(node);
|
47
|
-
const toggleExpandNode = () => {
|
48
|
-
onNodeSelect?.(node);
|
49
|
-
if (!isExpandable) {
|
50
|
-
toggleCheckedNode(node);
|
51
|
-
}
|
52
|
-
};
|
53
|
-
const isPrimaryKeyColumn = node instanceof ColumnDatabaseBuilderTreeNodeData &&
|
54
|
-
node.owner.primaryKey.includes(node.column);
|
55
|
-
const renderCheckedIcon = (_node) => {
|
56
|
-
if (_node instanceof ColumnDatabaseBuilderTreeNodeData) {
|
57
|
-
return null;
|
58
|
-
}
|
59
|
-
else if (isPartiallySelected(_node)) {
|
60
|
-
return _jsx(CircleIcon, {});
|
61
|
-
}
|
62
|
-
else if (_node.isChecked) {
|
63
|
-
return _jsx(CheckCircleIcon, {});
|
64
|
-
}
|
65
|
-
return _jsx(EmptyCircleIcon, {});
|
66
|
-
};
|
67
|
-
return (_jsxs("div", { className: "tree-view__node__container", style: {
|
68
|
-
paddingLeft: `${level * (stepPaddingInRem ?? 1)}rem`,
|
69
|
-
display: 'flex',
|
70
|
-
}, onClick: toggleExpandNode, children: [_jsxs("div", { className: "tree-view__node__icon database-builder-tree__node__icon__group", children: [_jsx("div", { className: "database-builder-tree__expand-icon", children: nodeExpandIcon }), _jsx("div", { className: "database-builder-tree__checker-icon", onClick: (event) => {
|
71
|
-
event.stopPropagation();
|
72
|
-
toggleCheckedNode(node);
|
73
|
-
}, children: renderCheckedIcon(node) }), _jsx("div", { className: "database-builder-tree__type-icon", children: nodeTypeIcon })] }), _jsxs("div", { className: "tree-view__node__label database-builder-tree__node__label", children: [node.label, node instanceof ColumnDatabaseBuilderTreeNodeData && (_jsx("div", { className: "database-builder-tree__node__type", children: _jsx("div", { className: "database-builder-tree__node__type__label", children: stringifyDataType(node.column.type) }) })), isPrimaryKeyColumn && (_jsx("div", { className: "database-builder-tree__node__pk", title: "Primary Key", children: _jsx(KeyIcon, {}) }))] })] }));
|
74
|
-
});
|
75
|
-
export const DatabaseBuilderExplorer = observer((props) => {
|
76
|
-
const { treeData, databaseBuilderState } = props;
|
77
|
-
const applicationStore = useApplicationStore();
|
78
|
-
const onNodeSelect = (node) => {
|
79
|
-
flowResult(databaseBuilderState.onNodeSelect(node, treeData)).catch(applicationStore.alertUnhandledError);
|
80
|
-
};
|
81
|
-
const getChildNodes = (node) => databaseBuilderState
|
82
|
-
.getChildNodes(node, treeData)
|
83
|
-
?.sort((a, b) => a.label.localeCompare(b.label)) ?? [];
|
84
|
-
const isPartiallySelected = (node) => {
|
85
|
-
if (node instanceof SchemaDatabaseBuilderTreeNodeData &&
|
86
|
-
!node.isChecked) {
|
87
|
-
return Boolean(databaseBuilderState
|
88
|
-
.getChildNodes(node, treeData)
|
89
|
-
?.find((childNode) => childNode.isChecked === true));
|
90
|
-
}
|
91
|
-
return false;
|
92
|
-
};
|
93
|
-
const toggleCheckedNode = (node) => databaseBuilderState.toggleCheckedNode(node, treeData);
|
94
|
-
return (_jsx(TreeView, { className: "database-builder-tree", components: {
|
95
|
-
TreeNodeContainer: DatabaseBuilderTreeNodeContainer,
|
96
|
-
}, innerProps: {
|
97
|
-
toggleCheckedNode,
|
98
|
-
isPartiallySelected,
|
99
|
-
}, treeData: treeData, onNodeSelect: onNodeSelect, getChildNodes: getChildNodes }));
|
100
|
-
});
|
101
|
-
export const DatabaseBuilder = observer((props) => {
|
102
|
-
const { databaseBuilderState, isReadOnly } = props;
|
103
|
-
const applicationStore = useApplicationStore();
|
104
|
-
const preview = applicationStore.guardUnhandledError(() => flowResult(databaseBuilderState.previewDatabaseModel()));
|
105
|
-
const saveOrUpdateDatabase = applicationStore.guardUnhandledError(() => flowResult(databaseBuilderState.createOrUpdateDatabase()));
|
106
|
-
const closeModal = () => {
|
107
|
-
databaseBuilderState.setShowModal(false);
|
108
|
-
databaseBuilderState.editorStore.explorerTreeState.setDatabaseBuilderState(undefined);
|
109
|
-
};
|
110
|
-
const isExecutingAction = databaseBuilderState.isBuildingDatabase ||
|
111
|
-
databaseBuilderState.isSavingDatabase;
|
112
|
-
const changeValue = (event) => {
|
113
|
-
if (!databaseBuilderState.currentDatabase) {
|
114
|
-
const stringValue = event.target.value;
|
115
|
-
const updatedValue = stringValue ? stringValue : undefined;
|
116
|
-
databaseBuilderState.setTargetDatabasePath(updatedValue ?? '');
|
117
|
-
}
|
118
|
-
};
|
119
|
-
useEffect(() => {
|
120
|
-
flowResult(databaseBuilderState.fetchDatabaseMetadata()).catch(applicationStore.alertUnhandledError);
|
121
|
-
}, [databaseBuilderState, applicationStore]);
|
122
|
-
useConditionedApplicationNavigationContext(LEGEND_STUDIO_APPLICATION_NAVIGATION_CONTEXT_KEY.DATABASE_BUILDER, databaseBuilderState.showModal);
|
123
|
-
return (_jsx(Dialog, { open: databaseBuilderState.showModal, onClose: noop, classes: { container: 'search-modal__container' }, PaperProps: {
|
124
|
-
classes: {
|
125
|
-
root: 'search-modal__inner-container database-builder__container',
|
126
|
-
},
|
127
|
-
}, children: _jsxs(Modal, { darkMode: true, className: "database-builder", children: [_jsxs(ModalHeader, { children: [_jsx(ModalTitle, { title: "Database Builder" }), _jsx(ModalHeaderActions, { children: _jsx("button", { className: "modal__header__action", tabIndex: -1, onClick: closeModal, children: _jsx(TimesIcon, {}) }) })] }), _jsxs(ModalBody, { className: "database-builder__content", children: [_jsx(PanelLoadingIndicator, { isLoading: isExecutingAction }), _jsxs(ResizablePanelGroup, { orientation: "vertical", children: [_jsx(ResizablePanel, { size: 450, children: _jsxs("div", { className: "database-builder__config", children: [_jsx(PanelHeader, { title: "schema explorer" }), _jsx(PanelContent, { className: "database-builder__config__content", children: databaseBuilderState.treeData && (_jsx(DatabaseBuilderExplorer, { treeData: databaseBuilderState.treeData, isReadOnly: false, databaseBuilderState: databaseBuilderState })) })] }) }), _jsx(ResizablePanelSplitter, {}), _jsx(ResizablePanel, { children: _jsxs(Panel, { className: "database-builder__model", children: [_jsx(PanelHeader, { title: "database model" }), _jsx(PanelContent, { children: _jsxs("div", { className: "database-builder__modeller", children: [_jsxs("div", { className: "panel__content__form__section database-builder__modeller__path", children: [_jsx("div", { className: "panel__content__form__section__header__label", children: "Target Database Path" }), _jsx("input", { className: "panel__content__form__section__input", spellCheck: false, disabled: isReadOnly ||
|
128
|
-
Boolean(databaseBuilderState.currentDatabase), value: databaseBuilderState.currentDatabase?.path ??
|
129
|
-
databaseBuilderState.targetDatabasePath, onChange: changeValue })] }), _jsxs("div", { className: "database-builder__modeller__preview", children: [databaseBuilderState.databaseGrammarCode && (_jsx(CodeEditor, { language: CODE_EDITOR_LANGUAGE.PURE, inputValue: databaseBuilderState.databaseGrammarCode, isReadOnly: true })), !databaseBuilderState.databaseGrammarCode && (_jsx(BlankPanelContent, { children: "No database preview" }))] })] }) })] }) })] })] }), _jsxs(ModalFooter, { children: [_jsx(ModalFooterButton, { className: "database-builder__action--btn", disabled: isReadOnly || isExecutingAction, onClick: preview, title: "Preview database model...", children: "Preview" }), _jsx(ModalFooterButton, { className: "database-builder__action--btn", disabled: isReadOnly || isExecutingAction, onClick: saveOrUpdateDatabase, children: databaseBuilderState.currentDatabase
|
130
|
-
? 'Update Database'
|
131
|
-
: 'Build Database' })] })] }) }));
|
132
|
-
});
|
133
|
-
//# sourceMappingURL=DatabaseBuilder.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"DatabaseBuilder.js","sourceRoot":"","sources":["../../../../../src/components/editor/editor-group/connection-editor/DatabaseBuilder.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EACL,MAAM,EAEN,mBAAmB,EACnB,cAAc,EACd,sBAAsB,EACtB,qBAAqB,EACrB,QAAQ,EACR,uBAAuB,EACvB,sBAAsB,EACtB,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,YAAY,EACZ,KAAK,EACL,WAAW,EACX,SAAS,EACT,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,SAAS,EACT,iBAAiB,EACjB,iBAAiB,EACj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AC,kBAAkB,EAEzC,QAAQ,EAAE,WAAW,GACrB,IACE,EACN,eAAK,SAAS,EAAC,qCAAqC,aACjD,oBAAoB,CAAC,mBAAmB,IAAI,CAC3C,KAAC,UAAU,IACT,QAAQ,EAAE,oBAAoB,CAAC,IAAI,EACnC,UAAU,EACR,oBAAoB,CAAC,mBAAmB,EAE1C,UAAU,EAAE,IAAI,GAChB,CACH,EACA,CAAC,oBAAoB,CAAC,mBAAmB,IAAI,CAC5C,KAAC,iBAAiB,sCAEE,CACrB,IACG,IACF,GACO,IACT,GACO,IACG,IACZ,EACZ,MAAC,WAAW,eACV,KAAC,iBAAiB,IAChB,SAAS,EAAC,+BAA+B,EACzC,QAAQ,EAAE,UAAU,IAAI,iBAAiB,EACzC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAC,2BAA2B,wBAGf,EACpB,KAAC,iBAAiB,IAChB,SAAS,EAAC,+BAA+B,EACzC,QAAQ,EAAE,UAAU,IAAI,iBAAiB,EACzC,OAAO,EAAE,oBAAoB,YAE5B,oBAAoB,CAAC,eAAe;gCACnC,CAAC,CAAC,iBAAiB;gCACnB,CAAC,CAAC,gBAAgB,GACF,IACR,IACR,GACD,CACV,CAAC;AACJ,CAAC,CACF,CAAC"}
|
@@ -1,397 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) 2020-present, Goldman Sachs
|
3
|
-
*
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
* you may not use this file except in compliance with the License.
|
6
|
-
* You may obtain a copy of the License at
|
7
|
-
*
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
*
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
* See the License for the specific language governing permissions and
|
14
|
-
* limitations under the License.
|
15
|
-
*/
|
16
|
-
|
17
|
-
import { observer } from 'mobx-react-lite';
|
18
|
-
import {
|
19
|
-
Dialog,
|
20
|
-
type TreeNodeContainerProps,
|
21
|
-
ResizablePanelGroup,
|
22
|
-
ResizablePanel,
|
23
|
-
ResizablePanelSplitter,
|
24
|
-
PanelLoadingIndicator,
|
25
|
-
TreeView,
|
26
|
-
PURE_DatabaseSchemaIcon,
|
27
|
-
PURE_DatabaseTableIcon,
|
28
|
-
CircleIcon,
|
29
|
-
ChevronDownIcon,
|
30
|
-
ChevronRightIcon,
|
31
|
-
CheckCircleIcon,
|
32
|
-
EmptyCircleIcon,
|
33
|
-
PanelContent,
|
34
|
-
Modal,
|
35
|
-
ModalHeader,
|
36
|
-
ModalBody,
|
37
|
-
ModalFooter,
|
38
|
-
ModalTitle,
|
39
|
-
ModalHeaderActions,
|
40
|
-
TimesIcon,
|
41
|
-
ModalFooterButton,
|
42
|
-
BlankPanelContent,
|
43
|
-
KeyIcon,
|
44
|
-
PanelHeader,
|
45
|
-
Panel,
|
46
|
-
} from '@finos/legend-art';
|
47
|
-
import { useEffect } from 'react';
|
48
|
-
import {
|
49
|
-
type DatabaseBuilderState,
|
50
|
-
type DatabaseBuilderTreeData,
|
51
|
-
type DatabaseBuilderTreeNodeData,
|
52
|
-
ColumnDatabaseBuilderTreeNodeData,
|
53
|
-
SchemaDatabaseBuilderTreeNodeData,
|
54
|
-
TableDatabaseBuilderTreeNodeData,
|
55
|
-
} from '../../../../stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.js';
|
56
|
-
import { noop } from '@finos/legend-shared';
|
57
|
-
import {
|
58
|
-
useApplicationStore,
|
59
|
-
useConditionedApplicationNavigationContext,
|
60
|
-
} from '@finos/legend-application';
|
61
|
-
import { renderColumnTypeIcon } from './DatabaseEditorHelper.js';
|
62
|
-
import { flowResult } from 'mobx';
|
63
|
-
import { LEGEND_STUDIO_APPLICATION_NAVIGATION_CONTEXT_KEY } from '../../../../__lib__/LegendStudioApplicationNavigationContext.js';
|
64
|
-
import {
|
65
|
-
CODE_EDITOR_LANGUAGE,
|
66
|
-
CodeEditor,
|
67
|
-
} from '@finos/legend-lego/code-editor';
|
68
|
-
import { stringifyDataType } from '@finos/legend-graph';
|
69
|
-
|
70
|
-
const getDatabaseSchemaNodeIcon = (
|
71
|
-
node: DatabaseBuilderTreeNodeData,
|
72
|
-
): React.ReactNode => {
|
73
|
-
if (node instanceof SchemaDatabaseBuilderTreeNodeData) {
|
74
|
-
return (
|
75
|
-
<div className="database-builder-tree__icon--schema">
|
76
|
-
<PURE_DatabaseSchemaIcon />
|
77
|
-
</div>
|
78
|
-
);
|
79
|
-
} else if (node instanceof TableDatabaseBuilderTreeNodeData) {
|
80
|
-
return (
|
81
|
-
<div className="database-builder-tree__icon--table">
|
82
|
-
<PURE_DatabaseTableIcon />
|
83
|
-
</div>
|
84
|
-
);
|
85
|
-
} else if (node instanceof ColumnDatabaseBuilderTreeNodeData) {
|
86
|
-
return renderColumnTypeIcon(node.column.type);
|
87
|
-
}
|
88
|
-
return null;
|
89
|
-
};
|
90
|
-
|
91
|
-
const DatabaseBuilderTreeNodeContainer = observer(
|
92
|
-
(
|
93
|
-
props: TreeNodeContainerProps<
|
94
|
-
DatabaseBuilderTreeNodeData,
|
95
|
-
{
|
96
|
-
toggleCheckedNode: (node: DatabaseBuilderTreeNodeData) => void;
|
97
|
-
isPartiallySelected: (node: DatabaseBuilderTreeNodeData) => boolean;
|
98
|
-
}
|
99
|
-
>,
|
100
|
-
) => {
|
101
|
-
const { node, level, stepPaddingInRem, onNodeSelect, innerProps } = props;
|
102
|
-
const { toggleCheckedNode, isPartiallySelected } = innerProps;
|
103
|
-
const isExpandable =
|
104
|
-
Boolean(!node.childrenIds || node.childrenIds.length) &&
|
105
|
-
!(node instanceof ColumnDatabaseBuilderTreeNodeData);
|
106
|
-
const nodeExpandIcon = isExpandable ? (
|
107
|
-
node.isOpen ? (
|
108
|
-
<ChevronDownIcon />
|
109
|
-
) : (
|
110
|
-
<ChevronRightIcon />
|
111
|
-
)
|
112
|
-
) : (
|
113
|
-
<div />
|
114
|
-
);
|
115
|
-
const nodeTypeIcon = getDatabaseSchemaNodeIcon(node);
|
116
|
-
const toggleExpandNode = (): void => {
|
117
|
-
onNodeSelect?.(node);
|
118
|
-
if (!isExpandable) {
|
119
|
-
toggleCheckedNode(node);
|
120
|
-
}
|
121
|
-
};
|
122
|
-
const isPrimaryKeyColumn =
|
123
|
-
node instanceof ColumnDatabaseBuilderTreeNodeData &&
|
124
|
-
node.owner.primaryKey.includes(node.column);
|
125
|
-
|
126
|
-
const renderCheckedIcon = (
|
127
|
-
_node: DatabaseBuilderTreeNodeData,
|
128
|
-
): React.ReactNode => {
|
129
|
-
if (_node instanceof ColumnDatabaseBuilderTreeNodeData) {
|
130
|
-
return null;
|
131
|
-
} else if (isPartiallySelected(_node)) {
|
132
|
-
return <CircleIcon />;
|
133
|
-
} else if (_node.isChecked) {
|
134
|
-
return <CheckCircleIcon />;
|
135
|
-
}
|
136
|
-
return <EmptyCircleIcon />;
|
137
|
-
};
|
138
|
-
|
139
|
-
return (
|
140
|
-
<div
|
141
|
-
className="tree-view__node__container"
|
142
|
-
style={{
|
143
|
-
paddingLeft: `${level * (stepPaddingInRem ?? 1)}rem`,
|
144
|
-
display: 'flex',
|
145
|
-
}}
|
146
|
-
onClick={toggleExpandNode}
|
147
|
-
>
|
148
|
-
<div className="tree-view__node__icon database-builder-tree__node__icon__group">
|
149
|
-
<div className="database-builder-tree__expand-icon">
|
150
|
-
{nodeExpandIcon}
|
151
|
-
</div>
|
152
|
-
<div
|
153
|
-
className="database-builder-tree__checker-icon"
|
154
|
-
onClick={(event) => {
|
155
|
-
event.stopPropagation();
|
156
|
-
toggleCheckedNode(node);
|
157
|
-
}}
|
158
|
-
>
|
159
|
-
{renderCheckedIcon(node)}
|
160
|
-
</div>
|
161
|
-
<div className="database-builder-tree__type-icon">{nodeTypeIcon}</div>
|
162
|
-
</div>
|
163
|
-
<div className="tree-view__node__label database-builder-tree__node__label">
|
164
|
-
{node.label}
|
165
|
-
{node instanceof ColumnDatabaseBuilderTreeNodeData && (
|
166
|
-
<div className="database-builder-tree__node__type">
|
167
|
-
<div className="database-builder-tree__node__type__label">
|
168
|
-
{stringifyDataType(node.column.type)}
|
169
|
-
</div>
|
170
|
-
</div>
|
171
|
-
)}
|
172
|
-
{isPrimaryKeyColumn && (
|
173
|
-
<div
|
174
|
-
className="database-builder-tree__node__pk"
|
175
|
-
title="Primary Key"
|
176
|
-
>
|
177
|
-
<KeyIcon />
|
178
|
-
</div>
|
179
|
-
)}
|
180
|
-
</div>
|
181
|
-
</div>
|
182
|
-
);
|
183
|
-
},
|
184
|
-
);
|
185
|
-
|
186
|
-
export const DatabaseBuilderExplorer = observer(
|
187
|
-
(props: {
|
188
|
-
treeData: DatabaseBuilderTreeData;
|
189
|
-
isReadOnly: boolean;
|
190
|
-
databaseBuilderState: DatabaseBuilderState;
|
191
|
-
}) => {
|
192
|
-
const { treeData, databaseBuilderState } = props;
|
193
|
-
const applicationStore = useApplicationStore();
|
194
|
-
const onNodeSelect = (node: DatabaseBuilderTreeNodeData): void => {
|
195
|
-
flowResult(databaseBuilderState.onNodeSelect(node, treeData)).catch(
|
196
|
-
applicationStore.alertUnhandledError,
|
197
|
-
);
|
198
|
-
};
|
199
|
-
|
200
|
-
const getChildNodes = (
|
201
|
-
node: DatabaseBuilderTreeNodeData,
|
202
|
-
): DatabaseBuilderTreeNodeData[] =>
|
203
|
-
databaseBuilderState
|
204
|
-
.getChildNodes(node, treeData)
|
205
|
-
?.sort((a, b) => a.label.localeCompare(b.label)) ?? [];
|
206
|
-
|
207
|
-
const isPartiallySelected = (
|
208
|
-
node: DatabaseBuilderTreeNodeData,
|
209
|
-
): boolean => {
|
210
|
-
if (
|
211
|
-
node instanceof SchemaDatabaseBuilderTreeNodeData &&
|
212
|
-
!node.isChecked
|
213
|
-
) {
|
214
|
-
return Boolean(
|
215
|
-
databaseBuilderState
|
216
|
-
.getChildNodes(node, treeData)
|
217
|
-
?.find((childNode) => childNode.isChecked === true),
|
218
|
-
);
|
219
|
-
}
|
220
|
-
return false;
|
221
|
-
};
|
222
|
-
|
223
|
-
const toggleCheckedNode = (node: DatabaseBuilderTreeNodeData): void =>
|
224
|
-
databaseBuilderState.toggleCheckedNode(node, treeData);
|
225
|
-
|
226
|
-
return (
|
227
|
-
<TreeView
|
228
|
-
className="database-builder-tree"
|
229
|
-
components={{
|
230
|
-
TreeNodeContainer: DatabaseBuilderTreeNodeContainer,
|
231
|
-
}}
|
232
|
-
innerProps={{
|
233
|
-
toggleCheckedNode,
|
234
|
-
isPartiallySelected,
|
235
|
-
}}
|
236
|
-
treeData={treeData}
|
237
|
-
onNodeSelect={onNodeSelect}
|
238
|
-
getChildNodes={getChildNodes}
|
239
|
-
/>
|
240
|
-
);
|
241
|
-
},
|
242
|
-
);
|
243
|
-
|
244
|
-
export const DatabaseBuilder = observer(
|
245
|
-
(props: {
|
246
|
-
databaseBuilderState: DatabaseBuilderState;
|
247
|
-
isReadOnly: boolean;
|
248
|
-
}) => {
|
249
|
-
const { databaseBuilderState, isReadOnly } = props;
|
250
|
-
const applicationStore = useApplicationStore();
|
251
|
-
const preview = applicationStore.guardUnhandledError(() =>
|
252
|
-
flowResult(databaseBuilderState.previewDatabaseModel()),
|
253
|
-
);
|
254
|
-
const saveOrUpdateDatabase = applicationStore.guardUnhandledError(() =>
|
255
|
-
flowResult(databaseBuilderState.createOrUpdateDatabase()),
|
256
|
-
);
|
257
|
-
const closeModal = (): void => {
|
258
|
-
databaseBuilderState.setShowModal(false);
|
259
|
-
databaseBuilderState.editorStore.explorerTreeState.setDatabaseBuilderState(
|
260
|
-
undefined,
|
261
|
-
);
|
262
|
-
};
|
263
|
-
const isExecutingAction =
|
264
|
-
databaseBuilderState.isBuildingDatabase ||
|
265
|
-
databaseBuilderState.isSavingDatabase;
|
266
|
-
|
267
|
-
const changeValue: React.ChangeEventHandler<HTMLInputElement> = (event) => {
|
268
|
-
if (!databaseBuilderState.currentDatabase) {
|
269
|
-
const stringValue = event.target.value;
|
270
|
-
const updatedValue = stringValue ? stringValue : undefined;
|
271
|
-
databaseBuilderState.setTargetDatabasePath(updatedValue ?? '');
|
272
|
-
}
|
273
|
-
};
|
274
|
-
|
275
|
-
useEffect(() => {
|
276
|
-
flowResult(databaseBuilderState.fetchDatabaseMetadata()).catch(
|
277
|
-
applicationStore.alertUnhandledError,
|
278
|
-
);
|
279
|
-
}, [databaseBuilderState, applicationStore]);
|
280
|
-
|
281
|
-
useConditionedApplicationNavigationContext(
|
282
|
-
LEGEND_STUDIO_APPLICATION_NAVIGATION_CONTEXT_KEY.DATABASE_BUILDER,
|
283
|
-
databaseBuilderState.showModal,
|
284
|
-
);
|
285
|
-
|
286
|
-
return (
|
287
|
-
<Dialog
|
288
|
-
open={databaseBuilderState.showModal}
|
289
|
-
onClose={noop} // disallow closing dialog by using Esc key or clicking on the backdrop
|
290
|
-
classes={{ container: 'search-modal__container' }}
|
291
|
-
PaperProps={{
|
292
|
-
classes: {
|
293
|
-
root: 'search-modal__inner-container database-builder__container',
|
294
|
-
},
|
295
|
-
}}
|
296
|
-
>
|
297
|
-
<Modal darkMode={true} className="database-builder">
|
298
|
-
<ModalHeader>
|
299
|
-
<ModalTitle title="Database Builder" />
|
300
|
-
<ModalHeaderActions>
|
301
|
-
<button
|
302
|
-
className="modal__header__action"
|
303
|
-
tabIndex={-1}
|
304
|
-
onClick={closeModal}
|
305
|
-
>
|
306
|
-
<TimesIcon />
|
307
|
-
</button>
|
308
|
-
</ModalHeaderActions>
|
309
|
-
</ModalHeader>
|
310
|
-
<ModalBody className="database-builder__content">
|
311
|
-
<PanelLoadingIndicator isLoading={isExecutingAction} />
|
312
|
-
<ResizablePanelGroup orientation="vertical">
|
313
|
-
<ResizablePanel size={450}>
|
314
|
-
<div className="database-builder__config">
|
315
|
-
<PanelHeader title="schema explorer" />
|
316
|
-
<PanelContent className="database-builder__config__content">
|
317
|
-
{databaseBuilderState.treeData && (
|
318
|
-
<DatabaseBuilderExplorer
|
319
|
-
treeData={databaseBuilderState.treeData}
|
320
|
-
isReadOnly={false}
|
321
|
-
databaseBuilderState={databaseBuilderState}
|
322
|
-
/>
|
323
|
-
)}
|
324
|
-
</PanelContent>
|
325
|
-
</div>
|
326
|
-
</ResizablePanel>
|
327
|
-
<ResizablePanelSplitter />
|
328
|
-
<ResizablePanel>
|
329
|
-
<Panel className="database-builder__model">
|
330
|
-
<PanelHeader title="database model" />
|
331
|
-
|
332
|
-
<PanelContent>
|
333
|
-
<div className="database-builder__modeller">
|
334
|
-
<div className="panel__content__form__section database-builder__modeller__path">
|
335
|
-
<div className="panel__content__form__section__header__label">
|
336
|
-
Target Database Path
|
337
|
-
</div>
|
338
|
-
<input
|
339
|
-
className="panel__content__form__section__input"
|
340
|
-
spellCheck={false}
|
341
|
-
disabled={
|
342
|
-
isReadOnly ||
|
343
|
-
Boolean(databaseBuilderState.currentDatabase)
|
344
|
-
}
|
345
|
-
value={
|
346
|
-
databaseBuilderState.currentDatabase?.path ??
|
347
|
-
databaseBuilderState.targetDatabasePath
|
348
|
-
}
|
349
|
-
onChange={changeValue}
|
350
|
-
/>
|
351
|
-
</div>
|
352
|
-
<div className="database-builder__modeller__preview">
|
353
|
-
{databaseBuilderState.databaseGrammarCode && (
|
354
|
-
<CodeEditor
|
355
|
-
language={CODE_EDITOR_LANGUAGE.PURE}
|
356
|
-
inputValue={
|
357
|
-
databaseBuilderState.databaseGrammarCode
|
358
|
-
}
|
359
|
-
isReadOnly={true}
|
360
|
-
/>
|
361
|
-
)}
|
362
|
-
{!databaseBuilderState.databaseGrammarCode && (
|
363
|
-
<BlankPanelContent>
|
364
|
-
No database preview
|
365
|
-
</BlankPanelContent>
|
366
|
-
)}
|
367
|
-
</div>
|
368
|
-
</div>
|
369
|
-
</PanelContent>
|
370
|
-
</Panel>
|
371
|
-
</ResizablePanel>
|
372
|
-
</ResizablePanelGroup>
|
373
|
-
</ModalBody>
|
374
|
-
<ModalFooter>
|
375
|
-
<ModalFooterButton
|
376
|
-
className="database-builder__action--btn"
|
377
|
-
disabled={isReadOnly || isExecutingAction}
|
378
|
-
onClick={preview}
|
379
|
-
title="Preview database model..."
|
380
|
-
>
|
381
|
-
Preview
|
382
|
-
</ModalFooterButton>
|
383
|
-
<ModalFooterButton
|
384
|
-
className="database-builder__action--btn"
|
385
|
-
disabled={isReadOnly || isExecutingAction}
|
386
|
-
onClick={saveOrUpdateDatabase}
|
387
|
-
>
|
388
|
-
{databaseBuilderState.currentDatabase
|
389
|
-
? 'Update Database'
|
390
|
-
: 'Build Database'}
|
391
|
-
</ModalFooterButton>
|
392
|
-
</ModalFooter>
|
393
|
-
</Modal>
|
394
|
-
</Dialog>
|
395
|
-
);
|
396
|
-
},
|
397
|
-
);
|