From 24e07df434da17a778959b9bf9d917cc9e9bf75d Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 17 Sep 2013 11:31:32 -0700 Subject: [PATCH] Restore "Unbreak Now" and "Needs Triage" homepage boxes as cusomizable elements Summary: Ref T3583. Fixes T3835. Dropbox and Disqus both want these things back, so restore them until we can do something about T3583. Test Plan: Viewed homepage, clicked "View All X" buttons. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T3583, T3835 Differential Revision: https://secure.phabricator.com/D7017 --- .../PhabricatorDirectoryMainController.php | 102 ++++++++++++++++++ .../PhabricatorManiphestConfigOptions.php | 21 ++++ 2 files changed, 123 insertions(+) diff --git a/src/applications/directory/controller/PhabricatorDirectoryMainController.php b/src/applications/directory/controller/PhabricatorDirectoryMainController.php index c93c9c3b55..bbb80fea0b 100644 --- a/src/applications/directory/controller/PhabricatorDirectoryMainController.php +++ b/src/applications/directory/controller/PhabricatorDirectoryMainController.php @@ -32,8 +32,12 @@ final class PhabricatorDirectoryMainController $maniphest = 'PhabricatorApplicationManiphest'; if (PhabricatorApplication::isClassInstalled($maniphest)) { + $unbreak_panel = $this->buildUnbreakNowPanel(); + $triage_panel = $this->buildNeedsTriagePanel($projects); $tasks_panel = $this->buildTasksPanel(); } else { + $unbreak_panel = null; + $triage_panel = null; $tasks_panel = null; } @@ -50,6 +54,8 @@ final class PhabricatorDirectoryMainController $content = array( $jump_panel, $welcome_panel, + $unbreak_panel, + $triage_panel, $revision_panel, $tasks_panel, $audit_panel, @@ -90,6 +96,102 @@ final class PhabricatorDirectoryMainController } } + private function buildUnbreakNowPanel() { + $unbreak_now = PhabricatorEnv::getEnvConfig( + 'maniphest.priorities.unbreak-now'); + if (!$unbreak_now) { + return null; + } + + $user = $this->getRequest()->getUser(); + + $task_query = id(new ManiphestTaskQuery()) + ->setViewer($user) + ->withStatuses(array(ManiphestTaskStatus::STATUS_OPEN)) + ->withPriorities(array($unbreak_now)) + ->setLimit(10); + + $tasks = $task_query->execute(); + + if (!$tasks) { + return $this->renderMiniPanel( + 'No "Unbreak Now!" Tasks', + 'Nothing appears to be critically broken right now.'); + } + + $panel = new AphrontPanelView(); + $panel->setHeader('Unbreak Now!'); + $panel->setCaption('Open tasks with "Unbreak Now!" priority.'); + $panel->addButton( + phutil_tag( + 'a', + array( + 'href' => '/maniphest/?statuses[]=0&priorities[]='.$unbreak_now.'#R', + 'class' => 'grey button', + ), + "View All Unbreak Now \xC2\xBB")); + + $panel->appendChild($this->buildTaskListView($tasks)); + $panel->setNoBackground(); + + return $panel; + } + + private function buildNeedsTriagePanel(array $projects) { + assert_instances_of($projects, 'PhabricatorProject'); + + $needs_triage = PhabricatorEnv::getEnvConfig( + 'maniphest.priorities.needs-triage'); + if (!$needs_triage) { + return null; + } + + $user = $this->getRequest()->getUser(); + if (!$user->isLoggedIn()) { + return null; + } + + if ($projects) { + $task_query = id(new ManiphestTaskQuery()) + ->setViewer($user) + ->withStatuses(array(ManiphestTaskStatus::STATUS_OPEN)) + ->withPriorities(array($needs_triage)) + ->withAnyProjects(mpull($projects, 'getPHID')) + ->setLimit(10); + $tasks = $task_query->execute(); + } else { + $tasks = array(); + } + + if (!$tasks) { + return $this->renderMiniPanel( + 'No "Needs Triage" Tasks', + hsprintf( + 'No tasks in projects you are a member of '. + 'need triage.')); + } + + $panel = new AphrontPanelView(); + $panel->setHeader('Needs Triage'); + $panel->setCaption(hsprintf( + 'Open tasks with "Needs Triage" priority in '. + 'projects you are a member of.')); + + $panel->addButton( + phutil_tag( + 'a', + array( + 'href' => '/maniphest/?statuses[]=0&priorities[]='.$needs_triage. + '&userProjects[]='.$user->getPHID().'#R', + 'class' => 'grey button', + ), + "View All Triage \xC2\xBB")); + $panel->appendChild($this->buildTaskListView($tasks)); + $panel->setNoBackground(); + + return $panel; + } + private function buildRevisionPanel() { $user = $this->getRequest()->getUser(); $user_phid = $user->getPHID(); diff --git a/src/applications/maniphest/config/PhabricatorManiphestConfigOptions.php b/src/applications/maniphest/config/PhabricatorManiphestConfigOptions.php index 8a5a4903e7..f516c8aeae 100644 --- a/src/applications/maniphest/config/PhabricatorManiphestConfigOptions.php +++ b/src/applications/maniphest/config/PhabricatorManiphestConfigOptions.php @@ -165,6 +165,27 @@ final class PhabricatorManiphestConfigOptions 'create a task, even if the sender is not a system user. The '. 'original email address will be stored in an `From Email` field '. 'on the task.')), + $this->newOption( + 'maniphest.priorities.unbreak-now', + 'int', + 100) + ->setSummary(pht('Priority used to populate "Unbreak Now" on home.')) + ->setDescription( + pht( + 'Temporary setting. If set, this priority is used to populate the '. + '"Unbreak Now" panel on the home page. You should adjust this if '. + 'you adjust priorities using `maniphest.priorities`.')), + $this->newOption( + 'maniphest.priorities.needs-triage', + 'int', + 90) + ->setSummary(pht('Priority used to populate "Needs Triage" on home.')) + ->setDescription( + pht( + 'Temporary setting. If set, this priority is used to populate the '. + '"Needs Triage" panel on the home page. You should adjust this if '. + 'you adjust priorities using `maniphest.priorities`.')), + ); }