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

Modularize Application Email Herald field

Summary:
Ref T8726. There's no interface we can check for this, so the adapter needs to opt in.

Also fix a spelling mistake.

Test Plan: Created rules with "Application Email" fields.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8726

Differential Revision: https://secure.phabricator.com/D13499
This commit is contained in:
epriestley 2015-07-06 13:16:26 -07:00
parent bfbc0e638d
commit 9f220995b2
5 changed files with 57 additions and 24 deletions

View file

@ -0,0 +1,5 @@
# NOTE: This is a spelling correction.
UPDATE {$NAMESPACE}_herald.herald_condition
SET fieldName = 'application-email'
WHERE fieldName = 'applicaton-email';

View file

@ -2112,6 +2112,7 @@ phutil_register_library_map(array(
'PhabricatorMetaMTAApplicationEmail' => 'applications/metamta/storage/PhabricatorMetaMTAApplicationEmail.php',
'PhabricatorMetaMTAApplicationEmailDatasource' => 'applications/metamta/typeahead/PhabricatorMetaMTAApplicationEmailDatasource.php',
'PhabricatorMetaMTAApplicationEmailEditor' => 'applications/metamta/editor/PhabricatorMetaMTAApplicationEmailEditor.php',
'PhabricatorMetaMTAApplicationEmailHeraldField' => 'applications/metamta/herald/PhabricatorMetaMTAApplicationEmailHeraldField.php',
'PhabricatorMetaMTAApplicationEmailPHIDType' => 'applications/phid/PhabricatorMetaMTAApplicationEmailPHIDType.php',
'PhabricatorMetaMTAApplicationEmailPanel' => 'applications/metamta/applicationpanel/PhabricatorMetaMTAApplicationEmailPanel.php',
'PhabricatorMetaMTAApplicationEmailQuery' => 'applications/metamta/query/PhabricatorMetaMTAApplicationEmailQuery.php',
@ -5800,6 +5801,7 @@ phutil_register_library_map(array(
),
'PhabricatorMetaMTAApplicationEmailDatasource' => 'PhabricatorTypeaheadDatasource',
'PhabricatorMetaMTAApplicationEmailEditor' => 'PhabricatorApplicationTransactionEditor',
'PhabricatorMetaMTAApplicationEmailHeraldField' => 'HeraldField',
'PhabricatorMetaMTAApplicationEmailPHIDType' => 'PhabricatorPHIDType',
'PhabricatorMetaMTAApplicationEmailPanel' => 'PhabricatorApplicationConfigurationPanel',
'PhabricatorMetaMTAApplicationEmailQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',

View file

@ -29,7 +29,6 @@ abstract class HeraldAdapter extends Phobject {
const FIELD_BRANCHES = 'branches';
const FIELD_AUTHOR_RAW = 'author-raw';
const FIELD_COMMITTER_RAW = 'committer-raw';
const FIELD_APPLICATION_EMAIL = 'applicaton-email';
const FIELD_TASK_PRIORITY = 'taskpriority';
const FIELD_TASK_STATUS = 'taskstatus';
const FIELD_PUSHER_IS_COMMITTER = 'pusher-is-committer';
@ -164,6 +163,10 @@ abstract class HeraldAdapter extends Phobject {
return $this;
}
public function supportsApplicationEmail() {
return false;
}
public function setApplicationEmail(
PhabricatorMetaMTAApplicationEmail $email) {
$this->applicationEmail = $email;
@ -183,19 +186,8 @@ abstract class HeraldAdapter extends Phobject {
return $impl->getHeraldFieldValue($this->getObject());
}
switch ($field_name) {
case self::FIELD_APPLICATION_EMAIL:
$value = array();
// while there is only one match by implementation, we do set
// comparisons on phids, so return an array with just the phid
if ($this->getApplicationEmail()) {
$value[] = $this->getApplicationEmail()->getPHID();
}
return $value;
default:
throw new Exception(pht("Unknown field '%s'!", $field_name));
}
}
abstract public function applyHeraldEffects(array $effects);
@ -391,7 +383,6 @@ abstract class HeraldAdapter extends Phobject {
self::FIELD_BRANCHES => pht('Commit\'s branches'),
self::FIELD_AUTHOR_RAW => pht('Raw author name'),
self::FIELD_COMMITTER_RAW => pht('Raw committer name'),
self::FIELD_APPLICATION_EMAIL => pht('Receiving email address'),
self::FIELD_TASK_PRIORITY => pht('Task priority'),
self::FIELD_TASK_STATUS => pht('Task status'),
self::FIELD_PUSHER_IS_COMMITTER => pht('Pusher same as committer'),
@ -481,13 +472,6 @@ abstract class HeraldAdapter extends Phobject {
self::CONDITION_EXISTS,
self::CONDITION_NOT_EXISTS,
);
case self::FIELD_APPLICATION_EMAIL:
return array(
self::CONDITION_INCLUDE_ANY,
self::CONDITION_INCLUDE_NONE,
self::CONDITION_EXISTS,
self::CONDITION_NOT_EXISTS,
);
case self::FIELD_DIFF_FILE:
case self::FIELD_BRANCHES:
return array(
@ -944,8 +928,6 @@ abstract class HeraldAdapter extends Phobject {
return self::VALUE_PROJECT;
case self::FIELD_REVIEWERS:
return self::VALUE_USER_OR_PROJECT;
case self::FIELD_APPLICATION_EMAIL:
return self::VALUE_APPLICATION_EMAIL;
default:
return self::VALUE_USER;
}

View file

@ -21,6 +21,10 @@ final class HeraldManiphestTaskAdapter extends HeraldAdapter {
$this->task = $this->newObject();
}
public function supportsApplicationEmail() {
return true;
}
public function getRepetitionOptions() {
return array(
HeraldRepetitionPolicyConfig::EVERY,
@ -72,7 +76,6 @@ final class HeraldManiphestTaskAdapter extends HeraldAdapter {
self::FIELD_ASSIGNEE,
self::FIELD_TASK_PRIORITY,
self::FIELD_TASK_STATUS,
self::FIELD_APPLICATION_EMAIL,
),
parent::getFields());
}

View file

@ -0,0 +1,41 @@
<?php
final class PhabricatorMetaMTAApplicationEmailHeraldField
extends HeraldField {
const FIELDCONST = 'application-email';
public function getHeraldFieldName() {
return pht('Receiving email address');
}
public function supportsObject($object) {
return $this->getAdapter()->supportsApplicationEmail();
}
public function getHeraldFieldValue($object) {
$phids = array();
$email = $this->getAdapter()->getApplicationEmail();
if ($email) {
$phids[] = $email;
}
return $phids;
}
protected function getHeraldFieldStandardConditions() {
return self::STANDARD_LIST;
}
public function getHeraldFieldValueType($condition) {
switch ($condition) {
case HeraldAdapter::CONDITION_EXISTS:
case HeraldAdapter::CONDITION_NOT_EXISTS:
return HeraldAdapter::VALUE_NONE;
default:
return HeraldAdapter::VALUE_APPLICATION_EMAIL;
}
}
}