mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 12:00:55 +01:00
Simplify Auditors custom field in Differential
Summary: Ref T11114. This field just stores the value of "Auditors" so you can trigger auditors explicitly later on if you want. Test Plan: Created and edited revisions with "Auditors". Reviewers: chad Reviewed By: chad Maniphest Tasks: T11114 Differential Revision: https://secure.phabricator.com/D17070
This commit is contained in:
parent
d12856b5d4
commit
914d9fa8b9
6 changed files with 44 additions and 24 deletions
|
@ -16,7 +16,7 @@ final class DifferentialAuditorsField
|
|||
}
|
||||
|
||||
public function getValueForStorage() {
|
||||
return json_encode($this->getValue());
|
||||
return phutil_json_encode($this->getValue());
|
||||
}
|
||||
|
||||
public function setValueFromStorage($value) {
|
||||
|
@ -28,33 +28,16 @@ final class DifferentialAuditorsField
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function shouldAppearInCommitMessage() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function shouldAllowEditInCommitMessage() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function canDisableField() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getRequiredHandlePHIDsForCommitMessage() {
|
||||
return nonempty($this->getValue(), array());
|
||||
public function shouldAppearInEditEngine() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function parseCommitMessageValue($value) {
|
||||
return $this->parseObjectList(
|
||||
$value,
|
||||
array(
|
||||
PhabricatorPeopleUserPHIDType::TYPECONST,
|
||||
PhabricatorProjectProjectPHIDType::TYPECONST,
|
||||
));
|
||||
}
|
||||
|
||||
public function renderCommitMessageValue(array $handles) {
|
||||
return $this->renderObjectList($handles);
|
||||
public function shouldAppearInCommitMessage() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function shouldAppearInConduitTransactions() {
|
||||
|
@ -65,4 +48,8 @@ final class DifferentialAuditorsField
|
|||
return new ConduitPHIDListParameterType();
|
||||
}
|
||||
|
||||
public function shouldAppearInApplicationTransactions() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,14 @@ final class DifferentialAuditorsCommitMessageField
|
|||
return 'phabricator:auditors';
|
||||
}
|
||||
|
||||
public function isFieldEditable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isTemplateField() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function readFieldValueFromConduit($value) {
|
||||
return $this->readStringListFieldValueFromConduit($value);
|
||||
}
|
||||
|
|
|
@ -182,7 +182,7 @@ abstract class DifferentialCommitMessageField
|
|||
protected function isCustomFieldEnabled($key) {
|
||||
$field_list = PhabricatorCustomField::getObjectFields(
|
||||
new DifferentialRevision(),
|
||||
PhabricatorCustomField::ROLE_VIEW);
|
||||
DifferentialCustomField::ROLE_COMMITMESSAGE);
|
||||
|
||||
$fields = $field_list->getFields();
|
||||
return isset($fields[$key]);
|
||||
|
|
|
@ -37,6 +37,10 @@ final class PhabricatorCustomFieldEditField
|
|||
}
|
||||
|
||||
protected function buildControl() {
|
||||
if ($this->getIsConduitOnly()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$field = $this->getCustomField();
|
||||
$clone = clone $field;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ final class PhabricatorCustomFieldEditEngineExtension
|
|||
|
||||
$field_list = PhabricatorCustomField::getObjectFields(
|
||||
$object,
|
||||
PhabricatorCustomField::ROLE_EDIT);
|
||||
PhabricatorCustomField::ROLE_EDITENGINE);
|
||||
|
||||
$field_list->setViewer($viewer);
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ abstract class PhabricatorCustomField extends Phobject {
|
|||
const ROLE_GLOBALSEARCH = 'GlobalSearch';
|
||||
const ROLE_CONDUIT = 'conduit';
|
||||
const ROLE_HERALD = 'herald';
|
||||
const ROLE_EDITENGINE = 'EditEngine';
|
||||
|
||||
|
||||
/* -( Building Applications with Custom Fields )--------------------------- */
|
||||
|
@ -292,6 +293,9 @@ abstract class PhabricatorCustomField extends Phobject {
|
|||
return $this->shouldAppearInTransactionMail();
|
||||
case self::ROLE_HERALD:
|
||||
return $this->shouldAppearInHerald();
|
||||
case self::ROLE_EDITENGINE:
|
||||
return $this->shouldAppearInEditView() ||
|
||||
$this->shouldAppearInEditEngine();
|
||||
case self::ROLE_DEFAULT:
|
||||
return true;
|
||||
default:
|
||||
|
@ -1120,12 +1124,19 @@ abstract class PhabricatorCustomField extends Phobject {
|
|||
return $this->proxy->newStandardEditField();
|
||||
}
|
||||
|
||||
if (!$this->shouldAppearInEditView()) {
|
||||
$conduit_only = true;
|
||||
} else {
|
||||
$conduit_only = false;
|
||||
}
|
||||
|
||||
return $this->newEditField()
|
||||
->setKey($this->getFieldKey())
|
||||
->setEditTypeKey($this->getModernFieldKey())
|
||||
->setLabel($this->getFieldName())
|
||||
->setDescription($this->getFieldDescription())
|
||||
->setTransactionType($this->getApplicationTransactionType())
|
||||
->setIsConduitOnly($conduit_only)
|
||||
->setValue($this->getNewValueForApplicationTransactions());
|
||||
}
|
||||
|
||||
|
@ -1146,6 +1157,16 @@ abstract class PhabricatorCustomField extends Phobject {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @task edit
|
||||
*/
|
||||
public function shouldAppearInEditEngine() {
|
||||
if ($this->proxy) {
|
||||
return $this->proxy->shouldAppearInEditEngine();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @task edit
|
||||
|
|
Loading…
Reference in a new issue