forked from atom/github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathissueish-tooltip-container.js
75 lines (68 loc) · 2.06 KB
/
issueish-tooltip-container.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import React from 'react';
import {createFragmentContainer, graphql} from 'react-relay';
import PropTypes from 'prop-types';
import cx from 'classnames';
import Octicon from '../atom/octicon';
import {GHOST_USER} from '../helpers';
const typeAndStateToIcon = {
Issue: {
OPEN: 'issue-opened',
CLOSED: 'issue-closed',
},
PullRequest: {
OPEN: 'git-pull-request',
CLOSED: 'git-pull-request',
MERGED: 'git-merge',
},
};
export class BareIssueishTooltipContainer extends React.Component {
static propTypes = {
resource: PropTypes.shape({
issue: PropTypes.shape({}),
pullRequest: PropTypes.shape({}),
}).isRequired,
}
render() {
const resource = this.props.resource;
const author = resource.author || GHOST_USER;
const {repository, state, number, title, __typename} = resource;
const icons = typeAndStateToIcon[__typename] || {};
const icon = icons[state] || '';
return (
<div className="github-IssueishTooltip">
<div className="issueish-avatar-and-title">
<img className="author-avatar" src={author.avatarUrl} title={author.login}
alt={author.login}
/>
<h3 className="issueish-title">{title}</h3>
</div>
<div className="issueish-badge-and-link">
<span className={cx('issueish-badge', 'badge', state.toLowerCase())}>
<Octicon icon={icon} />
{state.toLowerCase()}
</span>
<span className="issueish-link">
{repository.owner.login}/{repository.name}#{number}
</span>
</div>
</div>
);
}
}
export default createFragmentContainer(BareIssueishTooltipContainer, {
resource: graphql`
fragment issueishTooltipContainer_resource on UniformResourceLocatable {
__typename
... on Issue {
state number title
repository { name owner { login } }
author { login avatarUrl }
}
... on PullRequest {
state number title
repository { name owner { login } }
author { login avatarUrl }
}
}
`,
});