-
Notifications
You must be signed in to change notification settings - Fork 1k
UI: Added enable 'Secured by Papermark' in data rooms #1751
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
Open
AshishViradiya153
wants to merge
1
commit into
mfts:main
Choose a base branch
from
AshishViradiya153:244/securedByPapermark
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
components/links/link-sheet/secured-by-papermark-section.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { useEffect, useState } from "react"; | ||
|
||
import { LinkPreset } from "@prisma/client"; | ||
|
||
import { DEFAULT_LINK_TYPE } from "."; | ||
import LinkItem from "./link-item"; | ||
|
||
export default function SecuredByPapermarkSection({ | ||
data, | ||
setData, | ||
presets, | ||
}: { | ||
data: DEFAULT_LINK_TYPE; | ||
setData: React.Dispatch<React.SetStateAction<DEFAULT_LINK_TYPE>>; | ||
presets: LinkPreset | null; | ||
}) { | ||
const { securedByPapermark } = data; | ||
const [enabled, setEnabled] = useState<boolean>(false); | ||
|
||
useEffect(() => { | ||
setEnabled(securedByPapermark ?? false); | ||
}, [securedByPapermark]); | ||
|
||
useEffect(() => { | ||
if (presets?.securedByPapermark) { | ||
setEnabled(true); | ||
setData((prevData) => ({ | ||
...prevData, | ||
securedByPapermark: true, | ||
})); | ||
} | ||
}, [presets, setData]); | ||
|
||
const handleSecuredByPapermarkToggle = () => { | ||
const updatedSecuredByPapermark = !enabled; | ||
setData({ ...data, securedByPapermark: updatedSecuredByPapermark }); | ||
setEnabled(updatedSecuredByPapermark); | ||
}; | ||
|
||
return ( | ||
<div className="pb-5"> | ||
<LinkItem | ||
title="Secured by Papermark" | ||
tooltipContent="Show a subtle footer with 'Secured by Papermark' branding in your dataroom" | ||
enabled={enabled} | ||
action={handleSecuredByPapermarkToggle} | ||
isAllowed={true} | ||
/> | ||
</div> | ||
); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { useState } from "react"; | ||
|
||
import { CircleXIcon } from "lucide-react"; | ||
import { createPortal } from "react-dom"; | ||
|
||
export const SecuredByPapermark = ({ | ||
linkId, | ||
isClosable = true, | ||
}: { | ||
linkId: string; | ||
isClosable?: boolean; | ||
}) => { | ||
const [visible, setVisible] = useState(true); | ||
if (!visible) 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, | ||
); | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
prisma/migrations/20250711074827_add_secured_by_papermark/migration.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- DropIndex | ||
DROP INDEX "Viewer_teamId_createdAt_idx"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "Link" ADD COLUMN "securedByPapermark" BOOLEAN DEFAULT false; | ||
|
||
-- AlterTable | ||
ALTER TABLE "LinkPreset" ADD COLUMN "securedByPapermark" BOOLEAN DEFAULT false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🛠️ 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
🤖 Prompt for AI Agents