2019-07-11 04:54:19 +01:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
import { shortNumberFormat } from '../utils/numbers';
|
2019-07-17 23:53:09 +01:00
|
|
|
import classNames from 'classnames';
|
2019-07-11 04:54:19 +01:00
|
|
|
|
|
|
|
export default class TimelineQueueButtonHeader extends React.PureComponent {
|
|
|
|
static propTypes = {
|
|
|
|
onClick: PropTypes.func.isRequired,
|
|
|
|
count: PropTypes.number,
|
|
|
|
itemType: PropTypes.string,
|
|
|
|
};
|
|
|
|
|
|
|
|
static defaultProps = {
|
|
|
|
count: 0,
|
|
|
|
itemType: 'item',
|
|
|
|
};
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const { count, itemType, onClick } = this.props;
|
|
|
|
|
2019-07-17 23:53:09 +01:00
|
|
|
const classes = classNames('timeline-queue-header', {
|
|
|
|
'hidden': (count <= 0)
|
|
|
|
});
|
2019-07-11 04:54:19 +01:00
|
|
|
|
|
|
|
return (
|
2019-07-17 23:53:09 +01:00
|
|
|
<div className={classes}>
|
2019-07-11 04:54:19 +01:00
|
|
|
<a className='timeline-queue-header__btn' onClick={onClick}>
|
2019-07-17 23:53:09 +01:00
|
|
|
{(count > 0) && <FormattedMessage
|
2019-07-11 04:54:19 +01:00
|
|
|
id='timeline_queue.label'
|
|
|
|
defaultMessage='Click to see {count} new {type}'
|
|
|
|
values={{
|
|
|
|
count: shortNumberFormat(count),
|
|
|
|
type: count == 1 ? itemType : `${itemType}s`,
|
|
|
|
}}
|
2019-07-17 23:53:09 +01:00
|
|
|
/>}
|
2019-07-11 04:54:19 +01:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|