feat: add drag-and-drop logo upload for organizations#4765
Open
imrja8 wants to merge 4 commits into
Open
Conversation
- Integrated Dropzone component into handle-organization.tsx. - Resolved dialog auto-close bug by decoupling Dialog from DropdownMenu trigger. - Added DOMPurify to sanitize uploaded SVG logos preventing XSS. - Implemented client-side compression via canvas to resize raster images to 256x256 WebP. - Enhanced UX with instant logo preview, masked base64 input strings, and a quick-clear button. - Updated Dropzone to accept classNameContent for local height overrides.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this PR about?
This PR introduces a drag-and-drop feature for uploading Organization Profiles/Logos. It brings parity to how icons are managed elsewhere in the application, but with a heavy emphasis on security, performance, and user experience:
User Experience (UX)
Dropzonecomponent into the "Add/Update Organization" dialog for seamless file uploads.logo.png) or a fallback "Uploaded image" text, while dynamically setting the field to read-only.GlobeIconand instantly swaps to the uploaded image without causing jarring layout shifts.DropdownMenucaused the dialog to prematurely close. Fixed by decoupling theAddOrganizationdialog from the dropdown trigger.Security
.svguploads are parsed throughDOMPurifybefore being converted to a data URL, mitigating any potential Cross-Site Scripting (XSS) risks from malicious scripts embedded in the XML.Performance
organizationtable, any raster images (JPG, PNG, WebP) uploaded via the dropzone are instantly processed through a background HTML Canvas, resized to a maximum of256x256pixels, and compressed into the highly efficient WebP format. This shrinks typical 2MB user uploads to roughly ~15KB before they ever hit the database.Why and How
Users requested the ability to easily upload organization logos. However, storing raw, massive Base64 images directly into the PostgreSQL
TEXTcolumn creates unnecessary network/DB bottlenecks. UtilizedFileReaderto extract file contents,DOMPurifyfor SVG cleaning, and a nativecanvascontext for downscaling raster images. Furthermore, the globalDropzoneUI component was updated with a newclassNameContentprop to allow targeted height overrides, ensuring this specific dropzone fits the form perfectly without affecting global instances.Verification
Checklist
Before submitting this PR, please make sure that:
canarybranch.Issues related (if applicable)
closes #4727
Screenshots (if applicable)
Custom URL Input Working Perfectly

Drag and Drop Working Perfectly
