From 729492a8ff855d09ed1fe410f319c0f1106858ed Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 7 Nov 2016 11:30:02 -0800 Subject: [PATCH] Allow transactions to specialize their mail headers for diff sections Summary: Ref T7643. When we send mail about a change to a package description, allow it to say "CHANGES TO PACKAGE DESCRIPTION" instead of "EDIT DETAILS". Smooth! Test Plan: {F1909417} Reviewers: chad Reviewed By: chad Maniphest Tasks: T7643 Differential Revision: https://secure.phabricator.com/D16818 --- ...torCalendarEventDescriptionTransaction.php | 4 ++++ ...torOwnersPackageDescriptionTransaction.php | 4 ++++ .../PhabricatorPasteContentTransaction.php | 4 ++++ ...habricatorApplicationTransactionEditor.php | 20 ++++++++++++++++++- .../PhabricatorModularTransactionType.php | 4 ++++ 5 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/applications/calendar/xaction/PhabricatorCalendarEventDescriptionTransaction.php b/src/applications/calendar/xaction/PhabricatorCalendarEventDescriptionTransaction.php index 343ffa2adf..0de19989a7 100644 --- a/src/applications/calendar/xaction/PhabricatorCalendarEventDescriptionTransaction.php +++ b/src/applications/calendar/xaction/PhabricatorCalendarEventDescriptionTransaction.php @@ -30,6 +30,10 @@ final class PhabricatorCalendarEventDescriptionTransaction return true; } + public function getMailDiffSectionHeader() { + return pht('CHANGES TO EVENT DESCRIPTION'); + } + public function newChangeDetailView() { $viewer = $this->getViewer(); diff --git a/src/applications/owners/xaction/PhabricatorOwnersPackageDescriptionTransaction.php b/src/applications/owners/xaction/PhabricatorOwnersPackageDescriptionTransaction.php index 8b2effe80c..235262e947 100644 --- a/src/applications/owners/xaction/PhabricatorOwnersPackageDescriptionTransaction.php +++ b/src/applications/owners/xaction/PhabricatorOwnersPackageDescriptionTransaction.php @@ -19,6 +19,10 @@ final class PhabricatorOwnersPackageDescriptionTransaction $this->renderAuthor()); } + public function getMailDiffSectionHeader() { + return pht('CHANGES TO PACKAGE DESCRIPTION'); + } + public function newChangeDetailView() { return id(new PhabricatorApplicationTransactionTextDiffDetailView()) ->setViewer($this->getViewer()) diff --git a/src/applications/paste/xaction/PhabricatorPasteContentTransaction.php b/src/applications/paste/xaction/PhabricatorPasteContentTransaction.php index b04ed61642..0c3fa7e25b 100644 --- a/src/applications/paste/xaction/PhabricatorPasteContentTransaction.php +++ b/src/applications/paste/xaction/PhabricatorPasteContentTransaction.php @@ -104,6 +104,10 @@ final class PhabricatorPasteContentTransaction return true; } + public function getMailDiffSectionHeader() { + return pht('CHANGES TO PASTE CONTENT'); + } + public function newChangeDetailView() { $viewer = $this->getViewer(); diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php index 1a3dd1c89e..10db361837 100644 --- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php +++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php @@ -1141,9 +1141,15 @@ abstract class PhabricatorApplicationTransactionEditor PhabricatorLiskDAO $object, array $xactions) { + $this->object = $object; + $this->xactions = $xactions; + // Hook for edges or other properties that may need (re-)loading $object = $this->willPublish($object, $xactions); + // The object might have changed, so reassign it. + $this->object = $object; + $messages = array(); if (!$this->getDisableEmail()) { if ($this->shouldSendMail($object, $xactions)) { @@ -2871,12 +2877,24 @@ abstract class PhabricatorApplicationTransactionEditor foreach ($details as $xaction) { $details = $xaction->renderChangeDetailsForMail($body->getViewer()); if ($details !== null) { - $body->addHTMLSection(pht('EDIT DETAILS'), $details); + $label = $this->getMailDiffSectionHeader($xaction); + $body->addHTMLSection($label, $details); } } } + private function getMailDiffSectionHeader($xaction) { + $type = $xaction->getTransactionType(); + + $xtype = $this->getModularTransactionType($type); + if ($xtype) { + return $xtype->getMailDiffSectionHeader(); + } + + return pht('EDIT DETAILS'); + } + /** * @task mail */ diff --git a/src/applications/transactions/storage/PhabricatorModularTransactionType.php b/src/applications/transactions/storage/PhabricatorModularTransactionType.php index 01a02f7fd3..3c9ef6b182 100644 --- a/src/applications/transactions/storage/PhabricatorModularTransactionType.php +++ b/src/applications/transactions/storage/PhabricatorModularTransactionType.php @@ -67,6 +67,10 @@ abstract class PhabricatorModularTransactionType throw new PhutilMethodNotImplementedException(); } + public function getMailDiffSectionHeader() { + return pht('EDIT DETAILS'); + } + public function newRemarkupChanges() { return array(); }