Add job agent (#1672)

Co-authored-by: Muhammed Salih Altun <muhammedsalihaltun@gmail.com>
This commit is contained in:
Shuchang Zheng
2025-01-29 06:38:15 +08:00
committed by GitHub
parent c7f56f30b3
commit f7cd429558
7 changed files with 72 additions and 18 deletions

View File

@@ -2,6 +2,7 @@ import { getClient } from "@/api/AxiosClient";
import { useCredentialGetter } from "@/hooks/useCredentialGetter";
import { useQuery } from "@tanstack/react-query";
import { WorkflowApiResponse } from "../types/workflowTypes";
import { globalWorkflowIds } from "@/util/env";
type Props = {
workflowPermanentId?: string;
@@ -13,8 +14,14 @@ function useWorkflowQuery({ workflowPermanentId }: Props) {
queryKey: ["workflow", workflowPermanentId],
queryFn: async () => {
const client = await getClient(credentialGetter);
const isGlobalWorkflow =
workflowPermanentId && globalWorkflowIds.includes(workflowPermanentId);
const params = new URLSearchParams();
if (isGlobalWorkflow) {
params.set("template", "true");
}
return client
.get(`/workflows/${workflowPermanentId}`)
.get(`/workflows/${workflowPermanentId}`, { params })
.then((response) => response.data);
},
});

View File

@@ -5,6 +5,7 @@ import {
statusIsNotFinalized,
statusIsRunningOrQueued,
} from "@/routes/tasks/types";
import { globalWorkflowIds } from "@/util/env";
import { keepPreviousData, useQuery } from "@tanstack/react-query";
import { useParams } from "react-router-dom";
@@ -16,8 +17,16 @@ function useWorkflowRunQuery() {
queryKey: ["workflowRun", workflowPermanentId, workflowRunId],
queryFn: async () => {
const client = await getClient(credentialGetter);
const isGlobalWorkflow =
workflowPermanentId && globalWorkflowIds.includes(workflowPermanentId);
const params = new URLSearchParams();
if (isGlobalWorkflow) {
params.set("template", "true");
}
return client
.get(`/workflows/${workflowPermanentId}/runs/${workflowRunId}`)
.get(`/workflows/${workflowPermanentId}/runs/${workflowRunId}`, {
params,
})
.then((response) => response.data);
},
refetchInterval: (query) => {

View File

@@ -5,6 +5,7 @@ import { keepPreviousData, useQuery } from "@tanstack/react-query";
import { useParams } from "react-router-dom";
import { WorkflowRunTimelineItem } from "../types/workflowRunTypes";
import { useWorkflowRunQuery } from "./useWorkflowRunQuery";
import { globalWorkflowIds } from "@/util/env";
function useWorkflowRunTimelineQuery() {
const { workflowRunId, workflowPermanentId } = useParams();
@@ -15,8 +16,17 @@ function useWorkflowRunTimelineQuery() {
queryKey: ["workflowRunTimeline", workflowPermanentId, workflowRunId],
queryFn: async () => {
const client = await getClient(credentialGetter);
const isGlobalWorkflow =
workflowPermanentId && globalWorkflowIds.includes(workflowPermanentId);
const params = new URLSearchParams();
if (isGlobalWorkflow) {
params.set("template", "true");
}
return client
.get(`/workflows/${workflowPermanentId}/runs/${workflowRunId}/timeline`)
.get(
`/workflows/${workflowPermanentId}/runs/${workflowRunId}/timeline`,
{ params },
)
.then((response) => response.data);
},
refetchInterval: