1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00

Add Hovercards / restyle feed one line stories.

Summary: This adds hovercards to most stories and removes the profile photo from one line stories. I don't know about my implementation, which has difficulties with application transactions (because it shows status). Which leads me to a bigger question, which is can we render all people through a common function like AphrontTagView so we can easily class and/or hovercard it anywhere.

Test Plan: Reviewed my feed, various stories.

Reviewers: epriestley, btrahan

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D6684
This commit is contained in:
Chad Little 2013-08-06 09:20:04 -07:00
parent 5a352d0a69
commit b348aaefb9
8 changed files with 77 additions and 36 deletions

View file

@ -3791,7 +3791,7 @@ celerity_register_resource_map(array(
), ),
'phui-feed-story-css' => 'phui-feed-story-css' =>
array( array(
'uri' => '/res/5d7ab26c/rsrc/css/phui/phui-feed-story.css', 'uri' => '/res/68a0ce41/rsrc/css/phui/phui-feed-story.css',
'type' => 'css', 'type' => 'css',
'requires' => 'requires' =>
array( array(
@ -3827,7 +3827,7 @@ celerity_register_resource_map(array(
), ),
'phui-remarkup-preview-css' => 'phui-remarkup-preview-css' =>
array( array(
'uri' => '/res/6c886e63/rsrc/css/phui/phui-remarkup-preview.css', 'uri' => '/res/4535e062/rsrc/css/phui/phui-remarkup-preview.css',
'type' => 'css', 'type' => 'css',
'requires' => 'requires' =>
array( array(

View file

@ -232,11 +232,19 @@ abstract class PhabricatorFeedStory implements PhabricatorPolicyInterface {
// NOTE: We render our own link here to customize the styling and add // NOTE: We render our own link here to customize the styling and add
// the '_top' target for framed feeds. // the '_top' target for framed feeds.
return phutil_tag( $class = null;
if ($handle->getType() == PhabricatorPeoplePHIDTypeUser::TYPECONST) {
$class = 'phui-link-person';
}
return javelin_tag(
'a', 'a',
array( array(
'href' => $handle->getURI(), 'href' => $handle->getURI(),
'target' => $this->framed ? '_top' : null, 'target' => $this->framed ? '_top' : null,
'sigil' => 'hovercard',
'meta' => array('hoverPHID' => $phid),
'class' => $class,
), ),
$handle->getLinkName()); $handle->getLinkName());
} }

View file

@ -19,6 +19,7 @@ final class PhabricatorFeedStoryPhriction extends PhabricatorFeedStory {
$data = $this->getStoryData(); $data = $this->getStoryData();
$author_phid = $data->getAuthorPHID(); $author_phid = $data->getAuthorPHID();
$author_link = $this->linkTo($author_phid);
$document_phid = $data->getValue('phid'); $document_phid = $data->getValue('phid');
$view = $this->newStoryView(); $view = $this->newStoryView();
@ -38,7 +39,7 @@ final class PhabricatorFeedStoryPhriction extends PhabricatorFeedStory {
$from_handle = $this->getHandle($from_phid); $from_handle = $this->getHandle($from_phid);
$view->setTitle(pht( $view->setTitle(pht(
'%s moved the document %s from %s to %s.', '%s moved the document %s from %s to %s.',
$this->linkTo($author_phid), $author_link,
$document_handle->renderLink(), $document_handle->renderLink(),
phutil_tag( phutil_tag(
'a', 'a',
@ -58,7 +59,7 @@ final class PhabricatorFeedStoryPhriction extends PhabricatorFeedStory {
default: default:
$view->setTitle(pht( $view->setTitle(pht(
'%s %s the document %s.', '%s %s the document %s.',
$this->linkTo($author_phid), $author_link,
$verb, $verb,
$this->linkTo($document_phid))); $this->linkTo($document_phid)));
break; break;
@ -76,7 +77,8 @@ final class PhabricatorFeedStoryPhriction extends PhabricatorFeedStory {
} }
public function renderText() { public function renderText() {
$author_name = $this->getHandle($this->getAuthorPHID())->getLinkName(); $author_phid = $this->getHandle($this->getAuthorPHID());
$author_link = $this->linkTo($author_phid);
$document_handle = $this->getHandle($this->getPrimaryObjectPHID()); $document_handle = $this->getHandle($this->getPrimaryObjectPHID());
$document_title = $document_handle->getLinkName(); $document_title = $document_handle->getLinkName();
@ -85,7 +87,7 @@ final class PhabricatorFeedStoryPhriction extends PhabricatorFeedStory {
$action = $this->getValue('action'); $action = $this->getValue('action');
$verb = PhrictionActionConstants::getActionPastTenseVerb($action); $verb = PhrictionActionConstants::getActionPastTenseVerb($action);
$text = "{$author_name} {$verb} the document". $text = "{$author_link} {$verb} the document".
" {$document_title} {$document_uri}"; " {$document_title} {$document_uri}";
return $text; return $text;

View file

@ -33,18 +33,21 @@ final class PhabricatorFeedStoryProject extends PhabricatorFeedStory {
$proj_phid = $data->getValue('projectPHID'); $proj_phid = $data->getValue('projectPHID');
$author_phid = $data->getAuthorPHID(); $author_phid = $data->getAuthorPHID();
$author_link = $this->linkTo($author_phid);
switch ($type) { switch ($type) {
case PhabricatorProjectTransactionType::TYPE_NAME: case PhabricatorProjectTransactionType::TYPE_NAME:
if (strlen($old)) { if (strlen($old)) {
$action = hsprintf( $action = pht(
'renamed project %s from %s to %s.', '% renamed project %s from %s to %s.',
$author_link,
$this->linkTo($proj_phid), $this->linkTo($proj_phid),
$this->renderString($old), $this->renderString($old),
$this->renderString($new)); $this->renderString($new));
} else { } else {
$action = hsprintf( $action = pht(
'created project %s (as %s).', '% created project %s (as %s).',
$author_link,
$this->linkTo($proj_phid), $this->linkTo($proj_phid),
$this->renderString($new)); $this->renderString($new));
} }
@ -52,8 +55,9 @@ final class PhabricatorFeedStoryProject extends PhabricatorFeedStory {
case PhabricatorProjectTransactionType::TYPE_STATUS: case PhabricatorProjectTransactionType::TYPE_STATUS:
$old_name = PhabricatorProjectStatus::getNameForStatus($old); $old_name = PhabricatorProjectStatus::getNameForStatus($old);
$new_name = PhabricatorProjectStatus::getNameForStatus($new); $new_name = PhabricatorProjectStatus::getNameForStatus($new);
$action = hsprintf( $action = pht(
'changed project %s status from %s to %s.', '%s changed project %s status from %s to %s.',
$author_link,
$this->linkTo($proj_phid), $this->linkTo($proj_phid),
$this->renderString($old_name), $this->renderString($old_name),
$this->renderString($new_name)); $this->renderString($new_name));
@ -64,48 +68,64 @@ final class PhabricatorFeedStoryProject extends PhabricatorFeedStory {
if ((count($add) == 1) && (count($rem) == 0) && if ((count($add) == 1) && (count($rem) == 0) &&
(head($add) == $author_phid)) { (head($add) == $author_phid)) {
$action = hsprintf('joined project %s.', $this->linkTo($proj_phid)); $action = pht(
'% joined project %s.',
$author_link,
$this->linkTo($proj_phid));
} else if ((count($add) == 0) && (count($rem) == 1) && } else if ((count($add) == 0) && (count($rem) == 1) &&
(head($rem) == $author_phid)) { (head($rem) == $author_phid)) {
$action = hsprintf('left project %s.', $this->linkTo($proj_phid)); $action = pht(
'%s left project %s.',
$author_link,
$this->linkTo($proj_phid));
} else if (empty($rem)) { } else if (empty($rem)) {
$action = hsprintf( $action = pht(
'added members to project %s: %s.', '%s added members to project %s: %s.',
$author_link,
$this->linkTo($proj_phid), $this->linkTo($proj_phid),
$this->renderHandleList($add)); $this->renderHandleList($add));
} else if (empty($add)) { } else if (empty($add)) {
$action = hsprintf( $action = pht(
'removed members from project %s: %s.', '%s removed members from project %s: %s.',
$author_link,
$this->linkTo($proj_phid), $this->linkTo($proj_phid),
$this->renderHandleList($rem)); $this->renderHandleList($rem));
} else { } else {
$action = hsprintf( $action = pht(
'changed members of project %s, added: %s; removed: %s.', '%s changed members of project %s, added: %s; removed: %s.',
$author_link,
$this->linkTo($proj_phid), $this->linkTo($proj_phid),
$this->renderHandleList($add), $this->renderHandleList($add),
$this->renderHandleList($rem)); $this->renderHandleList($rem));
} }
break; break;
case PhabricatorProjectTransactionType::TYPE_CAN_VIEW: case PhabricatorProjectTransactionType::TYPE_CAN_VIEW:
$action = hsprintf( $action = pht(
'changed the visibility for %s.', '%s changed the visibility for %s.',
$author_link,
$this->linkTo($proj_phid)); $this->linkTo($proj_phid));
break; break;
case PhabricatorProjectTransactionType::TYPE_CAN_EDIT: case PhabricatorProjectTransactionType::TYPE_CAN_EDIT:
$action = hsprintf( $action = pht(
'changed the edit policy for %s.', '%s changed the edit policy for %s.',
$author_link,
$this->linkTo($proj_phid)); $this->linkTo($proj_phid));
break; break;
case PhabricatorProjectTransactionType::TYPE_CAN_JOIN: case PhabricatorProjectTransactionType::TYPE_CAN_JOIN:
$action = hsprintf( $action = pht(
'changed the join policy for %s.', '%s changed the join policy for %s.',
$author_link,
$this->linkTo($proj_phid)); $this->linkTo($proj_phid));
break; break;
default: default:
$action = hsprintf('updated project %s.', $this->linkTo($proj_phid)); $action = pht(
'%s updated project %s.',
$author_link,
$this->linkTo($proj_phid));
break; break;
} }
$view->setTitle(hsprintf('%s %s', $this->linkTo($author_phid), $action));
$view->setTitle($action);
$view->setImage($this->getHandle($author_phid)->getImageURI()); $view->setImage($this->getHandle($author_phid)->getImageURI());
return $view; return $view;
@ -121,7 +141,7 @@ final class PhabricatorFeedStoryProject extends PhabricatorFeedStory {
$proj_uri = PhabricatorEnv::getURI($proj_handle->getURI()); $proj_uri = PhabricatorEnv::getURI($proj_handle->getURI());
$author_phid = $this->getAuthorPHID(); $author_phid = $this->getAuthorPHID();
$author_name = $this->getHandle($author_phid)->getLinkName(); $author_name = $this->linkTo($author_phid);
switch ($type) { switch ($type) {
case PhabricatorProjectTransactionType::TYPE_NAME: case PhabricatorProjectTransactionType::TYPE_NAME:

View file

@ -28,7 +28,7 @@ final class PhabricatorFeedStoryStatus extends PhabricatorFeedStory {
$author_name = $author_handle->getLinkName(); $author_name = $author_handle->getLinkName();
$author_uri = PhabricatorEnv::getURI($author_handle->getURI()); $author_uri = PhabricatorEnv::getURI($author_handle->getURI());
$text = pht('% supdated their status %s', $author_name, $author_uri); $text = pht('% updated their status %s', $author_name, $author_uri);
return $text; return $text;
} }

View file

@ -172,24 +172,28 @@ final class PhabricatorObjectHandle
if ($name === null) { if ($name === null) {
$name = $this->getLinkName(); $name = $this->getLinkName();
} }
$class = null; $classes = array();
$title = $this->title; $title = $this->title;
if ($this->status != PhabricatorObjectHandleStatus::STATUS_OPEN) { if ($this->status != PhabricatorObjectHandleStatus::STATUS_OPEN) {
$class .= ' handle-status-'.$this->status; $classes[] = 'handle-status-'.$this->status;
$title = $title ? $title : $this->status; $title = $title ? $title : $this->status;
} }
if ($this->disabled) { if ($this->disabled) {
$class .= ' handle-disabled'; $classes[] = 'handle-disabled';
$title = 'disabled'; // Overwrite status. $title = 'disabled'; // Overwrite status.
} }
if ($this->getType() == PhabricatorPeoplePHIDTypeUser::TYPECONST) {
$classes[] = 'phui-link-person';
}
return phutil_tag( return phutil_tag(
'a', 'a',
array( array(
'href' => $this->getURI(), 'href' => $this->getURI(),
'class' => $class, 'class' => implode(' ', $classes),
'title' => $title, 'title' => $title,
), ),
$name); $name);

View file

@ -123,6 +123,7 @@ final class PHUIFeedStoryView extends AphrontView {
public function render() { public function render() {
require_celerity_resource('phui-feed-story-css'); require_celerity_resource('phui-feed-story-css');
Javelin::initBehavior('phabricator-hovercards');
$oneline = $this->isEmptyContent($this->renderChildren()); $oneline = $this->isEmptyContent($this->renderChildren());
$body = null; $body = null;
@ -204,7 +205,7 @@ final class PHUIFeedStoryView extends AphrontView {
'class' => 'phui-feed-story-head', 'class' => 'phui-feed-story-head',
), ),
array( array(
$actor, (!$oneline ? $actor : null),
nonempty($this->title, pht('Untitled Story')), nonempty($this->title, pht('Untitled Story')),
$icons, $icons,
$ol_foot $ol_foot

View file

@ -19,7 +19,12 @@
.phui-feed-story-head { .phui-feed-story-head {
padding: 8px; padding: 8px;
overflow: hidden; overflow: hidden;
color: #555;
}
.phui-feed-story-head .phui-link-person {
color: #333; color: #333;
font-weight: bold;
} }
.phui-feed-story-body { .phui-feed-story-body {
@ -99,5 +104,6 @@
color: #777; color: #777;
margin-top: 2px; margin-top: 2px;
line-height: 14px; line-height: 14px;
font-weight: normal;
} }