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