Skip to content

Commit 8fef2db

Browse files
authored
add export segment all list design modal (#2351)
* add export segment all list design modal * remove .env-test * kick-cicd
1 parent 48e3742 commit 8fef2db

5 files changed

Lines changed: 41 additions & 6 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: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
Segment,
1515
SEGMENT_LIST_ACTIONS,
1616
} from '../../../../../../../core/segments/store/segments.model';
17-
import { Observable } from 'rxjs';
17+
import { Observable, Subscription } from 'rxjs';
1818
import { AuthService } from '../../../../../../../core/auth/auth.service';
1919
import { UserPermission } from '../../../../../../../core/auth/store/auth.models';
2020
import {
@@ -43,6 +43,7 @@ export class SegmentListsSectionCardComponent {
4343
permissions$: Observable<UserPermission>;
4444
tableRowCount$ = this.segmentsService.selectSegmentListsLength$;
4545
selectedSegment$ = this.segmentsService.selectedSegment$;
46+
subscriptions = new Subscription();
4647

4748
menuButtonItems: IMenuButtonItem[] = [
4849
{
@@ -77,13 +78,27 @@ export class SegmentListsSectionCardComponent {
7778
console.log('Import List');
7879
break;
7980
case SEGMENT_LIST_ACTIONS.EXPORT_ALL:
80-
console.log('Export All Lists');
81+
this.handleExportAllLists(segment);
8182
break;
8283
default:
8384
console.log('Unknown action');
8485
}
8586
}
8687

88+
handleExportAllLists(segment: Segment) {
89+
this.subscriptions.add(
90+
this.dialogService
91+
.openExportSegmentListsDesignModal()
92+
.afterClosed()
93+
.subscribe((isExportClicked: boolean) => {
94+
if (isExportClicked) {
95+
const subsegmentIds = segment.subSegments.map((subSegment) => subSegment.id);
96+
this.segmentsService.exportSegments(subsegmentIds);
97+
}
98+
})
99+
);
100+
}
101+
87102
onSectionCardExpandChange(isSectionCardExpanded: boolean) {
88103
this.isSectionCardExpanded = isSectionCardExpanded;
89104
}
@@ -113,4 +128,8 @@ export class SegmentListsSectionCardComponent {
113128
}
114129
});
115130
}
131+
132+
onDestroy() {
133+
this.subscriptions.unsubscribe();
134+
}
116135
}

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
@@ -378,7 +378,7 @@ export class DialogService {
378378
return this.dialog.open(DeleteFeatureFlagModalComponent, config);
379379
}
380380

381-
openExportDesignModal(title, warning: string): MatDialogRef<CommonSimpleConfirmationModalComponent, boolean> {
381+
openExportDesignModal(title: string, warning: string): MatDialogRef<CommonSimpleConfirmationModalComponent, boolean> {
382382
const commonModalConfig: CommonModalConfig = {
383383
title: title,
384384
primaryActionBtnLabel: 'Export',
@@ -391,6 +391,18 @@ export class DialogService {
391391
return this.openSimpleCommonConfirmationModal(commonModalConfig, ModalSize.MEDIUM);
392392
}
393393

394+
openExportSegmentListsDesignModal(): MatDialogRef<CommonSimpleConfirmationModalComponent, boolean> {
395+
const commonModalConfig: CommonModalConfig = {
396+
title: 'segments.export-feature-flag-design.confirmation-title.text',
397+
primaryActionBtnLabel: 'Export',
398+
primaryActionBtnColor: 'primary',
399+
cancelBtnLabel: 'Cancel',
400+
params: {
401+
message: 'segments.export-feature-flag-design.confirmation-message.text',
402+
},
403+
};
404+
return this.openSimpleCommonConfirmationModal(commonModalConfig, ModalSize.MEDIUM);
405+
}
394406
openEmailFeatureFlagDataModal(
395407
warning: string,
396408
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)