11import { 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"
122import { Button } from "@/components/ui/button"
133import { 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"
155import { MoreVertical } from "lucide-react"
166import { useState } from "react"
17- import { toast } from "sonner"
187import IssueDesignDialog from "./issue-design-dialog"
198import 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 }
0 commit comments