Skip to content

Commit

Permalink
Merge branch 'dev' into enhancement/exposures-tab-header-and-content-…
Browse files Browse the repository at this point in the history
…comp
  • Loading branch information
danoswaltCL authored Jun 27, 2024
2 parents 2cf954e + 85fb2da commit ee8e4c0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ export class FeatureFlagsService {
map((exclusions) => exclusions.length)
);

convertNameStringToKey(name:string):string {
let upperCaseString = name.trim().toUpperCase();
let key = upperCaseString.replace(/ /g, '_');
return key;
}

fetchFeatureFlags(fromStarting?: boolean) {
this.store$.dispatch(FeatureFlagsActions.actionFetchFeatureFlags({ fromStarting }));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export class AddFeatureFlagModalComponent {
this.experimentService.fetchContextMetaData();
this.buildForm();
this.listenForFeatureFlagListLengthChanges();
this.listenOnNameChangesToUpdateKey();
}

buildForm(): void {
Expand All @@ -94,6 +95,15 @@ export class AddFeatureFlagModalComponent {
this.subscriptions = this.featureFlagsListLengthChange$.subscribe(() => this.closeModal());
}

listenOnNameChangesToUpdateKey(): void {
this.featureFlagForm.get('name')?.valueChanges.subscribe((name) => {
const keyControl = this.featureFlagForm.get('key');
if (keyControl && !keyControl.dirty) {
keyControl.setValue(this.featureFlagsService.convertNameStringToKey(name));
}
});
}

onPrimaryActionBtnClicked(): void {
if (this.featureFlagForm.valid) {
// Handle extra form validation logic here?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export class EditFeatureFlagModalComponent {
this.buildForm();
this.initializeFormValues();
this.listenForFeatureFlagGetUpdated();
this.listenOnNameChangesToUpdateKey();
}

buildForm(): void {
Expand Down Expand Up @@ -109,6 +110,15 @@ export class EditFeatureFlagModalComponent {
);
}

listenOnNameChangesToUpdateKey(): void {
this.featureFlagForm.get('name')?.valueChanges.subscribe((name) => {
const keyControl = this.featureFlagForm.get('key');
if (keyControl && !keyControl.dirty) {
keyControl.setValue(this.featureFlagsService.convertNameStringToKey(name));
}
});
}

// Close the modal once the feature flag list length changes, as that indicates actual success
listenForFeatureFlagGetUpdated(): void {
this.subscriptions = this.isSelectedFeatureFlagUpdated$.subscribe(() => this.closeModal());
Expand Down

0 comments on commit ee8e4c0

Please sign in to comment.