+
insert_drive_file
{{ fileName }}
diff --git a/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/modals/import-feature-flag-modal/import-feature-flag-modal.component.scss b/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/modals/import-feature-flag-modal/import-feature-flag-modal.component.scss
index 2a7dbce664..8ee757f43a 100644
--- a/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/modals/import-feature-flag-modal/import-feature-flag-modal.component.scss
+++ b/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/modals/import-feature-flag-modal/import-feature-flag-modal.component.scss
@@ -30,6 +30,7 @@
font-size: 14px;
}
}
+
.input-container-header {
position: absolute;
top: 5px;
@@ -41,6 +42,14 @@
font-size: 24px;
}
}
+
+.input-container-content {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+}
+
p {
color: grey;
font-size: 12px;
diff --git a/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/pages/feature-flag-root-page/feature-flag-root-page-content/feature-flag-root-section-card/feature-flag-root-section-card.component.html b/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/pages/feature-flag-root-page/feature-flag-root-page-content/feature-flag-root-section-card/feature-flag-root-section-card.component.html
index c7c574f264..36dc297154 100644
--- a/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/pages/feature-flag-root-page/feature-flag-root-page-content/feature-flag-root-section-card/feature-flag-root-section-card.component.html
+++ b/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/pages/feature-flag-root-page/feature-flag-root-page-content/feature-flag-root-section-card/feature-flag-root-section-card.component.html
@@ -14,6 +14,7 @@
[showPrimaryButton]="true"
[primaryButtonText]="'feature-flags.add-feature-flag.text' | translate"
[menuButtonItems]="menuButtonItems"
+ [showMenuButton]="true"
[isSectionCardExpanded]="isSectionCardExpanded"
(primaryButtonClick)="onAddFeatureFlagButtonClick()"
(menuButtonItemClick)="onMenuButtonItemClick($event)"
diff --git a/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/pages/feature-flag-root-page/feature-flag-root-page-content/feature-flag-root-section-card/feature-flag-root-section-card.component.ts b/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/pages/feature-flag-root-page/feature-flag-root-page-content/feature-flag-root-section-card/feature-flag-root-section-card.component.ts
index e8525b1306..ae07c422d8 100644
--- a/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/pages/feature-flag-root-page/feature-flag-root-page-content/feature-flag-root-section-card/feature-flag-root-section-card.component.ts
+++ b/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/pages/feature-flag-root-page/feature-flag-root-page-content/feature-flag-root-section-card/feature-flag-root-section-card.component.ts
@@ -98,7 +98,11 @@ export class FeatureFlagRootSectionCardComponent {
}
onMenuButtonItemClick(menuButtonItemName: string) {
- console.log('onMenuButtonItemClick:', menuButtonItemName);
+ if (menuButtonItemName === 'Import Feature Flag') {
+ this.dialogService.openImportFeatureFlagModal();
+ } else if (menuButtonItemName === 'Export All Feature Flags') {
+ console.log('onMenuButtonItemClick:', menuButtonItemName);
+ }
}
onSectionCardExpandChange(isSectionCardExpanded: boolean) {
From 5b000680fbed7f4c013162c27008ee8c3d8ee458 Mon Sep 17 00:00:00 2001
From: Khanjan Dalwadi <17khanjan@gmail.com>
Date: Mon, 1 Jul 2024 11:34:30 +0530
Subject: [PATCH 3/3] Made state variables as BehaviorSubjects and removed
duplicate code
---
.../import-feature-flag-modal.component.html | 8 +--
.../import-feature-flag-modal.component.ts | 61 ++++++++-----------
.../projects/upgrade/src/assets/i18n/en.json | 1 +
3 files changed, 32 insertions(+), 38 deletions(-)
diff --git a/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/modals/import-feature-flag-modal/import-feature-flag-modal.component.html b/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/modals/import-feature-flag-modal/import-feature-flag-modal.component.html
index 6e313786a3..259e49ebe8 100644
--- a/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/modals/import-feature-flag-modal/import-feature-flag-modal.component.html
+++ b/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/modals/import-feature-flag-modal/import-feature-flag-modal.component.html
@@ -4,7 +4,7 @@
[cancelBtnLabel]="data.cancelBtnLabel"
[primaryActionBtnLabel]="data.primaryActionBtnLabel"
[primaryActionBtnColor]="data.primaryActionBtnColor"
- [primaryActionBtnDisabled$]="isImportActionBtnDisabled"
+ [primaryActionBtnDisabled]="isImportActionBtnDisabled | async"
>
-
+
insert_drive_file
{{ fileName }}
@@ -31,7 +31,7 @@
- The Feature Flag JSON file should include the required properties for it to be imported.
+ {{ 'feature-flags.import-feature-flag.message.text' | translate }}
Learn More
diff --git a/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/modals/import-feature-flag-modal/import-feature-flag-modal.component.ts b/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/modals/import-feature-flag-modal/import-feature-flag-modal.component.ts
index 0d2d2395cb..e9cb49b01a 100644
--- a/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/modals/import-feature-flag-modal/import-feature-flag-modal.component.ts
+++ b/frontend/projects/upgrade/src/app/features/dashboard/feature-flags/modals/import-feature-flag-modal/import-feature-flag-modal.component.ts
@@ -3,7 +3,7 @@ import { CommonModalComponent } from '../../../../../shared-standalone-component
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog';
import { CommonModalConfig } from '../../../../../shared-standalone-component-lib/components/common-modal/common-modal-config';
import { FeatureFlagsService } from '../../../../../core/feature-flags/feature-flags.service';
-import { BehaviorSubject, Observable, Subscription, combineLatest, map } from 'rxjs';
+import { BehaviorSubject } from 'rxjs';
import { CommonModule } from '@angular/common';
import { SharedModule } from '../../../../../shared/shared.module';
@@ -12,73 +12,66 @@ import { SharedModule } from '../../../../../shared/shared.module';
standalone: true,
imports: [CommonModalComponent, CommonModule, SharedModule],
templateUrl: './import-feature-flag-modal.component.html',
- styleUrl: './import-feature-flag-modal.component.scss',
+ styleUrls: ['./import-feature-flag-modal.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ImportFeatureFlagModalComponent {
@ViewChild('fileInput') fileInput: ElementRef
;
isImportActionBtnDisabled = new BehaviorSubject(true);
- isDragOver = false;
- fileName: string | null = null;
+ isDragOver = new BehaviorSubject(false);
+ fileName = new BehaviorSubject(null);
constructor(
@Inject(MAT_DIALOG_DATA)
- public data: CommonModalConfig & { flagName: string; flagId: string },
+ public data: CommonModalConfig,
public dialog: MatDialog,
- private featureFlagsService: FeatureFlagsService,
public dialogRef: MatDialogRef
) {}
- onDragOver(event: DragEvent): void {
+ onDragOver(event: DragEvent) {
event.preventDefault();
event.stopPropagation();
- this.isDragOver = true;
+ this.isDragOver.next(true);
}
- onDragLeave(event: DragEvent): void {
+ onDragLeave(event: DragEvent) {
event.preventDefault();
event.stopPropagation();
- this.isDragOver = false;
+ this.isDragOver.next(false);
}
- onDrop(event: DragEvent): void {
+ onDrop(event: DragEvent) {
event.preventDefault();
event.stopPropagation();
- this.isDragOver = false;
+ this.isDragOver.next(false);
const files = event.dataTransfer?.files;
if (files && files.length > 0) {
- const file = files[0];
- if (file.type === 'application/json') {
- this.fileName = file.name;
- this.isImportActionBtnDisabled.next(false);
- this.handleFileInput(file);
- } else {
- alert('Please upload a valid JSON file.');
- this.fileName = null;
- this.isImportActionBtnDisabled.next(true);
- }
+ this.processFile(files[0]);
}
}
- onFileSelected(event: Event): void {
+ onFileSelected(event: Event) {
const input = event.target as HTMLInputElement;
if (input.files && input.files.length > 0) {
- const file = input.files[0];
- if (file.type === 'application/json') {
- this.fileName = file.name;
- this.isImportActionBtnDisabled.next(false);
- this.handleFileInput(file);
- } else {
- alert('Please upload a valid JSON file.');
- this.fileName = null;
- this.isImportActionBtnDisabled.next(true);
- }
+ this.processFile(input.files[0]);
}
}
- handleFileInput(file: File): void {
+ processFile(file: File) {
+ if (file.type === 'application/json') {
+ this.fileName.next(file.name);
+ this.isImportActionBtnDisabled.next(false);
+ this.handleFileInput(file);
+ } else {
+ alert('Please upload a valid JSON file.');
+ this.fileName.next(null);
+ this.isImportActionBtnDisabled.next(true);
+ }
+ }
+
+ handleFileInput(file: File) {
const reader = new FileReader();
reader.onload = (e: any) => {
const jsonContent = e.target.result;
diff --git a/frontend/projects/upgrade/src/assets/i18n/en.json b/frontend/projects/upgrade/src/assets/i18n/en.json
index c646543e96..7c1bde17b1 100644
--- a/frontend/projects/upgrade/src/assets/i18n/en.json
+++ b/frontend/projects/upgrade/src/assets/i18n/en.json
@@ -388,6 +388,7 @@
"feature-flags.enable.text": "Enable",
"feature-flags.add-feature-flag.text": "Add Feature Flag",
"feature-flags.import-feature-flag.text": "Import Feature Flag",
+ "feature-flags.import-feature-flag.message.text": "The Feature Flag JSON file should include the required properties for it to be imported",
"feature-flags.export-all-feature-flags.text": "Export All Feature Flags",
"segments.title.text": "Segments",
"segments.subtitle.text": "Define new segments to include or exclude from any experiment",