feat: add debug dialog and related functionality for skill debugging

This commit is contained in:
mlogclub
2026-04-10 16:52:45 +08:00
parent eac3d87cc2
commit 1087ddca44
5 changed files with 491 additions and 1 deletions
+34 -1
View File
@@ -21,6 +21,7 @@ import { CSS } from "@dnd-kit/utilities"
import { useCallback, useEffect, useState, type CSSProperties } from "react"
import {
BrainCircuitIcon,
BugIcon,
GripVerticalIcon,
MoreHorizontalIcon,
PlusIcon,
@@ -69,6 +70,7 @@ import {
import { getEnumLabel, getEnumOptions } from "@/lib/enums"
import { cn, formatDateTime } from "@/lib/utils"
import { EditDialog } from "./_components/edit"
import { DebugDialog } from "./_components/debug-dialog"
const statusFilterOptions = [
{ value: "all", label: "全部状态" },
@@ -83,6 +85,7 @@ type SortableSkillRowProps = {
disabled: boolean
actionLoadingId: number | null
openEditDialog: (item: SkillDefinition) => void
openDebugDialog: (item: SkillDefinition) => void
handleToggleStatus: (item: SkillDefinition) => void
handleDelete: (item: SkillDefinition) => void
}
@@ -92,6 +95,7 @@ function SortableSkillRow({
disabled,
actionLoadingId,
openEditDialog,
openDebugDialog,
handleToggleStatus,
handleDelete,
}: SortableSkillRowProps) {
@@ -184,6 +188,14 @@ function SortableSkillRow({
</TableCell>
<TableCell className="text-right">
<ButtonGroup className="ml-auto">
<Button
variant="outline"
size="sm"
onClick={() => openDebugDialog(item)}
>
<BugIcon />
</Button>
<Button
variant="outline"
size="sm"
@@ -229,7 +241,9 @@ export default function DashboardSkillsPage() {
const [actionLoadingId, setActionLoadingId] = useState<number | null>(null)
const [sorting, setSorting] = useState(false)
const [dialogOpen, setDialogOpen] = useState(false)
const [debugDialogOpen, setDebugDialogOpen] = useState(false)
const [editingItem, setEditingItem] = useState<SkillDefinition | null>(null)
const [debuggingItem, setDebuggingItem] = useState<SkillDefinition | null>(null)
const [result, setResult] = useState<PageResult<SkillDefinition>>({
results: [],
page: { page: 1, limit: 20, total: 0 },
@@ -301,6 +315,11 @@ export default function DashboardSkillsPage() {
setDialogOpen(true)
}
function openDebugDialog(item: SkillDefinition) {
setDebuggingItem(item)
setDebugDialogOpen(true)
}
function handleDialogOpenChange(open: boolean) {
if (saving) {
return
@@ -311,6 +330,13 @@ export default function DashboardSkillsPage() {
setDialogOpen(open)
}
function handleDebugDialogOpenChange(open: boolean) {
if (!open) {
setDebuggingItem(null)
}
setDebugDialogOpen(open)
}
async function handleSubmit(payload: CreateSkillDefinitionPayload) {
if (saving) {
return
@@ -464,7 +490,7 @@ export default function DashboardSkillsPage() {
<TableHead></TableHead>
<TableHead></TableHead>
<TableHead></TableHead>
<TableHead className="w-[92px] text-right"></TableHead>
<TableHead className="w-[168px] text-right"></TableHead>
</TableRow>
</TableHeader>
<TableBody>
@@ -486,6 +512,7 @@ export default function DashboardSkillsPage() {
disabled={sorting}
actionLoadingId={actionLoadingId}
openEditDialog={openEditDialog}
openDebugDialog={openDebugDialog}
handleToggleStatus={handleToggleStatus}
handleDelete={handleDelete}
/>
@@ -518,6 +545,12 @@ export default function DashboardSkillsPage() {
onOpenChange={handleDialogOpenChange}
onSubmit={handleSubmit}
/>
<DebugDialog
open={debugDialogOpen}
skillCode={debuggingItem?.code ?? ""}
skillName={debuggingItem?.name ?? ""}
onOpenChange={handleDebugDialogOpenChange}
/>
</>
)
}