diff --git a/resources/celerity/map.php b/resources/celerity/map.php index e5e7049b2c..99c98210b5 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -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', diff --git a/src/applications/herald/adapter/HeraldAdapter.php b/src/applications/herald/adapter/HeraldAdapter.php index 92a76f67e3..b3619b8887 100644 --- a/src/applications/herald/adapter/HeraldAdapter.php +++ b/src/applications/herald/adapter/HeraldAdapter.php @@ -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,11 +980,24 @@ abstract class HeraldAdapter { if (!is_array($value)) { $value = array($value); } - foreach ($value as $index => $val) { - $handle = idx($handles, $val); - if ($handle) { - $value[$index] = $handle->renderLink(); - } + 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; diff --git a/src/applications/herald/adapter/HeraldManiphestTaskAdapter.php b/src/applications/herald/adapter/HeraldManiphestTaskAdapter.php index 20a27b01f1..aea6f10530 100644 --- a/src/applications/herald/adapter/HeraldManiphestTaskAdapter.php +++ b/src/applications/herald/adapter/HeraldManiphestTaskAdapter.php @@ -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); diff --git a/src/applications/herald/controller/HeraldRuleController.php b/src/applications/herald/controller/HeraldRuleController.php index 36a904038a..570fffe5de 100644 --- a/src/applications/herald/controller/HeraldRuleController.php +++ b/src/applications/herald/controller/HeraldRuleController.php @@ -358,14 +358,25 @@ final class HeraldRuleController extends HeraldController { foreach ($rule->getConditions() as $condition) { $value = $condition->getValue(); - if (is_array($value)) { - $value_map = array(); - foreach ($value as $k => $fbid) { - $value_map[$fbid] = $handles[$fbid]->getName(); - } - $value = $value_map; + 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) { + $value_map[$fbid] = $handles[$fbid]->getName(); + } + $value = $value_map; + } + break; } - $serial_conditions[] = array( $condition->getFieldName(), $condition->getFieldCondition(), @@ -574,13 +585,14 @@ final class HeraldRuleController extends HeraldController { return array( 'source' => array( - 'email' => '/typeahead/common/mailable/', - 'user' => '/typeahead/common/accounts/', - 'repository' => '/typeahead/common/repositories/', - 'package' => '/typeahead/common/packages/', - 'project' => '/typeahead/common/projects/', + 'email' => '/typeahead/common/mailable/', + 'user' => '/typeahead/common/accounts/', + 'repository' => '/typeahead/common/repositories/', + 'package' => '/typeahead/common/packages/', + 'project' => '/typeahead/common/projects/', 'userorproject' => '/typeahead/common/accountsorprojects/', - 'buildplan' => '/typeahead/common/buildplans/', + 'buildplan' => '/typeahead/common/buildplans/', + 'taskpriority' => '/typeahead/common/taskpriority/', ), 'markup' => $template, ); diff --git a/src/applications/herald/storage/HeraldRule.php b/src/applications/herald/storage/HeraldRule.php index 82eb9926b6..57dbda5ca3 100644 --- a/src/applications/herald/storage/HeraldRule.php +++ b/src/applications/herald/storage/HeraldRule.php @@ -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; diff --git a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php index e7d9ab0f97..74c2f38d96 100644 --- a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php +++ b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php @@ -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) diff --git a/webroot/rsrc/js/application/herald/HeraldRuleEditor.js b/webroot/rsrc/js/application/herald/HeraldRuleEditor.js index ee3a597fb3..cf11b04780 100644 --- a/webroot/rsrc/js/application/herald/HeraldRuleEditor.js +++ b/webroot/rsrc/js/application/herald/HeraldRuleEditor.js @@ -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];