google drive integration
Summary by CodeRabbit
-
New Features
- Added Google Drive integration, allowing users to connect their account, browse, and import files or folders directly into the application.
- Introduced a multi-step Google Drive import flow with a dedicated picker, folder/file tree view, and bulk upload confirmation.
- Added a comprehensive upload progress panel and minimized upload progress UI for tracking multiple file uploads.
- Created an "Integrations" settings page for managing connected services.
-
Improvements
- Expanded the document upload modal to support Google Drive alongside existing upload and Notion options.
- Enhanced status notifications and error handling during file uploads and integration flows.
-
Bug Fixes
- Improved error handling and user notifications for Google Drive authentication and upload errors.
-
Database & Schema
- Added new fields and tables to support Google Drive integration and file/folder associations.
-
Documentation
- Updated navigation and UI to reflect new integration capabilities.
@AshishViradiya153 is attempting to deploy a commit to the mftsio Team on Vercel.
A member of the Team first needs to authorize it.
@coderabbitai full review
✅ Actions performed
Full review triggered.
[!IMPORTANT]
Review skipped
Draft detected.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.
Walkthrough
This update introduces comprehensive Google Drive integration into the application. It adds OAuth-based connection management, file/folder selection via Google Picker, recursive folder/file import and upload, and batch upload progress tracking. The backend supports Google Drive file/folder metadata, upload sessions, folder structure creation, and document association. UI components and database schema are extended to accommodate these new features, including integration management in settings.
Changes
| File(s) / Area | Change Summary |
|---|---|
components/documents/add-document-modal.tsx |
Enhanced AddDocumentModal to support Google Drive import: new tabs, Google Drive picker integration, recursive folder/file processing, confirmation dialog, error handling, and extended state management. Added new interfaces for file/folder metadata. |
components/documents/upload-notification-drawer.tsx,components/minimized-upload-progress.tsx,components/google-drive-upload-progress.tsx |
Added new components for upload progress: UploadNotificationDrawer manages drawer state and displays upload progress; MinimizedUploadProgress provides a compact view; GoogleDriveUploadProgress offers detailed, filterable upload status for Google Drive uploads. |
components/integrations/google-drive/google-drive-picker.tsx |
New GoogleDrivePicker component for selecting files/folders from Google Drive using the Picker API, with dynamic script loading, OAuth token handling, error management, and UI feedback. |
components/integrations/google-drive/google-drive.tsx |
New GoogleDriveIntegration component and hooks for managing connection status, OAuth flow, and disconnection. Handles state, user feedback, and triggers OAuth requests. |
components/settings/settings-header.tsx |
Added "Integrations" navigation item to the settings menu. |
components/shared/icons/google-drive.tsx |
Added GoogleDrive SVG icon component. |
components/ui/badge.tsx |
Added "success" badge variant with green styling. |
components/ui/confirmation-dialog.tsx |
New ConfirmationDialog component for modal confirmation with customizable messages and counts. |
lib/api/documents/process-document.tslib/documents/create-document.ts |
Added optional googleDriveFileId to document creation parameters and database record, supporting association of documents with Google Drive files. |
lib/auth/gdrive-upload-session.ts |
New module for managing Google Drive upload sessions in Redis, with Zod schema validation and session lifecycle functions. |
lib/context/upload-context.tsx |
Introduced UploadContext and provider for managing upload state and operations across the app. |
lib/files/file-utils.ts |
New utility functions for creating and finding folder records in the database, supporting both standard and dataroom folders, with Google Drive folder ID support. |
lib/files/process-and-upload.ts |
New module for recursively creating folder structures and processing Google Drive file uploads, including folder uniqueness, path construction, and PDF page counting. |
lib/files/tus-upload.ts |
Extended resumableUpload to support Buffer or File input, explicit fileName/fileType, and Google Drive file ID metadata. Updated upload result accordingly. |
lib/google-drive.ts |
New GoogleDriveClient class for managing OAuth2, token refresh, recursive file/folder listing, file download, token revocation, and disconnect. Singleton pattern, shortcut resolution, and error constants included. |
lib/hooks/use-google-drive-token.ts |
New hook for managing and refreshing Google Drive access tokens, with error handling and UI feedback. |
lib/hooks/use-google-drive-upload.ts |
New hook for managing Google Drive upload lifecycle: progress, error, document creation, session management, and UI state. Integrates with real-time updates and SWR. |
lib/swr/use-google-drive-integration.ts |
New SWR hook for fetching and managing Google Drive integration status. |
lib/trigger/batch-file-upload.ts |
New Trigger.dev task for batch file upload: manages chunked uploads, folder creation, progress/error tracking, document creation, dataroom association, and final status reporting. |
lib/utils/node-pdf-page-counter.ts |
New utility for estimating PDF page count from a Buffer using multiple heuristics. |
package.json |
Added googleapis dependency for Google Drive API integration. |
pages/_app.tsx |
Wrapped app in UploadProvider, added UploadNotificationDrawer, and inserted viewport meta tag for responsiveness. |
pages/api/file/browser-upload.ts |
Added a single comment for file identification. |
pages/api/integrations/google-drive/batch-upload.ts |
New POST API handler for batch uploading Google Drive files; validates input, triggers batch upload job, and manages upload session cookie. |
pages/api/integrations/google-drive/callback.ts |
New API handler for OAuth2 callback: validates state, exchanges code for tokens, fetches profile, stores integration, and redirects with status. |
pages/api/integrations/google-drive/disconnect.ts |
New POST API handler for disconnecting Google Drive integration, revoking tokens, and removing integration record. |
pages/api/integrations/google-drive/generate-state.ts |
New GET API handler for generating secure OAuth2 state parameter with checksum. |
pages/api/integrations/google-drive/index.tsx |
New GET API handler for fetching and refreshing Google Drive integration status and tokens. |
pages/api/integrations/google-drive/list-files.ts |
New POST API handler for recursively listing files/folders from Google Drive, building folder tree, and returning metadata. |
pages/api/integrations/google-drive/upload-session.ts |
New API handler for managing upload session lifecycle: fetch, validate, delete, and clear session cookies. |
pages/api/teams/[teamId]/datarooms/[id]/documents/index.ts |
Extended POST handler to support API token authentication, accept googleDriveFileId, and allow configurable notification delay. |
pages/api/teams/[teamId]/documents/index.ts |
POST handler now accepts optional googleDriveFileId for associating documents with Google Drive files. |
pages/settings/integrations.tsx |
New Integrations settings page with GoogleDriveIntegration component and layout. |
prisma/migrations/20250424171651_google_drive/migration.sql |
Database migration: added GoogleDriveIntegration table, new columns for Google Drive IDs in Document, Folder, DataroomDocument, and DataroomFolder tables, with indexes and constraints. |
prisma/schema/dataroom.prisma |
Schema: added googleDriveFileId and googleDriveFolderId fields to DataroomDocument and DataroomFolder models. |
prisma/schema/schema.prisma |
Schema: added GoogleDriveIntegration model, new fields for Google Drive IDs in User, Document, and Folder models, and relations/indexes. |
Sequence Diagram(s)
Google Drive File Import and Upload Flow
sequenceDiagram
participant User
participant AddDocumentModal
participant GoogleDrivePicker
participant BackendAPI
participant UploadContext
participant UploadNotificationDrawer
User->>AddDocumentModal: Opens modal
AddDocumentModal->>User: Shows tabs (Document, Google Drive, Notion)
User->>AddDocumentModal: Selects "Google Drive" tab
AddDocumentModal->>GoogleDrivePicker: Initiates file/folder picker
GoogleDrivePicker->>User: User selects files/folders
GoogleDrivePicker->>AddDocumentModal: Returns selected items
AddDocumentModal->>BackendAPI: POST /api/integrations/google-drive/list-files
BackendAPI->>AddDocumentModal: Returns folder tree & file metadata
AddDocumentModal->>User: Shows confirmation dialog (file/folder count)
User->>AddDocumentModal: Confirms upload
AddDocumentModal->>UploadContext: startUpload(treeFiles, filesList, etc.)
UploadContext->>BackendAPI: Triggers batch upload (Trigger.dev)
UploadContext->>UploadNotificationDrawer: Updates upload progress
UploadNotificationDrawer->>User: Displays upload status
UploadContext->>User: Notifies on completion/errors
Google Drive Integration Management Flow
sequenceDiagram
participant User
participant GoogleDriveIntegration
participant BackendAPI
User->>GoogleDriveIntegration: Clicks "Connect"
GoogleDriveIntegration->>BackendAPI: GET /api/integrations/google-drive/generate-state
GoogleDriveIntegration->>User: Redirects to Google OAuth
User->>BackendAPI: Google OAuth callback (/api/integrations/google-drive/callback)
BackendAPI->>GoogleDriveIntegration: Stores tokens, updates status
User->>GoogleDriveIntegration: Sees connected status
User->>GoogleDriveIntegration: Clicks "Disconnect"
GoogleDriveIntegration->>BackendAPI: POST /api/integrations/google-drive/disconnect
BackendAPI->>GoogleDriveIntegration: Revokes tokens, removes integration
GoogleDriveIntegration->>User: Updates to disconnected status
Poem
🐰✨
In the warren of code, new tunnels appear,
Google Drive now hops in—let’s all give a cheer!
With folders and files, and uploads in flight,
Progress bars twinkle, integrations feel right.
From OAuth to icons, the changes are wide—
Now Papermark’s ready for a Drive-powered ride!
🚀📄🌱
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
-
I pushed a fix in commit <commit_id>, please review it. -
Explain this complex logic. -
Open a follow-up GitHub issue for this discussion.
-
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:-
@coderabbitai explain this code block. -
@coderabbitai modularize this function.
-
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:-
@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase. -
@coderabbitai read src/utils.ts and explain its main purpose. -
@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format. -
@coderabbitai help me debug CodeRabbit configuration file.
-
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
-
@coderabbitai pauseto pause the reviews on a PR. -
@coderabbitai resumeto resume the paused reviews. -
@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai full reviewto do a full review from scratch and review all the files again. -
@coderabbitai summaryto regenerate the summary of the PR. -
@coderabbitai generate docstringsto generate docstrings for this PR. -
@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR. -
@coderabbitai resolveresolve all the CodeRabbit review comments. -
@coderabbitai configurationto show the current CodeRabbit configuration for the repository. -
@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.