Skip to content

Commit

Permalink
Adding sync message before draft queued message
Browse files Browse the repository at this point in the history
To do this, we check the queue count in the project doc and display that message if the build job state is queued. Once the sync count is zero, we display the regular queue message.
  • Loading branch information
josephmyers committed Jan 6, 2025
1 parent ec1d939 commit 65a356d
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,18 @@ <h1 class="mat-headline-4">
@if (draftJob != null) {
@if (isDraftQueued(draftJob)) {
<section>
<h3>{{ t("draft_queued_header") }}</h3>
@if (!hasDraftQueueDepth(draftJob)) {
<p>{{ t("draft_queued_detail") }}</p>
@if (isSyncing()) {
<h3>{{ t("draft_syncing") }}</h3>
<p>{{ t("draft_syncing_detail") }}</p>
} @else {
<p>
{{ t("draft_queued_detail_multiple", { count: draftJob.queueDepth }) }}
</p>
<h3>{{ t("draft_queued_header") }}</h3>
@if (!hasDraftQueueDepth(draftJob)) {
<p>{{ t("draft_queued_detail") }}</p>
} @else {
<p>
{{ t("draft_queued_detail_multiple", { count: draftJob.queueDepth }) }}
</p>
}
}
<app-working-animated-indicator></app-working-animated-indicator>
<div class="button-strip">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2032,6 +2032,49 @@ describe('DraftGenerationComponent', () => {
verify(mockDialogRef.close()).once();
});

it('should track whether the current project is not syncing', fakeAsync(() => {
let env = new TestEnvironment();
env.fixture.detectChanges();
tick();

expect(env.component.isSyncing()).toBe(false);
}));

it('should track whether the current project is syncing', fakeAsync(() => {
const projectDoc: SFProjectProfileDoc = {
data: createTestProjectProfile({
writingSystem: {
tag: 'xyz'
},
translateConfig: {
projectType: ProjectType.BackTranslation,
source: {
projectRef: 'testSourceProjectId',
writingSystem: {
tag: 'en'
}
}
},
sync: {
queuedCount: 1
}
})
} as SFProjectProfileDoc;
let env = new TestEnvironment(() => {
mockActivatedProjectService = jasmine.createSpyObj('ActivatedProjectService', [''], {
projectId: projectId,
projectId$: of(projectId),
projectDoc: projectDoc,
projectDoc$: of(projectDoc),
changes$: of(projectDoc)
});
});
env.fixture.detectChanges();
tick();

expect(env.component.isSyncing()).toBe(true);
}));

it('should display the Paratext credentials update prompt when startBuild throws a forbidden error', fakeAsync(() => {
let env = new TestEnvironment(() => {
mockDraftGenerationService.startBuildOrGetActiveBuild.and.returnValue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,10 @@ export class DraftGenerationComponent extends DataLoadingComponent implements On
return activeBuildStates.includes(job?.state as BuildStates);
}

isSyncing(): boolean {
return this.activatedProject.projectDoc.data.sync.queuedCount > 0;
}

isDraftQueued(job?: BuildDto): boolean {
return [BuildStates.Queued, BuildStates.Pending].includes(job?.state as BuildStates);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@
"draft_active_detail": "Generating draft; this usually takes at least {{ count }} hours.",
"draft_active_header": "Draft in progress",
"draft_is_ready": "Your draft is ready",
"draft_syncing": "Draft initializing",
"draft_syncing_detail": "Your project is being synced before queuing the draft.",
"draft_queued_detail_multiple": "The translation draft generation is number {{ count }} in the queue, and will begin once the server is finished with other projects. Please check back later.",
"draft_queued_detail": "Generation of the translation draft has been queued, and will begin once the server is finished with another project. Please check back later.",
"draft_queued_header": "Draft queued",
Expand Down

0 comments on commit 65a356d

Please sign in to comment.