@finos/legend-application-studio 13.1.2 → 15.0.1

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 (85) hide show
  1. package/lib/components/EditorComponentTestUtils.d.ts +3 -13
  2. package/lib/components/EditorComponentTestUtils.d.ts.map +1 -1
  3. package/lib/components/EditorComponentTestUtils.js +3 -22
  4. package/lib/components/EditorComponentTestUtils.js.map +1 -1
  5. package/lib/components/editor/edit-panel/EditPanel.js +4 -4
  6. package/lib/components/editor/edit-panel/EditPanel.js.map +1 -1
  7. package/lib/components/editor/edit-panel/{ModelLoader.d.ts → ModelImporter.d.ts} +2 -2
  8. package/lib/components/editor/edit-panel/ModelImporter.d.ts.map +1 -0
  9. package/lib/components/editor/edit-panel/ModelImporter.js +127 -0
  10. package/lib/components/editor/edit-panel/ModelImporter.js.map +1 -0
  11. package/lib/components/editor/edit-panel/external-format-editor/SchemaSetElementEditor.d.ts +7 -0
  12. package/lib/components/editor/edit-panel/external-format-editor/SchemaSetElementEditor.d.ts.map +1 -1
  13. package/lib/components/editor/edit-panel/external-format-editor/SchemaSetElementEditor.js +18 -42
  14. package/lib/components/editor/edit-panel/external-format-editor/SchemaSetElementEditor.js.map +1 -1
  15. package/lib/components/editor/edit-panel/external-format-editor/SchemaSetModelGenerationEditor.d.ts +24 -0
  16. package/lib/components/editor/edit-panel/external-format-editor/SchemaSetModelGenerationEditor.d.ts.map +1 -0
  17. package/lib/components/editor/edit-panel/external-format-editor/SchemaSetModelGenerationEditor.js +75 -0
  18. package/lib/components/editor/edit-panel/external-format-editor/SchemaSetModelGenerationEditor.js.map +1 -0
  19. package/lib/components/editor/edit-panel/mapping-editor/NewMappingElementModal.d.ts.map +1 -1
  20. package/lib/components/editor/edit-panel/mapping-editor/NewMappingElementModal.js +1 -2
  21. package/lib/components/editor/edit-panel/mapping-editor/NewMappingElementModal.js.map +1 -1
  22. package/lib/components/editor/side-bar/Explorer.js +4 -4
  23. package/lib/components/editor/side-bar/Explorer.js.map +1 -1
  24. package/lib/index.css +1 -1
  25. package/lib/index.d.ts +1 -0
  26. package/lib/index.d.ts.map +1 -1
  27. package/lib/index.js +1 -0
  28. package/lib/index.js.map +1 -1
  29. package/lib/package.json +7 -7
  30. package/lib/stores/EditorGraphState.d.ts +1 -1
  31. package/lib/stores/EditorGraphState.d.ts.map +1 -1
  32. package/lib/stores/EditorGraphState.js +10 -10
  33. package/lib/stores/EditorGraphState.js.map +1 -1
  34. package/lib/stores/EditorStore.d.ts +3 -3
  35. package/lib/stores/EditorStore.d.ts.map +1 -1
  36. package/lib/stores/EditorStore.js +6 -8
  37. package/lib/stores/EditorStore.js.map +1 -1
  38. package/lib/stores/LegendStudioApplicationPlugin.d.ts +7 -5
  39. package/lib/stores/LegendStudioApplicationPlugin.d.ts.map +1 -1
  40. package/lib/stores/LegendStudioApplicationPlugin.js.map +1 -1
  41. package/lib/stores/editor-state/ExternalFormatState.d.ts +3 -2
  42. package/lib/stores/editor-state/ExternalFormatState.d.ts.map +1 -1
  43. package/lib/stores/editor-state/ExternalFormatState.js +11 -8
  44. package/lib/stores/editor-state/ExternalFormatState.js.map +1 -1
  45. package/lib/stores/editor-state/ModelImporterState.d.ts +100 -0
  46. package/lib/stores/editor-state/ModelImporterState.d.ts.map +1 -0
  47. package/lib/stores/editor-state/ModelImporterState.js +358 -0
  48. package/lib/stores/editor-state/ModelImporterState.js.map +1 -0
  49. package/lib/stores/editor-state/element-editor-state/external-format/SchemaSetEditorState.d.ts +35 -12
  50. package/lib/stores/editor-state/element-editor-state/external-format/SchemaSetEditorState.d.ts.map +1 -1
  51. package/lib/stores/editor-state/element-editor-state/external-format/SchemaSetEditorState.js +141 -34
  52. package/lib/stores/editor-state/element-editor-state/external-format/SchemaSetEditorState.js.map +1 -1
  53. package/lib/stores/editor-state/entity-diff-editor-state/EntityChangeConflictEditorState.js +1 -1
  54. package/lib/stores/editor-state/entity-diff-editor-state/EntityChangeConflictEditorState.js.map +1 -1
  55. package/lib/stores/graphModifier/DSLExternalFormat_GraphModifierHelper.d.ts +1 -0
  56. package/lib/stores/graphModifier/DSLExternalFormat_GraphModifierHelper.d.ts.map +1 -1
  57. package/lib/stores/graphModifier/DSLExternalFormat_GraphModifierHelper.js +3 -0
  58. package/lib/stores/graphModifier/DSLExternalFormat_GraphModifierHelper.js.map +1 -1
  59. package/package.json +15 -15
  60. package/src/components/EditorComponentTestUtils.tsx +2 -29
  61. package/src/components/editor/edit-panel/EditPanel.tsx +4 -4
  62. package/src/components/editor/edit-panel/ModelImporter.tsx +372 -0
  63. package/src/components/editor/edit-panel/external-format-editor/SchemaSetElementEditor.tsx +47 -163
  64. package/src/components/editor/edit-panel/external-format-editor/SchemaSetModelGenerationEditor.tsx +226 -0
  65. package/src/components/editor/edit-panel/mapping-editor/NewMappingElementModal.tsx +1 -2
  66. package/src/components/editor/side-bar/Explorer.tsx +8 -8
  67. package/src/index.ts +1 -0
  68. package/src/stores/EditorGraphState.ts +13 -12
  69. package/src/stores/EditorStore.ts +7 -9
  70. package/src/stores/LegendStudioApplicationPlugin.ts +16 -7
  71. package/src/stores/editor-state/ExternalFormatState.ts +15 -12
  72. package/src/stores/editor-state/ModelImporterState.ts +514 -0
  73. package/src/stores/editor-state/element-editor-state/external-format/SchemaSetEditorState.ts +203 -46
  74. package/src/stores/editor-state/entity-diff-editor-state/EntityChangeConflictEditorState.ts +1 -1
  75. package/src/stores/graphModifier/DSLExternalFormat_GraphModifierHelper.ts +5 -0
  76. package/tsconfig.json +3 -2
  77. package/lib/components/editor/edit-panel/ModelLoader.d.ts.map +0 -1
  78. package/lib/components/editor/edit-panel/ModelLoader.js +0 -95
  79. package/lib/components/editor/edit-panel/ModelLoader.js.map +0 -1
  80. package/lib/stores/editor-state/ModelLoaderState.d.ts +0 -52
  81. package/lib/stores/editor-state/ModelLoaderState.d.ts.map +0 -1
  82. package/lib/stores/editor-state/ModelLoaderState.js +0 -199
  83. package/lib/stores/editor-state/ModelLoaderState.js.map +0 -1
  84. package/src/components/editor/edit-panel/ModelLoader.tsx +0 -259
  85. package/src/stores/editor-state/ModelLoaderState.ts +0 -280
