aboutsummaryrefslogtreecommitdiffstats
path: root/data
diff options
context:
space:
mode:
Diffstat (limited to 'data')
-rw-r--r--data/bzpage.js85
-rw-r--r--data/rhbzpage.js49
-rw-r--r--data/skip-bug.js20
-rw-r--r--data/util.js86
4 files changed, 152 insertions, 88 deletions
diff --git a/data/bzpage.js b/data/bzpage.js
index b980e96..f99bc21 100644
--- a/data/bzpage.js
+++ b/data/bzpage.js
@@ -100,9 +100,10 @@ function executeCommand(cmdObj) {
* @param cmdParams Object with the appropriate parameters for the command
*/
function centralCommandDispatch (cmdLabel, cmdParams) {
- console.log("centralCommandDispatch : cmdLabel = " + cmdLabel +
- ", cmdParams = " + cmdParams);
+ console.log("centralCommandDispatch : cmdLabel = " + cmdLabel);
switch (cmdLabel) {
+ case "name":
+ break;
case "resolution":
case "product":
case "component":
@@ -231,6 +232,7 @@ function killNodes(doc, target, remove) {
* @return none
*/
function changeAssignee (newAssignee) {
+ console.log("changeAssignee : newAssignee = " + newAssignee);
var defAssigneeButton = null;
// Previous assignee should know what's going on in his bug
addToCCList(getOwner());
@@ -357,7 +359,13 @@ function createDeadLink (id, text, parent, callback, params, before, covered, ac
* @return none
*/
function createNewButton (location, after, cmdObj) {
- var newId = cmdObj.name.toLowerCase().replace(/[^a-z0-9]+/,"","g") + "_btn";
+ try {
+ var newId = cmdObj.name.toLowerCase().replace(/[^a-z0-9]+/,"","g") + "_btn";
+ } catch (e) {
+ console.log("createNewButton : e = " + e);
+ console.log("createNewButton : cmdObj.toSource() = " +
+ cmdObj.toSource());
+ }
// protection against double-firings
if (document.getElementById(newId)) {
@@ -428,24 +436,34 @@ function generateButtons (pkgs, kNodes) {
for (var pkg in pkgs) {
for (var cmdIdx in pkgs[pkg]) {
var cmdObj = pkgs[pkg][cmdIdx];
- switch (cmdObj.position) {
- case "topRow":
- createNewButton(topRowPosition, false, cmdObj);
- break;
- case "bottomRow":
- createNewButton(bottomRowPosition, false, cmdObj);
- break;
- case "dropDown":
- addToCommentsDropdown(cmdObj);
- break;
- default: // [+-]ID
- var firstChr = cmdObj.position.charAt(0);
- var newId = cmdObj.position.substr(1);
- createNewButton(newId, firstChr === "+", cmdObj);
- break;
+ if (cmdObj.position !== undefined) {
+ switch (cmdObj.position) {
+ case "topRow":
+ createNewButton(topRowPosition, false, cmdObj);
+ break;
+ case "bottomRow":
+ createNewButton(bottomRowPosition, false, cmdObj);
+ break;
+ case "dropDown":
+ addToCommentsDropdown(cmdObj);
+ break;
+ default: // [+-]ID
+ var firstChr = cmdObj.position.charAt(0);
+ var newId = cmdObj.position.substr(1);
+ createNewButton(newId, firstChr === "+", cmdObj);
+ break;
+ }
+ } else {
+ console.log("generateButtons : rejected cmdObj = " +
+ cmdObj.toSource());
}
}
}
+ // TODO This is weird in this place, but that's the place where all constantData etc.
+ // are finally defined and available.
+ if (RHBZinit) {
+ RHBZinit();
+ }
}
function setConfigurationButton () {
@@ -463,31 +481,6 @@ function setConfigurationButton () {
}, false);
}
-/*
- * From <a> element diggs out just plain email address
- * Note that bugzilla.gnome.org doesn't have mailto: url but
- * https://bugzilla.gnome.org/page.cgi?id=describeuser.html&login=mcepl%40redhat.com
- *
- * @param aElement Element with href attribute or something else
- * @return String with the address or null
- *
- */
-function parseMailto(aElement) {
- var emailStr = "", hrefStr = "";
- // use url utils
- if (aElement) {
- hrefStr = decodeURIComponent(aElement.getAttribute("href"));
- emailStr = hrefStr.split(":");
- // workaround for Gnome bugzilla ... no mailto: here.
- if (emailStr.length < 2) {
- var params = getParamsFromURL("https://" + window.location.hostname + "/" + hrefStr);
- return decodeURI(params.login);
- }
- return emailStr[1];
- }
- return null;
-}
-
/**
* Get the current title of the bug
*
@@ -757,7 +750,7 @@ function parseAttachmentLine(inElem) {
var aHref = Array.filter(aHrefsArr, function(x) {
return x.textContent.trim() === "Details";
})[0];
- var id = getParamsFromURL(aHref.getAttribute("href")).id;
+ var id = parseURL(aHref.getAttribute("href")).params.id;
// getting MIME type and size
var stringArray = inElem.getElementsByClassName("bz_attach_extra_info")[0].textContent.
@@ -1017,10 +1010,6 @@ function startup() {
location: window.location.href,
login: getLogin()
}));
-
- if (RHBZinit) {
- RHBZinit();
- }
}
startup();
diff --git a/data/rhbzpage.js b/data/rhbzpage.js
index 60dda35..fa511c7 100644
--- a/data/rhbzpage.js
+++ b/data/rhbzpage.js
@@ -78,8 +78,11 @@ function setDefaultAssignee() {
// Add setting default assignee
if ((defAss.length > 0) && (defAss !== getOwner())) {
- constantData.defaultAssigneeTrigger = true;
- createNewButton("bz_assignee_edit_container",true,"rh-common","setDefaultAssignee");
+ createNewButton("bz_assignee_edit_container",true, {
+ "name": "Def. Assignee",
+ "assignee": "default"
+ }); // TODO when this will be a production we can remove
+ // rh-common/setDefaultAssignee from RH_Data-packages.json
}
}
@@ -111,7 +114,6 @@ function closeSomeRelease() {
* Additional commands specific for this subclass, overriding superclass one.
*/
function RHcentralCommandDispatch(cmdLabel, cmdParams) {
- console.log("cmdLabel = " + cmdLabel + ", cmdParams = " + cmdParams);
switch (cmdLabel) {
// Set up our own commands
case "closeUpstream":
@@ -155,7 +157,7 @@ function addAttachment(data, callback, param) {
var params = [];
if (!constantData.passwordState.passAvailable) {
- console.log("No password, no XML-RPC calls; sorry");
+ console.log("addAttachment : No password, no XML-RPC calls; sorry");
return null;
}
@@ -341,8 +343,20 @@ function addCheckShowLink(oldAtt, snippet) {
*/
function markBadAttachments(atts) {
var badMIMEArray = [ "application/octet-stream", "text/x-log", "undefined" ];
+/* FIXME
+error: An exception occurred.
+Traceback (most recent call last):
+ File "/home/matej/archiv/2011/projekty/bugzilla-triage/data/bzpage.js", line 1005, in
+ File "/home/matej/archiv/2011/projekty/bugzilla-triage/data/bzpage.js", line 998, in startup
+ File "/home/matej/archiv/2011/projekty/bugzilla-triage/data/rhbzpage.js", line 915, in RHBZinit
+ File "/home/matej/archiv/2011/projekty/bugzilla-triage/data/rhbzpage.js", line 344, in markBadAttachments
+TypeError: "use strict";constantData.passwordState is undefined
+*/
+ // FIXME this should work
+ console.log("markBadAttachments : constantData.passwordState.toSource() = " +
+ constantData.passwordState.toSource());
if (!constantData.passwordState.passAvailable) {
- console.log("No password, no XML-RPC calls; sorry");
+ console.log("markBadAttachments : No password, no XML-RPC calls; sorry");
return null;
}
@@ -456,15 +470,13 @@ function setBranding() {
}
*/
-/* // mark suspicious components FIXME
var compElems;
- if (suspiciousComponents
- && isInList(getComponent(), suspiciousComponents)
+ if (config.suspiciousComponents
+ && isInList(getComponent(), config.suspiciousComponents)
&& (compElems = document
.getElementById("bz_component_edit_container"))) {
compElems.style.background = "red none";
}
-*/
}
/**
@@ -649,13 +661,13 @@ function fillInChipMagic(XorgLogAttList, XorgLogAttListIndex) {
interestingArray = ChipsetRE.exec(interestingLineArr[0]);
interestingLine = interestingArray[2].
replace(/[\s"]+/g," ").trim();
- // Persuade createNewButton to have mercy and to actually add
- // non-default button
- constantData.chipMagicTrigger = true;
- // FIXME packages don't exist anymore
// that.packages["rh-xorg"].chipMagic.chipMagic = interestingLine+"\t"+interestingArray[1]
// .toUpperCase();
- createNewButton("status_whiteboard", true, "rh-xorg", "chipMagic");
+ // TODO we can remove rh-common / chipMagic element from RH_Data-packages.json
+ createNewButton("status_whiteboard", true, {
+ "name": "Fill In",
+ "chipMagic": true
+ });
}
}
}
@@ -667,7 +679,7 @@ function analyzeXorgLog(attachID) {
postMessage(new Message("GetURL", {
url: "https://bugzilla.redhat.com/attachment.cgi?id=" + attachID,
backMessage: "AnalyzeXorgLogBacktrace"
- };
+ }));
}
function analyzeXorgLogBacktrace(reponseText) {
@@ -897,6 +909,7 @@ function parseBacktrace (ret) {
function RHBZinit() {
// inheritance ... call superobject's constructor
+ console.log("We are in RHBZinit");
var AbrtRE = new RegExp("^\\s*\\[abrt\\]");
var btSnippet = "";
@@ -915,7 +928,7 @@ function RHBZinit() {
var attachments = getAttachments();
markBadAttachments(attachments);
- parsedAttachments = attachments.filter(function (att) {
+ var parsedAttachments = attachments.filter(function (att) {
return (new RegExp(titleParsedAttachment).test(att[0]));
});
@@ -926,7 +939,7 @@ function RHBZinit() {
// Dig out backtrace protection against double-firing?
btSnippet = "";
- var parseAbrtBacktraces = config.gJSONData.configData.parseAbrtBacktraces;
+ var parseAbrtBacktraces = config.parseAbrtBacktraces;
if (parseAbrtBacktraces && AbrtRE.test(getSummary())) {
pasteBacktraceInComments(parsedAttachments);
}
@@ -952,7 +965,7 @@ function RHBZinit() {
*/
// Take care of signature for Fedora bugzappers
- if (config.signature.length > 0) {
+ if (config.signature && config.signature.length > 0) {
var signatureFedoraString = config.signature;
document.forms.namedItem("changeform").addEventListener("submit",
function(aEvt) {
diff --git a/data/skip-bug.js b/data/skip-bug.js
new file mode 100644
index 0000000..9fcb531
--- /dev/null
+++ b/data/skip-bug.js
@@ -0,0 +1,20 @@
+// Released under the MIT/X11 license
+// http://www.opensource.org/licenses/mit-license.php
+// "use strict";
+
+function reloadPage() {
+ var stemURL = 'https://HOSTNAME/show_bug.cgi?id=';
+ var titleElems = document.getElementsByTagName('title');
+ if (titleElems) {
+ var REArr = new RegExp('[bB]ug\\s+([0-9]+)').
+ exec(titleElems[0].textContent);
+ var hostname = document.location.hostname;
+ if (REArr) {
+ console.log("Reloading bug " + REArr[1] + "!");
+ document.location = stemURL.
+ replace('HOSTNAME',hostname) + REArr[1];
+ }
+ }
+}
+
+reloadPage();
diff --git a/data/util.js b/data/util.js
index 5e8afcc..09360a0 100644
--- a/data/util.js
+++ b/data/util.js
@@ -4,29 +4,46 @@
// http://www.opensource.org/licenses/mit-license.php
"use strict";
// ==============================================================
+
/**
- * get parameters of URL as an object (name, value)
+ * parse URL to get its parts.
+ *
+ * @param url
+ * @return object with all parsed parts of URL as properties
+ *
+ * Originally from http://james.padolsey.com/javascript/parsing-urls-with-the-dom/
+ * Copyright February 19th, 2009, James Padolsey, <license undeclared>
+ *
+ * This function creates a new anchor element and uses location
+ * properties (inherent) to get the desired URL data. Some String
+ * operations are used (to normalize results across browsers).
*/
-function getParamsFromURL (url, base) {
- if (!url || (url.toString().length === 0)) {
- throw new Error("Missing URL value!");
- }
-
- var aElem = document.createElement("a");
- aElem.href = url;
-
- var paramsArr = url.pathname.split("?");
- if (paramsArr.length === 1) {
- return {};
- }
-
- // get convert URL parameters to an Object
- var params = {}, s = [];
- paramsArr[1].split('&').forEach(function(par) {
- s = par.split('=');
- params[s[0]] = s[1];
- });
- return params;
+function parseURL(url) {
+ var a = document.createElement('a');
+ a.href = url;
+ return {
+ source: url,
+ protocol: a.protocol.replace(':',''),
+ host: a.hostname,
+ port: a.port,
+ query: a.search,
+ params: (function(){
+ var ret = {},
+ seg = a.search.replace(/^\?/,'').split('&'),
+ len = seg.length, i = 0, s;
+ for (;i<len;i++) {
+ if (!seg[i]) { continue; }
+ s = seg[i].split('=');
+ ret[s[0]] = s[1];
+ }
+ return ret;
+ })(),
+ file: (a.pathname.match(/\/([^\/?#]+)$/i) || [,''])[1],
+ hash: a.hash.replace('#',''),
+ path: a.pathname.replace(/^([^\/])/,'/$1'),
+ relative: (a.href.match(/tps?:\/\/[^\/]+(.+)/) || [,''])[1],
+ segments: a.pathname.replace(/^\//,'').split('/')
+ };
}
/**
@@ -56,12 +73,37 @@ function getBugNo() {
* @return String with the bug ID
*/
function getBugNoFromURL(url) {
- var params = getParamsFromURL(url);
+ var params = parseURL(url).params;
if (params && params.id) {
return params.id;
}
}
+/*
+ * From <a> element diggs out just plain email address
+ * Note that bugzilla.gnome.org doesn't have mailto: url but
+ * https://bugzilla.gnome.org/page.cgi?id=describeuser.html&login=mcepl%40redhat.com
+ *
+ * @param aElement Element with href attribute or something else
+ * @return String with the address or null
+ *
+ */
+function parseMailto(aElement) {
+ var emailStr = "", hrefStr = "";
+ // use url utils
+ if (aElement) {
+ hrefStr = decodeURIComponent(aElement.getAttribute("href"));
+ emailStr = hrefStr.split(":");
+ // workaround for Gnome bugzilla ... no mailto: here.
+ if (emailStr.length < 2) {
+ var params = parseURL("https://" + window.location.hostname + "/" + hrefStr).params;
+ return decodeURI(params.login);
+ }
+ return emailStr[1];
+ }
+ return null;
+}
+
/**
* format date to be in ISO format (just day part)
*