chore(admin): deeplink to RP when creating WAF bypass token#20630
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves the FxA Admin Panel workflow for creating WAF bypass tokens by preserving relying party (RP) context when navigating from an RP detail view to the WAF Tokens page, using query params to prefill the create-token form.
Changes:
- Add support in the WAF Tokens page to consume
createForClientIdandnamequery params, auto-open the create form, and then clear those params from the URL. - Add unit tests covering auto-open/prefill behavior and query param clearing.
- Update the Relying Parties page to deeplink to the WAF Tokens page with the appropriate prefill query params.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/fxa-admin-panel/src/components/PageWafTokens/index.tsx | Consume query params to prefill/auto-open the create token form and clear params from the URL. |
| packages/fxa-admin-panel/src/components/PageWafTokens/index.test.tsx | Add tests validating prefill/auto-open behavior and query param cleanup. |
| packages/fxa-admin-panel/src/components/PageRelyingParties/index.tsx | Update RP panel link to deeplink into token creation with RP context. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8a2a3e6 to
96dab23
Compare
LZoog
left a comment
There was a problem hiding this comment.
I see it working locally, so r+!
| it('auto-opens create form with RP preselected and name prefilled from query params', async () => { | ||
| renderPage( | ||
| `/waf-tokens?createForClientId=${encodeURIComponent( | ||
| MOCK_RP_A.id! |
There was a problem hiding this comment.
Not sure off the top of my head why id can be undefined when I see MOCK_RP_A set with an id and I see id: string; on RelyingPartyDto 🤔
There was a problem hiding this comment.
Good Q — these fixtures are typed Partial<RelyingPartyDto> (to avoid filling in the ~10 fields the test doesn't read), which makes every property optional. So even though the literal sets id, TS widens MOCK_RP_A.id to string | undefined and needs the !...
| <NavLink | ||
| to={`/waf-tokens?createForClientId=${encodeURIComponent( | ||
| id | ||
| )}&name=${encodeURIComponent(name)}`} |
There was a problem hiding this comment.
The alternative here was just to use the router state like <NavLink to="/waf-tokens" state={{ clientId, name }}> and then read it on the other page. It would persist across a refresh too and we wouldn't have to delete the params after reading them on the next page. Usually we use query params for some external state but I think this is OK too if you prefer it as the work has already been done - if we ever want to send this as a link, this will work better🤷♀️
Because
This pull request
createForClientIdandnamequery params so the WAF bypass form is prefilled with RP context.Issue that this pull request solves
Closes: FXA-13769
Checklist
Put an
xin the boxes that applyTo test
Expected results with change: you are navigated to the WAF bypass token panel, and the "generate token" flow is active with the RP details pre-populated.
Expected results without change: you are navigated to the WAF bypass token panel.