2011-03-07 15:13:36 -08:00
|
|
|
<?php
|
|
|
|
|
|
2014-05-08 10:08:37 -07:00
|
|
|
final class DiffusionRepositoryListController extends DiffusionController {
|
2011-03-07 15:13:36 -08:00
|
|
|
|
2013-09-10 15:26:08 -07:00
|
|
|
private $queryKey;
|
2011-03-31 00:33:44 -07:00
|
|
|
|
2013-09-10 15:26:08 -07:00
|
|
|
public function shouldAllowPublic() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2011-03-31 00:33:44 -07:00
|
|
|
|
2013-09-10 15:26:08 -07:00
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
|
$this->queryKey = idx($data, 'queryKey');
|
|
|
|
|
}
|
2013-05-11 08:23:19 -07:00
|
|
|
|
2013-09-10 15:26:08 -07:00
|
|
|
public function processRequest() {
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
|
$controller = id(new PhabricatorApplicationSearchController($request))
|
|
|
|
|
->setQueryKey($this->queryKey)
|
|
|
|
|
->setSearchEngine(new PhabricatorRepositorySearchEngine())
|
|
|
|
|
->setNavigation($this->buildSideNavView());
|
2013-05-11 08:23:19 -07:00
|
|
|
|
2013-09-10 15:26:08 -07:00
|
|
|
return $this->delegateToController($controller);
|
|
|
|
|
}
|
2011-03-07 15:13:36 -08:00
|
|
|
|
2013-09-10 15:26:08 -07:00
|
|
|
public function buildSideNavView($for_app = false) {
|
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
2011-03-07 15:13:36 -08:00
|
|
|
|
2013-09-10 15:26:08 -07:00
|
|
|
$nav = new AphrontSideNavFilterView();
|
|
|
|
|
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
|
2011-03-12 16:17:34 -08:00
|
|
|
|
2013-09-10 15:26:08 -07:00
|
|
|
id(new PhabricatorRepositorySearchEngine())
|
|
|
|
|
->setViewer($viewer)
|
|
|
|
|
->addNavigationItems($nav->getMenu());
|
|
|
|
|
|
|
|
|
|
$nav->selectFilter(null);
|
|
|
|
|
|
|
|
|
|
return $nav;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-25 17:46:08 -07:00
|
|
|
public function buildApplicationCrumbs() {
|
|
|
|
|
$crumbs = parent::buildApplicationCrumbs();
|
|
|
|
|
|
|
|
|
|
$can_create = $this->hasApplicationCapability(
|
|
|
|
|
DiffusionCapabilityCreateRepositories::CAPABILITY);
|
|
|
|
|
|
|
|
|
|
$crumbs->addAction(
|
|
|
|
|
id(new PHUIListItemView())
|
2013-11-01 17:39:35 -07:00
|
|
|
->setName(pht('New Repository'))
|
|
|
|
|
->setHref($this->getApplicationURI('new/'))
|
2013-10-25 17:46:08 -07:00
|
|
|
->setDisabled(!$can_create)
|
2014-05-12 10:08:32 -07:00
|
|
|
->setIcon('fa-plus-square'));
|
2013-10-25 17:46:08 -07:00
|
|
|
|
|
|
|
|
return $crumbs;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-07 15:13:36 -08:00
|
|
|
}
|