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

import CountCell from './count-cell';

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

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

    render() {
        const pullRequest = this.props.pullRequest;
        return (
            <CountCell
                count={pullRequest.comment_count}
                tooltip={AJS.I18n.getText('bitbucket.web.comment.count', pullRequest.comment_count)}
                className="comments"
                icon={
                    <Icon size="small" icon="comment">
                        {AJS.I18n.getText('bitbucket.web.comment.count', pullRequest.comment_count)}
                    </Icon>
                }
            />
        );
    }
}

Comments.Header = CountCell.Header;
Comments.propTypes = propTypes;

export default Comments;
