forked from atom/github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile-patch-meta-view.js
51 lines (45 loc) · 1.52 KB
/
file-patch-meta-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
43
44
45
46
47
48
49
50
51
import React from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import CommitDetailItem from '../items/commit-detail-item';
import IssueishDetailItem from '../items/issueish-detail-item';
import {ItemTypePropType} from '../prop-types';
export default class FilePatchMetaView extends React.Component {
static propTypes = {
title: PropTypes.string.isRequired,
actionIcon: PropTypes.string.isRequired,
actionText: PropTypes.string.isRequired,
action: PropTypes.func.isRequired,
children: PropTypes.element.isRequired,
itemType: ItemTypePropType.isRequired,
};
renderMetaControls() {
if (this.props.itemType === CommitDetailItem || this.props.itemType === IssueishDetailItem) {
return null;
}
return (
<div className="github-FilePatchView-metaControls">
<button
className={cx('github-FilePatchView-metaButton', 'icon', this.props.actionIcon)}
onClick={this.props.action}>
{this.props.actionText}
</button>
</div>
);
}
render() {
return (
<div className="github-FilePatchView-meta">
<div className="github-FilePatchView-metaContainer">
<header className="github-FilePatchView-metaHeader">
<h3 className="github-FilePatchView-metaTitle">{this.props.title}</h3>
{this.renderMetaControls()}
</header>
<div className="github-FilePatchView-metaDetails">
{this.props.children}
</div>
</div>
</div>
);
}
}