2014-02-21 20:52:52 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DifferentialSummaryField
|
|
|
|
extends DifferentialCoreCustomField {
|
|
|
|
|
|
|
|
public function getFieldKey() {
|
|
|
|
return 'differential:summary';
|
|
|
|
}
|
|
|
|
|
2014-03-08 02:05:00 +01:00
|
|
|
public function getFieldKeyForConduit() {
|
|
|
|
return 'summary';
|
|
|
|
}
|
|
|
|
|
2014-02-21 20:52:52 +01:00
|
|
|
public function getFieldName() {
|
|
|
|
return pht('Summary');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFieldDescription() {
|
|
|
|
return pht('Stores a summary of the revision.');
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function readValueFromRevision(
|
|
|
|
DifferentialRevision $revision) {
|
2014-03-08 20:21:38 +01:00
|
|
|
if (!$revision->getID()) {
|
|
|
|
return null;
|
|
|
|
}
|
2014-02-21 20:52:52 +01:00
|
|
|
return $revision->getSummary();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function writeValueToRevision(
|
|
|
|
DifferentialRevision $revision,
|
|
|
|
$value) {
|
|
|
|
$revision->setSummary($value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function readValueFromRequest(AphrontRequest $request) {
|
|
|
|
$this->setValue($request->getStr($this->getFieldKey()));
|
|
|
|
}
|
|
|
|
|
2014-02-21 20:53:37 +01:00
|
|
|
public function renderEditControl(array $handles) {
|
2014-02-21 20:52:52 +01:00
|
|
|
return id(new PhabricatorRemarkupControl())
|
2014-11-25 00:25:25 +01:00
|
|
|
->setUser($this->getViewer())
|
2014-02-21 20:52:52 +01:00
|
|
|
->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();
|
|
|
|
|
|
|
|
return pht(
|
|
|
|
'%s updated the summary for this revision.',
|
|
|
|
$xaction->renderHandleLink($author_phid));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplicationTransactionTitleForFeed(
|
2015-01-02 17:45:43 +01:00
|
|
|
PhabricatorApplicationTransaction $xaction) {
|
2014-02-21 20:52:52 +01:00
|
|
|
|
|
|
|
$object_phid = $xaction->getObjectPHID();
|
|
|
|
$author_phid = $xaction->getAuthorPHID();
|
|
|
|
$old = $xaction->getOldValue();
|
|
|
|
$new = $xaction->getNewValue();
|
|
|
|
|
|
|
|
return pht(
|
|
|
|
'%s updated the summary for %s.',
|
|
|
|
$xaction->renderHandleLink($author_phid),
|
|
|
|
$xaction->renderHandleLink($object_phid));
|
|
|
|
}
|
|
|
|
|
Allow CustomField to provide ApplicationTransaction change details
Summary:
Ref T3886. Ref T418. For fields like "Summary" and "Test Plan" where changes can't be summarized in one line, allow CustomField to provide a "(Show Details)" link and render a diff.
Also consolidate some of the existing copy/paste, and simplify this featuer slightly now that we've move to dialogs.
Test Plan:
{F115918}
- Viewed "description"-style field changes in phlux, pholio, legalpad, maniphest, differential, ponder (questions), ponder (answers), and repositories.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T3886, T418
Differential Revision: https://secure.phabricator.com/D8284
2014-02-21 20:53:04 +01:00
|
|
|
public function getApplicationTransactionHasChangeDetails(
|
|
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplicationTransactionChangeDetails(
|
|
|
|
PhabricatorApplicationTransaction $xaction,
|
|
|
|
PhabricatorUser $viewer) {
|
|
|
|
return $xaction->renderTextCorpusChangeDetails(
|
|
|
|
$viewer,
|
|
|
|
$xaction->getOldValue(),
|
|
|
|
$xaction->getNewValue());
|
|
|
|
}
|
2014-02-21 20:52:52 +01:00
|
|
|
|
2014-03-08 20:21:38 +01:00
|
|
|
public function shouldHideInApplicationTransactions(
|
|
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
return ($xaction->getOldValue() === null);
|
|
|
|
}
|
|
|
|
|
2014-02-26 20:18:06 +01:00
|
|
|
public function shouldAppearInGlobalSearch() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function updateAbstractDocument(
|
|
|
|
PhabricatorSearchAbstractDocument $document) {
|
|
|
|
if (strlen($this->getValue())) {
|
|
|
|
$document->addField('body', $this->getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-27 01:53:42 +01:00
|
|
|
public function shouldAppearInPropertyView() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function renderPropertyViewLabel() {
|
|
|
|
return $this->getFieldName();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getStyleForPropertyView() {
|
|
|
|
return 'block';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getIconForPropertyView() {
|
|
|
|
return PHUIPropertyListView::ICON_SUMMARY;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function renderPropertyViewValue(array $handles) {
|
|
|
|
if (!strlen($this->getValue())) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2016-02-16 22:52:12 +01:00
|
|
|
return new PHUIRemarkupView($this->getViewer(), $this->getValue());
|
2014-02-27 01:53:42 +01:00
|
|
|
}
|
|
|
|
|
2014-03-01 00:20:45 +01:00
|
|
|
public function getApplicationTransactionRemarkupBlocks(
|
|
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
return array($xaction->getNewValue());
|
|
|
|
}
|
|
|
|
|
2014-03-08 02:05:00 +01:00
|
|
|
public function shouldAppearInCommitMessage() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function shouldAppearInCommitMessageTemplate() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function shouldOverwriteWhenCommitMessageIsEdited() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-04-01 17:23:34 +02:00
|
|
|
public function shouldAppearInTransactionMail() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function updateTransactionMailBody(
|
|
|
|
PhabricatorMetaMTAMailBody $body,
|
|
|
|
PhabricatorApplicationTransactionEditor $editor,
|
|
|
|
array $xactions) {
|
|
|
|
|
|
|
|
if (!$editor->getIsNewObject()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$summary = $this->getValue();
|
|
|
|
if (!strlen(trim($summary))) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-11-23 20:43:00 +01:00
|
|
|
$body->addRemarkupSection(pht('REVISION SUMMARY'), $summary);
|
2014-04-01 17:23:34 +02:00
|
|
|
}
|
|
|
|
|
2014-02-21 20:52:52 +01:00
|
|
|
}
|