Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / spaces / query / PhabricatorSpacesNamespaceSearchEngine.php
blob3880143a2457b7ca4d5f7e4a6b71f6425a59d7e8
1 <?php
3 final class PhabricatorSpacesNamespaceSearchEngine
4 extends PhabricatorApplicationSearchEngine {
6 public function getApplicationClassName() {
7 return 'PhabricatorSpacesApplication';
10 public function getResultTypeDescription() {
11 return pht('Spaces');
14 public function newQuery() {
15 return new PhabricatorSpacesNamespaceQuery();
18 protected function buildCustomSearchFields() {
19 return array(
20 id(new PhabricatorSearchThreeStateField())
21 ->setLabel(pht('Active'))
22 ->setKey('active')
23 ->setOptions(
24 pht('(Show All)'),
25 pht('Show Only Active Spaces'),
26 pht('Hide Active Spaces')),
30 protected function buildQueryFromParameters(array $map) {
31 $query = $this->newQuery();
33 if ($map['active']) {
34 $query->withIsArchived(!$map['active']);
37 return $query;
40 protected function getURI($path) {
41 return '/spaces/'.$path;
44 protected function getBuiltinQueryNames() {
45 $names = array(
46 'active' => pht('Active Spaces'),
47 'all' => pht('All Spaces'),
50 return $names;
53 public function buildSavedQueryFromBuiltin($query_key) {
54 $query = $this->newSavedQuery();
55 $query->setQueryKey($query_key);
57 switch ($query_key) {
58 case 'active':
59 return $query->setParameter('active', true);
60 case 'all':
61 return $query;
64 return parent::buildSavedQueryFromBuiltin($query_key);
67 protected function renderResultList(
68 array $spaces,
69 PhabricatorSavedQuery $query,
70 array $handles) {
71 assert_instances_of($spaces, 'PhabricatorSpacesNamespace');
73 $viewer = $this->requireViewer();
75 $list = new PHUIObjectItemListView();
76 $list->setUser($viewer);
77 foreach ($spaces as $space) {
78 $item = id(new PHUIObjectItemView())
79 ->setObjectName($space->getMonogram())
80 ->setHeader($space->getNamespaceName())
81 ->setHref('/'.$space->getMonogram());
83 if ($space->getIsDefaultNamespace()) {
84 $item->addIcon('fa-certificate', pht('Default Space'));
87 if ($space->getIsArchived()) {
88 $item->setDisabled(true);
91 $list->addItem($item);
94 $result = new PhabricatorApplicationSearchResultView();
95 $result->setObjectList($list);
96 $result->setNoDataString(pht('No spaces found.'));
98 return $result;
101 protected function getNewUserBody() {
102 $create_button = id(new PHUIButtonView())
103 ->setTag('a')
104 ->setText(pht('Create a Space'))
105 ->setHref('/spaces/create/')
106 ->setColor(PHUIButtonView::GREEN);
108 $icon = $this->getApplication()->getIcon();
109 $app_name = $this->getApplication()->getName();
110 $view = id(new PHUIBigInfoView())
111 ->setIcon($icon)
112 ->setTitle(pht('Welcome to %s', $app_name))
113 ->setDescription(
114 pht('Policy namespaces to segment object visibility throughout your '.
115 'instance.'))
116 ->addAction($create_button);
118 return $view;