mirror of
https://github.com/ascribe/onion.git
synced 2024-11-15 01:25:17 +01:00
Various small changes for FileDragAndDrop
Changed: - If only one file submitted: hide file-specific progress bar + filename extension - Fix bug for when uploaded file is deleteable (avoid error) - Add checkmark for when file was actually submitted
This commit is contained in:
parent
e4479dc95b
commit
1cf8ac2f31
@ -41,14 +41,21 @@ const FileDragAndDropPreview = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleDeleteFile() {
|
handleDeleteFile() {
|
||||||
// handleDeleteFile is optional, so if its not submitted,
|
const { handleDeleteFile,
|
||||||
// don't run it
|
handleCancelFile,
|
||||||
// On the other hand, if the files progress is not yet at a 100%,
|
file } = this.props;
|
||||||
// just run fineuploader.cancel
|
// `handleDeleteFile` is optional, so if its not submitted, don't run it
|
||||||
if(this.props.handleDeleteFile && this.props.file.progress === 100) {
|
//
|
||||||
this.props.handleDeleteFile(this.props.file.id);
|
// For delete though, we only want to trigger it, when we're sure that
|
||||||
} else if(this.props.handleCancelFile && this.props.file.progress !== 100) {
|
// the file has *completely* been uploaded to S3 and call now also be
|
||||||
this.props.handleCancelFile(this.props.file.id);
|
// deleted using an HTTP DELETE request.
|
||||||
|
if (handleDeleteFile &&
|
||||||
|
file.progress === 100 &&
|
||||||
|
(file.status === 'upload successful' || file.status === 'online') &&
|
||||||
|
file.s3UrlSafe) {
|
||||||
|
handleDeleteFile(file.id);
|
||||||
|
} else if(handleCancelFile) {
|
||||||
|
handleCancelFile(file.id);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -107,7 +114,8 @@ const FileDragAndDropPreview = React.createClass({
|
|||||||
url={file.url}
|
url={file.url}
|
||||||
toggleUploadProcess={this.toggleUploadProcess}
|
toggleUploadProcess={this.toggleUploadProcess}
|
||||||
areAssetsDownloadable={areAssetsDownloadable}
|
areAssetsDownloadable={areAssetsDownloadable}
|
||||||
downloadUrl={file.s3UrlSafe}/>
|
downloadUrl={file.s3UrlSafe}
|
||||||
|
showProgress={numberOfDisplayedFiles > 1} />
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
previewElement = (
|
previewElement = (
|
||||||
@ -117,7 +125,8 @@ const FileDragAndDropPreview = React.createClass({
|
|||||||
type={file.type.split('/')[1]}
|
type={file.type.split('/')[1]}
|
||||||
toggleUploadProcess={this.toggleUploadProcess}
|
toggleUploadProcess={this.toggleUploadProcess}
|
||||||
areAssetsDownloadable={areAssetsDownloadable}
|
areAssetsDownloadable={areAssetsDownloadable}
|
||||||
downloadUrl={file.s3UrlSafe}/>
|
downloadUrl={file.s3UrlSafe}
|
||||||
|
showProgress={numberOfDisplayedFiles > 1} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ProgressBar from 'react-bootstrap/lib/ProgressBar';
|
import ProgressBar from 'react-bootstrap/lib/ProgressBar';
|
||||||
|
|
||||||
|
import AclProxy from '../../acl_proxy';
|
||||||
import AscribeSpinner from '../../ascribe_spinner';
|
import AscribeSpinner from '../../ascribe_spinner';
|
||||||
import { getLangText } from '../../../utils/lang_utils';
|
import { getLangText } from '../../../utils/lang_utils';
|
||||||
|
|
||||||
@ -15,7 +16,8 @@ const FileDragAndDropPreviewImage = React.createClass({
|
|||||||
url: string,
|
url: string,
|
||||||
toggleUploadProcess: func,
|
toggleUploadProcess: func,
|
||||||
downloadUrl: string,
|
downloadUrl: string,
|
||||||
areAssetsDownloadable: bool
|
areAssetsDownloadable: bool,
|
||||||
|
showProgress: bool
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
@ -36,40 +38,45 @@ const FileDragAndDropPreviewImage = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let imageStyle = {
|
const { url,
|
||||||
backgroundImage: 'url("' + this.props.url + '")',
|
progress,
|
||||||
|
areAssetsDownloadable,
|
||||||
|
downloadUrl,
|
||||||
|
showProgress } = this.props;
|
||||||
|
const imageStyle = {
|
||||||
|
backgroundImage: 'url("' + url + '")',
|
||||||
backgroundSize: 'cover'
|
backgroundSize: 'cover'
|
||||||
};
|
};
|
||||||
|
|
||||||
let actionSymbol;
|
let actionSymbol;
|
||||||
|
|
||||||
if(this.props.progress > 0 && this.props.progress < 99 && this.state.paused) {
|
|
||||||
actionSymbol = <span className="glyphicon glyphicon-pause action-file" aria-hidden="true" title={getLangText('Pause upload')} onClick={this.toggleUploadProcess}/>;
|
|
||||||
} else if(this.props.progress > 0 && this.props.progress < 99 && !this.state.paused) {
|
|
||||||
actionSymbol = <span className="glyphicon glyphicon-play action-file" aria-hidden="true" title={getLangText('Resume uploading')} onClick={this.toggleUploadProcess}/>;
|
|
||||||
} else if(this.props.progress === 100) {
|
|
||||||
|
|
||||||
// only if assets are actually downloadable, there should be a download icon if the process is already at
|
// only if assets are actually downloadable, there should be a download icon if the process is already at
|
||||||
// 100%. If not, no actionSymbol should be displayed
|
// 100%. If not, no actionSymbol should be displayed
|
||||||
if(this.props.areAssetsDownloadable) {
|
if(progress === 100 && areAssetsDownloadable) {
|
||||||
actionSymbol = <a href={this.props.downloadUrl} target="_blank" className="glyphicon glyphicon-download action-file" aria-hidden="true" title={getLangText('Download file')}/>;
|
actionSymbol = <a href={downloadUrl} target="_blank" className="glyphicon glyphicon-download action-file" aria-hidden="true" title={getLangText('Download file')}/>;
|
||||||
}
|
} else if(progress >= 0 && progress < 100) {
|
||||||
|
|
||||||
} else {
|
|
||||||
actionSymbol = (
|
actionSymbol = (
|
||||||
<div className="spinner-file">
|
<div className="spinner-file">
|
||||||
<AscribeSpinner color='dark-blue' size='md' />
|
<AscribeSpinner color='dark-blue' size='md' />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
actionSymbol = (
|
||||||
|
<span
|
||||||
|
className="glyphicon glyphicon-ok action-file" />
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="file-drag-and-drop-preview-image"
|
className="file-drag-and-drop-preview-image"
|
||||||
style={imageStyle}>
|
style={imageStyle}>
|
||||||
|
<AclProxy
|
||||||
|
show={showProgress}>
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
now={Math.ceil(this.props.progress)}
|
now={Math.ceil(progress)}
|
||||||
className="ascribe-progress-bar ascribe-progress-bar-xs"/>
|
className="ascribe-progress-bar ascribe-progress-bar-xs"/>
|
||||||
|
</AclProxy>
|
||||||
{actionSymbol}
|
{actionSymbol}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ProgressBar from 'react-bootstrap/lib/ProgressBar';
|
import ProgressBar from 'react-bootstrap/lib/ProgressBar';
|
||||||
|
|
||||||
|
import AclProxy from '../../acl_proxy';
|
||||||
import AscribeSpinner from '../../ascribe_spinner';
|
import AscribeSpinner from '../../ascribe_spinner';
|
||||||
import { getLangText } from '../../../utils/lang_utils';
|
import { getLangText } from '../../../utils/lang_utils';
|
||||||
|
|
||||||
@ -15,7 +16,8 @@ const FileDragAndDropPreviewOther = React.createClass({
|
|||||||
progress: number,
|
progress: number,
|
||||||
areAssetsDownloadable: bool,
|
areAssetsDownloadable: bool,
|
||||||
toggleUploadProcess: func,
|
toggleUploadProcess: func,
|
||||||
downloadUrl: string
|
downloadUrl: string,
|
||||||
|
showProgress: bool
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
@ -36,39 +38,50 @@ const FileDragAndDropPreviewOther = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const { progress,
|
||||||
|
areAssetsDownloadable,
|
||||||
|
downloadUrl,
|
||||||
|
type,
|
||||||
|
showProgress } = this.props;
|
||||||
|
const style = !showProgress ? { visibility: 'hidden' }: null;
|
||||||
let actionSymbol;
|
let actionSymbol;
|
||||||
|
|
||||||
if(this.props.progress > 0 && this.props.progress < 99 && this.state.paused) {
|
// only if assets are actually downloadable, there should be a
|
||||||
actionSymbol = <span className="glyphicon glyphicon-pause action-file" aria-hidden="true" title={getLangText('Pause upload')} onClick={this.toggleUploadProcess}/>;
|
// download icon if the process is already at 100%.
|
||||||
} else if(this.props.progress > 0 && this.props.progress < 99 && !this.state.paused) {
|
// If not, no actionSymbol should be displayed
|
||||||
actionSymbol = <span className="glyphicon glyphicon-play action-file" aria-hidden="true" title={getLangText('Resume uploading')} onClick={this.toggleUploadProcess}/>;
|
if (progress === 100 && areAssetsDownloadable) {
|
||||||
} else if(this.props.progress === 100) {
|
actionSymbol = (
|
||||||
|
<a
|
||||||
// only if assets are actually downloadable, there should be a download icon if the process is already at
|
href={downloadUrl}
|
||||||
// 100%. If not, no actionSymbol should be displayed
|
target="_blank"
|
||||||
if(this.props.areAssetsDownloadable) {
|
className="glyphicon glyphicon-download action-file"
|
||||||
actionSymbol = <a href={this.props.downloadUrl} target="_blank" className="glyphicon glyphicon-download action-file" aria-hidden="true" title={getLangText('Download file')}/>;
|
aria-hidden="true"
|
||||||
}
|
title={getLangText('Download file')}/>
|
||||||
|
);
|
||||||
} else {
|
} else if(progress >= 0 && progress < 100) {
|
||||||
actionSymbol = (
|
actionSymbol = (
|
||||||
<div className="spinner-file">
|
<div className="spinner-file">
|
||||||
<AscribeSpinner color='dark-blue' size='md' />
|
<AscribeSpinner color='dark-blue' size='md' />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
actionSymbol = (
|
||||||
|
<span
|
||||||
|
className="glyphicon glyphicon-ok action-file" />
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="file-drag-and-drop-preview">
|
className="file-drag-and-drop-preview">
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
now={Math.ceil(this.props.progress)}
|
now={Math.ceil(progress)}
|
||||||
|
style={style}
|
||||||
className="ascribe-progress-bar ascribe-progress-bar-xs"/>
|
className="ascribe-progress-bar ascribe-progress-bar-xs"/>
|
||||||
<div className="file-drag-and-drop-preview-table-wrapper">
|
<div className="file-drag-and-drop-preview-table-wrapper">
|
||||||
<div className="file-drag-and-drop-preview-other">
|
<div className="file-drag-and-drop-preview-other">
|
||||||
{actionSymbol}
|
{actionSymbol}
|
||||||
<p>{'.' + this.props.type}</p>
|
<p style={style}>{'.' + type}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -40,6 +40,7 @@ let FileDragAndDropPreviewProgress = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const files = this.props.files.filter(displayValidProgressFilesFilter);
|
||||||
let overallProgress = this.calcOverallProgress();
|
let overallProgress = this.calcOverallProgress();
|
||||||
let overallFileSize = this.calcOverallFileSize();
|
let overallFileSize = this.calcOverallFileSize();
|
||||||
let style = {
|
let style = {
|
||||||
@ -48,7 +49,8 @@ let FileDragAndDropPreviewProgress = React.createClass({
|
|||||||
|
|
||||||
// only visible if overallProgress is over zero
|
// only visible if overallProgress is over zero
|
||||||
// or the overallFileSize is greater than 10MB
|
// or the overallFileSize is greater than 10MB
|
||||||
if(overallProgress !== 0 && overallFileSize > 10000000) {
|
// or the user is only uploading one file
|
||||||
|
if(overallProgress !== 0 && overallFileSize > 10000000 || files.length === 1) {
|
||||||
style.visibility = 'visible';
|
style.visibility = 'visible';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,6 +111,7 @@
|
|||||||
cursor: default;
|
cursor: default;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-file {
|
.action-file {
|
||||||
color: white;
|
color: white;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@ -129,6 +130,11 @@
|
|||||||
&:hover {
|
&:hover {
|
||||||
color: #d9534f;
|
color: #d9534f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.glyphicon-ok, &.glyphicon-ok:hover {
|
||||||
|
cursor: default;
|
||||||
|
color: lighten($ascribe--button-default-color, 20%);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.spinner-file {
|
.spinner-file {
|
||||||
@ -144,6 +150,10 @@
|
|||||||
width: 104px;
|
width: 104px;
|
||||||
|
|
||||||
.action-file, .spinner-file {
|
.action-file, .spinner-file {
|
||||||
|
margin-top: .8em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ascribe-progress-bar + .action-file, .ascribe-progress-bar + .spinner-file {
|
||||||
margin-top: .6em;
|
margin-top: .6em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user