]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1268305 - Integrate Readable Bug Status in Bug Detail Page
authorDylan Hardison <dylan@mozilla.com>
Tue, 24 May 2016 13:45:40 +0000 (09:45 -0400)
committerDylan Hardison <dylan@mozilla.com>
Tue, 24 May 2016 13:46:49 +0000 (09:46 -0400)
extensions/BugModal/Extension.pm
extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl
extensions/BugModal/template/en/default/bug_modal/header.html.tmpl
extensions/BugModal/web/bug_modal.js
js/bugzilla-readable-status-min.js [new file with mode: 0644]

index b1356bc34a96d59f5c28d120180f53c37d6305ff..f1f7fb5f09cf04ea635b7c0fb9e6afd6cb2143e0 100644 (file)
@@ -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
index 9ed5f28b7346341232286c7a0e45b3ec3be5a6fd..a0b13feec4c8ea4911a6e63c08b1b0a3edbdc5d7 100644 (file)
 [% 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"
     [%# 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">&#9656;</span>
       <div class="spin-toggle" data-latch="#product-latch" data-for="#product-info">
index e32f4c546da78334c1cb6e71d9808794ed7821bb..b86031b403ebc8eaacfd94eab5e0919081361a44 100644 (file)
@@ -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"
index 6c72eb24923990e0ec9085ca85c665138bb00169..b3b378d26505999de11a28edc7e3e190df2d561d 100644 (file)
@@ -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 (file)
index 0000000..b808a9e
--- /dev/null
@@ -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