Skip to content

Commit

Permalink
Add modelType to ImportListParams and update modal logic for feature …
Browse files Browse the repository at this point in the history
…flag imports
  • Loading branch information
RidhamShah committed Nov 26, 2024
1 parent 43d2e67 commit bfbdb03
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,19 @@ export interface UpsertPrivateSegmentListParams {
export interface ImportListParams {
listType: FEATURE_FLAG_LIST_FILTER_MODE;
flagId: string;
modelType?: MODEL_TYPE;
}

export enum LIST_OPTION_TYPE {
INDIVIDUAL = 'Individual',
SEGMENT = 'Segment',
}

export enum MODEL_TYPE {
LIST = 'List',
FEATURE_FLAG = 'Feature Flag',
}

export const PRIVATE_SEGMENT_LIST_FORM_FIELDS = {
LIST_TYPE: 'listType',
SEGMENT: 'segment',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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',
Expand All @@ -373,6 +374,7 @@ export class DialogService {
params: {
listType: listType,
flagId: flagId,
modelType: modelType,
},
};

Expand Down

0 comments on commit bfbdb03

Please sign in to comment.