Skip to content

Commit 987110d

Browse files
committed
Added download functionality to Dialog box
1 parent bde5d31 commit 987110d

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

client/modules/IDE/components/SketchList.jsx

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,19 @@ class SketchList extends React.Component {
3131
return `p5.js Web Editor | ${this.props.username}'s sketches`;
3232
}
3333

34+
closeAllDropdowns() {
35+
this.setState({
36+
actionDialogueDisplayed: new Array(this.props.sketches.length).fill(false)
37+
});
38+
}
39+
3440
render() {
3541
const username = this.props.username !== undefined ? this.props.username : this.props.user.username;
3642
return (
3743
<div
3844
className="sketches-table-container"
3945
role="presentation"
40-
onClick={e => this.setState({
41-
actionDialogueDisplayed: new Array(this.props.sketches.length).fill(false)
42-
})}
46+
onClick={e => this.closeAllDropdowns()}
4347
>
4448
<Helmet>
4549
<title>{this.getSketchesTitle()}</title>
@@ -139,16 +143,23 @@ class SketchList extends React.Component {
139143
<div className="sketch-list__action-option">
140144
Rename
141145
</div>
142-
<div className="sketch-list__action-option">
146+
{ this.props.project.id &&
147+
<div
148+
role="presentation"
149+
className="sketch-list__action-option"
150+
onClick={() => {
151+
this.props.autosaveProject();
152+
this.props.exportProjectAsZip(this.props.project.id);
153+
}}
154+
>
143155
Download
144-
</div>
156+
</div> }
145157
{ this.props.project.id && this.props.user.authenticated &&
146158
<div
147159
role="presentation"
148160
className="sketch-list__action-option"
149161
onClick={() => {
150162
this.props.cloneProject();
151-
this.setDropdown('none');
152163
}}
153164
>
154165
Duplicate
@@ -158,7 +169,6 @@ class SketchList extends React.Component {
158169
role="presentation"
159170
className="sketch-list__action-option"
160171
onClick={() => {
161-
console.log(this.props.project);
162172
this.props.showShareModal();
163173
}}
164174
>
@@ -170,12 +180,7 @@ class SketchList extends React.Component {
170180
onClick={(e) => {
171181
e.stopPropagation();
172182
if (window.confirm(`Are you sure you want to delete "${sketch.name}"?`)) {
173-
this.setState(() => {
174-
const actionDialogueDisplayed = new Array(this.props.sketches.length).fill(false);
175-
return {
176-
actionDialogueDisplayed,
177-
};
178-
});
183+
this.closeAllDropdowns();
179184
this.props.deleteProject(sketch.id);
180185
}
181186
}}
@@ -213,7 +218,9 @@ SketchList.propTypes = {
213218
id: PropTypes.string
214219
})
215220
}),
216-
cloneProject: PropTypes.func.isRequired
221+
cloneProject: PropTypes.func.isRequired,
222+
autosaveProject: PropTypes.func.isRequired,
223+
exportProjectAsZip: PropTypes.func.isRequired,
217224
};
218225

219226
SketchList.defaultProps = {

0 commit comments

Comments
 (0)