Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1613179 - Hide Phabricator related attachments from the attachment list and rely on phabricator table instead #1497

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<table role="table" class="layout-table" id="attachments">
[% 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");
Expand Down
7 changes: 4 additions & 3 deletions extensions/PhabBugz/lib/WebService.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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',
}
);
Expand Down Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<th>Title</th>
<th>Status</th>
<th>Reviewers</th>
<th></th>
</tr>
</thead>
<tbody class="phabricator-revision">
Expand Down
22 changes: 15 additions & 7 deletions extensions/PhabBugz/web/js/phabricator.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ Phabricator.getBugRevisions = async () => {
var table = $('<table/>');

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();
Expand Down Expand Up @@ -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;
Expand Down