From a2f2d22a11b83909de93312856eb3d4c90a68e0b Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Mon, 20 Sep 2010 18:40:34 +0200 Subject: Make showing parsed backtrace at least working * Fill always this.parsedAttachments parameter with attachments with parsed backtraces * Add a ton of Javadocs to rhbzpage methods * The window with parsed backtrace should be on the top * addNewAttachmentRow is called but made ineffective --- lib/rhbzpage.js | 63 +++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 20 deletions(-) (limited to 'lib/rhbzpage.js') diff --git a/lib/rhbzpage.js b/lib/rhbzpage.js index a3660ad..d3056f3 100644 --- a/lib/rhbzpage.js +++ b/lib/rhbzpage.js @@ -79,6 +79,13 @@ var RHBugzillaPage = function RHBugzillaPage(win, config) { this.XorgLogAttListIndex = 0; this.attachments = this.getAttachments(); this.markBadAttachments(); + + this.parsedAttachments = this.attachments.filter(function (att) { + return (new RegExp(titleParsedAttachment).test(att[0])); + }); + console.log("ourParsedAtts = " + this.parsedAttachments.toSource()); + + if (this.constantData.defaultAssignee) { this.setDefaultAssignee(); } @@ -267,7 +274,7 @@ RHBugzillaPage.prototype.addAttachment = function addAttachment(data, callback) this.reqCounter++; }; -/* Bugzilla functions. */ +/* === Bugzilla functions === */ /** * */ @@ -299,7 +306,7 @@ RHBugzillaPage.prototype.pasteBacktraceInComments = function() { } if (!(this.isTriaged() || this.idContainsWord("status_whiteboard", - 'btparsed'))) { + 'btparsed') || (this.parsedAttachments.length > 0))) { var btAttachments = this.attachments .filter(function(att, idx, arr) { return (/File: backtrace/.test(att[0])); @@ -332,21 +339,19 @@ RHBugzillaPage.prototype.pasteBacktraceInComments = function() { }, this); } // Add "show BT" links - if (this.idContainsWord("status_whiteboard", 'btparsed')) { - var ourParsedAtts = this.attachments.filter(function (att) { - return (new RegExp(titleParsedAttachment).test(att[0])); - }); - console.log("ourParsedAtts = " + ourParsedAtts.toSource()); - ourParsedAtts.forEach(function (att) { + if (this.parsedAttachments.length > 0) { + this.parsedAttachments.forEach(function (att) { that.addShowParsedBTLink(att); }, that); } }; -// FIXME opens wrong attachment id -// https://bugzilla.redhat.com/show_bug.cgi?id=571846 -// has attachment id https://bugzilla.redhat.com/attachment.cgi?id=448235 -// but this opens https://bugzilla.redhat.com/show_bug.cgi?id=571846 +/** + * Open new window with the content of the attachment. + * + * @param id Number of the attachment id + * @return none + */ RHBugzillaPage.prototype.showAttachment = function showAttachment(id) { var that = this; Request({ @@ -355,7 +360,8 @@ RHBugzillaPage.prototype.showAttachment = function showAttachment(id) { if (this.response.status == 200) { var infoWin = that.win.open("", "Check att. " + id, "width=640,height=640,status=no,location=no,"+ - "titlebar=no,scrollbars=yes,resizable=yes"); + "titlebar=no,scrollbars=yes,resizable=yes"+ + "alwaysRaised=yes"); var doc = infoWin.document; doc.body.innerHTML = "
"+
                     this.response.text + "
"; @@ -364,8 +370,12 @@ RHBugzillaPage.prototype.showAttachment = function showAttachment(id) { }).get(); }; +/** + * add a link opening a window with the parsed backtrace + * + * @param att Attachment object + */ RHBugzillaPage.prototype.addShowParsedBTLink = function addShowParsedBTLink(att) { - var elem = att[4].querySelector("td:last-of-type"); this.createDeadLink("showParsedBacktraceWindow-" + att[1], "showBT", elem, this.showAttachment, att[1], true); }; @@ -405,6 +415,7 @@ change its clone in addNewAttachmentRow to have correct values. * Unfinished ... see above */ RHBugzillaPage.prototype.addNewAttachmentRow = function addNewAttachmentRow(old) { + return null; // TODO make this working var that = this; var newTRElem = old[4].cloneNode(true); var elem = newTRElem.querySelector("td:last-of-type"); @@ -416,24 +427,27 @@ RHBugzillaPage.prototype.addNewAttachmentRow = function addNewAttachmentRow(old) }; /** + * Add a link to create a new attachment with a parsed backtrace * + * @param oldAtt Object with an attachment row + * @param snippet String with parsed backtrace + * @return none */ RHBugzillaPage.prototype.addCheckShowLink = function addCheckShowLink(oldAtt, snippet) { var that = this; var elem = oldAtt[4].querySelector("td:last-of-type"); this.createDeadLink("attachBacktraceActivator", "add parsed BT", elem, function(x) { that.addAttachment.call(that, snippet, function () { - // that.addNewAttachmentRow(oldAtt); - that.addStuffToTextBox("status_whiteboard", "btparsed"); - // TODO Doesn't work ... it gets into mid-air collision with comment about - // the new attachment. - // that.doc.forms.namedItem("changeform").submit(); + that.addNewAttachmentRow(oldAtt); }, false); }, [], true); }; /** + * Make it sailent that the some attachments with bad MIME type are present * + * @param none // TODO we should make it more functional + * @return none */ RHBugzillaPage.prototype.markBadAttachments = function() { var badMIMEArray = [ "application/octet-stream", "text/x-log", "undefined" ]; @@ -559,7 +573,9 @@ RHBugzillaPage.prototype.setBranding = function() { }; /** - * Search simple query in the upstream bugzilla appropriate for the component. + * Search simple query in the upstream bugzilla appropriate for the component + * + * @return none */ RHBugzillaPage.prototype.queryUpstream = function() { var text = this.getSelectionOrClipboard(); @@ -578,7 +594,9 @@ RHBugzillaPage.prototype.queryUpstream = function() { }; /** + * Open a tab in the upstream bugzilla to create a new bug * + * @return none */ RHBugzillaPage.prototype.sendBugUpstream = function() { var that = this; @@ -600,6 +618,11 @@ RHBugzillaPage.prototype.sendBugUpstream = function() { }); }; +/** + * Add a link opening selected lines of Xorg.0.log + * + * @return none + */ RHBugzillaPage.prototype.addCheckXorgLogLink = function addCheckXorgLogLink() { var that = this; if (this.xorglogAnalysis) { -- cgit