@finos/legend-application-studio 22.2.1 → 22.3.0

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.
Files changed (200) hide show
  1. package/lib/components/editor/StatusBar.js +1 -1
  2. package/lib/components/editor/StatusBar.js.map +1 -1
  3. package/lib/components/editor/command-center/ProjectSearchCommand.d.ts.map +1 -1
  4. package/lib/components/editor/command-center/ProjectSearchCommand.js +1 -0
  5. package/lib/components/editor/command-center/ProjectSearchCommand.js.map +1 -1
  6. package/lib/components/editor/edit-panel/EditPanel.d.ts.map +1 -1
  7. package/lib/components/editor/edit-panel/EditPanel.js +24 -11
  8. package/lib/components/editor/edit-panel/EditPanel.js.map +1 -1
  9. package/lib/components/editor/edit-panel/GenerationSpecificationEditor.d.ts.map +1 -1
  10. package/lib/components/editor/edit-panel/GenerationSpecificationEditor.js +2 -1
  11. package/lib/components/editor/edit-panel/GenerationSpecificationEditor.js.map +1 -1
  12. package/lib/components/editor/edit-panel/connection-editor/ConnectionEditor.d.ts.map +1 -1
  13. package/lib/components/editor/edit-panel/connection-editor/ConnectionEditor.js +1 -0
  14. package/lib/components/editor/edit-panel/connection-editor/ConnectionEditor.js.map +1 -1
  15. package/lib/components/editor/edit-panel/element-generation-editor/ElementGenerationEditor.d.ts.map +1 -1
  16. package/lib/components/editor/edit-panel/element-generation-editor/ElementGenerationEditor.js +4 -3
  17. package/lib/components/editor/edit-panel/element-generation-editor/ElementGenerationEditor.js.map +1 -1
  18. package/lib/components/editor/edit-panel/element-generation-editor/ElementXTGenerationEditor.d.ts +32 -0
  19. package/lib/components/editor/edit-panel/element-generation-editor/ElementXTGenerationEditor.d.ts.map +1 -0
  20. package/lib/components/editor/edit-panel/element-generation-editor/ElementXTGenerationEditor.js +66 -0
  21. package/lib/components/editor/edit-panel/element-generation-editor/ElementXTGenerationEditor.js.map +1 -0
  22. package/lib/components/editor/edit-panel/element-generation-editor/FileGenerationEditor.d.ts +0 -23
  23. package/lib/components/editor/edit-panel/element-generation-editor/FileGenerationEditor.d.ts.map +1 -1
  24. package/lib/components/editor/edit-panel/element-generation-editor/FileGenerationEditor.js +6 -58
  25. package/lib/components/editor/edit-panel/element-generation-editor/FileGenerationEditor.js.map +1 -1
  26. package/lib/components/editor/edit-panel/element-generation-editor/FileSystemViewer.d.ts +41 -0
  27. package/lib/components/editor/edit-panel/element-generation-editor/FileSystemViewer.d.ts.map +1 -0
  28. package/lib/components/editor/edit-panel/element-generation-editor/FileSystemViewer.js +77 -0
  29. package/lib/components/editor/edit-panel/element-generation-editor/FileSystemViewer.js.map +1 -0
  30. package/lib/components/editor/edit-panel/external-format-editor/DSL_ExternalFormat_BindingElementEditor.d.ts +7 -0
  31. package/lib/components/editor/edit-panel/external-format-editor/DSL_ExternalFormat_BindingElementEditor.d.ts.map +1 -1
  32. package/lib/components/editor/edit-panel/external-format-editor/DSL_ExternalFormat_BindingElementEditor.js +19 -14
  33. package/lib/components/editor/edit-panel/external-format-editor/DSL_ExternalFormat_BindingElementEditor.js.map +1 -1
  34. package/lib/components/editor/edit-panel/mapping-editor/EnumerationMappingEditor.d.ts.map +1 -1
  35. package/lib/components/editor/edit-panel/mapping-editor/EnumerationMappingEditor.js +3 -1
  36. package/lib/components/editor/edit-panel/mapping-editor/EnumerationMappingEditor.js.map +1 -1
  37. package/lib/components/editor/edit-panel/mapping-editor/InstanceSetImplementationSourceSelectorModal.js +3 -1
  38. package/lib/components/editor/edit-panel/mapping-editor/InstanceSetImplementationSourceSelectorModal.js.map +1 -1
  39. package/lib/components/editor/edit-panel/mapping-editor/MappingExecutionQueryBuilder.d.ts.map +1 -1
  40. package/lib/components/editor/edit-panel/mapping-editor/MappingExecutionQueryBuilder.js +3 -0
  41. package/lib/components/editor/edit-panel/mapping-editor/MappingExecutionQueryBuilder.js.map +1 -1
  42. package/lib/components/editor/edit-panel/mapping-editor/NewMappingElementModal.d.ts.map +1 -1
  43. package/lib/components/editor/edit-panel/mapping-editor/NewMappingElementModal.js +3 -1
  44. package/lib/components/editor/edit-panel/mapping-editor/NewMappingElementModal.js.map +1 -1
  45. package/lib/components/editor/edit-panel/service-editor/ServiceEditor.d.ts.map +1 -1
  46. package/lib/components/editor/edit-panel/service-editor/ServiceEditor.js +51 -13
  47. package/lib/components/editor/edit-panel/service-editor/ServiceEditor.js.map +1 -1
  48. package/lib/components/editor/edit-panel/service-editor/ServiceExecutionQueryEditor.d.ts.map +1 -1
  49. package/lib/components/editor/edit-panel/service-editor/ServiceExecutionQueryEditor.js +18 -10
  50. package/lib/components/editor/edit-panel/service-editor/ServiceExecutionQueryEditor.js.map +1 -1
  51. package/lib/components/editor/edit-panel/service-editor/testable/ServiceTestableEditor.d.ts +1 -3
  52. package/lib/components/editor/edit-panel/service-editor/testable/ServiceTestableEditor.d.ts.map +1 -1
  53. package/lib/components/editor/edit-panel/service-editor/testable/ServiceTestableEditor.js +2 -20
  54. package/lib/components/editor/edit-panel/service-editor/testable/ServiceTestableEditor.js.map +1 -1
  55. package/lib/components/editor/edit-panel/uml-editor/ClassEditor.d.ts.map +1 -1
  56. package/lib/components/editor/edit-panel/uml-editor/ClassEditor.js +9 -3
  57. package/lib/components/editor/edit-panel/uml-editor/ClassEditor.js.map +1 -1
  58. package/lib/components/editor/side-bar/CreateNewElementModal.d.ts.map +1 -1
  59. package/lib/components/editor/side-bar/CreateNewElementModal.js +1 -0
  60. package/lib/components/editor/side-bar/CreateNewElementModal.js.map +1 -1
  61. package/lib/components/editor/side-bar/Explorer.d.ts.map +1 -1
  62. package/lib/components/editor/side-bar/Explorer.js +29 -8
  63. package/lib/components/editor/side-bar/Explorer.js.map +1 -1
  64. package/lib/components/editor/side-bar/testable/GlobalTestRunner.d.ts.map +1 -1
  65. package/lib/components/editor/side-bar/testable/GlobalTestRunner.js +17 -3
  66. package/lib/components/editor/side-bar/testable/GlobalTestRunner.js.map +1 -1
  67. package/lib/index.css +2 -2
  68. package/lib/index.css.map +1 -1
  69. package/lib/index.d.ts +2 -2
  70. package/lib/index.d.ts.map +1 -1
  71. package/lib/index.js +2 -2
  72. package/lib/index.js.map +1 -1
  73. package/lib/package.json +3 -3
  74. package/lib/stores/DSL_Generation_LegendStudioApplicationPlugin_Extension.d.ts +2 -2
  75. package/lib/stores/DSL_Generation_LegendStudioApplicationPlugin_Extension.d.ts.map +1 -1
  76. package/lib/stores/DependencyProjectViewerHelper.d.ts +19 -0
  77. package/lib/stores/DependencyProjectViewerHelper.d.ts.map +1 -0
  78. package/lib/stores/DependencyProjectViewerHelper.js +23 -0
  79. package/lib/stores/DependencyProjectViewerHelper.js.map +1 -0
  80. package/lib/stores/EditorGraphState.d.ts +9 -2
  81. package/lib/stores/EditorGraphState.d.ts.map +1 -1
  82. package/lib/stores/EditorGraphState.js +35 -97
  83. package/lib/stores/EditorGraphState.js.map +1 -1
  84. package/lib/stores/EditorStore.d.ts.map +1 -1
  85. package/lib/stores/EditorStore.js +7 -1
  86. package/lib/stores/EditorStore.js.map +1 -1
  87. package/lib/stores/EditorTabManagerState.d.ts +1 -1
  88. package/lib/stores/EditorTabManagerState.d.ts.map +1 -1
  89. package/lib/stores/EditorTabManagerState.js +11 -13
  90. package/lib/stores/EditorTabManagerState.js.map +1 -1
  91. package/lib/stores/ExplorerTreeState.d.ts +4 -4
  92. package/lib/stores/ExplorerTreeState.d.ts.map +1 -1
  93. package/lib/stores/ExplorerTreeState.js +12 -13
  94. package/lib/stores/ExplorerTreeState.js.map +1 -1
  95. package/lib/stores/editor/NewElementState.d.ts.map +1 -1
  96. package/lib/stores/editor/NewElementState.js +0 -3
  97. package/lib/stores/editor/NewElementState.js.map +1 -1
  98. package/lib/stores/editor-state/ExternalFormatState.d.ts +2 -0
  99. package/lib/stores/editor-state/ExternalFormatState.d.ts.map +1 -1
  100. package/lib/stores/editor-state/ExternalFormatState.js +6 -0
  101. package/lib/stores/editor-state/ExternalFormatState.js.map +1 -1
  102. package/lib/stores/editor-state/FileGenerationState.d.ts +18 -18
  103. package/lib/stores/editor-state/FileGenerationState.d.ts.map +1 -1
  104. package/lib/stores/editor-state/FileGenerationState.js +86 -133
  105. package/lib/stores/editor-state/FileGenerationState.js.map +1 -1
  106. package/lib/stores/editor-state/FileGenerationViewerState.d.ts +3 -3
  107. package/lib/stores/editor-state/FileGenerationViewerState.d.ts.map +1 -1
  108. package/lib/stores/editor-state/FileGenerationViewerState.js.map +1 -1
  109. package/lib/stores/editor-state/FileSystemState.d.ts +30 -0
  110. package/lib/stores/editor-state/FileSystemState.d.ts.map +1 -0
  111. package/lib/stores/editor-state/FileSystemState.js +82 -0
  112. package/lib/stores/editor-state/FileSystemState.js.map +1 -0
  113. package/lib/stores/editor-state/GraphGenerationState.d.ts +9 -9
  114. package/lib/stores/editor-state/GraphGenerationState.d.ts.map +1 -1
  115. package/lib/stores/editor-state/GraphGenerationState.js +14 -15
  116. package/lib/stores/editor-state/GraphGenerationState.js.map +1 -1
  117. package/lib/stores/editor-state/element-editor-state/ElementEditorState.d.ts +25 -2
  118. package/lib/stores/editor-state/element-editor-state/ElementEditorState.d.ts.map +1 -1
  119. package/lib/stores/editor-state/element-editor-state/ElementEditorState.js +50 -7
  120. package/lib/stores/editor-state/element-editor-state/ElementEditorState.js.map +1 -1
  121. package/lib/stores/editor-state/element-editor-state/ElementExternalFormatGenerationState.d.ts +44 -0
  122. package/lib/stores/editor-state/element-editor-state/ElementExternalFormatGenerationState.d.ts.map +1 -0
  123. package/lib/stores/editor-state/element-editor-state/ElementExternalFormatGenerationState.js +172 -0
  124. package/lib/stores/editor-state/element-editor-state/ElementExternalFormatGenerationState.js.map +1 -0
  125. package/lib/stores/editor-state/element-editor-state/mapping/MappingExecutionState.js +1 -1
  126. package/lib/stores/editor-state/element-editor-state/mapping/MappingExecutionState.js.map +1 -1
  127. package/lib/stores/editor-state/element-editor-state/mapping/MappingTestState.js +2 -2
  128. package/lib/stores/editor-state/element-editor-state/mapping/MappingTestState.js.map +1 -1
  129. package/lib/stores/editor-state/element-editor-state/service/ServiceEditorState.d.ts +3 -0
  130. package/lib/stores/editor-state/element-editor-state/service/ServiceEditorState.d.ts.map +1 -1
  131. package/lib/stores/editor-state/element-editor-state/service/ServiceEditorState.js +14 -2
  132. package/lib/stores/editor-state/element-editor-state/service/ServiceEditorState.js.map +1 -1
  133. package/lib/stores/editor-state/element-editor-state/service/ServiceExecutionState.d.ts +9 -6
  134. package/lib/stores/editor-state/element-editor-state/service/ServiceExecutionState.d.ts.map +1 -1
  135. package/lib/stores/editor-state/element-editor-state/service/ServiceExecutionState.js +38 -28
  136. package/lib/stores/editor-state/element-editor-state/service/ServiceExecutionState.js.map +1 -1
  137. package/lib/stores/editor-state/element-editor-state/service/testable/ServiceTestEditorState.d.ts.map +1 -1
  138. package/lib/stores/editor-state/element-editor-state/service/testable/ServiceTestEditorState.js +6 -3
  139. package/lib/stores/editor-state/element-editor-state/service/testable/ServiceTestEditorState.js.map +1 -1
  140. package/lib/stores/shared/FileSystemTreeUtils.d.ts +56 -0
  141. package/lib/stores/shared/FileSystemTreeUtils.d.ts.map +1 -0
  142. package/lib/stores/shared/{FileGenerationTreeUtils.js → FileSystemTreeUtils.js} +31 -32
  143. package/lib/stores/shared/FileSystemTreeUtils.js.map +1 -0
  144. package/lib/stores/shared/PackageTreeUtils.d.ts +6 -4
  145. package/lib/stores/shared/PackageTreeUtils.d.ts.map +1 -1
  146. package/lib/stores/shared/PackageTreeUtils.js +90 -11
  147. package/lib/stores/shared/PackageTreeUtils.js.map +1 -1
  148. package/lib/stores/sidebar-state/testable/GlobalTestRunnerState.d.ts +3 -3
  149. package/lib/stores/sidebar-state/testable/GlobalTestRunnerState.d.ts.map +1 -1
  150. package/lib/stores/sidebar-state/testable/GlobalTestRunnerState.js +37 -1
  151. package/lib/stores/sidebar-state/testable/GlobalTestRunnerState.js.map +1 -1
  152. package/package.json +12 -12
  153. package/src/components/editor/StatusBar.tsx +1 -1
  154. package/src/components/editor/command-center/ProjectSearchCommand.tsx +1 -0
  155. package/src/components/editor/edit-panel/EditPanel.tsx +79 -25
  156. package/src/components/editor/edit-panel/GenerationSpecificationEditor.tsx +2 -1
  157. package/src/components/editor/edit-panel/connection-editor/ConnectionEditor.tsx +1 -0
  158. package/src/components/editor/edit-panel/element-generation-editor/ElementGenerationEditor.tsx +5 -7
  159. package/src/components/editor/edit-panel/element-generation-editor/ElementXTGenerationEditor.tsx +194 -0
  160. package/src/components/editor/edit-panel/element-generation-editor/FileGenerationEditor.tsx +6 -270
  161. package/src/components/editor/edit-panel/element-generation-editor/FileSystemViewer.tsx +296 -0
  162. package/src/components/editor/edit-panel/external-format-editor/DSL_ExternalFormat_BindingElementEditor.tsx +177 -155
  163. package/src/components/editor/edit-panel/mapping-editor/EnumerationMappingEditor.tsx +3 -1
  164. package/src/components/editor/edit-panel/mapping-editor/InstanceSetImplementationSourceSelectorModal.tsx +3 -3
  165. package/src/components/editor/edit-panel/mapping-editor/MappingExecutionQueryBuilder.tsx +3 -0
  166. package/src/components/editor/edit-panel/mapping-editor/NewMappingElementModal.tsx +3 -1
  167. package/src/components/editor/edit-panel/service-editor/ServiceEditor.tsx +243 -184
  168. package/src/components/editor/edit-panel/service-editor/ServiceExecutionQueryEditor.tsx +42 -15
  169. package/src/components/editor/edit-panel/service-editor/testable/ServiceTestableEditor.tsx +2 -65
  170. package/src/components/editor/edit-panel/uml-editor/ClassEditor.tsx +9 -3
  171. package/src/components/editor/side-bar/CreateNewElementModal.tsx +1 -0
  172. package/src/components/editor/side-bar/Explorer.tsx +82 -13
  173. package/src/components/editor/side-bar/testable/GlobalTestRunner.tsx +31 -9
  174. package/src/index.ts +5 -2
  175. package/src/stores/DSL_Generation_LegendStudioApplicationPlugin_Extension.ts +2 -2
  176. package/src/stores/DependencyProjectViewerHelper.ts +39 -0
  177. package/src/stores/EditorGraphState.ts +56 -155
  178. package/src/stores/EditorStore.ts +15 -5
  179. package/src/stores/EditorTabManagerState.ts +17 -20
  180. package/src/stores/ExplorerTreeState.ts +26 -18
  181. package/src/stores/editor/NewElementState.ts +0 -2
  182. package/src/stores/editor-state/ExternalFormatState.ts +9 -0
  183. package/src/stores/editor-state/FileGenerationState.ts +129 -180
  184. package/src/stores/editor-state/FileGenerationViewerState.ts +3 -3
  185. package/src/stores/editor-state/FileSystemState.ts +111 -0
  186. package/src/stores/editor-state/GraphGenerationState.ts +35 -31
  187. package/src/stores/editor-state/element-editor-state/ElementEditorState.ts +91 -6
  188. package/src/stores/editor-state/element-editor-state/ElementExternalFormatGenerationState.ts +266 -0
  189. package/src/stores/editor-state/element-editor-state/mapping/MappingExecutionState.ts +1 -1
  190. package/src/stores/editor-state/element-editor-state/mapping/MappingTestState.ts +2 -2
  191. package/src/stores/editor-state/element-editor-state/service/ServiceEditorState.ts +23 -2
  192. package/src/stores/editor-state/element-editor-state/service/ServiceExecutionState.ts +60 -55
  193. package/src/stores/editor-state/element-editor-state/service/testable/ServiceTestEditorState.ts +6 -2
  194. package/src/stores/shared/{FileGenerationTreeUtils.ts → FileSystemTreeUtils.ts} +77 -76
  195. package/src/stores/shared/PackageTreeUtils.ts +144 -10
  196. package/src/stores/sidebar-state/testable/GlobalTestRunnerState.ts +42 -3
  197. package/tsconfig.json +6 -1
  198. package/lib/stores/shared/FileGenerationTreeUtils.d.ts +0 -56
  199. package/lib/stores/shared/FileGenerationTreeUtils.d.ts.map +0 -1
  200. package/lib/stores/shared/FileGenerationTreeUtils.js.map +0 -1
