Skip to content

fix(content): show a member the webhook settings read-only, so Test and Save aren't pressed only to be refused - #1673

Merged
gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:fix/webhook-test-members
Oct 28, 2026
Merged

gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:fix/webhook-test-members

Conversation

@cihan-gyk

@cihan-gyk cihan-gyk commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Follow-up from #1605 (item 2): a member sees the webhook settings read-only, so they don't press Test or Save only to be refused.

Only admins and managers can save a brand's webhook (webhook_configs RLS) and test it (the API's assertWebhookEditor). A member saw Test Webhook and Save Webhook like anyone else, and only found out after pressing: a "forbidden" test result, or a failed save.

  • The dialog reads the role (useUserRole; it comes from the server layout, so the form doesn't flash editable first).
  • For a member:
    • the address, secret, events and Active switch show as they are, but disabled;
    • Test and Save are disabled;
    • a line says "Only admins and managers can change or test this webhook."
  • Review fix (2d1658b): the hand-made Active switch is dimmed with disabled: styles, like the checkboxes beside it.
  • The webhooks docs say members see the settings read-only.

Checked in the browser (local, 1024 px; demo user set to analyst for the check, then back to admin): the note shows, and every field and button except Close is disabled.

Related issue

Follow-up from #1605's review.

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

cd web && npx vitest run "src/app/[locale]/(dashboard)/dashboard/content/_webhook-settings.test.tsx"

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

Full checks were run in one tree with this batch's ten follow-up branches merged, and again after the review fixes:

  • server format, lint and npm test: 246 files, 3,343 tests passed;
  • web format, lint (0 errors; 7 warnings already on main), typecheck and build: all pass;
  • web vitest: 447 files, 4,352 tests passed (after the review fixes).

A pre-push review was run on all ten branches.

🤖 Generated with Claude Code

cihan-gyk and others added 2 commits October 28, 2026 05:30
…nd Save aren't pressed only to be refused

Follow-up from ansvisor#1605 (item 2). Only admins and managers can save a
brand's webhook (webhook_configs' RLS) and test it (the API's
assertWebhookEditor). A member saw Test Webhook and Save Webhook as for
anyone and learned they couldn't only after pressing: a "forbidden" test
result, or a failed save.

The dialog now reads the role (useUserRole): for a member the address,
secret, events and on/off switch show as they are but disabled, Test and
Save are disabled, and a line says "Only admins and managers can change
or test this webhook." The webhooks docs say members see it read-only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…her disabled fields

Review follow-up. The hand-made Active switch had no disabled styles, so
a member saw it in full colour with the pointer cursor although it does
nothing. It now takes disabled:cursor-not-allowed disabled:opacity-50,
as the disabled checkboxes beside it do.

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

mintlify Bot commented Oct 28, 2026

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 2d1658b.

Approve preview

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

What I checked:

  • Merge. Two commits (41705de, 2d1658b) on 3f6a4d4. It merges clean on main (b591947), alone and together with #1668 and #1672. #1668 changes the Delivery line two lines above this PR's docs line, and the two merge without a conflict.
  • Role. useUserRole().canManage is admin or manager. That matches the API's WEBHOOK_ROLES and the webhook_configs write policies. The role comes from RoleProvider in the dashboard layout, which is server-rendered, so the form doesn't show as editable first. With no provider, the context falls back to analyst, so the form is read-only.
  • Dialog.
    • For a member, the address, secret, event checkboxes and Active switch are disabled, and so are Test and Save.
    • Close still works.
    • The note shows above the form.
    • The switch's disabled: styles match the checkboxes.
    • Nothing changes for admins and managers.
  • Tests.
    • At the head, _webhook-settings.test.tsx passes (8).
    • With main's _webhook-settings.tsx under the head's test, the new member test fails.
    • CI passes.
  • Before the API deploy. This is web only and doesn't depend on the API.
  • Speed. No regex and no loop.

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