From 5bb3cbe23922200bffd97fb7a3a043ecf95db88e Mon Sep 17 00:00:00 2001 From: Chad Little Date: Wed, 18 May 2016 14:16:35 -0700 Subject: [PATCH] Add a "View Revision" button to HTML email Summary: Ref T10694. If this feels good, I'd plan to eventually add something similar to other applications ("View Task", etc). Not sure if we should keep the object link later in the mail body or not. I left it for now. Test Plan: {F1307256, size=full} Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T10694 Differential Revision: https://secure.phabricator.com/D15884 --- .../editor/DifferentialTransactionEditor.php | 10 ++- ...habricatorApplicationTransactionEditor.php | 61 ++++++++++++++++++- 2 files changed, 67 insertions(+), 4 deletions(-) diff --git a/src/applications/differential/editor/DifferentialTransactionEditor.php b/src/applications/differential/editor/DifferentialTransactionEditor.php index 819127b147..2d2671227d 100644 --- a/src/applications/differential/editor/DifferentialTransactionEditor.php +++ b/src/applications/differential/editor/DifferentialTransactionEditor.php @@ -1201,7 +1201,13 @@ final class DifferentialTransactionEditor $body = new PhabricatorMetaMTAMailBody(); $body->setViewer($this->requireActor()); - $this->addHeadersAndCommentsToMailBody($body, $xactions); + $revision_uri = PhabricatorEnv::getProductionURI('/D'.$object->getID()); + + $this->addHeadersAndCommentsToMailBody( + $body, + $xactions, + pht('View Revision'), + $revision_uri); $type_inline = DifferentialTransaction::TYPE_INLINE; @@ -1227,7 +1233,7 @@ final class DifferentialTransactionEditor $body->addLinkSection( pht('REVISION DETAIL'), - PhabricatorEnv::getProductionURI('/D'.$object->getID())); + $revision_uri); $update_xaction = null; foreach ($xactions as $xaction) { diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php index ce458a3407..891a6f401c 100644 --- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php +++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php @@ -2697,7 +2697,9 @@ abstract class PhabricatorApplicationTransactionEditor */ protected function addHeadersAndCommentsToMailBody( PhabricatorMetaMTAMailBody $body, - array $xactions) { + array $xactions, + $object_label = null, + $object_href = null) { $headers = array(); $comments = array(); @@ -2717,7 +2719,62 @@ abstract class PhabricatorApplicationTransactionEditor $comments[] = $comment; } } - $body->addRawSection(implode("\n", $headers)); + + $headers_text = implode("\n", $headers); + $body->addRawPlaintextSection($headers_text); + + $headers_html = phutil_implode_html(phutil_tag('br'), $headers); + + $header_button = null; + if ($object_label !== null) { + $button_style = array( + 'text-decoration: none;', + 'padding: 4px 8px;', + 'margin: 0 8px;', + 'float: right;', + 'color: #464C5C;', + 'font-weight: bold;', + 'border-radius: 3px;', + 'background-color: #F7F7F9;', + 'background-image: linear-gradient(to bottom,#fff,#f1f0f1);', + 'border: 1px solid rgba(71,87,120,.2);', + ); + + $header_button = phutil_tag( + 'a', + array( + 'style' => implode(' ', $button_style), + 'href' => $object_href, + ), + $object_label); + } + + $xactions_style = array( + 'padding: 0 0 8px 0;', + ); + + $headers_html = phutil_tag( + 'div', + array( + 'style' => implode(' ', $xactions_style), + ), + $headers_html); + + $header_style = array( + 'overflow: hidden;', + ); + + $headers_html = phutil_tag( + 'div', + array( + 'style' => implode(' ', $header_style), + ), + array( + $header_button, + $headers_html, + )); + + $body->addRawHTMLSection($headers_html); foreach ($comments as $comment) { $body->addRemarkupSection(null, $comment);