summaryrefslogtreecommitdiff
path: root/source/features/jump-to-change-requested-comment.tsx
blob: e2809d94df3af2d60fc38cad8715174b22873091 (plain) (blame)
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
import React from 'dom-chef';
import {$} from 'select-dom';
import * as pageDetect from 'github-url-detection';

import {wrap} from '../helpers/dom-utils.js';
import features from '../feature-manager.js';
import observe from '../helpers/selector-observer.js';

function linkify(textLine: HTMLElement): void {
	const url = $('a.dropdown-item[href^="#pullrequestreview-"]', textLine.parentElement!)!;
	// `lastChild` is a textNode
	wrap(textLine.lastChild!, <a href={url.hash}/>);
}

function init(signal: AbortSignal): void {
	observe('.merge-status-item.review-item [title*="requested changes"]', linkify, {signal});
}

void features.add(import.meta.url, {
	include: [
		pageDetect.isPRConversation,
	],
	init,
});

/*
Test URLs

https://github.com/ipaddress-gem/ipaddress/pull/22#partial-pull-merging
*/