Skip to content

Feature/handle non renderable content 1067 #1095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

BeckettFrey
Copy link

@BeckettFrey BeckettFrey commented Aug 8, 2025

Closes #1067

Summary

This PR introduces new FilePreview and SideBySideFilePreview React components to enhance the diff view experience for non-renderable file types (e.g., .xlsx, .docx, .zip). Instead of attempting to render these files inline—which previously caused automatic downloads and blank comparison windows—the UI now displays comprehensive file metadata and provides clear action buttons. This dramatically improves the user experience when reviewing unsupported file formats.

Changes

  • New Diff Types: Added FILE_PREVIEW and SIDE_BY_SIDE_FILE_PREVIEW constants in diff-types.js
  • Smart Content Detection: Implemented isNonRenderableType() to automatically detect non-renderable files
  • FilePreview Component: Displays file name, media type, size, hash, capture time, and action buttons
  • SideBySideFilePreview Component: Enables side-by-side comparison of non-renderable files
  • Integration: Updated ChangeView and DiffView to use new components with smart defaults
  • Styling: Added responsive CSS for clean, professional file preview interface

Problem Solved

Before: Excel files (.xlsx) triggered browser downloads and left blank comparison screens
After: Clean file information display with "View Raw File" and "Download File" buttons

Testing

  • Unit Tests: Added 14 new tests covering file preview components and smart detection logic
  • Test Coverage: FilePreview rendering, button functionality, edge cases (missing filenames, etc.)
  • Content Detection Tests: Verify Excel→FilePreview, HTML→Traditional diff views
  • Build Verification: All tests pass (93/93), clean linting, successful build
  • Visual Demo: Created standalone demo to verify component rendering and behavior

File Types Affected

Non-Renderable (now uses File Preview):

  • Microsoft Office: .xlsx, .docx, .pptx, etc.
  • Archives: .zip, .tar.gz, etc.
  • Binary files and specialized formats

Renderable (unchanged behavior):

  • HTML, text files, PDFs, images, JSON, XML, audio/video

Notes

  • All changes are backward compatible
  • Raw view options remain available as fallback
  • Smart defaults: non-renderable files auto-select SIDE_BY_SIDE_FILE_PREVIEW
  • Comprehensive documentation included
  • Ready for production deployment

- Add new diff types for non-renderable content
- Implement smart content detection with isNonRenderableType()
- Auto-select file preview for Excel, Word, ZIP files etc.
- Maintain existing behavior for renderable content (HTML, PDF, images)

Addresses edgi-govdata-archiving#1067
- Display file metadata (name, type, size, hash, capture time)
- Provide 'View Raw File' and 'Download File' buttons
- Show clear warning about non-renderable content
- Responsive design with clean styling
- Extract filename from URLs gracefully

Addresses edgi-govdata-archiving#1067
- Compare two non-renderable files side-by-side
- Uses FilePreview components for consistent display
- Maintains existing side-by-side layout patterns
- Clear version labeling ('From Version', 'To Version')

Addresses edgi-govdata-archiving#1067
- Import FilePreview and SideBySideFilePreview components
- Add render cases for FILE_PREVIEW and SIDE_BY_SIDE_FILE_PREVIEW diff types
- Pass appropriate props (page, version, diffData) to components
- Maintain existing rendering logic for other diff types

Addresses edgi-govdata-archiving#1067
- Add defaultFilePreviewDiffType constant
- Update ensureValidDiffType() to detect non-renderable content
- Auto-default to SIDE_BY_SIDE_FILE_PREVIEW for Excel, Word, ZIP files
- Maintain SIDE_BY_SIDE_RENDERED default for HTML, images, etc.
- Ensures optimal user experience without manual selection

Addresses edgi-govdata-archiving#1067
- FilePreview component tests: file info display, buttons, warnings
- SideBySideFilePreview component tests: dual preview rendering
- Smart content detection tests: Excel→FilePreview, HTML→Traditional
- Test edge cases: missing filenames, various media types
- All tests pass (93/93 total, +14 new tests)

Addresses edgi-govdata-archiving#1067
- Comprehensive overview of file preview feature
- Details all components, files, and functionality added
- Documents testing approach and results
- Explains file type handling and user experience improvements
- Reference for future maintenance and enhancements

Addresses edgi-govdata-archiving#1067
@BeckettFrey
Copy link
Author

@Mr0grog Implementation is complete and fully tested. Happy to address or iterate on any feedback/questions/concerns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle non-renderable content better
1 participant