-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Update program configuration Links tab #2510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe changes introduce a new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Form
participant ProgramLinkConfiguration
participant DomainVerificationService
participant WorkspaceContext
User->>Form: Interacts with form (create/update program)
Form->>ProgramLinkConfiguration: Renders with domain/url props
ProgramLinkConfiguration->>WorkspaceContext: Fetch workspace info
ProgramLinkConfiguration->>DomainVerificationService: Fetch domain status (SWR)
User->>ProgramLinkConfiguration: Selects domain / enters URL
ProgramLinkConfiguration->>Form: Calls onDomainChange/onUrlChange handlers
Form->>Form: Updates form state accordingly
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2510:
To re-run the tests, please comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/web/ui/partners/program-link-configuration.tsx (1)
142-155: Null-safe access is fine, but a guard would remove the optional chain
linkStructureOptions?.[0].exampleis safe but still rendersundefinedif the util returns an empty array. If that can happen, consider short-circuiting to avoid a blank line in the UI.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/form.tsx(2 hunks)apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/form.tsx(1 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/settings/links/links-settings.tsx(4 hunks)apps/web/lib/actions/partners/onboard-program.ts(1 hunks)apps/web/ui/partners/program-link-configuration.tsx(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/form.tsx (1)
apps/web/ui/partners/program-link-configuration.tsx (1)
ProgramLinkConfiguration(19-163)
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/settings/links/links-settings.tsx (1)
apps/web/ui/partners/program-link-configuration.tsx (1)
ProgramLinkConfiguration(19-163)
apps/web/ui/partners/program-link-configuration.tsx (2)
apps/web/lib/types.ts (1)
DomainVerificationStatusProps(196-202)apps/web/ui/domains/domain-configuration.tsx (1)
DomainConfiguration(6-123)
🔇 Additional comments (4)
apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/form.tsx (1)
80-84:maxDurationremoved from the watch list – confirm no downstream dependency
maxDurationis no longer watched. A quick scan shows it is not used in this component (it lives insideNewProgramForm), so this looks safe.
Please double-check that no validation / side-effect elsewhere relied on the parent form re-rendering whenmaxDurationchanged.apps/web/lib/actions/partners/onboard-program.ts (1)
16-19: Logic change may allow multiple programs whendefaultProgramIdisnullbut other programs existSwitching from “count any program” to “check
defaultProgramId” means a workspace that already created additional programs (but never set a default) could now create yet another one.
Verify that this behavioural change is intentional and that no invariant elsewhere assumes exactly one program per workspace.apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/settings/links/links-settings.tsx (1)
90-100: Good use of the newProgramLinkConfigurationcomponentIntegrating the shared component removes a lot of duplicated logic and keeps the form succinct. The
watch → setValuecallbacks are wired correctly and dirty-state is preserved.
Nice refactor!apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/form.tsx (1)
159-166: 👍 Clean hand-off to the shared link configuration componentThis drops a sizeable amount of bespoke domain logic and centralises it behind
ProgramLinkConfiguration, improving maintainability. Props are correctly typed andsetValuemarks the field dirty. Looks solid.
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2510:
To re-run the tests, please comment |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (1)
apps/web/ui/partners/program-link-configuration.tsx (1)
33-35:⚠️ Potential issueEncode
domainwhen constructing the verification URLThis security issue (path-injection / SSRF) was flagged in an earlier review but is still present. Use
encodeURIComponentbefore interpolatingdomaininto the path:- ? `/api/domains/${domain}/verify?workspaceId=${workspaceId}` + ? `/api/domains/${encodeURIComponent(domain)}/verify?workspaceId=${workspaceId}`
🧹 Nitpick comments (4)
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/settings/links/links-settings.tsx (1)
72-101: Watch → re-render dependency is safe but a bit expensive
const [domain, url] = watch(["domain", "url"]);subscribes the component to every change inside the form; this means the parent form will re-render even when unrelated fields mutate.
A lightweight alternative is to subscribe only to the specific fields viauseWatch:-import { useForm, useWatch } from "react-hook-form"; ... -const [domain, url] = watch(["domain", "url"]); +const domain = useWatch({ control, name: "domain" }); +const url = useWatch({ control, name: "url" });This avoids unnecessary re-renders when large forms grow.
apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/form.tsx (1)
159-166: Passnullnotundefinedto child props
watchreturnsundefinedfor untouched fields, yetProgramLinkConfiguration’s prop types expectstring | null.
Consider normalising the values to keep the prop contract explicit:- domain={domain} - url={url} + domain={domain ?? null} + url={url ?? null}apps/web/ui/partners/program-link-configuration.tsx (2)
39-43: MemoiselinkStructureOptions
getLinkStructureOptionscould be computationally heavy. Wrap it inuseMemoto avoid recomputation on every keystroke:- const linkStructureOptions = getLinkStructureOptions({ domain, url }); + const linkStructureOptions = useMemo( + () => getLinkStructureOptions({ domain, url }), + [domain, url], + );
95-104: Validate destination URL before propagatingCurrently any string that passes the browser’s
<input type="url">filter is accepted.
Consider basic runtime validation (e.g.https?://) and display inline feedback to avoid bad data entering the DB.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/form.tsx(2 hunks)apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/form.tsx(1 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/settings/links/links-settings.tsx(4 hunks)apps/web/lib/actions/partners/onboard-program.ts(1 hunks)apps/web/ui/partners/program-link-configuration.tsx(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/form.tsx (1)
apps/web/ui/partners/program-link-configuration.tsx (1)
ProgramLinkConfiguration(20-165)
apps/web/ui/partners/program-link-configuration.tsx (2)
apps/web/lib/types.ts (1)
DomainVerificationStatusProps(196-202)apps/web/ui/domains/domain-configuration.tsx (1)
DomainConfiguration(6-123)
🔇 Additional comments (1)
apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/form.tsx (1)
80-84: Confirm removal ofmaxDurationfrom the top–level watcher
maxDurationis now watched only insideNewProgramForm, which is fine as long as no logic outside that component relies on immediate updates of that field. Please double-check callers (e.g. button disabling, validation) to ensure no regressions slipped in after this change.
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2510:
To re-run the tests, please comment |
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2510:
To re-run the tests, please comment |
Summary by CodeRabbit
New Features
Refactor
Chores