mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-23 00:36:50 +08:00
49 lines
1.1 KiB
Plaintext
49 lines
1.1 KiB
Plaintext
|
_ = require 'underscore-plus'
|
||
|
React = require 'react'
|
||
|
{ListTabular, MultiselectList} = require 'ui-components'
|
||
|
{Actions,
|
||
|
DatabaseStore,
|
||
|
ComponentRegistry} = require 'inbox-exports'
|
||
|
FileListStore = require './file-list-store'
|
||
|
|
||
|
module.exports =
|
||
|
FileList = React.createClass
|
||
|
displayName: 'FileList'
|
||
|
|
||
|
componentWillMount: ->
|
||
|
prettySize = (size) ->
|
||
|
units = ['GB', 'MB', 'KB', 'bytes']
|
||
|
while size > 1024
|
||
|
size /= 1024
|
||
|
units.pop()
|
||
|
size = "#{(Math.ceil(size * 10) / 10)}"
|
||
|
pretty = units.pop()
|
||
|
"#{size} #{pretty}"
|
||
|
|
||
|
c1 = new ListTabular.Column
|
||
|
name: "Name"
|
||
|
flex: 1
|
||
|
resolver: (file) ->
|
||
|
<div>{file.filename}</div>
|
||
|
|
||
|
c2 = new ListTabular.Column
|
||
|
name: "Size"
|
||
|
width: '100px'
|
||
|
resolver: (file) ->
|
||
|
<div>{prettySize(file.size)}</div>
|
||
|
|
||
|
@columns = [c1, c2]
|
||
|
|
||
|
render: ->
|
||
|
<MultiselectList
|
||
|
dataStore={FileListStore}
|
||
|
columns={@columns}
|
||
|
commands={{}}
|
||
|
onDoubleClick={@_onDoubleClick}
|
||
|
itemClassProvider={ -> }
|
||
|
className="file-list"
|
||
|
collection="file" />
|
||
|
|
||
|
_onDoubleClick: (item) ->
|
||
|
|