@@ -87,6 +87,11 @@ export class FileNode extends React.Component {
8787 setTimeout ( ( ) => this . hideFileOptions ( ) , 0 ) ;
8888 }
8989
90+ handleClickUploadFile = ( ) => {
91+ this . props . openUploadFileModal ( this . props . id ) ;
92+ setTimeout ( this . hideFileOptions , 0 ) ;
93+ }
94+
9095 handleClickDelete = ( ) => {
9196 if ( window . confirm ( `Are you sure you want to delete ${ this . props . name } ?` ) ) {
9297 this . setState ( { isDeleting : true } ) ;
@@ -252,19 +257,18 @@ export class FileNode extends React.Component {
252257 Create file
253258 </ button >
254259 </ 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+ }
268272 </ React . Fragment >
269273 }
270274 < li >
@@ -318,7 +322,8 @@ FileNode.propTypes = {
318322 showFolderChildren : PropTypes . func . isRequired ,
319323 hideFolderChildren : PropTypes . func . isRequired ,
320324 canEdit : PropTypes . bool . isRequired ,
321- openUploadFileModal : PropTypes . func . isRequired
325+ openUploadFileModal : PropTypes . func . isRequired ,
326+ authenticated : PropTypes . bool . isRequired
322327} ;
323328
324329FileNode . defaultProps = {
@@ -329,7 +334,8 @@ FileNode.defaultProps = {
329334
330335function mapStateToProps ( state , ownProps ) {
331336 // 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 } ) ;
333339}
334340
335341function mapDispatchToProps ( dispatch ) {
0 commit comments