aboutsummaryrefslogtreecommitdiffstats
path: root/data
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-05-31 01:39:46 +0200
committerMatěj Cepl <mcepl@redhat.com>2011-05-31 01:44:58 +0200
commit2d8a9dabb4957ae1158ba000ee211b33bd0a81be (patch)
treeef1bddf7cae9957f8d4820cff531b62ff6ee1d21 /data
parentb21ce54137dd75f42d98b3b15178e8f0ea056a14 (diff)
downloadbugzilla-triage-2d8a9dabb4957ae1158ba000ee211b33bd0a81be.tar.gz
First draft of the flags handling for Mozilla bugzilla.
Will fix #103 (when reviewed)
Diffstat (limited to 'data')
-rw-r--r--data/lib/bzpage.js2
-rw-r--r--data/mozlib/mozpage.js73
-rw-r--r--data/rhlib/rhbzpage.js20
-rw-r--r--data/tweaks/bug-page-mod.js7
4 files changed, 96 insertions, 6 deletions
diff --git a/data/lib/bzpage.js b/data/lib/bzpage.js
index aa496cf..c1898eb 100644
--- a/data/lib/bzpage.js
+++ b/data/lib/bzpage.js
@@ -45,7 +45,7 @@ self.on('message', function onMessage(msg) {
break;
default:
if (TweakOnMessageHandler) {
- TweakOnMessageHandler(msg, RHOnMessageHandler);
+ TweakOnMessageHandler(msg, [RHOnMessageHandler, MozOnMessageHandler]);
}
else {
console.error("Error: unknown RPC call " + msg.toSource());
diff --git a/data/mozlib/mozpage.js b/data/mozlib/mozpage.js
new file mode 100644
index 0000000..51af8b5
--- /dev/null
+++ b/data/mozlib/mozpage.js
@@ -0,0 +1,73 @@
+// Released under the MIT/X11 license
+// http://www.opensource.org/licenses/mit-license.php
+
+
+// END OF CONSTANTS
+
+var btSnippet = null;
+
+function MozOnMessageHandler(msg, nextHandler) {
+ switch (msg.cmd) {
+ case "Error":
+ alert("Error " + msg.data);
+ break;
+ case "Unhandled":
+ break;
+ default:
+ if (nextHandler) {
+ var nextHandler = nextHandlerList.splice(0, 1);
+ if (nextHandler[0]) {
+ nextHandler[0](msg, nextHandlerList);
+ }
+ }
+ else {
+ console.error("Error: unknown RPC call " + msg.toSource());
+ }
+ break;
+ }
+}
+
+// MozBugzillaPage object
+function collectFlags() {
+ var flags = {};
+ var tdColumn2 = document.getElementById("bz_show_bug_column_2");
+ var flag_selects = tdColumn2.querySelectorAll("td.field_value select");
+ Array.forEach(flag_selects, function(sel) {
+ var label = tdColumn2.querySelector("label[for='" + sel.id + "']");
+ if (label) {
+ var key = label.textContent.trim().replace(/\s*:?$/,"");
+ flags[key] = sel.id;
+ }
+ });
+ return flags;
+}
+
+function changeFlag(flags, label, newValue) {
+ selectOption(flags[label], newValue);
+}
+
+/**
+ * Additional commands specific for this subclass, overriding superclass one.
+ */
+function MozCentralCommandDispatch(cmdLabel, cmdParams) {
+ switch (cmdLabel) {
+ // Set up our own commands
+ case "setFlag":
+ changeFlag(mozFlags, cmdParams, "+");
+ break;
+ case "unsetFlag":
+ changeFlag(mozFlags, cmdParams, "-");
+ break;
+ case "clearFlag":
+ changeFlag(mozFlags, cmdParams, "---");
+ break;
+ // FIXME what is the meaning of value == "?"
+ default:
+ console.error("Unknown command:\n" + cmdLabel + "\nparameters:\n" + cmdParams);
+ break;
+ }
+}
+
+
+var mozFlags = collectFlags();
+console.log("mozFlags = " + mozFlags.toSource());
diff --git a/data/rhlib/rhbzpage.js b/data/rhlib/rhbzpage.js
index a943eee..7060a37 100644
--- a/data/rhlib/rhbzpage.js
+++ b/data/rhlib/rhbzpage.js
@@ -56,7 +56,8 @@ var ProfessionalProducts = [
var btSnippet = null;
-function RHOnMessageHandler(msg) {
+
+function RHOnMessageHandler(msg, nextHandler) {
switch (msg.cmd) {
case "Error":
alert("Error " + msg.data);
@@ -77,7 +78,15 @@ function RHOnMessageHandler(msg) {
queryUpstreamCallback(msg.data, constantData.queryUpstreamBug);
break;
default:
- console.error("Error: unknown RPC call " + msg.toSource());
+ if (nextHandler) {
+ var nextHandler = nextHandlerList.splice(0, 1);
+ if (nextHandler[0]) {
+ nextHandler[0](msg, nextHandlerList);
+ }
+ }
+ else {
+ console.error("Error: unknown RPC call " + msg.toSource());
+ }
break;
}
}
@@ -136,7 +145,12 @@ function RHcentralCommandDispatch(cmdLabel, cmdParams) {
break;
// If we don't have it here, call superclass method
default:
- console.error("Unknown command:\n" + cmdLabel + "\nparameters:\n" + cmdParams);
+ if (MozCentralCommandDispatch) {
+ MozCentralCommandDispatch(cmdLabel, cmdParams);
+ }
+ else {
+ console.error("Unknown command:\n" + cmdLabel + "\nparameters:\n" + cmdParams);
+ }
break;
}
}
diff --git a/data/tweaks/bug-page-mod.js b/data/tweaks/bug-page-mod.js
index 13d73ac..20f16ea 100644
--- a/data/tweaks/bug-page-mod.js
+++ b/data/tweaks/bug-page-mod.js
@@ -33,7 +33,7 @@
* ***** END LICENSE BLOCK *****
*/
-function TweakOnMessageHandler(msg, nextHandler) {
+function TweakOnMessageHandler(msg, nextHandlerList) {
switch (msg.cmd) {
case "Unhandled":
break;
@@ -42,7 +42,10 @@ function TweakOnMessageHandler(msg, nextHandler) {
break;
default:
if (nextHandler) {
- nextHandler(msg);
+ var nextHandler = nextHandlerList.splice(0, 1);
+ if (nextHandler[0]) {
+ nextHandler[0](msg, nextHandlerList);
+ }
}
else {
console.error("Error: unknown RPC call " + msg.toSource());