mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 21:40:55 +01:00
Make feed its own application
Summary: Fixes the two-level nav issue introduced by D4376. (My claim that this page is device ready in the code is something of a lie, but it's fairly close.) (@chad, this could use an icon at some point, or you can point me at which one you want and I can take a stab at slicing it.) Test Plan: Looked at feed; saw it not-broken. Also checked public feed (which should just merge at some point). Reviewers: btrahan, chad Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D4381
This commit is contained in:
parent
21ed25019d
commit
ebf2435c49
6 changed files with 128 additions and 83 deletions
|
@ -601,6 +601,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorApplicationDiviner' => 'applications/diviner/application/PhabricatorApplicationDiviner.php',
|
||||
'PhabricatorApplicationDrydock' => 'applications/drydock/application/PhabricatorApplicationDrydock.php',
|
||||
'PhabricatorApplicationFact' => 'applications/fact/application/PhabricatorApplicationFact.php',
|
||||
'PhabricatorApplicationFeed' => 'applications/feed/application/PhabricatorApplicationFeed.php',
|
||||
'PhabricatorApplicationFiles' => 'applications/files/application/PhabricatorApplicationFiles.php',
|
||||
'PhabricatorApplicationFlags' => 'applications/flag/application/PhabricatorApplicationFlags.php',
|
||||
'PhabricatorApplicationHerald' => 'applications/herald/application/PhabricatorApplicationHerald.php',
|
||||
|
@ -800,6 +801,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorFeedConstants' => 'applications/feed/constants/PhabricatorFeedConstants.php',
|
||||
'PhabricatorFeedController' => 'applications/feed/controller/PhabricatorFeedController.php',
|
||||
'PhabricatorFeedDAO' => 'applications/feed/storage/PhabricatorFeedDAO.php',
|
||||
'PhabricatorFeedMainController' => 'applications/feed/controller/PhabricatorFeedMainController.php',
|
||||
'PhabricatorFeedPublicStreamController' => 'applications/feed/controller/PhabricatorFeedPublicStreamController.php',
|
||||
'PhabricatorFeedQuery' => 'applications/feed/PhabricatorFeedQuery.php',
|
||||
'PhabricatorFeedStory' => 'applications/feed/story/PhabricatorFeedStory.php',
|
||||
|
@ -1948,6 +1950,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorApplicationDiviner' => 'PhabricatorApplication',
|
||||
'PhabricatorApplicationDrydock' => 'PhabricatorApplication',
|
||||
'PhabricatorApplicationFact' => 'PhabricatorApplication',
|
||||
'PhabricatorApplicationFeed' => 'PhabricatorApplication',
|
||||
'PhabricatorApplicationFiles' => 'PhabricatorApplication',
|
||||
'PhabricatorApplicationFlags' => 'PhabricatorApplication',
|
||||
'PhabricatorApplicationHerald' => 'PhabricatorApplication',
|
||||
|
@ -2153,6 +2156,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorFactUpdateIterator' => 'PhutilBufferedIterator',
|
||||
'PhabricatorFeedController' => 'PhabricatorController',
|
||||
'PhabricatorFeedDAO' => 'PhabricatorLiskDAO',
|
||||
'PhabricatorFeedMainController' => 'PhabricatorFeedController',
|
||||
'PhabricatorFeedPublicStreamController' => 'PhabricatorFeedController',
|
||||
'PhabricatorFeedQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'PhabricatorFeedStory' => 'PhabricatorPolicyInterface',
|
||||
|
|
|
@ -18,11 +18,6 @@ class AphrontDefaultApplicationConfiguration
|
|||
return $this->getResourceURIMapRules() + array(
|
||||
'/(?:(?P<filter>(?:jump))/)?' =>
|
||||
'PhabricatorDirectoryMainController',
|
||||
'/(?:(?P<filter>feed)/)' => array(
|
||||
'public/' => 'PhabricatorFeedPublicStreamController',
|
||||
'(?:(?P<subfilter>[^/]+)/)?' =>
|
||||
'PhabricatorDirectoryMainController',
|
||||
),
|
||||
|
||||
'/typeahead/' => array(
|
||||
'common/(?P<type>\w+)/'
|
||||
|
|
|
@ -21,7 +21,6 @@ final class PhabricatorDirectoryMainController
|
|||
case 'jump':
|
||||
break;
|
||||
case 'home':
|
||||
case 'feed':
|
||||
$project_query = new PhabricatorProjectQuery();
|
||||
$project_query->setViewer($user);
|
||||
$project_query->withMemberPHIDs(array($user->getPHID()));
|
||||
|
@ -32,8 +31,6 @@ final class PhabricatorDirectoryMainController
|
|||
}
|
||||
|
||||
switch ($this->filter) {
|
||||
case 'feed':
|
||||
return $this->buildFeedResponse($nav, $projects);
|
||||
case 'jump':
|
||||
return $this->buildJumpResponse($nav);
|
||||
default:
|
||||
|
@ -111,46 +108,6 @@ final class PhabricatorDirectoryMainController
|
|||
));
|
||||
}
|
||||
|
||||
private function buildFeedResponse($nav, array $projects) {
|
||||
assert_instances_of($projects, 'PhabricatorProject');
|
||||
|
||||
$subnav = new AphrontSideNavFilterView();
|
||||
$subnav->setBaseURI(new PhutilURI('/feed/'));
|
||||
|
||||
$subnav->addFilter('all', 'All Activity', '/feed/');
|
||||
$subnav->addFilter('projects', 'My Projects');
|
||||
|
||||
$nav->appendChild($subnav);
|
||||
|
||||
$filter = $subnav->selectFilter($this->subfilter, 'all');
|
||||
|
||||
$view = null;
|
||||
switch ($filter) {
|
||||
case 'all':
|
||||
$view = $this->buildFeedView(array());
|
||||
break;
|
||||
case 'projects':
|
||||
if ($projects) {
|
||||
$phids = mpull($projects, 'getPHID');
|
||||
$view = $this->buildFeedView($phids);
|
||||
} else {
|
||||
$view = new AphrontErrorView();
|
||||
$view->setSeverity(AphrontErrorView::SEVERITY_NODATA);
|
||||
$view->setTitle('No Projects');
|
||||
$view->appendChild('You have not joined any projects.');
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$subnav->appendChild($view);
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
$nav,
|
||||
array(
|
||||
'title' => 'Feed',
|
||||
));
|
||||
}
|
||||
|
||||
private function buildUnbreakNowPanel() {
|
||||
$user = $this->getRequest()->getUser();
|
||||
$user_phid = $user->getPHID();
|
||||
|
@ -377,41 +334,6 @@ final class PhabricatorDirectoryMainController
|
|||
return $view;
|
||||
}
|
||||
|
||||
private function buildFeedView(array $phids) {
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
$user_phid = $user->getPHID();
|
||||
|
||||
$feed_query = new PhabricatorFeedQuery();
|
||||
$feed_query->setViewer($user);
|
||||
if ($phids) {
|
||||
$feed_query->setFilterPHIDs($phids);
|
||||
}
|
||||
|
||||
$pager = new AphrontCursorPagerView();
|
||||
$pager->readFromRequest($request);
|
||||
$pager->setPageSize(200);
|
||||
|
||||
$feed = $feed_query->executeWithCursorPager($pager);
|
||||
|
||||
$builder = new PhabricatorFeedBuilder($feed);
|
||||
$builder->setUser($user);
|
||||
$feed_view = $builder->buildView();
|
||||
|
||||
return
|
||||
'<div style="padding: 1em 3em;">'.
|
||||
'<div style="margin: 0 1em;">'.
|
||||
'<h1 style="font-size: 18px; '.
|
||||
'border-bottom: 1px solid #aaaaaa; '.
|
||||
'padding: 0;">Feed</h1>'.
|
||||
'</div>'.
|
||||
$feed_view->render().
|
||||
'<div class="phabricator-feed-frame">'.
|
||||
$pager->render().
|
||||
'</div>'.
|
||||
'</div>';
|
||||
}
|
||||
|
||||
private function buildJumpPanel($query=null) {
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorApplicationFeed extends PhabricatorApplication {
|
||||
|
||||
public function getBaseURI() {
|
||||
return '/feed/';
|
||||
}
|
||||
|
||||
public function getShortDescription() {
|
||||
return 'Review activity.';
|
||||
}
|
||||
|
||||
public function getIconName() {
|
||||
return 'feed';
|
||||
}
|
||||
|
||||
public function getRoutes() {
|
||||
return array(
|
||||
'/feed/' => array(
|
||||
'public/' => 'PhabricatorFeedPublicStreamController',
|
||||
'(?:(?P<filter>[^/]+)/)?' => 'PhabricatorFeedMainController',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function getApplicationGroup() {
|
||||
return self::GROUP_COMMUNICATION;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -22,4 +22,19 @@ abstract class PhabricatorFeedController extends PhabricatorController {
|
|||
return $response->setContent($page->render());
|
||||
}
|
||||
|
||||
protected function buildSideNavView() {
|
||||
$nav = new AphrontSideNavFilterView();
|
||||
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
|
||||
|
||||
$nav->addLabel('Feed');
|
||||
$nav->addFilter('all', 'All Activity');
|
||||
$nav->addFilter('projects', 'My Projects');
|
||||
|
||||
return $nav;
|
||||
}
|
||||
|
||||
protected function buildApplicationMenu() {
|
||||
return $this->buildSideNavView()->getMenu();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorFeedMainController extends PhabricatorFeedController {
|
||||
|
||||
private $filter;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->filter = idx($data, 'filter');
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
$nav = $this->buildSideNavView();
|
||||
$filter = $nav->selectFilter($this->filter, 'all');
|
||||
|
||||
$pager = new AphrontCursorPagerView();
|
||||
$pager->readFromRequest($request);
|
||||
$pager->setPageSize(200);
|
||||
|
||||
|
||||
$query = id(new PhabricatorFeedQuery())
|
||||
->setViewer($user);
|
||||
|
||||
$nodata = null;
|
||||
switch ($filter) {
|
||||
case 'all':
|
||||
$title = pht('Feed');
|
||||
break;
|
||||
case 'projects':
|
||||
$projects = id(new PhabricatorProjectQuery())
|
||||
->setViewer($user)
|
||||
->withMemberPHIDs(array($user->getPHID()))
|
||||
->execute();
|
||||
|
||||
if (!$projects) {
|
||||
$nodata = pht('You have not joined any projects.');
|
||||
} else {
|
||||
$query->setFilterPHIDs(mpull($projects, 'getPHID'));
|
||||
}
|
||||
|
||||
$title = pht('Feed: My Projects');
|
||||
break;
|
||||
}
|
||||
|
||||
if ($nodata) {
|
||||
$feed_view = id(new AphrontErrorView())
|
||||
->setSeverity(AphrontErrorView::SEVERITY_NODATA)
|
||||
->setTitle(pht('No Stories'))
|
||||
->appendChild($nodata);
|
||||
} else {
|
||||
$feed = $query->executeWithCursorPager($pager);
|
||||
|
||||
$builder = new PhabricatorFeedBuilder($feed);
|
||||
$builder->setUser($user);
|
||||
$feed_view = $builder->buildView();
|
||||
}
|
||||
|
||||
$header = id(new PhabricatorHeaderView())
|
||||
->setHeader($title);
|
||||
|
||||
$nav->appendChild(
|
||||
array(
|
||||
$header,
|
||||
$feed_view,
|
||||
$pager,
|
||||
));
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
$nav,
|
||||
array(
|
||||
'title' => $title,
|
||||
'device' => true,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue