From e6925c83c187bc7c24913116c0c7e84a8f80d588 Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Fri, 26 Apr 2024 12:32:46 +0200 Subject: [PATCH] Do not hardcode default Priority names in Project Reports tooltip Summary: Pull the names of Priority field values instead of hardcoding them. Closes T15799 Test Plan: * As an admin, go to `/config/edit/maniphest.priorities/` and change the value of `"name"` of a Priority value with a value < `50` (e.g.: Low, Wishlist) * Open `/maniphest/report/project/` * Hover over the `Oldest (Pri)` column and check the tooltip text before and after applying this patch Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15799 Differential Revision: https://we.phorge.it/D25602 --- .../controller/ManiphestReportController.php | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/applications/maniphest/controller/ManiphestReportController.php b/src/applications/maniphest/controller/ManiphestReportController.php index a7efe89194..012d6d136b 100644 --- a/src/applications/maniphest/controller/ManiphestReportController.php +++ b/src/applications/maniphest/controller/ManiphestReportController.php @@ -487,6 +487,12 @@ final class ManiphestReportController extends ManiphestController { ); } + private function getAveragePriority() { + // TODO: This is sort of a hard-code for the default "normal" status. + // When reports are more powerful, this should be made more general. + return 50; + } + public function renderOpenTasks() { $request = $this->getRequest(); $viewer = $request->getUser(); @@ -626,9 +632,7 @@ final class ManiphestReportController extends ManiphestController { $normal_or_better = array(); foreach ($taskv as $id => $task) { - // TODO: This is sort of a hard-code for the default "normal" status. - // When reports are more powerful, this should be made more general. - if ($task->getPriority() < 50) { + if ($task->getPriority() < $this->getAveragePriority()) { continue; } $normal_or_better[$id] = $task; @@ -700,13 +704,22 @@ final class ManiphestReportController extends ManiphestController { ), pht('Oldest (All)')); $cclass[] = 'n'; + $low_priorities = array(); + $priorities_map = ManiphestTaskPriority::getTaskPriorityMap(); + $normal_priority = $this->getAveragePriority(); + foreach ($priorities_map as $pri => $full_label) { + if ($pri < $normal_priority) { + $low_priorities[] = $full_label; + } + } + $pri_string = implode(', ', $low_priorities); $cname[] = javelin_tag( 'span', array( 'sigil' => 'has-tooltip', 'meta' => array( 'tip' => pht( - 'Oldest open task, excluding those with Low or Wishlist priority.'), + 'Oldest open task, excluding those with priority %s', $pri_string), 'size' => 200, ), ),