Skip to content

Commit e69ee81

Browse files
RaymondLuong3Nateowami
authored andcommitted
Code review fixes
1 parent 6b6efef commit e69ee81

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-history-list/draft-history-entry/draft-history-entry.component.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { SFProjectService } from '../../../../core/sf-project.service';
2222
import { BuildDto } from '../../../../machine-api/build-dto';
2323
import { BuildStates } from '../../../../machine-api/build-states';
2424
import { DraftGenerationService } from '../../draft-generation.service';
25+
import { FORMATTING_OPTIONS_SUPPORTED_DATE } from '../../draft-utils';
2526
import { TrainingDataService } from '../../training-data/training-data.service';
2627
import { DraftHistoryEntryComponent } from './draft-history-entry.component';
2728

@@ -33,8 +34,9 @@ const mockedTrainingDataService = mock(TrainingDataService);
3334
const mockedActivatedProjectService = mock(ActivatedProjectService);
3435
const mockedFeatureFlagsService = mock(FeatureFlagService);
3536

36-
const dateBeforeFormattingSupported = '2025-09-01T12:00:00.000Z';
37-
const dateAfterFormattingSupported = '2025-10-01T12:00:00.000Z';
37+
const oneDay = 1000 * 60 * 60 * 24;
38+
const dateBeforeFormattingSupported = new Date(FORMATTING_OPTIONS_SUPPORTED_DATE.getTime() - oneDay).toISOString();
39+
const dateAfterFormattingSupported = new Date(FORMATTING_OPTIONS_SUPPORTED_DATE.getTime() + oneDay).toISOString();
3840

3941
describe('DraftHistoryEntryComponent', () => {
4042
let component: DraftHistoryEntryComponent;
@@ -410,7 +412,7 @@ describe('DraftHistoryEntryComponent', () => {
410412
expect(fixture.nativeElement.querySelector('.require-formatting-options')).toBeNull();
411413
}));
412414

413-
it('should not show the USFM format option for drafts before the supported date', fakeAsync(() => {
415+
it('should not show the USFM format option for drafts created before the supported date', fakeAsync(() => {
414416
const user = 'user-display-name';
415417
const date = dateBeforeFormattingSupported;
416418
const trainingBooks = ['EXO'];

src/SIL.XForge.Scripture/ClientApp/src/app/translate/editor/editor-draft/editor-draft.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@
5252
</button>
5353
} @else if (formattingOptionsSupported) {
5454
<span
55-
[matTooltip]="t(doesLatestHaveDraft ? 'format_draft_can' : 'format_draft_cannot')"
56-
[style.cursor]="doesLatestHaveDraft ? 'pointer' : 'not-allowed'"
55+
[matTooltip]="t(doesLatestBuildHaveDraft ? 'format_draft_can' : 'format_draft_cannot')"
56+
[style.cursor]="doesLatestBuildHaveDraft ? 'pointer' : 'not-allowed'"
5757
>
58-
<button mat-button (click)="navigateToFormatting()" [disabled]="!doesLatestHaveDraft">
58+
<button mat-button (click)="navigateToFormatting()" [disabled]="!doesLatestBuildHaveDraft">
5959
<mat-icon>build</mat-icon>
6060
<transloco class="hide-lt-md" key="editor_draft_tab.format_draft"></transloco>
6161
<transloco class="hide-gt-md" key="editor_draft_tab.formatting"></transloco>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ describe('EditorDraftComponent', () => {
426426
flush();
427427
}));
428428

429-
it('should hide formatting options of drafts before supported date', fakeAsync(() => {
429+
it('should hide formatting options for drafts created before supported date', fakeAsync(() => {
430430
const testProjectDoc: SFProjectProfileDoc = {
431431
data: createTestProjectProfile({
432432
texts: [

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export class EditorDraftComponent implements AfterViewInit, OnChanges {
115115
return this.draftHandlingService.canApplyDraft(this.targetProject, this.bookNum, this.chapter, this.draftDelta.ops);
116116
}
117117

118-
get doesLatestHaveDraft(): boolean {
118+
get doesLatestBuildHaveDraft(): boolean {
119119
return (
120120
this.targetProject?.texts.find(t => t.bookNum === this.bookNum)?.chapters.find(c => c.number === this.chapter)
121121
?.hasDraft ?? false
@@ -127,14 +127,13 @@ export class EditorDraftComponent implements AfterViewInit, OnChanges {
127127
this.featureFlags.usfmFormat.enabled &&
128128
!this.hasFormattingSelected &&
129129
this.formattingOptionsSupported &&
130-
this.doesLatestHaveDraft
130+
this.doesLatestBuildHaveDraft
131131
);
132132
}
133133

134134
set draftRevisions(value: Revision[]) {
135135
this._draftRevisions = value;
136-
const latestRevisionDate = value.length > 0 ? new Date(value[0].timestamp) : new Date(0);
137-
this.formattingOptionsSupported = latestRevisionDate > FORMATTING_OPTIONS_SUPPORTED_DATE;
136+
this.formattingOptionsSupported = value.some(rev => new Date(rev.timestamp) > FORMATTING_OPTIONS_SUPPORTED_DATE);
138137
}
139138

140139
get draftRevisions(): Revision[] {

0 commit comments

Comments
 (0)