Last active
January 12, 2023 09:22
-
-
Save simahawk/22a9a8972ab3a56888aec55c781be283 to your computer and use it in GitHub Desktop.
JIRA board search project bookmarklet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Adds a search input to JIRA board quick filters to search for a project. | |
Installation: copy the snippet into a bookmark. | |
Usage: click on the bookmark while on a JIRA board. | |
Behavior: type a project name and hit enter. | |
If a proj is found on the page the others will be hidden. | |
To restore all the projects, wipe the text and hit enter. | |
*/ | |
javascript: (() => { | |
var search = document.querySelector("#js-work-quickfilters #search_proj"); | |
if (search) { | |
search.parentNode.removeChild(search); | |
} | |
var dd = document.createElement('dd'); | |
var input = document.createElement('input'); | |
input.placeholder = "Search project"; | |
input.name = "search_proj"; | |
input.id = "search_proj"; | |
dd.append(input); | |
document.querySelector("#js-work-quickfilters").append(dd); | |
input.addEventListener('change', (event) => { | |
var value = event.target.value; | |
var swimlanes = document.querySelectorAll('.ghx-swimlane'); | |
if (!value) { | |
swimlanes.forEach(function(el, i){ | |
el.style.display = "block"; | |
}); | |
return | |
} | |
var xpath = "//a[text()='" + value + "']"; | |
var proj = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | |
var heading = proj.closest(".ghx-heading"); | |
if (proj) { | |
var swimlane = heading.closest(".ghx-swimlane"); | |
var closed_swimlane = heading.closest(".ghx-closed"); | |
if (closed_swimlane) { | |
heading.querySelector(".aui-button").click(); | |
} | |
document.querySelectorAll('.ghx-swimlane').forEach(function(el, i){ | |
if (el != swimlane) { | |
el.style.display = "none"; | |
} | |
}); | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment