diff --git a/src/app/(theme)/connect/connection-string-input.tsx b/src/app/(theme)/connect/connection-string-input.tsx index 787e83d6..13afda5b 100644 --- a/src/app/(theme)/connect/connection-string-input.tsx +++ b/src/app/(theme)/connect/connection-string-input.tsx @@ -6,6 +6,7 @@ import { } from "./saved-connection-storage"; import { Input } from "@/components/ui/input"; import FileHandlerPicker from "@/components/filehandler-picker"; +import { CommonDialogProvider } from "@/components/common-dialog"; export default function ConnectionStringInput({ value, @@ -68,12 +69,14 @@ export default function ConnectionStringInput({ ); } else if (field.type === "filehandler") { inputDom = ( - { - onChange({ ...value, [field.name]: fileId }); - }} - /> + + { + onChange({ ...value, [field.name]: fileId }); + }} + /> + ); } diff --git a/src/components/filehandler-picker.tsx b/src/components/filehandler-picker.tsx index 3152b801..3f07faea 100644 --- a/src/components/filehandler-picker.tsx +++ b/src/components/filehandler-picker.tsx @@ -4,6 +4,8 @@ import { localDb } from "@/indexdb"; import { LucideFile, LucideFolderClosed } from "lucide-react"; import { cn } from "@/lib/utils"; import { SavedConnectionLocalStorage } from "@/app/(theme)/connect/saved-connection-storage"; +import { unsupportFileHandlerDialogContent } from "./screen-dropzone"; +import { useCommonDialog } from "./common-dialog"; /** * Cleanup file handler from indexdb database when @@ -64,6 +66,7 @@ export default function FileHandlerPicker({ onChange: (file: string) => void; }) { const [handler, setHandler] = useState(); + const { showDialog } = useCommonDialog(); useEffect(() => { if (value) { @@ -76,11 +79,17 @@ export default function FileHandlerPicker({ }, [value]); const onChangeFile = useCallback(() => { - cleanupFileHandler() - .then(openFileHandler) - .then(onChange) - .catch(console.error); - }, [onChange]); + try { + cleanupFileHandler() + .then(openFileHandler) + .then(onChange) + .catch(() => { + showDialog(unsupportFileHandlerDialogContent); + }); + } catch { + showDialog(unsupportFileHandlerDialogContent); + } + }, [onChange, showDialog]); if (handler) { return ( diff --git a/src/components/screen-dropzone.tsx b/src/components/screen-dropzone.tsx index f5e26ed8..aa43a210 100644 --- a/src/components/screen-dropzone.tsx +++ b/src/components/screen-dropzone.tsx @@ -2,11 +2,61 @@ import { useEffect } from "react"; import { useCommonDialog } from "./common-dialog"; +import Link from "next/link"; interface Props { onFileDrop: (handler: FileSystemFileHandle) => void; } +export const unsupportFileHandlerDialogContent = { + destructive: true, + title: "Unsupported Browser", + content: ( +

+

+ Outerbase Studio SQLite client requires the{" "} + + FileSystemHandle + {" "} + API to function. +

+ +

+ This API is currently supported only by Chromium-based browsers, such as{" "} + Edge, Chrome, and Brave. Learn more about it here:{" "} + + FileSystemHandle API + + . +

+ +

+ If you're encountering this issue in Brave, note that the File + System API is disabled by default. To enable it: +

+ + +

+ ), +}; + export default function ScreenDropZone({ onFileDrop }: Props) { const { showDialog } = useCommonDialog(); @@ -23,11 +73,7 @@ export default function ScreenDropZone({ onFileDrop }: Props) { try { (fileList[0] as any).getAsFileSystemHandle().then(onFileDrop); } catch (error) { - showDialog({ - destructive: true, - title: "Warning", - content: "Your browser are not support. please use another browser.", - }); + showDialog(unsupportFileHandlerDialogContent); } };