From 4ab9ebd9013aa4bd561aa8c575e167b9fb66d0b3 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Sun, 12 Apr 2015 18:08:09 -0700 Subject: [PATCH] Add setEpoch for PHUIHeaderView, use in all Documents Summary: Sets a consistent last update time in the header of PHUIDocuments, Legalpad, Diviner, Phriction. I'm not set on the exact language, just that there is consistency, feel free to suggest changes. Test Plan: Test Legalpad, Diviner, Phriction. {F368270} Reviewers: btrahan, epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D12384 --- .../controller/DivinerBookController.php | 23 ++----------------- .../LegalpadDocumentSignController.php | 3 +++ .../PhrictionDocumentController.php | 14 ++--------- src/view/phui/PHUIHeaderView.php | 16 +++++++++++++ 4 files changed, 23 insertions(+), 33 deletions(-) diff --git a/src/applications/diviner/controller/DivinerBookController.php b/src/applications/diviner/controller/DivinerBookController.php index 2821e8ea95..fcc9aa822b 100644 --- a/src/applications/diviner/controller/DivinerBookController.php +++ b/src/applications/diviner/controller/DivinerBookController.php @@ -35,16 +35,14 @@ final class DivinerBookController extends DivinerController { $header = id(new PHUIHeaderView()) ->setHeader($book->getTitle()) ->setUser($viewer) - ->setPolicyObject($book); + ->setPolicyObject($book) + ->setEpoch($book->getDateModified()); $document = new PHUIDocumentView(); $document->setHeader($header); $document->addClass('diviner-view'); - $document->setFontKit(PHUIDocumentView::FONT_SOURCE_SANS); - $properties = $this->buildPropertyList($book); - $atoms = id(new DivinerAtomQuery()) ->setViewer($viewer) ->withBookPHIDs(array($book->getPHID())) @@ -87,7 +85,6 @@ final class DivinerBookController extends DivinerController { $viewer); } - $document->appendChild($properties); $document->appendChild($preface_view); $document->appendChild($out); @@ -101,20 +98,4 @@ final class DivinerBookController extends DivinerController { )); } - private function buildPropertyList(DivinerLiveBook $book) { - $viewer = $this->getRequest()->getUser(); - $view = id(new PHUIPropertyListView()) - ->setUser($viewer); - - $policies = PhabricatorPolicyQuery::renderPolicyDescriptions( - $viewer, - $book); - - $view->addProperty( - pht('Updated'), - phabricator_datetime($book->getDateModified(), $viewer)); - - return $view; - } - } diff --git a/src/applications/legalpad/controller/LegalpadDocumentSignController.php b/src/applications/legalpad/controller/LegalpadDocumentSignController.php index faafe0ee3f..7a0018924d 100644 --- a/src/applications/legalpad/controller/LegalpadDocumentSignController.php +++ b/src/applications/legalpad/controller/LegalpadDocumentSignController.php @@ -232,6 +232,9 @@ final class LegalpadDocumentSignController extends LegalpadController { $header = id(new PHUIHeaderView()) ->setHeader($title) + ->setUser($viewer) + ->setPolicyObject($document) + ->setEpoch($document->getDateModified()) ->addActionLink( id(new PHUIButtonView()) ->setTag('a') diff --git a/src/applications/phriction/controller/PhrictionDocumentController.php b/src/applications/phriction/controller/PhrictionDocumentController.php index e5c2970ed5..6883858ad5 100644 --- a/src/applications/phriction/controller/PhrictionDocumentController.php +++ b/src/applications/phriction/controller/PhrictionDocumentController.php @@ -194,7 +194,8 @@ final class PhrictionDocumentController $header = id(new PHUIHeaderView()) ->setUser($user) ->setPolicyObject($document) - ->setHeader($page_title); + ->setHeader($page_title) + ->setEpoch($content->getDateCreated()); $prop_list = null; if ($properties) { @@ -244,17 +245,6 @@ final class PhrictionDocumentController pht('Last Author'), $viewer->renderHandle($content->getAuthorPHID())); - $age = time() - $content->getDateCreated(); - $age = floor($age / (60 * 60 * 24)); - if ($age < 1) { - $when = pht('Today'); - } else if ($age == 1) { - $when = pht('Yesterday'); - } else { - $when = pht('%d Days Ago', $age); - } - $view->addProperty(pht('Last Updated'), $when); - return $view; } diff --git a/src/view/phui/PHUIHeaderView.php b/src/view/phui/PHUIHeaderView.php index 8db57095f4..ad3561d930 100644 --- a/src/view/phui/PHUIHeaderView.php +++ b/src/view/phui/PHUIHeaderView.php @@ -17,6 +17,7 @@ final class PHUIHeaderView extends AphrontView { private $actionLinks = array(); private $buttonBar = null; private $policyObject; + private $epoch; public function setHeader($header) { $this->header = $header; @@ -107,6 +108,21 @@ final class PHUIHeaderView extends AphrontView { return $this->addProperty(self::PROPERTY_STATUS, $tag); } + public function setEpoch($epoch) { + $age = time() - $epoch; + $age = floor($age / (60 * 60 * 24)); + if ($age < 1) { + $when = pht('Today'); + } else if ($age == 1) { + $when = pht('Yesterday'); + } else { + $when = pht('%d Days Ago', $age); + } + + $this->setStatus('fa-clock-o bluegrey', null, pht('Updated %s', $when)); + return $this; + } + public function render() { require_celerity_resource('phui-header-view-css');