aboutsummaryrefslogtreecommitdiffstats
path: root/data/lib
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-04-29 01:22:18 +0200
committerMatěj Cepl <mcepl@redhat.com>2011-06-05 14:51:40 +0200
commit272ab432ddc4562237c7235f8e0ab8a11bad3d3d (patch)
treefbaddbe065bb8c4a60e820894c95c2ab7d8e1a2b /data/lib
parent7b6eefcd506ec03e1db422ca6e1f4f1bb8420d1c (diff)
downloadbugzilla-triage-272ab432ddc4562237c7235f8e0ab8a11bad3d3d.tar.gz
All XML-RPC calls are rewritten as JSON-RPC ones.
* also MakeJSONRPCall is a functional call now * reorganization for dealing with the history.
Diffstat (limited to 'data/lib')
-rw-r--r--data/lib/addAttachmentRow.js32
-rw-r--r--data/lib/bzpage.js23
-rw-r--r--data/lib/util.js8
3 files changed, 42 insertions, 21 deletions
diff --git a/data/lib/addAttachmentRow.js b/data/lib/addAttachmentRow.js
index a2b67ee..3bee73a 100644
--- a/data/lib/addAttachmentRow.js
+++ b/data/lib/addAttachmentRow.js
@@ -2,6 +2,7 @@
// http://www.opensource.org/licenses/mit-license.php
"use strict";
+// FIXME resp is JSON, not XML anymore
function addAttachmentCallback(resp) {
var newAttachID = parseInt(
resp.params.param.value.array.data.value.int, 10);
@@ -13,6 +14,25 @@ function addAttachmentCallback(resp) {
*
* This has to stay in RHBugzillaPage because upstream doesn't have
* addAttachment XML-RPC call yet.
+ *
+ Params: $params = {
+ id => '<bug_id>', # ID of the bug report
+ comment => "<Attachment Comment>", # OPTIONAL Text string containing comment to add.
+ description => "<Attachment Description>", # REQUIRED Text Description of the attachment.
+ isprivate => <Private Attachment ON/OFF 1/0>, # OPTIONAL Whether the Attachment
+ will be private # Default: false
+ filename => "<Attachment Filename>", REQUIRED The name of the file to attach to the bug report.
+ obsoletes => [List of attach_id's to obsolete], OPTIONAL List if attachment ids that are
+ obsoleted by this new attachment.
+ ispatch => <Patch Attachment True/False 1/0>, OPTIONAL Whether the attachment is a Patch
+ or not, if not provided the it will be considered NON Patch attachment.
+ contenttype => "<Attachment Content Type>", OPTIONAL If the attachment is patch
+ REQUIRED If the attachment is not a patch
+ If the attachment is patch then contenttype will always be text/plain
+ data => "<Encoded String of the Attachment Data>", REQUIRED It is a base64
+ encoded string of the actual attachment data.
+ nomail => 0, OPTIONAL Flag that is either 1 or 0 if you want email
+ to be send ot not for this change }
*/
function addAttachment(data, callback, param) {
var params = [];
@@ -23,18 +43,18 @@ function addAttachment(data, callback, param) {
return null;
}
- params.push(getBugNo());
- params.push({
+ var params = {
+ id: getBugNo(),
description : titleParsedAttachment,
filename : "parsed-backtrace.txt",
contenttype : "text/plain",
data : window.btoa(data),
nomail : true
- });
+ };
- self.postMessage(new Message("MakeXMLRPCall", {
- url : constantData.XMLRPCData[window.location.hostname].url,
- login : getLogin(),
+ self.postMessage(new Message("MakeJSONRPCCall", {
+ url : constantData.XMLRPCData[window.location.hostname].url.
+ replace("xmlrpc.cgi","jsonrpc.cgi"),
method : "bugzilla.addAttachment",
params : params,
callRPC : "AddAttachmentCallback"
diff --git a/data/lib/bzpage.js b/data/lib/bzpage.js
index 9e65794..02c8e3c 100644
--- a/data/lib/bzpage.js
+++ b/data/lib/bzpage.js
@@ -43,8 +43,8 @@ onMessage = function onMessage(msg) {
case "Unhandled":
break;
default:
- if (RHOnMessageHandler) {
- RHOnMessageHandler(msg);
+ if (TweakOnMessageHandler) {
+ TweakOnMessageHandler(msg, RHOnMessageHandler);
}
else {
console.error("Error: unknown RPC call " + msg.toSource());
@@ -55,7 +55,7 @@ onMessage = function onMessage(msg) {
/**
* @param cmd
* Object with all commands to be executed
- *
+ *
* PROBLEM: according to
* https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference\
* /Statements/for...in there is no guaranteed order of execution of commands
@@ -73,7 +73,7 @@ function executeCommand(cmdObj) {
/**
* Actual execution function
- *
+ *
* @param cmdLabel
* String with the name of the command to be executed
* @param cmdParams
@@ -184,7 +184,7 @@ function centralCommandDispatch (cmdLabel, cmdParams) {
/**
* Change assignee of the bug
- *
+ *
* @param newAssignee
* String with the email address of new assigneeAElement or 'default'
* if the component's default assignee should be used. Value null
@@ -228,7 +228,7 @@ function changeAssignee (newAssignee) {
/**
* Adds new option to the 'comment_action' scroll down box
- *
+ *
* @param pkg
* String package name
* @param cmd
@@ -312,8 +312,13 @@ function generateButtons (pkgs, kNodes) {
// constantData etc.
// are finally defined and available.
if (RHBZinit) {
+ console.log("call RHBZinit!");
RHBZinit();
}
+
+ if (tweakBugzilla) {
+ tweakBugzilla(document, constantData);
+ }
}
function setConfigurationButton () {
@@ -333,7 +338,7 @@ function setConfigurationButton () {
/**
* dd
- *
+ *
* @return Element with the href attribute containng the information
*/
function getOptionTableCell(tableId, label) {
@@ -356,13 +361,13 @@ function getOptionTableCell(tableId, label) {
/**
* Parse the row with the attachment
- *
+ *
* @param DOM
* element to be parsed
* @return array with string name of the attachment, integer its id number,
* string of MIME type, integer of size in kilobytes, and the whole
* element itself
- *
+ *
* TODO error handling is missing ... it's bleee
*/
function parseAttachmentLine(inElem) {
diff --git a/data/lib/util.js b/data/lib/util.js
index be674bc..064887c 100644
--- a/data/lib/util.js
+++ b/data/lib/util.js
@@ -68,12 +68,8 @@ function parseXMLfromString (inStuff) {
* Get a bug no
*/
function getBugNo() {
- var bugNoElem = document.forms.namedItem('changeform').getElementsByName("id")[0];
- if (bugNoElem) {
- return bugNoElem.value;
- } else {
- return null;
- }
+ console.log("bugNo = " + document.getElementsByName("id")[0].value);
+ return document.getElementsByName("id")[0].value;
}
/**