From 7b6eefcd506ec03e1db422ca6e1f4f1bb8420d1c Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Thu, 28 Apr 2011 14:28:10 +0200 Subject: Reorganization. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fixingAttMIME, rhbzpage, xorgBugCategories moved to data/rhlib directory, * docs directory removed ... keep documentation in JSDocs; rewrite in MD is a waste of time. * move Ehsan’s scripts to separate data/tweaks directory. --- data/rhlib/fixingAttMIME.js | 90 +++++++ data/rhlib/rhbzpage.js | 512 ++++++++++++++++++++++++++++++++++++++++ data/rhlib/xorgBugCategories.js | 74 ++++++ 3 files changed, 676 insertions(+) create mode 100644 data/rhlib/fixingAttMIME.js create mode 100644 data/rhlib/rhbzpage.js create mode 100644 data/rhlib/xorgBugCategories.js (limited to 'data/rhlib') diff --git a/data/rhlib/fixingAttMIME.js b/data/rhlib/fixingAttMIME.js new file mode 100644 index 0000000..365cfae --- /dev/null +++ b/data/rhlib/fixingAttMIME.js @@ -0,0 +1,90 @@ +// Released under the MIT/X11 license +// http://www.opensource.org/licenses/mit-license.php + +var reqCounter = 0; // TODO should be probably a dict indexed by called method + +/** + * Callback function for the XMLRPC request + * + * @param ret + * Object with xmlhttprequest response with attributes: + status -- int + * return code + statusText + responseHeaders + responseText + */ +function XMLRPCcallback() { + reqCounter--; + if (reqCounter <= 0) { + setTimeout(function() { + window.location.reload(true); + }, 1000); + } +} + +/** + * The worker function -- call XMLRPC to fix MIME type of the particular + * attachment + * + * @param id + * Integer with the attachment id to be fixed + * @param type + * String with the new MIME type, optional defaults to "text/plain" + * @param email + * Boolean whether email should be sent to appropriate person; option, + * defaults to false + * + * updateAttachMimeType($data_ref, $username, $password) + * + * Update the attachment mime type of an attachment. The first argument is a + * data hash containing information on the new MIME type and the attachment id + * that you want to act on. + * + * $data_ref = { "attach_id" => "", # Attachment ID to perform + * MIME type change on. "mime_type" => "", # Legal MIME + * type value that you want to change the attachment to. "nomail" => 0, # + * OPTIONAL Flag that is either 1 or 0 if you want email to be sent or not for + * this change }; + * + */ +function fixAttachById(id, XMLRPCURL, type, email) { + var params = []; + + if (type === undefined) { + type = "text/plain"; + } + if (email === undefined) { + email = false; + } + + // https://bugzilla.redhat.com/\ + // docs/en/html/api/extensions/compat_xmlrpc/code/webservice.html + // test on https://bugzilla.redhat.com/show_bug.cgi?id=485145 + params.push({ + 'attach_id' : id, + 'mime_type' : type, + 'nomail' : !email + }); + + self.postMessage(new Message("MakeXMLRPCall", { + url : XMLRPCURL, + login : getLogin(), + method : "bugzilla.updateAttachMimeType", + params : params, + callRPC : "FixAttachmentMIMECallback" + })); + reqCounter++; +} + +/** + * Add a link to the bad attachment for fixing it. + * + * @param + * DOM jQuery element with a bad attachment + * @return none + */ +function addTextLink(row, xmlRpcUrl) { + var elemS = row[4].getElementsByTagName("td"); + var elem = elemS[elemS.length - 1]; + createDeadLink("addFix2TextLink", "text", elem, fixAttachById, + [ + row[1], xmlRpcUrl + ], "br"); +} diff --git a/data/rhlib/rhbzpage.js b/data/rhlib/rhbzpage.js new file mode 100644 index 0000000..752e471 --- /dev/null +++ b/data/rhlib/rhbzpage.js @@ -0,0 +1,512 @@ +// Released under the MIT/X11 license +// http://www.opensource.org/licenses/mit-license.php + +// For identification of graphics card +var manuChipStrs = [ [ "ATI Radeon", "ATI", "1002" ], + [ "ATI Mobility Radeon", "ATI", "1002" ], + [ "Intel Corporation", "INTEL", "8086" ], [ "NVIDIA", "NV", "10de" ] ]; + +// http://en.wikipedia.org/wiki/HSL_color_space +// when only the value of S is changed +// stupido!!! the string is value in hex for each color +var RHColor = new Color(158, 41, 43); // RGB 158, 41, 43; HSL 359, 1, 39 +var FedoraColor = new Color(0, 40, 103); // RGB 0, 40, 103; HSL 359, 1, 39 +var RawhideColor = new Color(0, 119, 0); // or "green", or RGB 0, 119, 0, or + // HSL +// 120, 0, 23 +var RHITColor = new Color(102, 0, 102); // RGB 102, 0, 102; HSL 300, 0, 20 + +// [ 126.386] (--) NOUVEAU(0): Chipset: "NVIDIA NVaf" +var logAnalyzeLogic = { + "AnalyzeInterestingLine": { + /* + * [ 126.378] (--) PCI:*(0:4:0:0) 10de:08a0:106b:00c2 rev 162, Mem @ + * 0xd2000000/16777216, \ 0xc0000000/268435456, 0xd0000000/33554432, I/O @ + * 0x00001000/128, BIOS @ 0x????????/131072 + */ + re: [ + "^(\\[[ .0-9]+\\])?\\s*\\(--\\) PCI:\\*\\([0-9:]+\\)\\s*" + + "([0-9a-f:]+).*$", + "^\\s*\\[?[ 0-9.]*\\]?\\s*\\(--\\) "+ + "([A-Za-z]+)\\([0-9]?\\): Chipset: (.*)$", + ], + func: chipsetMagic + }, + /* + * [ 126.385] (WW) Falling back to old probe method for vesa [ 126.385] (WW) + * Falling back to old probe method for fbdev [ 126.386] (--) NOUVEAU(0): + * Chipset: "NVIDIA NVaf" Backtrace: [ 33.158] Kernel command line: ro + * root=LABEL=root rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 + * SYSFONT=latarcyrheb-sun16 KEYTABLE=us drm.debug=0x04 + * + */ + "AnalyzeXorgLogBacktrace": { + re: "^\\s*(\\[[0-9 .]*\\])?\\s*(\\((EE|WW)\\)|.* [cC]hipset:.*)|\\s*(Backtrace|Kernel command line)", + func: analyzeXorg + } +}; + +var ProfessionalProducts = [ + "Red Hat Enterprise Linux", + "Red Hat Enterprise MRG" +]; + +// END OF CONSTANTS + +var btSnippet = null; + +function RHOnMessageHandler(msg) { + switch (msg.cmd) { + case "Error": + alert("Error " + msg.data); + break; + case "Unhandled": + break; + case "AddAttachmentCallback": + addAttachmentCallback(msg.data); + break; + case "FixAttachmentMIMECallback": + XMLRPCcallback(); + break; + case "AnalyzeInterestingLine": + case "AnalyzeXorgLogBacktrace": + findInterestingLine(msg.data, msg.cmd); + break; + case "queryUpstream": + queryUpstreamCallback(msg.data, constantData.queryUpstreamBug); + break; + default: + console.error("Error: unknown RPC call " + msg.toSource()); + break; + } +} + +// RHBugzillaPage object + +/** + * Auxiliary function to compute more complicated resolution + */ +function closeSomeRelease() { + // for RAWHIDE close as RAWHIDE, + // if active selection -> CURRENTRELEASE + // and put the release version to + // "Fixed in Version" textbox + // otherwise -> NEXTRELEASE + selectOption("bug_status", "CLOSED"); + var text = getSelection(); + var resolution = ""; + + if (text.length > 0) { + resolution = "CURRENTRELEASE"; + document.getElementById("cf_fixed_in").value = text; + } + else if (document.getElementById("version").value === "rawhide") { + resolution = "RAWHIDE"; + } + else { + resolution = "NEXTRELEASE"; + } + centralCommandDispatch("resolution", resolution); +} + +/** + * Additional commands specific for this subclass, overriding superclass one. + */ +function RHcentralCommandDispatch(cmdLabel, cmdParams) { + switch (cmdLabel) { + // Set up our own commands + case "closeUpstream": + addClosingUpstream(); + break; + case "computeResolution": + closeSomeRelease(); + break; + case "queryStringUpstreamBugzilla": + queryUpstream(constantData.queryUpstreamBug); + break; + case "sendBugUpstream": + sendBugUpstream(); + break; + case "markTriaged": + markBugTriaged(); + break; + case "chipMagic": + console.myDebug("cmdParams = " + cmdParams.toSource()); + fillInWhiteBoard(cmdParams); + break; + // If we don't have it here, call superclass method + default: + console.error("Unknown command:\n" + cmdLabel + "\nparameters:\n" + cmdParams); + break; + } +} + +/* === Bugzilla functions === */ + +/** + * Make it sailent that the some attachments with bad MIME type are present + * + * @param atts + * Array of attachments subarrays + * @return none + */ +function markBadAttachments(atts) { + var badMIMEArray = [ "application/octet-stream", "text/x-log", "undefined" ]; + if (!constantData.passwordState.passAvailable) { + console.myDebug("markBadAttachments : No password, no XML-RPC calls; sorry"); + return null; + } + + var badAttachments = atts.filter(function(att) { + return (isInList(att[2], badMIMEArray)); + }); + + if (badAttachments.length > 0) { + var titleElement = document. + getElementsByClassName("bz_alias_short_desc_container")[0]; + titleElement.style.backgroundColor = "olive"; + + createDeadLink("fixAllButton", "Fix all", titleElement, function() { + Array.forEach(badAttachments, function(x) { + fixAttachById(x[1], constantData.XMLRPCData[window.location.hostname].url); + }); + }, [], false, null, "f"); + badAttachments.forEach(function(x, i, a) { + addTextLink(x, constantData.XMLRPCData[window.location.hostname].url); + }); + } +} + +/** + * Open a tab in the upstream bugzilla to create a new bug + * + * @return none + */ +function sendBugUpstream() { + var urlStr = filterByRegexp(constantData.newUpstreamBug, getComponent()); + if (!urlStr) { + return null; + } + + self.postMessage(new Message("OpenBugUpstream", { + url: urlStr, + subject: document.getElementById("short_desc_nonedit_display"). + textContent.trim(), + comment: collectComments() + })); +} + +/** + * Add a link opening selected lines of Xorg.0.log + * + * @return none + */ +function addCheckXorgLogLink(attList) { + if (config.XorgLogAnalysis) { + attList.forEach(function (row) { + var elemS = row[4].getElementsByTagName("td"); + var elem = elemS[elemS.length - 1]; + createDeadLink("xorgLogAnalyzeLink", "check", elem, + analyzeXorgLog, [row[1], "AnalyzeXorgLogBacktrace"], "br"); + }); + } +} + +/** + * Given line to be parsed, find out which chipset it is and fill in the + * whiteboard + * + * @param PCIidArrObj + * object with two fields id Array manufacturer-ID and product-ID (PCI + * IDs) chipsetLine whole line containing PCI ID. + * @param driverStr + * String with the driver name + * @return None + * + */ +function fillInWhiteBoard(cardName) { + console.myDebug("fillInWhiteBoard: cardName = " + cardName); + clickMouse("editme_action"); + var titleElem = document.getElementById('short_desc'); + titleElem.value = '[' + cardName + ']\u00A0' + titleElem.value; + document.getElementById("fillin_btn").style.display = "none"; +} + +/** + * Get attached Xorg.0.log, parse it and find the value of chip. Does not fill + * the whiteboard itself, just adds button to do so,paramList so that slow + * XMLHttpRequest is done in advance. + * + * @param log + * array of XorgLogAttList + * @return None + */ +function fillInChipMagic(XlogID) { + analyzeXorgLog(XlogID, "AnalyzeInterestingLine"); +} + +/** + * Creates a button to change summary by adding a graphic chip label + * + * @param Array + * with matching results of re.exec() + */ +function chipsetMagic (interestingLineArr) { + // parse Xorg.0.log + var cardStr = ""; + console.myDebug("interestingLineArr = " + interestingLineArr.toSource()); + console.myDebug("interestingLineArr[1] = " + interestingLineArr[1]); + + if (interestingLineArr.length >0) { + var interestingArray = interestingLineArr[0]; + if (interestingArray.length > 1) { + var interestingPCIID = interestingArray[2].trim().split(":"); + // If we have Chipset line, we should parse it as well and + // add to the button + if (interestingLineArr.length > 1) { + var PCIid = (interestingPCIID[0] + "," + interestingPCIID[1]). + toUpperCase(); + // Nvidia driver provides good code in the Chipset line + if (interestingPCIID[0].toLowerCase() == "10de") { + cardStr = interestingLineArr[1][2]. + replace(/\s*nvidia\s*/ig,""). + replace('"','','g'); + } else { + try { + cardStr = constantData.chipNames[PCIid][0]; + } catch (e if e instanceof TypeError) { + PCIid = PCIid.toLowerCase().replace(",",":"); + cardStr = null; + alert("PCI ID " + PCIid + " is not known!"); + self.postMessage(new Message("SetClipboard", PCIid.toString())); + } catch (e) { + throw e; + } + } + } + else { + cardStr = null; + } + + if (cardStr) { + createNewButton("short_desc_nonedit_display", false, { + "name": "Fill In", + "chipMagic": cardStr + }); + } + } + } +} + +function analyzeXorg(results) { + var innerString = ""; + + if (results.length > 0) { + results.splice(0, 1); // remove headers + results.sort(); + + results.forEach(function(lRE) { + innerString += lRE.input + "
\n"; + }); + innerString += "----------
\n" + + results.length + " interesting lines found."; + } + else { + innerString += "No matching lines found!"; + } + + self.postMessage(new Message("OpenStringInPanel", + '' + + "Xorg.0.log analysis
\n" +
+    innerString.trim() +
+    "\n
")); +} + +function analyzeXorgLog(attachID, backMsg) { + self.postMessage(new Message("GetURL", { + url: "https://" + window.location.hostname + "/attachment.cgi?id=" + attachID, + backMessage: backMsg + })); +} + +function findInterestingLine(wholeLog, backMsg) { + var REstr = logAnalyzeLogic[backMsg].re; + var REarr = []; + if (typeof REstr == "string") { + REarr = [new RegExp(REstr)]; + } + else if (Array.isArray(REstr)) { + REarr = REstr.map(function (reone) { + return new RegExp(reone); + }); + } + console.myDebug("Current REs:"); + REarr.forEach(function (re) { + console.myDebug("re: " + re.source); + }); + + var results = []; + wholeLog.split("\n"). + forEach(function(line) { + REarr.forEach(function (re, reIdx) { + if (re.test(line)) { + console.myDebug("Found match on line:\n" + line); + console.myDebug("Result: " + re.exec(line).toSource()); + results.push(re.exec(line)); + } + }); + }); + console.myDebug("results = " + results.toSource()); + logAnalyzeLogic[backMsg].func(results); +} + +/** + * Add information about the upstream bug upstream, and closing it. + * + * @param evt + * Event which called this handler + * @return none + */ +function addClosingUpstream() { + var refs = document.getElementById("external_bugs_table") + .getElementsByTagName("tr"); + + // that's a bad id, if there is a one. :) + var inputBox = document.getElementById("inputbox"); + var externalBugID = 0; + var wholeURL = ""; + + // Fix missing ID on the external_id SELECT + document.getElementsByName("external_id")[0].setAttribute("id", + "external_id"); + + if (inputBox.value.match(/^http.*/)) { + externalBugID = getBugNoFromURL(inputBox.value); + if (externalBugID) { + inputBox.value = externalBugID; + } + // get bugzillaName and set the label + var bugzillaName = getBugzillaName(wholeURL.host, constantData.bugzillaLabelNames); + selectOptionByLabel("external_id", bugzillaName); + } + else if (!isNaN(inputBox.value)) { + externalBugID = parseInt(inputBox.value, 10); + var bugzillaHostname = document.getElementById("external_id").value; + wholeURL = bugzillaHostname+"show_bug.cgi?id="+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 ((externalBugID > 0) || (refs.length > 2)) { + var msgStr = constantData.commentStrings.sentUpstreamString; + msgStr = msgStr.replace("§§§", wholeURL); + centralCommandDispatch("comment",msgStr); + centralCommandDispatch("status", "CLOSED"); + centralCommandDispatch("resolution", "UPSTREAM"); + } + else { + console.myDebug("No external bug specified among the External References!"); + } +} + +/** + * + */ +function parseBacktrace (ret) { + var signalHandler = new RegExp("^\\s*#[0-9]*\\s*"); + var frameNo = new RegExp("^\\s*#([0-9]*)\\s"); + + var splitArray = ret.split("\n"); + var i = 0, ii = splitArray.length; + var outStr = "", curLine = "", numStr = ""; + var lineCounter = 0, endLineNo = 0; + + // TODO shouldn't we just cut off and analyze whole thread? + while (i < ii) { + if (signalHandler.test(splitArray[i])) { + break; + } + i++; + } + + if (i < ii) { + lineCounter = parseInt(frameNo.exec(splitArray[i])[1], 10); + endLineNo = lineCounter + NumberOfFrames; + curLine = splitArray[i]; + while ((lineCounter < endLineNo) && (curLine.trim().length > 0) + && (i < ii)) { + outStr += curLine + '\n'; + numStr = frameNo.exec(curLine); + if (numStr) { + lineCounter = parseInt(numStr[1], 10); + } + i++; + curLine = splitArray[i]; + } + return outStr; + } + return ""; +} + +function RHBZinit() { + // inheritance ... call superobject's constructor + var AbrtRE = new RegExp("^\\s*\\[abrt\\]"); + var btSnippet = ""; + + var chipMagicInterestingLine = ""; + + // getBadAttachments + var XorgLogAttList = []; + var XorgLogAttListIndex = 0; + var attachments = getAttachments(); + markBadAttachments(attachments); + + var parsedAttachments = attachments.filter(function (att) { + return (new RegExp(titleParsedAttachment).test(att[0])); + }); + + if (constantData.defaultAssignee) { + setDefaultAssignee(); + } + + if (constantData.xorgBugsCategories) { + var XBZlist = filterByRegexp(constantData. + xorgBugsCategories, getComponent()); + if (XBZlist) { + makeBugCategoriesList(XBZlist); + } + } + + // setup logging only when we ask for it + if (config.submitsLogging && (window.location.hostname == "bugzilla.redhat.com")) { + setUpLogging(); + } + + // Dig out backtrace protection against double-firing? + btSnippet = ""; + + var parseAbrtBacktraces = config.parseAbrtBacktraces; + if (parseAbrtBacktraces && AbrtRE.test(getSummary())) { + pasteBacktraceInComments(parsedAttachments); + } + + // Find out Xorg.0.log attachment URL + XorgLogAttList = attachments.filter(function (value) { + // Xorg.0.log must be text, otherwise we cannot parse it + return (/[xX].*log/.test(value[0]) && /text/.test(value[2])); + }); + // Just add a link to every Xorg.0.log link analyzing it. + addCheckXorgLogLink(XorgLogAttList); + + setBranding(XorgLogAttList); + + // Uncheck "set default assignee" when the assignee is changed by other means + document.getElementById("assigned_to").addEventListener("change", + function() { + changeAssignee(null); + }, false); +} diff --git a/data/rhlib/xorgBugCategories.js b/data/rhlib/xorgBugCategories.js new file mode 100644 index 0000000..3357ed7 --- /dev/null +++ b/data/rhlib/xorgBugCategories.js @@ -0,0 +1,74 @@ +// Released under the MIT/X11 license +// http://www.opensource.org/licenses/mit-license.php +"use strict"; + +/** + * Returns true if the bug is in a good shape + * + * @return Boolean if the bug is either not in the category where we care about + * it (i.e., we don't have set up categories for this component) or if + * it is in the concerned categories, then it has a category recorded in + * the whiteboard input box. + * + */ +function hasXorgBugsCategory() { + var catRE = /\s*\[cat:.*?\]\s*/; // RE for testing whether + // there is already category tag in the Whiteboard + + var isXOrgBug = filterByRegexp( + constantData.xorgBugsCategories, getComponent()); + var whiteboardContent = document + .getElementById("status_whiteboard").value; + + if (isXOrgBug) { // is it XOR? + return catRE.test(whiteboardContent); + } + else { + return true; + } +} + +/** + * Create a category list to the upper toolbar + */ +function makeBugCategoriesList(catList) { + var catRE = /\s*\[cat:.*?\]\s*/; // RE for testing whether + // there is already category tag in the Whiteboard + + // Create with s for each category one + if (catList) { + catList.forEach(function(cat) { + optionElement = document.createElement("option"); + optionElement.value = cat; + optionElement.setAttribute("id", "catId_" + + cat.replace(" ", "").toLowerCase()); + optionElement.appendChild(document.createTextNode(cat)); + categoryList.appendChild(optionElement); + }); + } + + categoryList.addEventListener("change", function(evt) { + var selectedCategory = "[cat:" + this.value + "]"; + var whiteboardElement = document + .getElementById("status_whiteboard"); + + if (hasXorgBugsCategory()) { + whiteboardElement.value = whiteboardElement.value.replace( + catRE, ""); + } + addStuffToTextBox("status_whiteboard", selectedCategory); + }, false); + + targetDiv.insertBefore(categoryList, targetDiv.firstChild); +} -- cgit From 272ab432ddc4562237c7235f8e0ab8a11bad3d3d Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Fri, 29 Apr 2011 01:22:18 +0200 Subject: All XML-RPC calls are rewritten as JSON-RPC ones. * also MakeJSONRPCall is a functional call now * reorganization for dealing with the history. --- data/rhlib/fixingAttMIME.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'data/rhlib') diff --git a/data/rhlib/fixingAttMIME.js b/data/rhlib/fixingAttMIME.js index 365cfae..c2adde4 100644 --- a/data/rhlib/fixingAttMIME.js +++ b/data/rhlib/fixingAttMIME.js @@ -45,8 +45,6 @@ function XMLRPCcallback() { * */ function fixAttachById(id, XMLRPCURL, type, email) { - var params = []; - if (type === undefined) { type = "text/plain"; } @@ -57,15 +55,14 @@ function fixAttachById(id, XMLRPCURL, type, email) { // https://bugzilla.redhat.com/\ // docs/en/html/api/extensions/compat_xmlrpc/code/webservice.html // test on https://bugzilla.redhat.com/show_bug.cgi?id=485145 - params.push({ + var params = { 'attach_id' : id, 'mime_type' : type, 'nomail' : !email - }); + }; - self.postMessage(new Message("MakeXMLRPCall", { - url : XMLRPCURL, - login : getLogin(), + self.postMessage(new Message("MakeJSONRPCall", { + url : XMLRPCURL.replace("xmlrpc.cgi","jsonrpc.cgi"), method : "bugzilla.updateAttachMimeType", params : params, callRPC : "FixAttachmentMIMECallback" -- cgit From da49b6460ae02a1a1f0e86aef8f541798730a18f Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Thu, 5 May 2011 12:27:10 +0200 Subject: Make my console.myDebug configurable via about:config preference. That is the Boolean variable bugzilla-triage.setting.debug --- data/rhlib/rhbzpage.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'data/rhlib') diff --git a/data/rhlib/rhbzpage.js b/data/rhlib/rhbzpage.js index 752e471..55314d5 100644 --- a/data/rhlib/rhbzpage.js +++ b/data/rhlib/rhbzpage.js @@ -131,7 +131,6 @@ function RHcentralCommandDispatch(cmdLabel, cmdParams) { markBugTriaged(); break; case "chipMagic": - console.myDebug("cmdParams = " + cmdParams.toSource()); fillInWhiteBoard(cmdParams); break; // If we don't have it here, call superclass method @@ -254,7 +253,6 @@ function fillInChipMagic(XlogID) { function chipsetMagic (interestingLineArr) { // parse Xorg.0.log var cardStr = ""; - console.myDebug("interestingLineArr = " + interestingLineArr.toSource()); console.myDebug("interestingLineArr[1] = " + interestingLineArr[1]); if (interestingLineArr.length >0) { @@ -499,6 +497,7 @@ function RHBZinit() { // Xorg.0.log must be text, otherwise we cannot parse it return (/[xX].*log/.test(value[0]) && /text/.test(value[2])); }); + // Just add a link to every Xorg.0.log link analyzing it. addCheckXorgLogLink(XorgLogAttList); -- cgit From 49feb276224dfa812339b94cfe52ea8f0ee5c491 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Thu, 5 May 2011 18:41:00 +0200 Subject: Add makeJSONRPCCallWithLogin, and other small issues. * Release 0.102 * Don't react on bugzilla.gnome.org per default * Simplify handling of preferences and debugging output. --- data/rhlib/fixingAttMIME.js | 1 + 1 file changed, 1 insertion(+) (limited to 'data/rhlib') diff --git a/data/rhlib/fixingAttMIME.js b/data/rhlib/fixingAttMIME.js index c2adde4..ada6974 100644 --- a/data/rhlib/fixingAttMIME.js +++ b/data/rhlib/fixingAttMIME.js @@ -64,6 +64,7 @@ function fixAttachById(id, XMLRPCURL, type, email) { self.postMessage(new Message("MakeJSONRPCall", { url : XMLRPCURL.replace("xmlrpc.cgi","jsonrpc.cgi"), method : "bugzilla.updateAttachMimeType", + login: getLogin(), params : params, callRPC : "FixAttachmentMIMECallback" })); -- cgit From 8e501abd49e5aeac70a84ceef96a72b5078df221 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Sat, 7 May 2011 00:53:06 +0200 Subject: Another massive cleanup and simplification of tweak scripts. bugs on bugzilla.mozilla.org now work as well, although the history is still not shown inline, which remains for 1.1. Fixes #88 --- data/rhlib/rhbzpage.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'data/rhlib') diff --git a/data/rhlib/rhbzpage.js b/data/rhlib/rhbzpage.js index 55314d5..bab9947 100644 --- a/data/rhlib/rhbzpage.js +++ b/data/rhlib/rhbzpage.js @@ -450,7 +450,7 @@ function parseBacktrace (ret) { return ""; } -function RHBZinit() { +function RHBZinit(attachments) { // inheritance ... call superobject's constructor var AbrtRE = new RegExp("^\\s*\\[abrt\\]"); var btSnippet = ""; @@ -460,7 +460,6 @@ function RHBZinit() { // getBadAttachments var XorgLogAttList = []; var XorgLogAttListIndex = 0; - var attachments = getAttachments(); markBadAttachments(attachments); var parsedAttachments = attachments.filter(function (att) { -- cgit From 83fd7fd92e5b21a177bc16cc7318792cf63a343b Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Fri, 13 May 2011 12:20:05 +0200 Subject: Really Eclipseize formatting. --- data/rhlib/fixingAttMIME.js | 22 +++---- data/rhlib/rhbzpage.js | 142 ++++++++++++++++++++-------------------- data/rhlib/xorgBugCategories.js | 4 +- 3 files changed, 84 insertions(+), 84 deletions(-) (limited to 'data/rhlib') diff --git a/data/rhlib/fixingAttMIME.js b/data/rhlib/fixingAttMIME.js index ada6974..9834cfa 100644 --- a/data/rhlib/fixingAttMIME.js +++ b/data/rhlib/fixingAttMIME.js @@ -1,11 +1,11 @@ -// Released under the MIT/X11 license -// http://www.opensource.org/licenses/mit-license.php +//Released under the MIT/X11 license +//http://www.opensource.org/licenses/mit-license.php var reqCounter = 0; // TODO should be probably a dict indexed by called method /** * Callback function for the XMLRPC request - * + * * @param ret * Object with xmlhttprequest response with attributes: + status -- int * return code + statusText + responseHeaders + responseText @@ -22,7 +22,7 @@ function XMLRPCcallback() { /** * The worker function -- call XMLRPC to fix MIME type of the particular * attachment - * + * * @param id * Integer with the attachment id to be fixed * @param type @@ -30,19 +30,19 @@ function XMLRPCcallback() { * @param email * Boolean whether email should be sent to appropriate person; option, * defaults to false - * + * * updateAttachMimeType($data_ref, $username, $password) - * + * * Update the attachment mime type of an attachment. The first argument is a * data hash containing information on the new MIME type and the attachment id * that you want to act on. - * + * * $data_ref = { "attach_id" => "", # Attachment ID to perform * MIME type change on. "mime_type" => "", # Legal MIME * type value that you want to change the attachment to. "nomail" => 0, # * OPTIONAL Flag that is either 1 or 0 if you want email to be sent or not for * this change }; - * + * */ function fixAttachById(id, XMLRPCURL, type, email) { if (type === undefined) { @@ -62,9 +62,9 @@ function fixAttachById(id, XMLRPCURL, type, email) { }; self.postMessage(new Message("MakeJSONRPCall", { - url : XMLRPCURL.replace("xmlrpc.cgi","jsonrpc.cgi"), + url : XMLRPCURL.replace("xmlrpc.cgi", "jsonrpc.cgi"), method : "bugzilla.updateAttachMimeType", - login: getLogin(), + login : getLogin(), params : params, callRPC : "FixAttachmentMIMECallback" })); @@ -73,7 +73,7 @@ function fixAttachById(id, XMLRPCURL, type, email) { /** * Add a link to the bad attachment for fixing it. - * + * * @param * DOM jQuery element with a bad attachment * @return none diff --git a/data/rhlib/rhbzpage.js b/data/rhlib/rhbzpage.js index bab9947..48a5758 100644 --- a/data/rhlib/rhbzpage.js +++ b/data/rhlib/rhbzpage.js @@ -3,8 +3,8 @@ // For identification of graphics card var manuChipStrs = [ [ "ATI Radeon", "ATI", "1002" ], - [ "ATI Mobility Radeon", "ATI", "1002" ], - [ "Intel Corporation", "INTEL", "8086" ], [ "NVIDIA", "NV", "10de" ] ]; + [ "ATI Mobility Radeon", "ATI", "1002" ], + [ "Intel Corporation", "INTEL", "8086" ], [ "NVIDIA", "NV", "10de" ] ]; // http://en.wikipedia.org/wiki/HSL_color_space // when only the value of S is changed @@ -12,44 +12,44 @@ var manuChipStrs = [ [ "ATI Radeon", "ATI", "1002" ], var RHColor = new Color(158, 41, 43); // RGB 158, 41, 43; HSL 359, 1, 39 var FedoraColor = new Color(0, 40, 103); // RGB 0, 40, 103; HSL 359, 1, 39 var RawhideColor = new Color(0, 119, 0); // or "green", or RGB 0, 119, 0, or - // HSL +// HSL // 120, 0, 23 var RHITColor = new Color(102, 0, 102); // RGB 102, 0, 102; HSL 300, 0, 20 // [ 126.386] (--) NOUVEAU(0): Chipset: "NVIDIA NVaf" var logAnalyzeLogic = { - "AnalyzeInterestingLine": { - /* - * [ 126.378] (--) PCI:*(0:4:0:0) 10de:08a0:106b:00c2 rev 162, Mem @ - * 0xd2000000/16777216, \ 0xc0000000/268435456, 0xd0000000/33554432, I/O @ - * 0x00001000/128, BIOS @ 0x????????/131072 - */ - re: [ - "^(\\[[ .0-9]+\\])?\\s*\\(--\\) PCI:\\*\\([0-9:]+\\)\\s*" + - "([0-9a-f:]+).*$", - "^\\s*\\[?[ 0-9.]*\\]?\\s*\\(--\\) "+ - "([A-Za-z]+)\\([0-9]?\\): Chipset: (.*)$", - ], - func: chipsetMagic - }, - /* - * [ 126.385] (WW) Falling back to old probe method for vesa [ 126.385] (WW) - * Falling back to old probe method for fbdev [ 126.386] (--) NOUVEAU(0): - * Chipset: "NVIDIA NVaf" Backtrace: [ 33.158] Kernel command line: ro - * root=LABEL=root rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 - * SYSFONT=latarcyrheb-sun16 KEYTABLE=us drm.debug=0x04 - * - */ - "AnalyzeXorgLogBacktrace": { - re: "^\\s*(\\[[0-9 .]*\\])?\\s*(\\((EE|WW)\\)|.* [cC]hipset:.*)|\\s*(Backtrace|Kernel command line)", - func: analyzeXorg - } + "AnalyzeInterestingLine": { + /* + * [ 126.378] (--) PCI:*(0:4:0:0) 10de:08a0:106b:00c2 rev 162, Mem @ + * 0xd2000000/16777216, \ 0xc0000000/268435456, 0xd0000000/33554432, I/O @ + * 0x00001000/128, BIOS @ 0x????????/131072 + */ + re: [ + "^(\\[[ .0-9]+\\])?\\s*\\(--\\) PCI:\\*\\([0-9:]+\\)\\s*" + + "([0-9a-f:]+).*$", + "^\\s*\\[?[ 0-9.]*\\]?\\s*\\(--\\) "+ + "([A-Za-z]+)\\([0-9]?\\): Chipset: (.*)$", + ], + func: chipsetMagic + }, + /* + * [ 126.385] (WW) Falling back to old probe method for vesa [ 126.385] (WW) + * Falling back to old probe method for fbdev [ 126.386] (--) NOUVEAU(0): + * Chipset: "NVIDIA NVaf" Backtrace: [ 33.158] Kernel command line: ro + * root=LABEL=root rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 + * SYSFONT=latarcyrheb-sun16 KEYTABLE=us drm.debug=0x04 + * + */ + "AnalyzeXorgLogBacktrace": { + re: "^\\s*(\\[[0-9 .]*\\])?\\s*(\\((EE|WW)\\)|.* [cC]hipset:.*)|\\s*(Backtrace|Kernel command line)", + func: analyzeXorg + } }; var ProfessionalProducts = [ - "Red Hat Enterprise Linux", - "Red Hat Enterprise MRG" -]; + "Red Hat Enterprise Linux", + "Red Hat Enterprise MRG" + ]; // END OF CONSTANTS @@ -77,7 +77,7 @@ function RHOnMessageHandler(msg) { break; default: console.error("Error: unknown RPC call " + msg.toSource()); - break; + break; } } @@ -133,10 +133,10 @@ function RHcentralCommandDispatch(cmdLabel, cmdParams) { case "chipMagic": fillInWhiteBoard(cmdParams); break; - // If we don't have it here, call superclass method + // If we don't have it here, call superclass method default: console.error("Unknown command:\n" + cmdLabel + "\nparameters:\n" + cmdParams); - break; + break; } } @@ -144,7 +144,7 @@ function RHcentralCommandDispatch(cmdLabel, cmdParams) { /** * Make it sailent that the some attachments with bad MIME type are present - * + * * @param atts * Array of attachments subarrays * @return none @@ -162,7 +162,7 @@ function markBadAttachments(atts) { if (badAttachments.length > 0) { var titleElement = document. - getElementsByClassName("bz_alias_short_desc_container")[0]; + getElementsByClassName("bz_alias_short_desc_container")[0]; titleElement.style.backgroundColor = "olive"; createDeadLink("fixAllButton", "Fix all", titleElement, function() { @@ -178,7 +178,7 @@ function markBadAttachments(atts) { /** * Open a tab in the upstream bugzilla to create a new bug - * + * * @return none */ function sendBugUpstream() { @@ -190,14 +190,14 @@ function sendBugUpstream() { self.postMessage(new Message("OpenBugUpstream", { url: urlStr, subject: document.getElementById("short_desc_nonedit_display"). - textContent.trim(), + textContent.trim(), comment: collectComments() })); } /** * Add a link opening selected lines of Xorg.0.log - * + * * @return none */ function addCheckXorgLogLink(attList) { @@ -214,14 +214,14 @@ function addCheckXorgLogLink(attList) { /** * Given line to be parsed, find out which chipset it is and fill in the * whiteboard - * + * * @param PCIidArrObj * object with two fields id Array manufacturer-ID and product-ID (PCI * IDs) chipsetLine whole line containing PCI ID. * @param driverStr * String with the driver name * @return None - * + * */ function fillInWhiteBoard(cardName) { console.myDebug("fillInWhiteBoard: cardName = " + cardName); @@ -235,7 +235,7 @@ function fillInWhiteBoard(cardName) { * Get attached Xorg.0.log, parse it and find the value of chip. Does not fill * the whiteboard itself, just adds button to do so,paramList so that slow * XMLHttpRequest is done in advance. - * + * * @param log * array of XorgLogAttList * @return None @@ -246,7 +246,7 @@ function fillInChipMagic(XlogID) { /** * Creates a button to change summary by adding a graphic chip label - * + * * @param Array * with matching results of re.exec() */ @@ -263,12 +263,12 @@ function chipsetMagic (interestingLineArr) { // add to the button if (interestingLineArr.length > 1) { var PCIid = (interestingPCIID[0] + "," + interestingPCIID[1]). - toUpperCase(); + toUpperCase(); // Nvidia driver provides good code in the Chipset line if (interestingPCIID[0].toLowerCase() == "10de") { cardStr = interestingLineArr[1][2]. - replace(/\s*nvidia\s*/ig,""). - replace('"','','g'); + replace(/\s*nvidia\s*/ig,""). + replace('"','','g'); } else { try { cardStr = constantData.chipNames[PCIid][0]; @@ -307,17 +307,17 @@ function analyzeXorg(results) { innerString += lRE.input + "
\n"; }); innerString += "----------
\n" + - results.length + " interesting lines found."; + results.length + " interesting lines found."; } else { innerString += "No matching lines found!"; } self.postMessage(new Message("OpenStringInPanel", - '' + - "Xorg.0.log analysis
\n" +
-    innerString.trim() +
-    "\n
")); + '' + + "Xorg.0.log analysis
\n" +
+      innerString.trim() +
+  "\n
")); } function analyzeXorgLog(attachID, backMsg) { @@ -345,29 +345,29 @@ function findInterestingLine(wholeLog, backMsg) { var results = []; wholeLog.split("\n"). - forEach(function(line) { - REarr.forEach(function (re, reIdx) { - if (re.test(line)) { - console.myDebug("Found match on line:\n" + line); - console.myDebug("Result: " + re.exec(line).toSource()); - results.push(re.exec(line)); - } - }); + forEach(function(line) { + REarr.forEach(function (re, reIdx) { + if (re.test(line)) { + console.myDebug("Found match on line:\n" + line); + console.myDebug("Result: " + re.exec(line).toSource()); + results.push(re.exec(line)); + } }); + }); console.myDebug("results = " + results.toSource()); logAnalyzeLogic[backMsg].func(results); } /** * Add information about the upstream bug upstream, and closing it. - * + * * @param evt * Event which called this handler * @return none */ function addClosingUpstream() { var refs = document.getElementById("external_bugs_table") - .getElementsByTagName("tr"); + .getElementsByTagName("tr"); // that's a bad id, if there is a one. :) var inputBox = document.getElementById("inputbox"); @@ -375,8 +375,8 @@ function addClosingUpstream() { var wholeURL = ""; // Fix missing ID on the external_id SELECT - document.getElementsByName("external_id")[0].setAttribute("id", - "external_id"); + document.getElementsByName("external_id")[0].setAttribute("id", + "external_id"); if (inputBox.value.match(/^http.*/)) { externalBugID = getBugNoFromURL(inputBox.value); @@ -412,7 +412,7 @@ function addClosingUpstream() { } /** - * + * */ function parseBacktrace (ret) { var signalHandler = new RegExp("^\\s*#[0-9]*\\s*"); @@ -463,8 +463,8 @@ function RHBZinit(attachments) { markBadAttachments(attachments); var parsedAttachments = attachments.filter(function (att) { - return (new RegExp(titleParsedAttachment).test(att[0])); - }); + return (new RegExp(titleParsedAttachment).test(att[0])); + }); if (constantData.defaultAssignee) { setDefaultAssignee(); @@ -472,7 +472,7 @@ function RHBZinit(attachments) { if (constantData.xorgBugsCategories) { var XBZlist = filterByRegexp(constantData. - xorgBugsCategories, getComponent()); + xorgBugsCategories, getComponent()); if (XBZlist) { makeBugCategoriesList(XBZlist); } @@ -504,7 +504,7 @@ function RHBZinit(attachments) { // Uncheck "set default assignee" when the assignee is changed by other means document.getElementById("assigned_to").addEventListener("change", - function() { - changeAssignee(null); - }, false); + function() { + changeAssignee(null); + }, false); } diff --git a/data/rhlib/xorgBugCategories.js b/data/rhlib/xorgBugCategories.js index 3357ed7..31f2d37 100644 --- a/data/rhlib/xorgBugCategories.js +++ b/data/rhlib/xorgBugCategories.js @@ -4,12 +4,12 @@ /** * Returns true if the bug is in a good shape - * + * * @return Boolean if the bug is either not in the category where we care about * it (i.e., we don't have set up categories for this component) or if * it is in the concerned categories, then it has a category recorded in * the whiteboard input box. - * + * */ function hasXorgBugsCategory() { var catRE = /\s*\[cat:.*?\]\s*/; // RE for testing whether -- cgit From 216ccdca63a69b99e2b0bc282c4e250fb76c3cd3 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Fri, 13 May 2011 13:18:46 +0200 Subject: Don't allow submit for 0xFFFF component. Fix #97 --- data/rhlib/rhbzpage.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'data/rhlib') diff --git a/data/rhlib/rhbzpage.js b/data/rhlib/rhbzpage.js index 48a5758..881bba9 100644 --- a/data/rhlib/rhbzpage.js +++ b/data/rhlib/rhbzpage.js @@ -502,6 +502,16 @@ function RHBZinit(attachments) { setBranding(XorgLogAttList); + // Don't allow to submit a page which would change the bug to 0xFFFF component + document.forms.namedItem("changeform").addEventListener( + "submit", function(aEvt) { + if (getComponent() == "0xFFFF") { + alert("Don't change the component to 0xFFFF"); + aEvt.stopPropagation(); + aEvt.preventDefault(); + } + }, false); + // Uncheck "set default assignee" when the assignee is changed by other means document.getElementById("assigned_to").addEventListener("change", function() { -- cgit From 831e3e73846813c09dd21b5bd9189f5720acae89 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Fri, 13 May 2011 13:40:14 +0200 Subject: Move RH BZ-related XMLRPC calls to data/rhlib/ directory. Fixes #79 --- data/rhlib/addAttachmentRow.js | 63 +++++++++++++ data/rhlib/makeBacktraceAttachment.js | 166 ++++++++++++++++++++++++++++++++++ 2 files changed, 229 insertions(+) create mode 100644 data/rhlib/addAttachmentRow.js create mode 100644 data/rhlib/makeBacktraceAttachment.js (limited to 'data/rhlib') diff --git a/data/rhlib/addAttachmentRow.js b/data/rhlib/addAttachmentRow.js new file mode 100644 index 0000000..63babcd --- /dev/null +++ b/data/rhlib/addAttachmentRow.js @@ -0,0 +1,63 @@ +//Released under the MIT/X11 license +//http://www.opensource.org/licenses/mit-license.php +"use strict"; + +//FIXME resp is JSON, not XML anymore +function addAttachmentCallback(resp) { + var newAttachID = parseInt( + resp.params.param.value.array.data.value.int, 10); + console.log("attachID = " + newAttachID); + // FIXME callback.call(param, newAttachID, data.length); +} + +/** + * + * This has to stay in RHBugzillaPage because upstream doesn't have + * addAttachment XML-RPC call yet. + * + Params: $params = { + id => '', # ID of the bug report + comment => "", # OPTIONAL Text string containing comment to add. + description => "", # REQUIRED Text Description of the attachment. + isprivate => , # OPTIONAL Whether the Attachment + will be private # Default: false + filename => "", REQUIRED The name of the file to attach to the bug report. + obsoletes => [List of attach_id's to obsolete], OPTIONAL List if attachment ids that are + obsoleted by this new attachment. + ispatch => , OPTIONAL Whether the attachment is a Patch + or not, if not provided the it will be considered NON Patch attachment. + contenttype => "", OPTIONAL If the attachment is patch + REQUIRED If the attachment is not a patch + If the attachment is patch then contenttype will always be text/plain + data => "", REQUIRED It is a base64 + encoded string of the actual attachment data. + nomail => 0, OPTIONAL Flag that is either 1 or 0 if you want email + to be send ot not for this change } + */ +function addAttachment(data, callback, param) { + var params = []; + + if (!constantData.passwordState.passAvailable) { + console + .error("addAttachment : No password, no XML-RPC calls; sorry"); + return null; + } + + var params = { + id : getBugNo(), + description : titleParsedAttachment, + filename : "parsed-backtrace.txt", + contenttype : "text/plain", + data : window.btoa(data), + nomail : true + }; + + self.postMessage(new Message("MakeJSONRPCall", { + url : constantData.XMLRPCData[window.location.hostname].url + .replace("xmlrpc.cgi", "jsonrpc.cgi"), + method : "bugzilla.addAttachment", + params : params, + callRPC : "AddAttachmentCallback" + })); + reqCounter++; +} diff --git a/data/rhlib/makeBacktraceAttachment.js b/data/rhlib/makeBacktraceAttachment.js new file mode 100644 index 0000000..9fc72bc --- /dev/null +++ b/data/rhlib/makeBacktraceAttachment.js @@ -0,0 +1,166 @@ +//Released under the MIT/X11 license +//http://www.opensource.org/licenses/mit-license.php +var titleParsedAttachment = "Part of the thread where crash happened"; + +/** + * + */ +function pasteBacktraceInComments(atts) { + /* + * Let's comment it out, and we'll see if anything breaks. TODO This paragraph + * looks suspicous ... what is it? Does it belong to this function? var + * notedLabel = document.querySelector("label[for='newcc']"); while + * (notedLabel.firstChild) { var node = + * notedLabel.removeChild(notedLabel.firstChild); + * notedLabel.parentNode.insertBefore(node, notedLabel); } + * notedLabel.parentNode.removeChild(notedLabel); + */ + + // FIXME BROKEN and its depending functions are even more broken + return null; + + var abrtQueryURL = "https://bugzilla.redhat.com/buglist.cgi?" + + "cmdtype=dorem&remaction=run&namedcmd=all%20NEW%20abrt%20crashes&" + + "sharer_id=74116"; + + var mainTitle = document + .getElementsByClassName("bz_alias_short_desc_container")[0]; + + createDeadLink("callAbrtQuery_link", "Abrt bugs", mainTitle, + abrtQueryURL, [], false, null, "a"); + + if (idContainsWord("cf_devel_whiteboard", 'btparsed')) { + addStuffToTextBox('status_whiteboard', 'btparsed'); + } + + if (!(isTriaged() + || idContainsWord("status_whiteboard", 'btparsed') || (atts.length > 0))) { + var btAttachments = atts.filter(function(att) { + return (/File: backtrace/.test(att[0])); + }); + // TODO we need to go through all backtrace attachments, but + // just the first one will do for now, we would need to do async + // + btAttachments + .forEach( + function(x) { + var attURL = "https://bugzilla.redhat.com/attachment.cgi?id=" + + x[1]; + if ((!btSnippet) && // ???? FIXME + (!idContainsWord("status_whiteboard", 'btparsed'))) { + Request({ + url : attURL, + onComplete : function(response) { + if (response.status == 200) { + btSnippet = parseBacktrace(response.text); + if (btSnippet) { + addCheckShowLink(x, btSnippet); + } + } + } + }).get(); + } + }, this); + } + // Add "show BT" links + if (parsedAttachments.length > 0) { + this.parsedAttachments.forEach(function(att) { + addShowParsedBTLink(att); + }); + } +} + +/** + * Open new window with the content of the attachment. + * + * @param id + * Number of the attachment id + * @return none + */ +function showAttachment(id) { + self.postMessage(new Message("OpenURLinPanel", "https://" + + window.location.hostname + "/attachment.cgi?id=" + id)); +} + +/** + * add a link opening a window with the parsed backtrace + * + * @param att + * Attachment object + */ +function addShowParsedBTLink(att) { + var elem = att[4].querySelector("td:last-of-type"); + createDeadLink("showParsedBacktraceWindow-" + att[1], + "showBT", elem, showAttachment, att[1], true); +} + +/** + * Unfinished ... see above FIXME BROKEN AND DOESN'T WORK + */ +function addNewAttachmentRow(origAtt, newAttId, newAttSize) { + var that = this; + var oldAddBTLink = document + .getElementById("attachBacktraceActivator"); + oldAddBTLink.parentNode.removeChild(oldAddBTLink); + var newTRElem = origAtt[4].cloneNode(true); + + // fix number of the attachment + Array.forEach(newTRElem.getElementsByTagName("a"), function( + aEl) { + aEl.setAttribute("href", aEl.getAttribute("href").replace( + origAtt[1], newAttId)); + }); + + var aElements = newTRElem.getElementsByTagName("a"); + aElements[0].setAttribute("name", "parsed-backtrace.txt"); + aElements[0].getElementsByTagName("b")[0].textContent = titleParsedAttachment; + + var sizeSpan = newTRElem + .getElementsByClassName("bz_attach_extra_info")[0]; + sizeSpan.textContent = "(" + (newAttSize / 1024).toFixed(2) + + " KB, text/plain)"; + + // aElements[1].textContent = new Date().toString(); TODO we should add + // eventually, but not pressing + + var vcardSpan = newTRElem.getElementsByClassName("vcard")[0]; + if (vcardSpan !== undefined) { + var vcardSpanClassList = vcardSpan.classList; + if (/@redhat\.com/.test(this.login) + && !vcardSpanClassList.contains("redhat_user")) { + vcardSpanClassList.add("redhat_user"); + } + var vcardAElem = vcardSpan.getElementsByTagName("a")[0]; + vcardAElem.setAttribute("title", this.login); + vcardAElem.setAttribute("href", "mailto:" + this.login); + vcardAElem.className = "email"; + vcardAElem.innerHTML = "" + this.login + + ""; + } + + var elem = newTRElem.querySelector("td:last-of-type"); + this.createDeadLink("showBacktrace", "show BT", elem, + this.showAttachment, newAttId, false); + + origAtt[4].parentNode.insertBefore(newTRElem, + origAtt[4].nextSibling); +} + +/** + * Add a link to create a new attachment with a parsed backtrace + * + * @param oldAtt + * Object with an attachment row + * @param snippet + * String with parsed backtrace + * @return none + */ +function addCheckShowLink(oldAtt, snippet) { + var elem = oldAtt[4].querySelector("td:last-of-type"); + /* + * createDeadLink("attachBacktraceActivator", "add parsed BT", elem, + * function(x) { // pass function and parameters as two separate parameters, + * the function to be called from // addAttachment addAttachment(snippet, + * addNewAttachmentRow, oldAtt); }, [], true); + */ +} -- cgit From cc0d8793eb46476b0b2f6ca39eb631d267750f18 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Sat, 14 May 2011 13:12:06 +0200 Subject: New release 0.105. * bumping the metadata * when doing makeBacktraceAttachment conditional, we could loose titleParsedAttachment, which we need in RHBZInit. Moved to rhbzpage.js --- data/rhlib/makeBacktraceAttachment.js | 1 - data/rhlib/rhbzpage.js | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) (limited to 'data/rhlib') diff --git a/data/rhlib/makeBacktraceAttachment.js b/data/rhlib/makeBacktraceAttachment.js index 9fc72bc..c0e8389 100644 --- a/data/rhlib/makeBacktraceAttachment.js +++ b/data/rhlib/makeBacktraceAttachment.js @@ -1,6 +1,5 @@ //Released under the MIT/X11 license //http://www.opensource.org/licenses/mit-license.php -var titleParsedAttachment = "Part of the thread where crash happened"; /** * diff --git a/data/rhlib/rhbzpage.js b/data/rhlib/rhbzpage.js index 881bba9..b263d98 100644 --- a/data/rhlib/rhbzpage.js +++ b/data/rhlib/rhbzpage.js @@ -15,6 +15,7 @@ var RawhideColor = new Color(0, 119, 0); // or "green", or RGB 0, 119, 0, or // HSL // 120, 0, 23 var RHITColor = new Color(102, 0, 102); // RGB 102, 0, 102; HSL 300, 0, 20 +var titleParsedAttachment = "Part of the thread where crash happened"; // [ 126.386] (--) NOUVEAU(0): Chipset: "NVIDIA NVaf" var logAnalyzeLogic = { -- cgit From 7fc98165e35fffa5011ce712bf6ab5920b62ee63 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Sat, 28 May 2011 16:57:05 +0200 Subject: Make closing bug as UPSTREAM working again. Actually, wholeURL must be initialized and wholeURL is string, not an object which would have host property). Fixes #102 --- data/rhlib/rhbzpage.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'data/rhlib') diff --git a/data/rhlib/rhbzpage.js b/data/rhlib/rhbzpage.js index b263d98..654e1dc 100644 --- a/data/rhlib/rhbzpage.js +++ b/data/rhlib/rhbzpage.js @@ -380,12 +380,16 @@ function addClosingUpstream() { "external_id"); if (inputBox.value.match(/^http.*/)) { - externalBugID = getBugNoFromURL(inputBox.value); + wholeURL = inputBox.value; + // TODO this is probably midlly ineffective ... we do parseURL here, + // and getBugNoFromURL does it as well. + externalBugID = getBugNoFromURL(wholeURL); if (externalBugID) { inputBox.value = externalBugID; } // get bugzillaName and set the label - var bugzillaName = getBugzillaName(wholeURL.host, constantData.bugzillaLabelNames); + var bugzillaName = getBugzillaName(parseURL(wholeURL).host, + constantData.bugzillaLabelNames); selectOptionByLabel("external_id", bugzillaName); } else if (!isNaN(inputBox.value)) { -- cgit From 33d482951cc12f6a9a1a9a1cd2c499692d7c2a4b Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Sat, 28 May 2011 18:02:54 +0200 Subject: Add to the upstreamed bug note about our original bug. --- data/rhlib/rhbzpage.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'data/rhlib') diff --git a/data/rhlib/rhbzpage.js b/data/rhlib/rhbzpage.js index 654e1dc..e255381 100644 --- a/data/rhlib/rhbzpage.js +++ b/data/rhlib/rhbzpage.js @@ -183,16 +183,17 @@ function markBadAttachments(atts) { * @return none */ function sendBugUpstream() { + var admitMsg = "(originally filed as " + window.location.href + ")\n\n"; var urlStr = filterByRegexp(constantData.newUpstreamBug, getComponent()); if (!urlStr) { return null; } - + self.postMessage(new Message("OpenBugUpstream", { url: urlStr, subject: document.getElementById("short_desc_nonedit_display"). textContent.trim(), - comment: collectComments() + comment: admitMsg + collectComments(); })); } -- cgit From 16b78ccadf021cc9255016ab5dac31558d28dea4 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Sat, 28 May 2011 18:18:01 +0200 Subject: There shouldn't be a semicolon after object member. --- data/rhlib/rhbzpage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'data/rhlib') diff --git a/data/rhlib/rhbzpage.js b/data/rhlib/rhbzpage.js index e255381..b9325a1 100644 --- a/data/rhlib/rhbzpage.js +++ b/data/rhlib/rhbzpage.js @@ -193,7 +193,7 @@ function sendBugUpstream() { url: urlStr, subject: document.getElementById("short_desc_nonedit_display"). textContent.trim(), - comment: admitMsg + collectComments(); + comment: admitMsg + collectComments() })); } -- cgit From 3a7b19da58572396648df1ab215228d01129aede Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Tue, 31 May 2011 01:39:46 +0200 Subject: First draft of the flags handling for Mozilla bugzilla. Will fix #103 (when reviewed) --- data/rhlib/rhbzpage.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'data/rhlib') diff --git a/data/rhlib/rhbzpage.js b/data/rhlib/rhbzpage.js index b9325a1..a130306 100644 --- a/data/rhlib/rhbzpage.js +++ b/data/rhlib/rhbzpage.js @@ -56,7 +56,8 @@ var ProfessionalProducts = [ var btSnippet = null; -function RHOnMessageHandler(msg) { + +function RHOnMessageHandler(msg, nextHandler) { switch (msg.cmd) { case "Error": alert("Error " + msg.data); @@ -77,7 +78,15 @@ function RHOnMessageHandler(msg) { queryUpstreamCallback(msg.data, constantData.queryUpstreamBug); break; default: - console.error("Error: unknown RPC call " + msg.toSource()); + if (nextHandler) { + var nextHandler = nextHandlerList.splice(0, 1); + if (nextHandler[0]) { + nextHandler[0](msg, nextHandlerList); + } + } + else { + console.error("Error: unknown RPC call " + msg.toSource()); + } break; } } @@ -136,7 +145,12 @@ function RHcentralCommandDispatch(cmdLabel, cmdParams) { break; // If we don't have it here, call superclass method default: - console.error("Unknown command:\n" + cmdLabel + "\nparameters:\n" + cmdParams); + if (MozCentralCommandDispatch) { + MozCentralCommandDispatch(cmdLabel, cmdParams); + } + else { + console.error("Unknown command:\n" + cmdLabel + "\nparameters:\n" + cmdParams); + } break; } } -- cgit From e6fc443ce7008856fc4285ae9020deeb442e04a6 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Tue, 31 May 2011 23:37:20 +0200 Subject: Fix broken subsequent calls to message handlers. Fixes #104 But really, this is whole broken, and we need to eliminate direct calls and use event handlers internally. --- data/rhlib/rhbzpage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'data/rhlib') diff --git a/data/rhlib/rhbzpage.js b/data/rhlib/rhbzpage.js index a130306..c3c36de 100644 --- a/data/rhlib/rhbzpage.js +++ b/data/rhlib/rhbzpage.js @@ -57,7 +57,7 @@ var ProfessionalProducts = [ var btSnippet = null; -function RHOnMessageHandler(msg, nextHandler) { +function RHOnMessageHandler(msg, nextHandlerList) { switch (msg.cmd) { case "Error": alert("Error " + msg.data); @@ -78,7 +78,7 @@ function RHOnMessageHandler(msg, nextHandler) { queryUpstreamCallback(msg.data, constantData.queryUpstreamBug); break; default: - if (nextHandler) { + if (nextHandlerList) { var nextHandler = nextHandlerList.splice(0, 1); if (nextHandler[0]) { nextHandler[0](msg, nextHandlerList); -- cgit From 968a1a63f8e625994b40b7d2af2d22940285c63c Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Sun, 5 Jun 2011 23:34:55 +0200 Subject: Move attachments and comments functions into four separate objects. Specifically there are objects AttachList, Attachment, Comment, and CommentList. --- data/rhlib/rhbzpage.js | 104 +++++++++++++------------------------------------ 1 file changed, 27 insertions(+), 77 deletions(-) (limited to 'data/rhlib') diff --git a/data/rhlib/rhbzpage.js b/data/rhlib/rhbzpage.js index c3c36de..121885e 100644 --- a/data/rhlib/rhbzpage.js +++ b/data/rhlib/rhbzpage.js @@ -15,7 +15,6 @@ var RawhideColor = new Color(0, 119, 0); // or "green", or RGB 0, 119, 0, or // HSL // 120, 0, 23 var RHITColor = new Color(102, 0, 102); // RGB 102, 0, 102; HSL 300, 0, 20 -var titleParsedAttachment = "Part of the thread where crash happened"; // [ 126.386] (--) NOUVEAU(0): Chipset: "NVIDIA NVaf" var logAnalyzeLogic = { @@ -55,7 +54,7 @@ var ProfessionalProducts = [ // END OF CONSTANTS var btSnippet = null; - +var localThings = null; // I don't like it, but we need to store it somewhere for now function RHOnMessageHandler(msg, nextHandlerList) { switch (msg.cmd) { @@ -157,76 +156,34 @@ function RHcentralCommandDispatch(cmdLabel, cmdParams) { /* === Bugzilla functions === */ -/** - * Make it sailent that the some attachments with bad MIME type are present - * - * @param atts - * Array of attachments subarrays - * @return none - */ -function markBadAttachments(atts) { - var badMIMEArray = [ "application/octet-stream", "text/x-log", "undefined" ]; - if (!constantData.passwordState.passAvailable) { - console.myDebug("markBadAttachments : No password, no XML-RPC calls; sorry"); - return null; - } - - var badAttachments = atts.filter(function(att) { - return (isInList(att[2], badMIMEArray)); - }); - - if (badAttachments.length > 0) { - var titleElement = document. - getElementsByClassName("bz_alias_short_desc_container")[0]; - titleElement.style.backgroundColor = "olive"; - - createDeadLink("fixAllButton", "Fix all", titleElement, function() { - Array.forEach(badAttachments, function(x) { - fixAttachById(x[1], constantData.XMLRPCData[window.location.hostname].url); - }); - }, [], false, null, "f"); - badAttachments.forEach(function(x, i, a) { - addTextLink(x, constantData.XMLRPCData[window.location.hostname].url); - }); - } -} - /** * Open a tab in the upstream bugzilla to create a new bug * * @return none */ -function sendBugUpstream() { - var admitMsg = "(originally filed as " + window.location.href + ")\n\n"; - var urlStr = filterByRegexp(constantData.newUpstreamBug, getComponent()); - if (!urlStr) { - return null; +function sendBugUpstream(thgs) { + console.myDebug("sendBugUpstream: thgs = " + thgs); + if (thgs) { + localThings = thgs; + return; } - - self.postMessage(new Message("OpenBugUpstream", { - url: urlStr, - subject: document.getElementById("short_desc_nonedit_display"). - textContent.trim(), - comment: admitMsg + collectComments() - })); -} + if (localThings) { + var admitMsg = "(originally filed as " + window.location.href + ")\n\n"; + var urlStr = filterByRegexp(constantData.newUpstreamBug, getComponent()); + if (!urlStr) { + return null; + } -/** - * Add a link opening selected lines of Xorg.0.log - * - * @return none - */ -function addCheckXorgLogLink(attList) { - if (config.XorgLogAnalysis) { - attList.forEach(function (row) { - var elemS = row[4].getElementsByTagName("td"); - var elem = elemS[elemS.length - 1]; - createDeadLink("xorgLogAnalyzeLink", "check", elem, - analyzeXorgLog, [row[1], "AnalyzeXorgLogBacktrace"], "br"); - }); + self.postMessage(new Message("OpenBugUpstream", { + url: urlStr, + subject: document.getElementById("short_desc_nonedit_display"). + textContent.trim(), + comment: admitMsg + localThings.comments.getAllCommentsText() + })); } } + /** * Given line to be parsed, find out which chipset it is and fill in the * whiteboard @@ -470,21 +427,21 @@ function parseBacktrace (ret) { return ""; } -function RHBZinit(attachments) { +function RHBZinit(things) { // inheritance ... call superobject's constructor var AbrtRE = new RegExp("^\\s*\\[abrt\\]"); var btSnippet = ""; + sendBugUpstream(things); // FIXME this is not a real call, + // just initializing static variable var chipMagicInterestingLine = ""; // getBadAttachments var XorgLogAttList = []; var XorgLogAttListIndex = 0; - markBadAttachments(attachments); + things.attachments.markBadAttachments(); - var parsedAttachments = attachments.filter(function (att) { - return (new RegExp(titleParsedAttachment).test(att[0])); - }); + var parsedAttachments = things.attachments.getParsedAttachments(); if (constantData.defaultAssignee) { setDefaultAssignee(); @@ -506,21 +463,14 @@ function RHBZinit(attachments) { // Dig out backtrace protection against double-firing? btSnippet = ""; - var parseAbrtBacktraces = config.parseAbrtBacktraces; - if (parseAbrtBacktraces && AbrtRE.test(getSummary())) { + if (config.parseAbrtBacktraces && AbrtRE.test(getSummary())) { pasteBacktraceInComments(parsedAttachments); } - // Find out Xorg.0.log attachment URL - XorgLogAttList = attachments.filter(function (value) { - // Xorg.0.log must be text, otherwise we cannot parse it - return (/[xX].*log/.test(value[0]) && /text/.test(value[2])); - }); - // Just add a link to every Xorg.0.log link analyzing it. - addCheckXorgLogLink(XorgLogAttList); + things.attachments.addCheckXorgLogLink(); - setBranding(XorgLogAttList); + setBranding(things.attachments); // Don't allow to submit a page which would change the bug to 0xFFFF component document.forms.namedItem("changeform").addEventListener( -- cgit From 2d67008193187991bb61de59597925f3b776df35 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Mon, 6 Jun 2011 13:30:49 +0200 Subject: Make fixing MIME types of attachments working again. When the Attachment is suddenly object instead of an array. --- data/rhlib/fixingAttMIME.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'data/rhlib') diff --git a/data/rhlib/fixingAttMIME.js b/data/rhlib/fixingAttMIME.js index 9834cfa..f61ddbd 100644 --- a/data/rhlib/fixingAttMIME.js +++ b/data/rhlib/fixingAttMIME.js @@ -78,11 +78,11 @@ function fixAttachById(id, XMLRPCURL, type, email) { * DOM jQuery element with a bad attachment * @return none */ -function addTextLink(row, xmlRpcUrl) { - var elemS = row[4].getElementsByTagName("td"); +function addTextLink(att, xmlRpcUrl) { + var elemS = att.element.getElementsByTagName("td"); var elem = elemS[elemS.length - 1]; createDeadLink("addFix2TextLink", "text", elem, fixAttachById, [ - row[1], xmlRpcUrl + att.id, xmlRpcUrl ], "br"); } -- cgit From bd26ab13b7d8e89eccb684f374959cfedbe51de7 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Tue, 7 Jun 2011 00:53:09 +0200 Subject: And even chip magic now works with new Attachment objects. --- data/rhlib/addAttachmentRow.js | 1 - data/rhlib/rhbzpage.js | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) (limited to 'data/rhlib') diff --git a/data/rhlib/addAttachmentRow.js b/data/rhlib/addAttachmentRow.js index 63babcd..c8724e3 100644 --- a/data/rhlib/addAttachmentRow.js +++ b/data/rhlib/addAttachmentRow.js @@ -6,7 +6,6 @@ function addAttachmentCallback(resp) { var newAttachID = parseInt( resp.params.param.value.array.data.value.int, 10); - console.log("attachID = " + newAttachID); // FIXME callback.call(param, newAttachID, data.length); } diff --git a/data/rhlib/rhbzpage.js b/data/rhlib/rhbzpage.js index 121885e..abb5c19 100644 --- a/data/rhlib/rhbzpage.js +++ b/data/rhlib/rhbzpage.js @@ -162,7 +162,6 @@ function RHcentralCommandDispatch(cmdLabel, cmdParams) { * @return none */ function sendBugUpstream(thgs) { - console.myDebug("sendBugUpstream: thgs = " + thgs); if (thgs) { localThings = thgs; return; @@ -226,7 +225,6 @@ function fillInChipMagic(XlogID) { function chipsetMagic (interestingLineArr) { // parse Xorg.0.log var cardStr = ""; - console.myDebug("interestingLineArr[1] = " + interestingLineArr[1]); if (interestingLineArr.length >0) { var interestingArray = interestingLineArr[0]; @@ -470,7 +468,7 @@ function RHBZinit(things) { // Just add a link to every Xorg.0.log link analyzing it. things.attachments.addCheckXorgLogLink(); - setBranding(things.attachments); + setBranding(things); // Don't allow to submit a page which would change the bug to 0xFFFF component document.forms.namedItem("changeform").addEventListener( -- cgit From 53cc2b746e800210382a335eacafe64b896e1b92 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Fri, 10 Jun 2011 14:17:15 +0200 Subject: Separate PCI ID components with colon not with comma. Conflicts: data/rhlib/rhbzpage.js --- data/rhlib/rhbzpage.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'data/rhlib') diff --git a/data/rhlib/rhbzpage.js b/data/rhlib/rhbzpage.js index abb5c19..d65ad8d 100644 --- a/data/rhlib/rhbzpage.js +++ b/data/rhlib/rhbzpage.js @@ -233,8 +233,9 @@ function chipsetMagic (interestingLineArr) { // If we have Chipset line, we should parse it as well and // add to the button if (interestingLineArr.length > 1) { - var PCIid = (interestingPCIID[0] + "," + interestingPCIID[1]). + var PCIid = (interestingPCIID[0] + ":" + interestingPCIID[1]). toUpperCase(); + console.myDebug("PCIid = " + PCIid); // Nvidia driver provides good code in the Chipset line if (interestingPCIID[0].toLowerCase() == "10de") { cardStr = interestingLineArr[1][2]. @@ -244,7 +245,7 @@ function chipsetMagic (interestingLineArr) { try { cardStr = constantData.chipNames[PCIid][0]; } catch (e if e instanceof TypeError) { - PCIid = PCIid.toLowerCase().replace(",",":"); + PCIid = PCIid.toLowerCase(); cardStr = null; alert("PCI ID " + PCIid + " is not known!"); self.postMessage(new Message("SetClipboard", PCIid.toString())); -- cgit From edf4594eb695d849131cf6d92ea182639b0dd499 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Fri, 10 Jun 2011 14:19:58 +0200 Subject: We should work even when interestingLineArr == 1. We shouldn't check for its length, but for the length of interestingPCIID. --- data/rhlib/rhbzpage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'data/rhlib') diff --git a/data/rhlib/rhbzpage.js b/data/rhlib/rhbzpage.js index d65ad8d..a32f7fc 100644 --- a/data/rhlib/rhbzpage.js +++ b/data/rhlib/rhbzpage.js @@ -232,7 +232,7 @@ function chipsetMagic (interestingLineArr) { var interestingPCIID = interestingArray[2].trim().split(":"); // If we have Chipset line, we should parse it as well and // add to the button - if (interestingLineArr.length > 1) { + if (interestingPCIID.length > 1) { var PCIid = (interestingPCIID[0] + ":" + interestingPCIID[1]). toUpperCase(); console.myDebug("PCIid = " + PCIid); -- cgit From 5ff3f1227c883ebaaa131665a7d75c10985ee43a Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Sat, 11 Jun 2011 02:05:42 +0200 Subject: Adding external ticket reference. Fix #106 --- data/rhlib/rhbzpage.js | 56 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 22 deletions(-) (limited to 'data/rhlib') diff --git a/data/rhlib/rhbzpage.js b/data/rhlib/rhbzpage.js index a32f7fc..99d36a2 100644 --- a/data/rhlib/rhbzpage.js +++ b/data/rhlib/rhbzpage.js @@ -142,7 +142,10 @@ function RHcentralCommandDispatch(cmdLabel, cmdParams) { case "chipMagic": fillInWhiteBoard(cmdParams); break; - // If we don't have it here, call superclass method + case "addExternalBugID": + addExternalBug(); + break; + // If we don't have it here, call superclass method default: if (MozCentralCommandDispatch) { MozCentralCommandDispatch(cmdLabel, cmdParams); @@ -331,15 +334,13 @@ function findInterestingLine(wholeLog, backMsg) { } /** - * Add information about the upstream bug upstream, and closing it. + * Add an external bug reference from the input box * - * @param evt - * Event which called this handler - * @return none + * @return String with the external bug URL or null */ -function addClosingUpstream() { +function addExternalBug() { var refs = document.getElementById("external_bugs_table") - .getElementsByTagName("tr"); + .getElementsByTagName("tr"); // that's a bad id, if there is a one. :) var inputBox = document.getElementById("inputbox"); @@ -347,8 +348,8 @@ function addClosingUpstream() { var wholeURL = ""; // Fix missing ID on the external_id SELECT - document.getElementsByName("external_id")[0].setAttribute("id", - "external_id"); + document.getElementsByName("external_id")[0]. + setAttribute("id", "external_id"); if (inputBox.value.match(/^http.*/)) { wholeURL = inputBox.value; @@ -362,29 +363,40 @@ function addClosingUpstream() { var bugzillaName = getBugzillaName(parseURL(wholeURL).host, constantData.bugzillaLabelNames); selectOptionByLabel("external_id", bugzillaName); + return wholeURL; } else if (!isNaN(inputBox.value)) { - externalBugID = parseInt(inputBox.value, 10); - var bugzillaHostname = document.getElementById("external_id").value; - wholeURL = bugzillaHostname+"show_bug.cgi?id="+externalBugID; + return document.getElementById("external_id").value + + "show_bug.cgi?id=" + parseInt(inputBox.value, 10); } else { // no inputBox.value -- maybe there is an external bug from // the previous commit? + return null; } +} - // It is not good to close bug as UPSTREAM, if there is no reference - // to the upstream bug. - if ((externalBugID > 0) || (refs.length > 2)) { - var msgStr = constantData.commentStrings.sentUpstreamString; - msgStr = msgStr.replace("§§§", wholeURL); - centralCommandDispatch("comment",msgStr); - centralCommandDispatch("status", "CLOSED"); - centralCommandDispatch("resolution", "UPSTREAM"); - } - else { +/** + * Add information about the upstream bug upstream, and closing it. + * + * @param evt + * Event which called this handler + * @return none + */ +function addClosingUpstream() { + + var newBugURL = addExternalBug(); + + if (!newBugURL) { console.myDebug("No external bug specified among the External References!"); + return null; } + + var msgStr = constantData.commentStrings.sentUpstreamString; + msgStr = msgStr.replace("§§§", newBugURL); + centralCommandDispatch("comment",msgStr); + centralCommandDispatch("status", "CLOSED"); + centralCommandDispatch("resolution", "UPSTREAM"); } /** -- cgit