aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2010-05-26 01:24:08 +0200
committerMatěj Cepl <mcepl@redhat.com>2010-05-26 01:24:08 +0200
commit5dd666ee89fb0511148972c1f6e65ce597ede5d4 (patch)
treea7880c71bf5311d37850f6ab8eea2f616a0e1648
parent0dcce743668fb6e794e21cddef731a9401f81d11 (diff)
downloadbugzilla-triage-5dd666ee89fb0511148972c1f6e65ce597ede5d4.tar.gz
Logger object debugged.
Cleaned up CLOSED/UPSTREAM manipulation and commenting on submit: - generate upstream bug URL more sanely and no need for constantData.bugzillaIDURLs - It is now possible again to make an empty comment, which would still make bug to be submitted (only explicit Cancel avoids submit)
-rw-r--r--RH_Data-packages.json20
-rw-r--r--bugzillaBugTriage.js166
2 files changed, 80 insertions, 106 deletions
diff --git a/RH_Data-packages.json b/RH_Data-packages.json
index e1f3dc3..c9e57bc 100644
--- a/RH_Data-packages.json
+++ b/RH_Data-packages.json
@@ -229,26 +229,6 @@
"bugzilla.gnome.org": "bgo",
"bugzilla.redhat.com": "RH"
},
- "bugzillaIDURLs": [
- null,
- null,
- null,
- "https://bugzilla.gnome.org/show_bug.cgi?id=",
- null,
- null,
- "https://bugzilla.mozilla.org/show_bug.cgi?id=",
- null,
- null,
- null,
- null,
- "https://bugs.eclipse.org/bugs/show_bug.cgi?id=",
- null,
- null,
- null,
- null,
- null,
- "https://bugs.freedesktop.org/show_bug.cgi?id="
- ],
"defaultAssignee": [
{
"regexp": "xorg-x11-drv-(ati|mach.*|r128)",
diff --git a/bugzillaBugTriage.js b/bugzillaBugTriage.js
index d57adf7..dcb6130 100644
--- a/bugzillaBugTriage.js
+++ b/bugzillaBugTriage.js
@@ -15,7 +15,7 @@ var bugURL = "https://bugzilla.redhat.com/show_bug.cgi?id=";
var myStorage = jetpack.storage.simple;
// ==============================================================
-// TODO https://wiki.mozilla.org/Labs/Jetpack/JEP/24
+// https://wiki.mozilla.org/Labs/Jetpack/JEP/24
var manifest = {
settings : [
{
@@ -342,17 +342,14 @@ hlpr.getHost = function(url) {
*
*/
hlpr.getBugNo = function(url) {
- // FIXME Why not to parse URL?
// let bugNoTitle = this.doc.querySelector("#title > p").textContent.trim();
// console.log("bugNoTitle = " + bugNoTitle);
// this.bugNo = this.getBugNo(this.doc.location.toString());
-// https://bugzilla.redhat.com/show_bug.cgi?id=583826
let re = new RegExp(".*id=([0-9]+).*$");
let bugNo = null;
let reResult = re.exec(url);
if (reResult[1]) {
bugNo = reResult[1];
- console.log("this.bugNo = " + bugNo);
}
return bugNo;
};
@@ -651,11 +648,6 @@ function Logger(store, abbsMap) {
this.abbsMap = abbsMap;
};
-// FIXME we should store whole URL, not just ID (to cooperate with other bugzillas)
-// General rule: there is nothing special about bugzilla.redhat.com, so for example
-// constantData.bugzillalabelNames should be made non-RH-centric
-// and getBugzillaName should work everywhere same (even on bugzilla.mozilla.org,
-// if that makes sense?)
Logger.prototype.addLogRecord = function(that) {
let rec = {};
rec.date = new Date();
@@ -664,6 +656,8 @@ Logger.prototype.addLogRecord = function(that) {
let comment = jetpack.tabs.focused.contentWindow.prompt(
"Enter comments for this comment").trim();
if (comment.length > 0) {
+ console.log("comment = " + comment);
+ console.log("");
rec.comment = comment;
let recKey = hlpr.getISODate(rec.date) + "+" + hlpr.getHost(rec.url)
+ "+" + that.bugNo;
@@ -677,21 +671,24 @@ Logger.prototype.addLogRecord = function(that) {
}
jetpack.storage.simple.sync();
return rec;
- } else if (comment === null) {
- return null;
+ } else {
+ return comment;
}
};
Logger.prototype.getBugzillaAbbr = function(url) {
// for https://bugzilla.redhat.com/show_bug.cgi?id=579123 get RH
// for https://bugzilla.mozilla.org/show_bug.cgi?id=579123 get MoFo
- var abbr = this.abbsMap[host];
+ var abbr = this.abbsMap[hlpr.getHost(url)];
console.log("abbr = " + abbr);
return abbr;
}
Logger.prototype.timeSheetRecordsPrinter = function(body, records) {
let that = this;
+ let commentBugRE = new RegExp("[bB]ug\\s+([0-9]+)","g");
+ console.log("body = " + body);
+ console.log("records = " + records);
// sort the records into temporary array
let tmpArr = [];
@@ -709,6 +706,7 @@ Logger.prototype.timeSheetRecordsPrinter = function(body, records) {
tmpArr.forEach(function(rec) {
let x = rec[1];
let dayStr = hlpr.getISODate(x.date);
+ let host = hlpr.getHost(x.url);
let BZName = that.getBugzillaAbbr(x.url);
let bugNo = hlpr.getBugNo(x.url);
if (dayStr != currentDay) {
@@ -716,18 +714,41 @@ Logger.prototype.timeSheetRecordsPrinter = function(body, records) {
body.innerHTML += "<hr/><p><strong>" + currentDay
+ "</strong></p>";
}
+ console.log("comment = " + x.comment);
+ // replace "bug ####" with a hyperlink to the current bugzilla
+ let comment = x.comment.replace(commentBugRE,
+ "<a href='http://"+host+"/show_bug.cgi?id=$1'>$&</a>");
+ console.log("comment = " + comment);
body.innerHTML += "<p><em><a href='"
+ x.url
+ "'>Bug "
+ BZName + "/" + bugNo + ": "
+ x.title
+ "</a>"
- + " </em>\n<br/>" + x.comment + "</p>";
+ + " </em>\n<br/>" + comment + "</p>";
});
};
+/**
+ *
+ */
+Logger.prototype.createBlankPage = function (ttl, bodyBuildCB) {
+ let title = ttl || "Yet another untitled page";
+ let that = this;
+
+ let logTab = jetpack.tabs.open("about:blank");
+ jetpack.tabs.onReady(function() {
+ let otherDoc = logTab.contentDocument;
+ otherDoc.title = title;
+ otherDoc.body.innerHTML = "<h1>" + title + "</h1>";
+ bodyBuildCB.call(that, otherDoc.body);
+ logTab.focus();
+ });
+};
+
Logger.prototype.generateTimeSheet = function(body) {
let doc = body.ownerDocument;
+ console.log("doc = " + doc);
this.timeSheetRecordsPrinter(body, this.store);
};
@@ -775,6 +796,7 @@ function BZPage(doc) {
this.setUpLogging();
}
+ this.submitHandlerInstalled = false;
this.bugNo = hlpr.getBugNo(this.doc.location.toString());
this.reporter = this.getReporter();
this.product = this.getOptionValue("product");
@@ -915,7 +937,7 @@ BZPage.prototype.centralCommandDispatch = function (cmdLabel, cmdParams) {
* goes through all commands contained in it, and calls
* this.centralCommandDispatch to execute them.
*/
-BZPage.prototype.executeCommand = function (cmd) {
+BZPage.prototype.executeCommand = function(cmd) {
console.log("executeCommand / cmd = " + cmd);
let [pkg, id] = cmd.split("//");
let commentObj = this.packages[pkg][id];
@@ -1272,10 +1294,11 @@ BZPage.prototype.hasKeyword = function(str) {
*/
BZPage.prototype.getOptionValue = function(id) {
// Some special bugs don't have version for example
- try {
- return this.doc.getElementById(id).value;
- } catch (e) {
- console.error("Failed to find element with id = " + id);
+ let element = this.doc.getElementById(id);
+ if (element) {
+ return element.value;
+ } else {
+ console.log("Failed to find element with id = " + id);
return "#NA";
}
};
@@ -1394,14 +1417,22 @@ BZPage.prototype.setUpLogging = function() {
let that = this;
// logging all submits for timesheet
- this.doc.forms.namedItem("changeform").addEventListener("submit",
- function(evt) {
- if (that.log.addLogRecord(that) == null) {
+ // FIXME we should merge in functionality of RHBugzillaPage.submitCallback
+ // and actually make it working
+ // Maybe rewriting whole offline capability into a separate object?
+ if (!this.submitHandlerInstalled) {
+ console.log("Installing submit callback!");
+ this.doc.forms.namedItem("changeform").addEventListener("submit",function (evt) {
+ console.log("Submit callback!");
+ if (that.log.addLogRecord(that) === null) {
+ console.log("Avoiding submitting!");
// FIXME doesn't work ... still submitting'
evt.stopPropagation();
evt.preventDefault();
- }
+ }
}, false);
+ this.submitHandlerInstalled = true;
+ }
let generateTimeSheetUI = this.doc.createElement("li");
generateTimeSheetUI.innerHTML = "\u00A0-\u00A0<a href='#' id='generateTSButton'>"
@@ -1410,8 +1441,8 @@ BZPage.prototype.setUpLogging = function() {
this.doc.getElementById("generateTSButton").addEventListener(
"click",
function(evt) {
- that.createBlankPage.call(that, "TimeSheet",
- that.generateTimeSheet);
+ that.log.createBlankPage.call(that.log, "TimeSheet",
+ that.log.generateTimeSheet);
evt.stopPropagation();
evt.preventDefault();
}, false);
@@ -1572,12 +1603,6 @@ RHBugzillaPage = function(doc) {
this.setBranding();
this.checkComments();
- // offline-capable submit
- this.doc.forms.namedItem("changeform").addEventListener('submit',
- function(evt) {
- that.submitCallback.call(that, evt);
- }, false);
-
// TODO Get compiz bugs as well
if ((config.gJSONData.configData.PCIIDsURL
&& (config.PCI_ID_Array.length > 0))
@@ -1614,6 +1639,7 @@ RHBugzillaPage.prototype.setDefaultAssignee = function() {
this.defaultAssignee = this.getDefaultAssignee();
let defAss = this.defaultAssignee;
console.log("defAss = " + defAss);
+ console.log("owner = " + this.getOwner());
// Add setting default assignee
if ((defAss.length > 0) && (defAss !== this.getOwner())) {
@@ -1762,22 +1788,22 @@ RHBugzillaPage.prototype.serializeForm = function(form) {
return serialForm;
};
-RHBugzillaPage.prototype.submitCallback = function(evt) {
- console.log("Submit Callback!");
- if (jetpack.__parent__.navigator.onLine) {
- let serForm = this
- .serializeForm(jetpack.tabs.focused.contentWindow.document.forms
- .namedItem("changeform"));
-// console.log("serForm:\n" + serForm.toSource());
- } else {
- let serForm = this
- .serializeForm(jetpack.tabs.focused.contentWindow.document.forms
- .namedItem("changeform"));
- myStorage.forms[this.bugNo] = serForm;
- evt.stopPropagation();
- evt.preventDefault();
- }
-};
+//RHBugzillaPage.prototype.submitCallback = function(evt) {
+// console.log("Submit Callback!");
+// if (jetpack.__parent__.navigator.onLine) {
+// let serForm = this
+// .serializeForm(jetpack.tabs.focused.contentWindow.document.forms
+// .namedItem("changeform"));
+//// console.log("serForm:\n" + serForm.toSource());
+// } else {
+// let serForm = this
+// .serializeForm(jetpack.tabs.focused.contentWindow.document.forms
+// .namedItem("changeform"));
+// myStorage.forms[this.bugNo] = serForm;
+// evt.stopPropagation();
+// evt.preventDefault();
+// }
+//};
/**
*
@@ -1837,24 +1863,6 @@ RHBugzillaPage.prototype.submitCallback = function(evt) {
*/
/* Bugzilla functions. */
-/**
- *
- */
-RHBugzillaPage.prototype.createBlankPage = function (ttl, bodyBuildCB) {
- let title = ttl || "Yet another untitled page";
- let that = this;
-
- let logTab = jetpack.tabs.open("about:blank");
- jetpack.tabs.onReady(function() {
- let otherDoc = logTab.contentDocument;
- otherDoc.title = title;
- otherDoc.body.innerHTML = "<h1>" + title + "</h1>";
- bodyBuildCB.call(that, otherDoc.body);
- logTab.focus();
- });
-};
-
-
RHBugzillaPage.prototype.ProfessionalProducts = [
"Red Hat Enterprise Linux",
"Red Hat Enterprise MRG"
@@ -2353,24 +2361,6 @@ RHBugzillaPage.prototype.getBugzillaName = function(URLhostname) {
};
/**
- * Generate URL of the bug on remote bugzilla
- *
- * @param selectValue Number which is index of the bugzilla
- * in this.constantData.bugzillaIDURLs
- * @param bugID Number which is bug ID
- * @return string with the URL
- */
-RHBugzillaPage.prototype.getWholeURL = function(selectValue, bugID) {
- let returnURL = "";
- if (this.constantData.bugzillaIDURLs[selectValue]) {
- returnURL = this.constantData.bugzillaIDURLs[selectValue] + bugID;
- } else {
- returnURL = "";
- }
- return returnURL;
-};
-
-/**
* Callback function for the XMLRPC request
*
* @param ret Object with xmlhttprequest response with attributes:
@@ -2380,8 +2370,11 @@ RHBugzillaPage.prototype.getWholeURL = function(selectValue, bugID) {
* + responseText
*/
RHBugzillaPage.prototype.fixingMIMECallBack = function(data, textStatus) {
+ let that = this;
if (--this.reqCounter <= 0) {
- setTimeout(this.doc.location.reload, 1000);
+ setTimeout(function () {
+ that.doc.location.reload(true);
+ }, 1000);
}
};
@@ -2510,7 +2503,7 @@ RHBugzillaPage.prototype.addClosingUpstream = function() {
wholeURL = inputBox.value;
helpAElem.setAttribute("href", wholeURL);
let paramsArr = helpAElem.search.replace(/^\?/, '').split('&');
- // get ID#
+ // get convert URL parameters to an Object
let params = {}, s = [];
paramsArr.forEach(function(par, idx, arr) {
s = par.split('=');
@@ -2525,8 +2518,9 @@ RHBugzillaPage.prototype.addClosingUpstream = function() {
this.selectOption("external_id", bugzillaName);
} else if (!isNaN(inputBox.value)) {
externalBugID = parseInt(inputBox.value, 10);
- let bugzillaID = this.doc.getElementById("external_id").value;
- wholeURL = this.getWholeURL(bugzillaID, externalBugID);
+ let bugzillaHostname = this.doc.getElementById("external_id").value;
+ wholeURL = bugzillaHostname+"show_bug.cgi?id="+externalBugID;
+ console.log("wholeURL = " + wholeURL);
} else {
// no inputBox.value -- maybe there is an external bug from
// the previous commit?