]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1546146 - Show bug types in See Also
authorKohei Yoshino <kohei.yoshino@gmail.com>
Thu, 25 Apr 2019 21:38:08 +0000 (17:38 -0400)
committerGitHub <noreply@github.com>
Thu, 25 Apr 2019 21:38:08 +0000 (17:38 -0400)
Bugzilla/BugUrl/Bugzilla/Local.pm
Bugzilla/Template.pm
extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl
extensions/BugModal/template/en/default/bug_modal/field.html.tmpl
extensions/BugModal/web/bug_modal.css

index 73086524e2011f48b90ea33e4e280abd6ee62a52..9d3dda685257b5318a45af84c55764ba357c4584 100644 (file)
@@ -96,4 +96,9 @@ sub local_uri {
   return Bugzilla->localconfig->{urlbase} . "show_bug.cgi?id=$bug_id";
 }
 
+sub bug {
+  my ($self) = @_;
+  return Bugzilla::Bug->new({id => $self->target_bug_id, cache => 1});
+}
+
 1;
index b5affc46af24f2e6b78c2a1673fb6c8dea9844a4..cde211b9d0e4ea00df6b67e1383017b2e23d8dbe 100644 (file)
@@ -775,6 +775,14 @@ sub create {
         1
       ],
 
+      # Create a short, readable label for the given URL.
+      # e.g. https://www.mozilla.org/firefox/ -> mozilla.org/firefox
+      pretty_url => sub {
+        my ($url) = @_;
+        $url =~ s/^\s*(?:https?:\/\/(?:www\.)?)?(.+?)\/?\s*$/$1/g;
+        return $url;
+      },
+
       # In CSV, quotes are doubled, and any value containing a quote or a
       # comma is enclosed in quotes.
       # If a field starts with either "=", "+", "-" or "@", it is preceded
index 3817e80d7acc86c057e08bf476841905afce05a2..4131c2c58417306405a33a829eefdeeeb9080884 100644 (file)
 [% BLOCK bug_url_link %]
 [%
   IF !link_text.defined;
-    link_text = bug.bug_file_loc FILTER truncate(40);
+    link_text = bug.bug_file_loc FILTER pretty_url FILTER truncate(40);
   END;
 %]
-  <a href="[% bug.bug_file_loc FILTER html %]" target="_blank"
-     rel="noreferrer" title="[% bug.bug_file_loc FILTER truncate(256) FILTER html %]"
-     class="bug-url" data-safe="[% is_safe_url(bug.bug_file_loc) ? 1 : 0 %]"
-  >[% link_text FILTER html %]</a>
+  <div class="link">
+    <a href="[% bug.bug_file_loc FILTER html %]" target="_blank"
+      rel="noreferrer" title="[% bug.bug_file_loc FILTER truncate(256) FILTER html %]"
+      class="bug-url" data-safe="[% is_safe_url(bug.bug_file_loc) ? 1 : 0 %]">
+      [%~ link_text FILTER html ~%]
+    </a>
+  </div>
 [% END %]
index 6353b4a761d74086c9ae6790497370a356732a96..5d646f61ee3c37e2185869d04e8bc11e060443fb 100644 (file)
@@ -359,20 +359,38 @@ END;
 
 [%# bug-urls, currently just see-also %]
 [% BLOCK bug_urls %]
-  [% FOREACH url IN values %]
-    <div>
-      [% IF url.isa('Bugzilla::BugUrl::Bugzilla::Local') %]
-        [% url.target_bug_id FILTER bug_link(url.target_bug_id, use_alias => 1) FILTER none %]
-      [% ELSE %]
-        <a href="[% url.name FILTER html %]"
-           title="[% url.name FILTER truncate(256) FILTER html %]"
-        >[% url.name FILTER truncate(40) FILTER html %]</a>
-      [% END %]
+  [%
+    # Process internal (bug) and external links separately
+    internal_links = [];
+    external_links = [];
+    FOREACH value IN values;
+      IF value.isa('Bugzilla::BugUrl::Bugzilla::Local');
+        internal_links.push(value);
+      ELSE;
+        external_links.push(value);
+      END;
+    END;
+  %]
+
+  [% IF edit %]
+    [% FOREACH link IN internal_links %]
+      <div class="link">
+        [% link.bug.id FILTER bug_link(link.bug.id, use_alias => 1) FILTER none %]
+        <label><input type="checkbox" name="remove_see_also" value="[% link.name FILTER html %]"> Remove</label>
+      </div>
+    [% END %]
+  [% ELSE %]
+    [%# Show bugs by type %]
+    [% INCLUDE bug_list values=internal_links.pluck('bug') edit=0 %]
+  [% END %]
+
+  [% FOREACH link IN external_links %]
+    <div class="link">
+      <a href="[% link.name FILTER html %]" title="[% link.name FILTER truncate(256) FILTER html %]">
+        [%~ link.name FILTER pretty_url FILTER truncate(40) FILTER html ~%]
+      </a>
       [% IF edit %]
-          <label>
-            <input type="checkbox" name="remove_see_also" value="[% url.name FILTER html %]">
-            Remove
-          </label>
+        <label><input type="checkbox" name="remove_see_also" value="[% link.name FILTER html %]"> Remove</label>
       [% END %]
     </div>
   [% END %]
index 28e1013e9aac77b841c1b5250de1d230cae0067c..af7fce9d5220c6414408e2e27f74e81c5c5ed560 100644 (file)
@@ -137,6 +137,10 @@ a.activity-ref {
     transition: all .2s;
 }
 
+.module-subtitle .link {
+  display: inline;
+}
+
 .module-spinner[aria-expanded="true"] ~ .module-subtitle {
     opacity: 0;
 }
@@ -388,6 +392,11 @@ input[type="number"] {
 
 .field .value .bug-list .bug-type-label .icon {
   font-size: 16px;
+  vertical-align: text-bottom;
+}
+
+.field .value div.link {
+  line-height: 1.5;
 }
 
 #field-value-dependencytree {