Skip to content

Conversation

@abdulrahmancodes
Copy link
Contributor

@abdulrahmancodes abdulrahmancodes commented Dec 5, 2025

Screenshot 2025-12-06 at 12 50 42 AM

Closes #15771

- Removed unused previewable extension logic from AttachmentRow.
- Simplified link rendering in AttachmentRow for better readability.
- Enhanced DocumentViewer to handle non-previewable files with a user-friendly message and download option.
- Added styled components for unavailable preview messages in DocumentViewer.
@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:55958

This environment will automatically shut down when the PR is closed or after 5 hours.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 5, 2025

Greptile Overview

Greptile Summary

Refactored file preview handling to show friendly messages for non-previewable files. The previewability check was moved from AttachmentRow into DocumentViewer, improving separation of concerns. When users click on non-previewable files (like archives), they now see a contextual message with a download button instead of having the file open in a new tab.

Key changes:

  • Simplified AttachmentRow by removing duplicate previewability logic - all files now use the same click handler
  • Added fallback UI in DocumentViewer for non-previewable files with contextual messages differentiating archives from other file types
  • Maintained support for Cmd/Ctrl+click to bypass preview and open files in new tabs

Confidence Score: 4/5

  • This PR is safe to merge with one logic issue that should be verified
  • The refactoring improves code organization by moving the previewability check into DocumentViewer. However, there is one comment flagged about the click handler logic that should be reviewed to ensure the interaction behavior is as intended for all file types and preview states
  • Pay attention to AttachmentRow.tsx to verify the click handler behavior works correctly for all combinations of preview enabled/disabled and previewable/non-previewable files

Important Files Changed

File Analysis

Filename Score Overview
packages/twenty-front/src/modules/activities/files/components/AttachmentRow.tsx 4/5 Simplified attachment link logic by removing previewability check - now all files trigger preview modal when clicked
packages/twenty-front/src/modules/activities/files/components/DocumentViewer.tsx 5/5 Added friendly UI for non-previewable files with contextual messages and download button

Sequence Diagram

sequenceDiagram
    participant User
    participant AttachmentRow
    participant AttachmentList
    participant Modal
    participant DocumentViewer
    
    User->>AttachmentRow: Click attachment link
    AttachmentRow->>AttachmentRow: handleOpenDocument()
    alt Preview enabled (onPreview defined)
        AttachmentRow->>AttachmentRow: e.preventDefault()
        AttachmentRow->>AttachmentList: onPreview(attachment)
        AttachmentList->>Modal: openModal(PREVIEW_MODAL_ID)
        Modal->>DocumentViewer: Render with documentUrl and documentName
        DocumentViewer->>DocumentViewer: Check isPreviewable
        alt File is previewable
            DocumentViewer->>DocumentViewer: Render DocViewer component
            DocumentViewer-->>User: Show file preview
        else File is NOT previewable
            DocumentViewer->>DocumentViewer: Render friendly message UI
            DocumentViewer-->>User: Show "Preview Not Available" with download button
        end
    else Preview disabled (onPreview undefined)
        AttachmentRow-->>User: Link opens in new tab (default behavior)
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Comments (1)

  1. packages/twenty-front/src/modules/activities/files/components/AttachmentRow.tsx, line 143-154 (link)

    logic: logic bug: clicking a non-previewable file now triggers both the modal and opens a new tab

    The onClick handler will fire regardless of whether the file is previewable, calling onPreview(attachment) which opens the modal. The link also opens a new tab because e.preventDefault() only runs when onPreview exists AND the user doesn't press modifier keys.

    For non-previewable files, we want the link to open in a new tab WITHOUT opening the modal. The previous code checked isPreviewable before deciding which behavior to use.

    Consider restoring the previewability check or moving it into handleOpenDocument:

    But you'll also need to add back the isPreviewable logic to conditionally attach the onClick handler.

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File preview - Improve zip file preview

2 participants