mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 22:10:55 +01:00
Remove Differential "Title" custom field
Summary: Ref T11114. Obsoleted by Modular Transactions + EditEngine + CommitMessageField + we just "hard code" the title of revisions into the page because we're craaazy. Test Plan: - Made an edit on `stable`. - Viewed the edit on this change, it still had the proper UI strings. - Edited/created/updated revisions. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11114 Differential Revision: https://secure.phabricator.com/D17083
This commit is contained in:
parent
f552a20c61
commit
9e4c16c4c3
5 changed files with 22 additions and 129 deletions
|
@ -572,7 +572,6 @@ phutil_register_library_map(array(
|
||||||
'DifferentialTestPlanCommitMessageField' => 'applications/differential/field/DifferentialTestPlanCommitMessageField.php',
|
'DifferentialTestPlanCommitMessageField' => 'applications/differential/field/DifferentialTestPlanCommitMessageField.php',
|
||||||
'DifferentialTestPlanField' => 'applications/differential/customfield/DifferentialTestPlanField.php',
|
'DifferentialTestPlanField' => 'applications/differential/customfield/DifferentialTestPlanField.php',
|
||||||
'DifferentialTitleCommitMessageField' => 'applications/differential/field/DifferentialTitleCommitMessageField.php',
|
'DifferentialTitleCommitMessageField' => 'applications/differential/field/DifferentialTitleCommitMessageField.php',
|
||||||
'DifferentialTitleField' => 'applications/differential/customfield/DifferentialTitleField.php',
|
|
||||||
'DifferentialTransaction' => 'applications/differential/storage/DifferentialTransaction.php',
|
'DifferentialTransaction' => 'applications/differential/storage/DifferentialTransaction.php',
|
||||||
'DifferentialTransactionComment' => 'applications/differential/storage/DifferentialTransactionComment.php',
|
'DifferentialTransactionComment' => 'applications/differential/storage/DifferentialTransactionComment.php',
|
||||||
'DifferentialTransactionEditor' => 'applications/differential/editor/DifferentialTransactionEditor.php',
|
'DifferentialTransactionEditor' => 'applications/differential/editor/DifferentialTransactionEditor.php',
|
||||||
|
@ -5236,7 +5235,6 @@ phutil_register_library_map(array(
|
||||||
'DifferentialTestPlanCommitMessageField' => 'DifferentialCommitMessageField',
|
'DifferentialTestPlanCommitMessageField' => 'DifferentialCommitMessageField',
|
||||||
'DifferentialTestPlanField' => 'DifferentialCoreCustomField',
|
'DifferentialTestPlanField' => 'DifferentialCoreCustomField',
|
||||||
'DifferentialTitleCommitMessageField' => 'DifferentialCommitMessageField',
|
'DifferentialTitleCommitMessageField' => 'DifferentialCommitMessageField',
|
||||||
'DifferentialTitleField' => 'DifferentialCoreCustomField',
|
|
||||||
'DifferentialTransaction' => 'PhabricatorModularTransaction',
|
'DifferentialTransaction' => 'PhabricatorModularTransaction',
|
||||||
'DifferentialTransactionComment' => 'PhabricatorApplicationTransactionComment',
|
'DifferentialTransactionComment' => 'PhabricatorApplicationTransactionComment',
|
||||||
'DifferentialTransactionEditor' => 'PhabricatorApplicationTransactionEditor',
|
'DifferentialTransactionEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||||
|
|
|
@ -25,7 +25,6 @@ final class PhabricatorDifferentialConfigOptions
|
||||||
$custom_field_type = 'custom:PhabricatorCustomFieldConfigOptionType';
|
$custom_field_type = 'custom:PhabricatorCustomFieldConfigOptionType';
|
||||||
|
|
||||||
$fields = array(
|
$fields = array(
|
||||||
new DifferentialTitleField(),
|
|
||||||
new DifferentialSummaryField(),
|
new DifferentialSummaryField(),
|
||||||
new DifferentialTestPlanField(),
|
new DifferentialTestPlanField(),
|
||||||
new DifferentialReviewersField(),
|
new DifferentialReviewersField(),
|
||||||
|
|
|
@ -1,125 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class DifferentialTitleField
|
|
||||||
extends DifferentialCoreCustomField {
|
|
||||||
|
|
||||||
public function getFieldKey() {
|
|
||||||
return 'differential:title';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFieldKeyForConduit() {
|
|
||||||
return 'title';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFieldName() {
|
|
||||||
return pht('Title');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFieldDescription() {
|
|
||||||
return pht('Stores the revision title.');
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getDefaultTitle() {
|
|
||||||
return pht('<<Replace this line with your Revision Title>>');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function readValueFromRevision(
|
|
||||||
DifferentialRevision $revision) {
|
|
||||||
return $revision->getTitle();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function writeValueToRevision(
|
|
||||||
DifferentialRevision $revision,
|
|
||||||
$value) {
|
|
||||||
$revision->setTitle($value);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getCoreFieldRequiredErrorString() {
|
|
||||||
return pht('You must choose a title for this revision.');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function readValueFromRequest(AphrontRequest $request) {
|
|
||||||
$this->setValue($request->getStr($this->getFieldKey()));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function isCoreFieldRequired() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function renderEditControl(array $handles) {
|
|
||||||
return id(new AphrontFormTextAreaControl())
|
|
||||||
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_SHORT)
|
|
||||||
->setName($this->getFieldKey())
|
|
||||||
->setValue($this->getValue())
|
|
||||||
->setError($this->getFieldError())
|
|
||||||
->setLabel($this->getFieldName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getApplicationTransactionTitle(
|
|
||||||
PhabricatorApplicationTransaction $xaction) {
|
|
||||||
$author_phid = $xaction->getAuthorPHID();
|
|
||||||
$old = $xaction->getOldValue();
|
|
||||||
$new = $xaction->getNewValue();
|
|
||||||
|
|
||||||
if (strlen($old)) {
|
|
||||||
return pht(
|
|
||||||
'%s retitled this revision from "%s" to "%s".',
|
|
||||||
$xaction->renderHandleLink($author_phid),
|
|
||||||
$old,
|
|
||||||
$new);
|
|
||||||
} else {
|
|
||||||
return pht(
|
|
||||||
'%s created this revision.',
|
|
||||||
$xaction->renderHandleLink($author_phid));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getApplicationTransactionTitleForFeed(
|
|
||||||
PhabricatorApplicationTransaction $xaction) {
|
|
||||||
|
|
||||||
$object_phid = $xaction->getObjectPHID();
|
|
||||||
$author_phid = $xaction->getAuthorPHID();
|
|
||||||
$old = $xaction->getOldValue();
|
|
||||||
$new = $xaction->getNewValue();
|
|
||||||
|
|
||||||
if (strlen($old)) {
|
|
||||||
return pht(
|
|
||||||
'%s retitled %s, from "%s" to "%s".',
|
|
||||||
$xaction->renderHandleLink($author_phid),
|
|
||||||
$xaction->renderHandleLink($object_phid),
|
|
||||||
$old,
|
|
||||||
$new);
|
|
||||||
} else {
|
|
||||||
return pht(
|
|
||||||
'%s created %s.',
|
|
||||||
$xaction->renderHandleLink($author_phid),
|
|
||||||
$xaction->renderHandleLink($object_phid));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function shouldAppearInCommitMessage() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function shouldOverwriteWhenCommitMessageIsEdited() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function validateCommitMessageValue($value) {
|
|
||||||
if (!strlen($value)) {
|
|
||||||
throw new DifferentialFieldValidationException(
|
|
||||||
pht(
|
|
||||||
'You must provide a revision title in the first line '.
|
|
||||||
'of your commit message.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (preg_match('/^<<.*>>$/', $value)) {
|
|
||||||
throw new DifferentialFieldValidationException(
|
|
||||||
pht(
|
|
||||||
'Replace the line "%s" with a human-readable revision title which '.
|
|
||||||
'describes the changes you are making.',
|
|
||||||
self::getDefaultTitle()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -22,6 +22,23 @@ final class DifferentialTransaction
|
||||||
return 'DifferentialRevisionTransactionType';
|
return 'DifferentialRevisionTransactionType';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function newFallbackModularTransactionType() {
|
||||||
|
// TODO: This allows us to render modern strings for older transactions
|
||||||
|
// without doing a migration. At some point, we should do a migration and
|
||||||
|
// throw this away.
|
||||||
|
|
||||||
|
$xaction_type = $this->getTransactionType();
|
||||||
|
if ($xaction_type == PhabricatorTransactions::TYPE_CUSTOMFIELD) {
|
||||||
|
switch ($this->getMetadataValue('customfield:key')) {
|
||||||
|
case 'differential:title':
|
||||||
|
return new DifferentialRevisionTitleTransaction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::newFallbackModularTransactionType();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function setIsCommandeerSideEffect($is_side_effect) {
|
public function setIsCommandeerSideEffect($is_side_effect) {
|
||||||
$this->isCommandeerSideEffect = $is_side_effect;
|
$this->isCommandeerSideEffect = $is_side_effect;
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -46,7 +46,7 @@ abstract class PhabricatorModularTransaction
|
||||||
$key = $this->getTransactionType();
|
$key = $this->getTransactionType();
|
||||||
|
|
||||||
if (empty($types[$key])) {
|
if (empty($types[$key])) {
|
||||||
$type = new PhabricatorCoreVoidTransaction();
|
$type = $this->newFallbackModularTransactionType();
|
||||||
} else {
|
} else {
|
||||||
$type = clone $types[$key];
|
$type = clone $types[$key];
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,10 @@ abstract class PhabricatorModularTransaction
|
||||||
return $type;
|
return $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function newFallbackModularTransactionType() {
|
||||||
|
return new PhabricatorCoreVoidTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
final public function generateOldValue($object) {
|
final public function generateOldValue($object) {
|
||||||
return $this->getTransactionImplementation()->generateOldValue($object);
|
return $this->getTransactionImplementation()->generateOldValue($object);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue