feat(FN-5055): merge fusion/fn-5055

This commit is contained in:
gsxdsm
2026-05-18 09:02:00 -07:00
parent d9214b69c9
commit ead2ed89aa
3 changed files with 13 additions and 49 deletions

View File

@@ -549,7 +549,7 @@ function TaskCardComponent({
const sendBackRef = useRef<HTMLDivElement>(null);
const [isInViewport, setIsInViewport] = useState(false);
const { badgeUpdates, subscribeToBadge, unsubscribeFromBadge } = useBadgeWebSocket(projectId);
const { confirm, confirmWithChoice } = useConfirm();
const { confirm } = useConfirm();
const retryWarningThreshold = useRetryWarning();
// Touch gesture detection refs
@@ -1189,38 +1189,13 @@ function TaskCardComponent({
e.stopPropagation();
if (!onDeleteTask) return;
if (task.column === "done" && onArchiveTask) {
const deleteChoice = await confirmWithChoice({
title: "Delete Task",
message: `Delete ${task.id}?`,
confirmLabel: "Delete",
cancelLabel: "Cancel",
tertiaryLabel: "Archive Instead",
danger: true,
});
if (deleteChoice === "tertiary") {
try {
await onArchiveTask(task.id);
addToast(`Archived ${task.id}`, "success");
} catch (err) {
addToast(`Failed to archive ${task.id}: ${getErrorMessage(err)}`, "error");
}
return;
}
if (deleteChoice !== "primary") {
return;
}
} else {
const shouldDelete = await confirm({
title: "Delete Task",
message: `Delete ${task.id}?`,
danger: true,
});
if (!shouldDelete) {
return;
}
const shouldDelete = await confirm({
title: "Delete Task",
message: `Delete ${task.id}?`,
danger: true,
});
if (!shouldDelete) {
return;
}
const trackedIssue = task.githubTracking?.enabled === true ? task.githubTracking.issue : undefined;
@@ -1284,7 +1259,7 @@ function TaskCardComponent({
addToast(`Failed to delete ${task.id}: ${getErrorMessage(retryErr)}`, "error");
}
}
}, [addToast, confirm, confirmWithChoice, onArchiveTask, onDeleteTask, task.column, task.githubTracking?.enabled, task.githubTracking?.issue, task.id]);
}, [addToast, confirm, onDeleteTask, task.githubTracking?.enabled, task.githubTracking?.issue, task.id]);
const handleOpenFiles = useCallback((e: React.MouseEvent) => {
e.stopPropagation();
@@ -1639,7 +1614,7 @@ function TaskCardComponent({
<Pencil size={12} />
</button>
)}
{(task.column === "triage" || task.column === "done") && onDeleteTask && (
{task.column === "triage" && onDeleteTask && (
<button
className="card-delete-btn"
onClick={handleDeleteClick}

View File

@@ -271,10 +271,9 @@ describe("TaskCard", () => {
});
});
it("archives done task when archive-instead is chosen", async () => {
it("hides delete button for done tasks while keeping archive action", () => {
const onDeleteTask = vi.fn(async () => makeTask());
const onArchiveTask = vi.fn(async () => makeTask({ column: "archived" }));
mockConfirmWithChoice.mockResolvedValueOnce("tertiary");
render(
<TaskCard
@@ -286,14 +285,8 @@ describe("TaskCard", () => {
/>,
);
await act(async () => {
fireEvent.click(screen.getByLabelText("Delete task"));
});
await waitFor(() => {
expect(onArchiveTask).toHaveBeenCalledWith("FN-001");
expect(onDeleteTask).not.toHaveBeenCalled();
});
expect(screen.queryByLabelText("Delete task")).toBeNull();
expect(screen.getByLabelText("Archive task")).toBeDefined();
});
it("keeps two-button delete flow for non-done task", async () => {