summaryrefslogtreecommitdiff
path: root/source/features/linkify-branch-refs.tsx
blob: c3e43bc0ff98e67c0baf2a398eccf93df05a9b2a (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
import React from 'dom-chef';
import elementReady from 'element-ready';
import features from '../libs/features';
import {getRepoURL} from '../libs/utils';
import {wrap} from '../libs/dom-utils';

async function init(): Promise<void> {
	const el = await elementReady('.branch-name');
	if (el) {
		const branchUrl = `/${getRepoURL()}/tree/${el.textContent}`;
		wrap(el.closest('.branch-name')!, <a href={branchUrl}></a>);
	}
}

features.add({
	id: __featureName__,
	description: 'Linkifies branch references in "Quick PR" pages.',
	screenshot: 'https://user-images.githubusercontent.com/1402241/30208043-fa1ceaec-94bb-11e7-9c32-feabcf7db296.png',
	include: [
		features.isQuickPR
	],
	load: features.onAjaxedPages,
	init
});