Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

Commit

Permalink
Merge pull request #614 from jfurrow/fix/add-torrent-by-file-layout
Browse files Browse the repository at this point in the history
Fixes the layout in file upload modal
  • Loading branch information
jfurrow committed Jan 29, 2018
2 parents caf6229 + 09e5e54 commit 2cb40c4
Showing 1 changed file with 37 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,15 @@ class AddTorrentsByFile extends React.Component {
state = {
errors: {},
isAddingTorrents: false,
files: null,
files: [],
tags: '',
startTorrents: SettingsStore.getFloodSettings('startTorrentsOnLoad')
};

getFileDropzone() {
const dropzoneContent = (
<FormRowItem>
<label className="form__element__label">
<FormattedMessage
id="torrents.add.torrents.label"
defaultMessage="Torrents"
/>
</label>
<Dropzone
activeClassName="dropzone--is-dragging"
className="form__dropzone dropzone interactive-list"
ref="dropzone"
onDrop={this.handleFileDrop}
disablePreview
>
<div className="dropzone__copy">
<div className="dropzone__icon">
<Files />
</div>
<FormattedMessage
id="torrents.add.tab.file.drop"
defaultMessage="Drop some files here,"
/> <span className="dropzone__browse-button">
<FormattedMessage
id="torrents.add.tab.file.browse"
defaultMessage="or click to browse"
/></span>.
</div>
</Dropzone>
</FormRowItem>
);
let fileContent = null;

if (this.state.files && this.state.files.length > 0) {
if (this.state.files.length > 0) {
const files = this.state.files.map((file, index) => {
return (
<li
Expand Down Expand Up @@ -91,14 +60,41 @@ class AddTorrentsByFile extends React.Component {
);
}

let content = (
return (
<FormRowItem>
<label className="form__element__label">
<FormattedMessage
id="torrents.add.torrents.label"
defaultMessage="Torrents"
/>
</label>
{fileContent}
{dropzoneContent}
<Dropzone
activeClassName="dropzone--is-dragging"
className="form__dropzone dropzone interactive-list"
ref="dropzone"
onDrop={this.handleFileDrop}
disablePreview
>
<div className="dropzone__copy">
<div className="dropzone__icon">
<Files />
</div>
<FormattedMessage
id="torrents.add.tab.file.drop"
defaultMessage="Drop some files here,"
/>
{' '}
<span className="dropzone__browse-button">
<FormattedMessage
id="torrents.add.tab.file.browse"
defaultMessage="or click to browse"
/>
</span>.
</div>
</Dropzone>
</FormRowItem>
);

return content;
}

handleFileDrop = files => {
Expand All @@ -108,13 +104,14 @@ class AddTorrentsByFile extends React.Component {
delete nextErrorsState.files;
}

this.setState({errors: nextErrorsState, files});
this.setState(state => {
return { errors: nextErrorsState, files: state.files.concat(files) };
});
};

handleFileRemove = fileIndex => {
let files = this.state.files;
const {files} = this.state;
files.splice(fileIndex, 1);

this.setState({files});
};

Expand Down

0 comments on commit 2cb40c4

Please sign in to comment.