Skip to content

feat(layout): reach the brands page and the brand's settings from the brand switcher - #1339

Merged
gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:feature/sidebar-brand-switcher
Oct 22, 2026
Merged

gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:feature/sidebar-brand-switcher

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

From the user: the brands page and a brand's settings are reached from the brand switcher at the top of the menu, not from a sidebar item.

  • The sidebar's "Brands" item is gone. Its group held only that item, so the menu now starts at Execution.
  • Brand switcher list: "Show My All Brands" (opens /dashboard/brands) sits just above "Add Brand".
    • "Add Brand" now opens /dashboard/brands/new directly, as the empty-state button already did. Before, it opened the brands list, which "Show My All Brands" now does.
  • Settings icon beside the selected brand (not on the brands in the list):
    • it has a "Visit Brand Setting" tooltip;
    • it opens that brand's own /dashboard/brands/<id>/settings;
    • it's a sibling of the switcher's trigger, not inside it, so the name and the up/down chevron still open the menu, and the icon opens only the settings.
    • It's hidden in the collapsed sidebar, where only the logo fits.
  • Mobile menu: it had no brand switcher; the Brands item was its only way to the brands page. It now has the same switcher at the top of the sheet, which closes on navigation (onNavigate).
  • Clean-up: getDashboardNavLabel drops its brands namespace branch and the tBrands argument, which only "Brands" used (sidebar, mobile menu, onboarding preview).

Web only.

Related issue

None. Product feedback from the user.

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

How to test

  1. The sidebar has no "Brands" item.
  2. Hover the ⚙ beside the brand's name: "Visit Brand Setting". Click it: the brand's settings open, and the menu stays closed.
  3. Click the brand's name or the chevron: the menu opens with the brands, then "Show My All Brands" (→ brands page) and "Add Brand" (→ new brand).
  4. Collapse the sidebar: only the logo shows, and the menu still opens from it.
  5. At phone width, open ☰: the switcher is at the top.

Checked in light and dark, at 1024 px, collapsed, and at phone width.

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

yarn test: 282 files, 2,487 tests pass. yarn build passes with CI's placeholders.

🤖 Generated with Claude Code

… brand switcher

From the user's request:
- The sidebar's Brands item is gone. Its group only held that item,
  so the menu now starts at Execution.
- In the brand switcher's list, "Show My All Brands" (the brands page)
  sits above "Add Brand", which now opens the new-brand page directly.
- A settings icon beside the selected brand opens that brand's
  settings, with a "Visit Brand Setting" tooltip. It is a sibling of the
  switcher's trigger, so the name and the chevron still open the menu.
  It is hidden in the collapsed sidebar, where only the logo fits.
- The mobile menu had no brand switcher, and the Brands item was its
  only way to the brands page. It now has the switcher at the top.
- getDashboardNavLabel loses the brands namespace, which only Brands
  used.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

@gkhngyk This one is the user's sidebar change: the Brands item is gone, and the brand switcher now leads to the brands page ("Show My All Brands") and, through a ⚙ next to the selected brand, to that brand's settings. Heads-up: because the Brands item was the mobile menu's only way to the brands page, the mobile sheet now gets the same switcher at the top. It's web only; tests (2,487) and the build pass. A follow-up stacked on this adds a brand switch on the settings page itself.

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

One fix before merge, one small one:

  1. The settings icon opens edit controls the server refuses. web/src/components/layout/brand-switcher.tsx:160

    The icon shows for every role, which is fine: analysts need the brand's Tracking tab too. But on brands/[id]/settings/page.tsx only Shopping mode and Pause check the role. These still offer a write:

    • General → Save (:346)
    • Domains → add/remove/Save (:625, :666)
    • Competitors → add/delete (:784, :841)
    • Danger → Delete (:1042)

    For analysts and agency partners, RLS refuses the General and Domains writes (brands and brand_domains update are admin/manager only). updateBrand then throws, and in production the toast shows the masked server-action message. The server deletes a brand for admins only, so managers get a 403 on Delete too.

    This was already true from the brand cards. The icon puts the page one click away from every screen, though, so please gate it here:

    • General, Domains and Competitors on canManage;
    • Danger on canAdmin;
    • a short read-only note, the way ShoppingModeCard and PauseBrandCard do it;
    • role cases in settings/page.test.tsx, next to the existing ones.
  2. "Add Brand" for roles that can't add one. brand-switcher.tsx:149 (and the empty state at :48)

    brands: admin/manager insert refuses analysts and agency partners. The item now jumps straight into the wizard, which fails on its first Continue with the masked error. Show it only when useUserRole().canManage is true, as #1341 does for Workspace Settings.

    Also, at the plan's brand limit the item used to go through the brands page's upgrade button. Now it reaches the wizard and fails on its first step (the plan_limit toast). Fine as a follow-up, e.g. the wizard checking the limit when it loads.

The rest looks right. The sidebar group is gone with nothing indexing it. getDashboardNavLabel has no other callers. The mobile sheet closes on navigation. Colors stay on --primary.

The settings icon puts a brand's settings one click from every page, so
its writes now follow the server's rules: General, Domains and Competitors
are a disabled fieldset for anyone but admins and managers (brands and
brand_domains update, competitors writes), and Danger's delete for anyone
but admins, each with a read-only note. The switcher's Add Brand, and its
empty state, show only to admins and managers (brands: admin/manager
insert), so no one lands in a wizard that fails on its first step.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

@gkhngyk Thanks, both are in ae91c00d:

  1. Settings writes follow the role. On brands/[id]/settings, General, Domains and Competitors wrap their content in a <fieldset disabled={!canManage}>, so the inputs, the Save buttons, add/remove and the selects' triggers are all disabled. Each shows "Only admins and managers can change these settings." Danger's fieldset uses canAdmin, with "Only admins can delete a brand." Tracking stays open to everyone. New role cases in settings/page.test.tsx:
    • an analyst sees all four tabs locked, with the notes;
    • a manager can edit but not delete;
    • an admin can delete.
  2. Add Brand only for canManage, in the switcher's menu and its empty state, with a test.

Tried in the browser with the demo user temporarily set to analyst, then set back to admin. Web: 2,491 tests and the build pass. The plan-limit check in the wizard stays a follow-up, as you said.

Merged forward into #1340 (1cf817ac) and #1341.

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

Looks good. Both items from the last review are done:

  • General, Domains and Competitors are in a fieldset that is disabled unless canManage. Danger is disabled unless canAdmin. Each has a read-only note, and the role cases are in settings/page.test.tsx.
  • The switcher's Add Brand, and its empty state, show only with canManage, with a test.

Two small follow-ups, fine after merge:

  1. The Competitors tab here is now manager-only, but the Competitors page and the citations Add competitor button still offer adding and removing to every role. We'll decide which way to align them and follow up separately.
  2. At the plan's brand limit, the switcher's Add Brand goes straight to the wizard, which fails on its first step.

Tested on top of main together with #1340, #1341, #1352 and #1337: web and server tests, tsc, lint and Prettier pass.

@gkhngyk
gkhngyk merged commit babe261 into ansvisor:main Oct 22, 2026
5 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.

2 participants