Skip to content

Commit cb09ef7

Browse files
committed
[UI] Handle selection of all branches
1 parent 0956894 commit cb09ef7

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

html/branchSelection.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
d="M11.75 2.5a.75.75 0 100 1.5.75.75 0 000-1.5zm-2.25.75a2.25 2.25 0 113 2.122V6A2.5 2.5 0 0110 8.5H6a1 1 0 00-1 1v1.128a2.251 2.251 0 11-1.5 0V5.372a2.25 2.25 0 111.5 0v1.836A2.492 2.492 0 016 7h4a1 1 0 001-1v-.628A2.25 2.25 0 019.5 3.25zM4.25 12a.75.75 0 100 1.5.75.75 0 000-1.5zM3.5 3.25a.75.75 0 111.5 0 .75.75 0 01-1.5 0z">
1212
</path>
1313
</svg>
14-
<span class="css-truncate-target" data-menu-button="">All branches</span>
14+
<span class="css-truncate-target" data-menu-button="" id = "branches-dropdown-button">All branches</span>
1515
<span class="dropdown-caret"></span>
1616
</summary>
1717
<div class="SelectMenu">

js/setBranchOptions.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
function setBranchOptions(branches, selectedBranchNames, allBranches) {
22
var branchesContainer = document.getElementById("branches-list-parent");
33
var existingChild = branchesContainer.children[0];
4+
var branchesDropdownButton = document.getElementById("branches-dropdown-button");
45

56
var branchNames = new Set()
67
for (var branch in allBranches) {
@@ -11,6 +12,12 @@ function setBranchOptions(branches, selectedBranchNames, allBranches) {
1112
var newChild = existingChild.cloneNode(true);
1213
newChild.children[1].innerHTML = branch;
1314
newChild.setAttribute("branch-name", branch);
15+
if(selectedBranchNames.includes(branch)){
16+
newChild.setAttribute("aria-checked", "true");
17+
}
18+
else{
19+
newChild.setAttribute("aria-checked", "false");
20+
}
1421
newChild.addEventListener("click", () => {
1522
var thisItem = document.querySelector(`[branch-name="${branch}"]`);
1623

@@ -33,6 +40,15 @@ function setBranchOptions(branches, selectedBranchNames, allBranches) {
3340
branchesContainer.appendChild(newChild);
3441
});
3542

43+
if (branchNames.size == selectedBranchNames.length) {
44+
branchesContainer.children[0].setAttribute("aria-checked", "true");
45+
branchesDropdownButton.innerHTML = "All Branches";
46+
}
47+
else {
48+
branchesContainer.children[0].setAttribute("aria-checked", "false");
49+
branchesDropdownButton.innerHTML = "Select Branches";
50+
}
51+
3652
// Action for the "All branches" button
3753
branchesContainer.children[0].addEventListener("click", () => {
3854
if (branchesContainer.children[0].getAttribute("aria-checked") == "true") {

0 commit comments

Comments
 (0)