aboutsummaryrefslogtreecommitdiffstats
path: root/bugzillaBugTriage.js
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2009-11-15 23:40:43 +0100
committerMatěj Cepl <mcepl@redhat.com>2009-11-15 23:40:43 +0100
commit78728ad38776daaa284ea9663aaac85c402ac0e6 (patch)
tree79660d28b710c7120e96e85353bf97869a5fc8a3 /bugzillaBugTriage.js
parent0171e40748b01f28fbe0da530c27162735db70e4 (diff)
downloadbugzilla-triage-78728ad38776daaa284ea9663aaac85c402ac0e6.tar.gz
Some parts are actually working, still no "Query for string" and setting
assignee, not even mentioning chip magic.
Diffstat (limited to 'bugzillaBugTriage.js')
-rw-r--r--bugzillaBugTriage.js629
1 files changed, 508 insertions, 121 deletions
diff --git a/bugzillaBugTriage.js b/bugzillaBugTriage.js
index 53423c7..ce6bb51 100644
--- a/bugzillaBugTriage.js
+++ b/bugzillaBugTriage.js
@@ -3,6 +3,7 @@
jetpack.future.import("pageMods");
jetpack.future.import("storage.simple");
+jetpack.future.import("selection");
var RHColor = "#9E292B";
var FedoraColor = "#002867";
@@ -12,6 +13,7 @@ var SalmonPink = "#FFE0B0";
var ReporterColorHex = "#FFFFA6";
var XMLRPCurl = "https://bugzilla.redhat.com/xmlrpc.cgi";
var myConfig = jetpack.storage.simple;
+var badMIMEArray = ["application/octet-stream","text/x-log"];
//==============================================================
// CONFIGURE: The easiest method how to set up the configuration
@@ -61,20 +63,22 @@ var AddrArray = [];
var PCI_ID_Array = [];
var XorgLogAttList = [];
var XorgLogAttListIndex = 0;
+var topRow = {};
+var bottomRow = {};
// Get JSON configuration data
$.getJSON(jsonDataURL, function (response) {
- var data = response;
- msgStrs = data.strings;
- signatureFedoraString = data.signature;
- hashBugzillaName = data.bugzillalabelNames;
- hashBugzillaWholeURL = data.bugzillaIDURLs;
+ msgStrs = response.strings;
+ signatureFedoraString = response.signature;
+ hashBugzillaName = response.bugzillalabelNames;
+ hashBugzillaWholeURL = response.bugzillaIDURLs;
// [{'regexp to match component':'email address of an universal maintainer'}, ...]
- AddrArray = data.CCmaintainer;
- defAssigneeList = data.defaultAssignee;
- queryButtonAvailable = data.queryButton;
- chipIDsGroupings = data.chipIDsGroupings;
- // TODO buildButtons(data.topRow,data.bottomRow);
+ AddrArray = response.CCmaintainer;
+ defAssigneeList = response.defaultAssignee;
+ queryButtonAvailable = response.queryButton;
+ chipIDsGroupings = response.chipIDsGroupings;
+ topRow = response.topRow;
+ bottomRow = response.bottomRow;
});
// Get card translation table
@@ -92,7 +96,7 @@ $.getJSON(PCIIDsURL,
* @param chosingMark string by which the element of array is to be matched
* @return string chosen element
*/
-function filterByRegexp(list, chosingMark) {
+filterByRegexp = function(list, chosingMark) {
var chosenPair = [];
if (list.length > 0) {
chosenPair = list.filter(
@@ -113,7 +117,7 @@ function filterByRegexp(list, chosingMark) {
* @param list array of elements
* @return array of values
*/
-function valuesToList(list) {
+valuesToList = function(list) {
var outL = [];
list.forEach(function (e, i, a) {
@@ -132,45 +136,46 @@ function valuesToList(list) {
* @param list list
* @return position of the string in the list, or -1 if none found.
*/
-function isInList(mbr, list) {
+isInList = function(mbr, list) {
return (list.indexOf(mbr) !== -1);
}
-///////////////////////////////////////////////////////////////////////////////
-function bzPage(doc) {
- this.doc = $(doc);
- var bugNoTitle = $.trim($("#title > p:first", this.doc).text());
- this.bugNo = new RegExp("[0-9]+").exec(bugNoTitle)[0];
-
- this.reporter = $("#bz_show_bug_column_2 > table .vcard:first > a",
- this.doc).attr("title");
- this.product = $("#product option:selected:first", this.doc).text();
- this.component = $("#component option:selected:first", this.doc).text();
- this.version = $("#version option:selected:first", this.doc).text();
- this.its = $.trim($("#cf_issuetracker", this.doc).text());
- this.CCList = $("#cc", this.doc).attr("value");
- this.defaultAssignee = filterByRegexp(defAssigneeList, this.component).toLowerCase();
- this.maintCCAddr = filterByRegexp(AddrArray,this.component).toLowerCase();
-
- this.attachments = $("#attachment_table tr",
- this.doc).slice(1,-1).map(this.parseAttachmentLine);
-
- this.originalButton = $("#commit", this.doc).get(0);
-
- // Take care of signature for Fedora bugzappers
- if (signatureFedoraString.length > 0) {
- // (or a form named "changeform")
- $("form:nth-child(2)", this.doc).submit(function () {
- var cmntText = $("#comment", this.doc);
- if ((signatureFedoraString.length > 0) &&
- ($.trim(cmntText.text()).length > 0)) {
- cmntText.text($.trim(cmntText.text()) + signatureFedoraString);
+/**
+ * This function creates a new anchor element and uses location properties (inherent)
+ * to get the desired URL data. Some String operations are used (to normalize results
+ * across browsers).
+ * originally from http://snipplr.com/view.php?codeview&id=12659
+ *
+ * @param url String with URL
+ * @return object with parameters set
+ *
+ */
+function parseURL(url) {
+ var a = $('a',this.doc).get(0);
+ a.href = url;
+ return {
+ source: url,
+ protocol: a.protocol.replace(':',''),
+ host: a.hostname,
+ port: a.port,
+ query: a.search,
+ params: (function(){
+ var ret = {},
+ seg = a.search.replace(/^\?/,'').split('&'),
+ len = seg.length, i = 0, s;
+ for (;i<len;i++) {
+ if (!seg[i]) { continue; }
+ s = seg[i].split('=');
+ ret[s[0]] = s[1];
}
- });
- }
-
- this.setBranding();
- this.checkComments();
+ return ret;
+ })(),
+ file: (a.pathname.match(/\/([^\/?#]+)$/i) || [,''])[1],
+ hash: a.hash.replace('#',''),
+ path: a.pathname.replace(/^([^\/])/,'/$1'),
+ relative: (a.href.match(/tp:\/\/[^\/]+(.+)/) || [,''])[1],
+ segments: a.pathname.replace(/^\//,'').split('/')
+ };
}
/**
@@ -249,6 +254,8 @@ bzPage.prototype.setBranding = function () {
}
};
+/**
+ */
bzPage.prototype.groupIDs = function (manStr,cardStrID) {
var outStr = filterByRegexp(chipIDsGroupings,manStr+","+cardStrID);
if (outStr.length == 0) {
@@ -284,7 +291,7 @@ bzPage.prototype.checkChipStringFromID = function (manufacturerNo,cardNo) {
* @param driverStr string with the driver name
* @return None
*/
-bzPage.prototype.fillInWhiteBoard = function (iLine,driverStr) {
+bzPage.prototype.fillInWhiteBoard = function (iLine, driverStr) {
var outStr = "";
var cardIDStr = "";
var cardIDArr = [];
@@ -295,15 +302,15 @@ bzPage.prototype.fillInWhiteBoard = function (iLine,driverStr) {
chipSwitchboard:
if (driverStr == "RADEON") {
var cardID = iLine.replace(ATIgetIDRE,"$1");
- cardIDArr = checkChipStringFromID("1002",cardID);
+ cardIDArr = this.checkChipStringFromID("1002",cardID);
if (cardIDArr.length > 0) {
cardIDStr = cardIDArr[0];
if (cardIDArr[1]) {
optionStr = cardIDArr[1];
- outStr = groupIDs(driverStr,cardIDStr)+"/" + optionStr;
+ outStr = this.groupIDs(driverStr,cardIDStr)+"/" + optionStr;
console.log("cardIDArr = " + cardIDArr.toSource() + ", outStr = "+outStr);
} else {
- outStr = groupIDs(driverStr,cardIDStr);
+ outStr = this.groupIDs(driverStr,cardIDStr);
optionStr = "";
}
console.log("found IDs: " + cardIDStr + "," + optionStr);
@@ -323,39 +330,40 @@ bzPage.prototype.fillInWhiteBoard = function (iLine,driverStr) {
break chipSwitchboard;
}
// cardIDArr [0] = RE, [1] = ("RADEON","INTEL","NOUVEAU"), [2] = manu PCIID
- iLine = trim(iLine.replace(RegExp(cardIDArr[0],"i"),""));
+ iLine = $.trim(iLine.replace(RegExp(cardIDArr[0],"i")));
// FIXME is this necessary? Let's try without it
// outStr = iLine.replace(/^\W*(\w*).*$/,"$1");
// nVidia developers opted-out from grouping
if (driverStr == "INTEL") {
- outStr = groupIDs(cardIDArr[1],iLine);
+ outStr = this.groupIDs(cardIDArr[1],iLine);
} else {
outStr = iLine;
}
}
console.log("result = " + outStr);
- var whiteboardInput = document.getElementById("status_whiteboard");
- var attachedText = trim("card_"+outStr);
- if (whiteboardInput.value.length == 0) {
- whiteboardInput.value = attachedText;
+ var whiteboardInput = $("#status_whiteboard");
+ var attachedText = $.trim("card_"+outStr);
+ if (whiteboardInput.text().length == 0) {
+ whiteboardInput.text(attachedText);
} else {
- whiteboardInput.value += ", " + attachedText;
+ whiteboardInput.text(whiteboardInput.text()+", " + attachedText);
}
};
//
bzPage.prototype.fillInAddButton = function (interestLine,driverString) {
- var newButt = originalButton.cloneNode(true);
- var whiteboardInput = document.getElementById("status_whiteboard");
-
- newButt.setAttribute("id","chipmagic");
- newButt.setAttribute("value","Fill In");
- newButt.addEventListener('click',function (evt) {
+ var newButt = this.originalButton.clone(true);
+ var whiteboardInput = $("#status_whiteboard");
+
+ newButt.attr("id","chipmagic");
+ newButt.attr("value","Fill In");
+ console.log("fillInAddButton newButt = " + newButt.html());
+ newButt.get(0).setAttribute("type","button");
+ newButt.click(function (evt) {
fillInWhiteBoard(interestLine,driverString);
- },true);
- newButt.setAttribute("type","button");
- whiteboardInput.parentNode.appendChild(newButt);
- whiteboardInput.parentNode.insertBefore(document.createTextNode("\u00A0"),newButt);
+ });
+ whiteboardInput.append(newButt);
+ whiteboardInput.before("\u00A0");
};
/**
@@ -433,6 +441,54 @@ bzPage.prototype.fillInChipMagic = function () {
};
/**
+ * Opens a new tab with a query for the given text in the selected component
+ * @param text to be searched for
+ * @param component string with the component name (maybe latter regexp?)
+ * @param product (optional) string with the product name
+ * @return None
+ *
+ * old
+ * long_desc=Xpress%20200&bug_status=NEW&bug_status=ASSIGNED
+ * new
+ * long_desc_type=substring&long_desc=Xpress%20200&bug_status=NEW&bug_status=ASSIGNED
+ */
+bzPage.prototype.queryInNewTab = function(text,component,product) {
+ // Optional parameter
+ console.log("text = " + text + ", component = " + component + ", product " + product);
+ if (product == null) {
+ product = "Fedora";
+ }
+ var url = "https://bugzilla.redhat.com/buglist.cgi?query_format=advanced";
+ if (product) {
+ url += "&product="+product;
+ }
+ if (component) {
+ url += "&component="+component;
+ }
+ if (text) {
+ url += "&long_desc_type=substring&long_desc="+ text.replace(" ","%20");
+ }
+ console.log("queryInNewTab: url = " + url);
+ jetpack.tabs.contentWindow.open(url);
+}
+
+/**
+ */
+bzPage.prototype.queryForSelection = function() {
+// var text = $.trim(jetpack.tabs.current.contentWindow.getSelection().toString);
+// var text = $.trim(jetpack.selection.text);
+ var text="";
+// if (text.length < 1) {
+// console.log("current clipbpard flavors = " +
+// jetpack.clipboard.getCurrentFlavors());
+// text = jetpack.clipboard.get();
+// };
+// if (text.length > 0) {
+// queryInNewTab(text, this.component);
+// }
+}
+
+/**
* Parse the row with the attachment
*
* @param <tr> DOM element to be parsed
@@ -456,9 +512,7 @@ bzPage.prototype.parseAttachmentLine = function (index,inElem) {
var attName = $.trim($("b:first", inElem).text());
// getting id
var aHrefs = $("a", inElem);
- console.log("aHrefs = " + aHrefs.html());
var id = parseInt(aHrefs.attr("href").replace(/^.*attachment.cgi\?id=/, ""),10);
- console.log("id = " + id);
//getting MIME type and size
var stringArray = $(".bz_attach_extra_info >*:first",inElem).text().
@@ -470,6 +524,320 @@ bzPage.prototype.parseAttachmentLine = function (index,inElem) {
};
/**
+ * Select option with given label on the <SELECT> element with given id.
+ *
+ * Also execute change HTMLEvent, so that the form behaves accordingly.
+ *
+ * @param id
+ * @param label
+ * @return none
+ */
+bzPage.prototype.selectOption = function(id,label) {
+// var theOption = $("#"+id+" option[value='"+label+"']",this.doc);
+// theOption.select();
+ var selectElement = $(this.doc).get(0).getElementById(id);
+ var values = selectElement.options;
+ for (var i = 0; i < values.length; i++) {
+ values[i].normalize();
+ if (values[i].text.search(label) != -1) {
+ values[i].selected = true;
+ var intEvent = $(this.doc).get(0).createEvent("HTMLEvents");
+ intEvent.initEvent("change", true, true);
+ selectElement.dispatchEvent(intEvent);
+ break;
+ }
+ }
+}
+
+/**
+ * Check for the presence of a keyword
+ *
+ * @param str string with the keyword
+ * @return Boolean
+ *
+ */
+bzPage.prototype.hasKeyword = function(str) {
+ var kwd = $.trim($('#keywords',this.doc).text());
+ return (RegExp(str).test(kwd));
+}
+
+/**
+ * Add XGL to the CC list
+ *
+ * @param evt event which made this function active
+ * @return none
+ */
+bzPage.prototype.changeOwnerHandler = function(evt) {
+ /** Take care that when changing assignment of the bug,
+ * current owner is added to CC list.
+ * Switch off setting to the default assignee
+ */
+ if (!isInList(this.maintCCAddr, CCList)) {
+ $("#newcc",this.doc).text(this.maintCCAddr);
+ }
+ $("#set_default_assignee",this.doc).removeAttr("checked");
+ this.selectOption("bug_status", "ASSIGNED");
+}
+
+/**
+ * Set the bug to NEEDINFO state
+ *
+ * Working function.
+ * @return none
+ */
+bzPage.prototype.setNeedinfoReporter = function() {
+ $("#needinfo",this.doc).click();
+ this.selectOption("needinfo_role", "reporter");
+}
+
+/**
+ * Add text to the comment.
+ * @param string2BAdded string to be added to the comment box
+ *
+ * @return none
+ */
+bzPage.prototype.addTextToComment = function(string2BAdded) {
+ var commentTextarea = $("#comment",this.doc);
+
+ // don't remove the current content of the comment box,
+ // just behave accordingly
+ if (commentTextarea.text().length > 0) {
+ commentTextarea.text(commentTextarea.text() + "\n\n");
+ }
+ commentTextarea.text(commentTextarea.text() + string2BAdded);
+}
+
+/**
+ * Return string with the ID for the external_id SELECT for
+ * external bugzilla
+ *
+ * @param URLhostname string hostname of the external bugzilla
+ * @return string with the string for the external_id SELECT
+ */
+bzPage.prototype.getBugzillaName = function(URLhostname) {
+ var bugzillaID = "";
+ if (hashBugzillaName[URLhostname]) {
+ bugzillaID = hashBugzillaName[URLhostname];
+ } else {
+ bugzillaID = "";
+ }
+ return bugzillaID;
+}
+
+/**
+ * Generate URL of the bug on remote bugzilla
+ * @param selectValue Number which is index of the bugzilla in hashBugzillaWholeURL
+ * @param bugID Number which is bug ID
+ * @return string with the URL
+ */
+bzPage.prototype.getWholeURL = function(selectValue,bugID) {
+ var returnURL = "";
+ if (hashBugzillaWholeURL[selectValue]) {
+ returnURL = hashBugzillaWholeURL[selectValue]+bugID;
+ } else {
+ returnURL = "";
+ }
+ return returnURL;
+}
+
+/**
+ * Add information about the upstream bug upstream, and closing it.
+ * @param evt event which called this handler
+ *
+ * @return none
+ */
+bzPage.prototype.addClosingUpstream = function() {
+ var refs = $("#external_bugs_table tr",this.doc);
+ // that's a bad id, if there is a one. :)
+ var inputBox = $("#inputbox",this.doc);
+ var externalBugID = 0;
+ var wholeURL = "";
+
+ // Fix missing ID on the external_id SELECT
+ $("select[name='external_id']:first",this.doc).attr("id","external_id");
+
+ if (inputBox.text().match(/^http.*/)) {
+ var IBURLArr = parseURL(inputBox.text());
+ console.log("IBURLArr = " + IBURLArr.toSource());
+ externalBugID = parseInt(IBURLArr.params["id"]);
+ inputBox.text(externalBugID);
+ var bugzillaName = getBugzillaName(IBURLArr.host);
+ this.selectOption("external_id", bugzillaName);
+ console.log("externalBugID = " + externalBugID);
+ } else if (!isNaN(inputBox.text())) {
+ externalBugID = parseInt(inputBox.text());
+ var bugzillaID = $("#external_id").text();
+ wholeURL = getWholeURL(bugzillaID,externalBugID);
+ } else {
+ // no inputBox.value -- maybe there is an external bug from
+ // the previous commit?
+ ;
+ }
+
+ // It is not good to close bug as UPSTREAM, if there is no reference
+ // to the upstream bug.
+ if ((refs.length > 2) || (externalBugID > 0)) {
+ this.addTextToComment(msgStrs['sentUpstreamString'].replace("§§§",wholeURL));
+ this.selectOption("bug_status", "CLOSED");
+ this.selectOption("resolution", "UPSTREAM");
+ } else {
+ alert("No external bug specified among the External References!");
+ }
+}
+
+/**
+ * Currently we don't use this function
+ * @param evt event send from DOM (not used)
+ * @return none
+ */
+bzPage.prototype.swapXGLMainToCCListHandler = function(evt) {
+ /** Remove mcepl@redhat.com from CC list and put there
+ * xgl-maint@redhat.com
+ */
+
+ myAddrIndex = CCList.indexOf(login);
+ if (!isInList(this.maintCCAddr, CCList)) {
+ $("#newcc",this.doc).text(this.maintCCAddr);
+ }
+ if (isInList(login, CCList)) {
+ var selBox = $("#cc").get();
+ selBox[myAddrIndex].selected = true;
+ $("#removecc").attr("checked","checked");
+ }
+ evt.stopPropagation();
+ evt.preventDefault();
+}
+
+/** Insert row of buttons before the marked element
+ * @param anchor element before which the row of buttons will be inserted
+ * @param array array of data for buttons to be generated
+ */
+bzPage.prototype.generateToolBar = function(anchor,array) {
+ for (var i=0; i<array.length; i++) {
+ var butt = array[i];
+ this.addNewButton(anchor, butt['idx'],
+ butt['msg'], butt['string'], butt['state'], butt['parameter'],
+ butt['submit']);
+ }
+}
+
+/**
+ * Generalized function for all actions
+ *
+ * @param addString string to be added as new comment
+ * @param nextState string signifying next state of the bug (whatever is in Bugzilla +
+ "NEEDINFO" meaning NEEDINFO(Reporter))
+ * @param secondParameter string with label on the subbutton for reason
+ * of closing the bug
+ * @return none
+ */
+bzPage.prototype.generalPurposeCureForAllDisease = function
+ (addString,nextState,secondParameter) {
+ if (addString.length >0) {
+ this.addTextToComment(addString);
+ }
+
+ if (nextState == "CLOSED") {
+ if (secondParameter == "UPSTREAM") {
+ this.addClosingUpstream();
+ } else if (secondParameter.length > 0) {
+ this.selectOption("bug_status", nextState);
+ this.selectOption("resolution",secondParameter);
+ return 0;
+ } else {
+ throw("Missing resolution for CLOSED status.");
+ }
+ }
+
+ // Now closing bugs is done, what about the rest?
+ if (nextState == "NEEDINFO") {
+ this.setNeedinfoReporter();
+ } else if (nextState == "ADDKEYWORD") {
+ if (secondParameter.length == 0) {
+ throw "Keyword has to be defined";
+ }
+ this.addKeyword(secondParameter);
+ } else if (nextState == "ASSIGNED") {
+ if (!isInList(this.maintCCAddr, this.CCList)) {
+ $("#newcc",this.doc).text(this.maintCCAddr);
+ }
+ this.selectOption("bug_status", nextState);
+ } else if (nextState == "QUERYSEL") {
+ this.queryForSelection();
+ } else if (nextState == "SETDEFASS") {
+ if (secondParameter.length > 0) {
+ console.log("default assignee = " + secondParameter);
+ //$("#bz_assignee_edit_action",this.doc).click();
+ //$("#assigned_to", this.doc).text(secondParameter);
+ }
+ } else if (nextState.length >0) {
+ this.selectOption("bug_status", nextState);
+ }
+
+ if (secondParameter == "ADDSELFCC") {
+ $("#addselfcc", this.doc).attr("checked","checked");
+ } else if (secondParameter == "NODEFAULTASSIGNEE") {
+ $("#set_default_assignee", this.doc).removeAttr("checked");
+ }
+}
+
+/**
+ * Generic function to add new button to the page.
+ * Actually copies new button from the old one (in order to have the same
+ * look-and-feel, etc.
+ * @param originalLocation object with the button to be copied from
+ * @param newId string with the id of the new button; has to be unique in
+ whole page
+ * @param newLabel string with the label which will be shown to user
+ * @param commentString string with comment to be added to the comment box
+ * @param nState string with the new state bug should switch to (see
+ * generalPurposeCureForAllDisease function for details)
+ * @param secPar string with second parameter for generalPurposeForAllDisease
+ * @param doSubmit bool optional whether the button should submit whole page
+ * (default true)
+ *
+ * @return none
+ */
+bzPage.prototype.addNewButton = function (originalLocation,newId,newLabel,
+ commentString,nState,secPar,doSubmit) {
+ var that = this;
+ var commStr = "";
+ if (doSubmit === null) { // missing optional argument
+ doSubmit = true;
+ }
+ if (msgStrs[commentString]) {
+ commStr = msgStrs[commentString];
+ }
+ var newButton = this.originalButton.clone(true).attr({
+ "id":newId,
+ "value":newLabel
+ }).click(function (evt) {
+ that.generalPurposeCureForAllDisease(commStr,nState, secPar);
+ });
+ $(originalLocation, this.doc).before(newButton).before("\u00A0");
+ if (!doSubmit) {
+ newButton.get(0).setAttribute("type","button");
+ }
+}
+
+/**
+ * Add new keyword among the keywords.
+ *
+ * @param str string with the new keyword
+ * @return none
+ *
+ * Checks for the existing keywords.
+ */
+bzPage.prototype.addKeyword = function (str) {
+ var kwd = $('#keywords',this.doc);
+ if (kwd.text().length == 0) {
+ kwd.text(str);
+ }else{
+ kwd.text(kwd.text() + ", " + str);
+ }
+}
+
+/**
* Main executable functioning actually building all buttons on the page --
* separated into function, so that
* it could be called from onload method of the GM_XMLHTTPRequest.
@@ -479,76 +847,95 @@ bzPage.prototype.parseAttachmentLine = function (index,inElem) {
*/
bzPage.prototype.buildButtons = function (above,below) {
//Generate a list of <input> elements in the page
- var IBList = $("input[name*='submit']", this.doc);
- var IBLast = IBList.get(IBList.length-4);
- addNewButton(IBLast,"changeOwnerbtn","reASSIGN",
+ var IBLast = $("#commit_top", this.doc);
+ this.addNewButton(IBLast,"changeOwnerbtn","reASSIGN",
"","ASSIGNED","NODEFAULTASSIGNEE");
- // BUTTONS ABOVE THE COMMENT BOX
- var insAElem = $("<br>");
- $("#comment", this.doc).before(insAElem);
- generateToolBar(insAElem,above);
-
- // BUTTONS BELOW THE COMMENT BOX
- generateToolBar(this.originalButton,below);
+ // THE MAIN BUTTON ROWS
+ var commentBox = $("#comment", this.doc);
+ commentBox.before("<br>");
+ this.generateToolBar(commentBox.prev(),above);
+ this.generateToolBar(this.originalButton,below);
- // FIXME put this somehow into addNewButton and generalPurposeCureForAllDisease
- // framework
- if (queryButtonAvailable){
+ if (queryButtonAvailable) {
// Add query search button
- var newPosition = $("#newcommentprivacy", this.doc).siblings("eq(3)");
- var newButt = originalButton.clone(true).attr({
- "id":"newqueryintab",
- "value":"Query for string",
- "type":"button"
- }).click(function (evt) {
- queryForSelection();
- }).prependTo(newPosition).before("\u00A0");
+ // Apparently there is a bug in jQuery, we have to use plain DOM
+ //newPosition = $("#newcommentprivacy ~ br", this.doc);
+ newPosition = $(this.doc.get(0).querySelector("#newcommentprivacy ~ br"));
+ newPosition.css("border","solid blue");
+ this.addNewButton(newPosition,"newqueryintab","Query for string",
+ "","QUERYSEL","",false);
}
if ((chipIDsGroupings.length >0) && this.maintCCAddr == "xgl-maint@redhat.com") {
// Add find chip magic button
if (!$("#status_whiteboard:contains('card_')", this.doc)) {
- this.fillInChipMagic(); //FIXME missing!!!
+ this.fillInChipMagic();
}
}
// Add setting default assignee
- if ((this.defAssignee.length > 0) && (this.defAssignee != owner)) {
- var divAssigned = $("#bz_assignee_edit_container", this.doc);
- var divAssignedInput = $("#assigned_to", this.doc);
- var divAssignedActiveCheckbox = $("#bz_assignee_edit_action");
- newButt = originalButton.clone(true).
- attr({"id":"setdefaultassigneebutton",
- "value":"Def. Assignee",
- "type":"button"
- }).click(function (evt) {
- if (defAssignee.length > 0) {
- clickMouse(divAssignedActiveCheckbox);
- $(divAssignedInput,this.doc).text(defAssignee);
- }
- }); //FIXME SHOULD CONTINUE WHERE I ENDED HERE!
- divAssigned.appendChild(newButt);
- newButt.parentNode.insertBefore(document.createTextNode("\u00A0"),newButt);
+ if ((this.defaultAssignee.length > 0) && (this.defaultAssignee != this.owner)) {
+ this.addNewButton($("#bz_assignee_edit_container", this.doc),
+ "setdefaultassigneebutton","Def. Assignee",
+ "","SETDEFASS",this.defaultAssignee,false);
}
- $("component").change(
- function (event) {
- //FIXME We screw up default assignee value for unknown components
- var assignee = this.defAssignee;
- // FIXME tohlenějak rozesraný Ježe.
- if (assignee.length > 0) {
- clickMouse(document.getElementById("bz_assignee_edit_action"));
- $.ID("assigned_to").value = assignee;
- document.getElementById("set_default_assignee").checked = false;
- }
- });
};
+///////////////////////////////////////////////////////////////////////////////
+function bzPage(doc) {
+ this.doc = $(doc);
+ this.originalButton = $("#commit", this.doc);
+ var bugNoTitle = $.trim($("#title > p:first", this.doc).text());
+ this.bugNo = new RegExp("[0-9]+").exec(bugNoTitle)[0];
+
+ this.reporter = $("#bz_show_bug_column_2 > table .vcard:first > a",
+ this.doc).attr("title");
+ this.product = $("#product option:selected:first", this.doc).text();
+ this.component = $("#component option:selected:first", this.doc).text();
+ this.version = $("#version option:selected:first", this.doc).text();
+ this.its = $.trim($("#cf_issuetracker", this.doc).text());
+ this.CCList = $("#cc", this.doc).attr("value");
+ this.defaultAssignee = filterByRegexp(defAssigneeList, this.component).toLowerCase();
+ this.maintCCAddr = filterByRegexp(AddrArray,this.component).toLowerCase();
+
+ this.attachments = $("#attachment_table tr",
+ this.doc).slice(1,-1).map(this.parseAttachmentLine);
+
+ var badAttachments = this.attachments.filter(function (a) {
+ return (badMIMEArray.indexOf(a[2]) != -1);
+ });
+
+ if (badAttachments.length>0) {
+ console.log("we have " + badAttachments.length + " bad attachments.");
+ var titleElement = $(".bz_alias_short_desc_container:first").css("background-color",
+ "olive").append($(this.createFixAllButton(badAttachments)));
+ badAttachments.forEach(function (x) {
+ this.addTextLink(x);
+ });
+ }
+
+ // Take care of signature for Fedora bugzappers
+ if (signatureFedoraString.length > 0) {
+ // (or a form named "changeform")
+ $("form:nth-child(2)", this.doc).submit(function () {
+ var cmntText = $("#comment", this.doc);
+ if ((signatureFedoraString.length > 0) &&
+ ($.trim(cmntText.text()).length > 0)) {
+ cmntText.text($.trim(cmntText.text()) + signatureFedoraString);
+ }
+ });
+ }
+
+ this.setBranding();
+ this.checkComments();
+ this.buildButtons(topRow,bottomRow);
+}
+
var callback = function (doc) {
var curPage = new bzPage(doc);
};
var options = {};
options.matches = [
- "https://bugzilla.redhat.com/show_bug.cgi*",
- "https://bugzilla.redhat.com/process_bug.cgi"
+ "https://bugzilla.redhat.com/show_bug.cgi",
];
jetpack.pageMods.add(callback, options);