Skip to content

Commit

Permalink
Enable dev options as soon as version number is repeatedly clicked (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Nateowami authored Oct 6, 2024
1 parent f8f8f25 commit b259f2c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion scripts/db_tools/parse-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ParseVersion {

// This array is ordered based on the bit position of the feature flag
featureFlags: string[] = [
'Show feature flags',
'Show developer tools',
'Show non-published localizations',
'Show NMT drafting',
'Allow Forward Translation NMT drafting',
Expand Down
9 changes: 2 additions & 7 deletions src/SIL.XForge.Scripture/ClientApp/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,14 @@
<a mat-menu-item target="_blank" href="/3rdpartylicenses.txt">
<mat-icon>copyright</mat-icon> {{ t("open_source_licenses") }}
</a>
@if (versionNumberClickCount >= 7 || featureFlags.showFeatureFlags.enabled) {
@if (featureFlags.showDeveloperTools.enabled) {
<button mat-menu-item (click)="openFeatureFlagDialog()">
<mat-icon>science</mat-icon>
Developer settings
</button>
}
<mat-divider></mat-divider>
<div
mat-menu-item
disabled="true"
(click)="versionNumberClickCount = versionNumberClickCount + 1"
id="version-number"
>
<div mat-menu-item disabled="true" (click)="versionNumberClicked()" id="version-number">
{{ t("product_version", { version: version + this.featureFlags.versionSuffix }) }}
</div>
</mat-menu>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ class TestEnvironment {
}
when(mockedFeatureFlagService.showNmtDrafting).thenReturn(createTestFeatureFlag(false));
when(mockedFeatureFlagService.allowForwardTranslationNmtDrafting).thenReturn(createTestFeatureFlag(false));
when(mockedFeatureFlagService.showFeatureFlags).thenReturn(createTestFeatureFlag(false));
when(mockedFeatureFlagService.showDeveloperTools).thenReturn(createTestFeatureFlag(false));
when(mockedFeatureFlagService.stillness).thenReturn(createTestFeatureFlag(false));
when(mockedFeatureFlagService.showNonPublishedLocalizations).thenReturn(createTestFeatureFlag(false));
when(mockedFileService.notifyUserIfStorageQuotaBelow(anything())).thenResolve();
Expand Down
7 changes: 7 additions & 0 deletions src/SIL.XForge.Scripture/ClientApp/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,13 @@ export class AppComponent extends DataLoadingComponent implements OnInit, OnDest
this.dialogService.openMatDialog(FeatureFlagsDialogComponent);
}

versionNumberClicked(): void {
this.versionNumberClickCount++;
if (this.versionNumberClickCount >= 7) {
this.featureFlags.showDeveloperTools.enabled = true;
}
}

private async showProjectDeletedDialog(): Promise<void> {
await this.userService.setCurrentProjectId(this.currentUserDoc!, undefined);
await this.dialogService.message('app.project_has_been_deleted');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ export class FeatureFlagService {
// Also, the position is important - this is the bit wise position of the feature flag in the version.
// The position in the dialog is determined by the order in this class.

readonly showFeatureFlags: ObservableFeatureFlag = new FeatureFlagFromStorage(
'SHOW_FEATURE_FLAGS',
'Show feature flags',
readonly showDeveloperTools: ObservableFeatureFlag = new FeatureFlagFromStorage(
'SHOW_DEVELOPER_TOOLS',
'Show developer tools',
0,
this.featureFlagStore
);
Expand Down

0 comments on commit b259f2c

Please sign in to comment.