From 26599e61920095ad77126fdbfc66595ab9085470 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 27 Feb 2012 09:48:18 -0800 Subject: [PATCH] Show pending audits on home page Summary: When a user has pending audits, show them on the homepage. Test Plan: Looked at my homepage with and without pending audits. Reviewers: btrahan, jungejason Reviewed By: jungejason CC: aran, epriestley Maniphest Tasks: T904 Differential Revision: https://secure.phabricator.com/D1692 --- .../PhabricatorDirectoryMainController.php | 52 ++++++++++++++++++- .../directory/controller/main/__init__.php | 3 ++ 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/src/applications/directory/controller/main/PhabricatorDirectoryMainController.php b/src/applications/directory/controller/main/PhabricatorDirectoryMainController.php index 88f96f8835..f15cb82dd7 100644 --- a/src/applications/directory/controller/main/PhabricatorDirectoryMainController.php +++ b/src/applications/directory/controller/main/PhabricatorDirectoryMainController.php @@ -73,8 +73,10 @@ class PhabricatorDirectoryMainController $triage_panel = null; $tasks_panel = null; } + $jump_panel = $this->buildJumpPanel(); $revision_panel = $this->buildRevisionPanel(); + $audit_panel = $this->buildAuditPanel(); $content = array( $unbreak_panel, @@ -82,6 +84,7 @@ class PhabricatorDirectoryMainController $jump_panel, $revision_panel, $tasks_panel, + $audit_panel, ); $nav->appendChild($content); @@ -360,7 +363,6 @@ class PhabricatorDirectoryMainController $task_query->withStatus(ManiphestTaskQuery::STATUS_OPEN); $task_query->setGroupBy(ManiphestTaskQuery::GROUP_PRIORITY); $task_query->withOwners(array($user_phid)); - $task_query->setCalculateRows(true); $task_query->setLimit(10); $tasks = $task_query->execute(); @@ -377,7 +379,7 @@ class PhabricatorDirectoryMainController 'href' => '/maniphest/', 'class' => 'button grey', ), - "View All Assigned Tasks (".$task_query->getRowCount().") \xC2\xBB")); + "View Active Tasks \xC2\xBB")); $panel->appendChild($this->buildTaskListView($tasks)); } else { $panel->addButton( @@ -561,4 +563,50 @@ class PhabricatorDirectoryMainController return $panel; } + public function buildAuditPanel() { + $request = $this->getRequest(); + $user = $request->getUser(); + + $phids = PhabricatorAuditCommentEditor::loadAuditPHIDsForUser($user); + + $query = new PhabricatorAuditQuery(); + $query->withAuditorPHIDs($phids); + $query->withStatus(PhabricatorAuditQuery::STATUS_OPEN); + $query->setLimit(10); + + $audits = $query->execute(); + + if (!$audits) { + $panel = new AphrontMiniPanelView(); + $panel->appendChild( + '

'. + 'No Audits: '. + 'No commits are waiting for you to audit them.'. + '

'); + return $panel; + } + + $view = new PhabricatorAuditListView(); + $view->setAudits($audits); + + $phids = $view->getRequiredHandlePHIDs(); + $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); + $view->setHandles($handles); + + $panel = new AphrontPanelView(); + $panel->setHeader('Audits'); + $panel->setCaption('Commits awaiting your audit.'); + $panel->appendChild($view); + $panel->addButton( + phutil_render_tag( + 'a', + array( + 'href' => '/audit/', + 'class' => 'button grey', + ), + "View Active Audits \xC2\xBB")); + + return $panel; + } + } diff --git a/src/applications/directory/controller/main/__init__.php b/src/applications/directory/controller/main/__init__.php index 0a3850f4dd..d4ae353258 100644 --- a/src/applications/directory/controller/main/__init__.php +++ b/src/applications/directory/controller/main/__init__.php @@ -7,6 +7,9 @@ phutil_require_module('phabricator', 'aphront/response/redirect'); +phutil_require_module('phabricator', 'applications/audit/editor/comment'); +phutil_require_module('phabricator', 'applications/audit/query/audit'); +phutil_require_module('phabricator', 'applications/audit/view/list'); phutil_require_module('phabricator', 'applications/differential/query/revision'); phutil_require_module('phabricator', 'applications/differential/view/revisionlist'); phutil_require_module('phabricator', 'applications/directory/controller/base');