mirror of
https://we.phorge.it/source/phorge.git
synced 2025-03-06 09:29:28 +01: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:
parent
a2687caa33
commit
1527a967c0
7 changed files with 84 additions and 34 deletions
|
@ -370,7 +370,7 @@ return array(
|
||||||
'rsrc/js/application/files/behavior-icon-composer.js' => 'ea38f732',
|
'rsrc/js/application/files/behavior-icon-composer.js' => 'ea38f732',
|
||||||
'rsrc/js/application/files/behavior-launch-icon-composer.js' => '6ec125a0',
|
'rsrc/js/application/files/behavior-launch-icon-composer.js' => '6ec125a0',
|
||||||
'rsrc/js/application/harbormaster/behavior-reorder-steps.js' => 'b21125a5',
|
'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/PathTypeahead.js' => 'f7fc67ec',
|
||||||
'rsrc/js/application/herald/herald-rule-editor.js' => '7ebaeed3',
|
'rsrc/js/application/herald/herald-rule-editor.js' => '7ebaeed3',
|
||||||
'rsrc/js/application/maniphest/behavior-batch-editor.js' => '391457d7',
|
'rsrc/js/application/maniphest/behavior-batch-editor.js' => '391457d7',
|
||||||
|
@ -514,7 +514,7 @@ return array(
|
||||||
'diviner-shared-css' => 'be90f718',
|
'diviner-shared-css' => 'be90f718',
|
||||||
'global-drag-and-drop-css' => '697324ad',
|
'global-drag-and-drop-css' => '697324ad',
|
||||||
'herald-css' => '59d48f01',
|
'herald-css' => '59d48f01',
|
||||||
'herald-rule-editor' => '4366c8cc',
|
'herald-rule-editor' => '4f31d692',
|
||||||
'herald-test-css' => '2b7d0f54',
|
'herald-test-css' => '2b7d0f54',
|
||||||
'inline-comment-summary-css' => '14a91639',
|
'inline-comment-summary-css' => '14a91639',
|
||||||
'javelin-aphlict' => '493665ee',
|
'javelin-aphlict' => '493665ee',
|
||||||
|
@ -1054,19 +1054,6 @@ return array(
|
||||||
0 => 'javelin-install',
|
0 => 'javelin-install',
|
||||||
1 => 'javelin-event',
|
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' =>
|
'441f2137' =>
|
||||||
array(
|
array(
|
||||||
0 => 'javelin-behavior',
|
0 => 'javelin-behavior',
|
||||||
|
@ -1110,6 +1097,19 @@ return array(
|
||||||
1 => 'javelin-dom',
|
1 => 'javelin-dom',
|
||||||
2 => 'javelin-reactor-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' =>
|
'4f344388' =>
|
||||||
array(
|
array(
|
||||||
0 => 'javelin-install',
|
0 => 'javelin-install',
|
||||||
|
|
|
@ -39,6 +39,7 @@ abstract class HeraldAdapter {
|
||||||
const FIELD_AUTHOR_RAW = 'author-raw';
|
const FIELD_AUTHOR_RAW = 'author-raw';
|
||||||
const FIELD_COMMITTER_RAW = 'committer-raw';
|
const FIELD_COMMITTER_RAW = 'committer-raw';
|
||||||
const FIELD_IS_NEW_OBJECT = 'new-object';
|
const FIELD_IS_NEW_OBJECT = 'new-object';
|
||||||
|
const FIELD_TASK_PRIORITY = 'taskpriority';
|
||||||
|
|
||||||
const CONDITION_CONTAINS = 'contains';
|
const CONDITION_CONTAINS = 'contains';
|
||||||
const CONDITION_NOT_CONTAINS = '!contains';
|
const CONDITION_NOT_CONTAINS = '!contains';
|
||||||
|
@ -89,6 +90,7 @@ abstract class HeraldAdapter {
|
||||||
const VALUE_CONTENT_SOURCE = 'contentsource';
|
const VALUE_CONTENT_SOURCE = 'contentsource';
|
||||||
const VALUE_USER_OR_PROJECT = 'userorproject';
|
const VALUE_USER_OR_PROJECT = 'userorproject';
|
||||||
const VALUE_BUILD_PLAN = 'buildplan';
|
const VALUE_BUILD_PLAN = 'buildplan';
|
||||||
|
const VALUE_TASK_PRIORITY = 'taskpriority';
|
||||||
|
|
||||||
private $contentSource;
|
private $contentSource;
|
||||||
private $isNewObject;
|
private $isNewObject;
|
||||||
|
@ -233,6 +235,7 @@ abstract class HeraldAdapter {
|
||||||
self::FIELD_AUTHOR_RAW => pht('Raw author name'),
|
self::FIELD_AUTHOR_RAW => pht('Raw author name'),
|
||||||
self::FIELD_COMMITTER_RAW => pht('Raw committer name'),
|
self::FIELD_COMMITTER_RAW => pht('Raw committer name'),
|
||||||
self::FIELD_IS_NEW_OBJECT => pht('Is newly created?'),
|
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_COMMITTER:
|
||||||
case self::FIELD_REVIEWER:
|
case self::FIELD_REVIEWER:
|
||||||
case self::FIELD_PUSHER:
|
case self::FIELD_PUSHER:
|
||||||
|
case self::FIELD_TASK_PRIORITY:
|
||||||
return array(
|
return array(
|
||||||
self::CONDITION_IS_ANY,
|
self::CONDITION_IS_ANY,
|
||||||
self::CONDITION_IS_NOT_ANY,
|
self::CONDITION_IS_NOT_ANY,
|
||||||
|
@ -718,6 +722,8 @@ abstract class HeraldAdapter {
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
case self::FIELD_REPOSITORY:
|
case self::FIELD_REPOSITORY:
|
||||||
return self::VALUE_REPOSITORY;
|
return self::VALUE_REPOSITORY;
|
||||||
|
case self::FIELD_TASK_PRIORITY:
|
||||||
|
return self::VALUE_TASK_PRIORITY;
|
||||||
default:
|
default:
|
||||||
return self::VALUE_USER;
|
return self::VALUE_USER;
|
||||||
}
|
}
|
||||||
|
@ -941,6 +947,7 @@ abstract class HeraldAdapter {
|
||||||
private function renderConditionAsText(
|
private function renderConditionAsText(
|
||||||
HeraldCondition $condition,
|
HeraldCondition $condition,
|
||||||
array $handles) {
|
array $handles) {
|
||||||
|
|
||||||
$field_type = $condition->getFieldName();
|
$field_type = $condition->getFieldName();
|
||||||
$field_name = idx($this->getFieldNameMap(), $field_type);
|
$field_name = idx($this->getFieldNameMap(), $field_type);
|
||||||
|
|
||||||
|
@ -973,11 +980,24 @@ abstract class HeraldAdapter {
|
||||||
if (!is_array($value)) {
|
if (!is_array($value)) {
|
||||||
$value = array($value);
|
$value = array($value);
|
||||||
}
|
}
|
||||||
foreach ($value as $index => $val) {
|
switch ($condition->getFieldName()) {
|
||||||
$handle = idx($handles, $val);
|
case self::FIELD_TASK_PRIORITY:
|
||||||
if ($handle) {
|
$priority_map = ManiphestTaskPriority::getTaskPriorityMap();
|
||||||
$value[$index] = $handle->renderLink();
|
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);
|
$value = phutil_implode_html(', ', $value);
|
||||||
return $value;
|
return $value;
|
||||||
|
|
|
@ -80,6 +80,7 @@ final class HeraldManiphestTaskAdapter extends HeraldAdapter {
|
||||||
self::FIELD_CC,
|
self::FIELD_CC,
|
||||||
self::FIELD_CONTENT_SOURCE,
|
self::FIELD_CONTENT_SOURCE,
|
||||||
self::FIELD_PROJECTS,
|
self::FIELD_PROJECTS,
|
||||||
|
self::FIELD_TASK_PRIORITY,
|
||||||
self::FIELD_IS_NEW_OBJECT,
|
self::FIELD_IS_NEW_OBJECT,
|
||||||
),
|
),
|
||||||
parent::getFields());
|
parent::getFields());
|
||||||
|
@ -126,6 +127,8 @@ final class HeraldManiphestTaskAdapter extends HeraldAdapter {
|
||||||
return $this->getTask()->getCCPHIDs();
|
return $this->getTask()->getCCPHIDs();
|
||||||
case self::FIELD_PROJECTS:
|
case self::FIELD_PROJECTS:
|
||||||
return $this->getTask()->getProjectPHIDs();
|
return $this->getTask()->getProjectPHIDs();
|
||||||
|
case self::FIELD_TASK_PRIORITY:
|
||||||
|
return $this->getTask()->getPriority();
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::getHeraldField($field);
|
return parent::getHeraldField($field);
|
||||||
|
|
|
@ -358,14 +358,25 @@ final class HeraldRuleController extends HeraldController {
|
||||||
foreach ($rule->getConditions() as $condition) {
|
foreach ($rule->getConditions() as $condition) {
|
||||||
|
|
||||||
$value = $condition->getValue();
|
$value = $condition->getValue();
|
||||||
if (is_array($value)) {
|
switch ($condition->getFieldName()) {
|
||||||
$value_map = array();
|
case HeraldAdapter::FIELD_TASK_PRIORITY:
|
||||||
foreach ($value as $k => $fbid) {
|
$value_map = array();
|
||||||
$value_map[$fbid] = $handles[$fbid]->getName();
|
$priority_map = ManiphestTaskPriority::getTaskPriorityMap();
|
||||||
}
|
foreach ($value as $priority) {
|
||||||
$value = $value_map;
|
$value_map[$priority] = idx($priority_map, $priority);
|
||||||
|
}
|
||||||
|
$value = $value_map;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (is_array($value)) {
|
||||||
|
$value_map = array();
|
||||||
|
foreach ($value as $k => $fbid) {
|
||||||
|
$value_map[$fbid] = $handles[$fbid]->getName();
|
||||||
|
}
|
||||||
|
$value = $value_map;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$serial_conditions[] = array(
|
$serial_conditions[] = array(
|
||||||
$condition->getFieldName(),
|
$condition->getFieldName(),
|
||||||
$condition->getFieldCondition(),
|
$condition->getFieldCondition(),
|
||||||
|
@ -574,13 +585,14 @@ final class HeraldRuleController extends HeraldController {
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'source' => array(
|
'source' => array(
|
||||||
'email' => '/typeahead/common/mailable/',
|
'email' => '/typeahead/common/mailable/',
|
||||||
'user' => '/typeahead/common/accounts/',
|
'user' => '/typeahead/common/accounts/',
|
||||||
'repository' => '/typeahead/common/repositories/',
|
'repository' => '/typeahead/common/repositories/',
|
||||||
'package' => '/typeahead/common/packages/',
|
'package' => '/typeahead/common/packages/',
|
||||||
'project' => '/typeahead/common/projects/',
|
'project' => '/typeahead/common/projects/',
|
||||||
'userorproject' => '/typeahead/common/accountsorprojects/',
|
'userorproject' => '/typeahead/common/accountsorprojects/',
|
||||||
'buildplan' => '/typeahead/common/buildplans/',
|
'buildplan' => '/typeahead/common/buildplans/',
|
||||||
|
'taskpriority' => '/typeahead/common/taskpriority/',
|
||||||
),
|
),
|
||||||
'markup' => $template,
|
'markup' => $template,
|
||||||
);
|
);
|
||||||
|
|
|
@ -17,7 +17,7 @@ final class HeraldRule extends HeraldDAO
|
||||||
protected $isDisabled = 0;
|
protected $isDisabled = 0;
|
||||||
protected $triggerObjectPHID;
|
protected $triggerObjectPHID;
|
||||||
|
|
||||||
protected $configVersion = 28;
|
protected $configVersion = 29;
|
||||||
|
|
||||||
// phids for which this rule has been applied
|
// phids for which this rule has been applied
|
||||||
private $ruleApplied = self::ATTACHABLE;
|
private $ruleApplied = self::ATTACHABLE;
|
||||||
|
|
|
@ -36,6 +36,7 @@ final class PhabricatorTypeaheadCommonDatasourceController
|
||||||
$need_symbols = false;
|
$need_symbols = false;
|
||||||
$need_jump_objects = false;
|
$need_jump_objects = false;
|
||||||
$need_build_plans = false;
|
$need_build_plans = false;
|
||||||
|
$need_task_priority = false;
|
||||||
$need_macros = false;
|
$need_macros = false;
|
||||||
$need_legalpad_documents = false;
|
$need_legalpad_documents = false;
|
||||||
switch ($this->type) {
|
switch ($this->type) {
|
||||||
|
@ -99,6 +100,9 @@ final class PhabricatorTypeaheadCommonDatasourceController
|
||||||
case 'buildplans':
|
case 'buildplans':
|
||||||
$need_build_plans = true;
|
$need_build_plans = true;
|
||||||
break;
|
break;
|
||||||
|
case 'taskpriority':
|
||||||
|
$need_task_priority = true;
|
||||||
|
break;
|
||||||
case 'macros':
|
case 'macros':
|
||||||
$need_macros = true;
|
$need_macros = true;
|
||||||
break;
|
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) {
|
if ($need_macros) {
|
||||||
$macros = id(new PhabricatorMacroQuery())
|
$macros = id(new PhabricatorMacroQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
|
|
|
@ -222,6 +222,7 @@ JX.install('HeraldRuleEditor', {
|
||||||
case 'project':
|
case 'project':
|
||||||
case 'userorproject':
|
case 'userorproject':
|
||||||
case 'buildplan':
|
case 'buildplan':
|
||||||
|
case 'taskpriority':
|
||||||
var tokenizer = this._newTokenizer(type);
|
var tokenizer = this._newTokenizer(type);
|
||||||
input = tokenizer[0];
|
input = tokenizer[0];
|
||||||
get_fn = tokenizer[1];
|
get_fn = tokenizer[1];
|
||||||
|
|
Loading…
Add table
Reference in a new issue