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

Add a SearchEngine for Calendar import logs

Summary:
Ref T10747.

- Look at more than 25 logs!
- Review your favorite logs. Heartwarming! :)

Test Plan: Looked at logs. Wow! Logs!

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10747

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

+187 -34
+6
src/__phutil_library_map__.php
··· 2119 2119 'PhabricatorCalendarImportIgnoredNodeLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportIgnoredNodeLogType.php', 2120 2120 'PhabricatorCalendarImportListController' => 'applications/calendar/controller/PhabricatorCalendarImportListController.php', 2121 2121 'PhabricatorCalendarImportLog' => 'applications/calendar/storage/PhabricatorCalendarImportLog.php', 2122 + 'PhabricatorCalendarImportLogListController' => 'applications/calendar/controller/PhabricatorCalendarImportLogListController.php', 2122 2123 'PhabricatorCalendarImportLogQuery' => 'applications/calendar/query/PhabricatorCalendarImportLogQuery.php', 2124 + 'PhabricatorCalendarImportLogSearchEngine' => 'applications/calendar/query/PhabricatorCalendarImportLogSearchEngine.php', 2123 2125 'PhabricatorCalendarImportLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportLogType.php', 2126 + 'PhabricatorCalendarImportLogView' => 'applications/calendar/view/PhabricatorCalendarImportLogView.php', 2124 2127 'PhabricatorCalendarImportNameTransaction' => 'applications/calendar/xaction/PhabricatorCalendarImportNameTransaction.php', 2125 2128 'PhabricatorCalendarImportOriginalLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportOriginalLogType.php', 2126 2129 'PhabricatorCalendarImportOrphanLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportOrphanLogType.php', ··· 6952 6955 'PhabricatorPolicyInterface', 6953 6956 'PhabricatorDestructibleInterface', 6954 6957 ), 6958 + 'PhabricatorCalendarImportLogListController' => 'PhabricatorCalendarController', 6955 6959 'PhabricatorCalendarImportLogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 6960 + 'PhabricatorCalendarImportLogSearchEngine' => 'PhabricatorApplicationSearchEngine', 6956 6961 'PhabricatorCalendarImportLogType' => 'Phobject', 6962 + 'PhabricatorCalendarImportLogView' => 'AphrontView', 6957 6963 'PhabricatorCalendarImportNameTransaction' => 'PhabricatorCalendarImportTransactionType', 6958 6964 'PhabricatorCalendarImportOriginalLogType' => 'PhabricatorCalendarImportLogType', 6959 6965 'PhabricatorCalendarImportOrphanLogType' => 'PhabricatorCalendarImportLogType',
+4
src/applications/calendar/application/PhabricatorCalendarApplication.php
··· 83 83 => 'PhabricatorCalendarImportViewController', 84 84 'disable/(?P<id>[1-9]\d*)/' 85 85 => 'PhabricatorCalendarImportDisableController', 86 + 'log/' => array( 87 + $this->getQueryRoutePattern() 88 + => 'PhabricatorCalendarImportLogListController', 89 + ), 86 90 ), 87 91 ), 88 92 );
+12
src/applications/calendar/controller/PhabricatorCalendarImportLogListController.php
··· 1 + <?php 2 + 3 + final class PhabricatorCalendarImportLogListController 4 + extends PhabricatorCalendarController { 5 + 6 + public function handleRequest(AphrontRequest $request) { 7 + return id(new PhabricatorCalendarImportLogSearchEngine()) 8 + ->setController($this) 9 + ->buildResponse(); 10 + } 11 + 12 + }
+4 -34
src/applications/calendar/controller/PhabricatorCalendarImportViewController.php
··· 145 145 ->setLimit(25) 146 146 ->execute(); 147 147 148 - $rows = array(); 149 - foreach ($logs as $log) { 150 - $icon = $log->getDisplayIcon($viewer); 151 - $color = $log->getDisplayColor($viewer); 152 - $name = $log->getDisplayType($viewer); 153 - $description = $log->getDisplayDescription($viewer); 154 - 155 - $rows[] = array( 156 - $log->getID(), 157 - id(new PHUIIconView())->setIcon($icon, $color), 158 - $name, 159 - $description, 160 - phabricator_datetime($log->getDateCreated(), $viewer), 161 - ); 162 - } 163 - 164 - $table = id(new AphrontTableView($rows)) 165 - ->setHeaders( 166 - array( 167 - pht('ID'), 168 - null, 169 - pht('Type'), 170 - pht('Mesage'), 171 - pht('Date'), 172 - )) 173 - ->setColumnClasses( 174 - array( 175 - null, 176 - null, 177 - 'pri', 178 - 'wide', 179 - null, 180 - )); 148 + $logs_view = id(new PhabricatorCalendarImportLogView()) 149 + ->setViewer($viewer) 150 + ->setLogs($logs); 181 151 182 152 $all_uri = $this->getApplicationURI('import/log/'); 183 153 $all_uri = (string)id(new PhutilURI($all_uri)) ··· 196 166 return id(new PHUIObjectBoxView()) 197 167 ->setHeader($header) 198 168 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 199 - ->setTable($table); 169 + ->setTable($logs_view); 200 170 } 201 171 202 172 private function buildImportedEvents(PhabricatorCalendarImport $import) {
+77
src/applications/calendar/query/PhabricatorCalendarImportLogSearchEngine.php
··· 1 + <?php 2 + 3 + final class PhabricatorCalendarImportLogSearchEngine 4 + extends PhabricatorApplicationSearchEngine { 5 + 6 + public function getResultTypeDescription() { 7 + return pht('Calendar Import Logs'); 8 + } 9 + 10 + public function getApplicationClassName() { 11 + return 'PhabricatorCalendarApplication'; 12 + } 13 + 14 + public function newQuery() { 15 + return new PhabricatorCalendarImportLogQuery(); 16 + } 17 + 18 + protected function buildCustomSearchFields() { 19 + return array( 20 + id(new PhabricatorPHIDsSearchField()) 21 + ->setLabel(pht('Import Sources')) 22 + ->setKey('importSourcePHIDs') 23 + ->setAliases(array('importSourcePHID')), 24 + ); 25 + } 26 + 27 + protected function buildQueryFromParameters(array $map) { 28 + $query = $this->newQuery(); 29 + 30 + if ($map['importSourcePHIDs']) { 31 + $query->withImportPHIDs($map['importSourcePHIDs']); 32 + } 33 + 34 + return $query; 35 + } 36 + 37 + protected function getURI($path) { 38 + return '/calendar/import/log/'.$path; 39 + } 40 + 41 + protected function getBuiltinQueryNames() { 42 + $names = array( 43 + 'all' => pht('All Logs'), 44 + ); 45 + 46 + return $names; 47 + } 48 + 49 + public function buildSavedQueryFromBuiltin($query_key) { 50 + $query = $this->newSavedQuery(); 51 + $query->setQueryKey($query_key); 52 + 53 + switch ($query_key) { 54 + case 'all': 55 + return $query; 56 + } 57 + 58 + return parent::buildSavedQueryFromBuiltin($query_key); 59 + } 60 + 61 + protected function renderResultList( 62 + array $logs, 63 + PhabricatorSavedQuery $query, 64 + array $handles) { 65 + 66 + assert_instances_of($logs, 'PhabricatorCalendarImportLog'); 67 + $viewer = $this->requireViewer(); 68 + 69 + $view = id(new PhabricatorCalendarImportLogView()) 70 + ->setShowImportSources(true) 71 + ->setViewer($viewer) 72 + ->setLogs($logs); 73 + 74 + return id(new PhabricatorApplicationSearchResultView()) 75 + ->setTable($view->newTable()); 76 + } 77 + }
+84
src/applications/calendar/view/PhabricatorCalendarImportLogView.php
··· 1 + <?php 2 + 3 + final class PhabricatorCalendarImportLogView extends AphrontView { 4 + 5 + private $logs = array(); 6 + private $showImportSources = false; 7 + 8 + public function setLogs(array $logs) { 9 + assert_instances_of($logs, 'PhabricatorCalendarImportLog'); 10 + $this->logs = $logs; 11 + return $this; 12 + } 13 + 14 + public function getLogs() { 15 + return $this->logs; 16 + } 17 + 18 + public function setShowImportSources($show_import_sources) { 19 + $this->showImportSources = $show_import_sources; 20 + return $this; 21 + } 22 + 23 + public function getShowImportSources() { 24 + return $this->showImportSources; 25 + } 26 + 27 + public function render() { 28 + return $this->newTable(); 29 + } 30 + 31 + public function newTable() { 32 + $viewer = $this->getViewer(); 33 + $logs = $this->getLogs(); 34 + 35 + $show_sources = $this->getShowImportSources(); 36 + 37 + $rows = array(); 38 + foreach ($logs as $log) { 39 + $icon = $log->getDisplayIcon($viewer); 40 + $color = $log->getDisplayColor($viewer); 41 + $name = $log->getDisplayType($viewer); 42 + $description = $log->getDisplayDescription($viewer); 43 + 44 + $rows[] = array( 45 + $log->getID(), 46 + ($show_sources 47 + ? $viewer->renderHandle($log->getImport()->getPHID()) 48 + : null), 49 + id(new PHUIIconView())->setIcon($icon, $color), 50 + $name, 51 + $description, 52 + phabricator_datetime($log->getDateCreated(), $viewer), 53 + ); 54 + } 55 + 56 + $table = id(new AphrontTableView($rows)) 57 + ->setHeaders( 58 + array( 59 + pht('ID'), 60 + pht('Source'), 61 + null, 62 + pht('Type'), 63 + pht('Mesage'), 64 + pht('Date'), 65 + )) 66 + ->setColumnVisibility( 67 + array( 68 + true, 69 + $show_sources, 70 + )) 71 + ->setColumnClasses( 72 + array( 73 + null, 74 + null, 75 + null, 76 + 'pri', 77 + 'wide', 78 + null, 79 + )); 80 + 81 + return $table; 82 + } 83 + 84 + }