2015-06-12 02:52:49 +08:00
|
|
|
path = require 'path'
|
|
|
|
React = require 'react'
|
2015-07-16 04:15:05 +08:00
|
|
|
{RetinaImg, Flexbox} = require 'nylas-component-kit'
|
2015-06-12 02:52:49 +08:00
|
|
|
{Utils,
|
|
|
|
Actions,
|
|
|
|
FileUploadStore} = require 'nylas-exports'
|
|
|
|
|
|
|
|
class FileUpload extends React.Component
|
|
|
|
@displayName: 'FileUpload'
|
|
|
|
|
|
|
|
render: =>
|
2015-07-16 04:15:05 +08:00
|
|
|
<div className={"file-wrap file-upload"}>
|
|
|
|
<div className="inner">
|
|
|
|
<Flexbox direction="row" style={alignItems: 'center'}>
|
2015-06-12 02:52:49 +08:00
|
|
|
<RetinaImg className="file-icon"
|
|
|
|
fallback="file-fallback.png"
|
2015-11-24 14:09:17 +08:00
|
|
|
mode={RetinaImg.Mode.ContentPreserve}
|
2015-06-12 02:52:49 +08:00
|
|
|
name="file-#{@_extension()}.png"/>
|
2015-07-16 04:15:05 +08:00
|
|
|
<span className="file-name">
|
2016-01-27 07:36:13 +08:00
|
|
|
<span className="uploading">{@props.upload.filename}</span>
|
2015-07-16 04:15:05 +08:00
|
|
|
</span>
|
|
|
|
<div className="file-action-icon" onClick={@_onClickRemove}>
|
2015-11-24 14:09:17 +08:00
|
|
|
<RetinaImg name="remove-attachment.png" mode={RetinaImg.Mode.ContentDark} />
|
2015-07-16 04:15:05 +08:00
|
|
|
</div>
|
|
|
|
</Flexbox>
|
|
|
|
</div>
|
2015-06-12 02:52:49 +08:00
|
|
|
</div>
|
|
|
|
|
2016-01-28 07:38:01 +08:00
|
|
|
_onClickRemove: (event) =>
|
|
|
|
event.preventDefault()
|
2016-01-27 10:48:21 +08:00
|
|
|
Actions.removeAttachment @props.upload
|
2015-06-12 02:52:49 +08:00
|
|
|
|
2015-08-01 03:34:24 +08:00
|
|
|
_extension: =>
|
2016-01-27 07:36:13 +08:00
|
|
|
path.extname(@props.upload.filename)[1..-1]
|
2015-06-12 02:52:49 +08:00
|
|
|
|
|
|
|
module.exports = FileUpload
|