1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 01:08:50 +02:00

Herald - add support for task priority

Summary: adds a new FIELD and a new VALUE to support this. Slightly dodgy because priorities do not have phids so we have to special case how we handle this in a few spots. Ref T4294.

Test Plan: made a new rule to get cc'd on unbreak now and wishlist tasks. verified got cc'd correctly and not cc'd correctly.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Maniphest Tasks: T4294

Differential Revision: https://secure.phabricator.com/D8156
This commit is contained in:
Bob Trahan 2014-02-06 11:42:31 -08:00
parent a2687caa33
commit 1527a967c0
7 changed files with 84 additions and 34 deletions

View file

@ -370,7 +370,7 @@ return array(
'rsrc/js/application/files/behavior-icon-composer.js' => 'ea38f732',
'rsrc/js/application/files/behavior-launch-icon-composer.js' => '6ec125a0',
'rsrc/js/application/harbormaster/behavior-reorder-steps.js' => 'b21125a5',
'rsrc/js/application/herald/HeraldRuleEditor.js' => '4366c8cc',
'rsrc/js/application/herald/HeraldRuleEditor.js' => '4f31d692',
'rsrc/js/application/herald/PathTypeahead.js' => 'f7fc67ec',
'rsrc/js/application/herald/herald-rule-editor.js' => '7ebaeed3',
'rsrc/js/application/maniphest/behavior-batch-editor.js' => '391457d7',
@ -514,7 +514,7 @@ return array(
'diviner-shared-css' => 'be90f718',
'global-drag-and-drop-css' => '697324ad',
'herald-css' => '59d48f01',
'herald-rule-editor' => '4366c8cc',
'herald-rule-editor' => '4f31d692',
'herald-test-css' => '2b7d0f54',
'inline-comment-summary-css' => '14a91639',
'javelin-aphlict' => '493665ee',
@ -1054,19 +1054,6 @@ return array(
0 => 'javelin-install',
1 => 'javelin-event',
),
'4366c8cc' =>
array(
0 => 'multirow-row-manager',
1 => 'javelin-install',
2 => 'javelin-typeahead',
3 => 'javelin-util',
4 => 'javelin-dom',
5 => 'javelin-tokenizer',
6 => 'javelin-typeahead-preloaded-source',
7 => 'javelin-stratcom',
8 => 'javelin-json',
9 => 'phabricator-prefab',
),
'441f2137' =>
array(
0 => 'javelin-behavior',
@ -1110,6 +1097,19 @@ return array(
1 => 'javelin-dom',
2 => 'javelin-reactor-dom',
),
'4f31d692' =>
array(
0 => 'multirow-row-manager',
1 => 'javelin-install',
2 => 'javelin-typeahead',
3 => 'javelin-util',
4 => 'javelin-dom',
5 => 'javelin-tokenizer',
6 => 'javelin-typeahead-preloaded-source',
7 => 'javelin-stratcom',
8 => 'javelin-json',
9 => 'phabricator-prefab',
),
'4f344388' =>
array(
0 => 'javelin-install',

View file

@ -39,6 +39,7 @@ abstract class HeraldAdapter {
const FIELD_AUTHOR_RAW = 'author-raw';
const FIELD_COMMITTER_RAW = 'committer-raw';
const FIELD_IS_NEW_OBJECT = 'new-object';
const FIELD_TASK_PRIORITY = 'taskpriority';
const CONDITION_CONTAINS = 'contains';
const CONDITION_NOT_CONTAINS = '!contains';
@ -89,6 +90,7 @@ abstract class HeraldAdapter {
const VALUE_CONTENT_SOURCE = 'contentsource';
const VALUE_USER_OR_PROJECT = 'userorproject';
const VALUE_BUILD_PLAN = 'buildplan';
const VALUE_TASK_PRIORITY = 'taskpriority';
private $contentSource;
private $isNewObject;
@ -233,6 +235,7 @@ abstract class HeraldAdapter {
self::FIELD_AUTHOR_RAW => pht('Raw author name'),
self::FIELD_COMMITTER_RAW => pht('Raw committer name'),
self::FIELD_IS_NEW_OBJECT => pht('Is newly created?'),
self::FIELD_TASK_PRIORITY => pht('Task priority'),
);
}
@ -284,6 +287,7 @@ abstract class HeraldAdapter {
case self::FIELD_COMMITTER:
case self::FIELD_REVIEWER:
case self::FIELD_PUSHER:
case self::FIELD_TASK_PRIORITY:
return array(
self::CONDITION_IS_ANY,
self::CONDITION_IS_NOT_ANY,
@ -718,6 +722,8 @@ abstract class HeraldAdapter {
switch ($field) {
case self::FIELD_REPOSITORY:
return self::VALUE_REPOSITORY;
case self::FIELD_TASK_PRIORITY:
return self::VALUE_TASK_PRIORITY;
default:
return self::VALUE_USER;
}
@ -941,6 +947,7 @@ abstract class HeraldAdapter {
private function renderConditionAsText(
HeraldCondition $condition,
array $handles) {
$field_type = $condition->getFieldName();
$field_name = idx($this->getFieldNameMap(), $field_type);
@ -973,12 +980,25 @@ abstract class HeraldAdapter {
if (!is_array($value)) {
$value = array($value);
}
switch ($condition->getFieldName()) {
case self::FIELD_TASK_PRIORITY:
$priority_map = ManiphestTaskPriority::getTaskPriorityMap();
foreach ($value as $index => $val) {
$name = idx($priority_map, $val);
if ($name) {
$value[$index] = $name;
}
}
break;
default:
foreach ($value as $index => $val) {
$handle = idx($handles, $val);
if ($handle) {
$value[$index] = $handle->renderLink();
}
}
break;
}
$value = phutil_implode_html(', ', $value);
return $value;
}

View file

@ -80,6 +80,7 @@ final class HeraldManiphestTaskAdapter extends HeraldAdapter {
self::FIELD_CC,
self::FIELD_CONTENT_SOURCE,
self::FIELD_PROJECTS,
self::FIELD_TASK_PRIORITY,
self::FIELD_IS_NEW_OBJECT,
),
parent::getFields());
@ -126,6 +127,8 @@ final class HeraldManiphestTaskAdapter extends HeraldAdapter {
return $this->getTask()->getCCPHIDs();
case self::FIELD_PROJECTS:
return $this->getTask()->getProjectPHIDs();
case self::FIELD_TASK_PRIORITY:
return $this->getTask()->getPriority();
}
return parent::getHeraldField($field);

View file

@ -358,6 +358,16 @@ final class HeraldRuleController extends HeraldController {
foreach ($rule->getConditions() as $condition) {
$value = $condition->getValue();
switch ($condition->getFieldName()) {
case HeraldAdapter::FIELD_TASK_PRIORITY:
$value_map = array();
$priority_map = ManiphestTaskPriority::getTaskPriorityMap();
foreach ($value as $priority) {
$value_map[$priority] = idx($priority_map, $priority);
}
$value = $value_map;
break;
default:
if (is_array($value)) {
$value_map = array();
foreach ($value as $k => $fbid) {
@ -365,7 +375,8 @@ final class HeraldRuleController extends HeraldController {
}
$value = $value_map;
}
break;
}
$serial_conditions[] = array(
$condition->getFieldName(),
$condition->getFieldCondition(),
@ -581,6 +592,7 @@ final class HeraldRuleController extends HeraldController {
'project' => '/typeahead/common/projects/',
'userorproject' => '/typeahead/common/accountsorprojects/',
'buildplan' => '/typeahead/common/buildplans/',
'taskpriority' => '/typeahead/common/taskpriority/',
),
'markup' => $template,
);

View file

@ -17,7 +17,7 @@ final class HeraldRule extends HeraldDAO
protected $isDisabled = 0;
protected $triggerObjectPHID;
protected $configVersion = 28;
protected $configVersion = 29;
// phids for which this rule has been applied
private $ruleApplied = self::ATTACHABLE;

View file

@ -36,6 +36,7 @@ final class PhabricatorTypeaheadCommonDatasourceController
$need_symbols = false;
$need_jump_objects = false;
$need_build_plans = false;
$need_task_priority = false;
$need_macros = false;
$need_legalpad_documents = false;
switch ($this->type) {
@ -99,6 +100,9 @@ final class PhabricatorTypeaheadCommonDatasourceController
case 'buildplans':
$need_build_plans = true;
break;
case 'taskpriority':
$need_task_priority = true;
break;
case 'macros':
$need_macros = true;
break;
@ -243,6 +247,16 @@ final class PhabricatorTypeaheadCommonDatasourceController
}
}
if ($need_task_priority) {
$priority_map = ManiphestTaskPriority::getTaskPriorityMap();
foreach ($priority_map as $value => $name) {
// NOTE: $value is not a phid but is unique. This'll work.
$results[] = id(new PhabricatorTypeaheadResult())
->setPHID($value)
->setName($name);
}
}
if ($need_macros) {
$macros = id(new PhabricatorMacroQuery())
->setViewer($viewer)

View file

@ -222,6 +222,7 @@ JX.install('HeraldRuleEditor', {
case 'project':
case 'userorproject':
case 'buildplan':
case 'taskpriority':
var tokenizer = this._newTokenizer(type);
input = tokenizer[0];
get_fn = tokenizer[1];