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 };

View File

@@ -22,6 +22,7 @@ import {
PaginationPrevious,
} from "@/components/ui/pagination";
import { cn } from "@/util/utils";
import { WorkflowTitle } from "./WorkflowTitle";
function Workflows() {
const credentialGetter = useCredentialGetter();
@@ -153,19 +154,20 @@ function Workflows() {
<Table>
<TableHeader>
<TableRow>
<TableHead className="w-1/3">Workflow ID</TableHead>
<TableHead className="w-1/3">Workflow Run ID</TableHead>
<TableHead className="w-1/3">Status</TableHead>
<TableHead className="w-1/4">Workflow ID</TableHead>
<TableHead className="w-1/4">Workflow Title</TableHead>
<TableHead className="w-1/4">Workflow Run ID</TableHead>
<TableHead className="w-1/4">Status</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{workflowRunsIsLoading ? (
<TableRow>
<TableCell colSpan={3}>Loading...</TableCell>
<TableCell colSpan={4}>Loading...</TableCell>
</TableRow>
) : workflowRuns?.length === 0 ? (
<TableRow>
<TableCell colSpan={3}>No workflow runs found</TableCell>
<TableCell colSpan={4}>No workflow runs found</TableCell>
</TableRow>
) : (
workflowRuns?.map((workflowRun) => {
@@ -179,13 +181,18 @@ function Workflows() {
}}
className="cursor-pointer"
>
<TableCell className="w-1/3">
<TableCell className="w-1/4">
{workflowRun.workflow_permanent_id}
</TableCell>
<TableCell className="w-1/3">
<TableCell className="w-1/4">
<WorkflowTitle
workflowPermanentId={workflowRun.workflow_permanent_id}
/>
</TableCell>
<TableCell className="w-1/4">
{workflowRun.workflow_run_id}
</TableCell>
<TableCell className="w-1/3">
<TableCell className="w-1/4">
<StatusBadge status={workflowRun.status} />
</TableCell>
</TableRow>