Skip to content

Commit 107e87c

Browse files
authored
Moves download option into file editor (#716)
* Moves download option into file editor Instead of clicking in the file cell to download, and double clicking in the white part of the cell to edit/delete, this change adds download into the editor, so it’s easier to edit if needed, while keeping the download functionality. * Changes `let` to `const` in FileEditor.react.js
1 parent 01ba1e1 commit 107e87c

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/components/BrowserCell/BrowserCell.react.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ let BrowserCell = ({ type, value, hidden, width, current, onSelect, onEditChange
4545
content = JSON.stringify(value);
4646
} else if (type === 'File') {
4747
if (value.url()) {
48-
content = <a href={value.url()} target='_blank'><Pill value={getFileName(value)} /></a>;
48+
content = <Pill value={getFileName(value)} />;
4949
} else {
5050
content = <Pill value={'Uploading\u2026'} />;
5151
}

src/components/FileEditor/FileEditor.react.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,15 @@ export default class FileEditor extends React.Component {
5252
}
5353

5454
render() {
55+
const file = this.props.value;
5556
return (
5657
<div ref='input' style={{ minWidth: this.props.width }} className={styles.editor}>
57-
{this.props.value ? <a href='javascript:;' role='button' className={styles.delete} onClick={() => this.props.onCommit(undefined)}>Delete</a> : null}
58+
{file && file.url() ? <a href={file.url()} target='_blank' role='button' className={styles.download}>Download</a> : null}
5859
<a className={styles.upload}>
5960
<input type='file' onChange={this.handleChange.bind(this)} />
60-
<span>{this.props.value ? 'Replace file' : 'Upload file'}</span>
61+
<span>{file ? 'Replace file' : 'Upload file'}</span>
6162
</a>
63+
{file ? <a href='javascript:;' role='button' className={styles.delete} onClick={() => this.props.onCommit(undefined)}>Delete</a> : null}
6264
</div>
6365
);
6466
}

src/components/FileEditor/FileEditor.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
padding: 6px;
1515
}
1616

17-
.delete, .upload {
17+
.delete, .upload, .download {
1818
@include DosisFont;
1919
display: block;
2020
cursor: pointer;
@@ -28,13 +28,13 @@
2828

2929
.delete {
3030
background: $red;
31-
margin-bottom: 6px;
3231
}
3332

34-
.upload {
33+
.upload, .download {
3534
position: relative;
3635
overflow: hidden;
3736
background: $blue;
37+
margin-bottom: 6px;
3838

3939
input {
4040
position: absolute;

0 commit comments

Comments
 (0)