forked from atom/github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchanged-files-count-view.js
42 lines (37 loc) · 1.07 KB
/
changed-files-count-view.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import React from 'react';
import PropTypes from 'prop-types';
import Octicon from '../atom/octicon';
import {addEvent} from '../reporter-proxy';
import {autobind} from '../helpers';
export default class ChangedFilesCountView extends React.Component {
static propTypes = {
changedFilesCount: PropTypes.number.isRequired,
didClick: PropTypes.func.isRequired,
mergeConflictsPresent: PropTypes.bool,
}
static defaultProps = {
changedFilesCount: 0,
mergeConflictsPresent: false,
didClick: () => {},
}
constructor(props) {
super(props);
autobind(this, 'handleClick');
}
handleClick() {
addEvent('click', {package: 'github', component: 'ChangedFileCountView'});
this.props.didClick();
}
render() {
return (
<button
ref="changedFiles"
className="github-ChangedFilesCount inline-block"
onClick={this.handleClick}>
<Octicon icon="git-commit" />
{`Git (${this.props.changedFilesCount})`}
{this.props.mergeConflictsPresent && <Octicon icon="alert" />}
</button>
);
}
}