1
0
Fork 0
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:
epriestley 2013-03-04 18:07:47 -08:00
parent 2ea4d17f71
commit 7a8b4a21ab
3 changed files with 33 additions and 12 deletions

View file

@ -85,15 +85,13 @@ final class PhabricatorConfigTransaction
if ($old['deleted']) { if ($old['deleted']) {
$old_text = ''; $old_text = '';
} else { } else {
// NOTE: Here and below, we're adding a synthetic "\n" to prevent the $old_text = PhabricatorConfigJSON::prettyPrintJSON($old['value']);
// differ from complaining about missing trailing newlines.
$old_text = PhabricatorConfigJSON::prettyPrintJSON($old['value'])."\n";
} }
if ($new['deleted']) { if ($new['deleted']) {
$new_text = ''; $new_text = '';
} else { } else {
$new_text = PhabricatorConfigJSON::prettyPrintJSON($new['value'])."\n"; $new_text = PhabricatorConfigJSON::prettyPrintJSON($new['value']);
} }
$view = id(new PhabricatorApplicationTransactionTextDiffDetailView()) $view = id(new PhabricatorApplicationTransactionTextDiffDetailView())

View file

@ -49,10 +49,8 @@ final class PholioTransaction extends PhabricatorApplicationTransaction {
break; break;
case PholioTransactionType::TYPE_DESCRIPTION: case PholioTransactionType::TYPE_DESCRIPTION:
return pht( return pht(
'%s updated the description of this mock. '. "%s updated the mock's description.",
'The old description was: %s', $this->renderHandleLink($author_phid));
$this->renderHandleLink($author_phid),
$old);
break; break;
case PholioTransactionType::TYPE_INLINE: case PholioTransactionType::TYPE_INLINE:
return pht( return pht(
@ -63,5 +61,25 @@ final class PholioTransaction extends PhabricatorApplicationTransaction {
return parent::getTitle(); 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();
}
} }

View file

@ -23,10 +23,15 @@ final class PhabricatorApplicationTransactionTextDiffDetailView
// TODO: On mobile, or perhaps by default, we should switch to 1-up once // TODO: On mobile, or perhaps by default, we should switch to 1-up once
// that is built. // that is built.
$old = phutil_utf8_hard_wrap($old, 80); if (strlen($old)) {
$old = implode("\n", $old); $old = phutil_utf8_hard_wrap($old, 80);
$new = phutil_utf8_hard_wrap($new, 80); $old = implode("\n", $old)."\n";
$new = implode("\n", $new); }
if (strlen($new)) {
$new = phutil_utf8_hard_wrap($new, 80);
$new = implode("\n", $new)."\n";
}
$engine = new PhabricatorDifferenceEngine(); $engine = new PhabricatorDifferenceEngine();
$changeset = $engine->generateChangesetFromFileContent($old, $new); $changeset = $engine->generateChangesetFromFileContent($old, $new);