@@ -0,0 +1,194 @@
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 { useApplicationStore } from '@finos/legend-application';
18
+ import {
19
+ ArrowCircleLeftIcon,
20
+ PanelContent,
21
+ RefreshIcon,
22
+ ResizablePanel,
23
+ ResizablePanelGroup,
24
+ ResizablePanelSplitter,
25
+ ResizablePanelSplitterLine,
26
+ } from '@finos/legend-art';
27
+ import type { GenerationProperty } from '@finos/legend-graph';
28
+ import { debounce } from '@finos/legend-shared';
29
+ import { flowResult } from 'mobx';
30
+ import { observer } from 'mobx-react-lite';
31
+ import { useEffect, useMemo } from 'react';
32
+ import type { ElementEditorState } from '../../../../stores/editor-state/element-editor-state/ElementEditorState.js';
33
+ import type { ElementXTSchemaGenerationState } from '../../../../stores/editor-state/element-editor-state/ElementExternalFormatGenerationState.js';
34
+ import { ModelUnitEditor } from '../external-format-editor/DSL_ExternalFormat_BindingElementEditor.js';
35
+ import { GenerationPropertyEditor } from './FileGenerationEditor.js';
36
+ import { FileSystemViewer } from './FileSystemViewer.js';
37
+
38
+ enum HIDDEN_CONFIGURATION_PROPERTIES {
39
+ FORMAT = 'format',
40
+ TARGET_SCHEMA_SET = 'targetSchemaSet',
41
+ }
42
+
43
+ export const ExternalFormatGeneratioConfigEditor = observer(
44
+ (props: {
45
+ isReadOnly: boolean;
46
+ elementEditorState: ElementEditorState;
47
+ xtState: ElementXTSchemaGenerationState;
48
+ }) => {
49
+ const { isReadOnly, xtState } = props;
50
+ const xtGenerationState = xtState.xtGenerationState;
51
+ const editorStore = xtState.editorStore;
52
+ const applicationStore = editorStore.applicationStore;
53
+ const configSpecification = xtState.xtGenerationState.configSpecification;
54
+ const schemaGenerationProperties =
55
+ xtState.description.schemaGenerationProperties;
56
+ const debouncedRegenerate = useMemo(
57
+ () =>
58
+ debounce(() => flowResult(xtState.xtGenerationState.generate()), 500),
59
+ [xtState],
60
+ );
61
+ const update = (
62
+ generationProperty: GenerationProperty,
63
+ newValue: object,
64
+ ): void => {
65
+ debouncedRegenerate.cancel();
66
+ xtGenerationState.updateFileGenerationParameters(
67
+ configSpecification,
68
+ generationProperty,
69
+ newValue,
70
+ );
71
+ debouncedRegenerate()?.catch(applicationStore.alertUnhandledError);
72
+ };
73
+ const resetDefaultConfiguration = (): void => {
74
+ debouncedRegenerate.cancel();
75
+ xtGenerationState.resetGenerator();
76
+ debouncedRegenerate()?.catch(applicationStore.alertUnhandledError);
77
+ };
78
+
79
+ const getConfigValue = (name: string): unknown | undefined =>
80
+ xtState.xtGenerationState.configSpecification.configurationProperties.find(
81
+ (e) => e.name === name,
82
+ )?.value;
83
+
84
+ return (
85
+ <div className="panel file-generation-editor__configuration">
86
+ <div className="panel__header">
87
+ <div className="panel__header__title">
88
+ <div className="panel__header__title__label">{`${xtState.description.name} configuration`}</div>
89
+ </div>
90
+ <div className="panel__header__actions">
91
+ <button
92
+ className="panel__header__action file-generation-editor__configuration__reset-btn"
93
+ tabIndex={-1}
94
+ disabled={
95
+ isReadOnly ||
96
+ !configSpecification.configurationProperties.length
97
+ }
98
+ onClick={resetDefaultConfiguration}
99
+ title="Reset to default configuration"
100
+ >
101
+ <RefreshIcon />
102
+ </button>
103
+ </div>
104
+ </div>
105
+ <PanelContent>
106
+ <div className="file-generation-editor__configuration__content">
107
+ <ModelUnitEditor
108
+ isReadOnly={isReadOnly}
109
+ modelUnit={configSpecification.modelUnit}
110
+ />
111
+ {schemaGenerationProperties
112
+
113
+ .filter(
114
+ (property) =>
115
+ !Object.values(HIDDEN_CONFIGURATION_PROPERTIES).includes(
116
+ property.name as HIDDEN_CONFIGURATION_PROPERTIES,
117
+ ),
118
+ )
119
+ .map((abstractGenerationProperty) => (
120
+ <GenerationPropertyEditor
121
+ key={
122
+ abstractGenerationProperty.name +
123
+ abstractGenerationProperty.type
124
+ }
125
+ update={update}
126
+ isReadOnly={isReadOnly}
127
+ getConfigValue={getConfigValue}
128
+ property={abstractGenerationProperty}
129
+ />
130
+ ))}
131
+ </div>
132
+ </PanelContent>
133
+ </div>
134
+ );
135
+ },
136
+ );
137
+
138
+ export const ElementXTGenerationEditor = observer(
139
+ (props: {
140
+ currentElementState: ElementEditorState;
141
+ elementXTState: ElementXTSchemaGenerationState;
142
+ }) => {
143
+ const { elementXTState, currentElementState } = props;
144
+ const xtGenerationState = elementXTState.xtGenerationState;
145
+ const applicationStore = useApplicationStore();
146
+ const leaveElementGenerationView = (): void =>
147
+ currentElementState.setGenerationModeState(undefined);
148
+ useEffect(() => {
149
+ flowResult(elementXTState.regenerate()).catch(
150
+ applicationStore.alertUnhandledError,
151
+ );
152
+ }, [applicationStore, currentElementState, elementXTState]);
153
+
154
+ return (
155
+ <div className="panel element-generation-editor">
156
+ <div className="panel__header element-generation-editor__header">
157
+ <div className="panel__header__title">
158
+ <button
159
+ className="panel__header__action element-generation-editor__leave-btn"
160
+ tabIndex={-1}
161
+ onClick={leaveElementGenerationView}
162
+ title="Leave element generation view mode"
163
+ >
164
+ <ArrowCircleLeftIcon /> exit generation view
165
+ </button>
166
+ </div>
167
+ </div>
168
+ <div className="panel__content element-generation-editor__content">
169
+ <div className="file-generation-editor">
170
+ <ResizablePanelGroup orientation="vertical">
171
+ <ResizablePanel
172
+ size={300}
173
+ minSize={300}
174
+ className="file-generation-editor__split-pane"
175
+ >
176
+ <ExternalFormatGeneratioConfigEditor
177
+ isReadOnly={currentElementState.isReadOnly}
178
+ elementEditorState={currentElementState}
179
+ xtState={elementXTState}
180
+ />
181
+ </ResizablePanel>
182
+ <ResizablePanelSplitter>
183
+ <ResizablePanelSplitterLine color="var(--color-dark-grey-200)" />
184
+ </ResizablePanelSplitter>
185
+ <ResizablePanel>
186
+ <FileSystemViewer generatedFileState={xtGenerationState} />
187
+ </ResizablePanel>
188
+ </ResizablePanelGroup>
189
+ </div>
190
+ </div>
191
+ </div>
192
+ );
193
+ },
194
+ );
@@ -14,15 +14,11 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import { useState, useMemo, useCallback, Fragment } from 'react';
17
+ import { useState, useMemo, useCallback } from 'react';
18
18
  import { observer } from 'mobx-react-lite';
