Skip to content

Commit 8892fd9

Browse files
committed
add export segment all list design modal
1 parent f1ba973 commit 8892fd9

5 files changed

Lines changed: 33 additions & 5 deletions

File tree

frontend/projects/upgrade/src/app/features/dashboard/segments/pages/segment-details-page/segment-details-page-content/segment-lists-section-card/segment-lists-section-card.component.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,25 @@ export class SegmentListsSectionCardComponent {
7070
console.log('Import List');
7171
break;
7272
case SEGMENT_LIST_ACTIONS.EXPORT_ALL:
73-
console.log('Export All Lists');
73+
this.handleExportAllLists(segment);
7474
break;
7575
default:
7676
console.log('Unknown action');
7777
}
7878
}
7979

80+
handleExportAllLists(segment: Segment) {
81+
this.dialogService
82+
.openExportSegmentListsDesignModal()
83+
.afterClosed()
84+
.subscribe((isExportClicked: boolean) => {
85+
if (isExportClicked) {
86+
const subsegmentIds = segment.subSegments.map((subSegment) => subSegment.id);
87+
this.segmentsService.exportSegments(subsegmentIds);
88+
}
89+
});
90+
}
91+
8092
onSectionCardExpandChange(isSectionCardExpanded: boolean) {
8193
this.isSectionCardExpanded = isSectionCardExpanded;
8294
}

frontend/projects/upgrade/src/app/shared-standalone-component-lib/components/common-modal/common-modal.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<mat-card class="common-modal">
22
<!-- top part of the dialog -->
33
<header class="header-container dense-2">
4-
<h4 class="ft-22-700 header-title">{{ title }}</h4>
4+
<h4 class="ft-22-700 header-title">{{ title | translate }}</h4>
55
<button mat-icon-button mat-dialog-close class="close-btn">
66
<mat-icon>close</mat-icon>
77
</button>
@@ -14,7 +14,7 @@ <h4 class="ft-22-700 header-title">{{ title }}</h4>
1414
<!-- bottom part of the dialog -->
1515
<section *ngIf="!hideFooter" class="footer-container">
1616
<button mat-flat-button mat-dialog-close class="dialog-action-btn cancel-btn">
17-
{{ cancelBtnLabel }}
17+
{{ cancelBtnLabel | translate }}
1818
</button>
1919
<button
2020
class="dialog-action-btn"
@@ -23,7 +23,7 @@ <h4 class="ft-22-700 header-title">{{ title }}</h4>
2323
[disabled]="primaryActionBtnDisabled"
2424
(click)="onPrimaryActionBtnClicked()"
2525
>
26-
{{ primaryActionBtnLabel }}
26+
{{ primaryActionBtnLabel | translate }}
2727
</button>
2828
</section>
2929
</mat-card>

frontend/projects/upgrade/src/app/shared-standalone-component-lib/components/common-modal/common-modal.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { MatButtonModule } from '@angular/material/button';
77
import { MatDialogClose } from '@angular/material/dialog';
88
import { CommonModule } from '@angular/common';
99
import { MatIcon } from '@angular/material/icon';
10+
import { TranslateModule } from '@ngx-translate/core';
1011

1112
@Component({
1213
selector: 'app-common-dialog',
@@ -19,6 +20,7 @@ import { MatIcon } from '@angular/material/icon';
1920
MatDialogClose,
2021
CommonModule,
2122
MatIcon,
23+
TranslateModule,
2224
],
2325
templateUrl: './common-modal.component.html',
2426
styleUrl: './common-modal.component.scss',

frontend/projects/upgrade/src/app/shared/services/common-dialog.service.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ export class DialogService {
340340
return this.dialog.open(DeleteFeatureFlagModalComponent, config);
341341
}
342342

343-
openExportDesignModal(title, warning: string): MatDialogRef<CommonSimpleConfirmationModalComponent, boolean> {
343+
openExportDesignModal(title: string, warning: string): MatDialogRef<CommonSimpleConfirmationModalComponent, boolean> {
344344
const commonModalConfig: CommonModalConfig = {
345345
title: title,
346346
primaryActionBtnLabel: 'Export',
@@ -353,6 +353,18 @@ export class DialogService {
353353
return this.openSimpleCommonConfirmationModal(commonModalConfig, ModalSize.MEDIUM);
354354
}
355355

356+
openExportSegmentListsDesignModal(): MatDialogRef<CommonSimpleConfirmationModalComponent, boolean> {
357+
const commonModalConfig: CommonModalConfig = {
358+
title: 'segments.export-feature-flag-design.confirmation-title.text',
359+
primaryActionBtnLabel: 'Export',
360+
primaryActionBtnColor: 'primary',
361+
cancelBtnLabel: 'Cancel',
362+
params: {
363+
message: 'segments.export-feature-flag-design.confirmation-message.text',
364+
},
365+
};
366+
return this.openSimpleCommonConfirmationModal(commonModalConfig, ModalSize.MEDIUM);
367+
}
356368
openEmailFeatureFlagDataModal(
357369
warning: string,
358370
subtext: string

frontend/projects/upgrade/src/assets/i18n/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,8 @@
501501
"segments.new-segment-overview-stepper.segment-name-error.text": "Segment name already exists for selected context. Please enter a unique segment name",
502502
"segments.view-segment.members-subtitle.text": "Member(s)",
503503
"segments.global-members.segments-count-members-error.text": "Please have at least 1 valid member to move forward",
504+
"segments.export-feature-flag-design.confirmation-title.text": "Segment List Export All",
505+
"segments.export-feature-flag-design.confirmation-message.text": "Are you sure you want to export all lists (JSON)?",
504506
"segments.import-segment.text": "IMPORT SEGMENT",
505507
"segments.import-segment.message.text": "Select the JSON file(s) to import segments:",
506508
"segments.import-segment-modal.title.text": "Import Segment",

0 commit comments

Comments
 (0)