summaryrefslogtreecommitdiff
path: root/source/features/repo-wide-file-finder.tsx
blob: 8e82d7f1c74f360dc49b311398272a6a63dcd199 (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
33
34
import React from 'dom-chef';
import select from 'select-dom';
import * as pageDetect from 'github-url-detection';

import features from '.';
import {getRepoURL} from '../github-helpers';
import getDefaultBranch from '../github-helpers/get-default-branch';

async function init(): Promise<void> {
	document.body.append(
		<a
			hidden
			data-hotkey="t"
			data-pjax="true"
			href={`/${getRepoURL()}/find/${await getDefaultBranch()}`}
		/>
	);
}

void features.add({
	id: __filebasename,
	description: 'Enables the File Finder keyboard shortcut (`t`) on Issues and Pull Request pages as well.',
	screenshot: false
}, {
	include: [
		pageDetect.isRepoConversationList,
		pageDetect.isPR,
		pageDetect.isIssue
	],
	exclude: [
		() => select.exists('[data-hotkey="t"]')
	],
	init
});