forked from atom/github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser-mention-tooltip-container.js
66 lines (60 loc) · 1.99 KB
/
user-mention-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
import React from 'react';
import {graphql, createFragmentContainer} from 'react-relay';
import PropTypes from 'prop-types';
import Octicon from '../atom/octicon';
export class BareUserMentionTooltipContainer extends React.Component {
static propTypes = {
repositoryOwner: PropTypes.shape({
login: PropTypes.string.isRequired,
avatarUrl: PropTypes.string.isRequired,
repositories: PropTypes.shape({
totalCount: PropTypes.number.isRequired,
}).isRequired,
// Users
company: PropTypes.string,
// Organizations
membersWithRole: PropTypes.shape({
totalCount: PropTypes.number.isRequired,
}),
}).isRequired,
}
render() {
const owner = this.props.repositoryOwner;
const {login, company, repositories, membersWithRole} = owner;
return (
<div className="github-UserMentionTooltip">
<div className="github-UserMentionTooltip-avatar">
<img alt="repository owner's avatar" src={owner.avatarUrl} />
</div>
<div className="github-UserMentionTooltip-info">
<div className="github-UserMentionTooltip-info-username">
<Octicon icon="mention" /><strong>{login}</strong>
</div>
{company && <div><Octicon icon="briefcase" /><span>{company}</span></div>}
{membersWithRole && (
<div><Octicon icon="organization" /><span>{membersWithRole.totalCount} members</span></div>
)}
<div><Octicon icon="repo" /><span>{repositories.totalCount} repositories</span></div>
</div>
<div style={{clear: 'both'}} />
</div>
);
}
}
export default createFragmentContainer(BareUserMentionTooltipContainer, {
repositoryOwner: graphql`
fragment userMentionTooltipContainer_repositoryOwner on RepositoryOwner {
login
avatarUrl
repositories { totalCount }
... on User {
company
}
... on Organization {
membersWithRole {
totalCount
}
}
}
`,
});