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:
@@ -74,7 +74,8 @@ final class ConpherenceTransactionRenderer {
|
|||||||
->setUser($user)
|
->setUser($user)
|
||||||
->setConpherenceThread($conpherence)
|
->setConpherenceThread($conpherence)
|
||||||
->setHandles($handles)
|
->setHandles($handles)
|
||||||
->setMarkupEngine($engine);
|
->setMarkupEngine($engine)
|
||||||
|
->setFullDisplay($full_display);
|
||||||
|
|
||||||
foreach ($transactions as $transaction) {
|
foreach ($transactions as $transaction) {
|
||||||
if ($previous_transaction) {
|
if ($previous_transaction) {
|
||||||
@@ -96,21 +97,6 @@ final class ConpherenceTransactionRenderer {
|
|||||||
}
|
}
|
||||||
$transaction_view = id(clone $transaction_view_template)
|
$transaction_view = id(clone $transaction_view_template)
|
||||||
->setConpherenceTransaction($transaction);
|
->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();
|
$rendered_transactions[] = $transaction_view->render();
|
||||||
$previous_transaction = $transaction;
|
$previous_transaction = $transaction;
|
||||||
|
|||||||
@@ -227,15 +227,13 @@ final class ConpherenceThreadSearchEngine
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$history_href = '/'.$monogram.'#'.$xaction->getID();
|
|
||||||
|
|
||||||
$view = id(new ConpherenceTransactionView())
|
$view = id(new ConpherenceTransactionView())
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->setHandles($handles)
|
->setHandles($handles)
|
||||||
->setMarkupEngine($engines[$conpherence_phid])
|
->setMarkupEngine($engines[$conpherence_phid])
|
||||||
->setConpherenceThread($conpherence)
|
->setConpherenceThread($conpherence)
|
||||||
->setConpherenceTransaction($xaction)
|
->setConpherenceTransaction($xaction)
|
||||||
->setEpoch($xaction->getDateCreated(), $history_href)
|
->setFullDisplay(false)
|
||||||
->addClass('conpherence-fulltext-result');
|
->addClass('conpherence-fulltext-result');
|
||||||
|
|
||||||
if ($message['match']) {
|
if ($message['match']) {
|
||||||
|
|||||||
@@ -6,14 +6,9 @@ final class ConpherenceTransactionView extends AphrontView {
|
|||||||
private $conpherenceTransaction;
|
private $conpherenceTransaction;
|
||||||
private $handles;
|
private $handles;
|
||||||
private $markupEngine;
|
private $markupEngine;
|
||||||
private $epoch;
|
private $fullDisplay;
|
||||||
private $epochHref;
|
|
||||||
private $contentSource;
|
|
||||||
private $anchorName;
|
|
||||||
private $anchorText;
|
|
||||||
private $classes = array();
|
private $classes = array();
|
||||||
private $timeOnly;
|
private $timeOnly;
|
||||||
private $showImages = true;
|
|
||||||
|
|
||||||
public function setConpherenceThread(ConpherenceThread $t) {
|
public function setConpherenceThread(ConpherenceThread $t) {
|
||||||
$this->conpherenceThread = $t;
|
$this->conpherenceThread = $t;
|
||||||
@@ -52,25 +47,13 @@ final class ConpherenceTransactionView extends AphrontView {
|
|||||||
return $this->markupEngine;
|
return $this->markupEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setEpoch($epoch, $epoch_href = null) {
|
public function setFullDisplay($bool) {
|
||||||
$this->epoch = $epoch;
|
$this->fullDisplay = $bool;
|
||||||
$this->epochHref = $epoch_href;
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setContentSource(PhabricatorContentSource $source) {
|
private function getFullDisplay() {
|
||||||
$this->contentSource = $source;
|
return $this->fullDisplay;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addClass($class) {
|
public function addClass($class) {
|
||||||
@@ -78,23 +61,9 @@ final class ConpherenceTransactionView extends AphrontView {
|
|||||||
return $this;
|
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() {
|
public function render() {
|
||||||
$user = $this->getUser();
|
$viewer = $this->getUser();
|
||||||
if (!$user) {
|
if (!$viewer) {
|
||||||
throw new Exception(pht('Call setUser() before render()!'));
|
throw new Exception(pht('Call setUser() before render()!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,7 +89,7 @@ final class ConpherenceTransactionView extends AphrontView {
|
|||||||
),
|
),
|
||||||
phabricator_format_local_time(
|
phabricator_format_local_time(
|
||||||
$transaction->getDateCreated(),
|
$transaction->getDateCreated(),
|
||||||
$user,
|
$viewer,
|
||||||
'M jS, Y')),
|
'M jS, Y')),
|
||||||
));
|
));
|
||||||
break;
|
break;
|
||||||
@@ -132,7 +101,10 @@ final class ConpherenceTransactionView extends AphrontView {
|
|||||||
$content = $this->renderTransactionContent();
|
$content = $this->renderTransactionContent();
|
||||||
$classes = implode(' ', $this->classes);
|
$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(
|
$header = phutil_tag_div(
|
||||||
'conpherence-transaction-header grouped',
|
'conpherence-transaction-header grouped',
|
||||||
@@ -142,7 +114,7 @@ final class ConpherenceTransactionView extends AphrontView {
|
|||||||
'div',
|
'div',
|
||||||
array(
|
array(
|
||||||
'class' => 'conpherence-transaction-view '.$classes,
|
'class' => 'conpherence-transaction-view '.$classes,
|
||||||
'id' => $transaction_id,
|
'id' => $transaction_dom_id,
|
||||||
'sigil' => 'conpherence-transaction-view',
|
'sigil' => 'conpherence-transaction-view',
|
||||||
'meta' => array(
|
'meta' => array(
|
||||||
'id' => $transaction->getID(),
|
'id' => $transaction->getID(),
|
||||||
@@ -156,53 +128,60 @@ final class ConpherenceTransactionView extends AphrontView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function renderTransactionInfo() {
|
private function renderTransactionInfo() {
|
||||||
|
$viewer = $this->getUser();
|
||||||
|
$thread = $this->getConpherenceThread();
|
||||||
|
$transaction = $this->getConpherenceTransaction();
|
||||||
$info = array();
|
$info = array();
|
||||||
|
|
||||||
if ($this->getContentSource()) {
|
if ($this->getFullDisplay() && $transaction->getContentSource()) {
|
||||||
$content_source = id(new PhabricatorContentSourceView())
|
$content_source = id(new PhabricatorContentSourceView())
|
||||||
->setContentSource($this->getContentSource())
|
->setContentSource($transaction->getContentSource())
|
||||||
->setUser($this->user)
|
->setUser($viewer)
|
||||||
->render();
|
->render();
|
||||||
if ($content_source) {
|
if ($content_source) {
|
||||||
$info[] = $content_source;
|
$info[] = $content_source;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->epoch) {
|
Javelin::initBehavior('phabricator-tooltips');
|
||||||
if ($this->timeOnly) {
|
$tip = phabricator_datetime($transaction->getDateCreated(), $viewer);
|
||||||
$epoch = phabricator_time($this->epoch, $this->user);
|
$label = phabricator_time($transaction->getDateCreated(), $viewer);
|
||||||
} else {
|
$width = 360;
|
||||||
$epoch = phabricator_datetime($this->epoch, $this->user);
|
if ($this->getFullDisplay()) {
|
||||||
}
|
|
||||||
if ($this->epochHref) {
|
|
||||||
$epoch = phutil_tag(
|
|
||||||
'a',
|
|
||||||
array(
|
|
||||||
'href' => $this->epochHref,
|
|
||||||
'class' => 'epoch-link',
|
|
||||||
),
|
|
||||||
$epoch);
|
|
||||||
}
|
|
||||||
$info[] = $epoch;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->anchorName) {
|
|
||||||
Javelin::initBehavior('phabricator-watch-anchor');
|
Javelin::initBehavior('phabricator-watch-anchor');
|
||||||
|
|
||||||
$anchor = id(new PhabricatorAnchorView())
|
$anchor = id(new PhabricatorAnchorView())
|
||||||
->setAnchorName($this->anchorName)
|
->setAnchorName($transaction->getID())
|
||||||
->render();
|
->render();
|
||||||
|
|
||||||
$info[] = hsprintf(
|
$info[] = hsprintf(
|
||||||
'%s%s',
|
'%s%s',
|
||||||
$anchor,
|
$anchor,
|
||||||
phutil_tag(
|
javelin_tag(
|
||||||
'a',
|
'a',
|
||||||
array(
|
array(
|
||||||
'href' => '#'.$this->anchorName,
|
'href' => '#'.$transaction->getID(),
|
||||||
'class' => 'anchor-link',
|
'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);
|
$info = phutil_implode_html(" \xC2\xB7 ", $info);
|
||||||
@@ -234,7 +213,7 @@ final class ConpherenceTransactionView extends AphrontView {
|
|||||||
|
|
||||||
private function renderTransactionImage() {
|
private function renderTransactionImage() {
|
||||||
$image = null;
|
$image = null;
|
||||||
if ($this->getShowImages()) {
|
if ($this->getFullDisplay()) {
|
||||||
$transaction = $this->getConpherenceTransaction();
|
$transaction = $this->getConpherenceTransaction();
|
||||||
switch ($transaction->getTransactionType()) {
|
switch ($transaction->getTransactionType()) {
|
||||||
case PhabricatorTransactions::TYPE_COMMENT:
|
case PhabricatorTransactions::TYPE_COMMENT:
|
||||||
|
|||||||
Reference in New Issue
Block a user