Skip to content

Commit 47c2bd1

Browse files
committed
SF-3744 Hide format options button on draft tab when draft started
1 parent 5330354 commit 47c2bd1

5 files changed

Lines changed: 40 additions & 267 deletions

File tree

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

Lines changed: 5 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -202,29 +202,6 @@ <h1>
202202
</a>
203203
</div>
204204
</app-notice>
205-
@if (!featureFlags.newDraftHistory.enabled) {
206-
<section data-test-id="technical-details">
207-
<div>
208-
<p class="error-text">Technical details:</p>
209-
<div>
210-
<div><strong>Message:</strong> {{ draftJob?.message ?? "unknown" }}</div>
211-
<div>
212-
<strong>Translation Engine Id:</strong>
213-
{{ draftJob?.additionalInfo?.translationEngineId ?? "unknown" }}
214-
</div>
215-
<div><strong>Build Id:</strong> {{ draftJob?.additionalInfo?.buildId ?? "unknown" }}</div>
216-
<div>
217-
<strong>Corpora Ids:</strong>
218-
{{ draftJob?.additionalInfo?.corporaIds?.join(", ") ?? "unknown" }}
219-
</div>
220-
<div>
221-
<strong>Parallel Corpora Ids:</strong>
222-
{{ draftJob?.additionalInfo?.parallelCorporaIds?.join(", ") ?? "unknown" }}
223-
</div>
224-
</div>
225-
</div>
226-
</section>
227-
}
228205
}
229206
@if (!isDraftInProgress(draftJob) && !hasAnyCompletedBuild) {
230207
<section class="action-button-strip">
@@ -250,7 +227,7 @@ <h1>
250227
}
251228
@if (isPreviewSupported) {
252229
@if (draftJob != null) {
253-
@if (isDraftInProgress(draftJob) && featureFlags.newDraftHistory.enabled) {
230+
@if (isDraftInProgress(draftJob)) {
254231
<mat-card class="draft-progress-card">
255232
<mat-card-header>
256233
<mat-card-title>
@@ -290,86 +267,6 @@ <h1>
290267
}
291268
</mat-card-content>
292269
</mat-card>
293-
} @else if (!featureFlags.newDraftHistory.enabled) {
294-
@if (isDraftQueued(draftJob)) {
295-
<section>
296-
@if (isSyncing()) {
297-
<h3>{{ t("draft_syncing") }}</h3>
298-
<p>{{ t("draft_syncing_detail") }}</p>
299-
} @else {
300-
<h3>{{ t("draft_queued_header") }}</h3>
301-
@if (!hasDraftQueueDepth(draftJob)) {
302-
<p>{{ t("draft_queued_detail") }}</p>
303-
} @else {
304-
<p>
305-
{{ t("draft_queued_detail_multiple", { count: draftJob.queueDepth }) }}
306-
</p>
307-
}
308-
}
309-
<app-working-animated-indicator></app-working-animated-indicator>
310-
<div class="button-strip">
311-
@if (canCancel(draftJob)) {
312-
<button mat-flat-button color="primary" (click)="cancel()">
313-
<mat-icon>close</mat-icon>
314-
{{ t("cancel_generation_button") }}
315-
</button>
316-
}
317-
</div>
318-
</section>
319-
} @else if (isDraftActive(draftJob)) {
320-
<section class="progress-active">
321-
<h3>{{ t("draft_active_header") }}</h3>
322-
<div class="progress-text">
323-
<p>{{ t("draft_active_detail", { count: draftDurationHours | l10nNumber }) }}</p>
324-
</div>
325-
<circle-progress [percent]="draftJob.percentCompleted * 100"></circle-progress>
326-
<div class="button-strip">
327-
@if (canCancel(draftJob)) {
328-
<button mat-flat-button color="primary" (click)="cancel()">
329-
<mat-icon>close</mat-icon>
330-
{{ t("cancel_generation_button") }}
331-
</button>
332-
}
333-
</div>
334-
</section>
335-
} @else if (isDraftFinishing(draftJob)) {
336-
<section>
337-
<h3>{{ t("draft_finishing_header") }}</h3>
338-
<div class="progress-text">
339-
<p>{{ t("draft_finishing_detail") }}</p>
340-
</div>
341-
<app-working-animated-indicator></app-working-animated-indicator>
342-
</section>
343-
}
344-
@if (isDraftComplete(draftJob) || hasAnyCompletedBuild) {
345-
<section class="draft-complete">
346-
<mat-card class="preview-card">
347-
<mat-card-header>
348-
<mat-card-title>
349-
{{ isDraftComplete(draftJob) ? t("draft_is_ready") : t("preview_last_draft_header") }}
350-
</mat-card-title>
351-
</mat-card-header>
352-
<mat-card-content>
353-
@if (isDraftFaulted(draftJob)) {
354-
<p>{{ t("preview_last_draft_detail") }}</p>
355-
}
356-
<p>{{ t("click_book_to_preview") }}</p>
357-
<app-draft-preview-books></app-draft-preview-books>
358-
</mat-card-content>
359-
<mat-card-actions>
360-
@if (hasDraftBooksAvailable) {
361-
<app-draft-download-button [build]="lastCompletedBuild" />
362-
@if (featureFlags.usfmFormat.enabled) {
363-
<button mat-button [routerLink]="draftOptionsService.formattingOptionsPath">
364-
<mat-icon>settings</mat-icon>
365-
{{ t("format_draft") }}
366-
</button>
367-
}
368-
}
369-
</mat-card-actions>
370-
</mat-card>
371-
</section>
372-
}
373270
}
374271
}
375272
}
@@ -393,12 +290,7 @@ <h3>{{ t("draft_finishing_header") }}</h3>
393290
hasAnyCompletedBuild &&
394291
isSourcesConfigurationComplete
395292
) {
396-
<button
397-
mat-flat-button
398-
color="primary"
399-
type="button"
400-
(click)="generateDraftClicked({ withConfirm: !featureFlags.newDraftHistory.enabled })"
401-
>
293+
<button mat-flat-button color="primary" type="button" (click)="generateDraftClicked()">
402294
<mat-icon>add</mat-icon> {{ t("generate_new_draft") }}
403295
</button>
404296
@if (hasConfigureSourcePermission) {
@@ -422,11 +314,9 @@ <h3>{{ t("draft_finishing_header") }}</h3>
422314
}
423315
</section>
424316

425-
@if (featureFlags.newDraftHistory.enabled) {
426-
<app-draft-history-list [style.display]="isOnline ? 'flex' : 'none'"></app-draft-history-list>
427-
@if (isOnline && isServalAdmin()) {
428-
<h2>Further information</h2>
429-
}
317+
<app-draft-history-list [style.display]="isOnline ? 'flex' : 'none'"></app-draft-history-list>
318+
@if (isOnline && isServalAdmin()) {
319+
<h2>Further information</h2>
430320
}
431321

432322
@if (canShowAdditionalInfo(draftJob)) {

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

Lines changed: 2 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { SFProjectRole } from 'realtime-server/lib/esm/scriptureforge/models/sf-
99
import { createTestProjectProfile } from 'realtime-server/lib/esm/scriptureforge/models/sf-project-test-data';
1010
import { TextInfoPermission } from 'realtime-server/lib/esm/scriptureforge/models/text-info-permission';
1111
import { ProjectType } from 'realtime-server/lib/esm/scriptureforge/models/translate-config';
12-
import { BehaviorSubject, EMPTY, of, Subject, throwError } from 'rxjs';
12+
import { EMPTY, of, Subject, throwError } from 'rxjs';
1313
import { instance, mock, verify, when } from 'ts-mockito';
1414
import { ActivatedProjectService } from 'xforge-common/activated-project.service';
1515
import { AuthService } from 'xforge-common/auth.service';
@@ -200,7 +200,7 @@ describe('DraftGenerationComponent', () => {
200200
}
201201
})
202202
} as SFProjectProfileDoc;
203-
mockAuthService = jasmine.createSpyObj<AuthService>(['requestParatextCredentialUpdate'], {
203+
mockAuthService = jasmine.createSpyObj<AuthService>(['requestParatextCredentialUpdate', 'getAccessToken'], {
204204
currentUserId,
205205
currentUserRoles: [SystemRole.User]
206206
});
@@ -1331,15 +1331,6 @@ describe('DraftGenerationComponent', () => {
13311331
});
13321332

13331333
describe('isDraftFaulted', () => {
1334-
it('should return true if the draft build is faulted', () => {
1335-
const env = new TestEnvironment();
1336-
env.component.draftJob = { ...buildDto, state: BuildStates.Faulted };
1337-
env.fixture.detectChanges();
1338-
expect(env.component.isDraftFaulted({ state: BuildStates.Faulted } as BuildDto)).toBe(true);
1339-
expect(env.getElementByTestId('warning-generation-failed')).not.toBeNull();
1340-
expect(env.getElementByTestId('technical-details')).not.toBeNull();
1341-
});
1342-
13431334
it('should return false if the draft build is not faulted', () => {
13441335
const env = new TestEnvironment();
13451336
expect(env.component.isDraftFaulted({ state: BuildStates.Active } as BuildDto)).toBe(false);
@@ -1368,107 +1359,4 @@ describe('DraftGenerationComponent', () => {
13681359
expect(env.component.isDraftInProgress({ state: BuildStates.Faulted } as BuildDto)).toBe(false);
13691360
});
13701361
});
1371-
1372-
describe('download draft button', () => {
1373-
it('button should display if there are draft books available', () => {
1374-
const env = new TestEnvironment();
1375-
env.component.draftJob = { ...buildDto, state: BuildStates.Faulted };
1376-
env.component.hasDraftBooksAvailable = true;
1377-
env.fixture.detectChanges();
1378-
expect(env.downloadButton).not.toBeNull();
1379-
});
1380-
1381-
it('button should display if there is a completed build while a build is faulted', () => {
1382-
const env = new TestEnvironment();
1383-
env.component.draftJob = { ...buildDto, state: BuildStates.Faulted };
1384-
env.component.lastCompletedBuild = { ...buildDto, state: BuildStates.Completed };
1385-
env.component.hasDraftBooksAvailable = true;
1386-
env.fixture.detectChanges();
1387-
1388-
expect(env.downloadButton).not.toBeNull();
1389-
});
1390-
1391-
it('button should display if there is a completed build while a build is queued', () => {
1392-
const env = new TestEnvironment();
1393-
env.setup();
1394-
env.component.draftJob = { ...buildDto, state: BuildStates.Queued };
1395-
env.component.lastCompletedBuild = { ...buildDto, state: BuildStates.Completed };
1396-
env.component.hasDraftBooksAvailable = true;
1397-
env.fixture.detectChanges();
1398-
1399-
expect(env.downloadButton).not.toBeNull();
1400-
});
1401-
1402-
it('button should not display if there is no completed build while a build is faulted', () => {
1403-
const env = new TestEnvironment();
1404-
env.component.draftJob = { ...buildDto, state: BuildStates.Faulted };
1405-
env.component.lastCompletedBuild = undefined;
1406-
env.component.hasDraftBooksAvailable = true;
1407-
env.fixture.detectChanges();
1408-
1409-
expect(env.downloadButton).toBeNull();
1410-
});
1411-
1412-
it('button should display if the project has a draft complete', fakeAsync(() => {
1413-
// Setup the project and subject
1414-
const projectDoc: SFProjectProfileDoc = {
1415-
data: createTestProjectProfile({
1416-
translateConfig: {
1417-
preTranslate: true,
1418-
projectType: ProjectType.Standard,
1419-
source: {
1420-
projectRef: 'testSourceProjectId',
1421-
writingSystem: {
1422-
tag: 'es'
1423-
}
1424-
}
1425-
},
1426-
texts: [
1427-
{
1428-
bookNum: 1,
1429-
chapters: [{ number: 1 }],
1430-
permissions: { user01: TextInfoPermission.Write }
1431-
}
1432-
]
1433-
})
1434-
} as SFProjectProfileDoc;
1435-
const projectSubject = new BehaviorSubject<SFProjectProfileDoc>(projectDoc);
1436-
const projectObservable = projectSubject.asObservable();
1437-
const buildSubject = new BehaviorSubject<BuildDto>(buildDto);
1438-
const buildObservable = buildSubject.asObservable();
1439-
1440-
// Setup the initial environment
1441-
const env = new TestEnvironment(() => {
1442-
mockActivatedProjectService = jasmine.createSpyObj('ActivatedProjectService', [], {
1443-
projectDoc: projectDoc,
1444-
projectId: projectId,
1445-
projectId$: of(projectId),
1446-
projectDoc$: projectObservable,
1447-
changes$: projectObservable
1448-
});
1449-
mockDraftGenerationService.getBuildProgress.and.returnValue(buildObservable);
1450-
mockDraftGenerationService.pollBuildProgress.and.returnValue(buildObservable);
1451-
mockDraftGenerationService.getLastCompletedBuild.and.returnValue(buildObservable);
1452-
mockSFProjectService.hasDraft.and.returnValue(false);
1453-
});
1454-
tick(500);
1455-
env.fixture.detectChanges();
1456-
1457-
// Verify the button is not visible
1458-
expect(env.downloadButton).toBeNull();
1459-
1460-
// Update the has draft flag for the project
1461-
mockSFProjectService.hasDraft.and.returnValue(true);
1462-
projectDoc.data!.translateConfig.draftConfig.lastSelectedTranslationScriptureRanges = [
1463-
{ projectId: 'testSourceProjectId', scriptureRange: 'GEN' }
1464-
];
1465-
projectSubject.next(projectDoc);
1466-
buildSubject.next({ ...buildDto, state: BuildStates.Completed });
1467-
tick(500);
1468-
env.fixture.detectChanges();
1469-
1470-
// Verify the button is visible
1471-
expect(env.downloadButton).not.toBeNull();
1472-
}));
1473-
});
14741362
});

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

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ export class DraftGenerationComponent extends DataLoadingComponent implements On
342342
);
343343
}
344344

345-
async generateDraftClicked({ withConfirm = false } = {}): Promise<void> {
345+
async generateDraftClicked(): Promise<void> {
346346
if (this.formattingOptionsRequired) {
347347
const dialogRef = this.dialogService.openGenericDialog({
348348
title: this.i18n.translate('draft_generation.choose_formatting_options'),
@@ -359,24 +359,6 @@ export class DraftGenerationComponent extends DataLoadingComponent implements On
359359
if (await dialogRef.result) await this.router.navigate(this.draftOptionsService.formattingOptionsPath);
360360
return;
361361
}
362-
if (withConfirm) {
363-
const isConfirmed: boolean | undefined = await this.dialogService.openGenericDialog({
364-
title: this.i18n.translate('draft_generation.dialog_confirm_draft_regeneration_title'),
365-
message: this.i18n.translate('draft_generation.dialog_confirm_draft_regeneration_message'),
366-
options: [
367-
{ value: false, label: this.i18n.translate('draft_generation.dialog_confirm_draft_regeneration_no') },
368-
{
369-
value: true,
370-
label: this.i18n.translate('draft_generation.dialog_confirm_draft_regeneration_yes'),
371-
highlight: true
372-
}
373-
]
374-
}).result;
375-
376-
if (!isConfirmed) {
377-
return;
378-
}
379-
}
380362

381363
// Display pre-generation steps
382364
this.currentPage = 'steps';

0 commit comments

Comments
 (0)