forked from tedbow/drupal-gitlab-chrome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
toolbar.js
47 lines (44 loc) · 1.69 KB
/
toolbar.js
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
let src = chrome.runtime.getURL("common.js");
const { utils } = await import(src);
src = chrome.runtime.getURL("drupal-user-count.js");
const { userCount } = await import(src);
src = chrome.runtime.getURL("dynamic-filter-script.js");
const { titleFilter } = await import(src);
src = chrome.runtime.getURL("drupal-status-count.js");
const { statusCount } = await import(src);
src = chrome.runtime.getURL("drupal-priority-count.js");
const { priorityCount } = await import(src);
src = chrome.runtime.getURL("drupal-component-count.js");
const { componentCount } = await import(src);
/**
* Provides a custom toolbar on the listing page.
*
* @type {{elementId: string, create: listingToolbar.create, removeExisting: listingToolbar.removeExisting}}
*/
const listingToolbar = {
elementId: "custom-toolbar",
create: function () {
this.removeExisting();
const customToolbar = document.createElement("div");
customToolbar.id = this.elementId;
const issueTable = utils.getIssueTableElement();
// Add the individual elements to the toolbar.
customToolbar.appendChild(userCount.createElement());
customToolbar.appendChild(statusCount.createElement());
customToolbar.appendChild(priorityCount.createElement());
customToolbar.appendChild(componentCount.createElement());
customToolbar.appendChild(titleFilter.createElement());
issueTable.parentNode.insertBefore(customToolbar, issueTable);
return customToolbar;
},
removeExisting: function () {
const existingToolbar = this.getElement();
if (existingToolbar) {
existingToolbar.remove();
}
},
getElement: function () {
return document.getElementById(this.elementId);
},
};
export { listingToolbar };