Ensure task expiration has precedence over any other state

This commit is contained in:
davelopez
2024-07-16 19:56:29 +02:00
parent a87408b3a1
commit 0eb7eeeb8a
3 changed files with 12 additions and 5 deletions
@@ -191,9 +191,10 @@ describe("PersistentTaskProgressMonitorAlert.vue", () => {
expect(completedAlert.text()).not.toContain("Download here");
});
it("should render a warning alert when the task has expired", () => {
it("should render a warning alert when the task has expired even if the status is running", () => {
const useMonitor = {
...FAKE_MONITOR,
isRunning: ref(true),
};
const existingMonitoringData: MonitoringData = {
taskId: "1",
@@ -107,13 +107,13 @@ function dismissAlert() {
<template>
<div v-if="hasMonitoringData" class="d-flex justify-content-end">
<BAlert v-if="isRunning" variant="info" show>
<BAlert v-if="hasExpired" variant="warning" show dismissible @dismissed="dismissAlert">
The {{ monitorRequest.action }} task has <b>expired</b> and the result is no longer available.
</BAlert>
<BAlert v-else-if="isRunning" variant="info" show>
<b>{{ inProgressMessage }}</b>
<FontAwesomeIcon :icon="faSpinner" class="mr-2" spin />
</BAlert>
<BAlert v-else-if="hasExpired" variant="warning" show dismissible @dismissed="dismissAlert">
The {{ monitorRequest.action }} task has <b>expired</b> and the result is no longer available.
</BAlert>
<BAlert v-else-if="isCompleted" variant="success" show dismissible @dismissed="dismissAlert">
<span>{{ completedMessage }}</span>
<BLink v-if="downloadUrl" class="download-link" :href="downloadUrl">
@@ -179,6 +179,12 @@ export function usePersistentProgressTaskMonitor(
return loadStatus(currentMonitoringData.value.status!);
}
if (hasExpired.value) {
// The monitoring data has expired. Requesting the status again will likely
// return incorrect results. Reset the monitoring data to start fresh.
return;
}
return waitForTask(currentMonitoringData.value.taskId);
}