1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-28 00:10:57 +01:00

Add a feed detail/permalink page for feed stories

Summary:
Ref T2852. Asana has one bug which I'm having a little trouble figuring out. I want to get more information to debug it, but I'll need them to run `bin/feed republish <story_id>` to get that data.

Right now, it's incredibly hard to figure out the story ID for feed stories. So mostly this is to make that easier (click permalink; pull it out of the URL), but it also adds a little functionality and cleans the code up a bit.

The page itself could be prettier and maybe some day we'll add comments or whatever, but it seems reasonably functionalish.

Test Plan:
{F49962}

  - Also loaded many pages of feed history to check that nothing broke.

Reviewers: btrahan, chad

Reviewed By: chad

CC: chad, aran

Maniphest Tasks: T2852

Differential Revision: https://secure.phabricator.com/D6440
This commit is contained in:
epriestley 2013-07-12 17:04:02 -07:00
parent 7d3b19922c
commit abe24ff1ab
18 changed files with 99 additions and 30 deletions

View file

@ -2235,7 +2235,7 @@ celerity_register_resource_map(array(
),
'javelin-behavior-pholio-mock-view' =>
array(
'uri' => '/res/014eb2bd/rsrc/js/application/pholio/behavior-pholio-mock-view.js',
'uri' => '/res/415cd66a/rsrc/js/application/pholio/behavior-pholio-mock-view.js',
'type' => 'js',
'requires' =>
array(
@ -3806,7 +3806,7 @@ celerity_register_resource_map(array(
),
'phui-feed-story-css' =>
array(
'uri' => '/res/253ac568/rsrc/css/phui/phui-feed-story.css',
'uri' => '/res/7960f59a/rsrc/css/phui/phui-feed-story.css',
'type' => 'css',
'requires' =>
array(

View file

@ -1087,6 +1087,7 @@ phutil_register_library_map(array(
'PhabricatorFeedConstants' => 'applications/feed/constants/PhabricatorFeedConstants.php',
'PhabricatorFeedController' => 'applications/feed/controller/PhabricatorFeedController.php',
'PhabricatorFeedDAO' => 'applications/feed/storage/PhabricatorFeedDAO.php',
'PhabricatorFeedDetailController' => 'applications/feed/controller/PhabricatorFeedDetailController.php',
'PhabricatorFeedMainController' => 'applications/feed/controller/PhabricatorFeedMainController.php',
'PhabricatorFeedManagementRepublishWorkflow' => 'applications/feed/management/PhabricatorFeedManagementRepublishWorkflow.php',
'PhabricatorFeedManagementWorkflow' => 'applications/feed/management/PhabricatorFeedManagementWorkflow.php',
@ -3039,6 +3040,7 @@ phutil_register_library_map(array(
'PhabricatorFeedConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorFeedController' => 'PhabricatorController',
'PhabricatorFeedDAO' => 'PhabricatorLiskDAO',
'PhabricatorFeedDetailController' => 'PhabricatorFeedController',
'PhabricatorFeedMainController' => 'PhabricatorFeedController',
'PhabricatorFeedManagementRepublishWorkflow' => 'PhabricatorFeedManagementWorkflow',
'PhabricatorFeedManagementWorkflow' => 'PhutilArgumentWorkflow',

View file

@ -22,6 +22,7 @@ final class PhabricatorApplicationFeed extends PhabricatorApplication {
return array(
'/feed/' => array(
'public/' => 'PhabricatorFeedPublicStreamController',
'(?P<id>\d+)/' => 'PhabricatorFeedDetailController',
'(?:(?P<filter>[^/]+)/)?' => 'PhabricatorFeedMainController',
),
);

View file

@ -0,0 +1,52 @@
<?php
final class PhabricatorFeedDetailController extends PhabricatorFeedController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$story = id(new PhabricatorFeedQuery())
->setViewer($user)
->withChronologicalKeys(array($this->id))
->executeOne();
if (!$story) {
return new Aphront404Response();
}
$feed = array($story);
$builder = new PhabricatorFeedBuilder($feed);
$builder->setUser($user);
$feed_view = $builder->buildView();
$title = pht('Story');
$feed_view = hsprintf(
'<div class="phabricator-feed-frame">%s</div>',
$feed_view);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addCrumb(
id(new PhabricatorCrumbView())
->setName($title));
return $this->buildApplicationPage(
array(
$crumbs,
$feed_view,
),
array(
'title' => $title,
'device' => true,
'dust' => true,
));
}
}

View file

@ -258,6 +258,13 @@ abstract class PhabricatorFeedStory implements PhabricatorPolicyInterface {
return array();
}
protected function newStoryView() {
return id(new PHUIFeedStoryView())
->setChronologicalKey($this->getChronologicalKey())
->setEpoch($this->getEpoch())
->setViewed($this->getHasViewed());
}
/* -( PhabricatorPolicyInterface Implementation )-------------------------- */

View file

@ -10,7 +10,7 @@ final class PhabricatorFeedStoryAudit extends PhabricatorFeedStory {
$author_phid = $this->getAuthorPHID();
$commit_phid = $this->getPrimaryObjectPHID();
$view = new PHUIFeedStoryView();
$view = $this->newStoryView();
$view->setAppIcon('audit-dark');
$action = $this->getValue('action');
@ -22,8 +22,6 @@ final class PhabricatorFeedStoryAudit extends PhabricatorFeedStory {
$verb,
$this->linkTo($commit_phid)));
$view->setEpoch($this->getEpoch());
$comments = $this->getValue('content');
$view->setImage($this->getHandle($author_phid)->getImageURI());

View file

@ -49,11 +49,10 @@ final class PhabricatorFeedStoryCommit extends PhabricatorFeedStory {
$commit);
}
$view = new PHUIFeedStoryView();
$view = $this->newStoryView();
$view->setAppIcon('differential-dark');
$view->setTitle($title);
$view->setEpoch($data->getEpoch());
if ($data->getValue('authorPHID')) {
$view->setImage($this->getHandle($data->getAuthorPHID())->getImageURI());

View file

@ -9,13 +9,11 @@ final class PhabricatorFeedStoryDifferential extends PhabricatorFeedStory {
public function renderView() {
$data = $this->getStoryData();
$view = new PHUIFeedStoryView();
$view = $this->newStoryView();
$view->setAppIcon('differential-dark');
$view->setViewed($this->getHasViewed());
$line = $this->getLineForData($data);
$view->setTitle($line);
$view->setEpoch($data->getEpoch());
$href = $this->getHandle($data->getValue('revision_phid'))->getURI();
$view->setHref($href);

View file

@ -54,10 +54,8 @@ final class PhabricatorFeedStoryDifferentialAggregate
break;
}
$view = new PHUIFeedStoryView();
$view = $this->newStoryView();
$view->setAppIcon('differential-dark');
$view->setEpoch($this->getEpoch());
$view->setViewed($this->getHasViewed());
$view->setTitle($title);
$href = $this->getHandle($data->getValue('revision_phid'))->getURI();

View file

@ -16,13 +16,11 @@ final class PhabricatorFeedStoryManiphest
public function renderView() {
$data = $this->getStoryData();
$view = new PHUIFeedStoryView();
$view = $this->newStoryView();
$view->setAppIcon('maniphest-dark');
$view->setViewed($this->getHasViewed());
$line = $this->getLineForData($data);
$view->setTitle($line);
$view->setEpoch($data->getEpoch());
$action = $data->getValue('action');

View file

@ -54,10 +54,8 @@ final class PhabricatorFeedStoryManiphestAggregate
break;
}
$view = new PHUIFeedStoryView();
$view = $this->newStoryView();
$view->setAppIcon('maniphest-dark');
$view->setEpoch($this->getEpoch());
$view->setViewed($this->getHasViewed());
$view->setTitle($title);
$href = $this->getHandle($data->getValue('taskPHID'))->getURI();

View file

@ -21,7 +21,7 @@ final class PhabricatorFeedStoryPhriction extends PhabricatorFeedStory {
$author_phid = $data->getAuthorPHID();
$document_phid = $data->getValue('phid');
$view = new PHUIFeedStoryView();
$view = $this->newStoryView();
$view->setAppIcon('phriction-dark');
$action = $data->getValue('action');
@ -64,7 +64,6 @@ final class PhabricatorFeedStoryPhriction extends PhabricatorFeedStory {
break;
}
$view->setEpoch($data->getEpoch());
$view->setImage($this->getHandle($author_phid)->getImageURI());
$content = $this->renderSummary($data->getValue('content'));
$view->appendChild($content);

View file

@ -24,7 +24,7 @@ final class PhabricatorFeedStoryProject extends PhabricatorFeedStory {
public function renderView() {
$data = $this->getStoryData();
$view = new PHUIFeedStoryView();
$view = $this->newStoryView();
$view->setAppIcon('projects-dark');
$type = $data->getValue('type');

View file

@ -11,11 +11,10 @@ final class PhabricatorFeedStoryStatus extends PhabricatorFeedStory {
$author_phid = $data->getAuthorPHID();
$view = new PHUIFeedStoryView();
$view = $this->newStoryView();
$view->setAppIcon('calendar-dark');
$view->setTitle($this->linkTo($author_phid));
$view->setEpoch($data->getEpoch());
$view->setImage($this->getHandle($author_phid)->getImageURI());
$content = $this->renderSummary($data->getValue('content'), $len = null);

View file

@ -15,9 +15,8 @@ final class PhabricatorTokenGivenFeedStory
}
public function renderView() {
$view = new PHUIFeedStoryView();
$view = $this->newStoryView();
$view->setAppIcon('token-dark');
$view->setViewed($this->getHasViewed());
$author_phid = $this->getValue('authorPHID');
$href = $this->getHandle($this->getPrimaryObjectPHID())->getURI();

View file

@ -32,12 +32,10 @@ class PhabricatorApplicationTransactionFeedStory
}
public function renderView() {
$view = new PHUIFeedStoryView();
$view->setViewed($this->getHasViewed());
$view = $this->newStoryView();
$handle = $this->getHandle($this->getPrimaryObjectPHID());
$view->setHref($handle->getURI());
$view->setEpoch($this->getPrimaryTransaction()->getDateCreated());
$view->setAppIconFromPHID($handle->getPHID());

View file

@ -14,6 +14,16 @@ final class PHUIFeedStoryView extends AphrontView {
private $tokenBar = array();
private $projects = array();
private $actions = array();
private $chronologicalKey;
public function setChronologicalKey($chronological_key) {
$this->chronologicalKey = $chronological_key;
return $this;
}
public function getChronologicalKey() {
return $this->chronologicalKey;
}
public function setTitle($title) {
$this->title = $title;
@ -184,6 +194,15 @@ final class PHUIFeedStoryView extends AphrontView {
$foot = pht('No time specified.');
}
if ($this->chronologicalKey) {
$foot = phutil_tag(
'a',
array(
'href' => '/feed/'.$this->chronologicalKey.'/',
),
$foot);
}
$icon = null;
if ($this->appIcon) {
$icon = new PHUIIconView();

View file

@ -29,13 +29,17 @@
}
.phui-feed-story-foot {
color: #777;
font-size: 11px;
background: #f7f7f7;
padding: 10px;
line-height: 14px;
}
.phui-feed-story-foot,
.phui-feed-story-foot a {
color: #777;
}
.phui-feed-story-foot .phui-icon-view {
float: left;
display: inline-block;