summaryrefslogtreecommitdiff
path: root/source/features/comment-on-draft-pr-indicator.tsx
blob: 20b6a9c4ebd77adf076a3297f0a8362637022364 (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.js';
import observe from '../helpers/selector-observer.js';

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,
});