19
19
  import { flowResult, runInAction } from 'mobx';
20
20
  import { getElementIcon } from '../../../shared/ElementIconUtils.js';
21
21
  import { useDrop } from 'react-dnd';
22
- import {
23
- getTextContent,
24
- getEditorLanguageForFormat,
25
- } from '../../../../stores/editor-state/FileGenerationViewerState.js';
26
22
  import { FileGenerationEditorState } from '../../../../stores/editor-state/element-editor-state/FileGenerationEditorState.js';
27
23
  import {
28
24
  type DebouncedFunc,
@@ -32,28 +28,17 @@ import {
32
28
  type PlainObject,
33
29
  } from '@finos/legend-shared';
34
30
  import {
35
- type TreeNodeContainerProps,
36
- type TreeData,
37
- type TreeNodeData,
38
31
  ResizablePanelGroup,
39
32
  ResizablePanel,
40
33
  ResizablePanelSplitter,
41
34
  ResizablePanelSplitterLine,
42
35
  clsx,
43
- TreeView,
44
- BlankPanelContent,
45
- PanelLoadingIndicator,
46
36
  CustomSelectorInput,
47
37
  PencilIcon,
48
38
  RefreshIcon,
49
39
  TimesIcon,
50
40
  CheckSquareIcon,
51
41
  SquareIcon,
52
- ChevronDownIcon,
53
- ChevronRightIcon,
54
- FolderOpenIcon,
55
- FolderIcon,
56
- FileCodeIcon,
57
42
  LockIcon,
58
43
  SaveIcon,
59
44
  PanelDropZone,
@@ -68,12 +53,6 @@ import {
68
53
  } from '../../../../stores/shared/DnDUtils.js';
69
54
  import type { FileGenerationState } from '../../../../stores/editor-state/FileGenerationState.js';
70
55
  import type { ElementFileGenerationState } from '../../../../stores/editor-state/element-editor-state/ElementFileGenerationState.js';
71
- import {
72
- type GenerationTreeNodeData,
73
- GenerationDirectory,
74
- GenerationFile,
75
- getFileGenerationChildNodes,
76
- } from '../../../../stores/shared/FileGenerationTreeUtils.js';
77
56
  import { LEGEND_STUDIO_TEST_ID } from '../../../LegendStudioTestID.js';
78
57
  import { useEditorStore } from '../../EditorStoreProvider.js';
79
58
  import {
@@ -86,256 +65,14 @@ import {
86
65
  resolvePackagePathAndElementName,
87
66
  getNullableFileGenerationConfig,
88
67
  } from '@finos/legend-graph';
89
- import {
90
- TextInputEditor,
91
- useApplicationStore,
92
- } from '@finos/legend-application';
93
- import type { DSL_Generation_LegendStudioApplicationPlugin_Extension } from '../../../../stores/DSL_Generation_LegendStudioApplicationPlugin_Extension.js';
68
+ import { useApplicationStore } from '@finos/legend-application';
94
69
  import {
95
70
  fileGeneration_addScopeElement,
96
71
  fileGeneration_changeScopeElement,
97
72
  fileGeneration_deleteScopeElement,
98
73
  fileGeneration_setGenerationOutputPath,
99
74
  } from '../../../../stores/shared/modifier/DSL_Generation_GraphModifierHelper.js';
100
-
101
- export const FileGenerationTreeNodeContainer: React.FC<
102
- TreeNodeContainerProps<
103
- GenerationTreeNodeData,
104
- {
105
- selectedNode?: TreeNodeData | undefined;
106
- }
107
- >
108
- > = (props) => {
109
- const { node, level, stepPaddingInRem, onNodeSelect, innerProps } = props;
110
- const { selectedNode } = innerProps;
111
- const isSelected = selectedNode === node;
112
- const isDirectory = node.fileNode instanceof GenerationDirectory;
113
- const expandIcon = !isDirectory ? (
114
- <div />
115
- ) : node.isOpen ? (
116
- <ChevronDownIcon />
117
- ) : (
118
- <ChevronRightIcon />
119
- );
120
- const iconPackageColor = 'color--generated';
121
- const nodeIcon = isDirectory ? (
122
- node.isOpen ? (
123
- <div className={iconPackageColor}>
124
- <FolderOpenIcon />
125
- </div>
126
- ) : (
127
- <div className={iconPackageColor}>
128
- <FolderIcon />
129
- </div>
130
- )
131
- ) : (
132
- <div className="icon">
133
- <FileCodeIcon />
134
- </div>
135
- );
136
- const selectNode: React.MouseEventHandler = (event) => onNodeSelect?.(node);
137
-
138
- return (
139
- <div
140
- className={clsx(
141
- 'tree-view__node__container generation-result-viewer__explorer__package-tree__node__container',
142
- {
143
- 'generation-result-viewer__explorer__package-tree__node__container--selected':
144
- isSelected,
145
- },
146
- )}
147
- onClick={selectNode}
148
- style={{
149
- paddingLeft: `${level * (stepPaddingInRem ?? 1)}rem`,
150
- display: 'flex',
151
- }}
152
- >
153
- <div className="tree-view__node__icon generation-result-viewer__explorer__package-tree__node__icon">
154
- <div className="generation-result-viewer__explorer__package-tree__node__icon__expand">
155
- {expandIcon}
156
- </div>
157
- <div className="generation-result-viewer__explorer__package-tree__node__icon__type">
158
- {nodeIcon}
159
- </div>
160
- </div>
161
- <button
162
- className="tree-view__node__label generation-result-viewer__explorer__package-tree__node__label"
163
- tabIndex={-1}
164
- title={node.fileNode.path}
165
- >
166
- {node.label}
167
- </button>
168
- </div>
169
- );
170
- };
171
-
172
- export const FileGenerationTree = observer(
173
- (props: {
174
- selectedNode?: TreeNodeData | undefined;
175
- directoryTreeData: TreeData<GenerationTreeNodeData>;
176
- onNodeSelect: (node: GenerationTreeNodeData) => void;
177
- getFileElementTreeChildNodes: (
178
- node: GenerationTreeNodeData,
179
- ) => GenerationTreeNodeData[];
180
- }) => {
181
- const {
182
- directoryTreeData,
183
- onNodeSelect,
184
- getFileElementTreeChildNodes,
185
- selectedNode,
186
- } = props;
187
-
188
- return (
189
- <TreeView
190
- components={{
191
- TreeNodeContainer: FileGenerationTreeNodeContainer,
192
- }}
193
- treeData={directoryTreeData}
194
- onNodeSelect={onNodeSelect}
195
- getChildNodes={getFileElementTreeChildNodes}
196
- innerProps={{
197
- selectedNode: selectedNode,
198
- }}
199
- />
200
- );
201
- },
202
- );
203
-
204
- export const GenerationResultExplorer = observer(
205
- (props: { fileGenerationState: FileGenerationState }) => {
206
- const { fileGenerationState } = props;
207
- const treeData = guaranteeNonNullable(
208
- fileGenerationState.directoryTreeData,
209
- );
210
- const onNodeSelect = (node: GenerationTreeNodeData): void =>
211
- fileGenerationState.onTreeNodeSelect(node, treeData);
212
- const getMappingElementTreeChildNodes = (
213
- node: GenerationTreeNodeData,
214
- ): GenerationTreeNodeData[] => getFileGenerationChildNodes(node, treeData);
215
-
216
- if (!treeData.nodes.size) {
217
- return <BlankPanelContent>No content</BlankPanelContent>;
218
- }
219
- return (
220
- <div className="generation-result-viewer__explorer__content">
221
- <FileGenerationTree
222
- selectedNode={fileGenerationState.selectedNode}
223
- directoryTreeData={treeData}
224
- onNodeSelect={onNodeSelect}
225
- getFileElementTreeChildNodes={getMappingElementTreeChildNodes}
226
- />
227
- </div>
228
- );
229
- },
230
- );
231
-
232
- export const GenerationResultViewer = observer(
233
- (props: { fileGenerationState: FileGenerationState }) => {
234
- const { fileGenerationState } = props;
235
- const applicationStore = useApplicationStore();
236
- const selectedNode = fileGenerationState.selectedNode;
237
- const fileNode = selectedNode?.fileNode;
238
- const regenerate = applicationStore.guardUnhandledError(() =>
239
- flowResult(fileGenerationState.generate()),
240
- );
241
- const extraFileGenerationResultViewerActions =
242
- fileNode instanceof GenerationFile
243
- ? fileGenerationState.editorStore.pluginManager
244
- .getApplicationPlugins()
245
- .flatMap(
246
- (plugin) =>
247
- (
248
- plugin as DSL_Generation_LegendStudioApplicationPlugin_Extension
249
- ).getExtraFileGenerationResultViewerActionConfigurations?.() ??
250
- [],
251
- )
252
- .map((config) => (
253
- <Fragment key={config.key}>
254
- {config.renderer(fileGenerationState)}
255
- </Fragment>
256
- ))
257
- : null;
258
- return (
259
- <ResizablePanelGroup orientation="vertical">
260
- <ResizablePanel size={250} minSize={250}>
261
- <div className="generation-result-viewer__side-bar">
262
- <div className="panel generation-result-viewer__explorer">
263
- <div className="panel__header">
264
- <div className="panel__header__title">
265
- <div className="panel__header__title__label">result</div>
266
- </div>
267
- <div className="panel__header__actions">
268
- <button
269
- className={clsx(
270
- 'panel__header__action generation-result-viewer__regenerate-btn',
271
- {
272
- ' generation-result-viewer__regenerate-btn--loading':
273
- fileGenerationState.isGenerating,
274
- },
275
- )}
276
- tabIndex={-1}
277
- disabled={fileGenerationState.isGenerating}
278
- onClick={regenerate}
279
- title="Regenerate"
280
- >
281
- <RefreshIcon />
282
- </button>
283
- </div>
284
- </div>
285
- <PanelContent>
286
- <PanelLoadingIndicator
287
- isLoading={fileGenerationState.isGenerating}
288
- />
289
- {Boolean(fileGenerationState.directoryTreeData) && (
290
- <GenerationResultExplorer
291
- fileGenerationState={fileGenerationState}
292
- />
293
- )}
294
- {Boolean(!fileGenerationState.directoryTreeData) && (
295
- <BlankPanelContent>
296
- Generation result not available
297
- </BlankPanelContent>
298
- )}
299
- </PanelContent>
300
- </div>
301
- </div>
302
- </ResizablePanel>
303
- <ResizablePanelSplitter>
304
- <ResizablePanelSplitterLine color="var(--color-dark-grey-200)" />
305
- </ResizablePanelSplitter>
306
- <ResizablePanel>
307
- <div className="panel generation-result-viewer__file">
308
- <div className="panel__header">
309
- {fileNode && !(fileNode instanceof GenerationDirectory) && (
310
- <div className="panel__header__title">
311
- <div className="panel__header__title__label">file</div>
312
- <div className="panel__header__title__content generation-result-viewer__file__header__name">
313
- {fileNode.name}
314
- </div>
315
- </div>
316
- )}
317
- <div className="panel__header__actions">
318
- {extraFileGenerationResultViewerActions}
319
- </div>
320
- </div>
321
- <PanelContent>
322
- {fileNode instanceof GenerationFile && (
323
- <TextInputEditor
324
- inputValue={getTextContent(fileNode.content, fileNode.format)}
325
- isReadOnly={true}
326
- language={getEditorLanguageForFormat(fileNode.format)}
327
- />
328
- )}
329
- {!(fileNode instanceof GenerationFile) && (
330
- <BlankPanelContent>No file selected</BlankPanelContent>
331
- )}
332
- </PanelContent>
333
- </div>
334
- </ResizablePanel>
335
- </ResizablePanelGroup>
336
- );
337
- },
338
- );
75
+ import { FileSystemViewer } from './FileSystemViewer.js';
339
76
 
340
77
  const FileGenerationScopeEditor = observer(
341
78
  (props: {
@@ -1299,7 +1036,7 @@ export const FileGenerationConfigurationEditor = observer(
1299
1036
  };
1300
1037
  const resetDefaultConfiguration = (): void => {
1301
1038
  debouncedRegenerate.cancel();
1302
- fileGenerationState.resetFileGeneration();
1039
+ fileGenerationState.resetGenerator();
1303
1040
  debouncedRegenerate()?.catch(applicationStore.alertUnhandledError);
1304
1041
  };
1305
1042
 
@@ -1474,10 +1211,9 @@ export const FileGenerationEditor = observer(() => {
1474
1211
  <ResizablePanelSplitter>
1475
1212
  <ResizablePanelSplitterLine color="var(--color-dark-grey-200)" />
1476
1213
  </ResizablePanelSplitter>
1477
-
1478
1214
  <ResizablePanel>
1479
- <GenerationResultViewer
1480
- fileGenerationState={
1215
+ <FileSystemViewer
1216
+ generatedFileState={
1481
1217
  fileGenerationEditorState.fileGenerationState
1482
1218
  }
1483
1219
  />