@@ -31,15 +31,19 @@ class SketchList extends React.Component {
31
31
return `p5.js Web Editor | ${ this . props . username } 's sketches` ;
32
32
}
33
33
34
+ closeAllDropdowns ( ) {
35
+ this . setState ( {
36
+ actionDialogueDisplayed : new Array ( this . props . sketches . length ) . fill ( false )
37
+ } ) ;
38
+ }
39
+
34
40
render ( ) {
35
41
const username = this . props . username !== undefined ? this . props . username : this . props . user . username ;
36
42
return (
37
43
< div
38
44
className = "sketches-table-container"
39
45
role = "presentation"
40
- onClick = { e => this . setState ( {
41
- actionDialogueDisplayed : new Array ( this . props . sketches . length ) . fill ( false )
42
- } ) }
46
+ onClick = { e => this . closeAllDropdowns ( ) }
43
47
>
44
48
< Helmet >
45
49
< title > { this . getSketchesTitle ( ) } </ title >
@@ -139,16 +143,23 @@ class SketchList extends React.Component {
139
143
< div className = "sketch-list__action-option" >
140
144
Rename
141
145
</ 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
+ >
143
155
Download
144
- </ div >
156
+ </ div > }
145
157
{ this . props . project . id && this . props . user . authenticated &&
146
158
< div
147
159
role = "presentation"
148
160
className = "sketch-list__action-option"
149
161
onClick = { ( ) => {
150
162
this . props . cloneProject ( ) ;
151
- this . setDropdown ( 'none' ) ;
152
163
} }
153
164
>
154
165
Duplicate
@@ -158,7 +169,6 @@ class SketchList extends React.Component {
158
169
role = "presentation"
159
170
className = "sketch-list__action-option"
160
171
onClick = { ( ) => {
161
- console . log ( this . props . project ) ;
162
172
this . props . showShareModal ( ) ;
163
173
} }
164
174
>
@@ -170,12 +180,7 @@ class SketchList extends React.Component {
170
180
onClick = { ( e ) => {
171
181
e . stopPropagation ( ) ;
172
182
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 ( ) ;
179
184
this . props . deleteProject ( sketch . id ) ;
180
185
}
181
186
} }
@@ -213,7 +218,9 @@ SketchList.propTypes = {
213
218
id : PropTypes . string
214
219
} )
215
220
} ) ,
216
- cloneProject : PropTypes . func . isRequired
221
+ cloneProject : PropTypes . func . isRequired ,
222
+ autosaveProject : PropTypes . func . isRequired ,
223
+ exportProjectAsZip : PropTypes . func . isRequired ,
217
224
} ;
218
225
219
226
SketchList . defaultProps = {
0 commit comments