From 9f423e717a17290981bb30fc9de4c901542648dc Mon Sep 17 00:00:00 2001 From: Subhamoy Biswas Date: Wed, 9 Jul 2025 23:17:42 +0530 Subject: [PATCH] (refactor): merged extension tab with settings --- src/components/sidebar.tsx | 7 +-- src/main.tsx | 2 - src/pages/extension.tsx | 77 --------------------------------- src/pages/settings.tsx | 88 +++++++++++++++++++++++++++++++++++--- src/routes.ts | 7 +-- src/services/store.ts | 2 +- 6 files changed, 84 insertions(+), 99 deletions(-) delete mode 100644 src/pages/extension.tsx diff --git a/src/components/sidebar.tsx b/src/components/sidebar.tsx index f097609..9b407ea 100644 --- a/src/components/sidebar.tsx +++ b/src/components/sidebar.tsx @@ -1,7 +1,7 @@ import { config } from "@/config"; import { Link, useLocation } from "react-router-dom"; import { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent, SidebarHeader, SidebarMenu, SidebarMenuButton, SidebarMenuItem, useSidebar } from "@/components/ui/sidebar"; -import { CircleArrowUp, Download, Puzzle, Settings, SquarePlay, } from "lucide-react"; +import { CircleArrowUp, Download, Settings, SquarePlay, } from "lucide-react"; import { isActive as isActiveSidebarItem } from "@/utils"; import { RoutesObj } from "@/types/route"; import { useDownloadStatesStore, useSettingsPageStatesStore } from "@/services/store"; @@ -41,11 +41,6 @@ export function AppSidebar() { title: "Library", url: "/library", icon: SquarePlay, - }, - { - title: "Extension", - url: "/extension", - icon: Puzzle, } ]; diff --git a/src/main.tsx b/src/main.tsx index c79f8ad..1b8ad62 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -8,7 +8,6 @@ import RootLayout from "@/pages/layout/root"; import DownloaderPage from "@/pages/downloader"; import LibraryPage from "@/pages/library"; import SettingsPage from "@/pages/settings"; -import ExtensionPage from "@/pages/extension"; ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( @@ -19,7 +18,6 @@ ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( }> } /> } /> - } /> } /> diff --git a/src/pages/extension.tsx b/src/pages/extension.tsx deleted file mode 100644 index ac2148d..0000000 --- a/src/pages/extension.tsx +++ /dev/null @@ -1,77 +0,0 @@ -import { SlidingButton } from "@/components/custom/slidingButton"; -import Heading from "@/components/heading"; -import { ArrowRight } from "lucide-react"; -import { invoke } from "@tauri-apps/api/core"; -import { useToast } from "@/hooks/use-toast"; -import { Button } from "@/components/ui/button"; - -export default function ExtensionPage() { - const { toast } = useToast(); - const openLink = async (url: string, app: string | null) => { - try { - await invoke('open_file_with_app', { filePath: url, appName: app }).then(() => { - toast({ - title: 'Opening Link', - description: `Opening link with ${app ? app : 'default app'}.`, - }) - }); - } catch (e) { - console.error(e); - toast({ - title: 'Failed to open link', - description: 'An error occurred while trying to open the link.', - variant: "destructive" - }) - } - } - - return ( -
- -
- - - Get Now -
- } - onClick={() => openLink('https://chromewebstore.google.com/detail/neo-downloader-plus/mehopeailfjmiloiiohgicphlcgpompf', 'chrome')} - > - - - - - Get Chrome Extension - - from Chrome Web Store - - - - Get Now -
- } - onClick={() => openLink('https://addons.mozilla.org/en-US/firefox/addon/neo-downloader-plus', 'firefox')} - > - - - - - Get Firefox Extension - - from Mozilla Addons Store - - -
- - - - - -
-

* These links opens with coresponding browsers only. Make sure the browser is installed befor clicking the link

