1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-10 11:35:13 +02:00
onion/js/components/ascribe_uploader/ascribe_file_drag_and_drop/file_drag_and_drop_preview_other.js

89 lines
2.6 KiB
JavaScript
Raw Normal View History

2015-06-25 13:28:49 +02:00
'use strict';
2015-06-23 10:16:53 +02:00
import React from 'react';
import ProgressBar from 'react-bootstrap/lib/ProgressBar';
2015-06-23 10:16:53 +02:00
import AclProxy from '../../acl_proxy';
import AscribeSpinner from '../../ascribe_spinner';
2015-09-15 11:13:17 +02:00
import { getLangText } from '../../../utils/lang_utils';
2015-06-29 16:00:26 +02:00
const { string, number, bool, func } = React.PropTypes;
const FileDragAndDropPreviewOther = React.createClass({
2015-06-23 10:16:53 +02:00
propTypes: {
type: string,
progress: number,
areAssetsDownloadable: bool,
toggleUploadProcess: func,
downloadUrl: string,
showProgress: bool
2015-06-23 10:16:53 +02:00
},
2015-06-29 16:00:26 +02:00
getInitialState() {
return {
2015-06-30 13:53:02 +02:00
paused: true
2015-06-29 16:00:26 +02:00
};
},
2015-06-30 13:53:02 +02:00
toggleUploadProcess(e) {
2015-06-29 16:00:26 +02:00
e.preventDefault();
e.stopPropagation();
2015-06-30 13:53:02 +02:00
2015-06-29 16:00:26 +02:00
this.setState({
2015-06-30 13:53:02 +02:00
paused: !this.state.paused
2015-06-29 16:00:26 +02:00
});
2015-06-30 13:53:02 +02:00
this.props.toggleUploadProcess();
},
2015-06-23 10:16:53 +02:00
render() {
const { progress,
areAssetsDownloadable,
downloadUrl,
type,
showProgress } = this.props;
const style = !showProgress ? { visibility: 'hidden' } : null;
2015-06-30 13:53:02 +02:00
let actionSymbol;
// 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
if (progress === 100 && areAssetsDownloadable) {
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) {
actionSymbol = (
<div className="spinner-file">
<AscribeSpinner color='dark-blue' size='md' />
</div>
);
} else {
actionSymbol = (
<span className='ascribe-icon icon-ascribe-ok action-file' />
);
2015-06-30 13:53:02 +02:00
}
2015-06-25 13:28:49 +02:00
return (
<div className="file-drag-and-drop-preview">
<ProgressBar
now={Math.ceil(progress)}
style={style}
className="ascribe-progress-bar ascribe-progress-bar-xs" />
<div className="file-drag-and-drop-preview-other">
{actionSymbol}
<p style={style}>{'.' + (type ? type : 'file')}</p>
2015-06-23 10:16:53 +02:00
</div>
</div>
);
}
});
2015-07-03 19:08:56 +02:00
export default FileDragAndDropPreviewOther;