11import React , { Component , PropTypes } from 'react' ;
2- import { Col , Glyphicon } from 'react-bootstrap' ;
2+ import { Col , Glyphicon , Modal , Button } from 'react-bootstrap' ;
33import filesize from 'filesize' ;
44
55export default class FileUploadItem extends Component {
@@ -15,8 +15,23 @@ export default class FileUploadItem extends Component {
1515 width : "150px"
1616 } ;
1717
18+ state = {
19+ show : false
20+ } ;
21+
22+ showModal = ( show ) => {
23+ this . setState ( { show : show } ) ;
24+ } ;
25+
26+ deleteFile = ( ) => {
27+ let { onClick } = this . props ;
28+ onClick ( ) ;
29+ this . showModal ( false ) ;
30+ } ;
31+
1832 render ( ) {
1933 let { file, height, width, onClick } = this . props ;
34+ let { show } = this . state ;
2035
2136 const containerStyle = {
2237 margin : "auto" ,
@@ -64,12 +79,28 @@ export default class FileUploadItem extends Component {
6479
6580 return (
6681 < Col xs = { 4 } md = { 4 } >
82+ < Modal show = { show } >
83+ < Modal . Header >
84+ < Modal . Title > Delete file</ Modal . Title >
85+ </ Modal . Header >
86+ < Modal . Body >
87+ Are you sure that you want to delete this file?
88+ </ Modal . Body >
89+ < Modal . Footer >
90+ < Button onClick = { ( ) => this . showModal ( false ) } >
91+ Close
92+ </ Button >
93+ < Button bsStyle = "primary" onClick = { onClick } >
94+ Delete
95+ </ Button >
96+ </ Modal . Footer >
97+ </ Modal >
6798 < div style = { containerStyle } >
6899 < img height = { height } width = { width } src = { image } style = { imgStyle } />
69100 < div style = { textContainerStyle } >
70101 < p style = { fileNameStyle } > { filename } </ p >
71102 < div >
72- < div onClick = { onClick } style = { trashContainerStyle } >
103+ < div onClick = { ( ) => this . showModal ( true ) } style = { trashContainerStyle } >
73104 < Glyphicon glyph = "trash" />
74105 </ div >
75106 < div style = { fileSizeContainerStyle } >
0 commit comments