@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+128 -83
+4
src/__phutil_library_map__.php
··· 601 601 'PhabricatorApplicationDiviner' => 'applications/diviner/application/PhabricatorApplicationDiviner.php', 602 602 'PhabricatorApplicationDrydock' => 'applications/drydock/application/PhabricatorApplicationDrydock.php', 603 603 'PhabricatorApplicationFact' => 'applications/fact/application/PhabricatorApplicationFact.php', 604 + 'PhabricatorApplicationFeed' => 'applications/feed/application/PhabricatorApplicationFeed.php', 604 605 'PhabricatorApplicationFiles' => 'applications/files/application/PhabricatorApplicationFiles.php', 605 606 'PhabricatorApplicationFlags' => 'applications/flag/application/PhabricatorApplicationFlags.php', 606 607 'PhabricatorApplicationHerald' => 'applications/herald/application/PhabricatorApplicationHerald.php', ··· 800 801 'PhabricatorFeedConstants' => 'applications/feed/constants/PhabricatorFeedConstants.php', 801 802 'PhabricatorFeedController' => 'applications/feed/controller/PhabricatorFeedController.php', 802 803 'PhabricatorFeedDAO' => 'applications/feed/storage/PhabricatorFeedDAO.php', 804 + 'PhabricatorFeedMainController' => 'applications/feed/controller/PhabricatorFeedMainController.php', 803 805 'PhabricatorFeedPublicStreamController' => 'applications/feed/controller/PhabricatorFeedPublicStreamController.php', 804 806 'PhabricatorFeedQuery' => 'applications/feed/PhabricatorFeedQuery.php', 805 807 'PhabricatorFeedStory' => 'applications/feed/story/PhabricatorFeedStory.php', ··· 1948 1950 'PhabricatorApplicationDiviner' => 'PhabricatorApplication', 1949 1951 'PhabricatorApplicationDrydock' => 'PhabricatorApplication', 1950 1952 'PhabricatorApplicationFact' => 'PhabricatorApplication', 1953 + 'PhabricatorApplicationFeed' => 'PhabricatorApplication', 1951 1954 'PhabricatorApplicationFiles' => 'PhabricatorApplication', 1952 1955 'PhabricatorApplicationFlags' => 'PhabricatorApplication', 1953 1956 'PhabricatorApplicationHerald' => 'PhabricatorApplication', ··· 2153 2156 'PhabricatorFactUpdateIterator' => 'PhutilBufferedIterator', 2154 2157 'PhabricatorFeedController' => 'PhabricatorController', 2155 2158 'PhabricatorFeedDAO' => 'PhabricatorLiskDAO', 2159 + 'PhabricatorFeedMainController' => 'PhabricatorFeedController', 2156 2160 'PhabricatorFeedPublicStreamController' => 'PhabricatorFeedController', 2157 2161 'PhabricatorFeedQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 2158 2162 'PhabricatorFeedStory' => 'PhabricatorPolicyInterface',
-5
src/aphront/configuration/AphrontDefaultApplicationConfiguration.php
··· 18 18 return $this->getResourceURIMapRules() + array( 19 19 '/(?:(?P<filter>(?:jump))/)?' => 20 20 'PhabricatorDirectoryMainController', 21 - '/(?:(?P<filter>feed)/)' => array( 22 - 'public/' => 'PhabricatorFeedPublicStreamController', 23 - '(?:(?P<subfilter>[^/]+)/)?' => 24 - 'PhabricatorDirectoryMainController', 25 - ), 26 21 27 22 '/typeahead/' => array( 28 23 'common/(?P<type>\w+)/'
-78
src/applications/directory/controller/PhabricatorDirectoryMainController.php
··· 21 21 case 'jump': 22 22 break; 23 23 case 'home': 24 - case 'feed': 25 24 $project_query = new PhabricatorProjectQuery(); 26 25 $project_query->setViewer($user); 27 26 $project_query->withMemberPHIDs(array($user->getPHID())); ··· 32 31 } 33 32 34 33 switch ($this->filter) { 35 - case 'feed': 36 - return $this->buildFeedResponse($nav, $projects); 37 34 case 'jump': 38 35 return $this->buildJumpResponse($nav); 39 36 default: ··· 108 105 $nav, 109 106 array( 110 107 'title' => 'Jump Nav', 111 - )); 112 - } 113 - 114 - private function buildFeedResponse($nav, array $projects) { 115 - assert_instances_of($projects, 'PhabricatorProject'); 116 - 117 - $subnav = new AphrontSideNavFilterView(); 118 - $subnav->setBaseURI(new PhutilURI('/feed/')); 119 - 120 - $subnav->addFilter('all', 'All Activity', '/feed/'); 121 - $subnav->addFilter('projects', 'My Projects'); 122 - 123 - $nav->appendChild($subnav); 124 - 125 - $filter = $subnav->selectFilter($this->subfilter, 'all'); 126 - 127 - $view = null; 128 - switch ($filter) { 129 - case 'all': 130 - $view = $this->buildFeedView(array()); 131 - break; 132 - case 'projects': 133 - if ($projects) { 134 - $phids = mpull($projects, 'getPHID'); 135 - $view = $this->buildFeedView($phids); 136 - } else { 137 - $view = new AphrontErrorView(); 138 - $view->setSeverity(AphrontErrorView::SEVERITY_NODATA); 139 - $view->setTitle('No Projects'); 140 - $view->appendChild('You have not joined any projects.'); 141 - } 142 - break; 143 - } 144 - 145 - $subnav->appendChild($view); 146 - 147 - return $this->buildStandardPageResponse( 148 - $nav, 149 - array( 150 - 'title' => 'Feed', 151 108 )); 152 109 } 153 110 ··· 375 332 $view->setHandles($handles); 376 333 377 334 return $view; 378 - } 379 - 380 - private function buildFeedView(array $phids) { 381 - $request = $this->getRequest(); 382 - $user = $request->getUser(); 383 - $user_phid = $user->getPHID(); 384 - 385 - $feed_query = new PhabricatorFeedQuery(); 386 - $feed_query->setViewer($user); 387 - if ($phids) { 388 - $feed_query->setFilterPHIDs($phids); 389 - } 390 - 391 - $pager = new AphrontCursorPagerView(); 392 - $pager->readFromRequest($request); 393 - $pager->setPageSize(200); 394 - 395 - $feed = $feed_query->executeWithCursorPager($pager); 396 - 397 - $builder = new PhabricatorFeedBuilder($feed); 398 - $builder->setUser($user); 399 - $feed_view = $builder->buildView(); 400 - 401 - return 402 - '<div style="padding: 1em 3em;">'. 403 - '<div style="margin: 0 1em;">'. 404 - '<h1 style="font-size: 18px; '. 405 - 'border-bottom: 1px solid #aaaaaa; '. 406 - 'padding: 0;">Feed</h1>'. 407 - '</div>'. 408 - $feed_view->render(). 409 - '<div class="phabricator-feed-frame">'. 410 - $pager->render(). 411 - '</div>'. 412 - '</div>'; 413 335 } 414 336 415 337 private function buildJumpPanel($query=null) {
+31
src/applications/feed/application/PhabricatorApplicationFeed.php
··· 1 + <?php 2 + 3 + final class PhabricatorApplicationFeed extends PhabricatorApplication { 4 + 5 + public function getBaseURI() { 6 + return '/feed/'; 7 + } 8 + 9 + public function getShortDescription() { 10 + return 'Review activity.'; 11 + } 12 + 13 + public function getIconName() { 14 + return 'feed'; 15 + } 16 + 17 + public function getRoutes() { 18 + return array( 19 + '/feed/' => array( 20 + 'public/' => 'PhabricatorFeedPublicStreamController', 21 + '(?:(?P<filter>[^/]+)/)?' => 'PhabricatorFeedMainController', 22 + ), 23 + ); 24 + } 25 + 26 + public function getApplicationGroup() { 27 + return self::GROUP_COMMUNICATION; 28 + } 29 + 30 + } 31 +
+15
src/applications/feed/controller/PhabricatorFeedController.php
··· 22 22 return $response->setContent($page->render()); 23 23 } 24 24 25 + protected function buildSideNavView() { 26 + $nav = new AphrontSideNavFilterView(); 27 + $nav->setBaseURI(new PhutilURI($this->getApplicationURI())); 28 + 29 + $nav->addLabel('Feed'); 30 + $nav->addFilter('all', 'All Activity'); 31 + $nav->addFilter('projects', 'My Projects'); 32 + 33 + return $nav; 34 + } 35 + 36 + protected function buildApplicationMenu() { 37 + return $this->buildSideNavView()->getMenu(); 38 + } 39 + 25 40 }
+78
src/applications/feed/controller/PhabricatorFeedMainController.php
··· 1 + <?php 2 + 3 + final class PhabricatorFeedMainController extends PhabricatorFeedController { 4 + 5 + private $filter; 6 + 7 + public function willProcessRequest(array $data) { 8 + $this->filter = idx($data, 'filter'); 9 + } 10 + 11 + public function processRequest() { 12 + $request = $this->getRequest(); 13 + $user = $request->getUser(); 14 + 15 + $nav = $this->buildSideNavView(); 16 + $filter = $nav->selectFilter($this->filter, 'all'); 17 + 18 + $pager = new AphrontCursorPagerView(); 19 + $pager->readFromRequest($request); 20 + $pager->setPageSize(200); 21 + 22 + 23 + $query = id(new PhabricatorFeedQuery()) 24 + ->setViewer($user); 25 + 26 + $nodata = null; 27 + switch ($filter) { 28 + case 'all': 29 + $title = pht('Feed'); 30 + break; 31 + case 'projects': 32 + $projects = id(new PhabricatorProjectQuery()) 33 + ->setViewer($user) 34 + ->withMemberPHIDs(array($user->getPHID())) 35 + ->execute(); 36 + 37 + if (!$projects) { 38 + $nodata = pht('You have not joined any projects.'); 39 + } else { 40 + $query->setFilterPHIDs(mpull($projects, 'getPHID')); 41 + } 42 + 43 + $title = pht('Feed: My Projects'); 44 + break; 45 + } 46 + 47 + if ($nodata) { 48 + $feed_view = id(new AphrontErrorView()) 49 + ->setSeverity(AphrontErrorView::SEVERITY_NODATA) 50 + ->setTitle(pht('No Stories')) 51 + ->appendChild($nodata); 52 + } else { 53 + $feed = $query->executeWithCursorPager($pager); 54 + 55 + $builder = new PhabricatorFeedBuilder($feed); 56 + $builder->setUser($user); 57 + $feed_view = $builder->buildView(); 58 + } 59 + 60 + $header = id(new PhabricatorHeaderView()) 61 + ->setHeader($title); 62 + 63 + $nav->appendChild( 64 + array( 65 + $header, 66 + $feed_view, 67 + $pager, 68 + )); 69 + 70 + return $this->buildApplicationPage( 71 + $nav, 72 + array( 73 + 'title' => $title, 74 + 'device' => true, 75 + )); 76 + } 77 + 78 + }