@finos/legend-application-studio 28.19.69 → 28.19.70

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 (22) hide show
  1. package/lib/components/editor/editor-group/project-configuration-editor/ProjectDependencyEditor.d.ts.map +1 -1
  2. package/lib/components/editor/editor-group/project-configuration-editor/ProjectDependencyEditor.js +338 -26
  3. package/lib/components/editor/editor-group/project-configuration-editor/ProjectDependencyEditor.js.map +1 -1
  4. package/lib/index.css +2 -2
  5. package/lib/index.css.map +1 -1
  6. package/lib/package.json +1 -1
  7. package/lib/stores/editor/EditorGraphState.d.ts.map +1 -1
  8. package/lib/stores/editor/EditorGraphState.js +7 -1
  9. package/lib/stores/editor/EditorGraphState.js.map +1 -1
  10. package/lib/stores/editor/editor-state/project-configuration-editor-state/ProjectConfigurationEditorState.d.ts +2 -0
  11. package/lib/stores/editor/editor-state/project-configuration-editor-state/ProjectConfigurationEditorState.d.ts.map +1 -1
  12. package/lib/stores/editor/editor-state/project-configuration-editor-state/ProjectConfigurationEditorState.js +19 -0
  13. package/lib/stores/editor/editor-state/project-configuration-editor-state/ProjectConfigurationEditorState.js.map +1 -1
  14. package/lib/stores/editor/editor-state/project-configuration-editor-state/ProjectDependencyEditorState.d.ts +16 -1
  15. package/lib/stores/editor/editor-state/project-configuration-editor-state/ProjectDependencyEditorState.d.ts.map +1 -1
  16. package/lib/stores/editor/editor-state/project-configuration-editor-state/ProjectDependencyEditorState.js +112 -1
  17. package/lib/stores/editor/editor-state/project-configuration-editor-state/ProjectDependencyEditorState.js.map +1 -1
  18. package/package.json +5 -5
  19. package/src/components/editor/editor-group/project-configuration-editor/ProjectDependencyEditor.tsx +599 -53
  20. package/src/stores/editor/EditorGraphState.ts +11 -4
  21. package/src/stores/editor/editor-state/project-configuration-editor-state/ProjectConfigurationEditorState.ts +26 -0
  22. package/src/stores/editor/editor-state/project-configuration-editor-state/ProjectDependencyEditorState.ts +178 -1
@@ -799,15 +799,22 @@ export class EditorGraphState {
799
799
  projectDependencies: ProjectDependency[],
800
800
  ): Promise<ProjectDependencyCoordinates[]> {
801
801
  return Promise.all(
802
- projectDependencies.map(async (dep) =>
803
- Promise.resolve(
802
+ projectDependencies.map(async (dep) => {
803
+ const exclusionCoordinates = (dep.exclusions ?? []).map(
804
+ (exclusion) => ({
805
+ groupId: guaranteeNonNullable(exclusion.groupId),
806
+ artifactId: guaranteeNonNullable(exclusion.artifactId),
807
+ }),
808
+ );
809
+ return Promise.resolve(
804
810
  new ProjectDependencyCoordinates(
805
811
  guaranteeNonNullable(dep.groupId),
806
812
  guaranteeNonNullable(dep.artifactId),
807
813
  dep.versionId,
814
+ exclusionCoordinates.length > 0 ? exclusionCoordinates : undefined,
808
815
  ),
809
- ),
810
- ),
816
+ );
817
+ }),
811
818
  );
812
819
  }
813
820
 
