Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SF-3124 Add sync message before draft queued message #2923

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading