@finos/legend-application-studio 22.2.0 → 22.2.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 (34) hide show
  1. package/lib/index.css +1 -1
  2. package/lib/package.json +1 -1
  3. package/lib/stores/EditorGraphState.d.ts.map +1 -1
  4. package/lib/stores/EditorGraphState.js +10 -46
  5. package/lib/stores/EditorGraphState.js.map +1 -1
  6. package/lib/stores/EditorStore.d.ts +1 -1
  7. package/lib/stores/EditorStore.d.ts.map +1 -1
  8. package/lib/stores/EditorStore.js +8 -6
  9. package/lib/stores/EditorStore.js.map +1 -1
  10. package/lib/stores/EditorTabManagerState.d.ts +1 -2
  11. package/lib/stores/EditorTabManagerState.d.ts.map +1 -1
  12. package/lib/stores/EditorTabManagerState.js +2 -14
  13. package/lib/stores/EditorTabManagerState.js.map +1 -1
  14. package/lib/stores/ExplorerTreeState.d.ts.map +1 -1
  15. package/lib/stores/ExplorerTreeState.js +1 -3
  16. package/lib/stores/ExplorerTreeState.js.map +1 -1
  17. package/lib/stores/editor-state/project-configuration-editor-state/ProjectDependencyEditorState.d.ts.map +1 -1
  18. package/lib/stores/editor-state/project-configuration-editor-state/ProjectDependencyEditorState.js +1 -0
  19. package/lib/stores/editor-state/project-configuration-editor-state/ProjectDependencyEditorState.js.map +1 -1
  20. package/lib/stores/project-viewer/ProjectViewerStore.d.ts.map +1 -1
  21. package/lib/stores/project-viewer/ProjectViewerStore.js +1 -1
  22. package/lib/stores/project-viewer/ProjectViewerStore.js.map +1 -1
  23. package/lib/stores/sidebar-state/LocalChangesState.d.ts +16 -3
  24. package/lib/stores/sidebar-state/LocalChangesState.d.ts.map +1 -1
  25. package/lib/stores/sidebar-state/LocalChangesState.js +143 -246
  26. package/lib/stores/sidebar-state/LocalChangesState.js.map +1 -1
  27. package/package.json +10 -10
  28. package/src/stores/EditorGraphState.ts +18 -49
  29. package/src/stores/EditorStore.ts +12 -10
  30. package/src/stores/EditorTabManagerState.ts +1 -20
  31. package/src/stores/ExplorerTreeState.ts +4 -6
  32. package/src/stores/editor-state/project-configuration-editor-state/ProjectDependencyEditorState.ts +2 -0
  33. package/src/stores/project-viewer/ProjectViewerStore.ts +3 -1
  34. package/src/stores/sidebar-state/LocalChangesState.ts +279 -450
@@ -105,7 +105,6 @@ import { PACKAGEABLE_ELEMENT_TYPE } from './shared/ModelClassifierUtils.js';
105
105
  import { GlobalTestRunnerState } from './sidebar-state/testable/GlobalTestRunnerState.js';
106
106
  import { LEGEND_STUDIO_APP_EVENT } from './LegendStudioAppEvent.js';
107
107
  import { ExplorerTreeState } from './ExplorerTreeState.js';
108
- import { FileGenerationViewerState } from './editor-state/FileGenerationViewerState.js';
109
108
 
110
109
  export enum GraphBuilderStatus {
111
110
  SUCCEEDED = 'SUCCEEDED',
@@ -469,7 +468,9 @@ export class EditorGraphState {
469
468
  };
470
469
  }
471
470
  }
