summaryrefslogtreecommitdiff
path: root/app/client/common/fileList.component.js
blob: b3bcd432b00eafdacdbc484dd10ea4d0dc23b461 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { h, Component } from 'preact'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { Link } from 'react-router-dom';
import moment from 'moment'
import * as util from '../util'

class FileList extends Component {
  constructor(props){
    super()
  }
  render(){
    const { files, linkFiles, onClick } = this.props
	  const fileList = files.map(file => {
	   	return (
		   	<div class='row file' key={file.name}>
          <div className="filename" title={file.name || file.url}>
            {(linkFiles && file.url)
              ? <a target='_blank' href={file.url}>{file.name || file.url}</a>
              : <span class='link' onClick={() => onClick(file)}>{file.name || file.url}</span>
            }
          </div>
          <div className="date">{moment(file.created_at).format("YYYY-MM-DD h:mm a")}</div>
          <div className="size">{file.size ? ((file.size) / 1024 / 1024).toFixed(1) + ' mb.' : ''}</div>
          <div className="epoch">{file.epoch > 0 ? 'epoch ' + file.epoch : ' '}</div>
	        <div className='activity'>{file.activity || ''} {file.module || ''}</div>
          {this.props.options && this.props.options(file)}
		   	</div>
	   	)
	  })
	  return (
	  	<div className='filelist rows'>
	  		{fileList}
	  	</div>
  	)
  }
}



const mapStateToProps = state => ({
})

const mapDispatchToProps = (dispatch, ownProps) => ({
  // actions: bindActionCreators(liveActions, dispatch)
})

export default connect(mapStateToProps, mapDispatchToProps)(FileList)