1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Allow repositories to be filtered by type

Summary: Allows the user to query for repos by VCS type.

Test Plan: See screenshot.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D7038
This commit is contained in:
epriestley 2013-09-19 11:56:48 -07:00
parent 5251e2f14d
commit 8651e5feba
2 changed files with 38 additions and 1 deletions

View file

@ -6,6 +6,7 @@ final class PhabricatorRepositoryQuery
private $ids;
private $phids;
private $callsigns;
private $types;
const STATUS_OPEN = 'status-open';
const STATUS_CLOSED = 'status-closed';
@ -41,6 +42,11 @@ final class PhabricatorRepositoryQuery
return $this;
}
public function withTypes(array $types) {
$this->types = $types;
return $this;
}
public function needCommitCounts($need_counts) {
$this->needCommitCounts = $need_counts;
return $this;
@ -284,6 +290,14 @@ final class PhabricatorRepositoryQuery
$this->callsigns);
}
// TODO: Add a key for this.
if ($this->types) {
$where[] = qsprintf(
$conn_r,
'r.versionControlSystem IN (%Ls)',
$this->types);
}
$where[] = $this->buildPagingClause($conn_r);
return $this->formatWhereClause($where);

View file

@ -9,6 +9,7 @@ final class PhabricatorRepositorySearchEngine
$saved->setParameter('callsigns', $request->getStrList('callsigns'));
$saved->setParameter('status', $request->getStr('status'));
$saved->setParameter('order', $request->getStr('order'));
$saved->setParameter('types', $request->getArr('types'));
return $saved;
}
@ -37,6 +38,11 @@ final class PhabricatorRepositorySearchEngine
$query->setOrder(head($this->getOrderValues()));
}
$types = $saved->getParameter('types');
if ($types) {
$query->withTypes($types);
}
return $query;
}
@ -45,6 +51,8 @@ final class PhabricatorRepositorySearchEngine
PhabricatorSavedQuery $saved_query) {
$callsigns = $saved_query->getParameter('callsigns', array());
$types = $saved_query->getParameter('types', array());
$types = array_fuse($types);
$form
->appendChild(
@ -57,7 +65,22 @@ final class PhabricatorRepositorySearchEngine
->setName('status')
->setLabel(pht('Status'))
->setValue($saved_query->getParameter('status'))
->setOptions($this->getStatusOptions()))
->setOptions($this->getStatusOptions()));
$type_control = id(new AphrontFormCheckboxControl())
->setLabel(pht('Types'));
$all_types = PhabricatorRepositoryType::getAllRepositoryTypes();
foreach ($all_types as $key => $name) {
$type_control->addCheckbox(
'types[]',
$key,
$name,
isset($types[$key]));
}
$form
->appendChild($type_control)
->appendChild(
id(new AphrontFormSelectControl())
->setName('order')