1
0
mirror of https://github.com/ascribe/onion.git synced 2025-01-03 18:35:09 +01:00

Show filename when uploading

This commit is contained in:
Tim Daubenschütz 2015-12-07 16:34:10 +01:00
parent ddfdaa30e7
commit 9c9c99c714

View File

@ -41,7 +41,7 @@ export default function UploadButton({ className = 'btn btn-default btn-sm' } =
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
if(this.props.filesToUpload !== nextProps.filesToUpload) { if(this.props.filesToUpload !== nextProps.filesToUpload) {
this.setState({ this.setState({
disabled: this.getUploadingFiles().length !== 0 disabled: this.getUploadingFiles(nextProps.filesToUpload).length !== 0
}); });
} }
}, },
@ -56,8 +56,8 @@ export default function UploadButton({ className = 'btn btn-default btn-sm' } =
} }
}, },
getUploadingFiles() { getUploadingFiles(filesToUpload = this.props.filesToUpload) {
return this.props.filesToUpload.filter((file) => file.status === 'uploading'); return filesToUpload.filter((file) => file.status === 'uploading');
}, },
getUploadedFile() { getUploadedFile() {
@ -99,12 +99,19 @@ export default function UploadButton({ className = 'btn btn-default btn-sm' } =
} }
}, },
onClickCancel() {
this.clearSelection();
const uploadingFile = this.getUploadingFiles()[0];
this.props.handleCancelFile(uploadingFile.id);
},
onClickRemove() { onClickRemove() {
this.clearSelection(); this.clearSelection();
const uploadedFile = this.getUploadedFile(); const uploadedFile = this.getUploadedFile();
this.props.handleDeleteFile(uploadedFile.id); this.props.handleDeleteFile(uploadedFile.id);
}, },
getButtonLabel() { getButtonLabel() {
let { filesToUpload, fileClassToUpload } = this.props; let { filesToUpload, fileClassToUpload } = this.props;
@ -120,8 +127,16 @@ export default function UploadButton({ className = 'btn btn-default btn-sm' } =
getUploadedFileLabel() { getUploadedFileLabel() {
const uploadedFile = this.getUploadedFile(); const uploadedFile = this.getUploadedFile();
const uploadingFiles = this.getUploadingFiles();
if(uploadedFile) { if(uploadingFiles.length) {
return (
<span>
{' ' + truncateTextAtCharIndex(uploadingFiles[0].name, 40) + ' '}
[<a onClick={this.onClickCancel}>{getLangText('cancel upload')}</a>]
</span>
);
} else if(uploadedFile) {
return ( return (
<span> <span>
<span className='ascribe-icon icon-ascribe-ok'/> <span className='ascribe-icon icon-ascribe-ok'/>