Skip to content

feat: add topic creation from topics dashboard - #522

Merged
gkhngyk merged 2 commits into
ansvisor:mainfrom
BharadwajKanneveti:feature/add-topic-action-to-topics-page
Jul 24, 2026
Merged

gkhngyk merged 2 commits into
ansvisor:mainfrom
BharadwajKanneveti:feature/add-topic-action-to-topics-page

Conversation

@BharadwajKanneveti

Copy link
Copy Markdown
Contributor

Summary

  • Added the ability to create topics directly from the Topics dashboard.
  • Previously, topic creation was only available under Brand Settings → Topics, making the main Topics page read-only. This PR adds an Add Topic flow directly from the dashboard for users with write access.

Changes:

  • Added an Add Topic button to the Topics dashboard header.
  • Added the same Add Topic action to the empty leaderboard state.
  • Added a dialog-based topic creation flow for the active brand.
  • Reused the existing createTopic(brandId, name) action.
  • Added validation for empty topic names and duplicate topic names.
  • Refreshes the leaderboard after successful topic creation.
  • Added a success toast with guidance to assign prompts for tracking.
  • Restricted topic creation based on canManage permission.

Related issue

Closes #462

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

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

@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.

Functionally this is very close — the singular createTopic trap from #462 is correctly avoided, both buttons are canManage-gated, and the post-add flow (close → refresh → assign-prompts toast) matches the issue exactly. Two small asks before approval:

  1. Double-submit guard (real bug): the Input's Enter handler doesn't check isAdding — the button disables during the await, but pressing Enter again while createTopic + loadData are in flight runs handleAddTopic a second time, and the client-side duplicate check passes because topics hasn't refreshed yet → two topics with the same name. One line fixes it: if (isAdding) return; at the top of handleAddTopic.

  2. i18n: this page was wired to next-intl in #517 (your base includes it), so the new strings ("Add Topic", "Create a new topic for this brand.", "Cancel", both toasts) should go through the topics namespace in web/messages/en.json rather than reintroducing hardcoded English to a freshly-wired page.

Everything else is good to go — happy to approve once these two land.

@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.

Both points addressed cleanly — the isAdding guard covers the Enter path and all new strings are in the topics namespace. Thanks! (Non-blocking nit: the input placeholder "e.g. Industry, Comparison..." is the one string still hardcoded — fine to leave for a follow-up.)

@gkhngyk
gkhngyk merged commit 9579f37 into ansvisor:main Jul 24, 2026
3 checks passed
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.

Topics: add an "Add topic" action to the main Topics page

2 participants