This repository was archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 408
Expand file tree
/
Copy pathcomment-gutter-decoration-controller.js
More file actions
66 lines (59 loc) · 2.11 KB
/
comment-gutter-decoration-controller.js
File metadata and controls
66 lines (59 loc) · 2.11 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
61
62
63
64
65
66
import React from 'react';
import {Range} from 'atom';
import PropTypes from 'prop-types';
import {EndpointPropType} from '../prop-types';
import Decoration from '../atom/decoration';
import Marker from '../atom/marker';
import ReviewsItem from '../items/reviews-item';
import {addEvent} from '../reporter-proxy';
export default class CommentGutterDecorationController extends React.Component {
static propTypes = {
commentRow: PropTypes.number.isRequired,
threadId: PropTypes.string.isRequired,
extraClasses: PropTypes.array,
workspace: PropTypes.object.isRequired,
endpoint: EndpointPropType.isRequired,
owner: PropTypes.string.isRequired,
repo: PropTypes.string.isRequired,
number: PropTypes.number.isRequired,
workdir: PropTypes.string.isRequired,
editor: PropTypes.object,
// For metric reporting
parent: PropTypes.string.isRequired,
};
static defaultProps = {
extraClasses: [],
}
render() {
const range = Range.fromObject([[this.props.commentRow, 0], [this.props.commentRow, Infinity]]);
return (
<Marker
key={`github-comment-gutter-decoration-${this.props.threadId}`}
editor={this.props.editor}
exclusive={true}
invalidate="surround"
bufferRange={range}>
<Decoration
editor={this.props.editor}
type="gutter"
gutterName="github-comment-icon"
className={`github-editorCommentGutterIcon ${this.props.extraClasses.join(' ')}`}
omitEmptyLastRow={false}>
<button className="icon icon-comment" onClick={() => this.openReviewThread(this.props.threadId)} />
</Decoration>
</Marker>
);
}
async openReviewThread(threadId) {
const uri = ReviewsItem.buildURI({
host: this.props.endpoint.getHost(),
owner: this.props.owner,
repo: this.props.repo,
number: this.props.number,
workdir: this.props.workdir,
});
const reviewsItem = await this.props.workspace.open(uri, {searchAllPanes: true});
reviewsItem.jumpToThread(threadId);
addEvent('open-review-thread', {package: 'github', from: this.props.parent});
}
}