aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-06-11 02:05:42 +0200
committerMatěj Cepl <mcepl@redhat.com>2011-06-11 02:05:42 +0200
commit5ff3f1227c883ebaaa131665a7d75c10985ee43a (patch)
treec94803e4ef783de6cbfed6e388bee6dc1b428d14
parentb7ffb79c7f7fc2c4f26d75bcf8402521352b873c (diff)
downloadbugzilla-triage-5ff3f1227c883ebaaa131665a7d75c10985ee43a.tar.gz
Adding external ticket reference.
Fix #106
-rw-r--r--data/lib/bzpage.js7
-rw-r--r--data/rhlib/rhbzpage.js56
2 files changed, 41 insertions, 22 deletions
diff --git a/data/lib/bzpage.js b/data/lib/bzpage.js
index 6b2a2f6..4401792 100644
--- a/data/lib/bzpage.js
+++ b/data/lib/bzpage.js
@@ -380,6 +380,13 @@ function startup() {
}
}
+ // Prepare for adding external bugs
+ var a0Elements = document.getElementsByName("a0");
+ if (a0Elements.length > 0) {
+ var extBugsHeadline = a0Elements[a0Elements.length - 1];
+ extBugsHeadline.setAttribute("id", "external_bugs_headline");
+ }
+
// TODO Probably could be ignored ... used only once on line 973 of
// rhbzpage.js
// if (parseAbrtBacktraces && this.RE.Abrt.test(getSummary())) {
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");
}
/**