Skip to content

Commit 2f82928

Browse files
authored
fix(site): simplify bulk task delete confirmation UI (#20979)
Reduce from 3 confirmation stages to 2 by removing the redundant "resources" stage. The final button now shows "Delete N tasks and M workspaces" directly, so users still see what will be deleted. Also add a Cancel button to match the single task delete dialog UX. Refs #20905
1 parent 6acfcd5 commit 2f82928

File tree

2 files changed

+7
-67
lines changed

2 files changed

+7
-67
lines changed

site/src/pages/TasksPage/BatchDeleteConfirmation.stories.tsx

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const meta: Meta<typeof BatchDeleteConfirmation> = {
3333
name: "task-docs-789",
3434
display_name: "Update Documentation",
3535
initial_prompt: "Update documentation for the new features",
36-
// Intentionally null to test that only 2 workspaces are shown in review resources stage
36+
// Intentionally null to test that only 2 workspaces are shown
3737
workspace_id: null,
3838
created_at: new Date(
3939
Date.now() - 3 * 24 * 60 * 60 * 1000,
@@ -64,23 +64,3 @@ export const ReviewTasks: Story = {
6464
});
6565
},
6666
};
67-
68-
export const ReviewResources: Story = {
69-
play: async ({ canvasElement, step }) => {
70-
const body = within(canvasElement.ownerDocument.body);
71-
72-
await step("Advance to stage 2: Review tasks", async () => {
73-
const confirmButton = await body.findByRole("button", {
74-
name: /review selected tasks/i,
75-
});
76-
await userEvent.click(confirmButton);
77-
});
78-
79-
await step("Advance to stage 3: Review resources", async () => {
80-
const confirmButton = await body.findByRole("button", {
81-
name: /confirm.*tasks/i,
82-
});
83-
await userEvent.click(confirmButton);
84-
});
85-
},
86-
};

site/src/pages/TasksPage/BatchDeleteConfirmation.tsx

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Task } from "api/typesGenerated";
22
import { ConfirmDialog } from "components/Dialogs/ConfirmDialog/ConfirmDialog";
33
import dayjs from "dayjs";
44
import relativeTime from "dayjs/plugin/relativeTime";
5-
import { ClockIcon, ServerIcon, UserIcon } from "lucide-react";
5+
import { ClockIcon, UserIcon } from "lucide-react";
66
import { type FC, type ReactNode, useState } from "react";
77

88
dayjs.extend(relativeTime);
@@ -24,17 +24,12 @@ export const BatchDeleteConfirmation: FC<BatchDeleteConfirmationProps> = ({
2424
onConfirm,
2525
isLoading,
2626
}) => {
27-
const [stage, setStage] = useState<"consequences" | "tasks" | "resources">(
28-
"consequences",
29-
);
27+
const [stage, setStage] = useState<"consequences" | "tasks">("consequences");
3028

3129
const onProceed = () => {
3230
switch (stage) {
33-
case "resources":
34-
onConfirm();
35-
break;
3631
case "tasks":
37-
setStage("resources");
32+
onConfirm();
3833
break;
3934
case "consequences":
4035
setStage("tasks");
@@ -45,15 +40,12 @@ export const BatchDeleteConfirmation: FC<BatchDeleteConfirmationProps> = ({
4540
const taskCount = `${checkedTasks.length} ${
4641
checkedTasks.length === 1 ? "task" : "tasks"
4742
}`;
43+
const workspaceCountText = `${workspaceCount} ${
44+
workspaceCount === 1 ? "workspace" : "workspaces"
45+
}`;
4846

4947
let confirmText: ReactNode = <>Review selected tasks&hellip;</>;
5048
if (stage === "tasks") {
51-
confirmText = <>Confirm {taskCount}&hellip;</>;
52-
}
53-
if (stage === "resources") {
54-
const workspaceCountText = `${workspaceCount} ${
55-
workspaceCount === 1 ? "workspace" : "workspaces"
56-
}`;
5749
confirmText = (
5850
<>
5951
Delete {taskCount} and {workspaceCountText}
@@ -70,19 +62,13 @@ export const BatchDeleteConfirmation: FC<BatchDeleteConfirmationProps> = ({
7062
onClose();
7163
}}
7264
title={`Delete ${taskCount}`}
73-
hideCancel
7465
confirmLoading={isLoading}
7566
confirmText={confirmText}
7667
onConfirm={onProceed}
7768
description={
7869
<>
7970
{stage === "consequences" && <Consequences />}
8071
{stage === "tasks" && <Tasks tasks={checkedTasks} />}
81-
{stage === "resources" && (
82-
<Resources tasks={checkedTasks} workspaceCount={workspaceCount} />
83-
)}
84-
{/* Preload ServerIcon to prevent flicker on stage 3 */}
85-
<ServerIcon className="sr-only" aria-hidden />
8672
</>
8773
}
8874
/>
@@ -93,11 +79,6 @@ interface TasksStageProps {
9379
tasks: readonly Task[];
9480
}
9581

96-
interface ResourcesStageProps {
97-
tasks: readonly Task[];
98-
workspaceCount: number;
99-
}
100-
10182
const Consequences: FC = () => {
10283
return (
10384
<>
@@ -174,24 +155,3 @@ const Tasks: FC<TasksStageProps> = ({ tasks }) => {
174155
</>
175156
);
176157
};
177-
178-
const Resources: FC<ResourcesStageProps> = ({ tasks, workspaceCount }) => {
179-
const taskCount = tasks.length;
180-
181-
return (
182-
<div className="flex flex-col gap-4">
183-
<p>
184-
Deleting {taskCount === 1 ? "this task" : "these tasks"} will also
185-
permanently destroy&hellip;
186-
</p>
187-
<div className="flex flex-wrap justify-center gap-x-5 gap-y-1.5 text-sm">
188-
<div className="flex items-center gap-2">
189-
<ServerIcon className="size-icon-sm" />
190-
<span>
191-
{workspaceCount} {workspaceCount === 1 ? "workspace" : "workspaces"}
192-
</span>
193-
</div>
194-
</div>
195-
</div>
196-
);
197-
};

0 commit comments

Comments
 (0)