2019-11-13 09:13:48 +00:00
import React from 'react' ;
import PropTypes from 'prop-types' ;
import { gettext } from '../../../utils/constants' ;
const propTypes = {
type : PropTypes . string . isRequired ,
2020-09-22 06:03:58 +00:00
sortBy : PropTypes . string . isRequired ,
sortOrder : PropTypes . string . isRequired ,
sortItems : PropTypes . func . isRequired ,
2019-11-13 09:13:48 +00:00
children : PropTypes . oneOfType ( [ PropTypes . bool , PropTypes . array ] ) ,
} ;
class TrafficTable extends React . Component {
constructor ( props ) {
super ( props ) ;
}
render ( ) {
2020-09-22 06:03:58 +00:00
const { type , sortBy , sortOrder } = this . props ;
2019-11-13 09:13:48 +00:00
const sortIcon = sortOrder == 'asc' ? < span className = "fas fa-caret-up" > < / s p a n > : < s p a n c l a s s N a m e = " f a s f a - c a r e t - d o w n " > < / s p a n > ;
return (
< table className = "table-hover" >
< thead >
< tr >
2019-11-28 06:09:27 +00:00
< th width = "16%" > { type == 'user' ? gettext ( 'User' ) : gettext ( 'Organization' ) } < / t h >
2020-09-22 06:03:58 +00:00
< th width = "11%" > < div className = "d-block table-sort-op cursor-pointer" onClick = { this . props . sortItems . bind ( this , 'sync_file_upload' ) } > { gettext ( 'Sync Upload' ) } { sortBy === 'sync_file_upload' && sortIcon } < / d i v > < / t h >
< th width = "14%" > < div className = "d-block table-sort-op cursor-pointer" onClick = { this . props . sortItems . bind ( this , 'sync_file_download' ) } > { gettext ( 'Sync Download' ) } { sortBy === 'sync_file_download' && sortIcon } < / d i v > < / t h >
< th width = "11%" > < div className = "d-block table-sort-op cursor-pointer" onClick = { this . props . sortItems . bind ( this , 'web_file_upload' ) } > { gettext ( 'Web Upload' ) } { sortBy === 'web_file_upload' && sortIcon } < / d i v > < / t h >
< th width = "14%" > < div className = "d-block table-sort-op cursor-pointer" onClick = { this . props . sortItems . bind ( this , 'web_file_download' ) } > { gettext ( 'Web Download' ) } { sortBy === 'web_file_download' && sortIcon } < / d i v > < / t h >
< th width = "17%" > < div className = "d-block table-sort-op cursor-pointer" onClick = { this . props . sortItems . bind ( this , 'link_file_upload' ) } > { gettext ( 'Share link upload' ) } { sortBy === 'link_file_upload' && sortIcon } < / d i v > < / t h >
< th width = "17%" > < div className = "d-block table-sort-op cursor-pointer" onClick = { this . props . sortItems . bind ( this , 'link_file_download' ) } > { gettext ( 'Share link download' ) } { sortBy === 'link_file_download' && sortIcon } < / d i v > < / t h >
2019-11-13 09:13:48 +00:00
< / t r >
< / t h e a d >
< tbody >
{ this . props . children }
< / t b o d y >
< / t a b l e >
) ;
}
}
TrafficTable . propTypes = propTypes ;
2019-11-28 06:09:27 +00:00
export default TrafficTable ;