@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Added a Mentions tab to the Differential Revision View

Summary:
This revision adds a Mentions tab to the revision between the History and Commits tabs

The tab functions exactly like the tab you see on a Maniphest task

When you have revisions that have lots of activity, or, lots of mentions in other places (including tasks, and other revisions) it is hard to see that list in a concise way. This revision solves this by adding the same tab to a Revision

**This revision does the following: **
- Removes `final` from PHUIPropertyListView so we can extend it
- Created a new class called `PHUIMentionsListView` that extends `PHUIPropertyListView`
- Replaces the code in `ManiphestTaskDetailController` with this new view
- Adds a `Mentions` tab to `DifferentialRevisionViewController`

**Future Work**
We could re-use this in other places in Phorge that support mentions. Either as a Tab view, or, in some other place in the view.

{F3014887 width=800}

Closes T16003

Test Plan: Made a revision, mentioned it, and saw mentions

Reviewers: O1 Blessed Committers, valerio.bozzolan, avivey

Reviewed By: O1 Blessed Committers, valerio.bozzolan, avivey

Subscribers: avivey, aklapper, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T16003

Differential Revision: https://we.phorge.it/D25897

+139 -40
+1
src/__phutil_library_map__.php
··· 5405 5405 'PholioTransactionType' => 'applications/pholio/xaction/PholioTransactionType.php', 5406 5406 'PholioTransactionView' => 'applications/pholio/view/PholioTransactionView.php', 5407 5407 'PholioUploadedImageView' => 'applications/pholio/view/PholioUploadedImageView.php', 5408 + 'PhorgeApplicationMentionsListView' => 'applications/transactions/view/PhorgeApplicationMentionsListView.php', 5408 5409 'PhorgeCodeWarningSetupCheck' => 'applications/config/check/PhorgeCodeWarningSetupCheck.php', 5409 5410 'PhorgeFlagFlaggedObjectCustomField' => 'applications/flag/customfield/PhorgeFlagFlaggedObjectCustomField.php', 5410 5411 'PhorgeFlagFlaggedObjectFieldStorage' => 'applications/flag/customfield/PhorgeFlagFlaggedObjectFieldStorage.php',
+39
src/applications/differential/controller/DifferentialRevisionViewController.php
··· 40 40 return $this; 41 41 } 42 42 43 + 44 + private function newMentionsTab( 45 + DifferentialRevision $revision) { 46 + 47 + $phid = $revision->getPHID(); 48 + 49 + $edge_types = array( 50 + PhabricatorObjectMentionedByObjectEdgeType::EDGECONST, 51 + PhabricatorObjectMentionsObjectEdgeType::EDGECONST, 52 + ); 53 + 54 + $edge_query = id(new PhabricatorEdgeQuery()) 55 + ->withSourcePHIDs(array($phid)) 56 + ->withEdgeTypes($edge_types); 57 + 58 + $edge_query->execute(); 59 + 60 + $view = (new PhorgeApplicationMentionsListView()) 61 + ->setEdgeQuery($edge_query) 62 + ->setViewer($this->getViewer()) 63 + ->getMentionsView(); 64 + 65 + if (!$view ) { 66 + return null; 67 + } 68 + 69 + return id(new PHUITabView()) 70 + ->setName(pht('Mentions')) 71 + ->setKey('mentions') 72 + ->appendChild($view); 73 + } 74 + 75 + 43 76 public function handleRequest(AphrontRequest $request) { 44 77 $viewer = $this->getViewer(); 45 78 $this->revisionID = $request->getURIData('id'); ··· 487 520 ->setName(pht('History')) 488 521 ->setKey('history') 489 522 ->appendChild($history)); 523 + 524 + $mentions_tab = $this->newMentionsTab($revision); 525 + 526 + if ($mentions_tab) { 527 + $tab_group->addTab($mentions_tab); 528 + } 490 529 491 530 $filetree = id(new DifferentialFileTreeEngine()) 492 531 ->setViewer($viewer);
+6 -40
src/applications/maniphest/controller/ManiphestTaskDetailController.php
··· 163 163 } 164 164 165 165 $related_tabs[] = $this->newMocksTab($task, $query); 166 - $related_tabs[] = $this->newMentionsTab($task, $query); 166 + $related_tabs[] = $this->newMentionsTab($query); 167 167 $related_tabs[] = $this->newDuplicatesTab($task, $query); 168 168 169 169 $tab_view = null; ··· 528 528 } 529 529 530 530 private function newMentionsTab( 531 - ManiphestTask $task, 532 531 PhabricatorEdgeQuery $edge_query) { 533 532 534 - $in_type = PhabricatorObjectMentionedByObjectEdgeType::EDGECONST; 535 - $out_type = PhabricatorObjectMentionsObjectEdgeType::EDGECONST; 536 - 537 - $in_phids = $edge_query->getDestinationPHIDs(array(), array($in_type)); 538 - $out_phids = $edge_query->getDestinationPHIDs(array(), array($out_type)); 539 - 540 - // Filter out any mentioned users from the list. These are not generally 541 - // very interesting to show in a relationship summary since they usually 542 - // end up as subscribers anyway. 543 - 544 - $user_type = PhabricatorPeopleUserPHIDType::TYPECONST; 545 - foreach ($out_phids as $key => $out_phid) { 546 - if (phid_get_type($out_phid) == $user_type) { 547 - unset($out_phids[$key]); 548 - } 549 - } 550 - 551 - if (!$in_phids && !$out_phids) { 552 - return null; 553 - } 554 - 555 - $viewer = $this->getViewer(); 556 - $in_handles = $viewer->loadHandles($in_phids); 557 - $out_handles = $viewer->loadHandles($out_phids); 533 + $view = (new PhorgeApplicationMentionsListView()) 534 + ->setEdgeQuery($edge_query) 535 + ->setViewer($this->getViewer()) 536 + ->getMentionsView(); 558 537 559 - $in_handles = $this->getCompleteHandles($in_handles); 560 - $out_handles = $this->getCompleteHandles($out_handles); 561 - 562 - if (!count($in_handles) && !count($out_handles)) { 538 + if (!$view ) { 563 539 return null; 564 - } 565 - 566 - $view = new PHUIPropertyListView(); 567 - 568 - if (count($in_handles)) { 569 - $view->addProperty(pht('Mentioned In'), $in_handles->renderList()); 570 - } 571 - 572 - if (count($out_handles)) { 573 - $view->addProperty(pht('Mentioned Here'), $out_handles->renderList()); 574 540 } 575 541 576 542 return id(new PHUITabView())
+93
src/applications/transactions/view/PhorgeApplicationMentionsListView.php
··· 1 + <?php 2 + 3 + final class PhorgeApplicationMentionsListView { 4 + 5 + private $edgeQuery; 6 + private $viewer; 7 + private $hasMentions = false; 8 + 9 + public function setEdgeQuery( 10 + PhabricatorEdgeQuery $edge_query): self { 11 + $this->edgeQuery = $edge_query; 12 + return $this; 13 + } 14 + 15 + public function setViewer( 16 + PhabricatorUser $viewer): self { 17 + $this->viewer = $viewer; 18 + return $this; 19 + } 20 + 21 + public function getMentionsView(): ?PHUIPropertyListView { 22 + 23 + $in_type = PhabricatorObjectMentionedByObjectEdgeType::EDGECONST; 24 + $out_type = PhabricatorObjectMentionsObjectEdgeType::EDGECONST; 25 + 26 + $in_phids = $this->edgeQuery->getDestinationPHIDs([], [$in_type]); 27 + $out_phids = $this->edgeQuery->getDestinationPHIDs([], [$out_type]); 28 + 29 + // Filter out any mentioned users from the list. These are not generally 30 + // very interesting to show in a relationship summary since they usually 31 + // end up as subscribers anyway. 32 + 33 + $user_type = PhabricatorPeopleUserPHIDType::TYPECONST; 34 + 35 + foreach ($out_phids as $key => $out_phid) { 36 + if (phid_get_type($out_phid) == $user_type) { 37 + unset($out_phids[$key]); 38 + } 39 + } 40 + 41 + if (!$in_phids && !$out_phids) { 42 + return null; 43 + } 44 + 45 + $in_handles = $this->viewer->loadHandles($in_phids); 46 + $out_handles = $this->viewer->loadHandles($out_phids); 47 + 48 + $in_handles = $this->getCompleteHandles($in_handles); 49 + $out_handles = $this->getCompleteHandles($out_handles); 50 + 51 + if (!count($in_handles) && !count($out_handles)) { 52 + return null; 53 + } 54 + 55 + $view = new PHUIPropertyListView(); 56 + 57 + if (count($in_handles)) { 58 + $view->addProperty( 59 + pht('Mentioned In'), $in_handles->renderList()); 60 + } 61 + 62 + if (count($out_handles)) { 63 + $view->addProperty( 64 + pht('Mentioned Here'), $out_handles->renderList()); 65 + } 66 + 67 + $this->hasMentions = true; 68 + 69 + return $view; 70 + 71 + } 72 + 73 + public function hasMentions(): bool { 74 + return $this->hasMentions; 75 + } 76 + 77 + 78 + private function getCompleteHandles( 79 + PhabricatorHandleList $handles): PhabricatorHandleList { 80 + $phids = []; 81 + 82 + foreach ($handles as $phid => $handle) { 83 + if (!$handle->isComplete()) { 84 + continue; 85 + } 86 + $phids[] = $phid; 87 + } 88 + 89 + return $handles->newSublist($phids); 90 + } 91 + 92 + 93 + }