mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 13:30:55 +01:00
Begin adding "pro" modular transaction fields to Differential
Summary: Ref T11114. Currently, all of Differential is extremely custom CustomFields. I want to back away from that somewhat and leverage more EditEngine / ModularTransactions infrastructure. This allows EditEngine, ModularTransactions, and CustomFields to coexist in an uneasy peace. The "EditPro" controller applies a //different edit// than the CustomFields do, but everything works out in the end. I think. Hopefully the horrible mess I am creating here will be short-lived. Test Plan: - Edited a revision with the normal editor. - Edited a revision with the pro editor. - Created a revision with `arc diff`. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11114 Differential Revision: https://secure.phabricator.com/D17044
This commit is contained in:
parent
eda64b8549
commit
0906bf547b
6 changed files with 91 additions and 8 deletions
|
@ -553,6 +553,8 @@ phutil_register_library_map(array(
|
||||||
'DifferentialRevisionStatus' => 'applications/differential/constants/DifferentialRevisionStatus.php',
|
'DifferentialRevisionStatus' => 'applications/differential/constants/DifferentialRevisionStatus.php',
|
||||||
'DifferentialRevisionSummaryHeraldField' => 'applications/differential/herald/DifferentialRevisionSummaryHeraldField.php',
|
'DifferentialRevisionSummaryHeraldField' => 'applications/differential/herald/DifferentialRevisionSummaryHeraldField.php',
|
||||||
'DifferentialRevisionTitleHeraldField' => 'applications/differential/herald/DifferentialRevisionTitleHeraldField.php',
|
'DifferentialRevisionTitleHeraldField' => 'applications/differential/herald/DifferentialRevisionTitleHeraldField.php',
|
||||||
|
'DifferentialRevisionTitleTransaction' => 'applications/differential/xaction/DifferentialRevisionTitleTransaction.php',
|
||||||
|
'DifferentialRevisionTransactionType' => 'applications/differential/xaction/DifferentialRevisionTransactionType.php',
|
||||||
'DifferentialRevisionUpdateHistoryView' => 'applications/differential/view/DifferentialRevisionUpdateHistoryView.php',
|
'DifferentialRevisionUpdateHistoryView' => 'applications/differential/view/DifferentialRevisionUpdateHistoryView.php',
|
||||||
'DifferentialRevisionViewController' => 'applications/differential/controller/DifferentialRevisionViewController.php',
|
'DifferentialRevisionViewController' => 'applications/differential/controller/DifferentialRevisionViewController.php',
|
||||||
'DifferentialSchemaSpec' => 'applications/differential/storage/DifferentialSchemaSpec.php',
|
'DifferentialSchemaSpec' => 'applications/differential/storage/DifferentialSchemaSpec.php',
|
||||||
|
@ -5201,6 +5203,8 @@ phutil_register_library_map(array(
|
||||||
'DifferentialRevisionStatus' => 'Phobject',
|
'DifferentialRevisionStatus' => 'Phobject',
|
||||||
'DifferentialRevisionSummaryHeraldField' => 'DifferentialRevisionHeraldField',
|
'DifferentialRevisionSummaryHeraldField' => 'DifferentialRevisionHeraldField',
|
||||||
'DifferentialRevisionTitleHeraldField' => 'DifferentialRevisionHeraldField',
|
'DifferentialRevisionTitleHeraldField' => 'DifferentialRevisionHeraldField',
|
||||||
|
'DifferentialRevisionTitleTransaction' => 'DifferentialRevisionTransactionType',
|
||||||
|
'DifferentialRevisionTransactionType' => 'PhabricatorModularTransactionType',
|
||||||
'DifferentialRevisionUpdateHistoryView' => 'AphrontView',
|
'DifferentialRevisionUpdateHistoryView' => 'AphrontView',
|
||||||
'DifferentialRevisionViewController' => 'DifferentialController',
|
'DifferentialRevisionViewController' => 'DifferentialController',
|
||||||
'DifferentialSchemaSpec' => 'PhabricatorConfigSchemaSpec',
|
'DifferentialSchemaSpec' => 'PhabricatorConfigSchemaSpec',
|
||||||
|
@ -5210,7 +5214,7 @@ phutil_register_library_map(array(
|
||||||
'DifferentialSummaryField' => 'DifferentialCoreCustomField',
|
'DifferentialSummaryField' => 'DifferentialCoreCustomField',
|
||||||
'DifferentialTestPlanField' => 'DifferentialCoreCustomField',
|
'DifferentialTestPlanField' => 'DifferentialCoreCustomField',
|
||||||
'DifferentialTitleField' => 'DifferentialCoreCustomField',
|
'DifferentialTitleField' => 'DifferentialCoreCustomField',
|
||||||
'DifferentialTransaction' => 'PhabricatorApplicationTransaction',
|
'DifferentialTransaction' => 'PhabricatorModularTransaction',
|
||||||
'DifferentialTransactionComment' => 'PhabricatorApplicationTransactionComment',
|
'DifferentialTransactionComment' => 'PhabricatorApplicationTransactionComment',
|
||||||
'DifferentialTransactionEditor' => 'PhabricatorApplicationTransactionEditor',
|
'DifferentialTransactionEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||||
'DifferentialTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
'DifferentialTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
||||||
|
|
|
@ -60,7 +60,17 @@ final class DifferentialRevisionEditEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function buildCustomEditFields($object) {
|
protected function buildCustomEditFields($object) {
|
||||||
return array();
|
return array(
|
||||||
|
id(new PhabricatorTextEditField())
|
||||||
|
->setKey('title')
|
||||||
|
->setLabel(pht('Title'))
|
||||||
|
->setTransactionType(
|
||||||
|
DifferentialRevisionTitleTransaction::TRANSACTIONTYPE)
|
||||||
|
->setDescription(pht('The title of the revision.'))
|
||||||
|
->setConduitDescription(pht('Retitle the revision.'))
|
||||||
|
->setConduitTypeDescription(pht('New revision title.'))
|
||||||
|
->setValue($object->getTitle()),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class DifferentialTransaction extends PhabricatorApplicationTransaction {
|
final class DifferentialTransaction
|
||||||
|
extends PhabricatorModularTransaction {
|
||||||
|
|
||||||
private $isCommandeerSideEffect;
|
private $isCommandeerSideEffect;
|
||||||
|
|
||||||
|
@ -17,6 +18,9 @@ final class DifferentialTransaction extends PhabricatorApplicationTransaction {
|
||||||
const MAILTAG_REVIEW_REQUEST = 'differential-review-request';
|
const MAILTAG_REVIEW_REQUEST = 'differential-review-request';
|
||||||
const MAILTAG_OTHER = 'differential-other';
|
const MAILTAG_OTHER = 'differential-other';
|
||||||
|
|
||||||
|
public function getBaseTransactionClass() {
|
||||||
|
return 'DifferentialRevisionTransactionType';
|
||||||
|
}
|
||||||
|
|
||||||
public function setIsCommandeerSideEffect($is_side_effect) {
|
public function setIsCommandeerSideEffect($is_side_effect) {
|
||||||
$this->isCommandeerSideEffect = $is_side_effect;
|
$this->isCommandeerSideEffect = $is_side_effect;
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class DifferentialRevisionTitleTransaction
|
||||||
|
extends DifferentialRevisionTransactionType {
|
||||||
|
|
||||||
|
const TRANSACTIONTYPE = 'differential.revision.title';
|
||||||
|
|
||||||
|
public function generateOldValue($object) {
|
||||||
|
return $object->getTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applyInternalEffects($object, $value) {
|
||||||
|
$object->setTitle($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitle() {
|
||||||
|
return pht(
|
||||||
|
'%s retitled this revision from %s to %s.',
|
||||||
|
$this->renderAuthor(),
|
||||||
|
$this->renderOldValue(),
|
||||||
|
$this->renderNewValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitleForFeed() {
|
||||||
|
return pht(
|
||||||
|
'%s retitled %s from %s to %s.',
|
||||||
|
$this->renderAuthor(),
|
||||||
|
$this->renderObject(),
|
||||||
|
$this->renderOldValue(),
|
||||||
|
$this->renderNewValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function validateTransactions($object, array $xactions) {
|
||||||
|
$errors = array();
|
||||||
|
|
||||||
|
if ($this->isEmptyTextTransaction($object->getTitle(), $xactions)) {
|
||||||
|
$errors[] = $this->newRequiredError(
|
||||||
|
pht('Revisions must have a title.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$max_length = $object->getColumnMaximumByteLength('title');
|
||||||
|
foreach ($xactions as $xaction) {
|
||||||
|
$new_value = $xaction->getNewValue();
|
||||||
|
$new_length = strlen($new_value);
|
||||||
|
if ($new_length > $max_length) {
|
||||||
|
$errors[] = $this->newInvalidError(
|
||||||
|
pht(
|
||||||
|
'Revision title is too long: the maximum length of a '.
|
||||||
|
'revision title is 255 bytes.'),
|
||||||
|
$xaction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $errors;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
abstract class DifferentialRevisionTransactionType
|
||||||
|
extends PhabricatorModularTransactionType {}
|
|
@ -1,5 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
// TODO: Some "final" modifiers have been VERY TEMPORARILY moved aside to
|
||||||
|
// allow DifferentialTransaction to extend this class without converting
|
||||||
|
// fully to ModularTransactions.
|
||||||
|
|
||||||
abstract class PhabricatorModularTransaction
|
abstract class PhabricatorModularTransaction
|
||||||
extends PhabricatorApplicationTransaction {
|
extends PhabricatorApplicationTransaction {
|
||||||
|
|
||||||
|
@ -76,7 +80,7 @@ abstract class PhabricatorModularTransaction
|
||||||
->applyExternalEffects($object);
|
->applyExternalEffects($object);
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function shouldHide() {
|
/* final */ public function shouldHide() {
|
||||||
if ($this->getTransactionImplementation()->shouldHide()) {
|
if ($this->getTransactionImplementation()->shouldHide()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -84,7 +88,7 @@ abstract class PhabricatorModularTransaction
|
||||||
return parent::shouldHide();
|
return parent::shouldHide();
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function getIcon() {
|
/* final */ public function getIcon() {
|
||||||
$icon = $this->getTransactionImplementation()->getIcon();
|
$icon = $this->getTransactionImplementation()->getIcon();
|
||||||
if ($icon !== null) {
|
if ($icon !== null) {
|
||||||
return $icon;
|
return $icon;
|
||||||
|
@ -93,7 +97,7 @@ abstract class PhabricatorModularTransaction
|
||||||
return parent::getIcon();
|
return parent::getIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function getTitle() {
|
/* final */ public function getTitle() {
|
||||||
$title = $this->getTransactionImplementation()->getTitle();
|
$title = $this->getTransactionImplementation()->getTitle();
|
||||||
if ($title !== null) {
|
if ($title !== null) {
|
||||||
return $title;
|
return $title;
|
||||||
|
@ -111,7 +115,7 @@ abstract class PhabricatorModularTransaction
|
||||||
return $title;
|
return $title;
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function getTitleForFeed() {
|
/* final */ public function getTitleForFeed() {
|
||||||
$title = $this->getTransactionImplementation()->getTitleForFeed();
|
$title = $this->getTransactionImplementation()->getTitleForFeed();
|
||||||
if ($title !== null) {
|
if ($title !== null) {
|
||||||
return $title;
|
return $title;
|
||||||
|
@ -120,7 +124,7 @@ abstract class PhabricatorModularTransaction
|
||||||
return parent::getTitleForFeed();
|
return parent::getTitleForFeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function getColor() {
|
/* final */ public function getColor() {
|
||||||
$color = $this->getTransactionImplementation()->getColor();
|
$color = $this->getTransactionImplementation()->getColor();
|
||||||
if ($color !== null) {
|
if ($color !== null) {
|
||||||
return $color;
|
return $color;
|
||||||
|
|
Loading…
Reference in a new issue