1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 21:40:55 +01:00

Search repos by Project

Summary:
Ref T3102

In diffusion, add "In Any Project" to search options.

Test Plan: use it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Maniphest Tasks: T3102

Differential Revision: https://secure.phabricator.com/D8113
This commit is contained in:
Aviv Eyal 2014-01-30 11:45:43 -08:00 committed by epriestley
parent 73924dfa18
commit 5d1489a3ce
2 changed files with 41 additions and 0 deletions

View file

@ -10,6 +10,7 @@ final class PhabricatorRepositoryQuery
private $uuids; private $uuids;
private $nameContains; private $nameContains;
private $remoteURIs; private $remoteURIs;
private $anyProjectPHIDs;
const STATUS_OPEN = 'status-open'; const STATUS_OPEN = 'status-open';
const STATUS_CLOSED = 'status-closed'; const STATUS_CLOSED = 'status-closed';
@ -76,6 +77,11 @@ final class PhabricatorRepositoryQuery
return $this; return $this;
} }
public function withAnyProjects(array $projects) {
$this->anyProjectPHIDs = $projects;
return $this;
}
public function needCommitCounts($need_counts) { public function needCommitCounts($need_counts) {
$this->needCommitCounts = $need_counts; $this->needCommitCounts = $need_counts;
return $this; return $this;
@ -350,6 +356,12 @@ final class PhabricatorRepositoryQuery
PhabricatorRepository::TABLE_SUMMARY); PhabricatorRepository::TABLE_SUMMARY);
} }
if ($this->anyProjectPHIDs) {
$joins[] = qsprintf(
$conn_r,
'JOIN edge e ON e.src = r.phid');
}
return implode(' ', $joins); return implode(' ', $joins);
} }
@ -398,6 +410,13 @@ final class PhabricatorRepositoryQuery
$this->nameContains); $this->nameContains);
} }
if ($this->anyProjectPHIDs) {
$where[] = qsprintf(
$conn_r,
'e.dst IN (%Ls)',
$this->anyProjectPHIDs);
}
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn_r);
return $this->formatWhereClause($where); return $this->formatWhereClause($where);

View file

@ -12,6 +12,7 @@ final class PhabricatorRepositorySearchEngine
$saved->setParameter('hosted', $request->getStr('hosted')); $saved->setParameter('hosted', $request->getStr('hosted'));
$saved->setParameter('types', $request->getArr('types')); $saved->setParameter('types', $request->getArr('types'));
$saved->setParameter('name', $request->getStr('name')); $saved->setParameter('name', $request->getStr('name'));
$saved->setParameter('anyProjectPHIDs', $request->getArr('anyProjects'));
return $saved; return $saved;
} }
@ -57,6 +58,11 @@ final class PhabricatorRepositorySearchEngine
$query->withNameContains($name); $query->withNameContains($name);
} }
$any_project_phids = $saved->getParameter('anyProjectPHIDs');
if ($any_project_phids) {
$query->withAnyProjects($any_project_phids);
}
return $query; return $query;
} }
@ -68,6 +74,16 @@ final class PhabricatorRepositorySearchEngine
$types = $saved_query->getParameter('types', array()); $types = $saved_query->getParameter('types', array());
$types = array_fuse($types); $types = array_fuse($types);
$name = $saved_query->getParameter('name'); $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 $form
->appendChild( ->appendChild(
@ -80,6 +96,12 @@ final class PhabricatorRepositorySearchEngine
->setName('name') ->setName('name')
->setLabel(pht('Name Contains')) ->setLabel(pht('Name Contains'))
->setValue($name)) ->setValue($name))
->appendChild(
id(new AphrontFormTokenizerControl())
->setDatasource('/typeahead/common/projects/')
->setName('anyProjects')
->setLabel(pht('In Any Project'))
->setValue($any_project_handles))
->appendChild( ->appendChild(
id(new AphrontFormSelectControl()) id(new AphrontFormSelectControl())
->setName('status') ->setName('status')