- - ) -} \ No newline at end of file diff --git a/src/pages/settings.tsx b/src/pages/settings.tsx index 5c3ed7f..85f4068 100644 --- a/src/pages/settings.tsx +++ b/src/pages/settings.tsx @@ -7,7 +7,7 @@ import { Switch } from "@/components/ui/switch"; import { Label } from "@/components/ui/label"; import { Button } from "@/components/ui/button"; import { useToast } from "@/hooks/use-toast"; -import { ExternalLink, Folder, FolderOpen, Loader2, LucideIcon, Monitor, Moon, Radio, RotateCcw, RotateCw, Sun, Terminal, WandSparkles, Wifi, Wrench } from "lucide-react"; +import { ArrowDownToLine, ArrowRight, EthernetPort, ExternalLink, Folder, FolderOpen, Loader2, LucideIcon, Monitor, Moon, Radio, RotateCcw, RotateCw, Sun, Terminal, WandSparkles, Wifi, Wrench } from "lucide-react"; import { cn } from "@/lib/utils"; import { useEffect } from "react"; import { useTheme } from "@/providers/themeProvider"; @@ -22,6 +22,7 @@ import { zodResolver } from "@hookform/resolvers/zod" import { Form, FormControl, FormField, FormItem, FormMessage } from "@/components/ui/form"; import { invoke } from "@tauri-apps/api/core"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from "@/components/ui/alert-dialog"; +import { SlidingButton } from "@/components/custom/slidingButton"; const websocketPortSchema = z.object({ port: z.coerce.number({ @@ -79,6 +80,24 @@ export default function SettingsPage() { { value: 'system', icon: Monitor, label: 'System' }, ]; + const openLink = async (url: string, app: string | null) => { + try { + await invoke('open_file_with_app', { filePath: url, appName: app }).then(() => { + toast({ + title: 'Opening Link', + description: `Opening link with ${app ? app : 'default app'}.`, + }) + }); + } catch (e) { + console.error(e); + toast({ + title: 'Failed to open link', + description: 'An error occurred while trying to open the link.', + variant: "destructive" + }) + } + } + const proxyUrlForm = useForm>({ resolver: zodResolver(proxyUrlSchema), defaultValues: { @@ -456,18 +475,73 @@ export default function SettingsPage() { General + > Install + Port -
- +
+ +
+

NeoDLP Extension

+

Integrate NeoDLP with your favourite browser

+
+ + + Get Now +
+ } + onClick={() => openLink('https://chromewebstore.google.com/detail/neo-downloader-plus/mehopeailfjmiloiiohgicphlcgpompf', 'chrome')} + > + + + + + Get Chrome Extension + + from Chrome Web Store + + + + Get Now +
+ } + onClick={() => openLink('https://addons.mozilla.org/en-US/firefox/addon/neo-downloader-plus', 'firefox')} + > + + + + + Get Firefox Extension + + from Mozilla Addons Store + +
+
+ + + + + +
+

* These links opens with coresponding browsers only. Make sure the browser is installed befor clicking the link

+
+ +

Websocket Port

Change extension websocket server port

diff --git a/src/routes.ts b/src/routes.ts index 196d850..a52cd1a 100644 --- a/src/routes.ts +++ b/src/routes.ts @@ -1,4 +1,4 @@ -import { Download, Puzzle, Settings, SquarePlay } from "lucide-react"; +import { Download, Settings, SquarePlay } from "lucide-react"; import { RoutesObj } from "@/types/route"; export const AllRoutes: Array = [ @@ -12,11 +12,6 @@ export const AllRoutes: Array = [ url: "/library", icon: SquarePlay, }, - { - title: "Extension", - url: "/extension", - icon: Puzzle, - }, { title: "Settings", url: "/settings", diff --git a/src/services/store.ts b/src/services/store.ts index 863faa4..35d8514 100644 --- a/src/services/store.ts +++ b/src/services/store.ts @@ -93,7 +93,7 @@ export const useDownloadActionStatesStore = create((s })); export const useSettingsPageStatesStore = create((set) => ({ - activeTab: 'general', + activeTab: 'app', appVersion: null, isFetchingAppVersion: false, ytDlpVersion: null,