@finos/legend-application-studio 22.1.6 → 22.2.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 (69) hide show
  1. package/lib/components/editor/edit-panel/project-configuration-editor/ProjectDependencyEditor.d.ts.map +1 -1
  2. package/lib/components/editor/edit-panel/project-configuration-editor/ProjectDependencyEditor.js +155 -59
  3. package/lib/components/editor/edit-panel/project-configuration-editor/ProjectDependencyEditor.js.map +1 -1
  4. package/lib/components/editor/side-bar/Explorer.d.ts.map +1 -1
  5. package/lib/components/editor/side-bar/Explorer.js +1 -0
  6. package/lib/components/editor/side-bar/Explorer.js.map +1 -1
  7. package/lib/components/editor/side-bar/LocalChanges.d.ts.map +1 -1
  8. package/lib/components/editor/side-bar/LocalChanges.js +16 -3
  9. package/lib/components/editor/side-bar/LocalChanges.js.map +1 -1
  10. package/lib/index.css +2 -2
  11. package/lib/index.css.map +1 -1
  12. package/lib/package.json +3 -3
  13. package/lib/stores/ChangeDetectionState.d.ts +3 -0
  14. package/lib/stores/ChangeDetectionState.d.ts.map +1 -1
  15. package/lib/stores/ChangeDetectionState.js +68 -1
  16. package/lib/stores/ChangeDetectionState.js.map +1 -1
  17. package/lib/stores/EditorGraphState.d.ts +9 -1
  18. package/lib/stores/EditorGraphState.d.ts.map +1 -1
  19. package/lib/stores/EditorGraphState.js +220 -38
  20. package/lib/stores/EditorGraphState.js.map +1 -1
  21. package/lib/stores/EditorStore.d.ts +2 -1
  22. package/lib/stores/EditorStore.d.ts.map +1 -1
  23. package/lib/stores/EditorStore.js +14 -2
  24. package/lib/stores/EditorStore.js.map +1 -1
  25. package/lib/stores/EditorTabManagerState.d.ts +3 -10
  26. package/lib/stores/EditorTabManagerState.d.ts.map +1 -1
  27. package/lib/stores/EditorTabManagerState.js +33 -37
  28. package/lib/stores/EditorTabManagerState.js.map +1 -1
  29. package/lib/stores/ExplorerTreeState.d.ts +2 -0
  30. package/lib/stores/ExplorerTreeState.d.ts.map +1 -1
  31. package/lib/stores/ExplorerTreeState.js +53 -0
  32. package/lib/stores/ExplorerTreeState.js.map +1 -1
  33. package/lib/stores/LegendStudioRouter.d.ts +1 -1
  34. package/lib/stores/LegendStudioRouter.d.ts.map +1 -1
  35. package/lib/stores/LegendStudioRouter.js.map +1 -1
  36. package/lib/stores/editor-state/FileGenerationViewerState.d.ts +1 -0
  37. package/lib/stores/editor-state/FileGenerationViewerState.d.ts.map +1 -1
  38. package/lib/stores/editor-state/FileGenerationViewerState.js +4 -0
  39. package/lib/stores/editor-state/FileGenerationViewerState.js.map +1 -1
  40. package/lib/stores/editor-state/GraphGenerationState.d.ts.map +1 -1
  41. package/lib/stores/editor-state/GraphGenerationState.js +4 -1
  42. package/lib/stores/editor-state/GraphGenerationState.js.map +1 -1
  43. package/lib/stores/editor-state/element-editor-state/ElementEditorState.d.ts +1 -0
  44. package/lib/stores/editor-state/element-editor-state/ElementEditorState.d.ts.map +1 -1
  45. package/lib/stores/editor-state/element-editor-state/ElementEditorState.js +4 -0
  46. package/lib/stores/editor-state/element-editor-state/ElementEditorState.js.map +1 -1
  47. package/lib/stores/editor-state/project-configuration-editor-state/ProjectDependencyEditorState.d.ts +46 -13
  48. package/lib/stores/editor-state/project-configuration-editor-state/ProjectDependencyEditorState.d.ts.map +1 -1
  49. package/lib/stores/editor-state/project-configuration-editor-state/ProjectDependencyEditorState.js +176 -23
  50. package/lib/stores/editor-state/project-configuration-editor-state/ProjectDependencyEditorState.js.map +1 -1
  51. package/lib/stores/sidebar-state/LocalChangesState.d.ts +14 -2
  52. package/lib/stores/sidebar-state/LocalChangesState.d.ts.map +1 -1
  53. package/lib/stores/sidebar-state/LocalChangesState.js +206 -30
  54. package/lib/stores/sidebar-state/LocalChangesState.js.map +1 -1
  55. package/package.json +12 -12
  56. package/src/components/editor/edit-panel/project-configuration-editor/ProjectDependencyEditor.tsx +430 -169
  57. package/src/components/editor/side-bar/Explorer.tsx +1 -0
  58. package/src/components/editor/side-bar/LocalChanges.tsx +16 -6
  59. package/src/stores/ChangeDetectionState.ts +119 -0
  60. package/src/stores/EditorGraphState.ts +321 -44
  61. package/src/stores/EditorStore.ts +22 -2
  62. package/src/stores/EditorTabManagerState.ts +55 -37
  63. package/src/stores/ExplorerTreeState.ts +118 -0
  64. package/src/stores/LegendStudioRouter.ts +1 -1
  65. package/src/stores/editor-state/FileGenerationViewerState.ts +5 -0
  66. package/src/stores/editor-state/GraphGenerationState.ts +9 -0
  67. package/src/stores/editor-state/element-editor-state/ElementEditorState.ts +5 -0
  68. package/src/stores/editor-state/project-configuration-editor-state/ProjectDependencyEditorState.ts +259 -34
  69. package/src/stores/sidebar-state/LocalChangesState.ts +338 -62
