Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat: add rebuild index for datarooms
Marc Seitz6a7ca1666acf
diff --git a/components/datarooms/rebuild-index-button.tsx b/components/datarooms/actions/rebuild-index-button.tsxsimilarity index 74%rename from components/datarooms/rebuild-index-button.tsxrename to components/datarooms/actions/rebuild-index-button.tsxindex 8f7d1837..f0c74c25 100644--- a/components/datarooms/rebuild-index-button.tsx+++ b/components/datarooms/actions/rebuild-index-button.tsx@@ -1,10 +1,12 @@import { useState } from "react";-import { Hash, ListOrderedIcon, RefreshCw } from "lucide-react";+import { PlanEnum } from "@/ee/stripe/constants";+import { ListOrderedIcon } from "lucide-react";import { toast } from "sonner";-import { useFeatureFlags } from "@/lib/hooks/use-feature-flags";+import { usePlan } from "@/lib/swr/use-billing";+import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";import { Button } from "@/components/ui/button";import {Dialog,@@ -28,18 +30,21 @@ export default function RebuildIndexButton({dataroomId,disabled = false,}: RebuildIndexButtonProps) {- const { isFeatureEnabled } = useFeatureFlags();+ const { isDatarooms, isDataroomsPlus, isTrial } = usePlan();const [isLoading, setIsLoading] = useState(false);const [isOpen, setIsOpen] = useState(false);- const isDataroomIndexEnabled = isFeatureEnabled("dataroomIndex");-- // Don't render if feature is not enabled- if (!isDataroomIndexEnabled) {+ // INFO: Don't render if user doesn't have a datarooms plan+ if (!isDatarooms && !isDataroomsPlus && !isTrial) {return null;}const handleRebuildIndex = async () => {+ if (!isDataroomsPlus) {+ toast.error("Upgrade to Data Rooms Plus plan to use this feature.");+ return;+ }+try {setIsLoading(true);@@ -120,14 +125,27 @@ export default function RebuildIndexButton({</div></div></div>+<DialogFooter>- <Button variant="outline" onClick={() => setIsOpen(false)}>- Cancel- </Button>- <Button onClick={handleRebuildIndex} loading={isLoading}>- <ListOrderedIcon className="h-4 w-4" />- Rebuild Index- </Button>+ {isDataroomsPlus ? (+ <>+ <Button variant="outline" onClick={() => setIsOpen(false)}>+ Cancel+ </Button>+ <Button onClick={handleRebuildIndex} loading={isLoading}>+ <ListOrderedIcon className="h-4 w-4" />+ Rebuild Index+ </Button>+ </>+ ) : (+ <UpgradePlanModal+ clickedPlan={PlanEnum.DataRoomsPlus}+ trigger="datarooms_rebuild_index_button"+ highlightItem={["indexing"]}+ >+ <Button>Upgrade to rebuild index</Button>+ </UpgradePlanModal>+ )}</DialogFooter></DialogContent></Dialog>diff --git a/pages/datarooms/[id]/documents/[...name].tsx b/pages/datarooms/[id]/documents/[...name].tsxindex c3be19fd..ad0a0915 100644--- a/pages/datarooms/[id]/documents/[...name].tsx+++ b/pages/datarooms/[id]/documents/[...name].tsx@@ -9,12 +9,12 @@ import { useDataroom, useDataroomItems } from "@/lib/swr/use-dataroom";import DownloadDataroomButton from "@/components/datarooms/actions/download-dataroom";import GenerateIndexButton from "@/components/datarooms/actions/generate-index-button";+import RebuildIndexButton from "@/components/datarooms/actions/rebuild-index-button";import { BreadcrumbComponent } from "@/components/datarooms/dataroom-breadcrumb";import { DataroomHeader } from "@/components/datarooms/dataroom-header";import { DataroomItemsList } from "@/components/datarooms/dataroom-items-list";import { DataroomNavigation } from "@/components/datarooms/dataroom-navigation";import { SidebarFolderTree } from "@/components/datarooms/folders";-import RebuildIndexButton from "@/components/datarooms/rebuild-index-button";import { DataroomSortableList } from "@/components/datarooms/sortable/sortable-list";import { AddDocumentModal } from "@/components/documents/add-document-modal";import { LoadingDocuments } from "@/components/documents/loading-document";diff --git a/pages/datarooms/[id]/documents/index.tsx b/pages/datarooms/[id]/documents/index.tsxindex d1ed2742..eea37cb9 100644--- a/pages/datarooms/[id]/documents/index.tsx+++ b/pages/datarooms/[id]/documents/index.tsx@@ -7,11 +7,11 @@ import { useDataroom, useDataroomItems } from "@/lib/swr/use-dataroom";import DownloadDataroomButton from "@/components/datarooms/actions/download-dataroom";import GenerateIndexButton from "@/components/datarooms/actions/generate-index-button";+import RebuildIndexButton from "@/components/datarooms/actions/rebuild-index-button";import { DataroomHeader } from "@/components/datarooms/dataroom-header";import { DataroomItemsList } from "@/components/datarooms/dataroom-items-list";import { DataroomNavigation } from "@/components/datarooms/dataroom-navigation";import { SidebarFolderTree } from "@/components/datarooms/folders";-import RebuildIndexButton from "@/components/datarooms/rebuild-index-button";import { DataroomSortableList } from "@/components/datarooms/sortable/sortable-list";import { AddDocumentModal } from "@/components/documents/add-document-modal";import { LoadingDocuments } from "@/components/documents/loading-document";