Skip to content

Conversation

AshishViradiya153
Copy link
Contributor

@AshishViradiya153 AshishViradiya153 commented Jul 11, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a "Secured by Papermark" option for dataroom links, allowing users to enable a security badge on supported links.
    • Added a visual footer indicating when a link is secured by Papermark, with an optional close button.
    • Updated onboarding and link options to support the new security feature.
  • Bug Fixes

    • None.
  • Chores

    • Database updated to support "Secured by Papermark" status for links and presets.

@AshishViradiya153 AshishViradiya153 requested a review from mfts as a code owner July 11, 2025 09:49
Copy link

vercel bot commented Jul 11, 2025

@AshishViradiya153 is attempting to deploy a commit to the mftsio Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Jul 11, 2025

Walkthrough

A new boolean property, securedByPapermark, is introduced across the database schema, API, and frontend components to indicate whether a link or dataroom is secured by Papermark. New UI sections and a footer component are added to display and control this flag, with supporting logic in API endpoints and database migrations.

Changes

Files/Paths Change Summary
prisma/schema/link.prisma, prisma/migrations/.../migration.sql Added securedByPapermark boolean field to Link and LinkPreset models/tables; dropped an index
pages/api/links/index.ts, pages/api/links/[id]/index.ts, pages/api/links/domains/... API endpoints updated to handle securedByPapermark in create, update, and fetch operations
pages/api/links/[id]/documents/[documentId].ts Added securedByPapermark to Prisma select for link data
components/links/link-sheet/index.tsx Default link props/type extended with securedByPapermark
components/links/link-sheet/link-options.tsx, components/welcome/containers/onboarding... Added conditional rendering of SecuredByPapermarkSection based on link type
components/links/link-sheet/secured-by-papermark-section.tsx New component for toggling the "Secured by Papermark" flag in link options
components/links/links-table.tsx Internal logic updated to include securedByPapermark in edit handler
components/view/dataroom/dataroom-document-view.tsx Conditionally renders SecuredByPapermark footer if flag is set
components/view/dataroom/dataroom-view.tsx Passes securedByPapermark prop to viewer component
components/view/viewer/dataroom-viewer.tsx Accepts and uses securedByPapermark prop; adjusts layout and conditionally renders footer
components/view/secured-by-papermark.tsx New footer component displaying "Secured by Papermark" branding

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant API
    participant DB

    User->>UI: Open Link/Dataroom Options
    UI->>UI: Show SecuredByPapermarkSection toggle (if applicable)
    User->>UI: Toggle "Secured by Papermark"
    UI->>API: Save link with securedByPapermark=true/false
    API->>DB: Update Link/LinkPreset.securedByPapermark
    DB-->>API: Confirm update
    API-->>UI: Respond with updated link data

    User->>UI: View Dataroom/Document
    UI->>API: Fetch link data (includes securedByPapermark)
    API->>DB: Query Link.securedByPapermark
    DB-->>API: Return link data
    API-->>UI: Return link data
    UI->>UI: If securedByPapermark, render SecuredByPapermark footer
Loading

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-07-11T09_51_16_163Z-debug-0.log

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 (2)
components/links/link-sheet/index.tsx (1)

81-81: Simplify the boolean expression.

The ternary operator with boolean literals is unnecessary and can be simplified for better readability.

Apply this diff to simplify the expression:

-  securedByPapermark: linkType === LinkType.DATAROOM_LINK ? true : false,
+  securedByPapermark: linkType === LinkType.DATAROOM_LINK,
prisma/migrations/20250711074827_add_secured_by_papermark/migration.sql (1)

1-9: LGTM: Database schema changes are correctly implemented

The migration properly adds the securedByPapermark boolean column to both Link and LinkPreset tables with appropriate default values.

However, the dropped index "Viewer_teamId_createdAt_idx" appears unrelated to the new feature. Consider separating unrelated schema changes into different migrations for better maintainability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4a76053 and d8220de.

