Skip to content

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

fix(request-lists): let the requestList flag enable the feature on the base Data Rooms plan

Marc Seitz7fe2f9a86113
diff --git a/components/layouts/mobile-dataroom-more-menu.tsx b/components/layouts/mobile-dataroom-more-menu.tsx
index b2c5c860..6b69b249 100644
--- a/components/layouts/mobile-dataroom-more-menu.tsx
+++ b/components/layouts/mobile-dataroom-more-menu.tsx
@@ -5,6 +5,7 @@ import { useRouter } from "next/router";
import { useEffect, useState } from "react";
+import { useRequestListFeatureEnabled } from "@/ee/features/request-lists/lib/use-request-list-feature";
import { PlanEnum } from "@/ee/stripe/constants";
import {
BarChart3Icon,
@@ -23,7 +24,6 @@ import {
XIcon,
} from "lucide-react";
-import { useFeatureFlags } from "@/lib/hooks/use-feature-flags";
import { usePlan } from "@/lib/swr/use-billing";
import { useDataroom } from "@/lib/swr/use-dataroom";
import useLimits from "@/lib/swr/use-limits";
@@ -60,8 +60,7 @@ export function MobileDataroomMoreMenu({
const { isTrial } = usePlan();
const { limits } = useLimits();
const { dataroom } = useDataroom(dataroomId);
- const { isFeatureEnabled } = useFeatureFlags();
- const isRequestListFeatureEnabled = isFeatureEnabled("requestList");
+ const isRequestListFeatureEnabled = useRequestListFeatureEnabled();
const [settingsExpanded, setSettingsExpanded] = useState(() =>
router.pathname.includes("/settings"),
);
diff --git a/components/sidebar/dataroom-sidebar.tsx b/components/sidebar/dataroom-sidebar.tsx
index 326e0bf7..a24a0727 100644
--- a/components/sidebar/dataroom-sidebar.tsx
+++ b/components/sidebar/dataroom-sidebar.tsx
@@ -5,6 +5,7 @@ import { useRouter } from "next/router";
import { useEffect, useRef, useState } from "react";
+import { useRequestListFeatureEnabled } from "@/ee/features/request-lists/lib/use-request-list-feature";
import {
BarChart3Icon,
BellIcon,
@@ -28,7 +29,6 @@ import {
UsersIcon,
} from "lucide-react";
-import { useFeatureFlags } from "@/lib/hooks/use-feature-flags";
import { useSelfMembership } from "@/lib/hooks/use-self-membership";
import { useDataroom } from "@/lib/swr/use-dataroom";
import { cn } from "@/lib/utils";
@@ -124,8 +124,7 @@ export function DataroomSidebarContent() {
const { dataroom } = useDataroom();
const { state, isMobile } = useSidebar();
const { isDataroomMember } = useSelfMembership();
- const { isFeatureEnabled } = useFeatureFlags();
- const isRequestListFeatureEnabled = isFeatureEnabled("requestList");
+ const isRequestListFeatureEnabled = useRequestListFeatureEnabled();
const dataroomId = dataroom?.id ?? (router.query.id as string);
const [isLinkSheetOpen, setIsLinkSheetOpen] = useState(false);
diff --git a/lib/featureFlags/request-list.ts b/lib/featureFlags/request-list.ts
new file mode 100644
index 00000000..480fe1c3
--- /dev/null
+++ b/lib/featureFlags/request-list.ts
@@ -0,0 +1,35 @@
+import { teamPlanIsDataroomPlusTier } from "@/lib/billing/team-plan-custom-messaging";
+import { getFeatureFlags } from "@/lib/featureFlags";
+
+/**
+ * Request List ships on the Data Rooms Plus tier and above; the Edge Config
+ * `requestList` flag additionally enables it for a team on the base Data Rooms
+ * plan. Mirrors resolveDataroomFreezeEnabled.
+ *
+ * Takes already-fetched flags; use resolveRequestListEnabled to look them up.
+ */
+export function isRequestListEnabled(opts: {
+ requestListFlag: boolean | undefined;
+ teamPlan: string | null | undefined;
+}): boolean {
+ return (
+ teamPlanIsDataroomPlusTier(opts.teamPlan ?? undefined) ||
+ Boolean(opts.requestListFlag)
+ );
+}
+
+export async function resolveRequestListEnabled(opts: {
+ teamId: string | null | undefined;
+ teamPlan: string | null | undefined;
+}): Promise<boolean> {
+ // Checked here too, to skip the Edge Config lookup on the common path.
+ if (teamPlanIsDataroomPlusTier(opts.teamPlan ?? undefined)) {
+ return true;
+ }
+
+ const flags = await getFeatureFlags({ teamId: opts.teamId || undefined });
+ return isRequestListEnabled({
+ requestListFlag: flags.requestList,
+ teamPlan: opts.teamPlan,
+ });
+}
diff --git a/pages/api/teams/[teamId]/datarooms/[id]/index.ts b/pages/api/teams/[teamId]/datarooms/[id]/index.ts
index 77e7f428..0137b22a 100644
--- a/pages/api/teams/[teamId]/datarooms/[id]/index.ts
+++ b/pages/api/teams/[teamId]/datarooms/[id]/index.ts
@@ -5,6 +5,7 @@ import { DefaultPermissionStrategy, RootItemAccess } from "@prisma/client";
import { withTeamApi } from "@/lib/api/auth/with-session-team";
import { errorhandler } from "@/lib/errorHandler";
import { getFeatureFlags } from "@/lib/featureFlags";
+import { isRequestListEnabled } from "@/lib/featureFlags/request-list";
import prisma from "@/lib/prisma";
// GET /api/teams/:teamId/datarooms/:id
@@ -123,7 +124,10 @@ const patchHandler = withTeamApi(
if (
requestListEnabled !== undefined &&
- (!featureFlags.requestList || !isDataroomsPlus)
+ !isRequestListEnabled({
+ requestListFlag: featureFlags.requestList,
+ teamPlan: team.plan,
+ })
) {
return res.status(403).json({
message: "This feature is not available in your plan",
diff --git a/pages/datarooms/[id]/settings/index.tsx b/pages/datarooms/[id]/settings/index.tsx
index 6eb03def..056fa758 100644
--- a/pages/datarooms/[id]/settings/index.tsx
+++ b/pages/datarooms/[id]/settings/index.tsx
@@ -3,11 +3,11 @@ import { useState } from "react";
import { useTeam } from "@/context/team-context";
import { AgentsSettingsCard } from "@/ee/features/ai/components/agents-settings-card";
import { RequestListSettingsCard } from "@/ee/features/request-lists/components/request-list-settings-card";
+import { useRequestListFeatureEnabled } from "@/ee/features/request-lists/lib/use-request-list-feature";
import { Check, CircleHelpIcon, Copy } from "lucide-react";
import { toast } from "sonner";
import { mutate } from "swr";
-import { useFeatureFlags } from "@/lib/hooks/use-feature-flags";
import { useSelfMembership } from "@/lib/hooks/use-self-membership";
import { useDataroom } from "@/lib/swr/use-dataroom";
@@ -32,8 +32,7 @@ export default function Settings() {
const teamInfo = useTeam();
const teamId = teamInfo?.currentTeam?.id;
const { isDataroomMember } = useSelfMembership();
- const { isFeatureEnabled } = useFeatureFlags();
- const isRequestListEnabled = isFeatureEnabled("requestList");
+ const isRequestListEnabled = useRequestListFeatureEnabled();
const [isCopied, setIsCopied] = useState(false);
if (!dataroom) {