mirror of
https://github.com/langgenius/dify.git
synced 2026-09-07 10:23:54 +08:00
Co-authored-by: Jingyi-Dify <jingyi.qi@dify.ai> Co-authored-by: yyh <yuanyouhuilyz@gmail.com> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: hjlarry <hjlarry@163.com> Co-authored-by: Bond Zhu <783504079@qq.com> Co-authored-by: Yansong Zhang <916125788@qq.com> Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com>
78 lines
2.2 KiB
TypeScript
78 lines
2.2 KiB
TypeScript
'use client'
|
|
|
|
import {
|
|
AlertDialog,
|
|
AlertDialogActions,
|
|
AlertDialogCancelButton,
|
|
AlertDialogConfirmButton,
|
|
AlertDialogContent,
|
|
AlertDialogDescription,
|
|
AlertDialogTitle,
|
|
} from '@langgenius/dify-ui/alert-dialog'
|
|
import { toast } from '@langgenius/dify-ui/toast'
|
|
import { useMutation } from '@tanstack/react-query'
|
|
import { useTranslation } from 'react-i18next'
|
|
import { consoleQuery } from '@/service/client'
|
|
|
|
type DeleteAgentDialogProps = {
|
|
agentId: string
|
|
agentName: string
|
|
open: boolean
|
|
onOpenChange: (open: boolean) => void
|
|
}
|
|
|
|
export function DeleteAgentDialog({
|
|
agentId,
|
|
agentName,
|
|
open,
|
|
onOpenChange,
|
|
}: DeleteAgentDialogProps) {
|
|
const { t } = useTranslation('agentV2')
|
|
const { t: tCommon } = useTranslation('common')
|
|
const deleteAgentMutation = useMutation(consoleQuery.agent.byAgentId.delete.mutationOptions())
|
|
|
|
const handleDelete = () => {
|
|
if (deleteAgentMutation.isPending)
|
|
return
|
|
|
|
deleteAgentMutation.mutate({
|
|
params: {
|
|
agent_id: agentId,
|
|
},
|
|
}, {
|
|
onSuccess: () => {
|
|
toast.success(t('roster.deleteSuccess'))
|
|
onOpenChange(false)
|
|
},
|
|
onError: () => {
|
|
toast.error(t('roster.deleteFailed'))
|
|
},
|
|
})
|
|
}
|
|
|
|
return (
|
|
<AlertDialog open={open} onOpenChange={onOpenChange}>
|
|
<AlertDialogContent className="p-6">
|
|
<AlertDialogTitle className="truncate title-2xl-semi-bold text-text-primary">
|
|
{t('roster.deleteDialog.title', { name: agentName })}
|
|
</AlertDialogTitle>
|
|
<AlertDialogDescription className="mt-2 system-md-regular wrap-break-word whitespace-pre-wrap text-text-tertiary">
|
|
{t('roster.deleteDialog.description')}
|
|
</AlertDialogDescription>
|
|
<AlertDialogActions className="p-0 pt-6">
|
|
<AlertDialogCancelButton disabled={deleteAgentMutation.isPending}>
|
|
{tCommon('operation.cancel')}
|
|
</AlertDialogCancelButton>
|
|
<AlertDialogConfirmButton
|
|
tone="destructive"
|
|
loading={deleteAgentMutation.isPending}
|
|
onClick={handleDelete}
|
|
>
|
|
{tCommon('operation.delete')}
|
|
</AlertDialogConfirmButton>
|
|
</AlertDialogActions>
|
|
</AlertDialogContent>
|
|
</AlertDialog>
|
|
)
|
|
}
|