aboutsummaryrefslogtreecommitdiffstats
path: root/data/rhlib/rhbzpage.js
diff options
context:
space:
mode:
Diffstat (limited to 'data/rhlib/rhbzpage.js')
-rw-r--r--data/rhlib/rhbzpage.js159
1 files changed, 61 insertions, 98 deletions
diff --git a/data/rhlib/rhbzpage.js b/data/rhlib/rhbzpage.js
index f74556c..cbd8665 100644
--- a/data/rhlib/rhbzpage.js
+++ b/data/rhlib/rhbzpage.js
@@ -55,7 +55,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) {
@@ -143,7 +143,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);
@@ -155,76 +158,35 @@ 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
- */
-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);
- });
- }
-}
+/* === Bugzilla functions === */
/**
* 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) {
+ if (thgs) {
+ localThings = thgs;
+ return;
}
+ if (localThings) {
+ 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: admitMsg + 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");
- });
+ 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
@@ -267,7 +229,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];
@@ -374,15 +335,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");
@@ -390,8 +349,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;
@@ -405,29 +364,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");
}
/**
@@ -469,21 +439,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();
@@ -505,21 +475,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);
// Don't allow to submit a page which would change the bug to 0xFFFF component
document.forms.namedItem("changeform").addEventListener(