Workflow Run Timeline UI (#1433)

This commit is contained in:
Shuchang Zheng
2024-12-23 23:44:47 -08:00
committed by GitHub
parent 682bc717f9
commit 517de67811
42 changed files with 1517 additions and 301 deletions

View File

@@ -0,0 +1,32 @@
import { getClient } from "@/api/AxiosClient";
import { useCredentialGetter } from "@/hooks/useCredentialGetter";
import { statusIsNotFinalized } from "@/routes/tasks/types";
import { keepPreviousData, useQuery } from "@tanstack/react-query";
import { useParams } from "react-router-dom";
import { WorkflowRunTimelineItem } from "../types/workflowRunTypes";
import { useWorkflowRunQuery } from "./useWorkflowRunQuery";
function useWorkflowRunTimelineQuery() {
const { workflowRunId, workflowPermanentId } = useParams();
const credentialGetter = useCredentialGetter();
const { data: workflowRun } = useWorkflowRunQuery();
return useQuery<Array<WorkflowRunTimelineItem>>({
queryKey: ["workflowRunTimeline", workflowPermanentId, workflowRunId],
queryFn: async () => {
const client = await getClient(credentialGetter);
return client
.get(`/workflows/${workflowPermanentId}/runs/${workflowRunId}/timeline`)
.then((response) => response.data);
},
refetchInterval:
workflowRun && statusIsNotFinalized(workflowRun) ? 5000 : false,
placeholderData: keepPreviousData,
refetchOnMount:
workflowRun && statusIsNotFinalized(workflowRun) ? "always" : false,
refetchOnWindowFocus:
workflowRun && statusIsNotFinalized(workflowRun) ? "always" : false,
});
}
export { useWorkflowRunTimelineQuery };