mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-25 13:48:18 +08:00
revert: remove incorrect issue deletion UI
This commit is contained in:
1 parent
0acc530ee4
commit
26c15f2f82
4 files changed
+9
-86
No files matched your search
@@ -14,10 +14,9 @@ interface IssueCardProps {
|
||||
project?: DomainProject
|
||||
onViewIssue: (issue: DomainProjectIssue) => void
|
||||
onTaskCreated?: () => void
|
||||
onIssueDeleted?: () => void
|
||||
}
|
||||
|
||||
export default function IssueCard({ issue, projectId, project, onViewIssue, onTaskCreated, onIssueDeleted }: IssueCardProps) {
|
||||
export default function IssueCard({ issue, projectId, project, onViewIssue, onTaskCreated }: IssueCardProps) {
|
||||
|
||||
const priority = useMemo(() => {
|
||||
switch (issue.priority) {
|
||||
@@ -62,7 +61,7 @@ export default function IssueCard({ issue, projectId, project, onViewIssue, onTa
|
||||
>
|
||||
{issue.title}
|
||||
</div>
|
||||
<IssueMenu issue={issue} projectId={projectId} project={project} onTaskCreated={onTaskCreated} onIssueDeleted={onIssueDeleted} />
|
||||
<IssueMenu issue={issue} projectId={projectId} project={project} onTaskCreated={onTaskCreated} />
|
||||
</div>
|
||||
<div className="text-xs text-muted-foreground line-clamp-2 break-all">{issue.summary}</div>
|
||||
<Separator className="my-2" />
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "@/
|
||||
import { CalendarDays } from "lucide-react";
|
||||
import IssueCard from "./issue-card";
|
||||
|
||||
export default function ProjectIssueList({ issues, projectId, project, onViewIssue, onTaskCreated, onIssueDeleted }: { issues: DomainProjectIssue[], projectId: string, project?: DomainProject, onViewIssue: (issue: DomainProjectIssue) => void, onTaskCreated?: () => void, onIssueDeleted?: () => void }) {
|
||||
export default function ProjectIssueList({ issues, projectId, project, onViewIssue, onTaskCreated }: { issues: DomainProjectIssue[], projectId: string, project?: DomainProject, onViewIssue: (issue: DomainProjectIssue) => void, onTaskCreated?: () => void }) {
|
||||
if (issues.length === 0) {
|
||||
return (
|
||||
<div className="flex-1 min-h-0 flex flex-col">
|
||||
@@ -32,9 +32,8 @@ export default function ProjectIssueList({ issues, projectId, project, onViewIss
|
||||
project={project}
|
||||
onViewIssue={onViewIssue}
|
||||
onTaskCreated={onTaskCreated}
|
||||
onIssueDeleted={onIssueDeleted}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,9 @@
|
||||
import { type DomainProjectIssue, type DomainProject } from "@/api/Api"
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"
|
||||
import { IconDeviceImacCode, IconLoader, IconSparkles, IconTrash } from "@tabler/icons-react"
|
||||
import { IconDeviceImacCode, IconSparkles, IconTrash } from "@tabler/icons-react"
|
||||
import { MoreVertical } from "lucide-react"
|
||||
import { useState } from "react"
|
||||
import { toast } from "sonner"
|
||||
import IssueDesignDialog from "./issue-design-dialog"
|
||||
import IssueDevelopDialog from "./issue-dev-dialog"
|
||||
|
||||
@@ -23,50 +12,11 @@ interface IssueMenuProps {
|
||||
projectId: string
|
||||
project?: DomainProject
|
||||
onTaskCreated?: () => void
|
||||
onIssueDeleted?: () => void
|
||||
}
|
||||
|
||||
export default function IssueMenu({ issue, projectId, project, onTaskCreated, onIssueDeleted }: IssueMenuProps) {
|
||||
export default function IssueMenu({ issue, projectId, project, onTaskCreated }: IssueMenuProps) {
|
||||
const [designDialogOpen, setDesignDialogOpen] = useState(false)
|
||||
const [developDialogOpen, setDevelopDialogOpen] = useState(false)
|
||||
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false)
|
||||
const [deleting, setDeleting] = useState(false)
|
||||
|
||||
const handleDeleteIssue = async () => {
|
||||
if (!issue?.id) {
|
||||
toast.error("需求信息不完整")
|
||||
return
|
||||
}
|
||||
|
||||
setDeleting(true)
|
||||
try {
|
||||
const response = await fetch(`/api/v1/users/projects/${projectId}/issues/${issue.id}`, {
|
||||
method: "DELETE",
|
||||
credentials: "same-origin",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
},
|
||||
})
|
||||
|
||||
if (response.status === 401) {
|
||||
window.location.href = "/login"
|
||||
return
|
||||
}
|
||||
|
||||
const resp = await response.json().catch(() => null)
|
||||
if (response.ok && resp?.code === 0) {
|
||||
toast.success("需求已删除")
|
||||
onIssueDeleted?.()
|
||||
} else {
|
||||
toast.error(resp?.message || "删除需求失败")
|
||||
}
|
||||
} catch (error) {
|
||||
toast.error((error as Error)?.message || "删除需求失败")
|
||||
} finally {
|
||||
setDeleting(false)
|
||||
setDeleteDialogOpen(false)
|
||||
}
|
||||
}
|
||||
|
||||
if (!issue) {
|
||||
return null
|
||||
@@ -79,7 +29,7 @@ export default function IssueMenu({ issue, projectId, project, onTaskCreated, on
|
||||
<MoreVertical className="size-4" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" className="min-w-36">
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem onClick={() => setDesignDialogOpen(true)}>
|
||||
<IconSparkles />
|
||||
启动设计任务
|
||||
@@ -88,36 +38,12 @@ export default function IssueMenu({ issue, projectId, project, onTaskCreated, on
|
||||
<IconDeviceImacCode />
|
||||
启动开发任务
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => setDeleteDialogOpen(true)}>
|
||||
<DropdownMenuItem>
|
||||
<IconTrash />
|
||||
删除
|
||||
移除
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
<AlertDialog open={deleteDialogOpen} onOpenChange={(open) => !deleting && setDeleteDialogOpen(open)}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>确认删除需求</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
确定要删除需求「{issue.title || "未命名需求"}」吗?此操作不可撤销。
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel disabled={deleting}>取消</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
variant="destructive"
|
||||
disabled={deleting}
|
||||
onClick={(event) => {
|
||||
event.preventDefault()
|
||||
handleDeleteIssue()
|
||||
}}
|
||||
>
|
||||
{deleting && <IconLoader className="size-4 animate-spin" />}
|
||||
{deleting ? "删除中..." : "确认删除"}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
|
||||
<IssueDesignDialog
|
||||
open={designDialogOpen}
|
||||
|
||||
@@ -125,7 +125,6 @@ export default function ProjectOverviewIssuesTab({ projectId, project, onTaskCre
|
||||
project={project}
|
||||
onViewIssue={handleViewIssue}
|
||||
onTaskCreated={onTaskCreated}
|
||||
onIssueDeleted={fetchProjectIssues}
|
||||
/>
|
||||
</div>
|
||||
<CreateIssueDialog
|
||||
|
||||
Reference in new issue
Block a user