Files
gsfdc/demo-dify/dify/web/app/components/datasets/delete-dataset-confirmation.tsx
T
wuzilongandCursor 6519682885 chore: 纳入本地 Dify 1.19.0 源码及品牌与免登改动
演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-18 13:59:25 +08:00

71 lines
2.1 KiB
TypeScript

import {
AlertDialogBody,
AlertDialogCancelButton,
AlertDialogConfirmButton,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from '@langgenius/dify-ui/alert-dialog'
import { Button } from '@langgenius/dify-ui/button'
import { useQuery } from '@tanstack/react-query'
import { useTranslation } from 'react-i18next'
import { consoleQuery } from '@/service/console'
export function DeleteDatasetConfirmation({
datasetId,
isPending,
error,
onConfirm,
}: {
datasetId: string
isPending: boolean
error?: string
onConfirm: () => void
}) {
const { t } = useTranslation(['common', 'dataset'])
const usage = useQuery(
consoleQuery.datasets.byDatasetId.useCheck.get.queryOptions({
input: { params: { dataset_id: datasetId } },
staleTime: 0,
retry: false,
context: { silent: true },
}),
)
return (
<>
<AlertDialogHeader>
<AlertDialogTitle>
{t(($) => $.deleteDatasetConfirmTitle, { ns: 'dataset' })}
</AlertDialogTitle>
<AlertDialogDescription>
{t(($) => (usage.data?.is_using ? $.datasetUsedByApp : $.deleteDatasetConfirmContent), {
ns: 'dataset',
})}
</AlertDialogDescription>
</AlertDialogHeader>
{(error || usage.isError) && (
<AlertDialogBody className="flex flex-col items-start gap-2">
<p role="alert" className="text-text-destructive">
{error ?? t(($) => $['api.actionFailed'], { ns: 'common' })}
</p>
{usage.isError && (
<Button size="small" loading={usage.isFetching} onClick={() => void usage.refetch()}>
{t(($) => $['operation.retry'], { ns: 'common' })}
</Button>
)}
</AlertDialogBody>
)}
<AlertDialogFooter>
<AlertDialogCancelButton disabled={isPending}>
{t(($) => $['operation.cancel'], { ns: 'common' })}
</AlertDialogCancelButton>
<AlertDialogConfirmButton loading={isPending} onClick={onConfirm}>
{t(($) => $['operation.confirm'], { ns: 'common' })}
</AlertDialogConfirmButton>
</AlertDialogFooter>
</>
)
}