update:原生确认框替换为自定义弹窗
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
import { ConfirmDialog } from "~/components/common/ConfirmDialog";
|
||||
import type {
|
||||
Schedule,
|
||||
ScheduleArtifact,
|
||||
ScheduleNode,
|
||||
} from "~/services/api";
|
||||
|
||||
export type SchedulePendingConfirm =
|
||||
| { kind: "schedule"; schedule: Schedule }
|
||||
| { kind: "artifact"; artifact: ScheduleArtifact }
|
||||
| { kind: "node"; node: ScheduleNode }
|
||||
| { kind: "node-history"; node: ScheduleNode };
|
||||
|
||||
type SchedulePendingConfirmDialogProps = {
|
||||
pending: SchedulePendingConfirm | null;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
onConfirm: () => void | Promise<void>;
|
||||
};
|
||||
|
||||
function copyFor(pending: SchedulePendingConfirm) {
|
||||
switch (pending.kind) {
|
||||
case "schedule":
|
||||
return {
|
||||
title: "确定删除调度?",
|
||||
description: `确定删除调度"${pending.schedule.schedule_name}"吗?`,
|
||||
confirmLabel: "删除",
|
||||
};
|
||||
case "artifact":
|
||||
return {
|
||||
title: "确定移出调度列表?",
|
||||
description:
|
||||
`确定将"${pending.artifact.script_name} ${pending.artifact.version_label}"移出调度列表吗?稳定版本本身和历史运行记录不会被删除。`,
|
||||
confirmLabel: "移出",
|
||||
};
|
||||
case "node":
|
||||
return {
|
||||
title: "确定删除节点?",
|
||||
description: `确定删除节点"${pending.node.node_name}"吗?`,
|
||||
confirmLabel: "删除",
|
||||
};
|
||||
case "node-history":
|
||||
return {
|
||||
title: "一并删除运行日志?",
|
||||
description: "该节点有运行日志,是否一并删除?",
|
||||
confirmLabel: "删除",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function SchedulePendingConfirmDialog({
|
||||
pending,
|
||||
onOpenChange,
|
||||
onConfirm,
|
||||
}: SchedulePendingConfirmDialogProps) {
|
||||
const copy = pending ? copyFor(pending) : null;
|
||||
return (
|
||||
<ConfirmDialog
|
||||
open={pending !== null}
|
||||
onOpenChange={onOpenChange}
|
||||
title={copy?.title ?? ""}
|
||||
description={copy?.description ?? ""}
|
||||
confirmLabel={copy?.confirmLabel}
|
||||
destructive
|
||||
onConfirm={onConfirm}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user