diff options
Diffstat (limited to 'lib/rhbzpage.js')
-rw-r--r-- | lib/rhbzpage.js | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/lib/rhbzpage.js b/lib/rhbzpage.js index b55e44b..3ae39be 100644 --- a/lib/rhbzpage.js +++ b/lib/rhbzpage.js @@ -61,11 +61,12 @@ var RHBugzillaPage = function RHBugzillaPage(win, config) { this.chipMagicInterestingLine = ""; this.login = this.getLogin(); + this.product = this.doc.getElementById("product").value; this.maintCCAddr = null; if (this.constantData.CCmaintainer) { this.maintCCAddr = util.filterByRegexp(this.constantData.CCmaintainer, - this.component); + this.getComponent()); } var ITbutton = this.doc.getElementById("cf_issuetracker"); @@ -135,7 +136,6 @@ var RHBugzillaPage = function RHBugzillaPage(win, config) { if (compElement && (compElement.options)) { this.doc.getElementById("component").addEventListener("change", function() { - that.component = that.getOptionValue("component"); that.changeAssignee("default"); }, false); } @@ -150,6 +150,18 @@ RHBugzillaPage.prototype = util.heir(BZPage); RHBugzillaPage.prototype.constructor = RHBugzillaPage; /** + * Get login of the currently logged-in user. + * + * @return String with the login name of the currently logged-in user + */ +RHBugzillaPage.prototype.getLogin = function getLogin () { + var lastLIElement = this.doc.querySelector("#header ul.links li:last-of-type"); + var loginArr = lastLIElement.textContent.split("\n"); + var loginStr = loginArr[loginArr.length - 1].trim(); + return loginStr; +}; + +/** * Find default assignee based on the current component * * @return String what would be a default assignee if @@ -157,7 +169,7 @@ RHBugzillaPage.prototype.constructor = RHBugzillaPage; */ RHBugzillaPage.prototype.getDefaultAssignee = function() { return util.filterByRegexp(this.constantData.defaultAssignee, - this.component).toLowerCase(); + this.getComponent()).toLowerCase(); }; /** @@ -346,12 +358,7 @@ RHBugzillaPage.prototype.isEnterprise = function() { * @return Boolean whether the bug has been triaged or not */ RHBugzillaPage.prototype.isTriaged = function() { - // First excceptions - if (this.version > 7 && this.version < 12) { - return this.doc.getElementById("bug_status").value.toUpperCase() !== "NEW"; - } else { // and then the rule return this.hasKeyword("Triaged"); - } }; /** @@ -373,7 +380,7 @@ RHBugzillaPage.prototype.setBranding = function() { brandColor = this.RHColor; } } else if (new RegExp("Fedora").test(this.product)) { - if (this.version === 999) { + if (this.doc.getElementById("version").value === "rawhide") { brandColor = this.RawhideColor; } else { brandColor = this.FedoraColor; @@ -421,7 +428,7 @@ RHBugzillaPage.prototype.setBranding = function() { // mark suspicious components var compElems; if (this.suspiciousComponents - && util.isInList(this.component, this.suspiciousComponents) + && util.isInList(this.getComponent(), this.suspiciousComponents) && (compElems = this.doc .getElementById("bz_component_edit_container"))) { compElems.style.background = "red none"; @@ -436,7 +443,7 @@ RHBugzillaPage.prototype.queryUpstream = function() { if (text) { text = encodeURIComponent(text.trim()); var queryUpstreamBugsURLArray = this.constantData.queryUpstreamBug; - var urlBase = util.filterByRegexp(queryUpstreamBugsURLArray, this.component); + var urlBase = util.filterByRegexp(queryUpstreamBugsURLArray, this.getComponent()); tabs.open({ url: urlBase + text, inBackground: true, @@ -453,7 +460,7 @@ RHBugzillaPage.prototype.queryUpstream = function() { RHBugzillaPage.prototype.sendBugUpstream = function() { var that = this; var urlStr = util.filterByRegexp(JSON.parse(self.data.load("newUpstreamBug.json")), this - .getOptionValue("component")); + .getComponent()); tabs.open({ url: urlStr, |