Skip to content

Commit

Permalink
fix(ui): try retrieving live workflow first then archived (#12972)
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Currah <ryan@currah.ca>
(cherry picked from commit 9e1432a)
  • Loading branch information
ryancurrah authored and agilgur5 committed Apr 24, 2024
1 parent 47f920b commit 3e8de5d
Showing 1 changed file with 19 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -384,33 +384,30 @@ export function WorkflowDetails({history, location, match}: RouteComponentProps<
// Get workflow
useEffect(() => {
(async () => {
let archivedWf: Workflow;
if (uid !== '') {
try {
archivedWf = await services.workflows.getArchived(namespace, uid);
setError(null);
} catch (err) {
if (err.status !== 404) {
setError(err);
}
}
}

try {
const wf = await services.workflows.get(namespace, name);
setUid(wf.metadata.uid);
setWorkflow(wf);
setError(null);
// If we find live workflow which has same uid, we use live workflow.
if (!archivedWf || archivedWf.metadata.uid === wf.metadata.uid) {
setWorkflow(wf);
setUid(wf.metadata.uid);
} else {
setWorkflow(archivedWf);
}
return;
} catch (err) {
if (archivedWf) {
setWorkflow(archivedWf);
} else {
if (err.status !== 404 && uid === '') {
setError(err);
return;
}

try {
const archivedWf = await services.workflows.getArchived(namespace, uid);
setWorkflow(archivedWf);
setError(null);
return;
} catch (archiveErr) {
if (archiveErr.status === 500 && archiveErr.response.body.message === 'getting archived workflows not supported') {
setError(err);
return;
}

setError(archiveErr);
}
}
})();
Expand Down

0 comments on commit 3e8de5d

Please sign in to comment.