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
|
import './extend-status-labels.css';
import React from 'dom-chef';
import select from 'select-dom';
import {wrap} from '../libs/dom-utils';
import features from '../libs/features';
function init(): false | void {
if (select.exists('.gh-header-meta a .State')) {
return false;
}
const lastStatusChange = select.last(`
.discussion-item-closed,
.discussion-item-reopened,
.discussion-item-merged
`);
// Leave if the issue/PR was never closed or if it was reopened
if (!lastStatusChange || lastStatusChange.matches('.discussion-item-reopened')) {
return false;
}
const label = select('.gh-header-meta .State')!;
const lastActionLink = select('[href*="/pull/"], [href*="/commit/"], code', lastStatusChange);
if (lastActionLink) {
const isMerged = lastStatusChange.matches('.discussion-item-merged');
label.append(isMerged ? ' as ' : ' in ', lastActionLink.cloneNode(true));
}
// Link label to event in timeline
wrap(label, <a href={'#' + select('[id]', lastStatusChange)!.id}/>);
}
features.add({
id: __featureName__,
description: 'Add reference to PR/commit that closed the current issue/PR',
screenshot: 'https://user-images.githubusercontent.com/1402241/35973522-5c00acb6-0d08-11e8-89ca-03071de15c6f.png',
include: [
features.isPRConversation,
features.isIssue
],
load: features.onNewComments,
init
});
|