Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

Only show hidden documents button when there are hidden items

Cursor Agentb7272b1d6cf9
diff --git a/pages/documents/index.tsx b/pages/documents/index.tsx
index 2cc8047e..b6d1f3e4 100644
--- a/pages/documents/index.tsx
+++ b/pages/documents/index.tsx
@@ -5,7 +5,7 @@ import Link from "next/link";
import { useTeam } from "@/context/team-context";
import { EyeOffIcon, FolderPlusIcon, PlusIcon } from "lucide-react";
-import useDocuments, { useRootFolders } from "@/lib/swr/use-documents";
+import useDocuments, { useHiddenDocuments, useRootFolders } from "@/lib/swr/use-documents";
import { handleInvitationStatus } from "@/lib/utils";
import { AddDocumentModal } from "@/components/documents/add-document-modal";
@@ -34,6 +34,12 @@ export default function Documents() {
const { folders, loading: foldersLoading } = useRootFolders();
const { documents, pagination, isValidating, isFiltered, loading } =
useDocuments();
+ const { folders: hiddenFolders, documents: hiddenDocuments } =
+ useHiddenDocuments();
+
+ const hasHiddenItems =
+ (hiddenFolders && hiddenFolders.length > 0) ||
+ (hiddenDocuments && hiddenDocuments.length > 0);
const updatePagination = (newPage?: number, newPageSize?: number) => {
const params = new URLSearchParams(window.location.search);
@@ -93,16 +99,18 @@ export default function Documents() {
<SearchBoxPersisted loading={isValidating} inputClassName="h-10" />
</div>
<SortButton />
- <Link href="/documents/hidden">
- <Button
- variant="outline"
- size="icon"
- className="border-gray-500 bg-gray-50 hover:bg-gray-200 dark:bg-black hover:dark:bg-muted"
- title="View hidden documents"
- >
- <EyeOffIcon className="h-5 w-5 shrink-0" aria-hidden="true" />
- </Button>
- </Link>
+ {hasHiddenItems && (
+ <Link href="/documents/hidden">
+ <Button
+ variant="outline"
+ size="icon"
+ className="border-gray-500 bg-gray-50 hover:bg-gray-200 dark:bg-black hover:dark:bg-muted"
+ title="View hidden documents"
+ >
+ <EyeOffIcon className="h-5 w-5 shrink-0" aria-hidden="true" />
+ </Button>
+ </Link>
+ )}
</div>
<section id="documents-header-count" />