Skip to content

feat(brands): open the workspace's settings from the brand pages - #1341

Merged
gkhngyk merged 8 commits into
ansvisor:mainfrom
cihan-gyk:feature/workspace-settings-menu
Oct 22, 2026
Merged

gkhngyk merged 8 commits into
ansvisor:mainfrom
cihan-gyk:feature/workspace-settings-menu

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

From the user: the brands page and a brand's page should have a "Workspace Settings" button at the top right, opening Account, Organization, Team and Billing. Each should open its settings section. Admins and managers only.

  • Where:
    • /dashboard/brands, just left of "Add Brand";
    • the brand page's header (/dashboard/brands/<id>/…), right side. The header is shared, so it shows on Topics, Prompts and Settings.
  • The menu: Account, Organization, Team, Billing. Each opens its own address, /dashboard/settings/<section> (e.g. /dashboard/settings/team).
  • Who sees it:
    • admins and managers only (useUserRole().canManage). Analysts and agency partners don't see the button at all;
    • Billing only where the settings page has it (hasSettingsSection: Ansvisor Cloud), so self-host lists three.
    • A manager can open Organization but, as today, only an admin can edit it.
  • Phone width: both headers now wrap (flex-wrap), since the new button pushed them past the screen.
  • Copy: one new string, brands.workspaceSettings. The section names reuse settings.*.

Web only.

Stacked on #1340 (and #1339 below it), which changes the same brand page header. This PR's own commit is 7b9e7f32.

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. As an admin or a manager, open /dashboard/brands: "Workspace Settings" sits top right, left of "Add Brand".
  2. Click it: Account, Organization, Team (and Billing on Cloud). Click Team: Settings opens on Team.
  3. Open a brand's page (/dashboard/brands/<id>/settings): the same button, top right.
  4. As an analyst, neither page shows the button.
  5. At phone width, the button wraps below the title instead of running off the screen.

Checked in light and dark, at 1024 px, 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: 285 files, 2,499 tests pass. yarn build passes with CI's placeholders.

🤖 Generated with Claude Code

cihan-gyk and others added 3 commits October 22, 2026 11:11
… 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]>
Arrows beside the brand's name list the brands; picking another opens the
same page of that brand (its settings, from the settings) and makes it the
brand the app shows. The sidebar switcher keeps the brand page too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A Workspace Settings menu at the top right of the brands page and a brand's
page opens Account, Organization, Team and Billing (cloud only) at their own
addresses. Admins and managers only. The headers wrap on a phone.

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

Copy link
Copy Markdown
Collaborator Author

@gkhngyk Another small one, stacked on #1340 (this PR's own commit is 7b9e7f32): a Workspace Settings menu (Account / Organization / Team / Billing) at the top right of the brands page and a brand's page, for admins and managers only. Web only, no migration.

@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. One small follow-up:

  1. "Add Brand" beside it isn't role-gated. web/src/app/[locale]/(dashboard)/dashboard/brands/page.tsx:28

    Workspace Settings is hidden from analysts and agency partners. The Add Brand button next to it still shows to them, and RLS refuses the insert (brands: admin/manager insert). Please give it the same canManage gate as the switcher's item in #1339. The page is a server component, so either read profiles.role there or move the button into a small client component.

The rest checks out against the server:

  • Organization: edit is admin-only in the UI and in RLS (organizations: admin update).
  • Team: admin-only in the UI and in the server actions.
  • Billing: shown only where the settings page has it.

The canManage gate matches the request and has tests for each role. Stacked on #1340 and #1339, so it should merge after them.

cihan-gyk and others added 4 commits October 22, 2026 14:58
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]>
…-switch

# Conflicts:
#	web/src/components/layout/brand-switcher.test.tsx
…only

Workspace Settings beside it was already hidden from analysts and agency
partners; Add Brand (and the plan limit's upgrade button) now follows, read
from the profile's role on the server, as does the empty state's button.
brands: admin/manager insert would refuse the others on the wizard's first
step.

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

Copy link
Copy Markdown
Collaborator Author

@gkhngyk Your follow-up is in 8521c674, on top of #1339's fixes merged through #1340. The brands page reads profiles.role on the server and shows Add Brand, and the plan limit's upgrade button, only to admins and managers. The empty state's Add Brand uses useUserRole().canManage. A new brands/page.test.tsx covers each role and the limit case. Web: 2,508 tests and the build pass.

@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. Add Brand is gated as asked:

  • brands/page.tsx:54-60 reads the signed-in user's own profiles.role, so .single() is safe. The page hides both Add Brand and the plan-limit upgrade button from anyone who isn't an admin or manager.
  • The empty state's button (_brands-client.tsx:48) follows useUserRole().canManage.
  • brands/page.test.tsx covers each role and the upgrade case.

Two small follow-ups, neither blocking:

  1. The empty state's gate in _brands-client.tsx:48 has no test. One case beside page.test.tsx's would cover it.
  2. components/providers/brand-guard.tsx:84, the dashboard's no-brands state, still shows "Create Brand" to every role. That code is already on main, but it is the last Add Brand entry point without the gate.

This PR is stacked on #1340 and #1339, so merge it after them.

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

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