Skip to content

fix: gate content dismiss actions behind confirmation and undo - #653

Merged
gkhngyk merged 2 commits into
ansvisor:mainfrom
Adarshhic:fix/611-content-dismiss-confirmation
Aug 7, 2026
Merged

gkhngyk merged 2 commits into
ansvisor:mainfrom
Adarshhic:fix/611-content-dismiss-confirmation

Conversation

@Adarshhic

Copy link
Copy Markdown
Contributor

Summary

Content Opportunities dismiss actions previously mutated state immediately with no confirmation — both single-row dismiss and bulk "Dismiss All" fired on first click with an irreversible optimistic update.

This PR:

Gates Dismiss All (bulk) behind a confirm Dialog (same pattern as audit/[id]/page.tsx) showing the exact count of opportunities being dismissed. Cancelling leaves all rows untouched.
Gives single-row dismiss (list page + detail page) an undo-toast: the dismiss still fires immediately to keep the flow fast, but the success toast includes an Undo action that restores the opportunity back to new status.

Bulk actions get the harder confirm gate since the blast radius is higher and there's no undo; single dismiss uses the lighter undo-toast pattern per the issue's suggested fix.

Related issue

Closes #611

Type of change
fix — Bug fix
How to test
Go to /dashboard/content with a brand that has new opportunities
Click the dismiss (X) button on a single row → toast shows "Opportunity dismissed" with an Undo button → click Undo → row returns to new status
Select multiple rows → click "Dismiss All" → confirm dialog shows the exact count → Cancel leaves rows untouched → confirming dismisses them
Repeat the single-dismiss check on /dashboard/content/[id] detail page
Checklist
Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
Commits follow Conventional Commits
yarn lint passes (run from web/)
yarn typecheck passes (run from web/)
yarn format:check passes (run from web/)
Changes are focused — one concern per PR

Note on format:check: yarn format:check fails repo-wide on this branch due to CRLF line endings introduced by a Windows checkout — pre-existing and unrelated to this change, affecting files this PR doesn't touch. The three files this PR actually modifies (web/messages/en.json, content/page.tsx, content/[id]/page.tsx) are individually Prettier-clean, verified via:

npx prettier --check web/messages/en.json "web/src/app/[locale]/(dashboard)/dashboard/content/page.tsx" "web/src/app/[locale]/(dashboard)/dashboard/content/[id]/page.tsx"

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Welcome to Ansvisor, and thank you for your first PR! A maintainer will be by soon to review.

In the meantime, two things that make review faster:

  • A short description of why the change matters, not just what it does — most of our PRs link a Fixes #... to the issue that explains the why.
  • A quick local test note if there's anything worth eyeballing in the browser.

If you'd like to keep an eye on where Ansvisor goes next, a ⭐ on the repo helps others discover it (and Watch sends you a ping when related issues land). Either way — looking forward to your next one.

@gkhngyk gkhngyk left a comment

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.

Nice work — the dual pattern (confirm dialog for bulk, undo-toast for single dismiss) is exactly what #611 called for, and the Dialog usage matches the audit page pattern correctly.

One copy fix needed before merge: the dialog says "You can restore them individually afterward", but that's not true — row actions only render for status === 'new' on both the list and detail pages, so there is no UI path to restore a dismissed opportunity (the undo toast is the only one, and bulk doesn't have it). Users would confirm the bulk dismiss believing it's recoverable.

Please reword bulk.dismissAllConfirm to be honest about that, e.g.:

"{count, plural, one {This will dismiss # opportunity.} other {This will dismiss # opportunities.}} This can't be undone."

Everything else looks good — happy to approve once that line is updated.

@Adarshhic

Copy link
Copy Markdown
Contributor Author

Good catch — you're right, row actions only render for status === 'new' on both pages, so there's genuinely no UI path to restore a bulk-dismissed opportunity. Updated the copy to "This can't be undone." Pushed in the latest commit.

@gkhngyk gkhngyk left a comment

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.

Copy fix looks right — the dialog is honest about irreversibility now. The dual pattern (confirm for bulk, undo-toast for single dismiss) closes #611 nicely. Thanks!

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.

Content Optimization: Dismiss and Dismiss All fire immediately with no confirmation or undo

2 participants