mirror of
https://github.com/ascribe/onion.git
synced 2024-11-15 17:45:10 +01:00
83 lines
2.8 KiB
JavaScript
83 lines
2.8 KiB
JavaScript
'use strict';
|
|
|
|
import React from 'react';
|
|
import Router from 'react-router';
|
|
|
|
import { getLangText } from '../../utils/lang_utils';
|
|
|
|
let Link = Router.Link;
|
|
|
|
let FileDragAndDropDialog = React.createClass({
|
|
propTypes: {
|
|
hasFiles: React.PropTypes.bool,
|
|
multipleFiles: React.PropTypes.bool,
|
|
onClick: React.PropTypes.func,
|
|
enableLocalHashing: React.PropTypes.bool
|
|
},
|
|
|
|
mixins: [Router.State],
|
|
|
|
render() {
|
|
const queryParams = this.getQuery();
|
|
|
|
if(this.props.hasFiles) {
|
|
return null;
|
|
} else {
|
|
if(this.props.enableLocalHashing && !queryParams.method) {
|
|
|
|
let queryParamsHash = Object.assign({}, queryParams);
|
|
queryParamsHash.method = 'hash';
|
|
|
|
let queryParamsUpload = Object.assign({}, queryParams);
|
|
queryParamsUpload.method = 'upload';
|
|
|
|
return (
|
|
<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>
|
|
</span>
|
|
);
|
|
} else {
|
|
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');
|
|
|
|
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>
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
export default FileDragAndDropDialog; |