-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskActions.tsx
More file actions
85 lines (78 loc) · 2.42 KB
/
Copy pathTaskActions.tsx
File metadata and controls
85 lines (78 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import { useState } from "react"
import { useTranslation } from "react-i18next"
import type { HistoryItem } from "@shofer/types"
import { vscode } from "@/utils/vscode"
import { useCopyToClipboard } from "@/utils/clipboard"
import { useExtensionState } from "@/context/ExtensionStateContext"
import { DeleteTaskDialog } from "../history/DeleteTaskDialog"
import { CopyIcon, CheckIcon, DownloadIcon, Trash2Icon, FileJsonIcon, MessageSquareCodeIcon } from "lucide-react"
import { LucideIconButton } from "./LucideIconButton"
interface TaskActionsProps {
item?: HistoryItem
buttonsDisabled: boolean
}
export const TaskActions = ({ item, buttonsDisabled }: TaskActionsProps) => {
const [deleteTaskId, setDeleteTaskId] = useState<string | null>(null)
const { t } = useTranslation()
const { copyWithFeedback, showCopyFeedback } = useCopyToClipboard()
const { debug } = useExtensionState()
return (
<div className="flex flex-row items-center -ml-0.5 mt-1 gap-1">
<LucideIconButton
icon={DownloadIcon}
title={t("chat:task.export")}
onClick={() => vscode.postMessage({ type: "exportCurrentTask" })}
/>
<LucideIconButton
icon={FileJsonIcon}
title={t("chat:task.exportJson")}
onClick={() => vscode.postMessage({ type: "exportCurrentTaskJson" })}
/>
{item?.task && (
<LucideIconButton
icon={showCopyFeedback ? CheckIcon : CopyIcon}
title={t("history:copyPrompt")}
onClick={(e) => copyWithFeedback(item.task, e)}
/>
)}
{!!item?.size && item.size > 0 && (
<>
<LucideIconButton
icon={Trash2Icon}
title={t("chat:task.delete")}
disabled={buttonsDisabled}
onClick={(e) => {
e.stopPropagation()
if (e.shiftKey) {
vscode.postMessage({ type: "deleteTaskWithId", text: item.id })
} else {
setDeleteTaskId(item.id)
}
}}
/>
{deleteTaskId && (
<DeleteTaskDialog
taskId={deleteTaskId}
onOpenChange={(open) => !open && setDeleteTaskId(null)}
open
/>
)}
</>
)}
{debug && item?.id && (
<>
<LucideIconButton
icon={FileJsonIcon}
title={t("chat:task.openApiHistory")}
onClick={() => vscode.postMessage({ type: "openDebugApiHistory" })}
/>
<LucideIconButton
icon={MessageSquareCodeIcon}
title={t("chat:task.openUiHistory")}
onClick={() => vscode.postMessage({ type: "openDebugUiHistory" })}
/>
</>
)}
</div>
)
}