Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions components/datarooms/add-dataroom-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function AddDataroomModal({
const [editingFolderName, setEditingFolderName] = useState<string>("");

const teamInfo = useTeam();
const { isFree, isPro } = usePlan();
const { isFree, isPro, isTrial } = usePlan();
const analytics = useAnalytics();

const useTemplate = activeTab === "generate";
Expand Down Expand Up @@ -346,8 +346,7 @@ export function AddDataroomModal({
}
};

// If the team is on a free plan, show the upgrade modal
if (isFree || isPro) {
if ((isFree || isPro) && !isTrial) {
if (children) {
return (
<UpgradePlanModal
Expand Down
2 changes: 1 addition & 1 deletion ee/features/templates/api/datarooms/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export default async function handle(
where: {
id: teamId,
plan: {
// exclude all teams not on `business`, `datarooms`, `datarooms-plus`, `datarooms-premium`, `business+old`, `datarooms+old`, `datarooms-plus+old`, `datarooms-premium+old` plan
in: [
"business",
"datarooms",
Expand All @@ -59,6 +58,7 @@ export default async function handle(
"datarooms+old",
"datarooms-plus+old",
"datarooms-premium+old",
"free+drtrial",
"datarooms+drtrial",
"business+drtrial",
"datarooms-plus+drtrial",
Expand Down
2 changes: 2 additions & 0 deletions ee/limits/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export async function getLimits({
usage: { documents: documentCount, links: linkCount, users: userCount },
...(isTrial && {
users: 3,
datarooms: Math.max(parsedData.datarooms ?? defaultLimits?.datarooms ?? 0, 1),
}),
};
} else {
Expand All @@ -138,6 +139,7 @@ export async function getLimits({
usage: { documents: documentCount, links: linkCount, users: userCount },
...(isTrial && {
users: 3,
datarooms: Math.max(defaultLimits?.datarooms ?? 0, 1),
}),
};
}
Expand Down
2 changes: 1 addition & 1 deletion pages/api/teams/[teamId]/datarooms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ export default async function handle(
where: {
id: teamId,
plan: {
// exclude all teams not on `business`, `datarooms`, `datarooms-plus`, `datarooms-premium`, `business+old`, `datarooms+old`, `datarooms-plus+old`, `datarooms-premium+old` plan
in: [
"business",
"datarooms",
Expand All @@ -239,6 +238,7 @@ export default async function handle(
"datarooms+old",
"datarooms-plus+old",
"datarooms-premium+old",
"free+drtrial",
"datarooms+drtrial",
"business+drtrial",
"datarooms-plus+drtrial",
Expand Down
4 changes: 2 additions & 2 deletions pages/datarooms/[id]/settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function Settings() {
const teamId = teamInfo?.currentTeam?.id;
const [isCopied, setIsCopied] = useState(false);

const { isBusiness, isDatarooms, isDataroomsPlus } = usePlan();
const { isBusiness, isDatarooms, isDataroomsPlus, isTrial } = usePlan();

if (!dataroom) {
return <div>Loading...</div>;
Expand Down Expand Up @@ -219,7 +219,7 @@ export default function Settings() {
</CardFooter>
</Card>

{isBusiness || isDatarooms || isDataroomsPlus ? (
{isBusiness || isDatarooms || isDataroomsPlus || isTrial ? (
<DeleteDataroom
dataroomId={dataroom.id}
dataroomName={dataroom.name}
Expand Down
32 changes: 22 additions & 10 deletions pages/datarooms/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,29 @@ export default function DataroomsPage() {
})()}
</span>
</div>
<UpgradePlanModal
clickedPlan={PlanEnum.DataRooms}
trigger="datarooms"
>
<Button
className="group flex flex-1 items-center justify-start gap-x-3 px-3 text-left"
title="Upgrade to Add Data Room"
{datarooms.length === 0 ? (
<AddDataroomModal>
<Button
className="group flex flex-1 items-center justify-start gap-x-3 px-3 text-left"
title="Create New Dataroom"
>
<PlusIcon className="h-5 w-5 shrink-0" aria-hidden="true" />
<span>Create New Dataroom</span>
</Button>
</AddDataroomModal>
) : (
<UpgradePlanModal
clickedPlan={PlanEnum.DataRooms}
trigger="datarooms"
>
<span>Upgrade to Add Data Room</span>
</Button>
</UpgradePlanModal>
<Button
className="group flex flex-1 items-center justify-start gap-x-3 px-3 text-left"
title="Upgrade to Add Data Room"
>
<span>Upgrade to Add Data Room</span>
</Button>
</UpgradePlanModal>
)}
Comment on lines +138 to +160
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Use the unfiltered count for this trial CTA.

datarooms.length is the filtered list on the page, so a search/tag combination that matches nothing will show “Create New Dataroom” even when the team already owns its single trial dataroom. Gate this on totalDatarooms/limitDatarooms instead, otherwise the CTA leads straight to the 403 limit error.

Suggested fix
-                {datarooms.length === 0 ? (
+                {totalDatarooms < limitDatarooms ? (
                   <AddDataroomModal>
                     <Button
                       className="group flex flex-1 items-center justify-start gap-x-3 px-3 text-left"
                       title="Create New Dataroom"
📝 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
{datarooms.length === 0 ? (
<AddDataroomModal>
<Button
className="group flex flex-1 items-center justify-start gap-x-3 px-3 text-left"
title="Create New Dataroom"
>
<PlusIcon className="h-5 w-5 shrink-0" aria-hidden="true" />
<span>Create New Dataroom</span>
</Button>
</AddDataroomModal>
) : (
<UpgradePlanModal
clickedPlan={PlanEnum.DataRooms}
trigger="datarooms"
>
<span>Upgrade to Add Data Room</span>
</Button>
</UpgradePlanModal>
<Button
className="group flex flex-1 items-center justify-start gap-x-3 px-3 text-left"
title="Upgrade to Add Data Room"
>
<span>Upgrade to Add Data Room</span>
</Button>
</UpgradePlanModal>
)}
{totalDatarooms < limitDatarooms ? (
<AddDataroomModal>
<Button
className="group flex flex-1 items-center justify-start gap-x-3 px-3 text-left"
title="Create New Dataroom"
>
<PlusIcon className="h-5 w-5 shrink-0" aria-hidden="true" />
<span>Create New Dataroom</span>
</Button>
</AddDataroomModal>
) : (
<UpgradePlanModal
clickedPlan={PlanEnum.DataRooms}
trigger="datarooms"
>
<Button
className="group flex flex-1 items-center justify-start gap-x-3 px-3 text-left"
title="Upgrade to Add Data Room"
>
<span>Upgrade to Add Data Room</span>
</Button>
</UpgradePlanModal>
)}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pages/datarooms/index.tsx` around lines 138 - 160, The CTA currently checks
the filtered list length (datarooms.length) which can be zero due to
search/tags; change the gating logic to use the unfiltered counts
(totalDatarooms and limitDatarooms) so the AddDataroomModal is shown only when
the team is under its dataroom limit and UpgradePlanModal is shown when
at/exceeding the limit; update the conditional around AddDataroomModal /
UpgradePlanModal (where datarooms.length is used) to compare totalDatarooms <
limitDatarooms (or the appropriate limit check) and keep the existing props like
clickedPlan={PlanEnum.DataRooms} and trigger="datarooms" intact.

</div>
) : isBusiness || isDatarooms || isDataroomsPlus ? (
<AddDataroomModal>
Expand Down