From 627b2f75fee230a7770fc60f59fb1b1740cadb10 Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Tue, 26 Jan 2016 13:41:15 +0100 Subject: [PATCH 1/2] Extract extension using file name rather that mime type for uploader preview Also adds ellipsis overflow to the extension name to prevent long extensions from resizing the preview element and removes redundant `.file-drag-and-drop-preview-table-wrapper` class --- .../file_drag_and_drop_preview.js | 17 +++++++------- .../file_drag_and_drop_preview_other.js | 19 +++++++--------- sass/ascribe_uploader.scss | 22 ++++++------------- 3 files changed, 24 insertions(+), 34 deletions(-) diff --git a/js/components/ascribe_uploader/ascribe_file_drag_and_drop/file_drag_and_drop_preview.js b/js/components/ascribe_uploader/ascribe_file_drag_and_drop/file_drag_and_drop_preview.js index ca1be2d2..0f95427d 100644 --- a/js/components/ascribe_uploader/ascribe_file_drag_and_drop/file_drag_and_drop_preview.js +++ b/js/components/ascribe_uploader/ascribe_file_drag_and_drop/file_drag_and_drop_preview.js @@ -23,6 +23,7 @@ const FileDragAndDropPreview = React.createClass({ s3Url: string, s3UrlSafe: string }).isRequired, + handleDeleteFile: func, handleCancelFile: func, handlePauseFile: func, @@ -33,9 +34,9 @@ const FileDragAndDropPreview = React.createClass({ }, toggleUploadProcess() { - if(this.props.file.status === 'uploading') { + if (this.props.file.status === 'uploading') { this.props.handlePauseFile(this.props.file.id); - } else if(this.props.file.status === 'paused') { + } else if (this.props.file.status === 'paused') { this.props.handleResumeFile(this.props.file.id); } }, @@ -54,13 +55,13 @@ const FileDragAndDropPreview = React.createClass({ (file.status === 'upload successful' || file.status === 'online') && file.s3UrlSafe) { handleDeleteFile(file.id); - } else if(handleCancelFile) { + } else if (handleCancelFile) { handleCancelFile(file.id); } }, handleDownloadFile() { - if(this.props.file.s3Url) { + if (this.props.file.s3Url) { // This simply opens a new browser tab with the url provided open(this.props.file.s3Url); } @@ -69,7 +70,7 @@ const FileDragAndDropPreview = React.createClass({ getFileName() { const { numberOfDisplayedFiles, file } = this.props; - if(numberOfDisplayedFiles === 1) { + if (numberOfDisplayedFiles === 1) { return ( {truncateTextAtCharIndex(file.name, 30, '(...).' + extractFileExtensionFromString(file.name))} @@ -81,7 +82,7 @@ const FileDragAndDropPreview = React.createClass({ }, getRemoveButton() { - if(this.props.areAssetsEditable) { + if (this.props.areAssetsEditable) { return (