@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.

Move activity log rendering to a dashboard panel

Summary:
Ref T4986. Swap this in. Two minor notes:

- I adjusted the SearchEngine to add an additional constraint when the viewer isn't an admin. This mostly stops us from doing a bunch of unnecessary work.
- I fixed the settings panel to paginate (currently loads all results, slow in production).

Test Plan: Viewed logs; viewed settings panel; created a dashboard panel.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4986

Differential Revision: https://secure.phabricator.com/D9136

+59 -32
+2 -30
src/applications/people/controller/PhabricatorPeopleLogsController.php
··· 1 1 <?php 2 2 3 - final class PhabricatorPeopleLogsController extends PhabricatorPeopleController 4 - implements PhabricatorApplicationSearchResultsControllerInterface { 3 + final class PhabricatorPeopleLogsController 4 + extends PhabricatorPeopleController { 5 5 6 6 private $queryKey; 7 7 ··· 18 18 19 19 return $this->delegateToController($controller); 20 20 } 21 - 22 - public function renderResultsList( 23 - array $logs, 24 - PhabricatorSavedQuery $query) { 25 - assert_instances_of($logs, 'PhabricatorUserLog'); 26 - 27 - $request = $this->getRequest(); 28 - $viewer = $request->getUser(); 29 - 30 - $phids = array(); 31 - foreach ($logs as $log) { 32 - $phids[$log->getActorPHID()] = true; 33 - $phids[$log->getUserPHID()] = true; 34 - } 35 - $phids = array_keys($phids); 36 - $handles = $this->loadViewerHandles($phids); 37 - 38 - $table = id(new PhabricatorUserLogView()) 39 - ->setUser($viewer) 40 - ->setLogs($logs) 41 - ->setSearchBaseURI($this->getApplicationURI('logs/')) 42 - ->setHandles($handles); 43 - 44 - return id(new PHUIObjectBoxView()) 45 - ->setHeaderText(pht('User Activity Logs')) 46 - ->appendChild($table); 47 - } 48 - 49 21 50 22 public function buildSideNavView() { 51 23 $nav = new AphrontSideNavFilterView();
+48
src/applications/people/query/PhabricatorPeopleLogSearchEngine.php
··· 3 3 final class PhabricatorPeopleLogSearchEngine 4 4 extends PhabricatorApplicationSearchEngine { 5 5 6 + public function getApplicationClassName() { 7 + return 'PhabricatorApplicationPeople'; 8 + } 9 + 6 10 public function getPageSize(PhabricatorSavedQuery $saved) { 7 11 return 500; 8 12 } ··· 35 39 36 40 public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { 37 41 $query = id(new PhabricatorPeopleLogQuery()); 42 + 43 + // NOTE: If the viewer isn't an administrator, always restrict the query to 44 + // related records. This echoes the policy logic of these logs. This is 45 + // mostly a performance optimization, to prevent us from having to pull 46 + // large numbers of logs that the user will not be able to see and filter 47 + // them in-process. 48 + $viewer = $this->requireViewer(); 49 + if (!$viewer->getIsAdmin()) { 50 + $query->withRelatedPHIDs(array($viewer->getPHID())); 51 + } 38 52 39 53 $actor_phids = $saved->getParameter('actorPHIDs', array()); 40 54 if ($actor_phids) { ··· 154 168 return parent::buildSavedQueryFromBuiltin($query_key); 155 169 } 156 170 171 + protected function getRequiredHandlePHIDsForResultList( 172 + array $logs, 173 + PhabricatorSavedQuery $query) { 174 + 175 + $phids = array(); 176 + foreach ($logs as $log) { 177 + $phids[$log->getActorPHID()] = true; 178 + $phids[$log->getUserPHID()] = true; 179 + } 180 + 181 + return array_keys($phids); 182 + } 183 + 184 + protected function renderResultList( 185 + array $logs, 186 + PhabricatorSavedQuery $query, 187 + array $handles) { 188 + assert_instances_of($logs, 'PhabricatorUserLog'); 189 + 190 + $viewer = $this->requireViewer(); 191 + 192 + $table = id(new PhabricatorUserLogView()) 193 + ->setUser($viewer) 194 + ->setLogs($logs) 195 + ->setHandles($handles); 196 + 197 + if ($viewer->getIsAdmin()) { 198 + $table->setSearchBaseURI($this->getApplicationURI('logs/')); 199 + } 200 + 201 + return id(new PHUIObjectBoxView()) 202 + ->setHeaderText(pht('User Activity Logs')) 203 + ->appendChild($table); 204 + } 157 205 }
+9 -2
src/applications/settings/panel/PhabricatorSettingsPanelActivity.php
··· 27 27 $viewer = $request->getUser(); 28 28 $user = $this->getUser(); 29 29 30 + $pager = id(new AphrontCursorPagerView()) 31 + ->readFromRequest($request); 32 + 30 33 $logs = id(new PhabricatorPeopleLogQuery()) 31 34 ->setViewer($viewer) 32 35 ->withRelatedPHIDs(array($user->getPHID())) 33 - ->execute(); 36 + ->executeWithCursorPager($pager); 34 37 35 38 $phids = array(); 36 39 foreach ($logs as $log) { ··· 56 59 ->setHeaderText(pht('Account Activity Logs')) 57 60 ->appendChild($table); 58 61 59 - return $panel; 62 + $pager_box = id(new PHUIBoxView()) 63 + ->addMargin(PHUI::MARGIN_LARGE) 64 + ->appendChild($pager); 65 + 66 + return array($panel, $pager_box); 60 67 } 61 68 62 69 }