From b660960771a4280977926940e6aa042e15c51a4a Mon Sep 17 00:00:00 2001 From: Brayden Winterton Date: Wed, 9 Apr 2014 11:32:08 -0700 Subject: [PATCH] Add a priorityColor property to the maniphest conduit endpoint Summary: I added a getTaskPriorityColor function to the ManiphestTaskPriority class which returns the color set in the maniphest config for the given priority. This is in preparation for a change to arcanist which will allow it to display the priority color (if it is a supported color) upon running `arc tasks`. Fixed some linting issues Test Plan: Invoke the maniphest.info method from conduit and ensure that: * The priorityColor property is given in the json * the priorityColor property is set correctly Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D8734 --- .../maniphest/conduit/ConduitAPI_maniphest_Method.php | 2 ++ .../maniphest/constants/ManiphestTaskPriority.php | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/applications/maniphest/conduit/ConduitAPI_maniphest_Method.php b/src/applications/maniphest/conduit/ConduitAPI_maniphest_Method.php index f403ccfa28..4d6f26a844 100644 --- a/src/applications/maniphest/conduit/ConduitAPI_maniphest_Method.php +++ b/src/applications/maniphest/conduit/ConduitAPI_maniphest_Method.php @@ -265,6 +265,8 @@ abstract class ConduitAPI_maniphest_Method extends ConduitAPIMethod { 'isClosed' => $task->isClosed(), 'priority' => ManiphestTaskPriority::getTaskPriorityName( $task->getPriority()), + 'priorityColor' => ManiphestTaskPriority::getTaskPriorityColor( + $task->getPriority()), 'title' => $task->getTitle(), 'description' => $task->getDescription(), 'projectPHIDs' => $task->getProjectPHIDs(), diff --git a/src/applications/maniphest/constants/ManiphestTaskPriority.php b/src/applications/maniphest/constants/ManiphestTaskPriority.php index 603acd2231..ec2663f6ee 100644 --- a/src/applications/maniphest/constants/ManiphestTaskPriority.php +++ b/src/applications/maniphest/constants/ManiphestTaskPriority.php @@ -64,6 +64,17 @@ final class ManiphestTaskPriority extends ManiphestConstants { return idx(self::getTaskPriorityMap(), $priority, $priority); } + /** + * Retrieve the color of the priority level given + * + * @param int A priority level. + * @return string The color of the priority if the level is valid, + * or black if it is not. + */ + public static function getTaskPriorityColor($priority) { + return idx(self::getColorMap(), $priority, 'black'); + } + private static function getConfig() { $config = PhabricatorEnv::getEnvConfig('maniphest.priorities');