Skip to content

Commit 4dcfea7

Browse files
josephmyerspmachapman
authored andcommitted
Revert "SF-3566 Guide user to formatting options on draft tab (#3447)"
This reverts commit 0e369e2.
1 parent 3503d67 commit 4dcfea7

File tree

5 files changed

+39
-162
lines changed

5 files changed

+39
-162
lines changed

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

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,15 @@
4444
}
4545
<div class="apply-draft-button-container">
4646
@if (featureFlags.usfmFormat.enabled) {
47-
@if (mustChooseFormattingOptions) {
48-
<button mat-flat-button (click)="navigateToFormatting()">
47+
<span
48+
[matTooltip]="t(doesLatestHaveDraft ? 'format_draft_can' : 'format_draft_cannot')"
49+
[style.cursor]="doesLatestHaveDraft ? 'pointer' : 'not-allowed'"
50+
>
51+
<button mat-button (click)="navigateToFormatting()" [disabled]="!doesLatestHaveDraft">
4952
<mat-icon>build</mat-icon>
50-
<transloco class="hide-lt-md" key="editor_draft_tab.format_draft"></transloco>
51-
<transloco class="hide-gt-md" key="editor_draft_tab.formatting"></transloco>
53+
<transloco key="editor_draft_tab.format_draft"></transloco>
5254
</button>
53-
} @else if (formattingOptionsSupported) {
54-
<span
55-
[matTooltip]="t(doesLatestBuildHaveDraft ? 'format_draft_can' : 'format_draft_cannot')"
56-
[style.cursor]="doesLatestBuildHaveDraft ? 'pointer' : 'not-allowed'"
57-
>
58-
<button mat-button (click)="navigateToFormatting()" [disabled]="!doesLatestBuildHaveDraft">
59-
<mat-icon>build</mat-icon>
60-
<transloco class="hide-lt-md" key="editor_draft_tab.format_draft"></transloco>
61-
<transloco class="hide-gt-md" key="editor_draft_tab.formatting"></transloco>
62-
</button>
63-
</span>
64-
}
55+
</span>
6556
}
6657
@if (userAppliedDraft) {
6758
<span class="draft-indicator">
@@ -70,26 +61,21 @@
7061
</span>
7162
}
7263
@if (canApplyDraft) {
73-
<span
74-
[matTooltip]="t(mustChooseFormattingOptions ? 'format_draft_before' : 'add_chapter_to_project')"
75-
[style.cursor]="mustChooseFormattingOptions ? 'not-allowed' : 'pointer'"
76-
>
77-
<button mat-flat-button color="primary" (click)="applyDraft()" [disabled]="mustChooseFormattingOptions">
78-
<mat-icon>auto_awesome</mat-icon>
79-
@if (isDraftApplied) {
80-
<transloco key="editor_draft_tab.reapply_to_project"></transloco>
81-
} @else {
82-
<transloco key="editor_draft_tab.apply_to_project"></transloco>
83-
}
84-
</button>
85-
</span>
64+
<button mat-flat-button color="primary" (click)="applyDraft()">
65+
<mat-icon>auto_awesome</mat-icon>
66+
@if (isDraftApplied) {
67+
<transloco key="editor_draft_tab.reapply_to_project"></transloco>
68+
} @else {
69+
<transloco key="editor_draft_tab.apply_to_project"></transloco>
70+
}
71+
</button>
72+
}
73+
@if (!canApplyDraft) {
74+
<app-notice icon="warning" type="warning" mode="fill-dark">
75+
{{ "editor_draft_tab.cannot_import" | transloco }}
76+
</app-notice>
8677
}
8778
</div>
88-
@if (!canApplyDraft) {
89-
<app-notice icon="warning" type="warning" mode="fill-dark">
90-
{{ "editor_draft_tab.cannot_import" | transloco }}
91-
</app-notice>
92-
}
9379
</div>
9480
}
9581
} @else {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ app-notice {
3131
flex-grow: 1;
3232
display: flex;
3333
justify-content: flex-end;
34-
gap: 4px;
34+
column-gap: 4px;
3535
align-items: center;
3636
flex-wrap: wrap;
3737
}

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

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
77
import { cloneDeep } from 'lodash-es';
88
import { TranslocoMarkupModule } from 'ngx-transloco-markup';
99
import { Delta } from 'quill';
10-
import { SFProjectRole } from 'realtime-server/lib/esm/scriptureforge/models/sf-project-role';
1110
import { createTestProjectProfile } from 'realtime-server/lib/esm/scriptureforge/models/sf-project-test-data';
12-
import { ParagraphBreakFormat, QuoteFormat } from 'realtime-server/lib/esm/scriptureforge/models/translate-config';
1311
import { BehaviorSubject, of } from 'rxjs';
1412
import { anything, mock, verify, when } from 'ts-mockito';
1513
import { ActivatedProjectService } from 'xforge-common/activated-project.service';
@@ -393,96 +391,6 @@ describe('EditorDraftComponent', () => {
393391
}));
394392

