From 083cd5fd9d690b30723a2d996462a29c884c1ece Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 20 Jun 2012 13:51:19 -0700 Subject: [PATCH] Add a "Mark All Read" button for notifications Summary: Adds a button to mark everything as read. Test Plan: Clicked button. Reviewers: btrahan, jungejason, vrana Reviewed By: btrahan CC: aran Maniphest Tasks: T974 Differential Revision: https://secure.phabricator.com/D2812 --- src/__phutil_library_map__.php | 2 + ...AphrontDefaultApplicationConfiguration.php | 1 + ...PhabricatorNotificationClearController.php | 50 +++++++++++++++++++ .../PhabricatorNotificationListController.php | 9 ++++ 4 files changed, 62 insertions(+) create mode 100644 src/applications/notification/controller/PhabricatorNotificationClearController.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 68a3557541..4be33f8125 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -746,6 +746,7 @@ phutil_register_library_map(array( 'PhabricatorMustVerifyEmailController' => 'applications/auth/controller/PhabricatorMustVerifyEmailController.php', 'PhabricatorMySQLFileStorageEngine' => 'applications/files/engine/PhabricatorMySQLFileStorageEngine.php', 'PhabricatorNotificationBuilder' => 'applications/notification/builder/PhabricatorNotificationBuilder.php', + 'PhabricatorNotificationClearController' => 'applications/notification/controller/PhabricatorNotificationClearController.php', 'PhabricatorNotificationController' => 'applications/notification/controller/PhabricatorNotificationController.php', 'PhabricatorNotificationIndividualController' => 'applications/notification/controller/PhabricatorNotificationIndividualController.php', 'PhabricatorNotificationListController' => 'applications/notification/controller/PhabricatorNotificationListController.php', @@ -1722,6 +1723,7 @@ phutil_register_library_map(array( 'PhabricatorMetaMTAWorker' => 'PhabricatorWorker', 'PhabricatorMustVerifyEmailController' => 'PhabricatorAuthController', 'PhabricatorMySQLFileStorageEngine' => 'PhabricatorFileStorageEngine', + 'PhabricatorNotificationClearController' => 'PhabricatorNotificationController', 'PhabricatorNotificationController' => 'PhabricatorController', 'PhabricatorNotificationIndividualController' => 'PhabricatorNotificationController', 'PhabricatorNotificationListController' => 'PhabricatorNotificationController', diff --git a/src/aphront/configuration/AphrontDefaultApplicationConfiguration.php b/src/aphront/configuration/AphrontDefaultApplicationConfiguration.php index 0629bc7fd7..4f56a77cfe 100644 --- a/src/aphront/configuration/AphrontDefaultApplicationConfiguration.php +++ b/src/aphront/configuration/AphrontDefaultApplicationConfiguration.php @@ -431,6 +431,7 @@ class AphrontDefaultApplicationConfiguration 'panel/' => 'PhabricatorNotificationPanelController', 'individual/' => 'PhabricatorNotificationIndividualController', 'status/' => 'PhabricatorNotificationStatusController', + 'clear/' => 'PhabricatorNotificationClearController', ), '/flag/' => array( diff --git a/src/applications/notification/controller/PhabricatorNotificationClearController.php b/src/applications/notification/controller/PhabricatorNotificationClearController.php new file mode 100644 index 0000000000..070972974c --- /dev/null +++ b/src/applications/notification/controller/PhabricatorNotificationClearController.php @@ -0,0 +1,50 @@ +getRequest(); + $user = $request->getUser(); + + if ($request->isDialogFormPost()) { + $table = new PhabricatorFeedStoryNotification(); + + queryfx( + $table->establishConnection('w'), + 'UPDATE %T SET hasViewed = 1 WHERE + userPHID = %s AND hasViewed = 0', + $table->getTableName(), + $user->getPHID()); + + return id(new AphrontReloadResponse()) + ->setURI('/notification/'); + } + + $dialog = new AphrontDialogView(); + $dialog->setUser($user); + $dialog->setTitle('Really mark all notifications as read?'); + $dialog->appendChild( + "You can't ignore your problems forever, you know."); + $dialog->addCancelButton('/notification/'); + $dialog->addSubmitButton('Mark All Read'); + + return id(new AphrontDialogResponse())->setDialog($dialog); + } +} diff --git a/src/applications/notification/controller/PhabricatorNotificationListController.php b/src/applications/notification/controller/PhabricatorNotificationListController.php index b863b4bab0..4b71489ae7 100644 --- a/src/applications/notification/controller/PhabricatorNotificationListController.php +++ b/src/applications/notification/controller/PhabricatorNotificationListController.php @@ -43,6 +43,15 @@ final class PhabricatorNotificationListController $panel = new AphrontPanelView(); $panel->setHeader('Notifications'); + $panel->addButton( + javelin_render_tag( + 'a', + array( + 'href' => '/notification/clear/', + 'class' => 'button', + 'sigil' => 'workflow', + ), + 'Mark All Read')); $panel->appendChild($view); $panel->appendChild($pager);