feat: add delete dataset option to Settings dropdown#125
feat: add delete dataset option to Settings dropdown#125balasiddarthan22 wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughThis PR adds dataset deletion support to the dataset detail page for owners. The change introduces the 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@frontend/app/dataset/`[id]/page.tsx:
- Around line 247-256: The delete flow currently closes the confirmation modal
and allows repeated clicks before the async removeDataset completes; update the
confirm action handler and handleDelete to (1) introduce and use an "isDeleting"
boolean (or the mutation's isLoading) to short-circuit duplicate submits, (2) do
NOT close the modal until removeDataset resolves successfully, and (3) only call
router.push("/dashboard") after a successful await removeDataset, while on error
keep the modal open and call captureException(err, { operation:
"dataset_delete", datasetId: dataset._id }) so users see failure and cannot
trigger duplicate destructive requests. Ensure the confirm button is disabled
when isDeleting/isLoading is true.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ec46336c-ff9f-42dc-9222-779de9e08114
📒 Files selected for processing (1)
frontend/app/dataset/[id]/page.tsx
| async function handleDelete() { | ||
| if (!dataset) return; | ||
| try { | ||
| await removeDataset({ id: dataset._id }); | ||
| router.push("/dashboard"); | ||
| } catch (err) { | ||
| console.error("[delete] failed", err); | ||
| captureException(err, { operation: "dataset_delete", datasetId: dataset._id }); | ||
| } | ||
| } |
There was a problem hiding this comment.
Keep the delete confirmation modal open until deletion succeeds, and block duplicate submits.
Line 445 closes the modal before the async delete resolves, and the confirm action (Line 818) can be clicked repeatedly while the mutation is in flight. This creates duplicate destructive requests and a silent-failure UX in the critical delete flow.
Suggested fix
@@
- const [confirmDelete, setConfirmDelete] = useState(false);
+ const [confirmDelete, setConfirmDelete] = useState(false);
+ const [deleting, setDeleting] = useState(false);
@@
- async function handleDelete() {
- if (!dataset) return;
+ async function handleDelete() {
+ if (!dataset || deleting) return;
+ setDeleting(true);
try {
await removeDataset({ id: dataset._id });
- router.push("/dashboard");
+ setConfirmDelete(false);
+ router.replace("/dashboard");
} catch (err) {
console.error("[delete] failed", err);
captureException(err, { operation: "dataset_delete", datasetId: dataset._id });
+ } finally {
+ setDeleting(false);
}
}
@@
{confirmDelete && (
<ConfirmDeleteModal
datasetName={dataset.name}
- onConfirm={() => {
- setConfirmDelete(false);
- handleDelete();
- }}
- onCancel={() => setConfirmDelete(false)}
+ deleting={deleting}
+ onConfirm={handleDelete}
+ onCancel={() => {
+ if (!deleting) setConfirmDelete(false);
+ }}
/>
)}
@@
function ConfirmDeleteModal({
datasetName,
+ deleting,
onConfirm,
onCancel,
}: {
datasetName: string;
+ deleting: boolean;
onConfirm: () => void;
onCancel: () => void;
}) {
@@
<button
onClick={onCancel}
+ disabled={deleting}
className="flex-1 rounded-lg bg-foreground/[0.06] py-1.5 text-xs font-medium text-foreground hover:bg-foreground/[0.1] transition-colors"
>
Cancel
</button>
<button
onClick={onConfirm}
+ disabled={deleting}
className="flex-1 rounded-lg bg-red-600 py-1.5 text-xs font-medium text-white hover:bg-red-700 transition-colors"
>
- Delete dataset
+ {deleting ? "Deleting…" : "Delete dataset"}
</button>Also applies to: 441-447, 782-823
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@frontend/app/dataset/`[id]/page.tsx around lines 247 - 256, The delete flow
currently closes the confirmation modal and allows repeated clicks before the
async removeDataset completes; update the confirm action handler and
handleDelete to (1) introduce and use an "isDeleting" boolean (or the mutation's
isLoading) to short-circuit duplicate submits, (2) do NOT close the modal until
removeDataset resolves successfully, and (3) only call router.push("/dashboard")
after a successful await removeDataset, while on error keep the modal open and
call captureException(err, { operation: "dataset_delete", datasetId: dataset._id
}) so users see failure and cannot trigger duplicate destructive requests.
Ensure the confirm button is disabled when isDeleting/isLoading is true.
Summary
Problem
There was no way to delete a dataset from the UI. If a dataset ended up in a broken state (e.g. created with 0 columns), the user was stuck on a blank page with no recovery path and no way to clean it up.
Test plan