1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 05:12:41 +01:00

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
This commit is contained in:
Chad Little 2015-04-12 18:08:09 -07:00
parent a912e3bf83
commit 4ab9ebd901
4 changed files with 23 additions and 33 deletions

View file

@ -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;
}
}

View file

@ -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')

View file

@ -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;
}

View file

@ -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');