395393
describe('applyDraft', () => {
396-
it('should allow user to apply draft when formatting selected', fakeAsync(() => {
397-
const testProjectDoc: SFProjectProfileDoc = {
398-
data: createTestProjectProfile({
399-
texts: [
400-
{
401-
bookNum: 1,
402-
chapters: [{ number: 1, permissions: { user01: SFProjectRole.ParatextAdministrator }, hasDraft: true }]
403-
}
404-
],
405-
translateConfig: {
406-
draftConfig: {
407-
usfmConfig: { paragraphFormat: ParagraphBreakFormat.BestGuess, quoteFormat: QuoteFormat.Denormalized }
408-
}
409-
}
410-
})
411-
} as SFProjectProfileDoc;
412-
when(mockDraftGenerationService.draftExists(anything(), anything(), anything())).thenReturn(of(true));
413-
when(mockDraftGenerationService.getGeneratedDraftHistory(anything(), anything(), anything())).thenReturn(
414-
of(draftHistory)
415-
);
416-
when(mockActivatedProjectService.changes$).thenReturn(of(testProjectDoc));
417-
when(mockDialogService.confirm(anything(), anything())).thenResolve(true);
418-
spyOn<any>(component, 'getTargetOps').and.returnValue(of(targetDelta.ops));
419-
when(mockDraftHandlingService.getDraft(anything(), anything())).thenReturn(of(draftDelta.ops!));
420-
when(mockDraftHandlingService.draftDataToOps(anything(), anything())).thenReturn(draftDelta.ops!);
421-
422-
fixture.detectChanges();
423-
tick(EDITOR_READY_TIMEOUT);
424-
425-
expect(component.mustChooseFormattingOptions).toBe(false);
426-
flush();
427-
}));
428-
429-
it('should hide formatting options for drafts created before supported date', fakeAsync(() => {
430-
const testProjectDoc: SFProjectProfileDoc = {
431-
data: createTestProjectProfile({
432-
texts: [
433-
{
434-
bookNum: 1,
435-
chapters: [{ number: 1, permissions: { user01: SFProjectRole.ParatextAdministrator }, hasDraft: true }]
436-
}
437-
]
438-
})
439-
} as SFProjectProfileDoc;
440-
when(mockDraftGenerationService.draftExists(anything(), anything(), anything())).thenReturn(of(true));
441-
when(mockDraftGenerationService.getGeneratedDraftHistory(anything(), anything(), anything())).thenReturn(
442-
of(draftHistory)
443-
);
444-
when(mockActivatedProjectService.changes$).thenReturn(of(testProjectDoc));
445-
when(mockDialogService.confirm(anything(), anything())).thenResolve(true);
446-
spyOn<any>(component, 'getTargetOps').and.returnValue(of(targetDelta.ops));
447-
when(mockDraftHandlingService.getDraft(anything(), anything())).thenReturn(of(draftDelta.ops!));
448-
when(mockDraftHandlingService.draftDataToOps(anything(), anything())).thenReturn(draftDelta.ops!);
449-
450-
fixture.detectChanges();
451-
tick(EDITOR_READY_TIMEOUT);
452-
453-
expect(component.mustChooseFormattingOptions).toBe(false);
454-
flush();
455-
}));
456-
457-
it('should guide user to select formatting options when formatting not selected', fakeAsync(() => {
458-
const testProjectDoc: SFProjectProfileDoc = {
459-
data: createTestProjectProfile({
460-
texts: [
461-
{
462-
bookNum: 1,
463-
chapters: [{ number: 1, permissions: { user01: SFProjectRole.ParatextAdministrator }, hasDraft: true }]
464-
}
465-
]
466-
})
467-
} as SFProjectProfileDoc;
468-
when(mockDraftGenerationService.draftExists(anything(), anything(), anything())).thenReturn(of(true));
469-
const historyAfterFormattingOptions: Revision[] = [{ timestamp: '2025-10-01T12:00:00.000Z' }];
470-
when(mockDraftGenerationService.getGeneratedDraftHistory(anything(), anything(), anything())).thenReturn(
471-
of(historyAfterFormattingOptions)
472-
);
473-
when(mockActivatedProjectService.changes$).thenReturn(of(testProjectDoc));
474-
when(mockDialogService.confirm(anything(), anything())).thenResolve(true);
475-
spyOn<any>(component, 'getTargetOps').and.returnValue(of(targetDelta.ops));
476-
when(mockDraftHandlingService.getDraft(anything(), anything())).thenReturn(of(draftDelta.ops!));
477-
when(mockDraftHandlingService.draftDataToOps(anything(), anything())).thenReturn(draftDelta.ops!);
478-
479-
fixture.detectChanges();
480-
tick(EDITOR_READY_TIMEOUT);
481-
482-
expect(component.mustChooseFormattingOptions).toBe(true);
483-
flush();
484-
}));
485-
486394
it('should show a prompt when applying if the target has content', fakeAsync(() => {
487395
const testProjectDoc: SFProjectProfileDoc = {
488396
data: createTestProjectProfile()

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

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import { BuildStates } from '../../../machine-api/build-states';
4242
import { TextComponent } from '../../../shared/text/text.component';
4343
import { DraftGenerationService } from '../../draft-generation/draft-generation.service';
4444
import { DraftHandlingService } from '../../draft-generation/draft-handling.service';
45-
import { FORMATTING_OPTIONS_SUPPORTED_DATE } from '../../draft-generation/draft-utils';
4645
@Component({
4746
selector: 'app-editor-draft',
4847
templateUrl: './editor-draft.component.html',
@@ -68,8 +67,6 @@ export class EditorDraftComponent implements AfterViewInit, OnChanges {
6867
isDraftReady = false;
6968
isDraftApplied = false;
7069
userAppliedDraft = false;
71-
hasFormattingSelected = true;
72-
formattingOptionsSupported = true;
7370

7471
private selectedRevisionSubject = new BehaviorSubject<Revision | undefined>(undefined);
7572
private selectedRevision$ = this.selectedRevisionSubject.asObservable();
@@ -104,36 +101,8 @@ export class EditorDraftComponent implements AfterViewInit, OnChanges {
104101
private readonly router: Router
105102
) {}
106103

107-
get bookId(): string {
108-
return this.bookNum !== undefined ? Canon.bookNumberToId(this.bookNum) : '';
109-
}
110-
111-
get canApplyDraft(): boolean {
112-
if (this.targetProject == null || this.bookNum == null || this.chapter == null || this.draftDelta?.ops == null) {
113-
return false;
114-
}
115-
return this.draftHandlingService.canApplyDraft(this.targetProject, this.bookNum, this.chapter, this.draftDelta.ops);
116-
}
117-
118-
get doesLatestBuildHaveDraft(): boolean {
119-
return (
120-
this.targetProject?.texts.find(t => t.bookNum === this.bookNum)?.chapters.find(c => c.number === this.chapter)
121-
?.hasDraft ?? false
122-
);
123-
}
124-
125-
get mustChooseFormattingOptions(): boolean {
126-
return (
127-
this.featureFlags.usfmFormat.enabled &&
128-
!this.hasFormattingSelected &&
129-
this.formattingOptionsSupported &&
130-
this.doesLatestBuildHaveDraft
131-
);
132-
}
133-
134104
set draftRevisions(value: Revision[]) {
135105
this._draftRevisions = value;
136-
this.formattingOptionsSupported = value.some(rev => new Date(rev.timestamp) > FORMATTING_OPTIONS_SUPPORTED_DATE);
137106
}
138107

139108
get draftRevisions(): Revision[] {
@@ -159,6 +128,10 @@ export class EditorDraftComponent implements AfterViewInit, OnChanges {
159128
this.selectedRevisionSubject.next(this.selectedRevision);
160129
}
161130

131+
get bookId(): string {
132+
return this.bookNum !== undefined ? Canon.bookNumberToId(this.bookNum) : '';
133+
}
134+
162135
populateDraftTextInit(): void {
163136
combineLatest([
164137
this.onlineStatusService.onlineStatus$,
@@ -216,7 +189,6 @@ export class EditorDraftComponent implements AfterViewInit, OnChanges {
216189
filterNullish(),
217190
tap(projectDoc => {
218191
this.targetProject = projectDoc.data;
219-
this.hasFormattingSelected = projectDoc.data?.translateConfig.draftConfig.usfmConfig != null;
220192
}),
221193
distinctUntilChanged(),
222194
map(() => initialTimestamp)
@@ -277,6 +249,20 @@ export class EditorDraftComponent implements AfterViewInit, OnChanges {
277249
});
278250
}
279251

252+
get canApplyDraft(): boolean {
253+
if (this.targetProject == null || this.bookNum == null || this.chapter == null || this.draftDelta?.ops == null) {
254+
return false;
255+
}
256+
return this.draftHandlingService.canApplyDraft(this.targetProject, this.bookNum, this.chapter, this.draftDelta.ops);
257+
}
258+
259+
get doesLatestHaveDraft(): boolean {
260+
return (
261+
this.targetProject?.texts.find(t => t.bookNum === this.bookNum)?.chapters.find(c => c.number === this.chapter)
262+
?.hasDraft ?? false
263+
);
264+
}
265+
280266
navigateToFormatting(): void {
281267
this.router.navigateByUrl(`/projects/${this.projectId}/draft-generation/format/${this.bookId}/${this.chapter}`);
282268
}

src/SIL.XForge.Scripture/ClientApp/src/assets/i18n/non_checking_en.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,16 +403,13 @@
403403
"your_comment": "Your comment"
404404
},
405405
"editor_draft_tab": {
406-
"add_chapter_to_project": "Add this chapter to the project",
407406
"apply_to_project": "Add to project",
408407
"cannot_import": "You cannot import this draft because you do not have permission to edit this chapter. Permissions can be updated in Paratext.",
409408
"click_book_to_preview": "Click a book below to preview the draft and add it to your project.",
410409
"draft_indicator_applied": "Added",
411410
"draft_legacy_warning": "We have updated our drafting functionality. You can take advantage of this by [link:generateDraftUrl]generating a new draft[/link].",
412411
"error_applying_draft": "Failed to add the draft to the project. Try again later.",
413-
"formatting": "Formatting",
414412
"format_draft": "Formatting options",
415-
"format_draft_before": "Select formatting options before adding it to your project.",
416413
"format_draft_can": "Customize formatting options for the draft",
417414
"format_draft_cannot": "You can only change formatting for books from the latest draft",
418415
"no_draft_notice": "{{ bookChapterName }} has no draft.",

0 commit comments

Comments
 (0)