diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index a4d8a6b7a8..8d0a17e110 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1277,6 +1277,7 @@ phutil_register_library_map(array( 'ManiphestInfoConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestInfoConduitAPIMethod.php', 'ManiphestNameIndex' => 'applications/maniphest/storage/ManiphestNameIndex.php', 'ManiphestNameIndexEventListener' => 'applications/maniphest/event/ManiphestNameIndexEventListener.php', + 'ManiphestPriorityConfigOptionType' => 'applications/maniphest/config/ManiphestPriorityConfigOptionType.php', 'ManiphestPriorityEmailCommand' => 'applications/maniphest/command/ManiphestPriorityEmailCommand.php', 'ManiphestQueryConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestQueryConduitAPIMethod.php', 'ManiphestQueryStatusesConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestQueryStatusesConduitAPIMethod.php', @@ -5258,6 +5259,7 @@ phutil_register_library_map(array( 'ManiphestInfoConduitAPIMethod' => 'ManiphestConduitAPIMethod', 'ManiphestNameIndex' => 'ManiphestDAO', 'ManiphestNameIndexEventListener' => 'PhabricatorEventListener', + 'ManiphestPriorityConfigOptionType' => 'PhabricatorConfigJSONOptionType', 'ManiphestPriorityEmailCommand' => 'ManiphestEmailCommand', 'ManiphestQueryConduitAPIMethod' => 'ManiphestConduitAPIMethod', 'ManiphestQueryStatusesConduitAPIMethod' => 'ManiphestConduitAPIMethod', diff --git a/src/applications/maniphest/config/ManiphestPriorityConfigOptionType.php b/src/applications/maniphest/config/ManiphestPriorityConfigOptionType.php new file mode 100644 index 0000000000..029207788e --- /dev/null +++ b/src/applications/maniphest/config/ManiphestPriorityConfigOptionType.php @@ -0,0 +1,10 @@ + array( 'name' => pht('Unbreak Now!'), @@ -267,7 +267,10 @@ EOTEXT $this->newOption('maniphest.fields', $custom_field_type, $default_fields) ->setCustomData(id(new ManiphestTask())->getCustomFieldBaseClass()) ->setDescription(pht('Select and reorder task fields.')), - $this->newOption('maniphest.priorities', 'wild', $priority_defaults) + $this->newOption( + 'maniphest.priorities', + $priority_type, + $priority_defaults) ->setSummary(pht('Configure Maniphest priority names.')) ->setDescription( pht( diff --git a/src/applications/maniphest/constants/ManiphestTaskPriority.php b/src/applications/maniphest/constants/ManiphestTaskPriority.php index 55ebafe597..6bd1460628 100644 --- a/src/applications/maniphest/constants/ManiphestTaskPriority.php +++ b/src/applications/maniphest/constants/ManiphestTaskPriority.php @@ -116,4 +116,33 @@ final class ManiphestTaskPriority extends ManiphestConstants { return $config; } + public static function validateConfiguration(array $config) { + foreach ($config as $key => $value) { + if (!ctype_digit((string)$key)) { + throw new Exception( + pht( + 'Key "%s" is not a valid priority constant. Priority constants '. + 'must be nonnegative integers.', + $key)); + } + + if (!is_array($value)) { + throw new Exception( + pht( + 'Value for key "%s" should be a dictionary.', + $key)); + } + + PhutilTypeSpec::checkMap( + $value, + array( + 'name' => 'string', + 'short' => 'optional string', + 'color' => 'optional string', + 'keywords' => 'optional list', + 'disabled' => 'optional bool', + )); + } + } + }