1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 21:02:41 +01:00

Conpherence - add tooltip for full time for messages

Summary:
Fixes T8154. Now you can tell when a Conpherence was started by mousing over the date. I think this is sufficient.

This ends up cleaning up the code significantly; it used to inherit from some transaction view class and had built up lots of cludge over time. Much cleaner now.

Test Plan: moused over tooltips in both durable column and full conpherence and saw correct full dates. clicked on a timestamp in durable column and went to right place in full conpherence.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T8154

Differential Revision: https://secure.phabricator.com/D13057
This commit is contained in:
Bob Trahan 2015-05-28 15:27:08 -07:00
parent a55ed96f98
commit c61b5440e1
3 changed files with 52 additions and 89 deletions

View file

@ -74,7 +74,8 @@ final class ConpherenceTransactionRenderer {
->setUser($user)
->setConpherenceThread($conpherence)
->setHandles($handles)
->setMarkupEngine($engine);
->setMarkupEngine($engine)
->setFullDisplay($full_display);
foreach ($transactions as $transaction) {
if ($previous_transaction) {
@ -96,21 +97,6 @@ final class ConpherenceTransactionRenderer {
}
$transaction_view = id(clone $transaction_view_template)
->setConpherenceTransaction($transaction);
if ($full_display) {
$transaction_view
->setAnchor(
$transaction->getID(),
phabricator_time($transaction->getDateCreated(), $user));
$transaction_view->setContentSource($transaction->getContentSource());
$transaction_view->setShowImages(true);
} else {
$transaction_view
->setEpoch(
$transaction->getDateCreated(),
'/'.$conpherence->getMonogram().'#'.$transaction->getID())
->setTimeOnly(true);
$transaction_view->setShowImages(false);
}
$rendered_transactions[] = $transaction_view->render();
$previous_transaction = $transaction;

View file

@ -227,15 +227,13 @@ final class ConpherenceThreadSearchEngine
continue;
}
$history_href = '/'.$monogram.'#'.$xaction->getID();
$view = id(new ConpherenceTransactionView())
->setUser($viewer)
->setHandles($handles)
->setMarkupEngine($engines[$conpherence_phid])
->setConpherenceThread($conpherence)
->setConpherenceTransaction($xaction)
->setEpoch($xaction->getDateCreated(), $history_href)
->setFullDisplay(false)
->addClass('conpherence-fulltext-result');
if ($message['match']) {

View file

@ -6,14 +6,9 @@ final class ConpherenceTransactionView extends AphrontView {
private $conpherenceTransaction;
private $handles;
private $markupEngine;
private $epoch;
private $epochHref;
private $contentSource;
private $anchorName;
private $anchorText;
private $fullDisplay;
private $classes = array();
private $timeOnly;
private $showImages = true;
public function setConpherenceThread(ConpherenceThread $t) {
$this->conpherenceThread = $t;
@ -52,25 +47,13 @@ final class ConpherenceTransactionView extends AphrontView {
return $this->markupEngine;
}
public function setEpoch($epoch, $epoch_href = null) {
$this->epoch = $epoch;
$this->epochHref = $epoch_href;
public function setFullDisplay($bool) {
$this->fullDisplay = $bool;
return $this;
}
public function setContentSource(PhabricatorContentSource $source) {
$this->contentSource = $source;
return $this;
}
private function getContentSource() {
return $this->contentSource;
}
public function setAnchor($anchor_name, $anchor_text) {
$this->anchorName = $anchor_name;
$this->anchorText = $anchor_text;
return $this;
private function getFullDisplay() {
return $this->fullDisplay;
}
public function addClass($class) {
@ -78,23 +61,9 @@ final class ConpherenceTransactionView extends AphrontView {
return $this;
}
public function setTimeOnly($time) {
$this->timeOnly = $time;
return $this;
}
public function setShowImages($bool) {
$this->showImages = $bool;
return $this;
}
private function getShowImages() {
return $this->showImages;
}
public function render() {
$user = $this->getUser();
if (!$user) {
$viewer = $this->getUser();
if (!$viewer) {
throw new Exception(pht('Call setUser() before render()!'));
}
@ -120,7 +89,7 @@ final class ConpherenceTransactionView extends AphrontView {
),
phabricator_format_local_time(
$transaction->getDateCreated(),
$user,
$viewer,
'M jS, Y')),
));
break;
@ -132,7 +101,10 @@ final class ConpherenceTransactionView extends AphrontView {
$content = $this->renderTransactionContent();
$classes = implode(' ', $this->classes);
$transaction_id = $this->anchorName ? 'anchor-'.$this->anchorName : null;
$transaction_dom_id = null;
if ($this->getFullDisplay()) {
$transaction_dom_id = 'anchor-'.$transaction->getID();
}
$header = phutil_tag_div(
'conpherence-transaction-header grouped',
@ -142,7 +114,7 @@ final class ConpherenceTransactionView extends AphrontView {
'div',
array(
'class' => 'conpherence-transaction-view '.$classes,
'id' => $transaction_id,
'id' => $transaction_dom_id,
'sigil' => 'conpherence-transaction-view',
'meta' => array(
'id' => $transaction->getID(),
@ -156,53 +128,60 @@ final class ConpherenceTransactionView extends AphrontView {
}
private function renderTransactionInfo() {
$viewer = $this->getUser();
$thread = $this->getConpherenceThread();
$transaction = $this->getConpherenceTransaction();
$info = array();
if ($this->getContentSource()) {
if ($this->getFullDisplay() && $transaction->getContentSource()) {
$content_source = id(new PhabricatorContentSourceView())
->setContentSource($this->getContentSource())
->setUser($this->user)
->setContentSource($transaction->getContentSource())
->setUser($viewer)
->render();
if ($content_source) {
$info[] = $content_source;
}
}
if ($this->epoch) {
if ($this->timeOnly) {
$epoch = phabricator_time($this->epoch, $this->user);
} else {
$epoch = phabricator_datetime($this->epoch, $this->user);
}
if ($this->epochHref) {
$epoch = phutil_tag(
'a',
array(
'href' => $this->epochHref,
'class' => 'epoch-link',
),
$epoch);
}
$info[] = $epoch;
}
if ($this->anchorName) {
Javelin::initBehavior('phabricator-tooltips');
$tip = phabricator_datetime($transaction->getDateCreated(), $viewer);
$label = phabricator_time($transaction->getDateCreated(), $viewer);
$width = 360;
if ($this->getFullDisplay()) {
Javelin::initBehavior('phabricator-watch-anchor');
$anchor = id(new PhabricatorAnchorView())
->setAnchorName($this->anchorName)
->setAnchorName($transaction->getID())
->render();
$info[] = hsprintf(
'%s%s',
$anchor,
phutil_tag(
javelin_tag(
'a',
array(
'href' => '#'.$this->anchorName,
'href' => '#'.$transaction->getID(),
'class' => 'anchor-link',
'sigil' => 'has-tooltip',
'meta' => array(
'tip' => $tip,
'size' => $width,
),
$this->anchorText));
),
$label));
} else {
$href = '/'.$thread->getMonogram().'#'.$transaction->getID();
$info[] = javelin_tag(
'a',
array(
'href' => $href,
'class' => 'epoch-link',
'sigil' => 'has-tooltip',
'meta' => array(
'tip' => $tip,
'size' => $width,
),
),
$label);
}
$info = phutil_implode_html(" \xC2\xB7 ", $info);
@ -234,7 +213,7 @@ final class ConpherenceTransactionView extends AphrontView {
private function renderTransactionImage() {
$image = null;
if ($this->getShowImages()) {
if ($this->getFullDisplay()) {
$transaction = $this->getConpherenceTransaction();
switch ($transaction->getTransactionType()) {
case PhabricatorTransactions::TYPE_COMMENT: