Skip to content

Commit 962a70c

Browse files
committed
feat: Introduce app config to conditionally display file download buttons and remove the related feature modal.
1 parent 0901507 commit 962a70c

4 files changed

Lines changed: 34 additions & 23 deletions

File tree

app/(main)/academics/PdfViewer.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Star, StarOff, ExternalLink, Download } from "lucide-react";
33
import { useEffect, useState } from "react";
44
import Link from "next/link";
55
import { ActiveFile } from "@/types/file";
6+
import { appConfig } from "@/lib/app-config";
67

78
interface Favorite {
89
id: string;
@@ -91,9 +92,11 @@ export default function PdfViewer({ file }: PdfViewerProps) {
9192
<Star className="h-4 w-4" />
9293
)}
9394
</Button>
94-
<Button variant="outline" size="sm" onClick={handleDownload}>
95-
<Download className="h-4 w-4" />
96-
</Button>
95+
{appConfig.features.allowFileDownload && (
96+
<Button variant="outline" size="sm" onClick={handleDownload}>
97+
<Download className="h-4 w-4" />
98+
</Button>
99+
)}
97100
<Button variant="outline" size="sm" asChild>
98101
<Link
99102
href={`/viewer/${file.id}`}

app/layout.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { ThemeProvider } from "@/components/theme-provider";
55
import { Analytics } from "@vercel/analytics/next";
66
import { SITE_URL } from "@/lib/constants";
77
import { FestiveModal } from "@/components/FestiveModal";
8-
import { FeatureModal } from "@/components/FeatureModal";
98
import Script from "next/script";
109
import { Popunder, SocialBar } from "@/components/ads";
1110

@@ -97,10 +96,6 @@ export default function RootLayout({
9796
storageKey="diwali_2025_modal"
9897
expireDate="2025-10-23"
9998
/>
100-
<FeatureModal
101-
storageKey="feature-download-seen"
102-
expireDate="2026-01-15"
103-
/>
10499
<Analytics />
105100
</ThemeProvider>
106101
</body>

app/viewer/[fileId]/viewer-client.tsx

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import ChatPanel from "@/components/viewer/ChatPanel";
1818
import { Star, StarOff, MessageSquare, PanelRightClose, Download } from "lucide-react";
1919
import Image from "next/image";
2020
import Link from "next/link";
21+
import { appConfig } from "@/lib/app-config";
2122

2223
interface ViewerClientProps {
2324
fileDetails: {
@@ -128,21 +129,23 @@ export default function ViewerClient({ fileDetails }: ViewerClientProps) {
128129
</TooltipContent>
129130
</Tooltip>
130131

131-
<Tooltip>
132-
<TooltipTrigger asChild>
133-
<Button
134-
className="text-sm h-10 w-10"
135-
variant="outline"
136-
size="icon"
137-
onClick={handleDownload}
138-
>
139-
<Download className="h-4 w-4" />
140-
</Button>
141-
</TooltipTrigger>
142-
<TooltipContent>
143-
Download PDF
144-
</TooltipContent>
145-
</Tooltip>
132+
{appConfig.features.allowFileDownload && (
133+
<Tooltip>
134+
<TooltipTrigger asChild>
135+
<Button
136+
className="text-sm h-10 w-10"
137+
variant="outline"
138+
size="icon"
139+
onClick={handleDownload}
140+
>
141+
<Download className="h-4 w-4" />
142+
</Button>
143+
</TooltipTrigger>
144+
<TooltipContent>
145+
Download PDF
146+
</TooltipContent>
147+
</Tooltip>
148+
)}
146149
</TooltipProvider>
147150

148151
<Button

lib/app-config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
export const appConfig = {
3+
features: {
4+
/**
5+
* Enable or disable the file download option in viewers.
6+
* If false, the download button will be hidden.
7+
*/
8+
allowFileDownload: false,
9+
},
10+
};

0 commit comments

Comments
 (0)