From af4dd3bc1c98b381e4936479a7e0bf0c04052aaa Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Tue, 4 Feb 2020 12:32:31 -0500 Subject: [PATCH 1/2] Bug 1613179 - Hide Phabricator related attachments from the attachment list and rely on phabricator table instead --- .../BugModal/template/en/default/bug_modal/attachments.html.tmpl | 1 + 1 file changed, 1 insertion(+) 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 c83885c6b4..409e68b35c 100644 --- a/extensions/BugModal/template/en/default/bug_modal/attachments.html.tmpl +++ b/extensions/BugModal/template/en/default/bug_modal/attachments.html.tmpl @@ -16,6 +16,7 @@ [% FOREACH attachment IN bug.attachments %] [% + NEXT IF attachment.contenttype == 'text/x-phabricator-request'; NEXT IF attachment.isprivate && !(user.is_insider || attachment.attacher.id == user.id); attachment_rendered = 0; Hook.process("row"); From 1a10ccfe6c07b95cffe222594bac3cd8c3878992 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Thu, 6 Feb 2020 15:53:20 -0500 Subject: [PATCH 2/2] Add details link to phabricator revisions table to allow seeing local attachment attributes --- extensions/PhabBugz/lib/WebService.pm | 7 +++--- .../en/default/phabricator/table.html.tmpl | 1 + extensions/PhabBugz/web/js/phabricator.js | 22 +++++++++++++------ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/extensions/PhabBugz/lib/WebService.pm b/extensions/PhabBugz/lib/WebService.pm index 8376e6ad44..7971a05688 100644 --- a/extensions/PhabBugz/lib/WebService.pm +++ b/extensions/PhabBugz/lib/WebService.pm @@ -110,12 +110,12 @@ sub bug_revisions { # Validate that the user can see the bug itself my $bug = Bugzilla::Bug->check({id => $params->{bug_id}, cache => 1}); - my @revision_ids; + my %revision_map; foreach my $attachment (@{$bug->attachments}) { next if $attachment->contenttype ne PHAB_CONTENT_TYPE; my ($revision_id) = ($attachment->filename =~ PHAB_ATTACHMENT_PATTERN); next if !$revision_id; - push @revision_ids, int $revision_id; + $revision_map{$revision_id} = $attachment->id; } my $response = request( @@ -127,7 +127,7 @@ sub bug_revisions { 'subscribers' => 1, 'reviewers-extra' => 1, }, - constraints => {ids => \@revision_ids,}, + constraints => {ids => [ map { int $_ } keys %revision_map ]}, order => 'newest', } ); @@ -172,6 +172,7 @@ sub bug_revisions { my $revision_obj = Bugzilla::Extension::PhabBugz::Revision->new($revision); my $revision_data = { id => 'D' . $revision_obj->id, + attach_id => $revision_map{$revision_obj->id}, sortkey => $revision_obj->id, status => $revision_obj->status, long_status => $revision_status_map->{$revision_obj->status} diff --git a/extensions/PhabBugz/template/en/default/phabricator/table.html.tmpl b/extensions/PhabBugz/template/en/default/phabricator/table.html.tmpl index 1f26ad73fb..65b4f45381 100644 --- a/extensions/PhabBugz/template/en/default/phabricator/table.html.tmpl +++ b/extensions/PhabBugz/template/en/default/phabricator/table.html.tmpl @@ -14,6 +14,7 @@ + diff --git a/extensions/PhabBugz/web/js/phabricator.js b/extensions/PhabBugz/web/js/phabricator.js index 1666c67c7e..84f510b71a 100644 --- a/extensions/PhabBugz/web/js/phabricator.js +++ b/extensions/PhabBugz/web/js/phabricator.js @@ -17,12 +17,13 @@ Phabricator.getBugRevisions = async () => { var table = $('
Title Status Reviewers
'); function revisionRow(revision) { - var trRevision = tr.clone(); - var tdId = td.clone(); - var tdTitle = td.clone(); - var tdRevisionStatus = td.clone(); - var tdReviewers = td.clone(); - var tableReviews = table.clone(); + var trRevision = tr.clone(); + var tdId = td.clone(); + var tdTitle = td.clone(); + var tdRevisionStatus = td.clone(); + var tdReviewers = td.clone(); + var tdDetails = td.clone(); + var tableReviews = table.clone(); var spanRevisionStatus = span.clone(); var spanRevisionStatusIcon = span.clone(); @@ -66,11 +67,18 @@ Phabricator.getBugRevisions = async () => { $('tbody.phabricator-show-abandoned').removeClass('bz_default_hidden'); } + var detailsLink = link.clone(); + detailsLink.attr('href', `${BUGZILLA.config.basepath}attachment.cgi?action=edit&id=${revision.attach_id}`); + detailsLink.attr('title', 'Local Bugzilla Attachment Details'); + detailsLink.text('Details'); + tdDetails.append(detailsLink); + trRevision.append( tdId, tdTitle, tdRevisionStatus, - tdReviewers + tdReviewers, + tdDetails ); return trRevision;