@@ -87,6 +87,11 @@ export class FileNode extends React.Component {
87
87
setTimeout ( ( ) => this . hideFileOptions ( ) , 0 ) ;
88
88
}
89
89
90
+ handleClickUploadFile = ( ) => {
91
+ this . props . openUploadFileModal ( this . props . id ) ;
92
+ setTimeout ( this . hideFileOptions , 0 ) ;
93
+ }
94
+
90
95
handleClickDelete = ( ) => {
91
96
if ( window . confirm ( `Are you sure you want to delete ${ this . props . name } ?` ) ) {
92
97
this . setState ( { isDeleting : true } ) ;
@@ -252,19 +257,18 @@ export class FileNode extends React.Component {
252
257
Create file
253
258
</ button >
254
259
</ li >
255
- < li >
256
- < button
257
- aria-label = "upload file"
258
- onClick = { ( ) => {
259
- this . props . openUploadFileModal ( this . props . id ) ;
260
- setTimeout ( this . hideFileOptions , 0 ) ;
261
- } }
262
- onBlur = { this . onBlurComponent }
263
- onFocus = { this . onFocusComponent }
264
- >
265
- Upload file
266
- </ button >
267
- </ li >
260
+ { this . props . authenticated &&
261
+ < li >
262
+ < button
263
+ aria-label = "upload file"
264
+ onClick = { this . handleClickUploadFile }
265
+ onBlur = { this . onBlurComponent }
266
+ onFocus = { this . onFocusComponent }
267
+ >
268
+ Upload file
269
+ </ button >
270
+ </ li >
271
+ }
268
272
</ React . Fragment >
269
273
}
270
274
< li >
@@ -318,7 +322,8 @@ FileNode.propTypes = {
318
322
showFolderChildren : PropTypes . func . isRequired ,
319
323
hideFolderChildren : PropTypes . func . isRequired ,
320
324
canEdit : PropTypes . bool . isRequired ,
321
- openUploadFileModal : PropTypes . func . isRequired
325
+ openUploadFileModal : PropTypes . func . isRequired ,
326
+ authenticated : PropTypes . bool . isRequired
322
327
} ;
323
328
324
329
FileNode . defaultProps = {
@@ -329,7 +334,8 @@ FileNode.defaultProps = {
329
334
330
335
function mapStateToProps ( state , ownProps ) {
331
336
// this is a hack, state is updated before ownProps
332
- return state . files . find ( file => file . id === ownProps . id ) || { name : 'test' , fileType : 'file' } ;
337
+ const fileNode = state . files . find ( file => file . id === ownProps . id ) || { name : 'test' , fileType : 'file' } ;
338
+ return Object . assign ( { } , fileNode , { authenticated : state . user . authenticated } ) ;
333
339
}
334
340
335
341
function mapDispatchToProps ( dispatch ) {
0 commit comments