@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.

Transactions - add "and X others" dialog support to application transactions

Summary: Fixes T4430. Basically does a little code massage from the new stuff in D8525 and application transactions to get this working. Adds a new controller to the subscriptions app to make rendering these pretty easy peasy.

Test Plan: Used my test task in D8525 to verify both add and rem versions of these dialogs worked correctly.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, chad, Korvin

Maniphest Tasks: T4430

Differential Revision: https://secure.phabricator.com/D8540

+119 -6
+2
src/__phutil_library_map__.php
··· 2095 2095 'PhabricatorSubscriptionsEditController' => 'applications/subscriptions/controller/PhabricatorSubscriptionsEditController.php', 2096 2096 'PhabricatorSubscriptionsEditor' => 'applications/subscriptions/editor/PhabricatorSubscriptionsEditor.php', 2097 2097 'PhabricatorSubscriptionsListController' => 'applications/subscriptions/controller/PhabricatorSubscriptionsListController.php', 2098 + 'PhabricatorSubscriptionsTransactionController' => 'applications/subscriptions/controller/PhabricatorSubscriptionsTransactionController.php', 2098 2099 'PhabricatorSubscriptionsUIEventListener' => 'applications/subscriptions/events/PhabricatorSubscriptionsUIEventListener.php', 2099 2100 'PhabricatorSymbolNameLinter' => 'infrastructure/lint/hook/PhabricatorSymbolNameLinter.php', 2100 2101 'PhabricatorSyntaxHighlighter' => 'infrastructure/markup/PhabricatorSyntaxHighlighter.php', ··· 4897 4898 'PhabricatorSubscriptionsEditController' => 'PhabricatorController', 4898 4899 'PhabricatorSubscriptionsEditor' => 'PhabricatorEditor', 4899 4900 'PhabricatorSubscriptionsListController' => 'PhabricatorController', 4901 + 'PhabricatorSubscriptionsTransactionController' => 'PhabricatorController', 4900 4902 'PhabricatorSubscriptionsUIEventListener' => 'PhabricatorEventListener', 4901 4903 'PhabricatorSymbolNameLinter' => 'ArcanistXHPASTLintNamingHook', 4902 4904 'PhabricatorSyntaxHighlightingConfigOptions' => 'PhabricatorApplicationConfigOptions',
+2
src/applications/subscriptions/application/PhabricatorApplicationSubscriptions.php
··· 22 22 '(?P<action>add|delete)/'. 23 23 '(?P<phid>[^/]+)/' => 'PhabricatorSubscriptionsEditController', 24 24 'list/(?P<phid>[^/]+)/' => 'PhabricatorSubscriptionsListController', 25 + 'transaction/(?P<type>add|rem)/(?<phid>[^/]+)/' => 26 + 'PhabricatorSubscriptionsTransactionController', 25 27 ), 26 28 ); 27 29 }
+81
src/applications/subscriptions/controller/PhabricatorSubscriptionsTransactionController.php
··· 1 + <?php 2 + 3 + final class PhabricatorSubscriptionsTransactionController 4 + extends PhabricatorController { 5 + 6 + private $phid; 7 + private $changeType; 8 + 9 + public function willProcessRequest(array $data) { 10 + $this->phid = idx($data, 'phid'); 11 + $this->changeType = idx($data, 'type'); 12 + } 13 + 14 + public function processRequest() { 15 + $request = $this->getRequest(); 16 + 17 + $viewer = $request->getUser(); 18 + $xaction_phid = $this->phid; 19 + 20 + $xaction = id(new PhabricatorObjectQuery()) 21 + ->withPHIDs(array($xaction_phid)) 22 + ->setViewer($viewer) 23 + ->executeOne(); 24 + if (!$xaction) { 25 + return new Aphront404Response(); 26 + } 27 + 28 + $old = $xaction->getOldValue(); 29 + $new = $xaction->getNewValue(); 30 + switch ($this->changeType) { 31 + case 'add': 32 + $subscriber_phids = array_diff($new, $old); 33 + break; 34 + case 'rem': 35 + $subscriber_phids = array_diff($old, $new); 36 + break; 37 + default: 38 + return id(new Aphront404Response()); 39 + } 40 + 41 + $object_phid = $xaction->getObjectPHID(); 42 + $author_phid = $xaction->getAuthorPHID(); 43 + $handle_phids = $subscriber_phids; 44 + $handle_phids[] = $object_phid; 45 + $handle_phids[] = $author_phid; 46 + 47 + $handles = id(new PhabricatorHandleQuery()) 48 + ->setViewer($viewer) 49 + ->withPHIDs($handle_phids) 50 + ->execute(); 51 + $author_handle = $handles[$author_phid]; 52 + if (!in_array($author_phid, $subscriber_phids)) { 53 + unset($handles[$author_phid]); 54 + } 55 + 56 + switch ($this->changeType) { 57 + case 'add': 58 + $title = pht( 59 + 'All %d subscribers added by %s', 60 + count($subscriber_phids), 61 + $author_handle->renderLink()); 62 + break; 63 + case 'rem': 64 + $title = pht( 65 + 'All %d subscribers removed by %s', 66 + count($subscriber_phids), 67 + $author_handle->renderLink()); 68 + break; 69 + } 70 + 71 + $dialog = id(new SubscriptionListDialogBuilder()) 72 + ->setViewer($viewer) 73 + ->setTitle($title) 74 + ->setObjectPHID($object_phid) 75 + ->setHandles($handles) 76 + ->buildDialog(); 77 + 78 + return id(new AphrontDialogResponse())->setDialog($dialog); 79 + } 80 + 81 + }
+18 -2
src/applications/subscriptions/view/SubscriptionListStringBuilder.php
··· 24 24 return $this->objectPHID; 25 25 } 26 26 27 + public function buildTransactionString($change_type) { 28 + $handles = $this->getHandles(); 29 + if (!$handles) { 30 + return; 31 + } 32 + $list_uri = '/subscriptions/transaction/'. 33 + $change_type.'/'. 34 + $this->getObjectPHID().'/'; 35 + return $this->buildString($list_uri); 36 + } 37 + 27 38 public function buildPropertyString() { 28 - $phid = $this->getObjectPHID(); 29 39 $handles = $this->getHandles(); 30 40 31 41 if (!$handles) { 32 42 return phutil_tag('em', array(), pht('None')); 33 43 } 44 + $list_uri = '/subscriptions/list/'.$this->getObjectPHID().'/'; 45 + return $this->buildString($list_uri); 46 + } 47 + 48 + private function buildString($list_uri) { 49 + $handles = $this->getHandles(); 34 50 35 51 $html = array(); 36 52 $show_count = 3; ··· 53 69 $args[] = javelin_tag( 54 70 'a', 55 71 array( 56 - 'href' => '/subscriptions/list/'.$phid.'/', 72 + 'href' => $list_uri, 57 73 'sigil' => 'workflow' 58 74 ), 59 75 $not_shown_txt);
+16 -4
src/applications/transactions/storage/PhabricatorApplicationTransaction.php
··· 289 289 } 290 290 } 291 291 292 + private function renderSubscriberList(array $phids, $change_type) { 293 + if ($this->getRenderingTarget() == self::TARGET_TEXT) { 294 + return $this->renderHandleList($phids); 295 + } else { 296 + $handles = array_select_keys($this->getHandles(), $phids); 297 + return id(new SubscriptionListStringBuilder()) 298 + ->setHandles($handles) 299 + ->setObjectPHID($this->getPHID()) 300 + ->buildTransactionString($change_type); 301 + } 302 + } 303 + 292 304 public function renderPolicyName($phid) { 293 305 $policy = PhabricatorPolicy::newFromPolicyAndHandle( 294 306 $phid, ··· 455 467 '%s edited subscriber(s), added %d: %s; removed %d: %s.', 456 468 $this->renderHandleLink($author_phid), 457 469 count($add), 458 - $this->renderHandleList($add), 470 + $this->renderSubscriberList($add, 'add'), 459 471 count($rem), 460 - $this->renderHandleList($rem)); 472 + $this->renderSubscriberList($rem, 'rem')); 461 473 } else if ($add) { 462 474 return pht( 463 475 '%s added %d subscriber(s): %s.', 464 476 $this->renderHandleLink($author_phid), 465 477 count($add), 466 - $this->renderHandleList($add)); 478 + $this->renderSubscriberList($add, 'add')); 467 479 } else if ($rem) { 468 480 return pht( 469 481 '%s removed %d subscriber(s): %s.', 470 482 $this->renderHandleLink($author_phid), 471 483 count($rem), 472 - $this->renderHandleList($rem)); 484 + $this->renderSubscriberList($rem, 'rem')); 473 485 } else { 474 486 // This is used when rendering previews, before the user actually 475 487 // selects any CCs.