Open task in new tab when cmd or ctrl (#514)

Co-authored-by: Muhammed Salih Altun <muhammedsalihaltun@gmail.com>
This commit is contained in:
Kerem Yilmaz
2024-06-25 13:36:01 -07:00
committed by GitHub
parent e056c491a1
commit 3778094a9f
3 changed files with 42 additions and 18 deletions

View File

@@ -60,6 +60,18 @@ function TaskHistory() {
return <div>Error: {error?.message}</div>;
}
function handleNavigate(event: React.MouseEvent, id: string) {
if (event.ctrlKey || event.metaKey) {
window.open(
window.location.origin + `/tasks/${id}/actions`,
"_blank",
"noopener,noreferrer",
);
} else {
navigate(`${id}/actions`);
}
}
return (
<>
<div className="rounded-md border">
@@ -86,33 +98,25 @@ function TaskHistory() {
<TableRow key={task.task_id}>
<TableCell
className="w-1/4 cursor-pointer"
onClick={() => {
navigate(`${task.task_id}/actions`);
}}
onClick={(event) => handleNavigate(event, task.task_id)}
>
{task.task_id}
</TableCell>
<TableCell
className="w-1/4 cursor-pointer max-w-64 overflow-hidden whitespace-nowrap overflow-ellipsis"
onClick={() => {
navigate(`${task.task_id}/actions`);
}}
onClick={(event) => handleNavigate(event, task.task_id)}
>
{task.request.url}
</TableCell>
<TableCell
className="w-1/6 cursor-pointer"
onClick={() => {
navigate(`${task.task_id}/actions`);
}}
onClick={(event) => handleNavigate(event, task.task_id)}
>
<StatusBadge status={task.status} />
</TableCell>
<TableCell
className="w-1/4 cursor-pointer"
onClick={() => {
navigate(`${task.task_id}/actions`);
}}
onClick={(event) => handleNavigate(event, task.task_id)}
>
{basicTimeFormat(task.created_at)}
</TableCell>

View File

@@ -32,6 +32,18 @@ function QueuedTasks() {
},
});
function handleNavigate(event: React.MouseEvent, id: string) {
if (event.ctrlKey || event.metaKey) {
window.open(
window.location.origin + `/tasks/${id}/actions`,
"_blank",
"noopener,noreferrer",
);
} else {
navigate(`${id}/actions`);
}
}
return (
<div className="rounded-md border">
<Table>
@@ -54,9 +66,7 @@ function QueuedTasks() {
<TableRow
key={task.task_id}
className="w-4"
onClick={() => {
navigate(`${task.task_id}/actions`);
}}
onClick={(event) => handleNavigate(event, task.task_id)}
>
<TableCell className="w-1/4">{task.task_id}</TableCell>
<TableCell className="w-1/4 max-w-64 overflow-hidden whitespace-nowrap overflow-ellipsis">

View File

@@ -36,14 +36,24 @@ function RunningTasks() {
return <div>No running tasks</div>;
}
function handleNavigate(event: React.MouseEvent, id: string) {
if (event.ctrlKey || event.metaKey) {
window.open(
window.location.origin + `/tasks/${id}/actions`,
"_blank",
"noopener,noreferrer",
);
} else {
navigate(`/tasks/${id}/actions`);
}
}
return runningTasks?.map((task) => {
return (
<Card
key={task.task_id}
className="hover:bg-muted/50 cursor-pointer"
onClick={() => {
navigate(`/tasks/${task.task_id}/actions`);
}}
onClick={(event) => handleNavigate(event, task.task_id)}
>
<CardHeader>
<CardTitle className="overflow-hidden text-ellipsis whitespace-nowrap">