1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-23 17:56:28 +02:00
onion/js/components/ascribe_uploader/ascribe_file_drag_and_drop/file_drag_and_drop_preview_other.js
Brett Sun 627b2f75fe 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
2016-01-26 13:41:15 +01:00

89 lines
2.6 KiB
JavaScript

'use strict';
import React from 'react';
import ProgressBar from 'react-bootstrap/lib/ProgressBar';
import AclProxy from '../../acl_proxy';
import AscribeSpinner from '../../ascribe_spinner';
import { getLangText } from '../../../utils/lang_utils';
const { string, number, bool, func } = React.PropTypes;
const FileDragAndDropPreviewOther = React.createClass({
propTypes: {
type: string,
progress: number,
areAssetsDownloadable: bool,
toggleUploadProcess: func,
downloadUrl: string,
showProgress: bool
},
getInitialState() {
return {
paused: true
};
},
toggleUploadProcess(e) {
e.preventDefault();
e.stopPropagation();
this.setState({
paused: !this.state.paused
});
this.props.toggleUploadProcess();
},
render() {
const { progress,
areAssetsDownloadable,
downloadUrl,
type,
showProgress } = this.props;
const style = !showProgress ? { visibility: 'hidden' } : null;
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' />
);
}
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>
</div>
</div>
);
}
});
export default FileDragAndDropPreviewOther;