mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Herald - add support for "content source" conditions
Summary: ...and deploy on Maniphest. Ref T1638. Test Plan: created a herald rule to be cc'd for tasks created via web. made a task via web and another via email and was cc'd appropriately. edited the herald to be cc'd for tasks created via not web. made 2 tasks again and got cc'd appropriately Reviewers: epriestley Reviewed By: epriestley CC: Korvin, aran Maniphest Tasks: T1638 Differential Revision: https://secure.phabricator.com/D7145
This commit is contained in:
parent
b435c0297e
commit
477d4e9db1
7 changed files with 53 additions and 3 deletions
|
@ -19,6 +19,7 @@ abstract class HeraldAdapter {
|
|||
const FIELD_RULE = 'rule';
|
||||
const FIELD_AFFECTED_PACKAGE = 'affected-package';
|
||||
const FIELD_AFFECTED_PACKAGE_OWNER = 'affected-package-owner';
|
||||
const FIELD_CONTENT_SOURCE = 'contentsource';
|
||||
|
||||
const CONDITION_CONTAINS = 'contains';
|
||||
const CONDITION_NOT_CONTAINS = '!contains';
|
||||
|
@ -55,6 +56,17 @@ abstract class HeraldAdapter {
|
|||
const VALUE_OWNERS_PACKAGE = 'package';
|
||||
const VALUE_PROJECT = 'project';
|
||||
const VALUE_FLAG_COLOR = 'flagcolor';
|
||||
const VALUE_CONTENT_SOURCE = 'contentsource';
|
||||
|
||||
private $contentSource;
|
||||
|
||||
public function setContentSource(PhabricatorContentSource $content_source) {
|
||||
$this->contentSource = $content_source;
|
||||
return $this;
|
||||
}
|
||||
public function getContentSource() {
|
||||
return $this->contentSource;
|
||||
}
|
||||
|
||||
abstract public function getPHID();
|
||||
abstract public function getHeraldName();
|
||||
|
@ -63,6 +75,8 @@ abstract class HeraldAdapter {
|
|||
switch ($field_name) {
|
||||
case self::FIELD_RULE:
|
||||
return null;
|
||||
case self::FIELD_CONTENT_SOURCE:
|
||||
return $this->getContentSource()->getSource();
|
||||
default:
|
||||
throw new Exception(
|
||||
"Unknown field '{$field_name}'!");
|
||||
|
@ -108,6 +122,7 @@ abstract class HeraldAdapter {
|
|||
self::FIELD_AFFECTED_PACKAGE => pht('Any affected package'),
|
||||
self::FIELD_AFFECTED_PACKAGE_OWNER =>
|
||||
pht("Any affected package's owner"),
|
||||
self:: FIELD_CONTENT_SOURCE => pht('Content Source')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -186,6 +201,11 @@ abstract class HeraldAdapter {
|
|||
self::CONDITION_INCLUDE_ANY,
|
||||
self::CONDITION_INCLUDE_NONE,
|
||||
);
|
||||
case self::FIELD_CONTENT_SOURCE:
|
||||
return array(
|
||||
self::CONDITION_IS,
|
||||
self::CONDITION_IS_NOT,
|
||||
);
|
||||
default:
|
||||
throw new Exception(
|
||||
"This adapter does not define conditions for field '{$field}'!");
|
||||
|
@ -491,11 +511,18 @@ abstract class HeraldAdapter {
|
|||
switch ($condition) {
|
||||
case self::CONDITION_CONTAINS:
|
||||
case self::CONDITION_NOT_CONTAINS:
|
||||
case self::CONDITION_IS:
|
||||
case self::CONDITION_IS_NOT:
|
||||
case self::CONDITION_REGEXP:
|
||||
case self::CONDITION_REGEXP_PAIR:
|
||||
return self::VALUE_TEXT;
|
||||
case self::CONDITION_IS:
|
||||
case self::CONDITION_IS_NOT:
|
||||
switch ($field) {
|
||||
case self::FIELD_CONTENT_SOURCE:
|
||||
return self::VALUE_CONTENT_SOURCE;
|
||||
default:
|
||||
return self::VALUE_TEXT;
|
||||
}
|
||||
break;
|
||||
case self::CONDITION_IS_ANY:
|
||||
case self::CONDITION_IS_NOT_ANY:
|
||||
switch ($field) {
|
||||
|
|
|
@ -34,6 +34,7 @@ final class HeraldManiphestTaskAdapter extends HeraldAdapter {
|
|||
self::FIELD_BODY,
|
||||
self::FIELD_AUTHOR,
|
||||
self::FIELD_CC,
|
||||
self::FIELD_CONTENT_SOURCE,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -413,6 +413,8 @@ final class HeraldRuleController extends HeraldController {
|
|||
'rules' => $all_rules,
|
||||
'colors' => PhabricatorFlagColor::getColorNameMap(),
|
||||
'defaultColor' => PhabricatorFlagColor::COLOR_BLUE,
|
||||
'contentSources' => PhabricatorContentSource::getSourceNameMap(),
|
||||
'defaultSource' => PhabricatorContentSource::SOURCE_WEB
|
||||
),
|
||||
'author' => array($rule->getAuthorPHID() =>
|
||||
$handles[$rule->getAuthorPHID()]->getName()),
|
||||
|
|
|
@ -13,7 +13,7 @@ final class HeraldRule extends HeraldDAO
|
|||
protected $repetitionPolicy;
|
||||
protected $ruleType;
|
||||
|
||||
protected $configVersion = 9;
|
||||
protected $configVersion = 10;
|
||||
|
||||
private $ruleApplied = self::ATTACHABLE; // phids for which this rule has been applied
|
||||
private $validAuthor = self::ATTACHABLE;
|
||||
|
|
|
@ -53,6 +53,19 @@ final class PhabricatorContentSource {
|
|||
array());
|
||||
}
|
||||
|
||||
public static function getSourceNameMap() {
|
||||
return array(
|
||||
self::SOURCE_WEB => pht('Web'),
|
||||
self::SOURCE_EMAIL => pht('Email'),
|
||||
self::SOURCE_CONDUIT => pht('Conduit'),
|
||||
self::SOURCE_MOBILE => pht('Mobile'),
|
||||
self::SOURCE_TABLET => pht('Tablet'),
|
||||
self::SOURCE_FAX => pht('Fax'),
|
||||
self::SOURCE_LEGACY => pht('Legacy'),
|
||||
self::SOURCE_UNKNOWN => pht('Other'),
|
||||
);
|
||||
}
|
||||
|
||||
public function serialize() {
|
||||
return json_encode(array(
|
||||
'source' => $this->getSource(),
|
||||
|
|
|
@ -1496,6 +1496,7 @@ abstract class PhabricatorApplicationTransactionEditor
|
|||
array $xactions) {
|
||||
|
||||
$adapter = $this->buildHeraldAdapter($object, $xactions);
|
||||
$adapter->setContentSource($this->getContentSource());
|
||||
$xscript = HeraldEngine::loadAndApplyRules($adapter);
|
||||
|
||||
$this->setHeraldAdapter($adapter);
|
||||
|
|
|
@ -225,6 +225,12 @@ JX.install('HeraldRuleEditor', {
|
|||
get_fn = JX.bag;
|
||||
set_fn = JX.bag;
|
||||
break;
|
||||
case 'contentsource':
|
||||
input = this._renderSelect(this._config.template.contentSources);
|
||||
get_fn = function() { return input.value; };
|
||||
set_fn = function(v) { input.value = v; };
|
||||
set_fn(this._config.template.defaultSource);
|
||||
break;
|
||||
case 'flagcolor':
|
||||
input = this._renderSelect(this._config.template.colors);
|
||||
get_fn = function() { return input.value; };
|
||||
|
|
Loading…
Reference in a new issue