Remove product literal strings in "pht()", part 18
[phabricator.git] / src / applications / herald / query / HeraldWebhookSearchEngine.php
blob84997b60b11455795615dfe20ebd5e71be378236
1 <?php
3 final class HeraldWebhookSearchEngine
4 extends PhabricatorApplicationSearchEngine {
6 public function getResultTypeDescription() {
7 return pht('Webhooks');
10 public function getApplicationClassName() {
11 return 'PhabricatorHeraldApplication';
14 public function newQuery() {
15 return new HeraldWebhookQuery();
18 protected function buildQueryFromParameters(array $map) {
19 $query = $this->newQuery();
21 if ($map['statuses']) {
22 $query->withStatuses($map['statuses']);
25 return $query;
28 protected function buildCustomSearchFields() {
29 return array(
30 id(new PhabricatorSearchCheckboxesField())
31 ->setKey('statuses')
32 ->setLabel(pht('Status'))
33 ->setDescription(
34 pht('Search for archived or active pastes.'))
35 ->setOptions(HeraldWebhook::getStatusDisplayNameMap()),
39 protected function getURI($path) {
40 return '/herald/webhook/'.$path;
43 protected function getBuiltinQueryNames() {
44 $names = array();
46 $names['active'] = pht('Active');
47 $names['all'] = pht('All');
49 return $names;
52 public function buildSavedQueryFromBuiltin($query_key) {
53 $query = $this->newSavedQuery();
54 $query->setQueryKey($query_key);
56 switch ($query_key) {
57 case 'all':
58 return $query;
59 case 'active':
60 return $query->setParameter(
61 'statuses',
62 array(
63 HeraldWebhook::HOOKSTATUS_FIREHOSE,
64 HeraldWebhook::HOOKSTATUS_ENABLED,
65 ));
68 return parent::buildSavedQueryFromBuiltin($query_key);
71 protected function renderResultList(
72 array $hooks,
73 PhabricatorSavedQuery $query,
74 array $handles) {
75 assert_instances_of($hooks, 'HeraldWebhook');
77 $viewer = $this->requireViewer();
79 $list = id(new PHUIObjectItemListView())
80 ->setViewer($viewer);
81 foreach ($hooks as $hook) {
82 $item = id(new PHUIObjectItemView())
83 ->setObjectName(pht('Webhook %d', $hook->getID()))
84 ->setHeader($hook->getName())
85 ->setHref($hook->getURI())
86 ->addAttribute($hook->getWebhookURI());
88 $item->addIcon($hook->getStatusIcon(), $hook->getStatusDisplayName());
90 if ($hook->isDisabled()) {
91 $item->setDisabled(true);
94 $list->addItem($item);
97 return id(new PhabricatorApplicationSearchResultView())
98 ->setObjectList($list)
99 ->setNoDataString(pht('No webhooks found.'));