From 3f0ffaa9ebc6350f45ea6e02a855e03849df1c74 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Mon, 19 Aug 2013 11:51:22 -0700 Subject: [PATCH] Pholio - make create stories include the mock description, if there is one. Summary: This diff accomplishes this task by adding an arbitrary metadata store to PhabricatorObjectHandle. This seemed like it would be "necessary eventually"; for example if / when we decide we want to show images in these stories we'd need to add some more arbitrary data. A point of debate is this technique will yield the _current_ data and not the data at the time the transaction was originally made. I can see this being both desirable and non-desirable. Otherwise, the best way to do this is to make a new transaction type specifically for create and store exactly what data we think we would need. (and there's probably many other ways but they require much more work...) Test Plan: viewed some pholio create stories and yes, they had the description showing. Reviewers: epriestley Reviewed By: epriestley CC: Korvin, aran Maniphest Tasks: T3685 Differential Revision: https://secure.phabricator.com/D6767 --- .../pholio/storage/PholioTransaction.php | 19 +++++++++++++++---- ...ricatorApplicationTransactionFeedStory.php | 5 +++-- .../PhabricatorApplicationTransaction.php | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/applications/pholio/storage/PholioTransaction.php b/src/applications/pholio/storage/PholioTransaction.php index 6f9f7f8cce..9c6a3f5b56 100644 --- a/src/applications/pholio/storage/PholioTransaction.php +++ b/src/applications/pholio/storage/PholioTransaction.php @@ -250,15 +250,26 @@ final class PholioTransaction extends PhabricatorApplicationTransaction { return parent::getTitleForFeed(); } - public function getBodyForFeed() { + public function getBodyForFeed(PhabricatorFeedStory $story) { + $text = null; switch ($this->getTransactionType()) { + case PholioTransactionType::TYPE_NAME: + if ($this->getOldValue() === null) { + $mock = $story->getPrimaryObject(); + $text = $mock->getDescription(); + } + break; case PholioTransactionType::TYPE_INLINE: $text = $this->getComment()->getContent(); - return phutil_escape_html_newlines( - phutil_utf8_shorten($text, 128)); break; } - return parent::getBodyForFeed(); + + if ($text) { + return phutil_escape_html_newlines( + phutil_utf8_shorten($text, 128)); + } + + return parent::getBodyForFeed($story); } public function hasChangeDetails() { diff --git a/src/applications/transactions/feed/PhabricatorApplicationTransactionFeedStory.php b/src/applications/transactions/feed/PhabricatorApplicationTransactionFeedStory.php index 5e48c6dfc4..a235560a8f 100644 --- a/src/applications/transactions/feed/PhabricatorApplicationTransactionFeedStory.php +++ b/src/applications/transactions/feed/PhabricatorApplicationTransactionFeedStory.php @@ -44,8 +44,9 @@ class PhabricatorApplicationTransactionFeedStory $xaction->setHandles($this->getHandles()); $view->setTitle($xaction->getTitleForFeed()); - if (nonempty($xaction->getBodyForFeed())) { - $view->appendChild($xaction->getBodyForFeed()); + $body = $xaction->getBodyForFeed($this); + if (nonempty($body)) { + $view->appendChild($body); } $view->setImage( diff --git a/src/applications/transactions/storage/PhabricatorApplicationTransaction.php b/src/applications/transactions/storage/PhabricatorApplicationTransaction.php index efb6733f1b..f6376f7c2b 100644 --- a/src/applications/transactions/storage/PhabricatorApplicationTransaction.php +++ b/src/applications/transactions/storage/PhabricatorApplicationTransaction.php @@ -383,7 +383,7 @@ abstract class PhabricatorApplicationTransaction return $this->getTitle(); } - public function getBodyForFeed() { + public function getBodyForFeed(PhabricatorFeedStory $story) { $old = $this->getOldValue(); $new = $this->getNewValue();