3 final class PhabricatorSpacesNamespaceSearchEngine
4 extends PhabricatorApplicationSearchEngine
{
6 public function getApplicationClassName() {
7 return 'PhabricatorSpacesApplication';
10 public function getResultTypeDescription() {
14 public function newQuery() {
15 return new PhabricatorSpacesNamespaceQuery();
18 protected function buildCustomSearchFields() {
20 id(new PhabricatorSearchThreeStateField())
21 ->setLabel(pht('Active'))
25 pht('Show Only Active Spaces'),
26 pht('Hide Active Spaces')),
30 protected function buildQueryFromParameters(array $map) {
31 $query = $this->newQuery();
34 $query->withIsArchived(!$map['active']);
40 protected function getURI($path) {
41 return '/spaces/'.$path;
44 protected function getBuiltinQueryNames() {
46 'active' => pht('Active Spaces'),
47 'all' => pht('All Spaces'),
53 public function buildSavedQueryFromBuiltin($query_key) {
54 $query = $this->newSavedQuery();
55 $query->setQueryKey($query_key);
59 return $query->setParameter('active', true);
64 return parent
::buildSavedQueryFromBuiltin($query_key);
67 protected function renderResultList(
69 PhabricatorSavedQuery
$query,
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.'));
101 protected function getNewUserBody() {
102 $create_button = id(new PHUIButtonView())
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())
112 ->setTitle(pht('Welcome to %s', $app_name))
114 pht('Policy namespaces to segment object visibility throughout your '.
116 ->addAction($create_button);