Skip to content

Scoped PAT: clean up RHF usage - #48485

Merged
djhi merged 33 commits into
scopedpat/root-branchfrom
scopedpat/react-hook-form-best-practices
Jul 30, 2026
Merged

djhi merged 33 commits into
scopedpat/root-branchfrom
scopedpat/react-hook-form-best-practices

Conversation

@djhi

@djhi djhi commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

We don't follow good practices using react-hook-form for the scoped PAT.
This PR aims to fix that:

  • pass control and setValue instead of form
  • call useWatch instead of form.watch

No functional nor visual changes

Summary by CodeRabbit

  • Bug Fixes
    • Improved the scoped access token creation flow so permission selections and configured counts update reliably.
    • Ensured the review step and final token creation use the validated settings entered in the form.
    • Reset dependent resource selections when changing access modes to prevent conflicting configurations.
    • Improved handling of account-level confirmation and token expiration settings.

@djhi
djhi requested a review from a team as a code owner July 30, 2026 09:51
@vercel

vercel Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
studio-self-hosted Ready Ready Preview Jul 30, 2026 1:49pm
studio-staging Ready Ready Preview Jul 30, 2026 1:49pm
5 Skipped Deployments
Project Deployment Actions Updated (UTC)
studio Ignored Ignored Jul 30, 2026 1:49pm
design-system Skipped Skipped Jul 30, 2026 1:49pm
docs Skipped Skipped Jul 30, 2026 1:49pm
ui-library Skipped Skipped Jul 30, 2026 1:49pm
zone-www-dot-com Skipped Skipped Jul 30, 2026 1:49pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Scoped token form components now use react-hook-form subscriptions and focused control/setValue props. Validated submission values are stored and reused for the review screen and final token creation.

Changes

Scoped token form state

Layer / File(s) Summary
Resource access form wiring
apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/ResourceAccessStep.tsx
Resource access fields use useWatch, control, and setValue for access-mode changes, dependent resets, and account confirmation.
Token details form wiring
apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/TokenDetails.tsx
Token details accept focused form props and watch customExpiryDate through useWatch.
Live state and review submission
apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/NewScopedTokenForm.tsx
Permission state is derived through useWatch, while validated submit values drive review and final token creation.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: awaseem

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the main idea but omits most required template sections, including current behavior and additional context. Add the required template sections: CONTRIBUTING acknowledgement, change type, current behavior with links to issues, new behavior, and additional context.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change to React Hook Form usage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch scopedpat/react-hook-form-best-practices

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@supabase

supabase Bot commented Jul 30, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project xguihxuzqibwxjnimxev because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@github-actions

github-actions Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results (next)

passed  243 passed
skipped  5 skipped

Details

stats  248 tests across 29 suites
duration  5 minutes, 6 seconds
commit  8ea6b80

Skipped tests

Features › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled
Features › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected
Features › sql-editor.spec.ts › SQL Editor › share with team works as expected
Features › sql-editor.spec.ts › SQL Editor › folders works as expected
Features › sql-editor.spec.ts › SQL Editor › other SQL snippets actions work as expected

Base automatically changed from scopedpat/scope-permissions-api to scopedpat/root-branch July 30, 2026 13:42
@djhi

djhi commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

🧹 Nitpick comments (2)
apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/NewScopedTokenForm.tsx (1)

52-53: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use a boolean-prefixed state name.

Rename showMissingPermissionsWarning to shouldShowMissingPermissionsWarning and update its setter/usages. As per coding guidelines, booleans should use an is, has, can, or should prefix.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/NewScopedTokenForm.tsx`
around lines 52 - 53, Rename the boolean state variable
showMissingPermissionsWarning to shouldShowMissingPermissionsWarning in
NewScopedTokenForm, rename its setter consistently, and update every reference
to both state values throughout the component.

Source: Coding guidelines

apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/TokenDetails.tsx (1)

39-40: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Avoid casting the Select value into the form union.

Validate value against EXPIRY_OPTIONS and pass the matched option value to setValue; the cast can admit an invalid string and violates the repository’s TypeScript guidance. As per coding guidelines, “Avoid TypeScript as casts.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/TokenDetails.tsx`
around lines 39 - 40, Update handleExpiryChange to validate the incoming value
against EXPIRY_OPTIONS, locate the matching option, and pass its value to
setValue with shouldValidate enabled. Remove the TypeScript as cast and preserve
the existing behavior for valid expiry selections.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/NewScopedTokenForm.tsx`:
- Around line 52-53: Rename the boolean state variable
showMissingPermissionsWarning to shouldShowMissingPermissionsWarning in
NewScopedTokenForm, rename its setter consistently, and update every reference
to both state values throughout the component.

In
`@apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/TokenDetails.tsx`:
- Around line 39-40: Update handleExpiryChange to validate the incoming value
against EXPIRY_OPTIONS, locate the matching option, and pass its value to
setValue with shouldValidate enabled. Remove the TypeScript as cast and preserve
the existing behavior for valid expiry selections.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 723b7da1-05be-4a9f-8d15-c306b3c02e47

📥 Commits

Reviewing files that changed from the base of the PR and between 1e26457 and 8ea6b80.

📒 Files selected for processing (3)
  • apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/NewScopedTokenForm.tsx
  • apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/ResourceAccessStep.tsx
  • apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/TokenDetails.tsx

@djhi
djhi merged commit 1fcc5a3 into scopedpat/root-branch Jul 30, 2026
28 checks passed
@djhi
djhi deleted the scopedpat/react-hook-form-best-practices branch July 30, 2026 14:02
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