mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 20:40:56 +01:00
Use transaction diffs to show description changes in Pholio
Summary: Fixes T2659. These didn't exist until recently. Test Plan: {F34556} Reviewers: chad Reviewed By: chad CC: aran Maniphest Tasks: T2659 Differential Revision: https://secure.phabricator.com/D5221
This commit is contained in:
parent
2ea4d17f71
commit
7a8b4a21ab
3 changed files with 33 additions and 12 deletions
|
@ -85,15 +85,13 @@ final class PhabricatorConfigTransaction
|
|||
if ($old['deleted']) {
|
||||
$old_text = '';
|
||||
} else {
|
||||
// NOTE: Here and below, we're adding a synthetic "\n" to prevent the
|
||||
// differ from complaining about missing trailing newlines.
|
||||
$old_text = PhabricatorConfigJSON::prettyPrintJSON($old['value'])."\n";
|
||||
$old_text = PhabricatorConfigJSON::prettyPrintJSON($old['value']);
|
||||
}
|
||||
|
||||
if ($new['deleted']) {
|
||||
$new_text = '';
|
||||
} else {
|
||||
$new_text = PhabricatorConfigJSON::prettyPrintJSON($new['value'])."\n";
|
||||
$new_text = PhabricatorConfigJSON::prettyPrintJSON($new['value']);
|
||||
}
|
||||
|
||||
$view = id(new PhabricatorApplicationTransactionTextDiffDetailView())
|
||||
|
|
|
@ -49,10 +49,8 @@ final class PholioTransaction extends PhabricatorApplicationTransaction {
|
|||
break;
|
||||
case PholioTransactionType::TYPE_DESCRIPTION:
|
||||
return pht(
|
||||
'%s updated the description of this mock. '.
|
||||
'The old description was: %s',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$old);
|
||||
"%s updated the mock's description.",
|
||||
$this->renderHandleLink($author_phid));
|
||||
break;
|
||||
case PholioTransactionType::TYPE_INLINE:
|
||||
return pht(
|
||||
|
@ -63,5 +61,25 @@ final class PholioTransaction extends PhabricatorApplicationTransaction {
|
|||
return parent::getTitle();
|
||||
}
|
||||
|
||||
public function hasChangeDetails() {
|
||||
switch ($this->getTransactionType()) {
|
||||
case PholioTransactionType::TYPE_DESCRIPTION:
|
||||
return true;
|
||||
}
|
||||
return parent::hasChangeDetails();
|
||||
}
|
||||
|
||||
public function renderChangeDetails(PhabricatorUser $viewer) {
|
||||
$old = $this->getOldValue();
|
||||
$new = $this->getNewValue();
|
||||
|
||||
$view = id(new PhabricatorApplicationTransactionTextDiffDetailView())
|
||||
->setUser($viewer)
|
||||
->setOldText($old)
|
||||
->setNewText($new);
|
||||
|
||||
return $view->render();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -23,10 +23,15 @@ final class PhabricatorApplicationTransactionTextDiffDetailView
|
|||
// TODO: On mobile, or perhaps by default, we should switch to 1-up once
|
||||
// that is built.
|
||||
|
||||
if (strlen($old)) {
|
||||
$old = phutil_utf8_hard_wrap($old, 80);
|
||||
$old = implode("\n", $old);
|
||||
$old = implode("\n", $old)."\n";
|
||||
}
|
||||
|
||||
if (strlen($new)) {
|
||||
$new = phutil_utf8_hard_wrap($new, 80);
|
||||
$new = implode("\n", $new);
|
||||
$new = implode("\n", $new)."\n";
|
||||
}
|
||||
|
||||
$engine = new PhabricatorDifferenceEngine();
|
||||
$changeset = $engine->generateChangesetFromFileContent($old, $new);
|
||||
|
|
Loading…
Reference in a new issue