1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 17:45:10 +01:00
onion/js/components/ascribe_uploader/file_drag_and_drop_dialog.js

89 lines
3.2 KiB
JavaScript
Raw Normal View History

2015-07-07 18:07:12 +02:00
'use strict';
import React from 'react';
2015-07-27 14:21:26 +02:00
import Router from 'react-router';
2015-07-23 17:17:48 +02:00
import { getLangText } from '../../utils/lang_utils';
2015-07-27 14:21:26 +02:00
let Link = Router.Link;
2015-07-07 18:07:12 +02:00
let FileDragAndDropDialog = React.createClass({
propTypes: {
hasFiles: React.PropTypes.bool,
multipleFiles: React.PropTypes.bool,
onClick: React.PropTypes.func,
enableLocalHashing: React.PropTypes.bool
2015-07-07 18:07:12 +02:00
},
2015-07-27 14:21:26 +02:00
mixins: [Router.State],
2015-07-07 18:07:12 +02:00
render() {
2015-07-27 14:21:26 +02:00
const queryParams = this.getQuery();
2015-07-07 18:07:12 +02:00
if(this.props.hasFiles) {
return null;
} else {
if(this.props.enableLocalHashing && !queryParams.method) {
2015-07-27 14:21:26 +02:00
let queryParamsHash = Object.assign({}, queryParams);
queryParamsHash.method = 'hash';
let queryParamsUpload = Object.assign({}, queryParams);
queryParamsUpload.method = 'upload';
2015-07-07 18:07:12 +02:00
return (
2015-07-27 14:21:26 +02:00
<span className="file-drag-and-drop-dialog present-options">
<p>{getLangText('Would you rather')}</p>
<Link
to={this.getPath()}
query={queryParamsHash}>
<span className="btn btn-default btn-sm">
{getLangText('Hash your work')}
</span>
</Link>
<span> or </span>
<Link
to={this.getPath()}
query={queryParamsUpload}>
<span className="btn btn-default btn-sm">
{getLangText('Upload and hash your work')}
</span>
</Link>
2015-07-23 17:17:48 +02:00
</span>
2015-07-07 18:07:12 +02:00
);
} else {
2015-07-27 14:21:26 +02:00
if(this.props.multipleFiles) {
return (
<span className="file-drag-and-drop-dialog">
2015-08-11 10:03:12 +02:00
<p>{getLangText('Drag files here')}</p>
<p>{getLangText('or')}</p>
<span
className="btn btn-default"
onClick={this.props.onClick}>
{getLangText('choose files to upload')}
</span>
2015-07-27 14:21:26 +02:00
</span>
);
} else {
let dialog = queryParams.method === 'hash' ? getLangText('choose a file to hash') : getLangText('choose a file to upload');
2015-07-27 14:21:26 +02:00
return (
<span className="file-drag-and-drop-dialog">
<p>{getLangText('Drag a file here')}</p>
<p>{getLangText('or')}</p>
<span
className="btn btn-default"
onClick={this.props.onClick}>
{dialog}
</span>
</span>
2015-07-27 14:21:26 +02:00
);
}
2015-07-07 18:07:12 +02:00
}
}
}
});
export default FileDragAndDropDialog;