@@ -819,6 +819,7 @@ export const Explorer = observer(() => {
819
819
  // don't edit elements that fast in form mode, but this could throw off
820
820
  // test runner
821
821
  (editorStore.isInViewerMode ||
822
+ editorStore.isInGrammarTextMode ||
822
823
  editorStore.changeDetectionState.graphObserveState.hasSucceeded);
823
824
  // conflict resolution
824
825
  const showConflictResolutionContent =
@@ -51,6 +51,7 @@ import { useApplicationStore } from '@finos/legend-application';
51
51
  import { useEffect } from 'react';
52
52
  import { EntityChangeConflictEditorState } from '../../../stores/editor-state/entity-diff-editor-state/EntityChangeConflictEditorState.js';
53
53
  import { EntityChangeConflictSideBarItem } from '../edit-panel/diff-editor/EntityChangeConflictEditor.js';
54
+ import { FormLocalChangesState } from '../../../stores/sidebar-state/LocalChangesState.js';
54
55
 
55
56
  const PatchLoader = observer(() => {
56
57
  const editorStore = useEditorStore();
@@ -172,8 +173,11 @@ export const LocalChanges = observer(() => {
172
173
  editorStore.changeDetectionState.workspaceLocalLatestRevisionState.changes;
173
174
  const openChange =
174
175
  (diff: EntityDiff): (() => void) =>
175
- (): void =>
176
- localChangesState.openLocalChange(diff);
176
+ (): void => {
177
+ if (localChangesState instanceof FormLocalChangesState) {
178
+ localChangesState.openLocalChange(diff);
179
+ }
180
+ };
177
181
  // Local/Remote Workspace Conflicts
178
182
  const conflicts =
179
183
  editorStore.changeDetectionState.potentialWorkspacePullConflicts;
@@ -182,8 +186,11 @@ export const LocalChanges = observer(() => {
182
186
  conflict.entityPath === currentTabState.entityPath;
183
187
  const openPotentialConflict =
184
188
  (conflict: EntityChangeConflict): (() => void) =>
185
- (): void =>
186
- localChangesState.openPotentialWorkspacePullConflict(conflict);
189
+ (): void => {
190
+ if (localChangesState instanceof FormLocalChangesState) {
191
+ localChangesState.openPotentialWorkspacePullConflict(conflict);
192
+ }
193
+ };
187
194
  // Local/Remote Workspace Changes
188
195
  const workspacePullChanges =
189
196
  editorStore.changeDetectionState.aggregatedWorkspaceRemoteChanges;
@@ -195,8 +202,11 @@ export const LocalChanges = observer(() => {
195
202
  );
196
203
  const openWorkspacePullChange =
197
204
  (diff: EntityDiff): (() => void) =>
198
- (): void =>
199
- localChangesState.openWorkspacePullChange(diff);
205
+ (): void => {
206
+ if (localChangesState instanceof FormLocalChangesState) {
207
+ localChangesState.openWorkspacePullChange(diff);
208
+ }
209
+ };
200
210
 
201
211
  // check if workspace is still in-sync
202
212
  useEffect(() => {
@@ -35,6 +35,8 @@ import {
35
35
  hashObject,
36
36
  promisify,
37
37
  ActionState,
38
+ guaranteeNonNullable,
39
+ guaranteeType,
38
40
  } from '@finos/legend-shared';
39
41
  import type { EditorStore } from './EditorStore.js';
40
42
  import type { EditorGraphState } from './EditorGraphState.js';
@@ -44,6 +46,7 @@ import {
44
46
  EntityChangeConflict,
45
47
  EntityChangeType,
46
48
  EntityDiff,
49
+ type EntityChange,
47
50
  } from '@finos/legend-server-sdlc';
48
51
  import {
49
52
  ObserverContext,
@@ -51,6 +54,7 @@ import {
51
54
  observe_GraphElements,
52
55
  } from '@finos/legend-graph';
53
56
  import { type IDisposer, keepAlive } from 'mobx-utils';
57
+ import { TextLocalChangesState } from './sidebar-state/LocalChangesState.js';
54
58
 
55
59
  class RevisionChangeDetectionState {
56
60
  editorStore: EditorStore;
@@ -59,6 +63,7 @@ class RevisionChangeDetectionState {
59
63
  entityHashesIndex = new Map<string, string>();
60
64
  isBuildingEntityHashesIndex = false;
61
65
  entities: Entity[] = [];
66
+ currentEntityHashesIndex = new Map<string, string>();
62
67
 
63
68
  setEntityHashesIndex(hashesIndex: Map<string, string>): void {
64
69
  this.entityHashesIndex = hashesIndex;
@@ -80,6 +85,7 @@ class RevisionChangeDetectionState {
80
85
  setIsBuildingEntityHashesIndex: action,
81
86
  setEntities: action,
82
87
  computeChanges: flow,
88
+ computeChangesInTextMode: flow,
83
89
  buildEntityHashesIndex: flow,
84
90
  });
85
91
 
@@ -140,6 +146,95 @@ class RevisionChangeDetectionState {
140
146
  }
141
147
  }
142
148
 
149
+ *computeChangesInTextMode(
150
+ currentEntities: Entity[],
151
+ quiet?: boolean,
152
+ ): GeneratorFn<void> {
153
+ const startTime = Date.now();
154
+ const changes: EntityDiff[] = [];
155
+ const entityChanges: EntityChange[] = [];
156
+ if (!this.isBuildingEntityHashesIndex) {
157
+ let currentHashesIndex;
158
+ if (currentEntities.length) {
159
+ currentHashesIndex =
160
+ (yield this.editorStore.graphManagerState.graphManager.buildHashesIndex(
161
+ currentEntities,
162
+ )) as Map<string, string>;
163
+ this.currentEntityHashesIndex = currentHashesIndex;
164
+ }
165
+ const originalPaths = new Set(Array.from(this.entityHashesIndex.keys()));
166
+ if (currentHashesIndex) {
167
+ yield Promise.all<void>(
168
+ Array.from(currentHashesIndex.entries()).map(
169
+ ([elementPath, elementHash]) =>
170
+ promisify(() => {
171
+ const entity = currentEntities.find(
172
+ (e) => e.path === elementPath,
173
+ );
174
+ const originalElementHash =
175
+ this.entityHashesIndex.get(elementPath);
176
+ if (!originalElementHash) {
177
+ changes.push(
178
+ new EntityDiff(
179
+ undefined,
180
+ elementPath,
181
+ EntityChangeType.CREATE,
182
+ ),
183
+ );
184
+ entityChanges.push({
185
+ classifierPath: guaranteeNonNullable(entity).classifierPath,
186
+ entityPath: guaranteeNonNullable(entity).path,
187
+ content: guaranteeNonNullable(entity).content,
188
+ type: EntityChangeType.CREATE,
189
+ });
190
+ } else if (originalElementHash !== elementHash) {
191
+ changes.push(
192
+ new EntityDiff(
193
+ elementPath,
194
+ elementPath,
195
+ EntityChangeType.MODIFY,
196
+ ),
197
+ );
198
+ entityChanges.push({
199
+ classifierPath: guaranteeNonNullable(entity).classifierPath,
200
+ entityPath: guaranteeNonNullable(entity).path,
201
+ content: guaranteeNonNullable(entity).content,
202
+ type: EntityChangeType.MODIFY,
203
+ });
204
+ }
205
+ originalPaths.delete(elementPath);
206
+ }),
207
+ ),
208
+ );
209
+ }
210
+ yield promisify(() => {
211
+ Array.from(originalPaths).forEach((path) => {
212
+ changes.push(
213
+ new EntityDiff(path, undefined, EntityChangeType.DELETE),
214
+ );
215
+ entityChanges.push({
216
+ type: EntityChangeType.DELETE,
217
+ entityPath: path,
218
+ });
219
+ });
220
+ });
221
+ }
222
+ this.changes = changes;
223
+ guaranteeType(
224
+ this.editorStore.localChangesState,
225
+ TextLocalChangesState,
226
+ ).localChanges = entityChanges;
227
+ if (!quiet) {
228
+ this.editorStore.applicationStore.log.info(
229
+ LogEvent.create(
230
+ CHANGE_DETECTION_EVENT.CHANGE_DETECTION_CHANGES_COMPUTED,
231
+ ),
232
+ Date.now() - startTime,
233
+ 'ms',
234
+ );
235
+ }
236
+ }
237
+
143
238
  *buildEntityHashesIndex(
144
239
  entities: Entity[],
145
240
  logEvent: LogEvent,
@@ -303,6 +398,7 @@ export class ChangeDetectionState {
303
398
  computeConflictResolutionConflicts: flow,
304
399
  computeEntityChangeConflicts: flow,
305
400
  computeLocalChanges: flow,
401
+ computeLocalChangesInTextMode: flow,
306
402
  computeAggregatedWorkspaceRemoteChanges: flow,
307
403
  observeGraph: flow,
308
404
  });
@@ -759,6 +855,29 @@ export class ChangeDetectionState {
759
855
  }
760
856
  }
761
857
 
858
+ *computeLocalChangesInTextMode(
859
+ currentEntities: Entity[],
860
+ quiet?: boolean,
861
+ ): GeneratorFn<void> {
862
+ const startTime = Date.now();
863
+ yield Promise.all([
864
+ this.workspaceLocalLatestRevisionState.computeChangesInTextMode(
865
+ currentEntities,
866
+ quiet,
867
+ ),
868
+ ]);
869
+ if (!quiet) {
870
+ this.editorStore.applicationStore.log.info(
871
+ LogEvent.create(
872
+ CHANGE_DETECTION_EVENT.CHANGE_DETECTION_CHANGES_COMPUTED,
873
+ ),
874
+ Date.now() - startTime,
875
+ 'ms',
876
+ );
877
+ }
878
+ this.initState.pass();
879
+ }
880
+
762
881
  *observeGraph(): GeneratorFn<void> {
763
882
  if (this.initState.hasSucceeded) {
764
883
  throw new IllegalStateError(