Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@devkiran
Copy link
Collaborator

@devkiran devkiran commented Oct 2, 2025

Summary by CodeRabbit

  • New Features

    • Added Duplicate Link action with a dedicated modal and Duplicate button.
    • Introduced keyboard shortcuts: E (Edit), Q (QR), D (Duplicate) with on-button hints.
    • Exposed global menu/popover state so link actions can be coordinated across the UI.
  • UX Improvements

    • Link modal now distinguishes creating vs editing: updated headers, button labels, and success messages.
    • Destination fields disabled when editing to prevent changes.
    • Card clicks no longer open the edit modal; actions handled via embedded controls for more consistent popover/menu behavior.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 2, 2025

Walkthrough

Adds shared UI state for open link action menus via context, refactors partner link card to use a new Controls component, introduces keyboard shortcuts and a Duplicate Link flow with a new modal, and updates the Partner Link modal to explicitly handle create vs edit modes.

Changes

Cohort / File(s) Summary
Context state plumbing
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/page-client.tsx
Adds openMenuLinkId local state and setOpenMenuLinkId, and exposes both through PartnerLinksContext for descendant components.
Card refactor to Controls
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsx
Replaces inline modal/open-modal logic with a memoized internal Controls component that consumes card/context state and renders PartnerLinkControls; removes direct PartnerLinkModal invocation and related state.
Controls overhaul + shortcuts + Duplicate
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-controls.tsx
Changes API to accept openPopover, setOpenPopover, shortcutsEnabled; introduces keyboard shortcuts (E/Q/D) to open Edit, QR, and Duplicate modals; adds DuplicateLinkModal and Duplicate action; moves popover state external; minor import/class adjustments.
Modal create/edit separation
apps/web/ui/modals/partner-link-modal.tsx
Introduces isEditingLink/isCreatingLink flags, uses them to choose HTTP method and API path (PATCH vs POST), disable inputs, adjust labels/toasts, and control save behavior/UI text.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Page as ProgramLinksPageClient
  participant Ctx as PartnerLinksContext
  participant Card as PartnerLinkCard
  participant Ctrl as PartnerLinkControls
  participant M_Edit as PartnerLinkModal
  participant M_QR as LinkQRModal
  participant M_Dup as DuplicateLinkModal
  participant API as /api/partner-links

  User->>Card: hover/click card
  Card->>Ctx: read/write openMenuLinkId
  Card->>Ctrl: render with openPopover/setOpenPopover, shortcutsEnabled

  alt user opens actions
    User->>Ctrl: click actions button
    Ctrl-->>User: show popover with actions (Edit, QR, Duplicate)
  end

  par keyboard shortcuts (if enabled)
    User->>Ctrl: press E
    Ctrl->>M_Edit: open Edit modal
    User->>Ctrl: press Q
    Ctrl->>M_QR: open QR modal
    User->>Ctrl: press D
    Ctrl->>M_Dup: open Duplicate modal
  end

  rect rgba(235,245,255,0.6)
  User->>M_Edit: save changes
  M_Edit->>API: PATCH /partner-links/{id}
  API-->>M_Edit: 200
  M_Dup->>API: POST /partner-links
  API-->>M_Dup: 201
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • steven-tey

Poem

A rabbit taps E, Q, then D with delight,
Popovers bloom in the dashboard light.
Edit, QR, or copy a twin on cue—
PATCH or POST, a fresh link anew.
Carrots saved, the UI hops through. 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title Check ❓ Inconclusive The title “Partner link card updates” uses a generic term and only highlights one aspect of the changeset, omitting key enhancements like context state management, keyboard shortcuts, and the duplicate link flow, so it does not clearly convey the main changes. Consider revising the title to clearly reflect the primary functionality added, for example “Add duplicate link support and context state to partner link controls,” so it accurately summarizes the main changes.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch duplicate-partner-links

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 17abdf4 and ae493f7.

📒 Files selected for processing (2)
  • apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-controls.tsx (5 hunks)
  • apps/web/ui/modals/partner-link-modal.tsx (7 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
apps/web/ui/modals/partner-link-modal.tsx (1)
apps/web/lib/swr/use-program-enrollment.ts (1)
  • useProgramEnrollment (7-37)
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-controls.tsx (2)
apps/web/lib/types.ts (1)
  • PartnerProfileLinkProps (440-440)
apps/web/ui/modals/partner-link-modal.tsx (2)
  • usePartnerLinkModal (581-606)
  • PartnerLinkModal (64-81)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (12)
apps/web/ui/modals/partner-link-modal.tsx (7)

172-173: LGTM: Cleaner mode detection for edit/create/duplicate flows.

The introduction of isEditingLink and isCreatingLink flags provides explicit, self-documenting mode detection. This is superior to the previous Boolean(link) pattern, especially since it correctly handles the duplicate flow where link exists but link.id is empty.


229-236: LGTM: Save button logic correctly uses the new flags.

The saveDisabled logic appropriately uses isEditingLink to determine whether to check for dirty state (edit mode) or available destination domains (create mode).


266-269: LGTM: API call correctly branches on edit vs create.

The API path construction and HTTP method selection properly use isEditingLink to append the link ID and select PATCH vs POST.


296-305: LGTM: Success messaging correctly handles create vs update.

The toast and clipboard logic appropriately uses isCreatingLink to provide context-specific feedback for new links vs updates.


316-316: LGTM: Modal header text reflects the correct mode.

The header text correctly uses isEditingLink to display "Edit Link" vs "New Link".


408-408: LGTM: Destination domain correctly disabled when editing.

The disabled state for the destination domain combobox correctly uses isEditingLink, preventing users from changing the destination domain when editing an existing link.


490-490: LGTM: Save button text reflects the correct action.

The button text correctly uses isEditingLink to display "Save changes" vs "Create link".

apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-controls.tsx (5)

10-20: LGTM: External popover state enables coordinated UI flows.

The updated signature accepts external openPopover and setOpenPopover props along with shortcutsEnabled, allowing parent components to coordinate popover state and control keyboard shortcut behavior. This aligns with the broader PR changes that introduce shared context for link action menus.


32-41: LGTM: Duplicate link flow correctly reuses the modal with modified props.

The duplicate modal is cleverly initialized by passing the existing link with a blank id (triggering create mode per the modal's isEditingLink logic) and a modified key using nanoid(6) to prevent collisions. This approach avoids code duplication while ensuring the duplicate flow behaves correctly.


43-63: LGTM: Keyboard shortcuts improve UX for power users.

The shortcuts (E for Edit, Q for QR Code, D for Duplicate) are properly gated by shortcutsEnabled and use priority 1 to ensure they take precedence. The popover is closed before opening modals, providing a clean user experience.


69-69: LGTM: Duplicate button and modal properly integrated.

The DuplicateLinkModal is rendered alongside existing modals, and the Duplicate button correctly opens it with appropriate icon, shortcut hint, and styling.

Also applies to: 96-106


82-82: LGTM: Shortcut hints provide discoverability.

Adding shortcut hints (E, Q, D) to the respective buttons improves discoverability of the keyboard shortcuts for users.

Also applies to: 93-93, 104-104


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 and usage tips.

@vercel
Copy link
Contributor

vercel bot commented Oct 2, 2025

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

Project Deployment Preview Updated (UTC)
dub Ready Ready Preview Oct 2, 2025 6:49am

@steven-tey steven-tey merged commit 985dae1 into main Oct 2, 2025
8 checks passed
@steven-tey steven-tey deleted the duplicate-partner-links branch October 2, 2025 07:13
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.

3 participants