Skip to content

feat: add delete dataset option to Settings dropdown#125

Open
balasiddarthan22 wants to merge 1 commit into
tinyfish-io:mainfrom
balasiddarthan22:feat/delete-dataset
Open

feat: add delete dataset option to Settings dropdown#125
balasiddarthan22 wants to merge 1 commit into
tinyfish-io:mainfrom
balasiddarthan22:feat/delete-dataset

Conversation

@balasiddarthan22
Copy link
Copy Markdown

Summary

  • Added a Delete dataset button to the Settings dropdown on the dataset page
  • Wires up the existing \�pi.datasets.remove\ Convex mutation which was never called from the UI
  • Shows a confirmation modal before deleting to prevent accidental data loss
  • Redirects to the dashboard after successful deletion

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

  • Open a dataset, click Settings, confirm Delete dataset appears at the bottom
  • Click Delete dataset, confirm the modal appears
  • Confirm deletion, verify dataset is removed and user is redirected to dashboard
  • Verify cancel dismisses the modal without deleting
  • Verify Delete option only appears for the dataset owner

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds dataset deletion support to the dataset detail page for owners. The change introduces the ConfirmDeleteModal component, a confirmation dialog with keyboard and click-outside dismiss handlers. The SettingsDropdown component is extended with an optional onDelete callback that renders a delete button when provided. In DatasetPage, the Convex api.datasets.remove mutation is wired through a handleDelete handler that deletes the dataset and navigates to the dashboard, with the deletion action triggered through the settings dropdown and guarded by the confirmation modal.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a delete dataset option to the Settings dropdown, which is the primary feature introduced in this pull request.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, providing context on the problem, solution, and test plan for the new delete dataset functionality.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5a2e7c3 and d8ba69b.

📒 Files selected for processing (1)
  • frontend/app/dataset/[id]/page.tsx

Comment on lines +247 to +256
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 });
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant