Skip to content

Instantly share code, notes, and snippets.

@stephenfin
Last active December 10, 2018 14:03
Show Gist options
  • Save stephenfin/5d8185eeaff17fba872f2c93ff18b122 to your computer and use it in GitHub Desktop.
Save stephenfin/5d8185eeaff17fba872f2c93ff18b122 to your computer and use it in GitHub Desktop.
Bugzilla scripts

Custom Scripts for Bugzilla

These are designed to make life with Bugzilla a little more bearable. Unless you're working on nova in Red Hat, you probably won't find these that useful.

Requirements

Installation

  1. If not already done so, install the Code Injector plugin linked above.
  2. Once installed, configure a new script matching on bugzilla\.redhat\.com/. Paste the contents of the script and save it.
  3. Reload a bug. You should see the changes once the DOM has loaded.
/*
* Add tags to Bugzilla titles.
*
* Color palette based on https://www.materialpalette.com/colors
*/
var style = "; color: white; border-radius: 0.25rem; font-size: 0.8rem; padding: 0.1rem 0.2rem; vertical-align: middle; margin: 0.1rem; text-decoration: none;";
var release_url = "https://bugzilla.redhat.com/buglist.cgi?bug_status=NEW&bug_status=ASSIGNED&bug_status=POST&bug_status=MODIFIED&bug_status=ON_DEV&bug_status=ON_QA&classification=Red Hat&component=openstack-nova&list_id=9777946&product=Red Hat OpenStack&query_format=advanced&target_release="
var palette = {
"---": "grey",
"5.0 (RHEL 6)": "grey",
"5.0 (RHEL 7)": "grey",
"6.0 (Juno)": "grey",
"7.0 (Kilo)": "grey",
"8.0 (Liberty)": "#e53935",
"9.0 (Mitaka)": "#d81b60",
"10.0 (Newton)": "#8e24aa",
"11.0 (Ocata)": "#5e35b1",
"12.0 (Pike)": "#3949ab",
"13.0 (Queens)": "#1e88e5",
"14.0 (Rocky)": "#039be5",
"15.0 (Stein)": "#00acc1",
"16.0 (T)": "#00897b",
"17.0 (U)": "#43a047",
};
var parent_container = document.getElementById('summary_container');
// Target release
var target_release = document.getElementById("target_release");
target_release = target_release.options[target_release.selectedIndex].text;
var elem = document.createElement("a");
var text = document.createTextNode(target_release);
elem.style.cssText = "background-color: " + palette[target_release] + style;
elem.title = target_release;
elem.href = release_url + target_release;
elem.appendChild(text)
parent_container.appendChild(elem);
// Keywords
var keywords = document.getElementById("keywords").value;
if (keywords.trim() !== '')
keywords = keywords.split(", ");
else
keywords = []
for (var i = 0; i < keywords.length; i++) {
var elem = document.createElement("span");
var text = document.createTextNode(keywords[i]);
elem.style.cssText = "background-color: grey" + style;
elem.appendChild(text)
parent_container.appendChild(elem);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment