From e22f85f718686efe18f18c030c0cab25189d2f7f Mon Sep 17 00:00:00 2001 From: Ridham Shah <49234788+RidhamShah@users.noreply.github.com> Date: Fri, 6 Oct 2023 21:23:18 +0530 Subject: [PATCH 1/3] solve no experiments error after filtering (#1035) Co-authored-by: RidhamShah --- .../Upgrade/src/api/services/ExperimentAssignmentService.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/packages/Upgrade/src/api/services/ExperimentAssignmentService.ts b/backend/packages/Upgrade/src/api/services/ExperimentAssignmentService.ts index 50816c611b..d211674f8e 100644 --- a/backend/packages/Upgrade/src/api/services/ExperimentAssignmentService.ts +++ b/backend/packages/Upgrade/src/api/services/ExperimentAssignmentService.ts @@ -615,6 +615,11 @@ export class ExperimentAssignmentService { filteredExperiments = alreadyAssignedExperiment.flat().concat(filteredExperiments); + // return if no experiment + if (filteredExperiments.length === 0) { + return []; + } + // assign remaining experiment const experimentAssignment = await Promise.all( filteredExperiments.map((experiment) => { From 1d5dc840ece600626e1a04ae38f70b3e9ad6bb8e Mon Sep 17 00:00:00 2001 From: Yagnik Date: Thu, 12 Oct 2023 10:14:54 +0530 Subject: [PATCH 2/3] bug fix to not allow deleting segments which are in use --- .../segments/pages/view-segment/view-segment.component.html | 4 ++-- .../segments/pages/view-segment/view-segment.component.ts | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/projects/upgrade/src/app/features/dashboard/segments/pages/view-segment/view-segment.component.html b/frontend/projects/upgrade/src/app/features/dashboard/segments/pages/view-segment/view-segment.component.html index a2437f2329..3fc2d14384 100644 --- a/frontend/projects/upgrade/src/app/features/dashboard/segments/pages/view-segment/view-segment.component.html +++ b/frontend/projects/upgrade/src/app/features/dashboard/segments/pages/view-segment/view-segment.component.html @@ -29,8 +29,8 @@ mat-flat-button class="ft-14-600 button" (click)="deleteSegment()" - [ngClass]="{ 'button--disabled': permissions && !permissions.segments.delete }" - [disabled]="permissions && !permissions.segments.delete" + [ngClass]="{ 'button--disabled': permissions && !permissions.segments.delete || segmentUsed }" + [disabled]="permissions && !permissions.segments.delete || segmentUsed" > {{ 'global.delete.text' | translate }} diff --git a/frontend/projects/upgrade/src/app/features/dashboard/segments/pages/view-segment/view-segment.component.ts b/frontend/projects/upgrade/src/app/features/dashboard/segments/pages/view-segment/view-segment.component.ts index 8356489a67..e8c547c88b 100644 --- a/frontend/projects/upgrade/src/app/features/dashboard/segments/pages/view-segment/view-segment.component.ts +++ b/frontend/projects/upgrade/src/app/features/dashboard/segments/pages/view-segment/view-segment.component.ts @@ -25,6 +25,7 @@ export class ViewSegmentComponent implements OnInit, OnDestroy { segment: Segment; segmentSub: Subscription; members: { type: string; id: string }[] = []; + segmentUsed: boolean; displayedVariationColumns: string[] = ['value', 'name']; @@ -60,6 +61,8 @@ export class ViewSegmentComponent implements OnInit, OnDestroy { this.members.push({ type: MemberTypes.SEGMENT, id: subSegment.name }); }); }); + + this.segmentUsed = this.segment?.status === SEGMENT_STATUS.USED ? true : false; } openEditSegmentDialog() { From 28ebae265439bf5fa8f2540e9c460d69aec94336 Mon Sep 17 00:00:00 2001 From: Yagnik Date: Thu, 12 Oct 2023 14:38:27 +0530 Subject: [PATCH 3/3] code refactoring --- .../segments/pages/view-segment/view-segment.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/projects/upgrade/src/app/features/dashboard/segments/pages/view-segment/view-segment.component.ts b/frontend/projects/upgrade/src/app/features/dashboard/segments/pages/view-segment/view-segment.component.ts index e8c547c88b..b5c4090533 100644 --- a/frontend/projects/upgrade/src/app/features/dashboard/segments/pages/view-segment/view-segment.component.ts +++ b/frontend/projects/upgrade/src/app/features/dashboard/segments/pages/view-segment/view-segment.component.ts @@ -62,7 +62,7 @@ export class ViewSegmentComponent implements OnInit, OnDestroy { }); }); - this.segmentUsed = this.segment?.status === SEGMENT_STATUS.USED ? true : false; + this.segmentUsed = this.segment?.status === SEGMENT_STATUS.USED; } openEditSegmentDialog() {