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

83 lines
2.8 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">
{getLangText('Click or drag to add files')}
</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;