import { Check, Copy, FileIcon, FolderPlus, Loader2, Move, Trash2, X } from 'lucide-react'
import React, { useState } from 'react'
import { ApplyStatus, ManageFilesToolArgs } from "../../../types/apply"
interface ManageFilesOperation {
action: 'create_folder' | 'move' | 'delete' | 'copy' | 'rename'
path?: string
source_path?: string
destination_path?: string
new_name?: string
}
export default function MarkdownManageFilesBlock({
applyStatus,
onApply,
operations,
finish
}: {
applyStatus: ApplyStatus
onApply: (args: ManageFilesToolArgs) => void
operations: ManageFilesOperation[]
finish: boolean
}) {
const [applying, setApplying] = useState(false)
const getOperationIcon = (action: string) => {
switch (action) {
case 'create_folder':
return
case 'move':
return
case 'delete':
return
case 'copy':
return
case 'rename':
return
default:
return
}
}
const getOperationDescription = (operation: ManageFilesOperation) => {
switch (operation.action) {
case 'create_folder':
return `创建文件夹:${operation.path}`
case 'move':
return `移动文件:${operation.source_path} → ${operation.destination_path}`
case 'delete':
return `删除:${operation.path}`
case 'copy':
return `复制:${operation.source_path} → ${operation.destination_path}`
case 'rename':
return `重命名:${operation.path} → ${operation.new_name}`
default:
return `未知操作`
}
}
const handleApply = async () => {
if (applyStatus !== ApplyStatus.Idle) {
return
}
setApplying(true)
onApply({
type: 'manage_files',
operations: operations,
})
}
return (
文件管理操作 ({operations.length} 个操作)
{operations.map((operation, index) => (
{getOperationIcon(operation.action)}
{getOperationDescription(operation)}
))}
)
}