blob: 5929e4ff7a988b639e8faec004b7fd6d26c600b5 (
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
|
import React from 'dom-chef';
import select from 'select-dom';
import onetime from 'onetime';
import * as pageDetect from 'github-url-detection';
import {wrap} from '../helpers/dom-utils';
import features from '.';
async function init(): Promise<void> {
for (const label of select.all('.js-recent-activity-container :not(a) > .IssueLabel')) {
const activity = label.closest('li')!;
const isPR = select.exists('.octicon-git-pull-request', activity);
const repository = select<HTMLAnchorElement>('a[data-hovercard-type="repository"]', activity)!;
const url = new URL(`${repository.href}/${isPR ? 'pulls' : 'issues'}`);
const labelName = label.textContent!.trim();
url.searchParams.set('q', `is:${isPR ? 'pr' : 'issue'} is:open sort:updated-desc label:"${labelName}"`);
wrap(label, <a href={String(url)}/>);
}
}
void features.add({
id: __filebasename,
description: 'Makes labels clickable in the dashboard’s "Recent activity" box.',
screenshot: 'https://user-images.githubusercontent.com/1402241/69045444-6ef97300-0a29-11ea-99a3-9a622c395709.png'
}, {
include: [
pageDetect.isDashboard
],
onlyAdditionalListeners: true,
init: onetime(init)
});
|