@@ -106,6 +106,8 @@ export class ProjectConfigurationEditorState extends EditorState {
106
106
  setProjectConfiguration: action,
107
107
  setSelectedTab: action,
108
108
  setManualOverwrite: action,
109
+ syncExclusionsToProjectDependencies: action,
110
+ loadExclusionsFromProjectDependencies: action,
109
111
  fectchAssociatedProjectsAndVersions: flow,
110
112
  updateProjectConfiguration: flow,
111
113
  updateToLatestStructure: flow,
@@ -131,6 +133,7 @@ export class ProjectConfigurationEditorState extends EditorState {
131
133
 
132
134
  setProjectConfiguration(projectConfiguration: ProjectConfiguration): void {
133
135
  this.projectConfiguration = projectConfiguration;
136
+ this.loadExclusionsFromProjectDependencies();
134
137
  }
135
138
 
136
139
  setSelectedTab(tab: CONFIGURATION_EDITOR_TAB): void {
@@ -191,6 +194,24 @@ export class ProjectConfigurationEditorState extends EditorState {
191
194
  );
192
195
  }
193
196
 
197
+ syncExclusionsToProjectDependencies(): void {
198
+ this.currentProjectConfiguration.projectDependencies.forEach((dep) => {
199
+ const exclusions = this.projectDependencyEditorState.getExclusions(
200
+ dep.projectId,
201
+ );
202
+ dep.setExclusions(exclusions);
203
+ });
204
+ }
205
+
206
+ loadExclusionsFromProjectDependencies(): void {
207
+ this.projectConfiguration?.projectDependencies.forEach((dep) => {
208
+ if (dep.exclusions && dep.exclusions.length > 0) {
209
+ this.projectDependencyEditorState.dependencyExclusions[dep.projectId] =
210
+ [...dep.exclusions];
211
+ }
212
+ });
213
+ }
214
+
194
215
  *fectchAssociatedProjectsAndVersions(): GeneratorFn<void> {
195
216
  this.fetchingProjectVersionsState.inProgress();
196
217
  try {
@@ -234,6 +255,9 @@ export class ProjectConfigurationEditorState extends EditorState {
234
255
  ): GeneratorFn<void> {
235
256
  try {
236
257
  this.updatingConfigurationState.inProgress();
258
+
259
+ this.syncExclusionsToProjectDependencies();
260
+
237
261
  yield this.editorStore.sdlcServerClient.updateConfiguration(
238
262
  this.editorStore.sdlcState.activeProject.projectId,
239
263
  this.editorStore.sdlcState.activeWorkspace,
@@ -340,6 +364,8 @@ export class ProjectConfigurationEditorState extends EditorState {
340
364
  showLoading: true,
341
365
  });
342
366
  try {
367
+ this.syncExclusionsToProjectDependencies();
368
+
343
369
  const updateProjectConfigurationCommand =
344
370
  new UpdateProjectConfigurationCommand(
345
371
  this.currentProjectConfiguration.groupId,
@@ -24,6 +24,7 @@ import {
24
24
  assertErrorThrown,
25
25
  LogEvent,
26
26
  isNonNullable,
27
+ guaranteeNonNullable,
27
28
  uuid,
28
29
  } from '@finos/legend-shared';
29
30
  import {
@@ -39,7 +40,11 @@ import {
39
40
  } from '@finos/legend-server-depot';
40
41
  import type { TreeData, TreeNodeData } from '@finos/legend-art';
41
42
  import { LEGEND_STUDIO_APP_EVENT } from '../../../../__lib__/LegendStudioEvent.js';
42
- import type { ProjectConfiguration } from '@finos/legend-server-sdlc';
43
+ import {
44
+ ProjectDependencyExclusion,
45
+ type ProjectConfiguration,
46
+ } from '@finos/legend-server-sdlc';
47
+ import { generateGAVCoordinates } from '@finos/legend-storage';
43
48
 
44
49
  export abstract class ProjectDependencyConflictTreeNodeData
45
50
  implements TreeNodeData
@@ -299,6 +304,12 @@ export class ProjectDependencyEditorState {
299
304
  expandConflictsState = ActionState.create();
300
305
  buildConflictPathState = ActionState.create();
301
306
 
307
+ // Exclusions management
308
+ selectedDependencyForExclusions: ProjectDependencyVersionNode | undefined;
309
+ dependencyExclusions: {
310
+ [dependencyId: string]: ProjectDependencyExclusion[];
311
+ } = {};
312
+
302
313
  constructor(
303
314
  configState: ProjectConfigurationEditorState,
304
315
  editorStore: EditorStore,
@@ -312,6 +323,8 @@ export class ProjectDependencyEditorState {
312
323
  reportTab: observable,
313
324
  expandConflictsState: observable,
314
325
  buildConflictPathState: observable,
326
+ selectedDependencyForExclusions: observable,
327
+ dependencyExclusions: observable,
315
328
  setReportTab: action,
316
329
  expandAllConflicts: action,
317
330
  setFlattenDependencyTreeData: action,
@@ -320,6 +333,15 @@ export class ProjectDependencyEditorState {
320
333
  setDependencyTreeData: action,
321
334
  buildConflictPaths: action,
322
335
  setConflictStates: action,
336
+ setSelectedDependencyForExclusions: action,
337
+ addExclusion: action,
338
+ addExclusionByCoordinate: action,
339
+ removeExclusion: action,
340
+ removeExclusionByCoordinate: action,
341
+ clearExclusions: action,
342
+ getExclusions: action,
343
+ getExclusionCoordinates: action,
344
+ syncExclusionsToProjectDependency: action,
323
345
  fetchDependencyReport: flow,
324
346
  });
325
347
  this.configState = configState;
@@ -376,6 +398,149 @@ export class ProjectDependencyEditorState {
376
398
  return this.configState.projectConfiguration;
377
399
  }
378
400
 
401
+ setSelectedDependencyForExclusions(
402
+ dependency: ProjectDependencyVersionNode | undefined,
403
+ ): void {
404
+ this.selectedDependencyForExclusions = dependency;
405
+ }
406
+
407
+ addExclusion(
408
+ dependencyId: string,
409
+ exclusion: ProjectDependencyExclusion,
410
+ ): void {
411
+ if (!this.dependencyExclusions[dependencyId]) {
412
+ this.dependencyExclusions[dependencyId] = [];
413
+ }
414
+ const existingExclusion = this.findExistingExclusion(
415
+ dependencyId,
416
+ generateGAVCoordinates(
417
+ guaranteeNonNullable(exclusion.groupId),
418
+ guaranteeNonNullable(exclusion.artifactId),
419
+ undefined,
420
+ ),
421
+ );
422
+ if (!existingExclusion) {
423
+ this.dependencyExclusions[dependencyId].push(exclusion);
424
+ this.syncExclusionsToProjectDependency(dependencyId);
425
+ }
426
+ }
427
+
428
+ addExclusionByCoordinate(
429
+ dependencyId: string,
430
+ exclusionCoordinate: string,
431
+ ): void {
432
+ const exclusion =
433
+ ProjectDependencyExclusion.fromCoordinate(exclusionCoordinate);
434
+ this.addExclusion(dependencyId, exclusion);
435
+ }
436
+
437
+ removeExclusion(
438
+ dependencyId: string,
439
+ exclusion: ProjectDependencyExclusion,
440
+ ): void {
441
+ if (this.dependencyExclusions[dependencyId]) {
442
+ const coordinate = generateGAVCoordinates(
443
+ guaranteeNonNullable(exclusion.groupId),
444
+ guaranteeNonNullable(exclusion.artifactId),
445
+ undefined,
446
+ );
447
+ const index = this.findExclusionIndex(dependencyId, coordinate);
448
+ if (index > -1) {
449
+ this.dependencyExclusions[dependencyId].splice(index, 1);
450
+ }
451
+ if (this.dependencyExclusions[dependencyId].length === 0) {
452
+ delete this.dependencyExclusions[dependencyId];
453
+ }
454
+ this.syncExclusionsToProjectDependency(dependencyId);
455
+ }
456
+ }
457
+
458
+ removeExclusionByCoordinate(
459
+ dependencyId: string,
460
+ exclusionCoordinate: string,
461
+ ): void {
462
+ if (this.dependencyExclusions[dependencyId]) {
463
+ const index = this.findExclusionIndex(dependencyId, exclusionCoordinate);
464
+ if (index > -1) {
465
+ this.dependencyExclusions[dependencyId].splice(index, 1);
466
+ }
467
+ if (this.dependencyExclusions[dependencyId].length === 0) {
468
+ delete this.dependencyExclusions[dependencyId];
469
+ }
470
+ this.syncExclusionsToProjectDependency(dependencyId);
471
+ }
472
+ }
473
+
474
+ clearExclusions(dependencyId?: string): void {
475
+ if (dependencyId) {
476
+ delete this.dependencyExclusions[dependencyId];
477
+ this.syncExclusionsToProjectDependency(dependencyId);
478
+ } else {
479
+ this.dependencyExclusions = {};
480
+ this.projectConfiguration?.projectDependencies.forEach((dep) => {
481
+ this.syncExclusionsToProjectDependency(dep.projectId);
482
+ });
483
+ }
484
+ }
485
+
486
+ getExclusions(dependencyId: string): ProjectDependencyExclusion[] {
487
+ return this.dependencyExclusions[dependencyId] ?? [];
488
+ }
489
+
490
+ getExclusionCoordinates(dependencyId: string): string[] {
491
+ const exclusions = this.getExclusions(dependencyId);
492
+ return exclusions.map((e) =>
493
+ generateGAVCoordinates(
494
+ guaranteeNonNullable(e.groupId),
495
+ guaranteeNonNullable(e.artifactId),
496
+ undefined,
497
+ ),
498
+ );
499
+ }
500
+
501
+ private findExistingExclusion(
502
+ dependencyId: string,
503
+ coordinate: string,
504
+ ): ProjectDependencyExclusion | undefined {
505
+ if (!this.dependencyExclusions[dependencyId]) {
506
+ return undefined;
507
+ }
508
+ for (let i = 0; i < this.dependencyExclusions[dependencyId].length; i++) {
509
+ const exclusion = guaranteeNonNullable(
510
+ this.dependencyExclusions[dependencyId][i],
511
+ );
512
+ const exclusionCoordinate = generateGAVCoordinates(
513
+ guaranteeNonNullable(exclusion.groupId),
514
+ guaranteeNonNullable(exclusion.artifactId),
515
+ undefined,
516
+ );
517
+ if (exclusionCoordinate === coordinate) {
518
+ return this.dependencyExclusions[dependencyId][i];
519
+ }
520
+ }
521
+ return undefined;
522
+ }
523
+
524
+ private findExclusionIndex(dependencyId: string, coordinate: string): number {
525
+ if (!this.dependencyExclusions[dependencyId]) {
526
+ return -1;
527
+ }
528
+ for (let i = 0; i < this.dependencyExclusions[dependencyId].length; i++) {
529
+ const exclusion = guaranteeNonNullable(
530
+ this.dependencyExclusions[dependencyId][i],
531
+ );
532
+ const exclusionCoordinate = generateGAVCoordinates(
533
+ guaranteeNonNullable(exclusion.groupId),
534
+ guaranteeNonNullable(exclusion.artifactId),
535
+ undefined,
536
+ );
537
+ if (exclusionCoordinate === coordinate) {
538
+ return i;
539
+ }
540
+ }
541
+ return -1;
542
+ }
543
+
379
544
  *fetchDependencyReport(): GeneratorFn<void> {
380
545
  try {
381
546
  this.fetchingDependencyInfoState.inProgress();
@@ -442,5 +607,17 @@ export class ProjectDependencyEditorState {
442
607
  clearTrees(): void {
443
608
  this.flattenDependencyTreeData = undefined;
444
609
  this.dependencyTreeData = undefined;
610
+ this.selectedDependencyForExclusions = undefined;
611
+ }
612
+
613
+ syncExclusionsToProjectDependency(dependencyId: string): void {
614
+ const projectDependency =
615
+ this.projectConfiguration?.projectDependencies.find(
616
+ (dep) => dep.projectId === dependencyId,
617
+ );
618
+ if (projectDependency) {
619
+ const exclusions = this.getExclusions(dependencyId);
620
+ projectDependency.setExclusions(exclusions);
621
+ }
445
622
  }
446
623
  }