From fefa9ec12f7fe5e6f15887f0977ed4c110841032 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Thu, 28 May 2026 22:13:30 -0400 Subject: [PATCH 1/4] Bug 2043229 - Display a "Show External" button beneath attachments list to display all attachments that would redirect such as Github and Phabricator --- Bugzilla/Config/Attachment.pm | 5 ++++ .../default/bug_modal/attachments.html.tmpl | 7 ++++- .../en/default/bug_modal/edit.html.tmpl | 14 +++++++++ extensions/BugModal/web/bug_modal.js | 29 ++++++++++++++----- 4 files changed, 47 insertions(+), 8 deletions(-) diff --git a/Bugzilla/Config/Attachment.pm b/Bugzilla/Config/Attachment.pm index f3f74c7aa7..c55b9e58cb 100644 --- a/Bugzilla/Config/Attachment.pm +++ b/Bugzilla/Config/Attachment.pm @@ -54,6 +54,11 @@ sub get_param_list { }, {name => 'github_pr_linking_enabled', type => 'b', default => 0}, {name => 'github_pr_signature_secret', type => 't', default => ''}, + { + name => 'attachment_hide_content_types', + type => 't', + default => 'text/x-phabricator-request text/x-github-pull-request', + }, ); return @param_list; } diff --git a/extensions/BugModal/template/en/default/bug_modal/attachments.html.tmpl b/extensions/BugModal/template/en/default/bug_modal/attachments.html.tmpl index dec6360f52..863f00738d 100755 --- a/extensions/BugModal/template/en/default/bug_modal/attachments.html.tmpl +++ b/extensions/BugModal/template/en/default/bug_modal/attachments.html.tmpl @@ -23,12 +23,14 @@ attachment_rendered = 0; Hook.process("row"); NEXT IF attachment_rendered; + is_external = attachment_hide_types.${attachment.contenttype} ? 1 : 0; %] + " [% IF attachment.isobsolete || is_external %]style="display:none"[% END %]>
Attach New File [% END %] + [% IF external_attachments %] + + [% END %] [% IF obsolete_attachments %] [% END %] 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 f61783f92f..dff2887642 100755 --- a/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl +++ b/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl @@ -51,12 +51,24 @@ # count attachments active_attachments = 0; obsolete_attachments = 0; + external_attachments = 0; + + attachment_hide_types = {}; + IF Param('attachment_hide_content_types'); + FOREACH _type IN Param('attachment_hide_content_types').split('[,\s]+'); + attachment_hide_types.$_type = 1 IF _type; + END; + END; + FOREACH attachment IN bug.attachments; NEXT IF attachment.isprivate && !(user.is_insider || attachment.attacher.id == user.id || (attachment.is_bounty_attachment && bug.reporter.id == user.id)) ; IF attachment.isobsolete; obsolete_attachments = obsolete_attachments + 1; ELSE; active_attachments = active_attachments + 1; + IF attachment_hide_types.${attachment.contenttype}; + external_attachments = external_attachments + 1; + END; END; END; @@ -1408,6 +1420,8 @@ [% INCLUDE bug_modal/attachments.html.tmpl active_attachments = active_attachments obsolete_attachments = obsolete_attachments + external_attachments = external_attachments + attachment_hide_types = attachment_hide_types %] [% END %] [% END %] diff --git a/extensions/BugModal/web/bug_modal.js b/extensions/BugModal/web/bug_modal.js index bdc0416846..e04c032938 100644 --- a/extensions/BugModal/web/bug_modal.js +++ b/extensions/BugModal/web/bug_modal.js @@ -272,13 +272,28 @@ $(function() { } }); - // toggle obsolete attachments - $('#attachments-obsolete-btn') - .click(function(event) { - event.preventDefault(); - $(event.target).text(($('#attachments tr:hidden').length ? 'Hide Obsolete' : 'Show Obsolete')); - $('#attachments tr.attach-obsolete').toggle(); - }); + // toggle obsolete/external attachments + let attachObsoleteShowing = false; + let attachExternalShowing = false; + + function updateAttachmentRows() { + $('#attachments tr.attach-obsolete').toggle(attachObsoleteShowing); + $('#attachments tr.attach-external:not(.attach-obsolete)').toggle(attachExternalShowing); + $('#attachments-obsolete-btn').text(attachObsoleteShowing ? 'Hide Obsolete' : 'Show Obsolete'); + $('#attachments-external-btn').text(attachExternalShowing ? 'Hide External' : 'Show External'); + } + + $('#attachments-obsolete-btn').click(function(event) { + event.preventDefault(); + attachObsoleteShowing = !attachObsoleteShowing; + updateAttachmentRows(); + }); + + $('#attachments-external-btn').click(function(event) { + event.preventDefault(); + attachExternalShowing = !attachExternalShowing; + updateAttachmentRows(); + }); // URL --> unsafe warning $('.bug-url') From eae677c817db028bc88749d7e710f9c66758aa9d Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Fri, 29 May 2026 12:02:34 -0400 Subject: [PATCH 2/4] Copilot suggested fixes --- .../BugModal/template/en/default/bug_modal/edit.html.tmpl | 8 ++++++-- template/en/default/admin/params/attachment.html.tmpl | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) 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 dff2887642..bb03f4af17 100755 --- a/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl +++ b/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl @@ -1403,11 +1403,15 @@ [% IF active_attachments || obsolete_attachments || user.id %] [% sub = []; + visible_attachments = active_attachments - external_attachments; IF active_attachments + obsolete_attachments == 0; sub.push("No files"); END; - IF active_attachments; - sub.push(active_attachments _ " file" _ (active_attachments == 1 ? "" : "s")); + IF visible_attachments; + sub.push(visible_attachments _ " file" _ (visible_attachments == 1 ? "" : "s")); + END; + IF external_attachments; + sub.push(external_attachments _ " external file" _ (external_attachments == 1 ? "" : "s")); END; IF obsolete_attachments; sub.push(obsolete_attachments _ " obsolete file" _ (obsolete_attachments == 1 ? "" : "s")); diff --git a/template/en/default/admin/params/attachment.html.tmpl b/template/en/default/admin/params/attachment.html.tmpl index 3659cd5b76..466019150d 100644 --- a/template/en/default/admin/params/attachment.html.tmpl +++ b/template/en/default/admin/params/attachment.html.tmpl @@ -77,5 +77,13 @@ google_storage_service_account => "Google Cloud Storage Service Account", + + attachment_hide_content_types => + "A comma or whitespace separated list of MIME types that should be hidden" + _ " by default in the bug modal attachments list. Attachments matching these" + _ " types will not appear in the attachments table unless the user clicks the" + _ " Show External button. This is useful for content types such as" + _ " text/x-phabricator-request and text/x-github-pull-request" + _ " that are already displayed in a dedicated section above the attachments list.", } %] From 94fdf6ebd9ef43aca14f6c20565481311cfe29fd Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Mon, 8 Jun 2026 17:13:28 -0400 Subject: [PATCH 3/4] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- template/en/default/admin/params/attachment.html.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/en/default/admin/params/attachment.html.tmpl b/template/en/default/admin/params/attachment.html.tmpl index 466019150d..a905d58cbd 100644 --- a/template/en/default/admin/params/attachment.html.tmpl +++ b/template/en/default/admin/params/attachment.html.tmpl @@ -79,7 +79,7 @@ "Google Cloud Storage Service Account", attachment_hide_content_types => - "A comma or whitespace separated list of MIME types that should be hidden" + "A comma- or whitespace-separated list of MIME types that should be hidden" _ " by default in the bug modal attachments list. Attachments matching these" _ " types will not appear in the attachments table unless the user clicks the" _ " Show External button. This is useful for content types such as" From e50beccd60c08eff6be5e81958434f30866aa1db Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Mon, 8 Jun 2026 17:16:01 -0400 Subject: [PATCH 4/4] Copilot review fixes --- extensions/BugModal/web/bug_modal.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/extensions/BugModal/web/bug_modal.js b/extensions/BugModal/web/bug_modal.js index e04c032938..1a82aebbf1 100644 --- a/extensions/BugModal/web/bug_modal.js +++ b/extensions/BugModal/web/bug_modal.js @@ -277,8 +277,16 @@ $(function() { let attachExternalShowing = false; function updateAttachmentRows() { - $('#attachments tr.attach-obsolete').toggle(attachObsoleteShowing); - $('#attachments tr.attach-external:not(.attach-obsolete)').toggle(attachExternalShowing); + // A row may be obsolete, external, or both. It is only visible when + // every category it belongs to has been toggled on, so external rows + // stay hidden while "Show External" is off even if they are obsolete. + $('#attachments tr.attach-obsolete, #attachments tr.attach-external').each(function() { + const $row = $(this); + const visible = + (!$row.hasClass('attach-obsolete') || attachObsoleteShowing) && + (!$row.hasClass('attach-external') || attachExternalShowing); + $row.toggle(visible); + }); $('#attachments-obsolete-btn').text(attachObsoleteShowing ? 'Hide Obsolete' : 'Show Obsolete'); $('#attachments-external-btn').text(attachExternalShowing ? 'Hide External' : 'Show External'); }