mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 20:40:56 +01:00
Add Hosted/Remote filtering to Diffusion
Test Plan: Did searches in Diffusion using all 3 Hosted values Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley CC: Korvin, epriestley, aran Differential Revision: https://secure.phabricator.com/D7927
This commit is contained in:
parent
5417f91b77
commit
2ee4507486
2 changed files with 57 additions and 1 deletions
|
@ -21,6 +21,11 @@ final class PhabricatorRepositoryQuery
|
||||||
const ORDER_NAME = 'order-name';
|
const ORDER_NAME = 'order-name';
|
||||||
private $order = self::ORDER_CREATED;
|
private $order = self::ORDER_CREATED;
|
||||||
|
|
||||||
|
const HOSTED_PHABRICATOR = 'hosted-phab';
|
||||||
|
const HOSTED_REMOTE = 'hosted-remote';
|
||||||
|
const HOSTED_ALL = 'hosted-all';
|
||||||
|
private $hosted = self::HOSTED_ALL;
|
||||||
|
|
||||||
private $needMostRecentCommits;
|
private $needMostRecentCommits;
|
||||||
private $needCommitCounts;
|
private $needCommitCounts;
|
||||||
private $needProjectPHIDs;
|
private $needProjectPHIDs;
|
||||||
|
@ -45,6 +50,11 @@ final class PhabricatorRepositoryQuery
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function withHosted($hosted) {
|
||||||
|
$this->hosted = $hosted;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function withTypes(array $types) {
|
public function withTypes(array $types) {
|
||||||
$this->types = $types;
|
$this->types = $types;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -148,6 +158,24 @@ final class PhabricatorRepositoryQuery
|
||||||
default:
|
default:
|
||||||
throw new Exception("Unknown status '{$status}'!");
|
throw new Exception("Unknown status '{$status}'!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$hosted = $this->hosted;
|
||||||
|
switch ($hosted) {
|
||||||
|
case self::HOSTED_PHABRICATOR:
|
||||||
|
if (!$repo->isHosted()) {
|
||||||
|
unset($repositories[$key]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case self::HOSTED_REMOTE:
|
||||||
|
if ($repo->isHosted()) {
|
||||||
|
unset($repositories[$key]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case self::HOSTED_ALL:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Exception("Uknown hosted failed '${hosted}'!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $repositories;
|
return $repositories;
|
||||||
|
|
|
@ -9,6 +9,7 @@ final class PhabricatorRepositorySearchEngine
|
||||||
$saved->setParameter('callsigns', $request->getStrList('callsigns'));
|
$saved->setParameter('callsigns', $request->getStrList('callsigns'));
|
||||||
$saved->setParameter('status', $request->getStr('status'));
|
$saved->setParameter('status', $request->getStr('status'));
|
||||||
$saved->setParameter('order', $request->getStr('order'));
|
$saved->setParameter('order', $request->getStr('order'));
|
||||||
|
$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'));
|
||||||
|
|
||||||
|
@ -40,6 +41,12 @@ final class PhabricatorRepositorySearchEngine
|
||||||
$query->setOrder(head($this->getOrderValues()));
|
$query->setOrder(head($this->getOrderValues()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$hosted = $saved->getParameter('hosted');
|
||||||
|
$hosted = idx($this->getHostedValues(), $hosted);
|
||||||
|
if ($hosted) {
|
||||||
|
$query->withHosted($hosted);
|
||||||
|
}
|
||||||
|
|
||||||
$types = $saved->getParameter('types');
|
$types = $saved->getParameter('types');
|
||||||
if ($types) {
|
if ($types) {
|
||||||
$query->withTypes($types);
|
$query->withTypes($types);
|
||||||
|
@ -78,7 +85,13 @@ final class PhabricatorRepositorySearchEngine
|
||||||
->setName('status')
|
->setName('status')
|
||||||
->setLabel(pht('Status'))
|
->setLabel(pht('Status'))
|
||||||
->setValue($saved_query->getParameter('status'))
|
->setValue($saved_query->getParameter('status'))
|
||||||
->setOptions($this->getStatusOptions()));
|
->setOptions($this->getStatusOptions()))
|
||||||
|
->appendChild(
|
||||||
|
id(new AphrontFormSelectControl())
|
||||||
|
->setName('hosted')
|
||||||
|
->setLabel(pht('Hosted'))
|
||||||
|
->setValue($saved_query->getParameter('hosted'))
|
||||||
|
->setOptions($this->getHostedOptions()));
|
||||||
|
|
||||||
$type_control = id(new AphrontFormCheckboxControl())
|
$type_control = id(new AphrontFormCheckboxControl())
|
||||||
->setLabel(pht('Types'));
|
->setLabel(pht('Types'));
|
||||||
|
@ -164,5 +177,20 @@ final class PhabricatorRepositorySearchEngine
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getHostedOptions() {
|
||||||
|
return array(
|
||||||
|
'' => pht('Hosted and Remote Repositories'),
|
||||||
|
'phabricator' => pht('Hosted Repositories'),
|
||||||
|
'remote' => pht('Remote Repositories'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getHostedValues() {
|
||||||
|
return array(
|
||||||
|
'' => PhabricatorRepositoryQuery::HOSTED_ALL,
|
||||||
|
'phabricator' => PhabricatorRepositoryQuery::HOSTED_PHABRICATOR,
|
||||||
|
'remote' => PhabricatorRepositoryQuery::HOSTED_REMOTE,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue