mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-31 08:58:20 +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:
parent
656c82f9b8
commit
8cd0997965
6 changed files with 81 additions and 13 deletions
|
@ -744,6 +744,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorNotificationBuilder' => 'applications/notification/builder/PhabricatorNotificationBuilder.php',
|
||||
'PhabricatorNotificationController' => 'applications/notification/controller/PhabricatorNotificationController.php',
|
||||
'PhabricatorNotificationIndividualController' => 'applications/notification/controller/PhabricatorNotificationIndividualController.php',
|
||||
'PhabricatorNotificationListController' => 'applications/notification/controller/PhabricatorNotificationListController.php',
|
||||
'PhabricatorNotificationPanelController' => 'applications/notification/controller/PhabricatorNotificationPanelController.php',
|
||||
'PhabricatorNotificationQuery' => 'applications/notification/PhabricatorNotificationQuery.php',
|
||||
'PhabricatorNotificationStatusController' => 'applications/notification/controller/PhabricatorNotificationStatusController.php',
|
||||
|
@ -1715,7 +1716,9 @@ phutil_register_library_map(array(
|
|||
'PhabricatorMySQLFileStorageEngine' => 'PhabricatorFileStorageEngine',
|
||||
'PhabricatorNotificationController' => 'PhabricatorController',
|
||||
'PhabricatorNotificationIndividualController' => 'PhabricatorNotificationController',
|
||||
'PhabricatorNotificationListController' => 'PhabricatorNotificationController',
|
||||
'PhabricatorNotificationPanelController' => 'PhabricatorNotificationController',
|
||||
'PhabricatorNotificationQuery' => 'PhabricatorOffsetPagedQuery',
|
||||
'PhabricatorNotificationStatusController' => 'PhabricatorNotificationController',
|
||||
'PhabricatorNotificationStoryView' => 'PhabricatorNotificationView',
|
||||
'PhabricatorNotificationView' => 'AphrontView',
|
||||
|
|
|
@ -427,6 +427,7 @@ class AphrontDefaultApplicationConfiguration
|
|||
),
|
||||
|
||||
'/notification/' => array(
|
||||
'' => 'PhabricatorNotificationListController',
|
||||
'panel/' => 'PhabricatorNotificationPanelController',
|
||||
'individual/' => 'PhabricatorNotificationIndividualController',
|
||||
'status/' => 'PhabricatorNotificationStatusController',
|
||||
|
|
|
@ -16,29 +16,20 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
final class PhabricatorNotificationQuery {
|
||||
final class PhabricatorNotificationQuery extends PhabricatorOffsetPagedQuery {
|
||||
|
||||
private $limit = 100;
|
||||
private $userPHID;
|
||||
|
||||
|
||||
public function setLimit($limit) {
|
||||
$this->limit = $limit;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUserPHID($user_phid) {
|
||||
$this->userPHID = $user_phid;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function execute() {
|
||||
if (!$this->userPHID) {
|
||||
throw new Exception("Call setUser() before executing the query");
|
||||
}
|
||||
|
||||
//TODO throw an exception if no user
|
||||
$story_table = new PhabricatorFeedStoryData();
|
||||
$notification_table = new PhabricatorFeedStoryNotification();
|
||||
|
||||
|
@ -49,12 +40,12 @@ final class PhabricatorNotificationQuery {
|
|||
"SELECT story.*, notif.hasViewed FROM %T notif
|
||||
JOIN %T story ON notif.chronologicalKey = story.chronologicalKey
|
||||
WHERE notif.userPHID = %s
|
||||
ORDER BY notif.chronologicalKey desc
|
||||
LIMIT %d",
|
||||
ORDER BY notif.chronologicalKey DESC
|
||||
%Q",
|
||||
$notification_table->getTableName(),
|
||||
$story_table->getTableName(),
|
||||
$this->userPHID,
|
||||
$this->limit);
|
||||
$this->buildLimitClause($conn));
|
||||
|
||||
$viewed_map = ipull($data, 'hasViewed', 'chronologicalKey');
|
||||
$data = $story_table->loadAllFromArray($data);
|
||||
|
|
|
@ -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',
|
||||
));
|
||||
}
|
||||
|
||||
}
|
|
@ -48,6 +48,16 @@ final class PhabricatorNotificationPanelController
|
|||
'</div>';
|
||||
}
|
||||
|
||||
$content .=
|
||||
'<div class="phabricator-notification view-all-notifications">'.
|
||||
phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '/notification/',
|
||||
),
|
||||
'View All Notifications').
|
||||
'</div>';
|
||||
|
||||
$json = array(
|
||||
'content' => $content,
|
||||
'number' => $num_unconsumed,
|
||||
|
|
|
@ -310,3 +310,10 @@ a.handle-disabled {
|
|||
.phabricator-notification-unread {
|
||||
background: #aacfef;
|
||||
}
|
||||
|
||||
.view-all-notifications {
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
background: #eeeeee;
|
||||
border-top: 1px solid #dddddd;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue