-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmergeRequestFilter.js
More file actions
50 lines (46 loc) · 1.49 KB
/
mergeRequestFilter.js
File metadata and controls
50 lines (46 loc) · 1.49 KB
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
45
46
47
48
49
50
let src = chrome.runtime.getURL("common.js");
const { utils } = await import(src);
src = chrome.runtime.getURL("toolbarRowFilterer.js");
const { toolbarRowFilterer } = await import(src);
src = chrome.runtime.getURL("merge-request-status.js");
const { mergeRequestStatus } = await import(src);
/**
* Creates a toolbar item that lists how many issues each user has and allows filtering by user.
*
* @type {{createElement: (function(): HTMLDivElement)}}
*/
class mergeRequestFilterer extends toolbarRowFilterer {
createElement() {
// On issue queue search page
const mergeRequestsTds = utils
.getIssueListViewElement()
.querySelectorAll("td.merge-request-status");
const existingStatuses = Array.from(mergeRequestStatus.existingStatues);
existingStatuses.unshift("none");
existingStatuses.unshift(toolbarRowFilterer.notEmpty);
return this.setUpFilter(
mergeRequestsTds,
"Merge-Request",
existingStatuses
);
}
/**
* Determines if a field matches a value.
*
* @param field
* @param filterValue
* @returns {boolean}
*/
fieldMatchesFilterValue(field, filterValue) {
if (
filterValue === toolbarRowFilterer.notEmpty &&
field.classList.contains("merge-request-status-exists")
) {
return true;
}
const mergeStatusClass = "merge-request-status_" + filterValue;
return field.classList.contains(mergeStatusClass);
}
}
const mergeRequestFilter = new mergeRequestFilterer();
export { mergeRequestFilter };