2020-02-29 15:42:47 +00:00
|
|
|
import { FormattedMessage } from 'react-intl'
|
|
|
|
import classNames from 'classnames'
|
|
|
|
import { shortNumberFormat } from '../utils/numbers'
|
|
|
|
import Button from './button'
|
|
|
|
import Text from './text'
|
2019-08-07 06:02:36 +01:00
|
|
|
|
|
|
|
export default class TimelineQueueButtonHeader extends PureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
onClick: PropTypes.func.isRequired,
|
|
|
|
count: PropTypes.number,
|
|
|
|
itemType: PropTypes.string,
|
2020-02-29 15:42:47 +00:00
|
|
|
floating: PropTypes.bool
|
|
|
|
}
|
2019-08-07 06:02:36 +01:00
|
|
|
|
|
|
|
static defaultProps = {
|
|
|
|
count: 0,
|
|
|
|
itemType: 'item',
|
2020-02-29 15:42:47 +00:00
|
|
|
}
|
2019-08-07 06:02:36 +01:00
|
|
|
|
|
|
|
render () {
|
2020-02-29 15:42:47 +00:00
|
|
|
const { count, itemType, onClick } = this.props
|
|
|
|
|
|
|
|
const hasItems = count > 0
|
2019-08-07 06:02:36 +01:00
|
|
|
|
2020-02-29 15:42:47 +00:00
|
|
|
// : todo :
|
2019-08-07 06:02:36 +01:00
|
|
|
|
|
|
|
const classes = classNames('timeline-queue-header', {
|
|
|
|
'timeline-queue-header--extended': hasItems,
|
2020-02-29 15:42:47 +00:00
|
|
|
})
|
2019-08-07 06:02:36 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={classes}>
|
|
|
|
<a className='timeline-queue-header__btn' onClick={onClick}>
|
|
|
|
{
|
|
|
|
hasItems &&
|
|
|
|
<FormattedMessage
|
|
|
|
id='timeline_queue.label'
|
|
|
|
defaultMessage='{count} new {type}'
|
|
|
|
values={{
|
|
|
|
count: shortNumberFormat(count),
|
|
|
|
type: count === 1 ? itemType : `${itemType}s`,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
</a>
|
|
|
|
</div>
|
2020-02-29 15:42:47 +00:00
|
|
|
)
|
2019-08-07 06:02:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|