mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-11 18:32:20 +08:00
73ae6ea6f3
Summary: fix misc spec failure by making event store fetch immediately on setup add specs for displayExtension, displayName Test Plan: Run new tests Reviewers: evan Maniphest Tasks: T2387 Differential Revision: https://phab.nylas.com/D1821
49 lines
1.5 KiB
CoffeeScript
49 lines
1.5 KiB
CoffeeScript
path = require 'path'
|
|
React = require 'react'
|
|
{RetinaImg, Flexbox} = require 'nylas-component-kit'
|
|
{Utils,
|
|
Actions,
|
|
FileUploadStore} = require 'nylas-exports'
|
|
|
|
class FileUpload extends React.Component
|
|
@displayName: 'FileUpload'
|
|
|
|
render: =>
|
|
<div className={"file-wrap file-upload"}>
|
|
<div className="inner">
|
|
<div className={"progress-bar-wrap state-#{@props.uploadData.state}"}>
|
|
<span className="progress-background"></span>
|
|
<span className="progress-foreground" style={@_uploadProgressStyle()}></span>
|
|
</div>
|
|
|
|
<Flexbox direction="row" style={alignItems: 'center'}>
|
|
<RetinaImg className="file-icon"
|
|
fallback="file-fallback.png"
|
|
name="file-#{@_extension()}.png"/>
|
|
<span className="file-name">
|
|
<span className="uploading">Uploading:</span> {@_basename()}
|
|
</span>
|
|
<div className="file-action-icon" onClick={@_onClickRemove}>
|
|
<RetinaImg name="remove-attachment.png"/>
|
|
</div>
|
|
</Flexbox>
|
|
</div>
|
|
</div>
|
|
|
|
_uploadProgressStyle: =>
|
|
if @props.uploadData.fileSize <= 0
|
|
percent = 0
|
|
else
|
|
percent = Math.min(1, (@props.uploadData.bytesUploaded / @props.uploadData.fileSize)) * 100
|
|
width: "#{percent}%"
|
|
|
|
_onClickRemove: =>
|
|
Actions.abortUpload @props.uploadData
|
|
|
|
_basename: =>
|
|
path.basename(@props.uploadData.filePath)
|
|
|
|
_extension: =>
|
|
path.extname(@_basename())[1..-1]
|
|
|
|
module.exports = FileUpload
|