]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1535723 - Don't show inline attachments for bugs that have the keywords "hang...
authorKohei Yoshino <kohei.yoshino@gmail.com>
Fri, 29 Mar 2019 07:42:45 +0000 (03:42 -0400)
committerGitHub <noreply@github.com>
Fri, 29 Mar 2019 07:42:45 +0000 (03:42 -0400)
extensions/BugModal/template/en/default/bug_modal/activity_stream.html.tmpl
extensions/BugModal/template/en/default/bug_modal/header.html.tmpl
extensions/BugModal/web/bug_modal.css
extensions/BugModal/web/comments.js

index b66188e6687ac726424194d9cf3396ccd603ccb6..2d32d0652ada68e03b9982fa8a23fe61ab1b298d 100644 (file)
@@ -94,7 +94,8 @@
 [% END %]
 
 [% BLOCK comment_header %]
-  <div class="comment" data-id="[% comment.id FILTER none %]" data-no="[% comment.count FILTER none %]">
+  <div class="comment" data-id="[% comment.id FILTER none %]" data-no="[% comment.count FILTER none %]"
+       data-tags="[% comment.tags.join(' ') FILTER html %]">
     [%# normal comment header %]
     <table class="layout-table change-head [% extra_class FILTER none %]" id="ch-[% comment.count FILTER none %]"
       [% IF comment.collapsed +%] style="display:none"[% END %]>
index cbc3acd5b472580ff6f64ed319ff2f642c90d246..9f87922eae3c9a71d62bfab7c8934925a1b31f79 100644 (file)
@@ -92,6 +92,7 @@
   BUGZILLA.bug_title = '[% unfiltered_title FILTER js %]';
   BUGZILLA.bug_summary = '[% bug.short_desc FILTER js %]';
   BUGZILLA.bug_url = '[% Bugzilla.localconfig.canonical_urlbase _ "show_bug.cgi?id=" _ bug.id FILTER js %]';
+  BUGZILLA.bug_keywords = '[% bug.keywords FILTER js %]',
   BUGZILLA.user = {
     id: [% user.id FILTER none %],
     login: '[% user.login FILTER js %]',
index 79e5deab2dcce264eaa7fcc9ce19b141f36277e5..cf9315f49fbe81cd0e2df02d4d5b7041b93ea368 100644 (file)
@@ -802,10 +802,6 @@ h3.change-name {
     max-width: 426px;
 }
 
-.change-set .attachment [content="image/svg+xml"] ~ .outer img {
-    width: 426px;
-}
-
 .change-set .attachment pre {
     position: relative;
     overflow: hidden;
index 8ce5eaa6ce21071a2e734eedd1ef1bafb350bd0f..38dcfb73ae3c475ebc7befbadbfaba39b4621e40 100644 (file)
@@ -320,6 +320,7 @@ $(function() {
             root.append(span);
         });
         $('#ctag-' + commentNo + ' .comment-tags').append($('#ctag-error'));
+        $(`.comment[data-no="${commentNo}"]`).attr('data-tags', tags.join(' '));
     }
 
     var refreshXHR;
@@ -522,9 +523,10 @@ Bugzilla.BugModal.Comments = class Comments {
    * @see https://developer.mozilla.org/en-US/docs/Web/API/Network_Information_API
    */
   prepare_inline_attachments() {
-    // Check the user setting, API support and connectivity
-    if (!BUGZILLA.user.settings.inline_attachments || typeof IntersectionObserver !== 'function' ||
-        (navigator.connection && navigator.connection.type === 'cellular')) {
+    // Check the connectivity, API support, user setting and sensitive keywords
+    if ((navigator.connection && navigator.connection.type === 'cellular') ||
+        typeof IntersectionObserver !== 'function' || !BUGZILLA.user.settings.inline_attachments ||
+        BUGZILLA.bug_keywords.split(', ').find(keyword => keyword.match(/^(hang|assertion|crash)$/))) {
       return;
     }
 
@@ -537,9 +539,18 @@ Bugzilla.BugModal.Comments = class Comments {
       }
     }), { root: document.querySelector('#bugzilla-body') });
 
-    // Show attachments except for obsolete or deleted ones
-    document.querySelectorAll('.change-set .attachment:not(.obsolete):not(.deleted)')
-      .forEach($att => observer.observe($att));
+    document.querySelectorAll('.change-set').forEach($set => {
+      // Skip if the comment has the `hide-attachment` tag
+      const $comment = $set.querySelector('.comment:not([data-tags~="hide-attachment"])');
+      // Skip if the attachment is obsolete or deleted
+      const $attachment = $set.querySelector('.attachment:not(.obsolete):not(.deleted)');
+      // Skip if the attachment is SVG image
+      const is_svg = !!$set.querySelector('.attachment [itemprop="encodingFormat"][content="image/svg+xml"]');
+
+      if ($comment && $attachment && !is_svg) {
+        observer.observe($attachment);
+      }
+    });
   }
 
   /**