472
- this.editorStore.setGraphEditMode(GRAPH_EDITOR_MODE.GRAMMAR_TEXT);
471
+ yield flowResult(
472
+ this.editorStore.setGraphEditMode(GRAPH_EDITOR_MODE.GRAMMAR_TEXT),
473
+ );
473
474
  yield flowResult(
474
475
  this.globalCompileInTextMode({
475
476
  ignoreBlocking: true,
@@ -665,13 +666,8 @@ export class EditorGraphState {
665
666
  );
666
667
  return FormModeCompilationOutcome.FAILED;
667
668
  }
668
- this.editorStore.setGraphEditMode(GRAPH_EDITOR_MODE.GRAMMAR_TEXT);
669
- // Stop change detection as we don't need the actual change detection in text mode
670
- this.editorStore.changeDetectionState.stop();
671
- this.editorStore.changeDetectionState.computeLocalChangesInTextMode(
672
- (yield this.editorStore.graphManagerState.graphManager.pureCodeToEntities(
673
- this.editorStore.grammarTextEditorState.graphGrammarText,
674
- )) as Entity[],
669
+ yield flowResult(
670
+ this.editorStore.setGraphEditMode(GRAPH_EDITOR_MODE.GRAMMAR_TEXT),
675
671
  );
676
672
  yield flowResult(
677
673
  this.globalCompileInTextMode({
@@ -829,7 +825,9 @@ export class EditorGraphState {
829
825
  this.editorStore.changeDetectionState.getCurrentGraphHash();
830
826
  this.editorStore.grammarTextEditorState.setGraphGrammarText('');
831
827
  this.editorStore.grammarTextEditorState.resetCurrentElementLabelRegexString();
832
- this.editorStore.setGraphEditMode(GRAPH_EDITOR_MODE.FORM);
828
+ yield flowResult(
829
+ this.editorStore.setGraphEditMode(GRAPH_EDITOR_MODE.FORM),
830
+ );
833
831
  if (this.editorStore.tabManagerState.currentTab) {
834
832
  this.editorStore.tabManagerState.openTab(
835
833
  this.editorStore.tabManagerState.currentTab,
@@ -867,8 +865,13 @@ export class EditorGraphState {
867
865
  actions: [
868
866
  {
869
867
  label: 'Discard Changes',
870
- handler: (): void =>
871
- this.editorStore.setGraphEditMode(GRAPH_EDITOR_MODE.FORM),
868
+ handler: () => {
869
+ flowResult(
870
+ this.editorStore.setGraphEditMode(GRAPH_EDITOR_MODE.FORM),
871
+ ).catch(
872
+ this.editorStore.applicationStore.alertUnhandledError,
873
+ );
874
+ },
872
875
  type: ActionAlertActionType.PROCEED_WITH_CAUTION,
873
876
  },
874
877
  {
@@ -919,15 +922,12 @@ export class EditorGraphState {
919
922
  const systemTreeData = this.editorStore.explorerTreeState.systemTreeData;
920
923
  const dependencyTreeData =
921
924
  this.editorStore.explorerTreeState.dependencyTreeData;
922
- const fileGenTreeData =
923
- this.editorStore.explorerTreeState.fileGenerationTreeData;
924
925
  const selectedNodeId = this.editorStore.explorerTreeState.selectedNode?.id;
925
926
  this.editorStore.explorerTreeState = new ExplorerTreeState(
926
927
  this.editorStore,
927
928
  );
928
929
  this.editorStore.explorerTreeState.systemTreeData = systemTreeData;
929
930
  this.editorStore.explorerTreeState.dependencyTreeData = dependencyTreeData;
930
- this.editorStore.explorerTreeState.fileGenerationTreeData = fileGenTreeData;
931
931
  this.editorStore.explorerTreeState.buildTreeInTextMode();
932
932
  this.editorStore.explorerTreeState.openExplorerTreeNodes(
933
933
  mainTreeOpenedNodeIds,
@@ -1027,14 +1027,9 @@ export class EditorGraphState {
1027
1027
  * hold any reference to the actual graph.
1028
1028
  */
1029
1029
  const openedTabPaths: string[] = [];
1030
- // We can store file genration editor states as is as they don't hold any references to the graph.
1031
- const openedGeneratedFileTabStates: FileGenerationViewerState[] = [];
1032
1030
  this.editorStore.tabManagerState.tabs.forEach((state: TabState) => {
1033
1031
  if (state instanceof ElementEditorState) {
1034
1032
  openedTabPaths.push(state.elementPath);
1035
- } else if (state instanceof FileGenerationViewerState) {
1036
- openedTabPaths.push(state.generatedFilePath);
1037
- openedGeneratedFileTabStates.push(state);
1038
1033
  }
1039
1034
  });
1040
1035
  // Only stores editor state for file generation editors as they don't hold any references to the
@@ -1104,7 +1099,6 @@ export class EditorGraphState {
1104
1099
  */
1105
1100
  this.editorStore.tabManagerState.recoverTabs(
1106
1101
  openedTabPaths,
1107
- openedGeneratedFileTabStates,
1108
1102
  currentTabState,
1109
1103
  currentTabElementPath,
1110
1104
  true,
@@ -1213,14 +1207,9 @@ export class EditorGraphState {
1213
1207
  * hold any reference to the actual graph.
1214
1208
  */
1215
1209
  const openedTabPaths: string[] = [];
1216
- // We can store file genration editor states as is as they don't hold any references to the graph.
1217
- const openedGeneratedFileTabStates: FileGenerationViewerState[] = [];
1218
1210
  this.editorStore.tabManagerState.tabs.forEach((state: TabState) => {
1219
1211
  if (state instanceof ElementEditorState) {
1220
1212
  openedTabPaths.push(state.elementPath);
1221
- } else if (state instanceof FileGenerationViewerState) {
1222
- openedTabPaths.push(state.generatedFilePath);
1223
- openedGeneratedFileTabStates.push(state);
1224
1213
  }
1225
1214
  });
1226
1215
  // Only stores editor state for file generation editors as they don't hold any references to the
@@ -1287,7 +1276,6 @@ export class EditorGraphState {
1287
1276
  */
1288
1277
  this.editorStore.tabManagerState.recoverTabs(
1289
1278
  openedTabPaths,
1290
- openedGeneratedFileTabStates,
1291
1279
  currentTabState,
1292
1280
  currentTabElementPath,
1293
1281
  false,
@@ -1306,24 +1294,10 @@ export class EditorGraphState {
1306
1294
  LogEvent.create(GRAPH_MANAGER_EVENT.GRAPH_BUILDER_FAILURE),
1307
1295
  error,
1308
1296
  );
1309
- this.editorStore.changeDetectionState.stop(true); // force stop change detection
1310
1297
  this.isUpdatingGraph = false;
1311
- // Note: in the future this function will probably be ideal to refactor when we have different classes for each mode
1312
- // as we would handle this error differently in `text` mode and `form` mode.
1313
- if (error instanceof GraphBuilderError && this.editorStore.isInFormMode) {
1314
- this.editorStore.applicationStore.setBlockingAlert({
1315
- message: `Can't build graph: ${error.message}`,
1316
- prompt: 'Refreshing full application...',
1317
- showLoading: true,
1318
- });
1319
- this.editorStore.tabManagerState.closeAllTabs();
1320
- this.editorStore.cleanUp();
1321
- yield flowResult(this.editorStore.buildGraph(entities));
1322
- } else {
1323
- this.editorStore.applicationStore.notifyError(
1324
- `Can't build graph: ${error.message}`,
1325
- );
1326
- }
1298
+ this.editorStore.applicationStore.notifyError(
1299
+ `Can't build graph: ${error.message}`,
1300
+ );
1327
1301
  } finally {
1328
1302
  this.isUpdatingApplication = false;
1329
1303
  this.editorStore.applicationStore.setBlockingAlert(undefined);
@@ -1346,13 +1320,9 @@ export class EditorGraphState {
1346
1320
  * Backup and editor states info before resetting
1347
1321
  */
1348
1322
  const openedTabEditorPaths: string[] = [];
1349
- const openedGeneratedFileTabStates: FileGenerationViewerState[] = [];
1350
1323
  this.editorStore.tabManagerState.tabs.forEach((state: TabState) => {
1351
1324
  if (state instanceof ElementEditorState) {
1352
1325
  openedTabEditorPaths.push(state.elementPath);
1353
- } else if (state instanceof FileGenerationViewerState) {
1354
- openedTabEditorPaths.push(state.generatedFilePath);
1355
- openedGeneratedFileTabStates.push(state);
1356
1326
  }
1357
1327
  });
1358
1328
  const currentTabState =
@@ -1381,7 +1351,6 @@ export class EditorGraphState {
1381
1351
  this.updateExplorerTree();
1382
1352
  this.editorStore.tabManagerState.recoverTabs(
1383
1353
  openedTabEditorPaths,
1384
- openedGeneratedFileTabStates,
1385
1354
  currentTabState,
1386
1355
  currentTabElementPath,
1387
1356
  true,
@@ -231,7 +231,7 @@ export class EditorStore implements CommandRegistrar {
231
231
  setActiveAuxPanelMode: action,
232
232
  cleanUp: action,
233
233
  reset: action,
234
- setGraphEditMode: action,
234
+ setGraphEditMode: flow,
235
235
  setActiveActivity: action,
236
236
 
237
237
  initialize: flow,
@@ -340,10 +340,19 @@ export class EditorStore implements CommandRegistrar {
340
340
  this.mode = val;
341
341
  }
342
342
 
343
- setGraphEditMode(graphEditor: GRAPH_EDITOR_MODE): void {
343
+ *setGraphEditMode(graphEditor: GRAPH_EDITOR_MODE): GeneratorFn<void> {
344
344
  this.graphEditMode = graphEditor;
345
345
  this.changeLocalChangesState();
346
346
  this.graphState.clearProblems();
347
+ if (graphEditor === GRAPH_EDITOR_MODE.GRAMMAR_TEXT) {
348
+ // Stop change detection as we don't need the actual change detection in text mode
349
+ this.changeDetectionState.stop();
350
+ this.changeDetectionState.computeLocalChangesInTextMode(
351
+ (yield this.graphManagerState.graphManager.pureCodeToEntities(
352
+ this.grammarTextEditorState.graphGrammarText,
353
+ )) as Entity[],
354
+ );
355
+ }
347
356
  }
348
357
 
349
358
  cleanUp(): void {
@@ -1113,20 +1122,13 @@ export class EditorStore implements CommandRegistrar {
1113
1122
  return;
1114
1123
  }
1115
1124
  this.applicationStore.setBlockingAlert(undefined);
1116
- this.setGraphEditMode(GRAPH_EDITOR_MODE.GRAMMAR_TEXT);
1125
+ yield flowResult(this.setGraphEditMode(GRAPH_EDITOR_MODE.GRAMMAR_TEXT));
1117
1126
  // navigate to the currently opened element immediately after entering text mode editor
1118
1127
  if (this.tabManagerState.currentTab instanceof ElementEditorState) {
1119
1128
  this.grammarTextEditorState.setCurrentElementLabelRegexString(
1120
1129
  this.tabManagerState.currentTab.element,
1121
1130
  );
1122
1131
  }
1123
- // Stop change detection as we don't need the actual change detection in text mode
1124
- this.changeDetectionState.stop();
1125
- this.changeDetectionState.computeLocalChangesInTextMode(
1126
- (yield this.graphManagerState.graphManager.pureCodeToEntities(
1127
- this.grammarTextEditorState.graphGrammarText,
1128
- )) as Entity[],
1129
- );
1130
1132
  } else if (this.isInGrammarTextMode) {
1131
1133
  yield flowResult(this.graphState.leaveTextMode());
1132
1134
  } else {
@@ -21,7 +21,6 @@ import { makeObservable, action } from 'mobx';
21
21
  import type { EditorState } from './editor-state/EditorState.js';
22
22
  import { ElementEditorState } from './editor-state/element-editor-state/ElementEditorState.js';
23
23
  import { EntityDiffViewerState } from './editor-state/entity-diff-editor-state/EntityDiffEditorState.js';
24
- import type { FileGenerationViewerState } from './editor-state/FileGenerationViewerState.js';
25
24
  import type { EditorStore } from './EditorStore.js';
26
25
 
27
26
  export class EditorTabManagerState extends TabManagerState {
@@ -94,21 +93,10 @@ export class EditorTabManagerState extends TabManagerState {
94
93
  */
95
94
  recoverTabs = (
96
95
  openedTabEditorPaths: string[],
97
- openedGeneratedFileTabStates: FileGenerationViewerState[],
98
96
  currentTabState: EditorState | undefined,
99
97
  currentTabElementPath: string | undefined,
100
98
  shouldRecoverTabs: boolean,
101
99
  ): void => {
102
- const getElemenetPathFromFilePath = (filePath: string): string => {
103
- const paths = filePath.split('/');
104
- let elementPath = '';
105
- const fileName = paths.slice(-1)[0]?.split('.')[0];
106
- paths
107
- .slice(1, paths.length - 1)
108
- .forEach((path) => (elementPath = `${elementPath + path}::`));
109
- elementPath = `${elementPath + fileName}`;
110
- return elementPath;
111
- };
112
100
  if (shouldRecoverTabs) {
113
101
  this.tabs = openedTabEditorPaths
114
102
  .map((editorPath) => {
@@ -121,14 +109,7 @@ export class EditorTabManagerState extends TabManagerState {
121
109
  correspondingElement,
122
110
  );
123
111
  }
124
- const fileGenerationViewerEditor = openedGeneratedFileTabStates.find(
125
- (editorState) =>
126
- editorState.generatedFilePath === editorPath &&
127
- this.editorStore.graphManagerState.graph.getNullableElement(
128
- getElemenetPathFromFilePath(editorState.file.path),
129
- ) !== undefined,
130
- );
131
- return fileGenerationViewerEditor;
112
+ return undefined;
132
113
  })
133
114
  .filter(isNonNullable);
134
115
  this.setCurrentTab(
@@ -214,12 +214,10 @@ export class ExplorerTreeState {
214
214
  this.editorStore.graphManagerState.graph.generationModel.root,
215
215
  ExplorerTreeRootPackageLabel.MODEL_GENERATION,
216
216
  );
217
- if (!this.fileGenerationTreeData) {
218
- this.fileGenerationTreeData = getGenerationTreeData(
219
- this.editorStore.graphState.graphGenerationState.rootFileDirectory,
220
- ExplorerTreeRootPackageLabel.FILE_GENERATION,
221
- );
222
- }
217
+ this.fileGenerationTreeData = getGenerationTreeData(
218
+ this.editorStore.graphState.graphGenerationState.rootFileDirectory,
219
+ ExplorerTreeRootPackageLabel.FILE_GENERATION,
220
+ );
223
221
  this.setSelectedNode(undefined);
224
222
  this.buildState.complete();
225
223
  }
@@ -269,7 +269,9 @@ export class ProjectDependencyConflictState {
269
269
  ) {
270
270
  makeObservable(this, {
271
271
  treeData: observable.ref,
272
+ setTreeData: action,
272
273
  });
274
+
273
275
  this.report = report;
274
276
  this.conflict = conflict;
275
277
  this.paths = paths;
@@ -474,7 +474,9 @@ export class ProjectViewerStore {
474
474
  });
475
475
  return false;
476
476
  }
477
- this.editorStore.setGraphEditMode(GRAPH_EDITOR_MODE.GRAMMAR_TEXT);
477
+ yield flowResult(
478
+ this.editorStore.setGraphEditMode(GRAPH_EDITOR_MODE.GRAMMAR_TEXT),
479
+ );
478
480
  yield flowResult(
479
481
  this.editorStore.graphState.globalCompileInTextMode({
480
482
  ignoreBlocking: true,