Put workflow title in workflow runs table (#591)

This commit is contained in:
Kerem Yilmaz
2024-07-11 11:06:21 -07:00
committed by GitHub
parent 6f88ae31a0
commit 4e49d84f1e
2 changed files with 54 additions and 8 deletions

View File

@@ -0,0 +1,39 @@
import { getClient } from "@/api/AxiosClient";
import { WorkflowApiResponse } from "@/api/types";
import { Skeleton } from "@/components/ui/skeleton";
import { useCredentialGetter } from "@/hooks/useCredentialGetter";
import { useQuery } from "@tanstack/react-query";
type Props = {
workflowPermanentId: string;
};
function WorkflowTitle({ workflowPermanentId }: Props) {
const credentialGetter = useCredentialGetter();
const {
data: workflow,
isError,
isLoading,
} = useQuery<WorkflowApiResponse>({
queryKey: ["workflow", workflowPermanentId],
queryFn: async () => {
const client = await getClient(credentialGetter);
return client
.get(`/workflows/${workflowPermanentId}`)
.then((response) => response.data);
},
});
if (isLoading) {
return <Skeleton className="w-full h-6" />;
}
if (isError || !workflow) {
return <span></span>;
}
return <span>{workflow.title}</span>;
}
export { WorkflowTitle };