@@ -1,199 +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
- import { observable, action, flow, makeObservable } from 'mobx';
17
- import { EditorState } from './EditorState.js';
18
- import { assertErrorThrown, LogEvent, UnsupportedOperationError, isNonNullable, } from '@finos/legend-shared';
19
- import { LEGEND_STUDIO_APP_EVENT } from '../LegendStudioAppEvent.js';
20
- import { ImportMode, } from '@finos/legend-graph';
21
- import { TAB_SIZE } from '@finos/legend-application';
22
- export var MODEL_UPDATER_INPUT_TYPE;
23
- (function (MODEL_UPDATER_INPUT_TYPE) {
24
- MODEL_UPDATER_INPUT_TYPE["ENTITIES"] = "ENTITIES";
25
- MODEL_UPDATER_INPUT_TYPE["PURE_PROTOCOL"] = "PURE_PROTOCOL";
26
- MODEL_UPDATER_INPUT_TYPE["PURE_GRAMMAR"] = "PURE_GRAMMAR";
27
- })(MODEL_UPDATER_INPUT_TYPE = MODEL_UPDATER_INPUT_TYPE || (MODEL_UPDATER_INPUT_TYPE = {}));
28
- export class ModelLoaderState extends EditorState {
29
- modelText = this.getExampleEntitiesInputText();
30
- currentModelLoadType = MODEL_UPDATER_INPUT_TYPE.ENTITIES;
31
- // TODO: remove model import in favor of external formats
32
- modelImportDescriptions = [];
33
- modelLoaderExtensionConfigurations = [];
34
- replace = true;
35
- isLoadingModel = false;
36
- constructor(editorStore) {
37
- super(editorStore);
38
- makeObservable(this, {
39
- modelText: observable,
40
- currentModelLoadType: observable,
41
- modelImportDescriptions: observable,
42
- modelLoaderExtensionConfigurations: observable,
43
- replace: observable,
44
- isLoadingModel: observable,
45
- setReplaceFlag: action,
46
- setModelText: action,
47
- loadCurrentProjectEntities: flow,
48
- loadModel: flow,
49
- fetchAvailableModelImportDescriptions: flow,
50
- });
51
- //extensions
52
- this.modelLoaderExtensionConfigurations = this.editorStore.pluginManager
53
- .getApplicationPlugins()
54
- .flatMap((plugin) => plugin.getExtraModelLoaderExtensionConfigurations?.() ?? [])
55
- .filter(isNonNullable);
56
- }
57
- get headerName() {
58
- return 'Model Loader';
59
- }
60
- getImportConfigurationDescription(key) {
61
- return this.modelImportDescriptions.find((description) => description.key === key);
62
- }
63
- getLoaderExtensionConfiguration(key) {
64
- return this.modelLoaderExtensionConfigurations.find((config) => config.key === key);
65
- }
66
- setReplaceFlag(val) {
67
- this.replace = val;
68
- }
69
- setModelText(modelText) {
70
- this.modelText = modelText;
71
- }
72
- setCurrentModelLoadType(modelLoadType) {
73
- if (modelLoadType !== this.currentModelLoadType) {
74
- this.currentModelLoadType = modelLoadType;
75
- this.modelText = this.getExampleText(modelLoadType);
76
- }
77
- }
78
- getExampleText(inputType) {
79
- if (inputType === MODEL_UPDATER_INPUT_TYPE.PURE_PROTOCOL) {
80
- return this.getExamplePureProtocolInputText();
81
- }
82
- else if (inputType === MODEL_UPDATER_INPUT_TYPE.ENTITIES) {
83
- return this.getExampleEntitiesInputText();
84
- }
85
- else if (this.getImportConfigurationDescription(inputType)) {
86
- return this.getExampleExternalFormatInputText();
87
- }
88
- return '';
89
- }
90
- /**
91
- * Current project entities will be taken from the current graph
92
- * If graph is not parsable, we will fall back to model loader
93
- */
94
- *loadCurrentProjectEntities() {
95
- switch (this.currentModelLoadType) {
96
- case MODEL_UPDATER_INPUT_TYPE.PURE_PROTOCOL: {
97
- const graphEntities = this.editorStore.graphManagerState.graphBuildState
98
- .hasSucceeded
99
- ? this.editorStore.graphManagerState.graph.allOwnElements.map((element) => this.editorStore.graphManagerState.graphManager.elementToEntity(element))
100
- : this.editorStore.changeDetectionState
101
- .workspaceLocalLatestRevisionState.entities;
102
- this.modelText =
103
- (yield this.editorStore.graphManagerState.graphManager.entitiesToPureProtocolText(graphEntities));
104
- break;
105
- }
106
- case MODEL_UPDATER_INPUT_TYPE.ENTITIES: {
107
- const graphEntities = this.editorStore.graphManagerState.graphBuildState
108
- .hasSucceeded
109
- ? this.editorStore.graphManagerState.graph.allOwnElements.map((element) => this.editorStore.graphManagerState.graphManager.elementToEntity(element))
110
- : this.editorStore.changeDetectionState
111
- .workspaceLocalLatestRevisionState.entities;
112
- this.modelText = JSON.stringify(graphEntities, undefined, TAB_SIZE);
113
- break;
114
- }
115
- case MODEL_UPDATER_INPUT_TYPE.PURE_GRAMMAR: {
116
- this.modelText =
117
- (yield this.editorStore.graphManagerState.graphManager.graphToPureCode(this.editorStore.graphManagerState.graph));
118
- break;
119
- }
120
- default:
121
- throw new UnsupportedOperationError(`Can't load current project entities for input type of type '${this.currentModelLoadType}'`);
122
- }
123
- }
124
- *loadModel() {
125
- try {
126
- this.isLoadingModel = true;
127
- this.editorStore.setBlockingAlert({
128
- message: 'Loading model...',
129
- prompt: 'Please do not close the application',
130
- showLoading: true,
131
- });
132
- let entities;
133
- const externalConfigType = this.getImportConfigurationDescription(this.currentModelLoadType);
134
- if (externalConfigType) {
135
- entities =
136
- (yield this.editorStore.graphManagerState.graphManager.externalFormatTextToEntities(this.modelText, externalConfigType.key, ImportMode.SCHEMA_IMPORT));
137
- }
138
- else {
139
- switch (this.currentModelLoadType) {
140
- case MODEL_UPDATER_INPUT_TYPE.PURE_PROTOCOL: {
141
- entities =
142
- this.editorStore.graphManagerState.graphManager.pureProtocolTextToEntities(this.modelText);
143
- break;
144
- }
145
- case MODEL_UPDATER_INPUT_TYPE.ENTITIES: {
146
- entities = JSON.parse(this.modelText);
147
- break;
148
- }
149
- case MODEL_UPDATER_INPUT_TYPE.PURE_GRAMMAR: {
150
- entities =
151
- (yield this.editorStore.graphManagerState.graphManager.pureCodeToEntities(this.modelText));
152
- break;
153
- }
154
- default:
155
- throw new UnsupportedOperationError(`Can't load model for input of type '${this.currentModelLoadType}'`);
156
- }
157
- }
158
- const message = `loading entities from ${this.editorStore.applicationStore.config.appName} [${this.replace ? `potentially affected ` : ''} ${entities.length} entities]`;
159
- yield this.editorStore.sdlcServerClient.updateEntities(this.editorStore.sdlcState.activeProject.projectId, this.editorStore.sdlcState.activeWorkspace, { replace: this.replace, entities, message });
160
- this.editorStore.applicationStore.navigator.reload();
161
- }
162
- catch (error) {
163
- assertErrorThrown(error);
164
- this.editorStore.applicationStore.log.error(LogEvent.create(LEGEND_STUDIO_APP_EVENT.MODEL_LOADER_FAILURE), error);
165
- this.editorStore.applicationStore.notifyError(error);
166
- }
167
- finally {
168
- this.isLoadingModel = false;
169
- this.editorStore.setBlockingAlert(undefined);
170
- }
171
- }
172
- *fetchAvailableModelImportDescriptions() {
173
- try {
174
- this.modelImportDescriptions =
175
- (yield this.editorStore.graphManagerState.graphManager.getAvailableImportConfigurationDescriptions());
176
- }
177
- catch (error) {
178
- assertErrorThrown(error);
179
- this.editorStore.applicationStore.log.error(LogEvent.create(LEGEND_STUDIO_APP_EVENT.MODEL_LOADER_FAILURE), error);
180
- this.editorStore.applicationStore.notifyError(error);
181
- }
182
- }
183
- getExampleEntitiesInputText() {
184
- return `// example entity\n${JSON.stringify([
185
- {
186
- classifierPath: 'string',
187
- content: {},
188
- path: 'string',
189
- },
190
- ], undefined, TAB_SIZE)}`;
191
- }
192
- getExamplePureProtocolInputText() {
193
- return `// example Pure model context data\n${this.editorStore.graphManagerState.graphManager.getExamplePureProtocolText()}`;
194
- }
195
- getExampleExternalFormatInputText() {
196
- return `// example external format import data\n${this.editorStore.graphManagerState.graphManager.getExampleExternalFormatImportText()}`;
197
- }
198
- }
199
- //# sourceMappingURL=ModelLoaderState.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":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AAW,CAAC,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;SACtD;gBAAS;YACR,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;YAC5B,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;SAC9C;IACH,CAAC;IAED,CAAC,qCAAqC;QACpC,IAAI;YACF,IAAI,CAAC,uBAAuB;gBAC1B,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,YAAY,CAAC,2CAA2C,EAAE,CAAqC,CAAC;SAC7I;QAAC,OAAO,KAAK,EAAE;YACd,iBAAiB,CAAC,KAAK,CAAC,CAAC;YACzB,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,GAAG,CAAC,KAAK,CACzC,QAAQ,CAAC,MAAM,CAAC,uBAAuB,CAAC,oBAAoB,CAAC,EAC7D,KAAK,CACN,CAAC;YACF,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;SACtD;IACH,CAAC;IAEO,2BAA2B;QACjC,OAAO,sBAAsB,IAAI,CAAC,SAAS,CACzC;YACE;gBACE,cAAc,EAAE,QAAQ;gBACxB,OAAO,EAAE,EAAE;gBACX,IAAI,EAAE,QAAQ;aACL;SACZ,EACD,SAAS,EACT,QAAQ,CACT,EAAE,CAAC;IACN,CAAC;IAEO,+BAA+B;QACrC,OAAO,uCAAuC,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,YAAY,CAAC,0BAA0B,EAAE,EAAE,CAAC;IAC/H,CAAC;IAEO,iCAAiC;QACvC,OAAO,2CAA2C,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,YAAY,CAAC,kCAAkC,EAAE,EAAE,CAAC;IAC3I,CAAC;CACF"}
@@ -1,259 +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
- ModelLoaderState,
20
- MODEL_UPDATER_INPUT_TYPE,
21
- } from '../../../stores/editor-state/ModelLoaderState.js';
22
- import { prettyCONSTName } from '@finos/legend-shared';
23
- import {
24
- DropdownMenu,
25
- MenuContent,
26
- MenuContentItem,
27
- CaretDownIcon,
28
- CheckSquareIcon,
29
- TruckLoadingIcon,
30
- EmptySquareIcon,
31
- } from '@finos/legend-art';
32
- import { flowResult } from 'mobx';
33
- import { useEditorStore } from '../EditorStoreProvider.js';
34
- import {
35
- ActionAlertType,
36
- ActionAlertActionType,
37
- useApplicationStore,
38
- EDITOR_LANGUAGE,
39
- useApplicationNavigationContext,
40
- } from '@finos/legend-application';
41
- import { StudioTextInputEditor } from '../../shared/StudioTextInputEditor.js';
42
- import type { ModelLoaderExtensionConfiguration } from '../../../stores/LegendStudioApplicationPlugin.js';
43
- import { LEGEND_STUDIO_APPLICATION_NAVIGATION_CONTEXT_KEY } from '../../../stores/LegendStudioApplicationNavigationContext.js';
44
-
45
- export const ModelLoader = observer(() => {
46
- const editorStore = useEditorStore();
47
- const applicationStore = useApplicationStore();
48
- const modelLoaderState = editorStore.getCurrentEditorState(ModelLoaderState);
49
- const nativeInputTypes = Object.values(MODEL_UPDATER_INPUT_TYPE);
50
- const externalFormatInputTypes = modelLoaderState.modelImportDescriptions;
51
- const extraModelLoaderExtensionsConfigs =
52
- modelLoaderState.modelLoaderExtensionConfigurations;
53
- // input type
54
- const currentModelLoadType = modelLoaderState.currentModelLoadType;
55
- // replace flag
56
- const replace = modelLoaderState.replace;
57
- const toggleReplace = (): void => modelLoaderState.setReplaceFlag(!replace);
58
- // actions
59
- const loadCurrentProjectEntities = applicationStore.guardUnhandledError(() =>
60
- flowResult(modelLoaderState.loadCurrentProjectEntities()),
61
- );
62
- const setCurrentInputType =
63
- (inputType: string | MODEL_UPDATER_INPUT_TYPE): (() => void) =>
64
- (): void => {
65
- modelLoaderState.setCurrentModelLoadType(inputType);
66
- };
67
- const loaderExtensionConfig =
68
- modelLoaderState.getLoaderExtensionConfiguration(currentModelLoadType);
69
- const label =
70
- modelLoaderState.getImportConfigurationDescription(currentModelLoadType)
71
- ?.label ??
72
- loaderExtensionConfig?.label ??
73
- loaderExtensionConfig?.key ??
74
- currentModelLoadType;
75
- const allowHardReplace =
76
- !loaderExtensionConfig || loaderExtensionConfig.allowHardReplace;
77
- const isNativeInput = Object.values(MODEL_UPDATER_INPUT_TYPE).includes(
78
- currentModelLoadType as MODEL_UPDATER_INPUT_TYPE,
79
- );
80
- const loadModel = (): void => {
81
- if (loaderExtensionConfig) {
82
- loaderExtensionConfig
83
- .load(editorStore)
84
- .catch(applicationStore.alertUnhandledError);
85
- } else if (editorStore.hasUnpushedChanges) {
86
- editorStore.setActionAlertInfo({
87
- message: 'You have unpushed changes',
88
- prompt:
89
- 'This action will discard these changes and refresh the application',
90
- type: ActionAlertType.CAUTION,
91
- onEnter: (): void => editorStore.setBlockGlobalHotkeys(true),
92
- onClose: (): void => editorStore.setBlockGlobalHotkeys(false),
93
- actions: [
94
- {
95
- label: 'Proceed to load model',
96
- type: ActionAlertActionType.PROCEED_WITH_CAUTION,
97
- handler: (): void => {
98
- editorStore.setIgnoreNavigationBlocking(true);
99
- flowResult(modelLoaderState.loadModel()).catch(
100
- applicationStore.alertUnhandledError,
101
- );
102
- },
103
- },
104
- {
105
- label: 'Abort',
106
- type: ActionAlertActionType.PROCEED,
107
- default: true,
108
- },
109
- ],
110
- });
111
- } else {
112
- flowResult(modelLoaderState.loadModel()).catch(
113
- applicationStore.alertUnhandledError,
114
- );
115
- }
116
- };
117
- const updateModel = (val: string): void => modelLoaderState.setModelText(val);
118
-
119
- useApplicationNavigationContext(
120
- LEGEND_STUDIO_APPLICATION_NAVIGATION_CONTEXT_KEY.MODEL_LOADER,
121
- );
122
-
123
- return (
124
- <div className="panel model-loader">
125
- <div className="panel__header model-loader__header">
126
- <div className="model-loader__header__configs">
127
- <DropdownMenu
128
- content={
129
- <MenuContent className="model-loader__header__configs__type__menu">
130
- <div className="model-loader__header__configs__type-option__group model-loader__header__configs__type-option__group--native">
131
- <div className="model-loader__header__configs__type-option__group__name">
132
- native
133
- </div>
134
- <div className="model-loader__header__configs__type-option__group__options">
135
- {nativeInputTypes.map((inputType) => (
136
- <MenuContentItem
137
- key={inputType}
138
- className="model-loader__header__configs__type-option__group__option"
139
- onClick={setCurrentInputType(inputType)}
140
- >
141
- {prettyCONSTName(inputType)}
142
- </MenuContentItem>
143
- ))}
144
- </div>
145
- </div>
146
- {Boolean(externalFormatInputTypes) && (
147
- <>
148
- <div className="model-loader__header__configs__type-option__group__separator" />
149
- <div className="model-loader__header__configs__type-option__group model-loader__header__configs__type-option__group--external">
150
- <div className="model-loader__header__configs__type-option__group__name">
151
- external
152
- </div>
153
- <div className="model-loader__header__configs__type-option__group__options">
154
- {externalFormatInputTypes.map((inputType) => (
155
- <MenuContentItem
156
- key={inputType.key}
157
- className="model-loader__header__configs__type-option__group__option"
158
- onClick={setCurrentInputType(inputType.key)}
159
- >
160
- {inputType.label}
161
- </MenuContentItem>
162
- ))}
163
- </div>
164
- </div>
165
- </>
166
- )}
167
- {Boolean(extraModelLoaderExtensionsConfigs.length > 0) && (
168
- <>
169
- <div className="model-loader__header__configs__type-option__group__separator" />
170
- <div className="model-loader__header__configs__type-option__group model-loader__header__configs__type-option__group--extension">
171
- <div className="model-loader__header__configs__type-option__group__name">
172
- extensions
173
- </div>
174
- <div className="model-loader__header__configs__type-option__group__options">
175
- {extraModelLoaderExtensionsConfigs.map(
176
- (config: ModelLoaderExtensionConfiguration) => (
177
- <MenuContentItem
178
- key={config.key}
179
- className="model-loader__header__configs__type-option__group__option"
180
- onClick={setCurrentInputType(config.key)}
181
- >
182
- {config.label ?? prettyCONSTName(config.key)}
183
- </MenuContentItem>
184
- ),
185
- )}
186
- </div>
187
- </div>
188
- </>
189
- )}
190
- </MenuContent>
191
- }
192
- menuProps={{
193
- anchorOrigin: { vertical: 'bottom', horizontal: 'right' },
194
- transformOrigin: { vertical: 'top', horizontal: 'right' },
195
- }}
196
- >
197
- <div className="model-loader__header__configs__type">
198
- <div className="model-loader__header__configs__type__label">
199
- {prettyCONSTName(label)}
200
- </div>
201
- <div className="model-loader__header__configs__type__icon">
202
- <CaretDownIcon />
203
- </div>
204
- </div>
205
- </DropdownMenu>
206
- {allowHardReplace && (
207
- <div
208
- className="model-loader__header__configs__edit-mode"
209
- onClick={toggleReplace}
210
- >
211
- <div className="model-loader__header__configs__edit-mode__icon">
212
- {replace ? <CheckSquareIcon /> : <EmptySquareIcon />}
213
- </div>
214
- <div className="model-loader__header__configs__edit-mode__label">
215
- replace
216
- </div>
217
- </div>
218
- )}
219
- {isNativeInput && (
220
- <button
221
- className="model-loader__header__configs__load-project-entities-btn"
222
- tabIndex={-1}
223
- onClick={loadCurrentProjectEntities}
224
- title="Load current project entities"
225
- >
226
- <TruckLoadingIcon />
227
- </button>
228
- )}
229
- </div>
230
- <div className="model-loader__header__action">
231
- <button
232
- className="btn--dark model-loader__header__load-btn"
233
- onClick={loadModel}
234
- disabled={modelLoaderState.isLoadingModel}
235
- tabIndex={-1}
236
- title="Load model"
237
- >
238
- Load
239
- </button>
240
- </div>
241
- </div>
242
- <div className="panel__content model-loader__editor">
243
- {loaderExtensionConfig?.renderer(editorStore) ?? (
244
- <StudioTextInputEditor
245
- language={
246
- modelLoaderState.currentModelLoadType ===
247
- MODEL_UPDATER_INPUT_TYPE.PURE_GRAMMAR
248
- ? EDITOR_LANGUAGE.PURE
249
- : EDITOR_LANGUAGE.JSON
250
- }
251
- inputValue={modelLoaderState.modelText}
252
- updateInput={updateModel}
253
- showMiniMap={true}
254
- />
255
- )}
256
- </div>
257
- </div>
258
- );
259
- });