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..bb03f4af17 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;
@@ -1391,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"));
@@ -1408,6 +1424,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..1a82aebbf1 100644
--- a/extensions/BugModal/web/bug_modal.js
+++ b/extensions/BugModal/web/bug_modal.js
@@ -272,13 +272,36 @@ $(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() {
+ // 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');
+ }
+
+ $('#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')
diff --git a/template/en/default/admin/params/attachment.html.tmpl b/template/en/default/admin/params/attachment.html.tmpl
index 3659cd5b76..a905d58cbd 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.",
}
%]