mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 04:20:55 +01:00
Implement Differential subscribers as a CustomField
Summary: Ref T3886. Now that a custom field can emit a core transaction, just emit a subscribers transaction. Test Plan: {F116014} Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T3886 Differential Revision: https://secure.phabricator.com/D8289
This commit is contained in:
parent
f91e94eb90
commit
aa7ba4c6e6
9 changed files with 66 additions and 18 deletions
|
@ -464,6 +464,7 @@ phutil_register_library_map(array(
|
|||
'DifferentialRevisionViewController' => 'applications/differential/controller/DifferentialRevisionViewController.php',
|
||||
'DifferentialSearchIndexer' => 'applications/differential/search/DifferentialSearchIndexer.php',
|
||||
'DifferentialSubscribeController' => 'applications/differential/controller/DifferentialSubscribeController.php',
|
||||
'DifferentialSubscribersField' => 'applications/differential/customfield/DifferentialSubscribersField.php',
|
||||
'DifferentialSummaryField' => 'applications/differential/customfield/DifferentialSummaryField.php',
|
||||
'DifferentialSummaryFieldSpecification' => 'applications/differential/field/specification/DifferentialSummaryFieldSpecification.php',
|
||||
'DifferentialTasksAttacher' => 'applications/differential/DifferentialTasksAttacher.php',
|
||||
|
@ -3012,6 +3013,7 @@ phutil_register_library_map(array(
|
|||
'DifferentialRevisionViewController' => 'DifferentialController',
|
||||
'DifferentialSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
|
||||
'DifferentialSubscribeController' => 'DifferentialController',
|
||||
'DifferentialSubscribersField' => 'DifferentialCoreCustomField',
|
||||
'DifferentialSummaryField' => 'DifferentialCoreCustomField',
|
||||
'DifferentialSummaryFieldSpecification' => 'DifferentialFreeformFieldSpecification',
|
||||
'DifferentialTestPlanField' => 'DifferentialCoreCustomField',
|
||||
|
|
|
@ -14,9 +14,11 @@ abstract class DifferentialCoreCustomField
|
|||
abstract protected function readValueFromRevision(
|
||||
DifferentialRevision $revision);
|
||||
|
||||
abstract protected function writeValueToRevision(
|
||||
protected function writeValueToRevision(
|
||||
DifferentialRevision $revision,
|
||||
$value);
|
||||
$value) {
|
||||
throw new PhabricatorCustomFieldImplementationIncompleteException($this);
|
||||
}
|
||||
|
||||
protected function isCoreFieldRequired() {
|
||||
return false;
|
||||
|
|
|
@ -20,12 +20,6 @@ final class DifferentialEditPolicyField
|
|||
return $revision->getEditPolicy();
|
||||
}
|
||||
|
||||
protected function writeValueToRevision(
|
||||
DifferentialRevision $revision,
|
||||
$value) {
|
||||
$revision->setEditPolicy($value);
|
||||
}
|
||||
|
||||
public function readValueFromRequest(AphrontRequest $request) {
|
||||
$this->setValue($request->getStr($this->getFieldKey()));
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ final class DifferentialRepositoryField
|
|||
public function readValueFromRequest(AphrontRequest $request) {
|
||||
$phids = $request->getArr($this->getFieldKey());
|
||||
$first = head($phids);
|
||||
$this->setValue(coalesce($first, null));
|
||||
$this->setValue(nonempty($first, null));
|
||||
}
|
||||
|
||||
public function getRequiredHandlePHIDsForEdit() {
|
||||
|
@ -41,7 +41,6 @@ final class DifferentialRepositoryField
|
|||
}
|
||||
|
||||
public function renderEditControl(array $handles) {
|
||||
|
||||
if ($this->getValue()) {
|
||||
$control_value = array_select_keys($handles, array($this->getValue()));
|
||||
} else {
|
||||
|
@ -97,7 +96,6 @@ final class DifferentialRepositoryField
|
|||
$xaction->renderHandleLink($author_phid),
|
||||
$xaction->renderHandleLink($old));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getApplicationTransactionTitleForFeed(
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
final class DifferentialSubscribersField
|
||||
extends DifferentialCoreCustomField {
|
||||
|
||||
public function getFieldKey() {
|
||||
return 'differential:subscribers';
|
||||
}
|
||||
|
||||
public function getFieldName() {
|
||||
return pht('Subscribers');
|
||||
}
|
||||
|
||||
public function getFieldDescription() {
|
||||
return pht('Manage subscribers.');
|
||||
}
|
||||
|
||||
protected function readValueFromRevision(
|
||||
DifferentialRevision $revision) {
|
||||
return PhabricatorSubscribersQuery::loadSubscribersForPHID(
|
||||
$revision->getPHID());
|
||||
}
|
||||
|
||||
public function getNewValueForApplicationTransactions() {
|
||||
return array('=' => $this->getValue());
|
||||
}
|
||||
|
||||
public function readValueFromRequest(AphrontRequest $request) {
|
||||
$this->setValue($request->getArr($this->getFieldKey()));
|
||||
}
|
||||
|
||||
public function getRequiredHandlePHIDsForEdit() {
|
||||
return $this->getValue();
|
||||
}
|
||||
|
||||
public function renderEditControl(array $handles) {
|
||||
return id(new AphrontFormTokenizerControl())
|
||||
->setName($this->getFieldKey())
|
||||
->setDatasource('/typeahead/common/mailable/')
|
||||
->setValue($handles)
|
||||
->setError($this->getFieldError())
|
||||
->setLabel($this->getFieldName());
|
||||
}
|
||||
|
||||
public function getApplicationTransactionType() {
|
||||
return PhabricatorTransactions::TYPE_SUBSCRIBERS;
|
||||
}
|
||||
|
||||
}
|
|
@ -20,12 +20,6 @@ final class DifferentialViewPolicyField
|
|||
return $revision->getViewPolicy();
|
||||
}
|
||||
|
||||
protected function writeValueToRevision(
|
||||
DifferentialRevision $revision,
|
||||
$value) {
|
||||
$revision->setViewPolicy($value);
|
||||
}
|
||||
|
||||
public function readValueFromRequest(AphrontRequest $request) {
|
||||
$this->setValue($request->getStr($this->getFieldKey()));
|
||||
}
|
||||
|
|
|
@ -58,6 +58,8 @@ final class DifferentialTransactionEditor
|
|||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||
$object->setEditPolicy($xaction->getNewValue());
|
||||
return;
|
||||
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
||||
return;
|
||||
}
|
||||
|
||||
return parent::applyCustomInternalTransaction($object, $xaction);
|
||||
|
@ -71,6 +73,8 @@ final class DifferentialTransactionEditor
|
|||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||
return;
|
||||
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
||||
return;
|
||||
}
|
||||
|
||||
return parent::applyCustomExternalTransaction($object, $xaction);
|
||||
|
|
|
@ -469,6 +469,7 @@ final class DifferentialRevision extends DifferentialDAO
|
|||
new DifferentialTitleField(),
|
||||
new DifferentialSummaryField(),
|
||||
new DifferentialTestPlanField(),
|
||||
new DifferentialSubscribersField(),
|
||||
new DifferentialRepositoryField(),
|
||||
new DifferentialViewPolicyField(),
|
||||
new DifferentialEditPolicyField(),
|
||||
|
|
|
@ -186,7 +186,11 @@ abstract class PhabricatorApplicationTransaction
|
|||
public function getHandle($phid) {
|
||||
if (empty($this->handles[$phid])) {
|
||||
throw new Exception(
|
||||
"Transaction requires a handle ('{$phid}') it did not load.");
|
||||
pht(
|
||||
'Transaction ("%s") requires a handle ("%s") that it did not '.
|
||||
'load.',
|
||||
$this->getPHID(),
|
||||
$phid));
|
||||
}
|
||||
return $this->handles[$phid];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue