import { Component, PropTypes } from 'react';
import Icon from '../../aui-react/icon';

import CountCell from './count-cell';

const propTypes = {
    pullRequest: PropTypes.object.isRequired,
};

class Tasks extends Component {
    shouldComponentUpdate(newProps) {
        return this.props.pullRequest.task_count !== newProps.pullRequest.task_count;
    }

    render() {
        const pullRequest = this.props.pullRequest;
        return (
            <CountCell
                count={pullRequest.task_count}
                tooltip={AJS.I18n.getText('bitbucket.web.tasks.openTaskCount', pullRequest.task_count)}
                className="tasks"
                icon={
                    <Icon size="small" icon="editor-task">
                        {AJS.I18n.getText('bitbucket.web.tasks.openTask.label')}
                    </Icon>
                }
            />
        );
    }
}

Tasks.Header = CountCell.Header;
Tasks.propTypes = propTypes;

export default Tasks;
