1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-31 18:01:00 +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' => 'config-options-css' =>
array( array(
'uri' => '/res/cbef6aae/rsrc/css/application/config/config-options.css', 'uri' => '/res/4b5b6779/rsrc/css/application/config/config-options.css',
'type' => 'css', 'type' => 'css',
'requires' => 'requires' =>
array( array(

View file

@ -12,6 +12,40 @@ final class PhabricatorManiphestConfigOptions
} }
public function getOptions() { 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( return array(
$this->newOption('maniphest.custom-fields', 'wild', array()) $this->newOption('maniphest.custom-fields', 'wild', array())
->setSummary(pht("Custom Maniphest fields.")) ->setSummary(pht("Custom Maniphest fields."))
@ -36,6 +70,24 @@ final class PhabricatorManiphestConfigOptions
"Class which drives custom field construction. See 'Maniphest ". "Class which drives custom field construction. See 'Maniphest ".
"User Guide: Adding Custom Fields' in the documentation for more ". "User Guide: Adding Custom Fields' in the documentation for more ".
"information.")), "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) $this->newOption('maniphest.default-priority', 'int', 90)
->setSummary(pht("Default task priority for create flows.")) ->setSummary(pht("Default task priority for create flows."))
->setDescription( ->setDescription(

View file

@ -1,49 +1,49 @@
<?php <?php
/**
* @group maniphest
*/
final class ManiphestTaskPriority extends ManiphestConstants { 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. * Get the priorities and their full descriptions.
* *
* @return map Priorities to descriptions. * @return map Priorities to descriptions.
*/ */
public static function getTaskPriorityMap() { public static function getTaskPriorityMap() {
return array( $map = self::getConfig();
self::PRIORITY_UNBREAK_NOW => 'Unbreak Now!', foreach ($map as $key => $spec) {
self::PRIORITY_TRIAGE => 'Needs Triage', $map[$key] = idx($spec, 'name', $key);
self::PRIORITY_HIGH => 'High', }
self::PRIORITY_NORMAL => 'Normal', return $map;
self::PRIORITY_LOW => 'Low',
self::PRIORITY_WISH => 'Wishlist',
);
} }
/** /**
* Get the priorities and their related short (one-word) descriptions. * 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() { public static function getShortNameMap() {
return array( $map = self::getConfig();
self::PRIORITY_UNBREAK_NOW => 'Unbreak!', foreach ($map as $key => $spec) {
self::PRIORITY_TRIAGE => 'Triage', $map[$key] = idx($spec, 'short', idx($spec, 'name', $key));
self::PRIORITY_HIGH => 'High', }
self::PRIORITY_NORMAL => 'Normal', return $map;
self::PRIORITY_LOW => 'Low',
self::PRIORITY_WISH => 'Wish',
);
} }
/**
* 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. * Return the default priority for this instance of Phabricator.
* *
@ -53,15 +53,22 @@ final class ManiphestTaskPriority extends ManiphestConstants {
return PhabricatorEnv::getEnvConfig('maniphest.default-priority'); return PhabricatorEnv::getEnvConfig('maniphest.default-priority');
} }
/** /**
* Retrieve the full name of the priority level provided. * Retrieve the full name of the priority level provided.
* *
* @param int A priority level. * @param int A priority level.
* @return string The priority name if the level is a valid one, * @return string The priority name if the level is a valid one.
* or `???` if it is not.
*/ */
public static function getTaskPriorityName($priority) { 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(); $normal_or_better = array();
foreach ($taskv as $id => $task) { 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; continue;
} }
$normal_or_better[$id] = $task; $normal_or_better[$id] = $task;
@ -574,7 +576,7 @@ final class ManiphestReportController extends ManiphestController {
$cname = array($col_header); $cname = array($col_header);
$cclass = array('pri right wide'); $cclass = array('pri right wide');
$pri_map = ManiphestTaskPriority::getTaskBriefPriorityMap(); $pri_map = ManiphestTaskPriority::getShortNameMap();
foreach ($pri_map as $pri => $label) { foreach ($pri_map as $pri => $label) {
$cname[] = $label; $cname[] = $label;
$cclass[] = 'n'; $cclass[] = 'n';

View file

@ -40,14 +40,7 @@ final class ManiphestTaskListView extends ManiphestView {
$list->setFlush(true); $list->setFlush(true);
$status_map = ManiphestTaskStatus::getTaskStatusMap(); $status_map = ManiphestTaskStatus::getTaskStatusMap();
$color_map = array( $color_map = ManiphestTaskPriority::getColorMap();
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',
);
if ($this->showBatchControls) { if ($this->showBatchControls) {
Javelin::initBehavior('maniphest-list-editor'); Javelin::initBehavior('maniphest-list-editor');

View file

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