summaryrefslogtreecommitdiff
path: root/source/features/delete-fork-link.tsx
blob: 190141d6b2da5e3ec68de9429dde01ebaba6d977 (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
31
32
import React from 'dom-chef';
import select from 'select-dom';
import features from '../libs/features';
import {getRepoURL} from '../libs/utils';

function init() {
	const currentBranch = select<HTMLElement>('#partial-pull-merging .merge-branch-description .commit-ref');
	if (!currentBranch) {
		return false;
	}

	const [forkPath] = currentBranch.title.split(':');

	if (forkPath === getRepoURL()) {
		return false;
	}

	currentBranch.parentElement.append(
		<a id="refined-github-delete-fork-link" href={`/${forkPath}/settings`}>
			Delete fork
		</a>
	);
}

features.add({
	id: 'delete-fork-link',
	include: [
		features.isPRConversation
	],
	load: features.onNewComments,
	init
});