Improve notification list view

Summary:
  - Provide a filter to show just unread notifications.
  - Visually show which notifications are unread.
  - Style tweaks to make notifications more readable.

Test Plan: {F13494}

Reviewers: btrahan, jungejason

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D2883
This commit is contained in:
epriestley
2012-06-28 13:59:50 -07:00
parent 0c321d8176
commit 1e3cd8afa8
5 changed files with 107 additions and 30 deletions

View File

@@ -19,16 +19,41 @@
final class PhabricatorNotificationListController
extends PhabricatorNotificationController {
private $filter;
public function willProcessRequest(array $data) {
$this->filter = idx($data, 'filter');
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI('/notification/'));
$nav->addFilter('all', 'All Notifications');
$nav->addFilter('unread', 'Unread Notifications');
$filter = $nav->selectFilter($this->filter, 'all');
$pager = new AphrontPagerView();
$pager->setURI($request->getRequestURI(), 'offset');
$pager->setOffset($request->getInt('offset'));
$query = new PhabricatorNotificationQuery();
$query->setUserPHID($user->getPHID());
switch ($filter) {
case 'unread':
$query->withUnread(true);
$header = pht('Unread Notifications');
$no_data = pht('You have no unread notifications.');
break;
default:
$header = pht('Notifications');
$no_data = pht('You have no notifications.');
break;
}
$notifications = $query->executeWithPager($pager);
if ($notifications) {
@@ -37,12 +62,19 @@ final class PhabricatorNotificationListController
} else {
$view =
'<div class="phabricator-notification no-notifications">'.
'You have no notifications.'.
$no_data.
'</div>';
}
$view = array(
'<div class="phabricator-notification-list">',
$view,
'</div>',
);
$panel = new AphrontPanelView();
$panel->setHeader('Notifications');
$panel->setHeader($header);
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
$panel->addButton(
javelin_render_tag(
'a',
@@ -55,8 +87,10 @@ final class PhabricatorNotificationListController
$panel->appendChild($view);
$panel->appendChild($pager);
$nav->appendChild($panel);
return $this->buildStandardPageResponse(
$panel,
$nav,
array(
'title' => 'Notifications',
));