mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-26 01:06:23 +02:00
feat: integrate document upload dialog and enhance dashboard layout
- Added DocumentUploadDialogProvider to manage document upload dialog state across components. - Updated DashboardClientLayout to include the DocumentUploadDialogProvider for improved user experience. - Refactored DocumentsTableShell to utilize the new dialog for file uploads instead of navigating to a separate upload page. - Removed the deprecated upload page and streamlined document upload handling within the dialog. - Enhanced DocumentUploadTab with improved file type handling and user feedback during uploads. - Updated GridPattern styling for better visual consistency.
This commit is contained in:
parent
aa96e08231
commit
5ebb9d7aea
7 changed files with 316 additions and 273 deletions
|
|
@ -9,8 +9,8 @@ import {
|
|||
} from "@assistant-ui/react";
|
||||
import { FileText, Loader2, Paperclip, PlusIcon, Upload, XIcon } from "lucide-react";
|
||||
import Image from "next/image";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import { type FC, type PropsWithChildren, useRef, useEffect, useState } from "react";
|
||||
import { useDocumentUploadDialog } from "./document-upload-popup";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { TooltipIconButton } from "@/components/assistant-ui/tooltip-icon-button";
|
||||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
|
||||
|
|
@ -319,19 +319,22 @@ export const ComposerAttachments: FC = () => {
|
|||
};
|
||||
|
||||
export const ComposerAddAttachment: FC = () => {
|
||||
const router = useRouter();
|
||||
const params = useParams();
|
||||
const searchSpaceId = params.search_space_id as string;
|
||||
const chatAttachmentInputRef = useRef<HTMLInputElement>(null);
|
||||
const { openDialog } = useDocumentUploadDialog();
|
||||
|
||||
const handleFileUpload = () => {
|
||||
router.push(`/dashboard/${searchSpaceId}/documents/upload`);
|
||||
openDialog();
|
||||
};
|
||||
|
||||
const handleChatAttachment = () => {
|
||||
chatAttachmentInputRef.current?.click();
|
||||
};
|
||||
|
||||
// Prevent event bubbling when file input is clicked
|
||||
const handleFileInputClick = (e: React.MouseEvent<HTMLInputElement>) => {
|
||||
e.stopPropagation();
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<DropdownMenu>
|
||||
|
|
@ -354,7 +357,7 @@ export const ComposerAddAttachment: FC = () => {
|
|||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={handleFileUpload} className="cursor-pointer">
|
||||
<Upload className="size-4" />
|
||||
<span>File upload</span>
|
||||
<span>Upload Files</span>
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
|
|
@ -365,6 +368,7 @@ export const ComposerAddAttachment: FC = () => {
|
|||
multiple
|
||||
className="hidden"
|
||||
accept="image/*,application/pdf,.doc,.docx,.txt"
|
||||
onClick={handleFileInputClick}
|
||||
/>
|
||||
</ComposerPrimitive.AddAttachment>
|
||||
</>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue