Skip to content

Commit 5bec122

Browse files
committed
Hiding these checks behind the feature flag
1 parent e2310d9 commit 5bec122

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

src/SIL.XForge.Scripture/ClientApp/src/app/translate/editor/editor.component.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4903,6 +4903,7 @@ class TestEnvironment {
49034903
when(mockedDraftGenerationService.draftExists(anything(), anything(), anything())).thenReturn(of(true));
49044904
when(mockedPermissionsService.isUserOnProject(anything())).thenResolve(true);
49054905
when(mockedFeatureFlagService.newDraftHistory).thenReturn(createTestFeatureFlag(false));
4906+
when(mockedFeatureFlagService.usfmFormat).thenReturn(createTestFeatureFlag(true));
49064907
when(mockedLynxWorkspaceService.rawInsightSource$).thenReturn(of([]));
49074908

49084909
this.realtimeService = TestBed.inject(TestRealtimeService);

src/SIL.XForge.Scripture/ClientApp/src/app/translate/editor/editor.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ import { CONSOLE, ConsoleInterface } from 'xforge-common/browser-globals';
8585
import { DataLoadingComponent } from 'xforge-common/data-loading-component';
8686
import { DialogService } from 'xforge-common/dialog.service';
8787
import { ErrorReportingService } from 'xforge-common/error-reporting.service';
88+
import { FeatureFlagService } from 'xforge-common/feature-flags/feature-flag.service';
8889
import { FontService } from 'xforge-common/font.service';
8990
import { I18nService } from 'xforge-common/i18n.service';
9091
import { Breakpoint, MediaBreakpointService } from 'xforge-common/media-breakpoints/media-breakpoint.service';
@@ -317,7 +318,8 @@ export class EditorComponent extends DataLoadingComponent implements OnDestroy,
317318
private readonly breakpointObserver: BreakpointObserver,
318319
private readonly mediaBreakpointService: MediaBreakpointService,
319320
private readonly permissionsService: PermissionsService,
320-
readonly editorInsightState: LynxInsightStateService
321+
readonly editorInsightState: LynxInsightStateService,
322+
private readonly featureFlagService: FeatureFlagService
321323
) {
322324
super(noticeService);
323325
const wordTokenizer = new LatinWordTokenizer();
@@ -1489,6 +1491,7 @@ export class EditorComponent extends DataLoadingComponent implements OnDestroy,
14891491
this.userService.currentUserId
14901492
);
14911493
const hasSetDraftFormatting =
1494+
!this.featureFlagService.usfmFormat.enabled ||
14921495
this.activatedProject.projectDoc?.data?.translateConfig.draftConfig.usfmConfig != null;
14931496
if (((hasDraft && !draftApplied) || urlDraftActive) && canViewDrafts && hasSetDraftFormatting) {
14941497
// URL may indicate to select the 'draft' tab (such as when coming from generate draft page)

src/SIL.XForge.Scripture/ClientApp/src/app/translate/editor/tabs/editor-tab-menu.service.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { of, take } from 'rxjs';
66
import { anything, mock, when } from 'ts-mockito';
77
import { v4 as uuid } from 'uuid';
88
import { ActivatedProjectService } from 'xforge-common/activated-project.service';
9+
import { createTestFeatureFlag, FeatureFlagService } from 'xforge-common/feature-flags/feature-flag.service';
910
import { OnlineStatusService } from 'xforge-common/online-status.service';
1011
import { TestOnlineStatusModule } from 'xforge-common/test-online-status.module';
1112
import { TestOnlineStatusService } from 'xforge-common/test-online-status.service';
@@ -24,6 +25,7 @@ const activatedProjectMock = mock(ActivatedProjectService);
2425
const tabStateMock: TabStateService<any, any> = mock(TabStateService);
2526
const mockUserService = mock(UserService);
2627
const mockPermissionsService = mock(PermissionsService);
28+
const mockFeatureFlagService = mock(FeatureFlagService);
2729

2830
describe('EditorTabMenuService', () => {
2931
configureTestingModule(() => ({
@@ -34,7 +36,8 @@ describe('EditorTabMenuService', () => {
3436
{ provide: TabStateService, useMock: tabStateMock },
3537
{ provide: UserService, useMock: mockUserService },
3638
{ provide: PermissionsService, useMock: mockPermissionsService },
37-
{ provide: OnlineStatusService, useClass: TestOnlineStatusService }
39+
{ provide: OnlineStatusService, useClass: TestOnlineStatusService },
40+
{ provide: FeatureFlagService, useMock: mockFeatureFlagService }
3841
]
3942
}));
4043

@@ -320,6 +323,7 @@ class TestEnvironment {
320323
when(activatedProjectMock.projectDoc).thenReturn(projectDoc as any);
321324
when(mockUserService.currentUserId).thenReturn('user01');
322325
when(mockPermissionsService.canAccessDrafts(anything(), anything())).thenReturn(true);
326+
when(mockFeatureFlagService.usfmFormat).thenReturn(createTestFeatureFlag(true));
323327
service = TestBed.inject(EditorTabMenuService);
324328
}
325329

src/SIL.XForge.Scripture/ClientApp/src/app/translate/editor/tabs/editor-tab-menu.service.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { isParatextRole } from 'realtime-server/lib/esm/scriptureforge/models/sf
88
import { combineLatest, map, Observable, of } from 'rxjs';
99
import { shareReplay, switchMap } from 'rxjs/operators';
1010
import { ActivatedProjectService } from 'xforge-common/activated-project.service';
11+
import { FeatureFlagService } from 'xforge-common/feature-flags/feature-flag.service';
1112
import { I18nService } from 'xforge-common/i18n.service';
1213
import { OnlineStatusService } from 'xforge-common/online-status.service';
1314
import { UserService } from 'xforge-common/user.service';
@@ -29,7 +30,8 @@ export class EditorTabMenuService implements TabMenuService<EditorTabGroupType>
2930
private readonly onlineStatus: OnlineStatusService,
3031
private readonly tabState: TabStateService<EditorTabGroupType, EditorTabInfo>,
3132
private readonly permissionsService: PermissionsService,
32-
private readonly i18n: I18nService
33+
private readonly i18n: I18nService,
34+
private readonly featureFlagService: FeatureFlagService
3335
) {}
3436

3537
getMenuItems(): Observable<TabMenuItem[]> {
@@ -47,12 +49,15 @@ export class EditorTabMenuService implements TabMenuService<EditorTabGroupType>
4749
return combineLatest([of(projectDoc), of(isOnline), this.tabState.tabs$]);
4850
}),
4951
switchMap(([projectDoc, isOnline, existingTabs]) => {
52+
const hasSetDraftFormatting =
53+
!this.featureFlagService.usfmFormat.enabled ||
54+
this.activatedProject.projectDoc?.data?.translateConfig.draftConfig.usfmConfig != null;
5055
const showDraft =
5156
isOnline &&
5257
projectDoc.data != null &&
5358
SFProjectService.hasDraft(projectDoc.data) &&
5459
this.permissionsService.canAccessDrafts(projectDoc, this.userService.currentUserId) &&
55-
this.activatedProject.projectDoc?.data?.translateConfig.draftConfig.usfmConfig != null;
60+
hasSetDraftFormatting;
5661
const items: Observable<TabMenuItem>[] = [];
5762

5863
for (const tabType of editorTabTypes) {

0 commit comments

Comments
 (0)