11import _ from 'lodash'
22import React , { PropTypes } from 'react'
3- import Modal from 'react-modal'
43import filesize from 'filesize'
54import { Icons } from 'appirio-tech-react-components'
6- import FileDeletionConfirmModal from './FileDeletionConfirmModal'
75
86const { TrashIcon, CloseIcon, EditIcon, SaveIcon } = Icons
97
@@ -14,21 +12,17 @@ export default class FileListItem extends React.Component {
1412 this . state = {
1513 title : props . title ,
1614 description : props . description ,
17- isEditing : false ,
18- showDeletionDialog : false
15+ isEditing : false
1916 }
2017 this . handleSave = this . handleSave . bind ( this )
2118 this . startEdit = this . startEdit . bind ( this )
2219 this . onDelete = this . onDelete . bind ( this )
23- this . showDeletionDialog = this . showDeletionDialog . bind ( this )
24- this . hideDeletionDialog = this . hideDeletionDialog . bind ( this )
2520 this . validateForm = this . validateForm . bind ( this )
2621 this . validateTitle = this . validateTitle . bind ( this )
2722 this . onTitleChange = this . onTitleChange . bind ( this )
2823 }
2924
3025 onDelete ( ) {
31- this . setState ( { showDeletionDialog : false } )
3226 this . props . onDelete ( this . props . id )
3327 }
3428
@@ -73,14 +67,6 @@ export default class FileListItem extends React.Component {
7367 this . setState ( { errors } )
7468 }
7569
76- showDeletionDialog ( ) {
77- this . setState ( { showDeletionDialog : true } )
78- }
79-
80- hideDeletionDialog ( ) {
81- this . setState ( { showDeletionDialog : false } )
82- }
83-
8470 renderEditing ( ) {
8571 const { title, description} = this . props
8672 const { errors } = this . state
@@ -103,28 +89,16 @@ export default class FileListItem extends React.Component {
10389
10490 renderReadOnly ( ) {
10591 const { title, downloadUrl, description, size, isEditable} = this . props
106- const { showDeletionDialog } = this . state
10792 return (
10893 < div >
109- < Modal
110- isOpen = { showDeletionDialog }
111- className = "file-deletion-dialog"
112- overlayClassName = "file-deletion-dialog-overlay"
113- onRequestClose = { this . hideDeletionDialog }
114- >
115- < FileDeletionConfirmModal fileName = { title } onConfirm = { this . onDelete } onCancel = { this . hideDeletionDialog } />
116- < div onClick = { this . hideDeletionDialog } className = "file-deletion-dialog-close" >
117- < Icons . XMarkIcon />
118- </ div >
119- </ Modal >
12094 < div className = "title" >
12195 < h4 > < a href = { downloadUrl } target = "_blank" rel = "noopener noreferrer" > { title } </ a > </ h4 >
12296 < div className = "size" >
12397 { filesize ( size ) }
12498 </ div >
12599 { isEditable && < div className = "edit-icons" >
126100 < i className = "icon-edit" onClick = { this . startEdit } > < EditIcon /> </ i >
127- < i className = "icon-trash" onClick = { this . showDeletionDialog } > < TrashIcon /> </ i >
101+ < i className = "icon-trash" onClick = { this . onDelete } > < TrashIcon /> </ i >
128102 </ div > }
129103 </ div >
130104 < p > { description } </ p >
@@ -133,7 +107,7 @@ export default class FileListItem extends React.Component {
133107 }
134108
135109 render ( ) {
136- const { isEditing} = this . state
110+ const { isEditing } = this . state
137111 let iconPath
138112 try {
139113 iconPath = require ( './images/' + this . props . contentType . split ( '/' ) [ 1 ] + '.svg' )
0 commit comments