1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-29 00:40:57 +01:00

Make Maniphest task priorites user-customizable

Summary: Drive these purely out of configuration after removing behavioral hardcodes in D6981.

Test Plan:
Mucked around with them:

{F58128} {F58129} {F58130}

Reviewers: btrahan

Reviewed By: btrahan

CC: chad, aran

Differential Revision: https://secure.phabricator.com/D6984
This commit is contained in:
epriestley 2013-09-13 11:11:05 -07:00
parent 7139655969
commit d97d8d5fc4
6 changed files with 97 additions and 42 deletions

View file

@ -963,7 +963,7 @@ celerity_register_resource_map(array(
),
'config-options-css' =>
array(
'uri' => '/res/cbef6aae/rsrc/css/application/config/config-options.css',
'uri' => '/res/4b5b6779/rsrc/css/application/config/config-options.css',
'type' => 'css',
'requires' =>
array(

View file

@ -12,6 +12,40 @@ final class PhabricatorManiphestConfigOptions
}
public function getOptions() {
$priority_defaults = array(
100 => array(
'name' => pht('Unbreak Now!'),
'short' => pht('Unbreak!'),
'color' => 'indigo',
),
90 => array(
'name' => pht('Needs Triage'),
'short' => pht('Triage'),
'color' => 'violet',
),
80 => array(
'name' => pht('High'),
'short' => pht('High'),
'color' => 'red',
),
50 => array(
'name' => pht('Normal'),
'short' => pht('Normal'),
'color' => 'orange',
),
25 => array(
'name' => pht('Low'),
'short' => pht('Low'),
'color' => 'yellow',
),
0 => array(
'name' => pht('Wishlist'),
'short' => pht('Wish'),
'color' => 'sky',
),
);
return array(
$this->newOption('maniphest.custom-fields', 'wild', array())
->setSummary(pht("Custom Maniphest fields."))
@ -36,6 +70,24 @@ final class PhabricatorManiphestConfigOptions
"Class which drives custom field construction. See 'Maniphest ".
"User Guide: Adding Custom Fields' in the documentation for more ".
"information.")),
$this->newOption('maniphest.priorities', 'wild', $priority_defaults)
->setSummary(pht("Configure Maniphest priority names."))
->setDescription(
pht(
'Allows you to edit or override the default priorities available '.
'in Maniphest, like "High", "Normal" and "Low". The configuration '.
'should contain a map of priority constants to priority '.
'specifications (see defaults below for examples).'.
"\n\n".
'The keys you can define for a priority are:'.
"\n\n".
' - `name` Name of the priority.'."\n".
' - `short` Alternate shorter name, used in UIs where there is '.
' not much space available.'."\n".
' - `color` A color for this priority, like "red" or "blue".'.
"\n\n".
'You can choose which priority is the default for newly created '.
'tasks with `maniphest.default-priority`.')),
$this->newOption('maniphest.default-priority', 'int', 90)
->setSummary(pht("Default task priority for create flows."))
->setDescription(

View file

@ -1,49 +1,49 @@
<?php
/**
* @group maniphest
*/
final class ManiphestTaskPriority extends ManiphestConstants {
const PRIORITY_UNBREAK_NOW = 100;
const PRIORITY_TRIAGE = 90;
const PRIORITY_HIGH = 80;
const PRIORITY_NORMAL = 50;
const PRIORITY_LOW = 25;
const PRIORITY_WISH = 0;
/**
* Get the priorities and their full descriptions.
*
* @return map Priorities to descriptions.
*/
public static function getTaskPriorityMap() {
return array(
self::PRIORITY_UNBREAK_NOW => 'Unbreak Now!',
self::PRIORITY_TRIAGE => 'Needs Triage',
self::PRIORITY_HIGH => 'High',
self::PRIORITY_NORMAL => 'Normal',
self::PRIORITY_LOW => 'Low',
self::PRIORITY_WISH => 'Wishlist',
);
$map = self::getConfig();
foreach ($map as $key => $spec) {
$map[$key] = idx($spec, 'name', $key);
}
return $map;
}
/**
* Get the priorities and their related short (one-word) descriptions.
*
* @return map Priorities to brief descriptions.
* @return map Priorities to short descriptions.
*/
public static function getTaskBriefPriorityMap() {
return array(
self::PRIORITY_UNBREAK_NOW => 'Unbreak!',
self::PRIORITY_TRIAGE => 'Triage',
self::PRIORITY_HIGH => 'High',
self::PRIORITY_NORMAL => 'Normal',
self::PRIORITY_LOW => 'Low',
self::PRIORITY_WISH => 'Wish',
);
public static function getShortNameMap() {
$map = self::getConfig();
foreach ($map as $key => $spec) {
$map[$key] = idx($spec, 'short', idx($spec, 'name', $key));
}
return $map;
}
/**
* Get a map from priority constants to their colors.
*
* @return map<int, string> Priorities to colors.
*/
public static function getColorMap() {
$map = self::getConfig();
foreach ($map as $key => $spec) {
$map[$key] = idx($spec, 'color', 'grey');
}
return $map;
}
/**
* Return the default priority for this instance of Phabricator.
*
@ -53,15 +53,22 @@ final class ManiphestTaskPriority extends ManiphestConstants {
return PhabricatorEnv::getEnvConfig('maniphest.default-priority');
}
/**
* Retrieve the full name of the priority level provided.
*
* @param int A priority level.
* @return string The priority name if the level is a valid one,
* or `???` if it is not.
* @return string The priority name if the level is a valid one.
*/
public static function getTaskPriorityName($priority) {
return idx(self::getTaskPriorityMap(), $priority, '???');
return idx(self::getTaskPriorityMap(), $priority, $priority);
}
private static function getConfig() {
$config = PhabricatorEnv::getEnvConfig('maniphest.priorities');
krsort($config);
return $config;
}
}

View file

@ -520,7 +520,9 @@ final class ManiphestReportController extends ManiphestController {
$normal_or_better = array();
foreach ($taskv as $id => $task) {
if ($task->getPriority() < ManiphestTaskPriority::PRIORITY_NORMAL) {
// 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) {
continue;
}
$normal_or_better[$id] = $task;
@ -574,7 +576,7 @@ final class ManiphestReportController extends ManiphestController {
$cname = array($col_header);
$cclass = array('pri right wide');
$pri_map = ManiphestTaskPriority::getTaskBriefPriorityMap();
$pri_map = ManiphestTaskPriority::getShortNameMap();
foreach ($pri_map as $pri => $label) {
$cname[] = $label;
$cclass[] = 'n';

View file

@ -40,14 +40,7 @@ final class ManiphestTaskListView extends ManiphestView {
$list->setFlush(true);
$status_map = ManiphestTaskStatus::getTaskStatusMap();
$color_map = array(
ManiphestTaskPriority::PRIORITY_UNBREAK_NOW => 'indigo',
ManiphestTaskPriority::PRIORITY_TRIAGE => 'violet',
ManiphestTaskPriority::PRIORITY_HIGH => 'red',
ManiphestTaskPriority::PRIORITY_NORMAL => 'orange',
ManiphestTaskPriority::PRIORITY_LOW => 'yellow',
ManiphestTaskPriority::PRIORITY_WISH => 'sky',
);
$color_map = ManiphestTaskPriority::getColorMap();
if ($this->showBatchControls) {
Javelin::initBehavior('maniphest-list-editor');

View file

@ -31,6 +31,7 @@
.config-option-table td {
color: {$darkgreytext};
width: 100%;
white-space: pre-wrap;
}
.config-option-table .column-labels th {