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

Accommodate project reviewers in Differential search

Summary:
Ref T1279. Two changes to the search/query for Differential:

- "Reviewers" now accepts users and projects.
- "Responsible Users" now includes revisions where a project you are a member of is a reviewer.

Test Plan:
- Searched for project reviewers.
- Verified that the dashboard now shows reviews which I'm only part of via project membership.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1279

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

+37 -6
+13 -2
src/applications/differential/query/DifferentialRevisionQuery.php
··· 495 495 if ($this->responsibles) { 496 496 $basic_authors = $this->authors; 497 497 $basic_reviewers = $this->reviewers; 498 + 499 + $authority_projects = id(new PhabricatorProjectQuery()) 500 + ->setViewer($this->getViewer()) 501 + ->withMemberPHIDs($this->responsibles) 502 + ->execute(); 503 + $authority_phids = mpull($authority_projects, 'getPHID'); 504 + 498 505 try { 499 506 // Build the query where the responsible users are authors. 500 507 $this->authors = array_merge($basic_authors, $this->responsibles); 501 508 $this->reviewers = $basic_reviewers; 502 509 $selects[] = $this->buildSelectStatement($conn_r); 503 510 504 - // Build the query where the responsible users are reviewers. 511 + // Build the query where the responsible users are reviewers, or 512 + // projects they are members of are reviewers. 505 513 $this->authors = $basic_authors; 506 - $this->reviewers = array_merge($basic_reviewers, $this->responsibles); 514 + $this->reviewers = array_merge( 515 + $basic_reviewers, 516 + $this->responsibles, 517 + $authority_phids); 507 518 $selects[] = $this->buildSelectStatement($conn_r); 508 519 509 520 // Put everything back like it was.
+7 -2
src/applications/differential/query/DifferentialRevisionSearchEngine.php
··· 23 23 24 24 $saved->setParameter( 25 25 'reviewerPHIDs', 26 - $this->readUsersFromRequest($request, 'reviewers')); 26 + $this->readUsersFromRequest( 27 + $request, 28 + 'reviewers', 29 + array( 30 + PhabricatorProjectPHIDTypeProject::TYPECONST, 31 + ))); 27 32 28 33 $saved->setParameter( 29 34 'subscriberPHIDs', ··· 140 145 id(new AphrontFormTokenizerControl()) 141 146 ->setLabel(pht('Reviewers')) 142 147 ->setName('reviewers') 143 - ->setDatasource('/typeahead/common/accounts/') 148 + ->setDatasource('/typeahead/common/accountsorprojects/') 144 149 ->setValue(array_select_keys($handles, $reviewer_phids))) 145 150 ->appendChild( 146 151 id(new AphrontFormTokenizerControl())
+11 -2
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
··· 254 254 * 255 255 * @param AphrontRequest Request to read user PHIDs from. 256 256 * @param string Key to read in the request. 257 + * @param list<const> Other permitted PHID types. 257 258 * @return list<phid> List of user PHIDs. 258 259 * 259 260 * @task read 260 261 */ 261 - protected function readUsersFromRequest(AphrontRequest $request, $key) { 262 + protected function readUsersFromRequest( 263 + AphrontRequest $request, 264 + $key, 265 + array $allow_types = array()) { 262 266 $list = $request->getArr($key, null); 263 267 if ($list === null) { 264 268 $list = $request->getStrList($key); ··· 266 270 267 271 $phids = array(); 268 272 $names = array(); 273 + $allow_types = array_fuse($allow_types); 269 274 $user_type = PhabricatorPHIDConstants::PHID_TYPE_USER; 270 275 foreach ($list as $item) { 271 - if (phid_get_type($item) == $user_type) { 276 + $type = phid_get_type($item); 277 + phlog($type); 278 + if ($type == $user_type) { 279 + $phids[] = $item; 280 + } else if (isset($allow_types[$type])) { 272 281 $phids[] = $item; 273 282 } else { 274 283 $names[] = $item;
+5
src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php
··· 85 85 $need_users = true; 86 86 $need_all_users = true; 87 87 break; 88 + case 'accountsorprojects': 89 + $need_users = true; 90 + $need_all_users = true; 91 + $need_projs = true; 92 + break; 88 93 case 'arcanistprojects': 89 94 $need_arcanist_projects = true; 90 95 break;
+1
src/view/form/control/AphrontFormTokenizerControl.php
··· 103 103 'repositories' => pht('Type a repository name...'), 104 104 'packages' => pht('Type a package name...'), 105 105 'arcanistproject' => pht('Type an arc project name...'), 106 + 'accountsorprojects' => pht('Type a user or project name...'), 106 107 ); 107 108 108 109 return idx($map, $request);