mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 16:52:41 +01:00
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
This commit is contained in:
parent
cf4eb3109e
commit
9434df9d7c
5 changed files with 37 additions and 6 deletions
|
@ -495,15 +495,26 @@ final class DifferentialRevisionQuery
|
|||
if ($this->responsibles) {
|
||||
$basic_authors = $this->authors;
|
||||
$basic_reviewers = $this->reviewers;
|
||||
|
||||
$authority_projects = id(new PhabricatorProjectQuery())
|
||||
->setViewer($this->getViewer())
|
||||
->withMemberPHIDs($this->responsibles)
|
||||
->execute();
|
||||
$authority_phids = mpull($authority_projects, 'getPHID');
|
||||
|
||||
try {
|
||||
// Build the query where the responsible users are authors.
|
||||
$this->authors = array_merge($basic_authors, $this->responsibles);
|
||||
$this->reviewers = $basic_reviewers;
|
||||
$selects[] = $this->buildSelectStatement($conn_r);
|
||||
|
||||
// Build the query where the responsible users are reviewers.
|
||||
// Build the query where the responsible users are reviewers, or
|
||||
// projects they are members of are reviewers.
|
||||
$this->authors = $basic_authors;
|
||||
$this->reviewers = array_merge($basic_reviewers, $this->responsibles);
|
||||
$this->reviewers = array_merge(
|
||||
$basic_reviewers,
|
||||
$this->responsibles,
|
||||
$authority_phids);
|
||||
$selects[] = $this->buildSelectStatement($conn_r);
|
||||
|
||||
// Put everything back like it was.
|
||||
|
|
|
@ -23,7 +23,12 @@ final class DifferentialRevisionSearchEngine
|
|||
|
||||
$saved->setParameter(
|
||||
'reviewerPHIDs',
|
||||
$this->readUsersFromRequest($request, 'reviewers'));
|
||||
$this->readUsersFromRequest(
|
||||
$request,
|
||||
'reviewers',
|
||||
array(
|
||||
PhabricatorProjectPHIDTypeProject::TYPECONST,
|
||||
)));
|
||||
|
||||
$saved->setParameter(
|
||||
'subscriberPHIDs',
|
||||
|
@ -140,7 +145,7 @@ final class DifferentialRevisionSearchEngine
|
|||
id(new AphrontFormTokenizerControl())
|
||||
->setLabel(pht('Reviewers'))
|
||||
->setName('reviewers')
|
||||
->setDatasource('/typeahead/common/accounts/')
|
||||
->setDatasource('/typeahead/common/accountsorprojects/')
|
||||
->setValue(array_select_keys($handles, $reviewer_phids)))
|
||||
->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
|
|
|
@ -254,11 +254,15 @@ abstract class PhabricatorApplicationSearchEngine {
|
|||
*
|
||||
* @param AphrontRequest Request to read user PHIDs from.
|
||||
* @param string Key to read in the request.
|
||||
* @param list<const> Other permitted PHID types.
|
||||
* @return list<phid> List of user PHIDs.
|
||||
*
|
||||
* @task read
|
||||
*/
|
||||
protected function readUsersFromRequest(AphrontRequest $request, $key) {
|
||||
protected function readUsersFromRequest(
|
||||
AphrontRequest $request,
|
||||
$key,
|
||||
array $allow_types = array()) {
|
||||
$list = $request->getArr($key, null);
|
||||
if ($list === null) {
|
||||
$list = $request->getStrList($key);
|
||||
|
@ -266,9 +270,14 @@ abstract class PhabricatorApplicationSearchEngine {
|
|||
|
||||
$phids = array();
|
||||
$names = array();
|
||||
$allow_types = array_fuse($allow_types);
|
||||
$user_type = PhabricatorPHIDConstants::PHID_TYPE_USER;
|
||||
foreach ($list as $item) {
|
||||
if (phid_get_type($item) == $user_type) {
|
||||
$type = phid_get_type($item);
|
||||
phlog($type);
|
||||
if ($type == $user_type) {
|
||||
$phids[] = $item;
|
||||
} else if (isset($allow_types[$type])) {
|
||||
$phids[] = $item;
|
||||
} else {
|
||||
$names[] = $item;
|
||||
|
|
|
@ -85,6 +85,11 @@ final class PhabricatorTypeaheadCommonDatasourceController
|
|||
$need_users = true;
|
||||
$need_all_users = true;
|
||||
break;
|
||||
case 'accountsorprojects':
|
||||
$need_users = true;
|
||||
$need_all_users = true;
|
||||
$need_projs = true;
|
||||
break;
|
||||
case 'arcanistprojects':
|
||||
$need_arcanist_projects = true;
|
||||
break;
|
||||
|
|
|
@ -103,6 +103,7 @@ final class AphrontFormTokenizerControl extends AphrontFormControl {
|
|||
'repositories' => pht('Type a repository name...'),
|
||||
'packages' => pht('Type a package name...'),
|
||||
'arcanistproject' => pht('Type an arc project name...'),
|
||||
'accountsorprojects' => pht('Type a user or project name...'),
|
||||
);
|
||||
|
||||
return idx($map, $request);
|
||||
|
|
Loading…
Reference in a new issue