diff options
author | Matěj Cepl <mcepl@redhat.com> | 2011-06-05 23:34:55 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2011-06-05 23:34:55 +0200 |
commit | 968a1a63f8e625994b40b7d2af2d22940285c63c (patch) | |
tree | 4e6dc4d0fd51068ccd57be9ccb2bb5e3e7de8528 /data/rhlib | |
parent | ffa6d74ddbf28c7fb7be1ad473847807d0301eac (diff) | |
download | bugzilla-triage-968a1a63f8e625994b40b7d2af2d22940285c63c.tar.gz |
Move attachments and comments functions into four separate objects.
Specifically there are objects AttachList, Attachment, Comment,
and CommentList.
Diffstat (limited to 'data/rhlib')
-rw-r--r-- | data/rhlib/rhbzpage.js | 104 |
1 files changed, 27 insertions, 77 deletions
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) { @@ -158,75 +157,33 @@ 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( |