diff options
author | Dylan Hardison <dylan@mozilla.com> | 2016-05-24 15:45:40 +0200 |
---|---|---|
committer | Dylan Hardison <dylan@mozilla.com> | 2016-05-24 15:46:49 +0200 |
commit | 4434d09061b49fd96fcdac4210edaab4a2d83722 (patch) | |
tree | e79b286565f61c501f22abdbaa70049e7c49fe33 | |
parent | 915f99d5e169b2c2c355af762a5555ba2c0ed770 (diff) | |
download | bugzilla-4434d09061b49fd96fcdac4210edaab4a2d83722.tar.gz bugzilla-4434d09061b49fd96fcdac4210edaab4a2d83722.tar.xz |
Bug 1268305 - Integrate Readable Bug Status in Bug Detail Page
-rw-r--r-- | extensions/BugModal/Extension.pm | 31 | ||||
-rw-r--r-- | extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl | 13 | ||||
-rw-r--r-- | extensions/BugModal/template/en/default/bug_modal/header.html.tmpl | 1 | ||||
-rw-r--r-- | extensions/BugModal/web/bug_modal.js | 3 | ||||
-rw-r--r-- | js/bugzilla-readable-status-min.js | 7 |
5 files changed, 52 insertions, 3 deletions
diff --git a/extensions/BugModal/Extension.pm b/extensions/BugModal/Extension.pm index b1356bc34..f1f7fb5f0 100644 --- a/extensions/BugModal/Extension.pm +++ b/extensions/BugModal/Extension.pm @@ -20,9 +20,21 @@ use Bugzilla::User::Setting; use Bugzilla::Util qw(trick_taint datetime_from html_quote time_ago); use List::MoreUtils qw(any); use Template::Stash; +use JSON::XS qw(encode_json); +use Scalar::Util qw(blessed); our $VERSION = '1'; +use constant READABLE_BUG_STATUS_PRODUCTS => ( + 'Core', + 'Toolkit', + 'Firefox', + 'Firefox for Android', + 'Firefox for iOS', + 'Bugzilla', + 'bugzilla.mozilla.org' +); + # force skin to mozilla sub settings_after_update { my ($self, $args) = @_; @@ -190,6 +202,25 @@ sub template_before_process { vars => $vars, }); + if (any { $bug->product eq $_ } READABLE_BUG_STATUS_PRODUCTS) { + my @flags = map { { name => $_->name, status => $_->status } } @{$bug->flags}; + $vars->{readable_bug_status_json} = encode_json({ + dupe_of => $bug->dup_id, + id => $bug->id, + keywords => [ map { $_->name } @{$bug->keyword_objects} ], + priority => $bug->priority, + resolution => $bug->resolution, + status => $bug->bug_status, + flags => \@flags, + target_milestone => $bug->target_milestone, + map { $_->name => $_->bug_flag($bug->id)->value } @{$vars->{tracking_flags}}, + }); + # HTML4 attributes cannot be longer than this, so just skip it in this case. + if (length($vars->{readable_bug_status_json}) > 65536) { + delete $vars->{readable_bug_status_json}; + } + } + # bug->choices loads a lot of data that we want to lazy-load # just load the status and resolutions and perform extra checks here # upstream does these checks in the bug/fields template diff --git a/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl b/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl index 9ed5f28b7..a0b13feec 100644 --- a/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl +++ b/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl @@ -312,6 +312,13 @@ [% END %] [%# === status === %] +[% IF readable_bug_status_json %] + [% readable_bug_status_span = BLOCK -%] + [%- %]<span id="readable-bug-status" data-readable-bug-status="[% readable_bug_status_json FILTER html %]"></span> + [% END %] + + [% subtitle = [{ unfiltered = readable_bug_status_span }] %] +[% END %] [% WRAPPER bug_modal/module.html.tmpl title = "Status" @@ -321,10 +328,10 @@ [%# product %] [% can_edit_product = bug.check_can_change_field("product", 0, 1) %] [% WRAPPER bug_modal/field.html.tmpl - field = bug_fields.product - field_type = constants.FIELD_TYPE_SINGLE_SELECT + field = bug_fields.product + field_type = constants.FIELD_TYPE_SINGLE_SELECT hide_on_edit = can_edit_product - help = "describecomponents.cgi" + help = "describecomponents.cgi" %] <span class="spin-latch" id="product-latch" data-latch="#product-latch" data-for="#product-info">▸</span> <div class="spin-toggle" data-latch="#product-latch" data-for="#product-info"> diff --git a/extensions/BugModal/template/en/default/bug_modal/header.html.tmpl b/extensions/BugModal/template/en/default/bug_modal/header.html.tmpl index e32f4c546..b86031b40 100644 --- a/extensions/BugModal/template/en/default/bug_modal/header.html.tmpl +++ b/extensions/BugModal/template/en/default/bug_modal/header.html.tmpl @@ -53,6 +53,7 @@ "extensions/BugModal/web/bug_modal.js", "extensions/BugModal/web/comments.js", "extensions/BugModal/web/ZeroClipboard/ZeroClipboard.min.js", + "js/bugzilla-readable-status-min.js", "js/field.js", "js/comments.js", "js/util.js" diff --git a/extensions/BugModal/web/bug_modal.js b/extensions/BugModal/web/bug_modal.js index 6c72eb249..b3b378d26 100644 --- a/extensions/BugModal/web/bug_modal.js +++ b/extensions/BugModal/web/bug_modal.js @@ -735,6 +735,9 @@ $(function() { var other = $(that.attr('id') == 'dup_id' ? '#bottom-dup_id' : '#dup_id'); other.val(that.val()); }); + var rbs = $("#readable-bug-status"); + var rbs_text = bugzillaReadableStatus.readable(rbs.data('readable-bug-status')); + rbs.text(rbs_text); // add see-also button $('.bug-urls-btn') diff --git a/js/bugzilla-readable-status-min.js b/js/bugzilla-readable-status-min.js new file mode 100644 index 000000000..b808a9e84 --- /dev/null +++ b/js/bugzilla-readable-status-min.js @@ -0,0 +1,7 @@ +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.bugzillaReadableStatus = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ +var set_error=function(t){return{error:t}},Bug=function(t){return this.data=t,this};Bug.prototype.parse=function(){try{return this._parse()}catch(t){return set_error("CANNOT_PARSE_BUG")}},Bug.prototype._parse=function(){var t,e="",r="",s="";if("undefined"==typeof this.data.id||"undefined"==typeof this.data.status||"undefined"==typeof this.data.resolution)return set_error("NO_STRING_FOR_BUG");if(s=this.hasKeyword("regression")?"regression bug":"bug","VERIFIED"===this.data.status.toUpperCase())e=s+" has been fixed and VERIFIED",t=this.getTargetMilestone(),t&&(e+=" for Firefox "+t);else if(["CLOSED","RESOLVED"].indexOf(this.data.status.toUpperCase())>-1){if(e=s+" "+this.data.status.toUpperCase()+" as "+this.data.resolution,"DUPLICATE"===this.data.resolution.toUpperCase())return e+=" of "+this.data.dupe_of;if("FIXED"!==this.data.resolution.toUpperCase())return e;t=this.getTargetMilestone(),t&&(e+=" for Firefox "+t)}else e=this.data.status.toUpperCase()+" "+s;return this.data.triage&&"untriaged"===this.data.triage.toLowerCase()&&(e="UNTRIAGED "+e),r=this.firstAffected(),r&&(e+=" found in Firefox "+r),firstTracked=this.firstTracked(),firstTracked?e+=" which is tracked for Firefox "+firstTracked:"FIXED"!=this.data.resolution&&(e+=this.getPriority()),this.hasNeedInfo()&&(e+=" awaiting an answer on a request for information"),e},Bug.prototype.getPriority=function(){var t;switch(this.data.priority){case"--":t=" with no priority";break;case"P1":t=" which should be worked on in the current release/iteration";break;case"P2":t=" which should be worked on in the next release/iteration";break;case"P3":t=" which is a feature request";break;case"P4":t=" which is a long term backlog item";break;case"P5":t=" which will not be worked on by staff, but a patch will be accepted";break;default:t=""}return t},Bug.prototype.hasKeyword=function(t){return this.data.keywords&&this.data.keywords.indexOf(t)>-1},Bug.prototype.hasFlag=function(t,e){return this.data.flags&&this.data.flags.some(function(r,s,i){return r.name===t&&r.status===e})},Bug.prototype.hasNeedInfo=function(){return this.hasFlag("needinfo","?")},Bug.prototype.getFields=function(t){var e,r=Object.keys(this.data);return e=r.filter(function(e,r,s){return 0===e.indexOf(t)}),e.sort()},Bug.prototype.getAffectedReleases=function(){return"undefined"==typeof this.statusFlags&&(this.statusFlags=this.getFields("cf_status_firefox")),this.statusFlags.filter(function(t,e,r){return["affected"].indexOf(this.data[t])>-1},this)},Bug.prototype.firstAffected=function(){var t;return"undefined"==typeof this.statusFlags&&(this.statusFlags=this.getFields("cf_status_firefox")),t=this.getAffectedReleases(),t.length>0?t[0].split("cf_status_firefox")[1]:""},Bug.prototype.getTargetMilestone=function(){return"undefined"!=typeof this.data.target_milestone&&"---"!=this.data.target_milestone&&0===this.data.target_milestone.indexOf("mozilla")?this.data.target_milestone.slice(7):""},Bug.prototype.getTrackedReleases=function(){return"undefined"==typeof this.trackingFlags&&(this.trackingFlags=this.getFields("cf_tracking_firefox")),this.trackingFlags.filter(function(t,e,r){return["+"].indexOf(this.data[t])>-1},this)},Bug.prototype.firstTracked=function(){var t;return"undefined"==typeof this.trackingFlags&&(this.trackingFlags=this.getFields("cf_tracking_firefox")),t=this.getTrackedReleases(),t.length>0?t[0].split("cf_tracking_firefox")[1]:""},exports.readable=function(t){if(void 0===t)return set_error("NO_BUG_INFO");if(Array.isArray(t)){var e={statuses:[]};return t.forEach(function(t){var r={},s=new Bug(t),i=s.parse();"undefined"!=typeof i.error?r.error=i.error:r.status=i,r.id=s.data.id,e.statuses.push(r)}),e}var r=new Bug(t);return r.parse()}; +},{}]},{},[1])(1) +}); + + +//# sourceMappingURL=bugzilla-readable-status-min.js.map
\ No newline at end of file |