@finos/legend-application-studio 22.1.6 → 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 (73) 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 +188 -42
  20. package/lib/stores/EditorGraphState.js.map +1 -1
  21. package/lib/stores/EditorStore.d.ts +3 -2
  22. package/lib/stores/EditorStore.d.ts.map +1 -1
  23. package/lib/stores/EditorStore.js +19 -5
  24. package/lib/stores/EditorStore.js.map +1 -1
  25. package/lib/stores/EditorTabManagerState.d.ts +2 -10
  26. package/lib/stores/EditorTabManagerState.d.ts.map +1 -1
  27. package/lib/stores/EditorTabManagerState.js +21 -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 +51 -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 +177 -23
  50. package/lib/stores/editor-state/project-configuration-editor-state/ProjectDependencyEditorState.js.map +1 -1
  51. package/lib/stores/project-viewer/ProjectViewerStore.d.ts.map +1 -1
  52. package/lib/stores/project-viewer/ProjectViewerStore.js +1 -1
  53. package/lib/stores/project-viewer/ProjectViewerStore.js.map +1 -1
  54. package/lib/stores/sidebar-state/LocalChangesState.d.ts +28 -3
  55. package/lib/stores/sidebar-state/LocalChangesState.d.ts.map +1 -1
  56. package/lib/stores/sidebar-state/LocalChangesState.js +186 -113
  57. package/lib/stores/sidebar-state/LocalChangesState.js.map +1 -1
  58. package/package.json +12 -12
  59. package/src/components/editor/edit-panel/project-configuration-editor/ProjectDependencyEditor.tsx +430 -169
  60. package/src/components/editor/side-bar/Explorer.tsx +1 -0
  61. package/src/components/editor/side-bar/LocalChanges.tsx +16 -6
  62. package/src/stores/ChangeDetectionState.ts +119 -0
  63. package/src/stores/EditorGraphState.ts +295 -49
  64. package/src/stores/EditorStore.ts +27 -5
  65. package/src/stores/EditorTabManagerState.ts +36 -37
  66. package/src/stores/ExplorerTreeState.ts +116 -0
  67. package/src/stores/LegendStudioRouter.ts +1 -1
  68. package/src/stores/editor-state/FileGenerationViewerState.ts +5 -0
  69. package/src/stores/editor-state/GraphGenerationState.ts +9 -0
  70. package/src/stores/editor-state/element-editor-state/ElementEditorState.ts +5 -0
  71. package/src/stores/editor-state/project-configuration-editor-state/ProjectDependencyEditorState.ts +261 -34
  72. package/src/stores/project-viewer/ProjectViewerStore.ts +3 -1
  73. package/src/stores/sidebar-state/LocalChangesState.ts +320 -215
@@ -174,7 +174,7 @@ class PatchLoaderState {
174
174
  }
175
175
  }
176
176
 
