1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-07 12:28:28 +01:00

Add a list of all notifications

Summary: Add a "View All Notifications" link and page.

Test Plan: Viewed all notifications

Reviewers: jungejason, vrana

Reviewed By: jungejason

CC: aran

Maniphest Tasks: T974

Differential Revision: https://secure.phabricator.com/D2780
This commit is contained in:
epriestley 2012-06-18 14:07:38 -07:00
parent 656c82f9b8
commit 8cd0997965
6 changed files with 81 additions and 13 deletions

View file

@ -744,6 +744,7 @@ phutil_register_library_map(array(
'PhabricatorNotificationBuilder' => 'applications/notification/builder/PhabricatorNotificationBuilder.php', 'PhabricatorNotificationBuilder' => 'applications/notification/builder/PhabricatorNotificationBuilder.php',
'PhabricatorNotificationController' => 'applications/notification/controller/PhabricatorNotificationController.php', 'PhabricatorNotificationController' => 'applications/notification/controller/PhabricatorNotificationController.php',
'PhabricatorNotificationIndividualController' => 'applications/notification/controller/PhabricatorNotificationIndividualController.php', 'PhabricatorNotificationIndividualController' => 'applications/notification/controller/PhabricatorNotificationIndividualController.php',
'PhabricatorNotificationListController' => 'applications/notification/controller/PhabricatorNotificationListController.php',
'PhabricatorNotificationPanelController' => 'applications/notification/controller/PhabricatorNotificationPanelController.php', 'PhabricatorNotificationPanelController' => 'applications/notification/controller/PhabricatorNotificationPanelController.php',
'PhabricatorNotificationQuery' => 'applications/notification/PhabricatorNotificationQuery.php', 'PhabricatorNotificationQuery' => 'applications/notification/PhabricatorNotificationQuery.php',
'PhabricatorNotificationStatusController' => 'applications/notification/controller/PhabricatorNotificationStatusController.php', 'PhabricatorNotificationStatusController' => 'applications/notification/controller/PhabricatorNotificationStatusController.php',
@ -1715,7 +1716,9 @@ phutil_register_library_map(array(
'PhabricatorMySQLFileStorageEngine' => 'PhabricatorFileStorageEngine', 'PhabricatorMySQLFileStorageEngine' => 'PhabricatorFileStorageEngine',
'PhabricatorNotificationController' => 'PhabricatorController', 'PhabricatorNotificationController' => 'PhabricatorController',
'PhabricatorNotificationIndividualController' => 'PhabricatorNotificationController', 'PhabricatorNotificationIndividualController' => 'PhabricatorNotificationController',
'PhabricatorNotificationListController' => 'PhabricatorNotificationController',
'PhabricatorNotificationPanelController' => 'PhabricatorNotificationController', 'PhabricatorNotificationPanelController' => 'PhabricatorNotificationController',
'PhabricatorNotificationQuery' => 'PhabricatorOffsetPagedQuery',
'PhabricatorNotificationStatusController' => 'PhabricatorNotificationController', 'PhabricatorNotificationStatusController' => 'PhabricatorNotificationController',
'PhabricatorNotificationStoryView' => 'PhabricatorNotificationView', 'PhabricatorNotificationStoryView' => 'PhabricatorNotificationView',
'PhabricatorNotificationView' => 'AphrontView', 'PhabricatorNotificationView' => 'AphrontView',

View file

@ -427,6 +427,7 @@ class AphrontDefaultApplicationConfiguration
), ),
'/notification/' => array( '/notification/' => array(
'' => 'PhabricatorNotificationListController',
'panel/' => 'PhabricatorNotificationPanelController', 'panel/' => 'PhabricatorNotificationPanelController',
'individual/' => 'PhabricatorNotificationIndividualController', 'individual/' => 'PhabricatorNotificationIndividualController',
'status/' => 'PhabricatorNotificationStatusController', 'status/' => 'PhabricatorNotificationStatusController',

View file

@ -16,29 +16,20 @@
* limitations under the License. * limitations under the License.
*/ */
final class PhabricatorNotificationQuery { final class PhabricatorNotificationQuery extends PhabricatorOffsetPagedQuery {
private $limit = 100;
private $userPHID; private $userPHID;
public function setLimit($limit) {
$this->limit = $limit;
return $this;
}
public function setUserPHID($user_phid) { public function setUserPHID($user_phid) {
$this->userPHID = $user_phid; $this->userPHID = $user_phid;
return $this; return $this;
} }
public function execute() { public function execute() {
if (!$this->userPHID) { if (!$this->userPHID) {
throw new Exception("Call setUser() before executing the query"); throw new Exception("Call setUser() before executing the query");
} }
//TODO throw an exception if no user
$story_table = new PhabricatorFeedStoryData(); $story_table = new PhabricatorFeedStoryData();
$notification_table = new PhabricatorFeedStoryNotification(); $notification_table = new PhabricatorFeedStoryNotification();
@ -49,12 +40,12 @@ final class PhabricatorNotificationQuery {
"SELECT story.*, notif.hasViewed FROM %T notif "SELECT story.*, notif.hasViewed FROM %T notif
JOIN %T story ON notif.chronologicalKey = story.chronologicalKey JOIN %T story ON notif.chronologicalKey = story.chronologicalKey
WHERE notif.userPHID = %s WHERE notif.userPHID = %s
ORDER BY notif.chronologicalKey desc ORDER BY notif.chronologicalKey DESC
LIMIT %d", %Q",
$notification_table->getTableName(), $notification_table->getTableName(),
$story_table->getTableName(), $story_table->getTableName(),
$this->userPHID, $this->userPHID,
$this->limit); $this->buildLimitClause($conn));
$viewed_map = ipull($data, 'hasViewed', 'chronologicalKey'); $viewed_map = ipull($data, 'hasViewed', 'chronologicalKey');
$data = $story_table->loadAllFromArray($data); $data = $story_table->loadAllFromArray($data);

View file

@ -0,0 +1,56 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
final class PhabricatorNotificationListController
extends PhabricatorNotificationController {
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$pager = new AphrontPagerView();
$pager->setURI($request->getRequestURI(), 'offset');
$pager->setOffset($request->getInt('offset'));
$query = new PhabricatorNotificationQuery();
$query->setUserPHID($user->getPHID());
$notifications = $query->executeWithPager($pager);
if ($notifications) {
$builder = new PhabricatorNotificationBuilder($notifications);
$view = $builder->buildView();
} else {
$view =
'<div class="phabricator-notification no-notifications">'.
'You have no notifications.'.
'</div>';
}
$panel = new AphrontPanelView();
$panel->setHeader('Notifications');
$panel->appendChild($view);
$panel->appendChild($pager);
return $this->buildStandardPageResponse(
$panel,
array(
'title' => 'Notifications',
));
}
}

View file

@ -48,6 +48,16 @@ final class PhabricatorNotificationPanelController
'</div>'; '</div>';
} }
$content .=
'<div class="phabricator-notification view-all-notifications">'.
phutil_render_tag(
'a',
array(
'href' => '/notification/',
),
'View All Notifications').
'</div>';
$json = array( $json = array(
'content' => $content, 'content' => $content,
'number' => $num_unconsumed, 'number' => $num_unconsumed,

View file

@ -310,3 +310,10 @@ a.handle-disabled {
.phabricator-notification-unread { .phabricator-notification-unread {
background: #aacfef; background: #aacfef;
} }
.view-all-notifications {
text-align: center;
font-weight: bold;
background: #eeeeee;
border-top: 1px solid #dddddd;
}