📒 Files selected for processing (15)
  • components/links/link-sheet/index.tsx (3 hunks)
  • components/links/link-sheet/link-options.tsx (2 hunks)
  • components/links/link-sheet/secured-by-papermark-section.tsx (1 hunks)
  • components/links/links-table.tsx (1 hunks)
  • components/view/dataroom/dataroom-document-view.tsx (2 hunks)
  • components/view/dataroom/dataroom-view.tsx (1 hunks)
  • components/view/secured-by-papermark.tsx (1 hunks)
  • components/view/viewer/dataroom-viewer.tsx (5 hunks)
  • components/welcome/containers/onboarding-dataroom-link-options.tsx (2 hunks)
  • pages/api/links/[id]/documents/[documentId].ts (1 hunks)
  • pages/api/links/[id]/index.ts (2 hunks)
  • pages/api/links/domains/[...domainSlug].ts (1 hunks)
  • pages/api/links/index.ts (1 hunks)
  • prisma/migrations/20250711074827_add_secured_by_papermark/migration.sql (1 hunks)
  • prisma/schema/link.prisma (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
components/welcome/containers/onboarding-dataroom-link-options.tsx (1)
components/links/link-sheet/secured-by-papermark-section.tsx (1)
  • SecuredByPapermarkSection (8-51)
🪛 Biome (1.9.4)
components/links/link-sheet/index.tsx

[error] 81-81: Unnecessary use of boolean literals in conditional expression.

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with

(lint/complexity/noUselessTernary)

🔇 Additional comments (23)
components/view/dataroom/dataroom-view.tsx (1)

291-291: LGTM! Proper boolean coercion and consistent prop naming.

The use of double negation (!!) ensures the prop is always a boolean, and the prop name matches the database field for consistency.

pages/api/links/[id]/documents/[documentId].ts (1)

50-50: LGTM! Correctly includes the field in API responses.

The addition of securedByPapermark: true to the Prisma select ensures this field is available for frontend consumption.

components/welcome/containers/onboarding-dataroom-link-options.tsx (2)

21-21: LGTM! Correct import statement.

The import follows the established pattern for other link sheet components.


90-94: LGTM! Proper component integration.

The SecuredByPapermarkSection is correctly placed in the alwaysShown section with the appropriate props (data, setData, presets) matching the component interface.

components/view/dataroom/dataroom-document-view.tsx (2)

22-22: LGTM! Correct import statement.

The import follows the established pattern and naming conventions.


361-361: LGTM! Proper conditional rendering.

The conditional rendering ensures the SecuredByPapermark component only appears when the flag is enabled, and the linkId prop is correctly passed.

pages/api/links/index.ts (1)

187-187: LGTM! Correct property persistence.

The securedByPapermark property is correctly included in the link creation data, following the established pattern for other boolean properties.

pages/api/links/domains/[...domainSlug].ts (1)

56-56: LGTM: Field addition is correctly implemented.

The addition of securedByPapermark to the Prisma select clause is appropriate and consistent with the feature rollout across the API layer.

components/links/links-table.tsx (1)

210-210: LGTM: Proper null handling implementation.

The use of the null coalescing operator (??) provides appropriate fallback behavior, ensuring the securedByPapermark property is always set to a valid boolean value when editing links.

prisma/schema/link.prisma (2)

45-45: LGTM: Schema addition is well-designed.

The securedByPapermark field is properly defined as an optional Boolean with a sensible default value of false, which is appropriate for this type of feature flag.


121-121: LGTM: Consistent schema implementation.

The addition of securedByPapermark to the LinkPreset model maintains consistency with the Link model and follows the same pattern with optional Boolean and default value.

components/links/link-sheet/link-options.tsx (2)

37-37: LGTM: Import statement is properly added.

The import for SecuredByPapermarkSection is correctly placed and follows the established import organization pattern.


305-310: LGTM: Conditional rendering is appropriately implemented.

The conditional rendering for DATAROOM_LINK type is correct and the component receives all necessary props (data, setData, and presets) to function properly.

components/links/link-sheet/index.tsx (1)

124-124: LGTM: Type definition is properly added.

The addition of securedByPapermark: boolean to the type definition is correct and maintains type safety.

pages/api/links/[id]/index.ts (2)

49-49: LGTM: Correctly added field to Prisma select query

The addition of securedByPapermark: true to the select query ensures the new field is retrieved from the database.


334-334: LGTM: Properly handled field update with default value

The update operation correctly sets securedByPapermark with a fallback to false if not provided, ensuring data consistency.

components/view/viewer/dataroom-viewer.tsx (3)

101-101: LGTM: Correctly added optional prop for secured by Papermark feature

The new securedByPapermark prop is properly typed as optional boolean, maintaining backward compatibility.

Also applies to: 117-117


342-346: LGTM: Smart height adjustment for footer accommodation

The dynamic height calculation properly accounts for the footer when securedByPapermark is enabled, preventing content from being hidden behind the fixed footer.


494-496: LGTM: Proper conditional rendering of footer component

The SecuredByPapermark component is correctly rendered only when the flag is enabled, with appropriate props passed.

components/view/secured-by-papermark.tsx (1)

24-24: LGTM: Well-structured UTM tracking implementation

The UTM parameters are properly configured for campaign tracking, incorporating the linkId for analytics purposes.

components/links/link-sheet/secured-by-papermark-section.tsx (3)

20-32: LGTM: Proper state synchronization with data and presets

The useEffect hooks correctly handle:

  1. Synchronizing local state with the parent data
  2. Forcing the feature to be enabled when presets require it

The dependency arrays are properly configured to prevent unnecessary re-renders.


34-38: LGTM: Well-implemented toggle handler

The toggle handler properly updates both the local state and parent state, ensuring UI consistency.


40-50: LGTM: Clean LinkItem integration

The component properly integrates with the LinkItem component, providing appropriate tooltip content and ensuring the toggle is always allowed.

Comment on lines +15 to +44
return createPortal(
<div className="fixed bottom-0 left-0 right-0 z-[100] border-t border-gray-200 bg-white dark:border-gray-800 dark:bg-black">
<div className="flex items-center justify-between px-12 py-2 text-xs text-gray-500 dark:text-gray-400">
<div className="flex items-center space-x-2">
<span>© {new Date().getFullYear()} All rights reserved</span>
</div>
<div className="flex items-center space-x-1.5">
<span>Secured by</span>
<a
href={`https://www.papermark.com?utm_campaign=securedby&utm_medium=securedby&utm_source=papermark-${linkId}`}
target="_blank"
rel="noopener noreferrer"
className="font-semibold text-gray-700 transition-colors hover:text-gray-900 dark:text-gray-300 dark:hover:text-gray-100"
>
Papermark
</a>
</div>
{isClosable && (
<button
onClick={() => setVisible(false)}
className="absolute right-4 rounded text-lg text-gray-400 hover:text-gray-700 dark:hover:text-gray-200"
aria-label="Close"
>
<CircleXIcon className="h-4 w-4" />
</button>
)}
</div>
</div>,
document.body,
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add SSR safety check for document.body access

The component looks well-implemented with proper portal usage and styling. However, accessing document.body directly can cause issues during server-side rendering.

Add a safety check to ensure the component only renders on the client side:

  if (!visible) return null;
+ if (typeof window === 'undefined') return null;
  return createPortal(

This prevents SSR errors when document.body is not available.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return createPortal(
<div className="fixed bottom-0 left-0 right-0 z-[100] border-t border-gray-200 bg-white dark:border-gray-800 dark:bg-black">
<div className="flex items-center justify-between px-12 py-2 text-xs text-gray-500 dark:text-gray-400">
<div className="flex items-center space-x-2">
<span>© {new Date().getFullYear()} All rights reserved</span>
</div>
<div className="flex items-center space-x-1.5">
<span>Secured by</span>
<a
href={`https://www.papermark.com?utm_campaign=securedby&utm_medium=securedby&utm_source=papermark-${linkId}`}
target="_blank"
rel="noopener noreferrer"
className="font-semibold text-gray-700 transition-colors hover:text-gray-900 dark:text-gray-300 dark:hover:text-gray-100"
>
Papermark
</a>
</div>
{isClosable && (
<button
onClick={() => setVisible(false)}
className="absolute right-4 rounded text-lg text-gray-400 hover:text-gray-700 dark:hover:text-gray-200"
aria-label="Close"
>
<CircleXIcon className="h-4 w-4" />
</button>
)}
</div>
</div>,
document.body,
);
if (!visible) return null;
if (typeof window === 'undefined') return null;
return createPortal(
<div className="fixed bottom-0 left-0 right-0 z-[100] border-t border-gray-200 bg-white dark:border-gray-800 dark:bg-black">
<div className="flex items-center justify-between px-12 py-2 text-xs text-gray-500 dark:text-gray-400">
<div className="flex items-center space-x-2">
<span>© {new Date().getFullYear()} All rights reserved</span>
</div>
<div className="flex items-center space-x-1.5">
<span>Secured by</span>
<a
href={`https://www.papermark.com?utm_campaign=securedby&utm_medium=securedby&utm_source=papermark-${linkId}`}
target="_blank"
rel="noopener noreferrer"
className="font-semibold text-gray-700 transition-colors hover:text-gray-900 dark:text-gray-300 dark:hover:text-gray-100"
>
Papermark
</a>
</div>
{isClosable && (
<button
onClick={() => setVisible(false)}
className="absolute right-4 rounded text-lg text-gray-400 hover:text-gray-700 dark:hover:text-gray-200"
aria-label="Close"
>
<CircleXIcon className="h-4 w-4" />
</button>
)}
</div>
</div>,
document.body,
);
🤖 Prompt for AI Agents
In components/view/secured-by-papermark.tsx around lines 15 to 44, the code
directly accesses document.body for createPortal, which causes errors during
server-side rendering because document is undefined on the server. To fix this,
add a client-side check to ensure the component only attempts to render the
portal when running in the browser, such as by using a state variable that is
set to true inside a useEffect hook or by checking if typeof window !==
'undefined' before accessing document.body. This will prevent SSR errors by
avoiding document access on the server.

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.

1 participant