1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 12:52:42 +01:00

Implement a "Space is any of..." condition in Herald

Summary: Ref T8498. Allow Herald rules to act on the Space which contains an object.

Test Plan:
  - Wrote a "Space is any of..." rule, created tasks that matched and failed the rule.
  - Also created a Pholio rule with the "Space..." condition.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8498

Differential Revision: https://secure.phabricator.com/D13242
This commit is contained in:
epriestley 2015-06-11 10:14:06 -07:00
parent 88e7cd158f
commit d5668ddeae
6 changed files with 34 additions and 11 deletions

View file

@ -371,7 +371,7 @@ return array(
'rsrc/js/application/doorkeeper/behavior-doorkeeper-tag.js' => 'e5822781',
'rsrc/js/application/files/behavior-icon-composer.js' => '8ef9ab58',
'rsrc/js/application/files/behavior-launch-icon-composer.js' => '48086888',
'rsrc/js/application/herald/HeraldRuleEditor.js' => '271ffdd7',
'rsrc/js/application/herald/HeraldRuleEditor.js' => 'b2cae298',
'rsrc/js/application/herald/PathTypeahead.js' => 'f7fc67ec',
'rsrc/js/application/herald/herald-rule-editor.js' => '7ebaeed3',
'rsrc/js/application/maniphest/behavior-batch-editor.js' => 'f5d1233b',
@ -527,7 +527,7 @@ return array(
'global-drag-and-drop-css' => '697324ad',
'harbormaster-css' => '49d64eb4',
'herald-css' => '826075fa',
'herald-rule-editor' => '271ffdd7',
'herald-rule-editor' => 'b2cae298',
'herald-test-css' => '778b008e',
'homepage-panel-css' => 'e34bf140',
'inline-comment-summary-css' => '51efda3a',
@ -1009,15 +1009,6 @@ return array(
'phabricator-drag-and-drop-file-upload',
'phabricator-draggable-list',
),
'271ffdd7' => array(
'multirow-row-manager',
'javelin-install',
'javelin-util',
'javelin-dom',
'javelin-stratcom',
'javelin-json',
'phabricator-prefab',
),
'2818f5ce' => array(
'javelin-install',
'javelin-util',
@ -1701,6 +1692,15 @@ return array(
'javelin-uri',
'javelin-request',
),
'b2cae298' => array(
'multirow-row-manager',
'javelin-install',
'javelin-util',
'javelin-dom',
'javelin-stratcom',
'javelin-json',
'phabricator-prefab',
),
'b3a4b884' => array(
'javelin-behavior',
'phabricator-prefab',

View file

@ -44,6 +44,7 @@ abstract class HeraldAdapter {
const FIELD_TASK_STATUS = 'taskstatus';
const FIELD_PUSHER_IS_COMMITTER = 'pusher-is-committer';
const FIELD_PATH = 'path';
const FIELD_SPACE = 'space';
const CONDITION_CONTAINS = 'contains';
const CONDITION_NOT_CONTAINS = '!contains';
@ -101,6 +102,7 @@ abstract class HeraldAdapter {
const VALUE_TASK_STATUS = 'taskstatus';
const VALUE_LEGAL_DOCUMENTS = 'legaldocuments';
const VALUE_APPLICATION_EMAIL = 'applicationemail';
const VALUE_SPACE = 'space';
private $contentSource;
private $isNewObject;
@ -219,6 +221,19 @@ abstract class HeraldAdapter {
$value[] = $this->getApplicationEmail()->getPHID();
}
return $value;
case self::FIELD_SPACE:
$object = $this->getObject();
if (!($object instanceof PhabricatorSpacesInterface)) {
throw new Exception(
pht(
'Adapter object (of class "%s") does not implement interface '.
'"%s", so the Space field value can not be determined.',
get_class($object),
'PhabricatorSpacesInterface'));
}
return PhabricatorSpacesNamespaceQuery::getObjectSpacePHID($object);
default:
if ($this->isHeraldCustomKey($field_name)) {
return $this->getCustomFieldValue($field_name);
@ -400,6 +415,7 @@ abstract class HeraldAdapter {
self::FIELD_TASK_STATUS => pht('Task status'),
self::FIELD_PUSHER_IS_COMMITTER => pht('Pusher same as committer'),
self::FIELD_PATH => pht('Path'),
self::FIELD_SPACE => pht('Space'),
) + $this->getCustomFieldNameMap();
}
@ -453,6 +469,7 @@ abstract class HeraldAdapter {
case self::FIELD_PUSHER:
case self::FIELD_TASK_PRIORITY:
case self::FIELD_TASK_STATUS:
case self::FIELD_SPACE:
return array(
self::CONDITION_IS_ANY,
self::CONDITION_IS_NOT_ANY,
@ -957,6 +974,8 @@ abstract class HeraldAdapter {
return self::VALUE_TASK_PRIORITY;
case self::FIELD_TASK_STATUS:
return self::VALUE_TASK_STATUS;
case self::FIELD_SPACE:
return self::VALUE_SPACE;
default:
return self::VALUE_USER;
}

View file

@ -73,6 +73,7 @@ final class HeraldManiphestTaskAdapter extends HeraldAdapter {
self::FIELD_TASK_STATUS,
self::FIELD_IS_NEW_OBJECT,
self::FIELD_APPLICATION_EMAIL,
self::FIELD_SPACE,
),
parent::getFields());
}

View file

@ -52,6 +52,7 @@ final class HeraldPholioMockAdapter extends HeraldAdapter {
self::FIELD_CC,
self::FIELD_PROJECTS,
self::FIELD_IS_NEW_OBJECT,
self::FIELD_SPACE,
),
parent::getFields());
}

View file

@ -632,6 +632,7 @@ final class HeraldRuleController extends HeraldController {
'email' => new PhabricatorMetaMTAMailableDatasource(),
'userorproject' => new PhabricatorProjectOrUserDatasource(),
'applicationemail' => new PhabricatorMetaMTAApplicationEmailDatasource(),
'space' => new PhabricatorSpacesNamespaceDatasource(),
);
foreach ($sources as $key => $source) {

View file

@ -222,6 +222,7 @@ JX.install('HeraldRuleEditor', {
case 'taskstatus':
case 'legaldocuments':
case 'applicationemail':
case 'space':
var tokenizer = this._newTokenizer(type);
input = tokenizer[0];
get_fn = tokenizer[1];