3 final class PhabricatorNotificationSearchEngine
4 extends PhabricatorApplicationSearchEngine
{
6 public function getResultTypeDescription() {
7 return pht('Notifications');
10 public function getApplicationClassName() {
11 return 'PhabricatorNotificationsApplication';
14 public function buildSavedQueryFromRequest(AphrontRequest
$request) {
15 $saved = new PhabricatorSavedQuery();
19 $this->readBoolFromRequest($request, 'unread'));
24 public function buildQueryFromSavedQuery(PhabricatorSavedQuery
$saved) {
25 $query = id(new PhabricatorNotificationQuery())
26 ->withUserPHIDs(array($this->requireViewer()->getPHID()));
28 if ($saved->getParameter('unread')) {
29 $query->withUnread(true);
35 public function buildSearchForm(
36 AphrontFormView
$form,
37 PhabricatorSavedQuery
$saved) {
39 $unread = $saved->getParameter('unread');
42 id(new AphrontFormCheckboxControl())
43 ->setLabel(pht('Unread'))
47 pht('Show only unread notifications.'),
51 protected function getURI($path) {
52 return '/notification/'.$path;
55 protected function getBuiltinQueryNames() {
58 'all' => pht('All Notifications'),
59 'unread' => pht('Unread Notifications'),
65 public function buildSavedQueryFromBuiltin($query_key) {
66 $query = $this->newSavedQuery();
67 $query->setQueryKey($query_key);
73 return $query->setParameter('unread', true);
76 return parent
::buildSavedQueryFromBuiltin($query_key);
79 protected function renderResultList(
81 PhabricatorSavedQuery
$query,
83 assert_instances_of($notifications, 'PhabricatorFeedStory');
85 $viewer = $this->requireViewer();
87 $image = id(new PHUIIconView())
88 ->setIcon('fa-bell-o');
90 $button = id(new PHUIButtonView())
92 ->addSigil('workflow')
93 ->setColor(PHUIButtonView
::GREY
)
95 ->setText(pht('Mark All Read'));
97 switch ($query->getQueryKey()) {
99 $header = pht('Unread Notifications');
100 $no_data = pht('You have no unread notifications.');
103 $header = pht('Notifications');
104 $no_data = pht('You have no notifications.');
108 $clear_uri = id(new PhutilURI('/notification/clear/'));
109 if ($notifications) {
110 $builder = id(new PhabricatorNotificationBuilder($notifications))
113 $view = $builder->buildView();
114 $clear_uri->replaceQueryParam(
116 head($notifications)->getChronologicalKey());
118 $view = phutil_tag_div(
119 'phabricator-notification no-notifications',
121 $button->setDisabled(true);
123 $button->setHref((string)$clear_uri);
125 $view = id(new PHUIBoxView())
126 ->addPadding(PHUI
::PADDING_MEDIUM
)
127 ->addClass('phabricator-notification-list')
128 ->appendChild($view);
130 $result = new PhabricatorApplicationSearchResultView();
131 $result->addAction($button);
132 $result->setContent($view);