177
- export class LocalChangesState {
177
+ export abstract class LocalChangesState {
178
178
  readonly editorStore: EditorStore;
179
179
  readonly sdlcState: EditorSDLCState;
180
180
  readonly workspaceSyncState: WorkspaceSyncState;
@@ -186,10 +186,11 @@ export class LocalChangesState {
186
186
  constructor(editorStore: EditorStore, sdlcState: EditorSDLCState) {
187
187
  makeObservable(this, {
188
188
  hasUnpushedChanges: computed,
189
- openPotentialWorkspacePullConflict: action,
190
189
  refreshWorkspaceSyncStatus: flow,
191
190
  refreshLocalChanges: flow,
192
191
  pushLocalChanges: flow,
192
+ processConflicts: flow,
193
+ restartChangeDetection: flow,
193
194
  });
194
195
 
195
196
  this.editorStore = editorStore;
@@ -245,189 +246,6 @@ export class LocalChangesState {
245
246
  }
246
247
  }
247
248
 
248
- openLocalChange(diff: EntityDiff): void {
249
- const fromEntityGetter = (
250
- entityPath: string | undefined,
251
- ): Entity | undefined => {
252
- if (entityPath) {
253
- return this.editorStore.changeDetectionState.workspaceLocalLatestRevisionState.entities.find(
254
- (e) => e.path === entityPath,
255
- );
256
- }
257
- return undefined;
258
- };
259
- const toEntityGetter = (
260
- entityPath: string | undefined,
261
- ): Entity | undefined => {
262
- if (!entityPath) {
263
- return undefined;
264
- }
265
- const element =
266
- this.editorStore.graphManagerState.graph.getNullableElement(entityPath);
267
- if (!element) {
268
- return undefined;
269
- }
270
- const entity =
271
- this.editorStore.graphManagerState.graphManager.elementToEntity(
272
- element,
273
- {
274
- pruneSourceInformation: true,
275
- },
276
- );
277
- return entity;
278
- };
279
- const fromEntity = EntityDiff.shouldOldEntityExist(diff)
280
- ? guaranteeNonNullable(
281
- fromEntityGetter(diff.getValidatedOldPath()),
282
- `Can't find entity with path '${diff.oldPath}'`,
283
- )
284
- : undefined;
285
- const toEntity = EntityDiff.shouldNewEntityExist(diff)
286
- ? guaranteeNonNullable(
287
- toEntityGetter(diff.getValidatedNewPath()),
288
- `Can't find entity with path '${diff.newPath}'`,
289
- )
290
- : undefined;
291
- this.editorStore.tabManagerState.openTab(
292
- new EntityDiffViewState(
293
- this.editorStore,
294
- SPECIAL_REVISION_ALIAS.WORKSPACE_HEAD,
295
- SPECIAL_REVISION_ALIAS.LOCAL,
296
- diff.oldPath,
297
- diff.newPath,
298
- fromEntity,
299
- toEntity,
300
- fromEntityGetter,
301
- toEntityGetter,
302
- ),
303
- );
304
- }
305
-
306
- openWorkspacePullChange(diff: EntityDiff): void {
307
- const fromEntityGetter = (
308
- entityPath: string | undefined,
309
- ): Entity | undefined => {
310
- if (entityPath) {
311
- return this.editorStore.changeDetectionState.workspaceLocalLatestRevisionState.entities.find(
312
- (e) => e.path === entityPath,
313
- );
314
- }
315
- return undefined;
316
- };
317
- const toEntityGetter = (
318
- entityPath: string | undefined,
319
- ): Entity | undefined => {
320
- if (entityPath) {
321
- return this.editorStore.changeDetectionState.workspaceRemoteLatestRevisionState.entities.find(
322
- (e) => e.path === entityPath,
323
- );
324
- }
325
- return undefined;
326
- };
327
- const fromEntity = EntityDiff.shouldOldEntityExist(diff)
328
- ? guaranteeNonNullable(
329
- fromEntityGetter(diff.getValidatedOldPath()),
330
- `Can't find entity with path '${diff.oldPath}'`,
331
- )
332
- : undefined;
333
- const toEntity = EntityDiff.shouldNewEntityExist(diff)
334
- ? guaranteeNonNullable(
335
- toEntityGetter(diff.getValidatedNewPath()),
336
- `Can't find entity with path '${diff.newPath}'`,
337
- )
338
- : undefined;
339
- this.editorStore.tabManagerState.openTab(
340
- new EntityDiffViewState(
341
- this.editorStore,
342
- SPECIAL_REVISION_ALIAS.LOCAL,
343
- SPECIAL_REVISION_ALIAS.WORKSPACE_HEAD,
344
- diff.oldPath,
345
- diff.newPath,
346
- fromEntity,
347
- toEntity,
348
- fromEntityGetter,
349
- toEntityGetter,
350
- ),
351
- );
352
- }
353
-
354
- openPotentialWorkspacePullConflict(conflict: EntityChangeConflict): void {
355
- const baseEntityGetter = (
356
- entityPath: string | undefined,
357
- ): Entity | undefined =>
358
- entityPath
359
- ? this.editorStore.changeDetectionState.workspaceLocalLatestRevisionState.entities.find(
360
- (e) => e.path === entityPath,
361
- )
362
- : undefined;
363
- const currentChangeEntityGetter = (
364
- entityPath: string | undefined,
365
- ): Entity | undefined =>
366
- entityPath
367
- ? this.editorStore.graphManagerState.graph.allOwnElements
368
- .map((element) =>
369
- this.editorStore.graphManagerState.graphManager.elementToEntity(
370
- element,
371
- ),
372
- )
373
- .find((e) => e.path === entityPath)
374
- : undefined;
375
- const incomingChangeEntityGetter = (
376
- entityPath: string | undefined,
377
- ): Entity | undefined =>
378
- entityPath
379
- ? this.editorStore.changeDetectionState.workspaceRemoteLatestRevisionState.entities.find(
380
- (e) => e.path === entityPath,
381
- )
382
- : undefined;
383
- const conflictEditorState = new EntityChangeConflictEditorState(
384
- this.editorStore,
385
- this.editorStore.conflictResolutionState,
386
- conflict.entityPath,
387
- SPECIAL_REVISION_ALIAS.WORKSPACE_BASE,
388
- SPECIAL_REVISION_ALIAS.LOCAL,
389
- SPECIAL_REVISION_ALIAS.WORKSPACE_HEAD,
390
- baseEntityGetter(conflict.entityPath),
391
- currentChangeEntityGetter(conflict.entityPath),
392
- incomingChangeEntityGetter(conflict.entityPath),
393
- baseEntityGetter,
394
- currentChangeEntityGetter,
395
- incomingChangeEntityGetter,
396
- );
397
- conflictEditorState.setReadOnly(true);
398
- this.editorStore.tabManagerState.openTab(conflictEditorState);
399
- }
400
-
401
- *refreshLocalChanges(): GeneratorFn<void> {
402
- const startTime = Date.now();
403
- this.refreshLocalChangesDetectorState.inProgress();
404
- try {
405
- // ======= (RE)START CHANGE DETECTION =======
406
- this.editorStore.changeDetectionState.stop();
407
- yield Promise.all([
408
- this.sdlcState.buildWorkspaceLatestRevisionEntityHashesIndex(),
409
- this.editorStore.changeDetectionState.preComputeGraphElementHashes(),
410
- ]);
411
- this.editorStore.changeDetectionState.start();
412
- this.editorStore.applicationStore.log.info(
413
- LogEvent.create(CHANGE_DETECTION_EVENT.CHANGE_DETECTION_RESTARTED),
414
- Date.now() - startTime,
415
- 'ms',
416
- );
417
- // ======= FINISHED (RE)START CHANGE DETECTION =======
418
- } catch (error) {
419
- assertErrorThrown(error);
420
- this.editorStore.applicationStore.log.error(
421
- LogEvent.create(LEGEND_STUDIO_APP_EVENT.SDLC_MANAGER_FAILURE),
422
- error,
423
- );
424
- this.editorStore.applicationStore.notifyError(error);
425
- this.sdlcState.handleChangeDetectionRefreshIssue(error);
426
- } finally {
427
- this.refreshLocalChangesDetectorState.complete();
428
- }
429
- }
430
-
431
249
  *refreshWorkspaceSyncStatus(): GeneratorFn<void> {
432
250
  try {
433
251
  this.refreshWorkspaceSyncStatusState.inProgress();
@@ -488,6 +306,18 @@ export class LocalChangesState {
488
306
  }
489
307
  }
490
308
 
309
+ abstract refreshLocalChanges(): GeneratorFn<void>;
310
+
311
+ abstract processConflicts(): GeneratorFn<void>;
312
+
313
+ abstract getLocalChanges(): EntityChange[];
314
+
315
+ abstract getCurrentHashIndexes(): Map<string, string>;
316
+
317
+ abstract stopChangeDetection(): void;
318
+
319
+ abstract restartChangeDetection(): GeneratorFn<void>;
320
+
491
321
  *pushLocalChanges(pushMessage?: string): GeneratorFn<void> {
492
322
  if (
493
323
  this.pushChangesState.isInProgress ||
@@ -496,29 +326,11 @@ export class LocalChangesState {
496
326
  return;
497
327
  }
498
328
  // check if the workspace is in conflict resolution mode
499
- try {
500
- const isInConflictResolutionMode = (yield flowResult(
501
- this.sdlcState.checkIfCurrentWorkspaceIsInConflictResolutionMode(),
502
- )) as boolean;
503
- if (isInConflictResolutionMode) {
504
- this.editorStore.applicationStore.setBlockingAlert({
505
- message: 'Workspace is in conflict resolution mode',
506
- prompt: 'Please refresh the application',
507
- });
508
- return;
509
- }
510
- } catch (error) {
511
- assertErrorThrown(error);
512
- this.editorStore.applicationStore.notifyWarning(
513
- 'Failed to check if current workspace is in conflict resolution mode',
514
- );
515
- return;
516
- }
329
+ yield flowResult(this.processConflicts());
517
330
 
518
331
  this.pushChangesState.inProgress();
519
332
  const startTime = Date.now();
520
- const localChanges =
521
- this.editorStore.graphState.computeLocalEntityChanges();
333
+ const localChanges = this.getLocalChanges();
522
334
  if (!localChanges.length) {
523
335
  this.pushChangesState.complete();
524
336
  return;
@@ -576,8 +388,8 @@ export class LocalChangesState {
576
388
  this.pushChangesState.complete();
577
389
  return;
578
390
  }
579
- const currentHashesIndex =
580
- this.editorStore.changeDetectionState.snapshotLocalEntityHashesIndex();
391
+ const currentHashesIndex = this.getCurrentHashIndexes();
392
+
581
393
  try {
582
394
  const nullableRevisionChange =
583
395
  (yield this.editorStore.sdlcServerClient.performEntityChanges(
@@ -613,7 +425,9 @@ export class LocalChangesState {
613
425
  );
614
426
 
615
427
  // ======= (RE)START CHANGE DETECTION =======
616
- this.editorStore.changeDetectionState.stop();
428
+
429
+ this.stopChangeDetection();
430
+
617
431
  try {
618
432
  /**
619
433
  * Here we try to rebuild local hash index. If failed, we will use local hash index, but for veracity, it's best to use entities
@@ -686,13 +500,7 @@ export class LocalChangesState {
686
500
  throw error;
687
501
  }
688
502
  }
689
- yield this.editorStore.changeDetectionState.preComputeGraphElementHashes();
690
- this.editorStore.changeDetectionState.start();
691
- yield Promise.all([
692
- this.editorStore.changeDetectionState.computeAggregatedWorkspaceChanges(
693
- true,
694
- ),
695
- ]);
503
+ yield flowResult(this.restartChangeDetection());
696
504
  this.editorStore.applicationStore.log.info(
697
505
  LogEvent.create(CHANGE_DETECTION_EVENT.CHANGE_DETECTION_RESTARTED),
698
506
  Date.now() - syncFinishedTime,
@@ -723,3 +531,300 @@ export class LocalChangesState {
723
531
  }
724
532
  }
725
533
  }
534
+
535
+ export class FormLocalChangesState extends LocalChangesState {
536
+ constructor(editorStore: EditorStore, sdlcState: EditorSDLCState) {
537
+ super(editorStore, sdlcState);
538
+ makeObservable(this, {
539
+ openPotentialWorkspacePullConflict: action,
540
+ });
541
+ }
542
+ openLocalChange(diff: EntityDiff): void {
543
+ const fromEntityGetter = (
544
+ entityPath: string | undefined,
545
+ ): Entity | undefined => {
546
+ if (entityPath) {
547
+ return this.editorStore.changeDetectionState.workspaceLocalLatestRevisionState.entities.find(
548
+ (e) => e.path === entityPath,
549
+ );
550
+ }
551
+ return undefined;
552
+ };
553
+ const toEntityGetter = (
554
+ entityPath: string | undefined,
555
+ ): Entity | undefined => {
556
+ if (!entityPath) {
557
+ return undefined;
558
+ }
559
+ const element =
560
+ this.editorStore.graphManagerState.graph.getNullableElement(entityPath);
561
+ if (!element) {
562
+ return undefined;
563
+ }
564
+ const entity =
565
+ this.editorStore.graphManagerState.graphManager.elementToEntity(
566
+ element,
567
+ {
568
+ pruneSourceInformation: true,
569
+ },
570
+ );
571
+ return entity;
572
+ };
573
+ const fromEntity = EntityDiff.shouldOldEntityExist(diff)
574
+ ? guaranteeNonNullable(
575
+ fromEntityGetter(diff.getValidatedOldPath()),
576
+ `Can't find entity with path '${diff.oldPath}'`,
577
+ )
578
+ : undefined;
579
+ const toEntity = EntityDiff.shouldNewEntityExist(diff)
580
+ ? guaranteeNonNullable(
581
+ toEntityGetter(diff.getValidatedNewPath()),
582
+ `Can't find entity with path '${diff.newPath}'`,
583
+ )
584
+ : undefined;
585
+ this.editorStore.tabManagerState.openTab(
586
+ new EntityDiffViewState(
587
+ this.editorStore,
588
+ SPECIAL_REVISION_ALIAS.WORKSPACE_HEAD,
589
+ SPECIAL_REVISION_ALIAS.LOCAL,
590
+ diff.oldPath,
591
+ diff.newPath,
592
+ fromEntity,
593
+ toEntity,
594
+ fromEntityGetter,
595
+ toEntityGetter,
596
+ ),
597
+ );
598
+ }
599
+
600
+ openWorkspacePullChange(diff: EntityDiff): void {
601
+ const fromEntityGetter = (
602
+ entityPath: string | undefined,
603
+ ): Entity | undefined => {
604
+ if (entityPath) {
605
+ return this.editorStore.changeDetectionState.workspaceLocalLatestRevisionState.entities.find(
606
+ (e) => e.path === entityPath,
607
+ );
608
+ }
609
+ return undefined;
610
+ };
611
+ const toEntityGetter = (
612
+ entityPath: string | undefined,
613
+ ): Entity | undefined => {
614
+ if (entityPath) {
615
+ return this.editorStore.changeDetectionState.workspaceRemoteLatestRevisionState.entities.find(
616
+ (e) => e.path === entityPath,
617
+ );
618
+ }
619
+ return undefined;
620
+ };
621
+ const fromEntity = EntityDiff.shouldOldEntityExist(diff)
622
+ ? guaranteeNonNullable(
623
+ fromEntityGetter(diff.getValidatedOldPath()),
624
+ `Can't find entity with path '${diff.oldPath}'`,
625
+ )
626
+ : undefined;
627
+ const toEntity = EntityDiff.shouldNewEntityExist(diff)
628
+ ? guaranteeNonNullable(
629
+ toEntityGetter(diff.getValidatedNewPath()),
630
+ `Can't find entity with path '${diff.newPath}'`,
631
+ )
632
+ : undefined;
633
+ this.editorStore.tabManagerState.openTab(
634
+ new EntityDiffViewState(
635
+ this.editorStore,
636
+ SPECIAL_REVISION_ALIAS.LOCAL,
637
+ SPECIAL_REVISION_ALIAS.WORKSPACE_HEAD,
638
+ diff.oldPath,
639
+ diff.newPath,
640
+ fromEntity,
641
+ toEntity,
642
+ fromEntityGetter,
643
+ toEntityGetter,
644
+ ),
645
+ );
646
+ }
647
+
648
+ openPotentialWorkspacePullConflict(conflict: EntityChangeConflict): void {
649
+ const baseEntityGetter = (
650
+ entityPath: string | undefined,
651
+ ): Entity | undefined =>
652
+ entityPath
653
+ ? this.editorStore.changeDetectionState.workspaceLocalLatestRevisionState.entities.find(
654
+ (e) => e.path === entityPath,
655
+ )
656
+ : undefined;
657
+ const currentChangeEntityGetter = (
658
+ entityPath: string | undefined,
659
+ ): Entity | undefined =>
660
+ entityPath
661
+ ? this.editorStore.graphManagerState.graph.allOwnElements
662
+ .map((element) =>
663
+ this.editorStore.graphManagerState.graphManager.elementToEntity(
664
+ element,
665
+ ),
666
+ )
667
+ .find((e) => e.path === entityPath)
668
+ : undefined;
669
+ const incomingChangeEntityGetter = (
670
+ entityPath: string | undefined,
671
+ ): Entity | undefined =>
672
+ entityPath
673
+ ? this.editorStore.changeDetectionState.workspaceRemoteLatestRevisionState.entities.find(
674
+ (e) => e.path === entityPath,
675
+ )
676
+ : undefined;
677
+ const conflictEditorState = new EntityChangeConflictEditorState(
678
+ this.editorStore,
679
+ this.editorStore.conflictResolutionState,
680
+ conflict.entityPath,
681
+ SPECIAL_REVISION_ALIAS.WORKSPACE_BASE,
682
+ SPECIAL_REVISION_ALIAS.LOCAL,
683
+ SPECIAL_REVISION_ALIAS.WORKSPACE_HEAD,
684
+ baseEntityGetter(conflict.entityPath),
685
+ currentChangeEntityGetter(conflict.entityPath),
686
+ incomingChangeEntityGetter(conflict.entityPath),
687
+ baseEntityGetter,
688
+ currentChangeEntityGetter,
689
+ incomingChangeEntityGetter,
690
+ );
691
+ conflictEditorState.setReadOnly(true);
692
+ this.editorStore.tabManagerState.openTab(conflictEditorState);
693
+ }
694
+
695
+ *refreshLocalChanges(): GeneratorFn<void> {
696
+ const startTime = Date.now();
697
+ this.refreshLocalChangesDetectorState.inProgress();
698
+ try {
699
+ // ======= (RE)START CHANGE DETECTION =======
700
+ this.editorStore.changeDetectionState.stop();
701
+ yield Promise.all([
702
+ this.sdlcState.buildWorkspaceLatestRevisionEntityHashesIndex(),
703
+ this.editorStore.changeDetectionState.preComputeGraphElementHashes(),
704
+ ]);
705
+ this.editorStore.changeDetectionState.start();
706
+ this.editorStore.applicationStore.log.info(
707
+ LogEvent.create(CHANGE_DETECTION_EVENT.CHANGE_DETECTION_RESTARTED),
708
+ Date.now() - startTime,
709
+ 'ms',
710
+ );
711
+ // ======= FINISHED (RE)START CHANGE DETECTION =======
712
+ } catch (error) {
713
+ assertErrorThrown(error);
714
+ this.editorStore.applicationStore.log.error(
715
+ LogEvent.create(LEGEND_STUDIO_APP_EVENT.SDLC_MANAGER_FAILURE),
716
+ error,
717
+ );
718
+ this.editorStore.applicationStore.notifyError(error);
719
+ this.sdlcState.handleChangeDetectionRefreshIssue(error);
720
+ } finally {
721
+ this.refreshLocalChangesDetectorState.complete();
722
+ }
723
+ }
724
+
725
+ *processConflicts(): GeneratorFn<void> {
726
+ try {
727
+ const isInConflictResolutionMode = (yield flowResult(
728
+ this.sdlcState.checkIfCurrentWorkspaceIsInConflictResolutionMode(),
729
+ )) as boolean;
730
+ if (isInConflictResolutionMode) {
731
+ this.editorStore.applicationStore.setBlockingAlert({
732
+ message: 'Workspace is in conflict resolution mode',
733
+ prompt: 'Please refresh the application',
734
+ });
735
+ return;
736
+ }
737
+ } catch (error) {
738
+ assertErrorThrown(error);
739
+ this.editorStore.applicationStore.notifyWarning(
740
+ 'Failed to check if current workspace is in conflict resolution mode',
741
+ );
742
+ return;
743
+ }
744
+ }
745
+
746
+ getLocalChanges(): EntityChange[] {
747
+ return this.editorStore.graphState.computeLocalEntityChanges();
748
+ }
749
+
750
+ getCurrentHashIndexes(): Map<string, string> {
751
+ return this.editorStore.changeDetectionState.snapshotLocalEntityHashesIndex();
752
+ }
753
+
754
+ stopChangeDetection(): void {
755
+ this.editorStore.changeDetectionState.stop();
756
+ }
757
+
758
+ *restartChangeDetection(): GeneratorFn<void> {
759
+ yield this.editorStore.changeDetectionState.preComputeGraphElementHashes();
760
+ this.editorStore.changeDetectionState.start();
761
+ yield Promise.all([
762
+ this.editorStore.changeDetectionState.computeAggregatedWorkspaceChanges(
763
+ true,
764
+ ),
765
+ ]);
766
+ }
767
+ }
768
+
769
+ export class TextLocalChangesState extends LocalChangesState {
770
+ localChanges: EntityChange[] = [];
771
+
772
+ constructor(editorStore: EditorStore, sdlcState: EditorSDLCState) {
773
+ super(editorStore, sdlcState);
774
+ makeObservable(this, {
775
+ setLocalChanges: action,
776
+ });
777
+ }
778
+
779
+ setLocalChanges(val: EntityChange[]): void {
780
+ this.localChanges = val;
781
+ }
782
+
783
+ *refreshLocalChanges(): GeneratorFn<void> {
784
+ this.refreshLocalChangesDetectorState.inProgress();
785
+ try {
786
+ yield Promise.all([
787
+ this.sdlcState.buildWorkspaceLatestRevisionEntityHashesIndex(),
788
+ this.editorStore.changeDetectionState.preComputeGraphElementHashes(),
789
+ ]);
790
+ this.editorStore.changeDetectionState.computeLocalChangesInTextMode(
791
+ this.editorStore.changeDetectionState.workspaceLocalLatestRevisionState
792
+ .entities,
793
+ );
794
+ } catch (error) {
795
+ assertErrorThrown(error);
796
+ this.editorStore.applicationStore.log.error(
797
+ LogEvent.create(LEGEND_STUDIO_APP_EVENT.SDLC_MANAGER_FAILURE),
798
+ error,
799
+ );
800
+ this.editorStore.applicationStore.notifyError(error);
801
+ this.sdlcState.handleChangeDetectionRefreshIssue(error);
802
+ } finally {
803
+ this.refreshLocalChangesDetectorState.complete();
804
+ }
805
+ }
806
+
807
+ *processConflicts(): GeneratorFn<void> {
808
+ return;
809
+ }
810
+
811
+ getLocalChanges(): EntityChange[] {
812
+ return this.localChanges;
813
+ }
814
+
815
+ getCurrentHashIndexes(): Map<string, string> {
816
+ return this.editorStore.changeDetectionState
817
+ .workspaceLocalLatestRevisionState.currentEntityHashesIndex;
818
+ }
819
+
820
+ stopChangeDetection(): void {
821
+ this.localChanges = [];
822
+ }
823
+
824
+ *restartChangeDetection(): GeneratorFn<void> {
825
+ this.editorStore.changeDetectionState.computeLocalChangesInTextMode(
826
+ this.editorStore.changeDetectionState.workspaceLocalLatestRevisionState
827
+ .entities,
828
+ );
829
+ }
830
+ }