Skip to content

Conversation

@amjedidiah
Copy link
Contributor

Added the following event listeners:

  • onClick
  • onUpload
  • onUploadFail
  • onCompletedUpload
  • onAllCompleted
  • onFileRemove
  • onDragOver
  • onDragLeave
  • onDrop
  • onFileProgress
  • onTotalProgress

- Added support for previewing multiple file types (PDF, DOCX, XLSX, etc.)
- Implemented `react-file-viewer` for better file preview capabilities
- Maintained fallback to FileIcon component when preview fails

OTHER CHANGES
- Resolved React version mismatch (16.14.0 -> 18.2.0) to fix hook errors in Storybook
- Added VSCode workspace folder to `.gitignore`

BREAKING CHANGE: New dependency `react-file-viewer` is required
- Added hover effect with background color change and shadow elevation
- Implemented cursor pointer for clickable file previews
- Added active state for click feedback
- Enhanced dark mode hover states
- Maintained consistent hover behaviour across mini and full preview modes
- Added modal-based DOCX preview to prevent interference between multiple previews
- Created FileWithId interface and shared type definitions
- Fixed file ID generation and management
- Added proper cleanup for object URLs
- Ensured consistent key generation for previews

BREAKING CHANGE: File state type is now FileWithId[] instead of File[]
- Replaced DOCX-specific preview with universal file preview component
- Added modal preview support for all file types
- Fixed file name truncation in preview cards
- Added file handling events (onFileClick, onFilesChange, onFileRemove)
- Added upload lifecycle events (onUpload, onCompletedUpload, onAllCompleted, onUploadFail)
- Added progress tracking events (onFileProgress, onTotalProgress)
- Added drag-and-drop events (onDragOver, onDragLeave, onDrop)
- Added integration selection event (onClick)

The event system provides granular control and visibility into:
- File selection and removal
- Upload progress per file and overall
- Upload success/failure states
- Drag-and-drop interactions
- Integration method selection
- Updates

Demonstrates all events in Storybook with status updates and console logs
Copy link
Collaborator

Choose a reason for hiding this comment

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

It might be worth including a few additional events to cover more use cases and enhance flexibility. Here are some suggestions:

onFileTypeMismatch: Called when a file's type doesn’t match the allowed types, useful for providing feedback about supported formats.

onCancelUpload: Handles user-initiated upload cancellations, providing better control over the upload flow.

We could benefit from slight refinements to reduce ambiguity and ensure consistency.

onClick
Issue: The name is too generic and doesn’t describe its purpose (related to integration type selection).
Suggestion: Rename it to onIntegrationClick or onIntegrationSelected to clarify its intent.

onUpload
Issue: Could be misinterpreted as a trigger for when the entire upload process starts, but it actually refers to individual file uploads.
Suggestion: Rename it to onFileUploadStart for clarity.

onCompletedUpload

Issue: The name doesn’t specify that it’s for a single file’s upload completion.
Suggestion: Rename it to onFileUploadComplete to indicate it's for individual files.
onAllCompleted

Issue: Slightly ambiguous; could be confused with completing all operations, not just uploads.
Suggestion: Rename it to onAllUploadsComplete to make it clear it relates to uploads.

onUploadFail

Issue: The name is fine but could be improved for consistency with other events.
Suggestion: Rename it to onFileUploadFail.

onTotalProgress

Issue: Clear for aggregate progress but could use a slight clarification for upload context.
Suggestion: Rename it to onTotalUploadProgress.

Drag events could be prefixed with onFile (e.g., onFileDragOver) for better specificity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @BSalaeddin , done

…tency

per review, changed:
- `onClick` to `onIntegrationClick`
- `onUpload` to `onFileUploadStart`
- `onCompletedUpload` to `onFileUploadComplete`
- `onAllCompleted` to `onAllUploadsComplete`
- `onUploadFail` to `onFileUploadFail`
- `onTotalProgress` to `onTotalUploadProgress`
- `onDragOver` to `onFileDragOver`
- `onDragLeave` to `onFileDragLeave`
- `onDrop` to `onFileDrop`

fix failing build caused by `src/lib/uploadObject.ts`
@amjedidiah amjedidiah changed the title Cu 86b2qw06r feat add upload event listeners [pending review changes] Cu 86b2qw06r feat add upload event listeners Nov 25, 2024
- Added onFileTypeMismatch event to handle file type validation failures
- Added onCancelUpload event for upload cancellation handling
- Updated useProgress hook to properly handle upload abortion
- Exposed cancelUpload method through component ref
@MedAmine1212 MedAmine1212 self-requested a review November 26, 2024 19:46
Comment on lines 67 to 73
// Add this helper function at the top level
const createFileWithId = (file: File) => {
return Object.assign(file, {
id: `${file.name}-${file.size}-${file.lastModified}-${Math.random()}`,
})
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Change math.random() with an actual UUID.
(please make sure to not use math.random anywhere)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @MedAmine1212, done

@amjedidiah amjedidiah changed the title [pending review changes] Cu 86b2qw06r feat add upload event listeners Cu 86b2qw06r feat add upload event listeners Nov 26, 2024
@amjedidiah amjedidiah merged commit 54c53aa into DevinoSolutions:master Nov 27, 2024
2 checks passed
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.

3 participants