Update workflows table actions (#736)

This commit is contained in:
Kerem Yilmaz
2024-08-26 22:34:06 +03:00
committed by GitHub
parent 672a2e22e4
commit c7ca6fefbc

View File

@@ -83,6 +83,36 @@ function Workflows() {
return <WorkflowsBetaAlertCard />; return <WorkflowsBetaAlertCard />;
} }
function handleRowClick(
event: React.MouseEvent<HTMLTableCellElement>,
workflowPermanentId: string,
) {
if (event.ctrlKey || event.metaKey) {
window.open(
window.location.origin + `/workflows/${workflowPermanentId}/runs`,
"_blank",
"noopener,noreferrer",
);
return;
}
navigate(`/workflows/${workflowPermanentId}/runs`);
}
function handleIconClick(
event: React.MouseEvent<HTMLButtonElement>,
path: string,
) {
if (event.ctrlKey || event.metaKey) {
window.open(
window.location.origin + path,
"_blank",
"noopener,noreferrer",
);
return;
}
navigate(path);
}
return ( return (
<div className="space-y-8"> <div className="space-y-8">
<header> <header>
@@ -92,42 +122,60 @@ function Workflows() {
<Table> <Table>
<TableHeader> <TableHeader>
<TableRow> <TableRow>
<TableHead className="w-1/4">ID</TableHead> <TableHead className="w-1/3">ID</TableHead>
<TableHead className="w-1/4">Status</TableHead> <TableHead className="w-1/3">Title</TableHead>
<TableHead className="w-1/4">Created At</TableHead> <TableHead className="w-1/3">Created At</TableHead>
<TableHead className="w-1/4"></TableHead> <TableHead></TableHead>
</TableRow> </TableRow>
</TableHeader> </TableHeader>
<TableBody> <TableBody>
{isLoading ? ( {isLoading ? (
<TableRow> <TableRow>
<TableCell colSpan={3}>Loading...</TableCell> <TableCell colSpan={4}>Loading...</TableCell>
</TableRow> </TableRow>
) : workflows?.length === 0 ? ( ) : workflows?.length === 0 ? (
<TableRow> <TableRow>
<TableCell colSpan={3}>No workflows found</TableCell> <TableCell colSpan={4}>No workflows found</TableCell>
</TableRow> </TableRow>
) : ( ) : (
workflows?.map((workflow) => { workflows?.map((workflow) => {
return ( return (
<TableRow key={workflow.workflow_permanent_id}> <TableRow
<TableCell className="w-1/3"> key={workflow.workflow_permanent_id}
className="cursor-pointer"
>
<TableCell
onClick={(event) => {
handleRowClick(event, workflow.workflow_permanent_id);
}}
>
{workflow.workflow_permanent_id} {workflow.workflow_permanent_id}
</TableCell> </TableCell>
<TableCell className="w-1/3">{workflow.title}</TableCell> <TableCell
<TableCell className="w-1/3"> onClick={(event) => {
handleRowClick(event, workflow.workflow_permanent_id);
}}
>
{workflow.title}
</TableCell>
<TableCell
onClick={(event) => {
handleRowClick(event, workflow.workflow_permanent_id);
}}
>
{basicTimeFormat(workflow.created_at)} {basicTimeFormat(workflow.created_at)}
</TableCell> </TableCell>
<TableCell> <TableCell>
<div className="flex gap-2"> <div className="flex justify-end gap-2">
<TooltipProvider> <TooltipProvider>
<Tooltip> <Tooltip>
<TooltipTrigger asChild> <TooltipTrigger asChild>
<Button <Button
size="icon" size="icon"
variant="outline" variant="outline"
onClick={() => { onClick={(event) => {
navigate( handleIconClick(
event,
`/workflows/${workflow.workflow_permanent_id}/runs`, `/workflows/${workflow.workflow_permanent_id}/runs`,
); );
}} }}
@@ -144,8 +192,9 @@ function Workflows() {
<Button <Button
size="icon" size="icon"
variant="outline" variant="outline"
onClick={() => { onClick={(event) => {
navigate( handleIconClick(
event,
`/workflows/${workflow.workflow_permanent_id}`, `/workflows/${workflow.workflow_permanent_id}`,
); );
}} }}
@@ -162,8 +211,9 @@ function Workflows() {
<Button <Button
size="icon" size="icon"
variant="outline" variant="outline"
onClick={() => { onClick={(event) => {
navigate( handleIconClick(
event,
`/workflows/${workflow.workflow_permanent_id}/run`, `/workflows/${workflow.workflow_permanent_id}/run`,
); );
}} }}