Skip to content

Commit 26c15f2

Browse files
committed
revert: remove incorrect issue deletion UI
1 parent 0acc530 commit 26c15f2

4 files changed

Lines changed: 9 additions & 86 deletions

File tree

frontend/src/components/console/project/issue-card.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ interface IssueCardProps {
1414
project?: DomainProject
1515
onViewIssue: (issue: DomainProjectIssue) => void
1616
onTaskCreated?: () => void
17-
onIssueDeleted?: () => void
1817
}
1918

20-
export default function IssueCard({ issue, projectId, project, onViewIssue, onTaskCreated, onIssueDeleted }: IssueCardProps) {
19+
export default function IssueCard({ issue, projectId, project, onViewIssue, onTaskCreated }: IssueCardProps) {
2120

2221
const priority = useMemo(() => {
2322
switch (issue.priority) {
@@ -62,7 +61,7 @@ export default function IssueCard({ issue, projectId, project, onViewIssue, onTa
6261
>
6362
{issue.title}
6463
</div>
65-
<IssueMenu issue={issue} projectId={projectId} project={project} onTaskCreated={onTaskCreated} onIssueDeleted={onIssueDeleted} />
64+
<IssueMenu issue={issue} projectId={projectId} project={project} onTaskCreated={onTaskCreated} />
6665
</div>
6766
<div className="text-xs text-muted-foreground line-clamp-2 break-all">{issue.summary}</div>
6867
<Separator className="my-2" />

frontend/src/components/console/project/issue-list.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "@/
33
import { CalendarDays } from "lucide-react";
44
import IssueCard from "./issue-card";
55

6-
export default function ProjectIssueList({ issues, projectId, project, onViewIssue, onTaskCreated, onIssueDeleted }: { issues: DomainProjectIssue[], projectId: string, project?: DomainProject, onViewIssue: (issue: DomainProjectIssue) => void, onTaskCreated?: () => void, onIssueDeleted?: () => void }) {
6+
export default function ProjectIssueList({ issues, projectId, project, onViewIssue, onTaskCreated }: { issues: DomainProjectIssue[], projectId: string, project?: DomainProject, onViewIssue: (issue: DomainProjectIssue) => void, onTaskCreated?: () => void }) {
77
if (issues.length === 0) {
88
return (
99
<div className="flex-1 min-h-0 flex flex-col">
@@ -32,9 +32,8 @@ export default function ProjectIssueList({ issues, projectId, project, onViewIss
3232
project={project}
3333
onViewIssue={onViewIssue}
3434
onTaskCreated={onTaskCreated}
35-
onIssueDeleted={onIssueDeleted}
3635
/>
3736
))}
3837
</div>
3938
)
40-
}
39+
}

frontend/src/components/console/project/issue-menu.tsx

Lines changed: 5 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
11
import { type DomainProjectIssue, type DomainProject } from "@/api/Api"
2-
import {
3-
AlertDialog,
4-
AlertDialogAction,
5-
AlertDialogCancel,
6-
AlertDialogContent,
7-
AlertDialogDescription,
8-
AlertDialogFooter,
9-
AlertDialogHeader,
10-
AlertDialogTitle,
11-
} from "@/components/ui/alert-dialog"
122
import { Button } from "@/components/ui/button"
133
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"
14-
import { IconDeviceImacCode, IconLoader, IconSparkles, IconTrash } from "@tabler/icons-react"
4+
import { IconDeviceImacCode, IconSparkles, IconTrash } from "@tabler/icons-react"
155
import { MoreVertical } from "lucide-react"
166
import { useState } from "react"
17-
import { toast } from "sonner"
187
import IssueDesignDialog from "./issue-design-dialog"
198
import IssueDevelopDialog from "./issue-dev-dialog"
209

@@ -23,50 +12,11 @@ interface IssueMenuProps {
2312
projectId: string
2413
project?: DomainProject
2514
onTaskCreated?: () => void
26-
onIssueDeleted?: () => void
2715
}
2816

29-
export default function IssueMenu({ issue, projectId, project, onTaskCreated, onIssueDeleted }: IssueMenuProps) {
17+
export default function IssueMenu({ issue, projectId, project, onTaskCreated }: IssueMenuProps) {
3018
const [designDialogOpen, setDesignDialogOpen] = useState(false)
3119
const [developDialogOpen, setDevelopDialogOpen] = useState(false)
32-
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false)
33-
const [deleting, setDeleting] = useState(false)
34-
35-
const handleDeleteIssue = async () => {
36-
if (!issue?.id) {
37-
toast.error("需求信息不完整")
38-
return
39-
}
40-
41-
setDeleting(true)
42-
try {
43-
const response = await fetch(`/api/v1/users/projects/${projectId}/issues/${issue.id}`, {
44-
method: "DELETE",
45-
credentials: "same-origin",
46-
headers: {
47-
Accept: "application/json",
48-
},
49-
})
50-
51-
if (response.status === 401) {
52-
window.location.href = "/login"
53-
return
54-
}
55-
56-
const resp = await response.json().catch(() => null)
57-
if (response.ok && resp?.code === 0) {
58-
toast.success("需求已删除")
59-
onIssueDeleted?.()
60-
} else {
61-
toast.error(resp?.message || "删除需求失败")
62-
}
63-
} catch (error) {
64-
toast.error((error as Error)?.message || "删除需求失败")
65-
} finally {
66-
setDeleting(false)
67-
setDeleteDialogOpen(false)
68-
}
69-
}
7020

7121
if (!issue) {
7222
return null
@@ -79,7 +29,7 @@ export default function IssueMenu({ issue, projectId, project, onTaskCreated, on
7929
<MoreVertical className="size-4" />
8030
</Button>
8131
</DropdownMenuTrigger>
82-
<DropdownMenuContent align="end" className="min-w-36">
32+
<DropdownMenuContent align="end">
8333
<DropdownMenuItem onClick={() => setDesignDialogOpen(true)}>
8434
<IconSparkles />
8535
启动设计任务
@@ -88,36 +38,12 @@ export default function IssueMenu({ issue, projectId, project, onTaskCreated, on
8838
<IconDeviceImacCode />
8939
启动开发任务
9040
</DropdownMenuItem>
91-
<DropdownMenuItem onClick={() => setDeleteDialogOpen(true)}>
41+
<DropdownMenuItem>
9242
<IconTrash />
93-
删除
43+
移除
9444
</DropdownMenuItem>
9545
</DropdownMenuContent>
9646
</DropdownMenu>
97-
<AlertDialog open={deleteDialogOpen} onOpenChange={(open) => !deleting && setDeleteDialogOpen(open)}>
98-
<AlertDialogContent>
99-
<AlertDialogHeader>
100-
<AlertDialogTitle>确认删除需求</AlertDialogTitle>
101-
<AlertDialogDescription>
102-
确定要删除需求「{issue.title || "未命名需求"}」吗?此操作不可撤销。
103-
</AlertDialogDescription>
104-
</AlertDialogHeader>
105-
<AlertDialogFooter>
106-
<AlertDialogCancel disabled={deleting}>取消</AlertDialogCancel>
107-
<AlertDialogAction
108-
variant="destructive"
109-
disabled={deleting}
110-
onClick={(event) => {
111-
event.preventDefault()
112-
handleDeleteIssue()
113-
}}
114-
>
115-
{deleting && <IconLoader className="size-4 animate-spin" />}
116-
{deleting ? "删除中..." : "确认删除"}
117-
</AlertDialogAction>
118-
</AlertDialogFooter>
119-
</AlertDialogContent>
120-
</AlertDialog>
12147

12248
<IssueDesignDialog
12349
open={designDialogOpen}

frontend/src/pages/console/user/project/overview/issues-tab.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ export default function ProjectOverviewIssuesTab({ projectId, project, onTaskCre
125125
project={project}
126126
onViewIssue={handleViewIssue}
127127
onTaskCreated={onTaskCreated}
128-
onIssueDeleted={fetchProjectIssues}
129128
/>
130129
</div>
131130
<CreateIssueDialog

0 commit comments

Comments
 (0)