Index: src/applications/repository/query/PhabricatorRepositoryQuery.php =================================================================== --- src/applications/repository/query/PhabricatorRepositoryQuery.php +++ src/applications/repository/query/PhabricatorRepositoryQuery.php @@ -10,6 +10,7 @@ private $uuids; private $nameContains; private $remoteURIs; + private $anyProjectPHIDs; const STATUS_OPEN = 'status-open'; const STATUS_CLOSED = 'status-closed'; @@ -76,6 +77,11 @@ return $this; } + public function withAnyProjects(array $projects) { + $this->anyProjectPHIDs = $projects; + return $this; + } + public function needCommitCounts($need_counts) { $this->needCommitCounts = $need_counts; return $this; @@ -350,6 +356,12 @@ PhabricatorRepository::TABLE_SUMMARY); } + if ($this->anyProjectPHIDs) { + $joins[] = qsprintf( + $conn_r, + 'JOIN edge e ON e.src = r.phid'); + } + return implode(' ', $joins); } @@ -398,6 +410,13 @@ $this->nameContains); } + if ($this->anyProjectPHIDs) { + $where[] = qsprintf( + $conn_r, + 'e.dst IN (%Ls)', + $this->anyProjectPHIDs); + } + $where[] = $this->buildPagingClause($conn_r); return $this->formatWhereClause($where); Index: src/applications/repository/query/PhabricatorRepositorySearchEngine.php =================================================================== --- src/applications/repository/query/PhabricatorRepositorySearchEngine.php +++ src/applications/repository/query/PhabricatorRepositorySearchEngine.php @@ -12,6 +12,7 @@ $saved->setParameter('hosted', $request->getStr('hosted')); $saved->setParameter('types', $request->getArr('types')); $saved->setParameter('name', $request->getStr('name')); + $saved->setParameter('anyProjectPHIDs', $request->getArr('anyProjects')); return $saved; } @@ -57,6 +58,11 @@ $query->withNameContains($name); } + $any_project_phids = $saved->getParameter('anyProjectPHIDs'); + if ($any_project_phids) { + $query->withAnyProjects($any_project_phids); + } + return $query; } @@ -68,6 +74,16 @@ $types = $saved_query->getParameter('types', array()); $types = array_fuse($types); $name = $saved_query->getParameter('name'); + $any_project_phids = $saved_query->getParameter('anyProjectPHIDs', array()); + + if ($any_project_phids) { + $any_project_handles = id(new PhabricatorHandleQuery()) + ->setViewer($this->requireViewer()) + ->withPHIDs($any_project_phids) + ->execute(); + } else { + $any_project_handles = array(); + } $form ->appendChild( @@ -81,6 +97,12 @@ ->setLabel(pht('Name Contains')) ->setValue($name)) ->appendChild( + id(new AphrontFormTokenizerControl()) + ->setDatasource('/typeahead/common/projects/') + ->setName('anyProjects') + ->setLabel(pht('In Any Project')) + ->setValue($any_project_handles)) + ->appendChild( id(new AphrontFormSelectControl()) ->setName('status') ->setLabel(pht('Status'))