forked from atom/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathissueish-tooltip-item.js
More file actions
60 lines (54 loc) · 1.59 KB
/
issueish-tooltip-item.js
File metadata and controls
60 lines (54 loc) · 1.59 KB
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
import React from 'react';
import ReactDom from 'react-dom';
import {QueryRenderer, graphql} from 'react-relay';
import IssueishTooltipContainer from '../containers/issueish-tooltip-container';
export default class IssueishTooltipItem {
constructor(issueishUrl, relayEnvironment) {
this.issueishUrl = issueishUrl;
this.relayEnvironment = relayEnvironment;
}
getElement() {
return this.element;
}
get element() {
if (!this._element) {
this._element = document.createElement('div');
const rootContainer = (
<QueryRenderer
environment={this.relayEnvironment}
query={graphql`
query issueishTooltipItemQuery($issueishUrl: URI!) {
resource(url: $issueishUrl) {
...issueishTooltipContainer_resource
}
}
`}
variables={{
issueishUrl: this.issueishUrl,
}}
render={({error, props, retry}) => {
if (error) {
return <div>Could not load information</div>;
} else if (props) {
return <IssueishTooltipContainer {...props} />;
} else {
return (
<div className="github-Loader">
<span className="github-Spinner" />
</div>
);
}
}}
/>
);
this._component = ReactDom.render(rootContainer, this._element);
}
return this._element;
}
destroy() {
if (this._element) {
ReactDom.unmountComponentAtNode(this._element);
delete this._element;
}
}
}