blob: befed5e652f0a77f8c4d673163b73a91834d6295 (
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
35
36
37
38
39
40
41
42
43
44
|
import select from 'select-dom';
import features from '../libs/features';
import * as api from '../libs/api';
import {getOwnerAndRepo} from '../libs/utils';
async function init(): Promise<void> {
const {ownerName, repoName} = getOwnerAndRepo();
const result = await api.v4(`
query {
repository(owner: "${ownerName}", name: "${repoName}") {
projects { totalCount }
milestones { totalCount }
}
organization(login: "${ownerName}") {
projects { totalCount }
}
}
`, {
allowErrors: true
});
// If the repo and organization has no projects, its selector will be empty
if (
result.repository.projects.totalCount === 0 &&
(!result.organization || result.organization.projects.totalCount === 0)
) {
select('[data-hotkey="p"')!.parentElement!.remove();
}
// If the repo has no milestones, its selector will be empty
if (result.repository.milestones.totalCount === 0) {
select('[data-hotkey="m"')!.parentElement!.remove();
}
}
features.add({
id: 'clean-issue-filters',
description: 'Hide empty issue/PR filters in lists',
init,
load: features.onAjaxedPages,
include: [
features.isRepoDiscussionList
]
});
|