diff --git a/frontend/projects/upgrade/src/app/core/segments/store/segments.model.ts b/frontend/projects/upgrade/src/app/core/segments/store/segments.model.ts index 8738e72137..b4738eb92d 100644 --- a/frontend/projects/upgrade/src/app/core/segments/store/segments.model.ts +++ b/frontend/projects/upgrade/src/app/core/segments/store/segments.model.ts @@ -175,6 +175,7 @@ export interface UpsertPrivateSegmentListParams { export interface ImportListParams { listType: FEATURE_FLAG_LIST_FILTER_MODE; flagId: string; + modelType?: MODEL_TYPE; } export enum LIST_OPTION_TYPE { @@ -182,6 +183,11 @@ export enum LIST_OPTION_TYPE { SEGMENT = 'Segment', } +export enum MODEL_TYPE { + LIST = 'List', + FEATURE_FLAG = 'Feature Flag', +} + export const PRIVATE_SEGMENT_LIST_FORM_FIELDS = { LIST_TYPE: 'listType', SEGMENT: 'segment', 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 1b062ccb02..6ad143029f 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 @@ -11,7 +11,7 @@ import { CommonImportContainerComponent } from '../../../../../shared-standalone import { CommonModalConfig } from '../../../../../shared-standalone-component-lib/components/common-modal/common-modal.types'; import { MatTableDataSource } from '@angular/material/table'; import { ValidateFeatureFlagError } from '../../../../../core/feature-flags/store/feature-flags.model'; -import { importError, ImportListParams } from '../../../../../core/segments/store/segments.model'; +import { importError, ImportListParams, MODEL_TYPE } from '../../../../../core/segments/store/segments.model'; import { NotificationService } from '../../../../../core/notifications/notification.service'; import { IFeatureFlagFile } from 'upgrade_types'; import { FeatureFlagsStore } from './feature-flag.signal.store'; @@ -92,9 +92,9 @@ export class ImportFeatureFlagModalComponent { }) ); - if (this.data.title === 'Import Feature Flag') { + if (this.data.params.modelType === MODEL_TYPE.FEATURE_FLAG) { this.featureFlagStore.validateFeatureFlags(this.fileData); - } else if (this.data.title === 'Import List') { + } else if (this.data.params.modelType === MODEL_TYPE.LIST) { this.featureFlagStore.validateFeatureFlagList({ fileData: this.fileData, flagId: this.data.params.flagId, @@ -131,9 +131,9 @@ export class ImportFeatureFlagModalComponent { try { this.isImportActionBtnDisabled.next(true); - if (this.data.title === 'Import Feature Flag') { + if (this.data.params.modelType === MODEL_TYPE.FEATURE_FLAG) { this.featureFlagStore.importFeatureFlags({ files: this.fileData }); - } else if (this.data.title === 'Import List') { + } else if (this.data.params.modelType === MODEL_TYPE.LIST) { this.featureFlagStore.importFeatureFlagList({ fileData: this.fileData, flagId: this.data.params.flagId, diff --git a/frontend/projects/upgrade/src/app/shared/services/common-dialog.service.ts b/frontend/projects/upgrade/src/app/shared/services/common-dialog.service.ts index ef2fbfb47c..a5c678fc62 100644 --- a/frontend/projects/upgrade/src/app/shared/services/common-dialog.service.ts +++ b/frontend/projects/upgrade/src/app/shared/services/common-dialog.service.ts @@ -6,6 +6,7 @@ import { ImportFeatureFlagModalComponent } from '../../features/dashboard/featur import { UpsertFeatureFlagModalComponent } from '../../features/dashboard/feature-flags/modals/upsert-feature-flag-modal/upsert-feature-flag-modal.component'; import { UpsertPrivateSegmentListModalComponent } from '../../features/dashboard/segments/modals/upsert-private-segment-list-modal/upsert-private-segment-list-modal.component'; import { + MODEL_TYPE, UPSERT_PRIVATE_SEGMENT_LIST_ACTION, UpsertPrivateSegmentListParams, } from '../../core/segments/store/segments.model'; @@ -353,18 +354,18 @@ export class DialogService { } openImportFeatureFlagModal() { - return this.openImportModal('Import Feature Flag', null, null); + return this.openImportModal('Import Feature Flag', null, null, MODEL_TYPE.FEATURE_FLAG); } openImportFeatureFlagIncludeListModal(flagId: string) { - return this.openImportModal('Import List', FEATURE_FLAG_LIST_FILTER_MODE.INCLUSION, flagId); + return this.openImportModal('Import List', FEATURE_FLAG_LIST_FILTER_MODE.INCLUSION, flagId, MODEL_TYPE.LIST); } openImportFeatureFlagExcludeListModal(flagId: string) { - return this.openImportModal('Import List', FEATURE_FLAG_LIST_FILTER_MODE.EXCLUSION, flagId); + return this.openImportModal('Import List', FEATURE_FLAG_LIST_FILTER_MODE.EXCLUSION, flagId, MODEL_TYPE.LIST); } - openImportModal(title: string, listType: FEATURE_FLAG_LIST_FILTER_MODE, flagId: string) { + openImportModal(title: string, listType: FEATURE_FLAG_LIST_FILTER_MODE, flagId: string, modelType?: MODEL_TYPE) { const commonModalConfig: CommonModalConfig = { title: title, primaryActionBtnLabel: 'Import', @@ -373,6 +374,7 @@ export class DialogService { params: { listType: listType, flagId: flagId, + modelType: modelType, }, };