summaryrefslogtreecommitdiff
path: root/source/features/comment-on-draft-pr-indicator.tsx
blob: f8625ac70ba408dcdb5942fe7a3641ac26d0d741 (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
import * as pageDetect from 'github-url-detection';

import features from '../feature-manager';
import observe from '../helpers/selector-observer';

function addIndicator(button: HTMLElement): void {
	const preposition = button.textContent!.includes('Add') ? ' to ' : ' on ';
	button.textContent! += preposition + 'draft PR';
}

function init(signal: AbortSignal): void {
	observe([
		'.review-simple-reply-button', // "Add single comment" button
		'.add-comment-label', // "Add review comment" button
		'.start-review-label', // "Start a review" button
	], addIndicator, {signal});
}

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