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

Allow displaying more users at once in Differential overview

Summary:
I want to check the work of several people (bootcampers) at once.
This implements the OR filter required for that.
In the next diff, I plan to implement also the AND filter which can be useful too.

Test Plan:
Searched for several people, clicked all filters.
Searched for one person, verified that pretty URL is still created.

Reviewers: epriestley

Reviewed By: epriestley

CC: wez, aran, Korvin

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

vrana c59aeb22 b73622b8

+47 -51
+1 -1
src/applications/differential/application/PhabricatorApplicationDifferential.php
··· 71 71 72 72 list($active, $waiting) = DifferentialRevisionQuery::splitResponsible( 73 73 $revisions, 74 - $user->getPHID()); 74 + array($user->getPHID())); 75 75 76 76 $status = array(); 77 77
+43 -47
src/applications/differential/controller/DifferentialRevisionListController.php
··· 33 33 $default_filter); 34 34 35 35 // Redirect from search to canonical URL. 36 - $phid_arr = $request->getArr('view_user'); 36 + $phid_arr = $request->getArr('view_users'); 37 37 if ($phid_arr) { 38 - $view_user = id(new PhabricatorUser()) 39 - ->loadOneWhere('phid = %s', head($phid_arr)); 38 + $view_users = id(new PhabricatorUser()) 39 + ->loadAllWhere('phid IN (%Ls)', $phid_arr); 40 + 41 + if (count($view_users) == 1) { 42 + // This is a single user, so generate a pretty URI. 43 + $uri = new PhutilURI( 44 + '/differential/filter/'.$this->filter.'/'. 45 + phutil_escape_uri(reset($view_users)->getUserName()).'/'); 46 + $uri->setQueryParams($params); 40 47 41 - $base_uri = '/differential/filter/'.$this->filter.'/'; 42 - if ($view_user) { 43 - // This is a user, so generate a pretty URI. 44 - $uri = $base_uri.phutil_escape_uri($view_user->getUserName()).'/'; 45 - } else { 46 - // We're assuming this is a mailing list, generate an ugly URI. 47 - $uri = $base_uri; 48 - $params['phid'] = head($phid_arr); 48 + return id(new AphrontRedirectResponse())->setURI($uri); 49 49 } 50 50 51 - $uri = new PhutilURI($uri); 52 - $uri->setQueryParams($params); 53 - 54 - return id(new AphrontRedirectResponse())->setURI($uri); 55 51 } 56 52 57 53 $uri = new PhutilURI('/differential/filter/'.$this->filter.'/'); ··· 66 62 } 67 63 $username = phutil_escape_uri($this->username).'/'; 68 64 $uri->setPath('/differential/filter/'.$this->filter.'/'.$username); 69 - $params['phid'] = $view_user->getPHID(); 65 + $params['view_users'] = array($view_user->getPHID()); 70 66 } else { 71 - $phid = $request->getStr('phid'); 72 - if (strlen($phid)) { 73 - $params['phid'] = $phid; 67 + $phids = $request->getArr('view_users'); 68 + if ($phids) { 69 + $params['view_users'] = $phids; 70 + $uri->setQueryParams($params); 74 71 } 75 72 } 76 73 77 74 // Fill in the defaults we'll actually use for calculations if any 78 75 // parameters are missing. 79 76 $params += array( 80 - 'phid' => $user->getPHID(), 77 + 'view_users' => array($user->getPHID()), 81 78 'status' => 'all', 82 79 'order' => 'modified', 83 80 ); ··· 97 94 $panels = array(); 98 95 $handles = array(); 99 96 $controls = $this->getFilterControls($this->filter); 100 - if ($this->getFilterRequiresUser($this->filter) && !$params['phid']) { 97 + if ($this->getFilterRequiresUser($this->filter) && !$params['view_users']) { 101 98 // In the anonymous case, we still want to let you see some user's 102 99 // list, but we don't have a default PHID to provide (normally, we use 103 100 // the viewing user's). Show a warning instead. ··· 108 105 'This filter requires that a user be specified above.'); 109 106 $panels[] = $warning; 110 107 } else { 111 - $query = $this->buildQuery($this->filter, $params['phid']); 108 + $query = $this->buildQuery($this->filter, $params['view_users']); 112 109 113 110 $pager = null; 114 111 if ($this->getFilterAllowsPaging($this->filter)) { ··· 131 128 $revisions = $pager->sliceResults($revisions); 132 129 } 133 130 134 - $views = $this->buildViews($this->filter, $params['phid'], $revisions); 131 + $views = $this->buildViews( 132 + $this->filter, 133 + $params['view_users'], 134 + $revisions); 135 135 136 136 $view_objects = array(); 137 137 foreach ($views as $view) { ··· 139 139 $view_objects[] = $view['view']; 140 140 } 141 141 } 142 - $phids = array_mergev(mpull($view_objects, 'getRequiredHandlePHIDs')); 143 - $phids[] = $params['phid']; 142 + $phids = mpull($view_objects, 'getRequiredHandlePHIDs'); 143 + $phids[] = $params['view_users']; 144 + $phids = array_mergev($phids); 144 145 $handles = $this->loadViewerHandles($phids); 145 146 146 147 foreach ($views as $view) { ··· 275 276 return $controls[$filter]; 276 277 } 277 278 278 - private function buildQuery($filter, $user_phid) { 279 + private function buildQuery($filter, array $user_phids) { 279 280 $query = new DifferentialRevisionQuery(); 280 281 281 282 $query->needRelationships(true); 282 283 283 284 switch ($filter) { 284 285 case 'active': 285 - $query->withResponsibleUsers(array($user_phid)); 286 + $query->withResponsibleUsers($user_phids); 286 287 $query->withStatus(DifferentialRevisionQuery::STATUS_OPEN); 287 288 $query->setLimit(null); 288 289 break; 289 290 case 'revisions': 290 - $query->withAuthors(array($user_phid)); 291 + $query->withAuthors($user_phids); 291 292 break; 292 293 case 'reviews': 293 - $query->withReviewers(array($user_phid)); 294 + $query->withReviewers($user_phids); 294 295 break; 295 296 case 'subscribed': 296 - $query->withSubscribers(array($user_phid)); 297 + $query->withSubscribers($user_phids); 297 298 break; 298 299 case 'drafts': 299 - $query->withDraftRepliesByAuthors(array($user_phid)); 300 + $query->withDraftRepliesByAuthors($user_phids); 300 301 break; 301 302 case 'all': 302 303 break; ··· 315 316 switch ($control) { 316 317 case 'subscriber': 317 318 case 'phid': 318 - $view_phid = $params['phid']; 319 - $value = array(); 320 - if ($view_phid) { 321 - $value = array( 322 - $view_phid => $handles[$view_phid]->getFullName(), 323 - ); 324 - } 319 + $value = mpull( 320 + array_select_keys($handles, $params['view_users']), 321 + 'getFullName'); 325 322 326 323 if ($control == 'subscriber') { 327 324 $source = '/typeahead/common/allmailable/'; 328 - $label = 'View Subscriber'; 325 + $label = 'View Subscribers'; 329 326 } else { 330 327 $source = '/typeahead/common/accounts/'; 331 - $label = 'View User'; 328 + $label = 'View Users'; 332 329 } 333 330 334 331 return id(new AphrontFormTokenizerControl()) 335 332 ->setDatasource($source) 336 333 ->setLabel($label) 337 - ->setName('view_user') 338 - ->setValue($value) 339 - ->setLimit(1); 334 + ->setName('view_users') 335 + ->setValue($value); 340 336 case 'status': 341 337 return id(new AphrontFormToggleButtonsControl()) 342 338 ->setLabel('Status') ··· 389 385 } 390 386 } 391 387 392 - private function buildViews($filter, $user_phid, array $revisions) { 388 + private function buildViews($filter, array $user_phids, array $revisions) { 393 389 assert_instances_of($revisions, 'DifferentialRevision'); 394 390 395 391 $user = $this->getRequest()->getUser(); ··· 403 399 case 'active': 404 400 list($active, $waiting) = DifferentialRevisionQuery::splitResponsible( 405 401 $revisions, 406 - $user_phid); 402 + $user_phids); 407 403 408 404 $view = id(clone $template) 409 405 ->setHighlightAge(true) ··· 416 412 417 413 // Flags are sort of private, so only show the flag panel if you're 418 414 // looking at your own requests. 419 - if ($user_phid == $user->getPHID()) { 415 + if (in_array($user->getPHID(), $user_phids)) { 420 416 $flags = id(new PhabricatorFlagQuery()) 421 - ->withOwnerPHIDs(array($user_phid)) 417 + ->withOwnerPHIDs(array($user->getPHID())) 422 418 ->withTypes(array(PhabricatorPHIDConstants::PHID_TYPE_DREV)) 423 419 ->needHandles(true) 424 420 ->execute();
+2 -2
src/applications/differential/query/DifferentialRevisionQuery.php
··· 891 891 } 892 892 } 893 893 894 - public static function splitResponsible(array $revisions, $user_phid) { 894 + public static function splitResponsible(array $revisions, array $user_phids) { 895 895 $active = array(); 896 896 $waiting = array(); 897 897 $status_review = ArcanistDifferentialRevisionStatus::NEEDS_REVIEW; ··· 901 901 // something about). 902 902 foreach ($revisions as $revision) { 903 903 $needs_review = ($revision->getStatus() == $status_review); 904 - $filter_is_author = ($revision->getAuthorPHID() == $user_phid); 904 + $filter_is_author = in_array($revision->getAuthorPHID(), $user_phids); 905 905 906 906 // If exactly one of "needs review" and "the user is the author" is 907 907 // true, the user needs to act on it. Otherwise, they're waiting on
+1 -1
src/applications/directory/controller/PhabricatorDirectoryMainController.php
··· 241 241 242 242 list($active, $waiting) = DifferentialRevisionQuery::splitResponsible( 243 243 $revisions, 244 - $user_phid); 244 + array($user_phid)); 245 245 246 246 if (!$active) { 247 247 return $this->renderMiniPanel(