1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 09:12:41 +01:00

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
This commit is contained in:
epriestley 2016-10-18 13:21:16 -07:00
parent d8318089c8
commit 94a5a09d75
6 changed files with 187 additions and 34 deletions

View file

@ -2119,8 +2119,11 @@ phutil_register_library_map(array(
'PhabricatorCalendarImportIgnoredNodeLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportIgnoredNodeLogType.php', 'PhabricatorCalendarImportIgnoredNodeLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportIgnoredNodeLogType.php',
'PhabricatorCalendarImportListController' => 'applications/calendar/controller/PhabricatorCalendarImportListController.php', 'PhabricatorCalendarImportListController' => 'applications/calendar/controller/PhabricatorCalendarImportListController.php',
'PhabricatorCalendarImportLog' => 'applications/calendar/storage/PhabricatorCalendarImportLog.php', 'PhabricatorCalendarImportLog' => 'applications/calendar/storage/PhabricatorCalendarImportLog.php',
'PhabricatorCalendarImportLogListController' => 'applications/calendar/controller/PhabricatorCalendarImportLogListController.php',
'PhabricatorCalendarImportLogQuery' => 'applications/calendar/query/PhabricatorCalendarImportLogQuery.php', 'PhabricatorCalendarImportLogQuery' => 'applications/calendar/query/PhabricatorCalendarImportLogQuery.php',
'PhabricatorCalendarImportLogSearchEngine' => 'applications/calendar/query/PhabricatorCalendarImportLogSearchEngine.php',
'PhabricatorCalendarImportLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportLogType.php', 'PhabricatorCalendarImportLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportLogType.php',
'PhabricatorCalendarImportLogView' => 'applications/calendar/view/PhabricatorCalendarImportLogView.php',
'PhabricatorCalendarImportNameTransaction' => 'applications/calendar/xaction/PhabricatorCalendarImportNameTransaction.php', 'PhabricatorCalendarImportNameTransaction' => 'applications/calendar/xaction/PhabricatorCalendarImportNameTransaction.php',
'PhabricatorCalendarImportOriginalLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportOriginalLogType.php', 'PhabricatorCalendarImportOriginalLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportOriginalLogType.php',
'PhabricatorCalendarImportOrphanLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportOrphanLogType.php', 'PhabricatorCalendarImportOrphanLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportOrphanLogType.php',
@ -6952,8 +6955,11 @@ phutil_register_library_map(array(
'PhabricatorPolicyInterface', 'PhabricatorPolicyInterface',
'PhabricatorDestructibleInterface', 'PhabricatorDestructibleInterface',
), ),
'PhabricatorCalendarImportLogListController' => 'PhabricatorCalendarController',
'PhabricatorCalendarImportLogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorCalendarImportLogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorCalendarImportLogSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhabricatorCalendarImportLogType' => 'Phobject', 'PhabricatorCalendarImportLogType' => 'Phobject',
'PhabricatorCalendarImportLogView' => 'AphrontView',
'PhabricatorCalendarImportNameTransaction' => 'PhabricatorCalendarImportTransactionType', 'PhabricatorCalendarImportNameTransaction' => 'PhabricatorCalendarImportTransactionType',
'PhabricatorCalendarImportOriginalLogType' => 'PhabricatorCalendarImportLogType', 'PhabricatorCalendarImportOriginalLogType' => 'PhabricatorCalendarImportLogType',
'PhabricatorCalendarImportOrphanLogType' => 'PhabricatorCalendarImportLogType', 'PhabricatorCalendarImportOrphanLogType' => 'PhabricatorCalendarImportLogType',

View file

@ -83,6 +83,10 @@ final class PhabricatorCalendarApplication extends PhabricatorApplication {
=> 'PhabricatorCalendarImportViewController', => 'PhabricatorCalendarImportViewController',
'disable/(?P<id>[1-9]\d*)/' 'disable/(?P<id>[1-9]\d*)/'
=> 'PhabricatorCalendarImportDisableController', => 'PhabricatorCalendarImportDisableController',
'log/' => array(
$this->getQueryRoutePattern()
=> 'PhabricatorCalendarImportLogListController',
),
), ),
), ),
); );

View file

@ -0,0 +1,12 @@
<?php
final class PhabricatorCalendarImportLogListController
extends PhabricatorCalendarController {
public function handleRequest(AphrontRequest $request) {
return id(new PhabricatorCalendarImportLogSearchEngine())
->setController($this)
->buildResponse();
}
}

View file

@ -145,39 +145,9 @@ final class PhabricatorCalendarImportViewController
->setLimit(25) ->setLimit(25)
->execute(); ->execute();
$rows = array(); $logs_view = id(new PhabricatorCalendarImportLogView())
foreach ($logs as $log) { ->setViewer($viewer)
$icon = $log->getDisplayIcon($viewer); ->setLogs($logs);
$color = $log->getDisplayColor($viewer);
$name = $log->getDisplayType($viewer);
$description = $log->getDisplayDescription($viewer);
$rows[] = array(
$log->getID(),
id(new PHUIIconView())->setIcon($icon, $color),
$name,
$description,
phabricator_datetime($log->getDateCreated(), $viewer),
);
}
$table = id(new AphrontTableView($rows))
->setHeaders(
array(
pht('ID'),
null,
pht('Type'),
pht('Mesage'),
pht('Date'),
))
->setColumnClasses(
array(
null,
null,
'pri',
'wide',
null,
));
$all_uri = $this->getApplicationURI('import/log/'); $all_uri = $this->getApplicationURI('import/log/');
$all_uri = (string)id(new PhutilURI($all_uri)) $all_uri = (string)id(new PhutilURI($all_uri))
@ -196,7 +166,7 @@ final class PhabricatorCalendarImportViewController
return id(new PHUIObjectBoxView()) return id(new PHUIObjectBoxView())
->setHeader($header) ->setHeader($header)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setTable($table); ->setTable($logs_view);
} }
private function buildImportedEvents(PhabricatorCalendarImport $import) { private function buildImportedEvents(PhabricatorCalendarImport $import) {

View file

@ -0,0 +1,77 @@
<?php
final class PhabricatorCalendarImportLogSearchEngine
extends PhabricatorApplicationSearchEngine {
public function getResultTypeDescription() {
return pht('Calendar Import Logs');
}
public function getApplicationClassName() {
return 'PhabricatorCalendarApplication';
}
public function newQuery() {
return new PhabricatorCalendarImportLogQuery();
}
protected function buildCustomSearchFields() {
return array(
id(new PhabricatorPHIDsSearchField())
->setLabel(pht('Import Sources'))
->setKey('importSourcePHIDs')
->setAliases(array('importSourcePHID')),
);
}
protected function buildQueryFromParameters(array $map) {
$query = $this->newQuery();
if ($map['importSourcePHIDs']) {
$query->withImportPHIDs($map['importSourcePHIDs']);
}
return $query;
}
protected function getURI($path) {
return '/calendar/import/log/'.$path;
}
protected function getBuiltinQueryNames() {
$names = array(
'all' => pht('All Logs'),
);
return $names;
}
public function buildSavedQueryFromBuiltin($query_key) {
$query = $this->newSavedQuery();
$query->setQueryKey($query_key);
switch ($query_key) {
case 'all':
return $query;
}
return parent::buildSavedQueryFromBuiltin($query_key);
}
protected function renderResultList(
array $logs,
PhabricatorSavedQuery $query,
array $handles) {
assert_instances_of($logs, 'PhabricatorCalendarImportLog');
$viewer = $this->requireViewer();
$view = id(new PhabricatorCalendarImportLogView())
->setShowImportSources(true)
->setViewer($viewer)
->setLogs($logs);
return id(new PhabricatorApplicationSearchResultView())
->setTable($view->newTable());
}
}

View file

@ -0,0 +1,84 @@
<?php
final class PhabricatorCalendarImportLogView extends AphrontView {
private $logs = array();
private $showImportSources = false;
public function setLogs(array $logs) {
assert_instances_of($logs, 'PhabricatorCalendarImportLog');
$this->logs = $logs;
return $this;
}
public function getLogs() {
return $this->logs;
}
public function setShowImportSources($show_import_sources) {
$this->showImportSources = $show_import_sources;
return $this;
}
public function getShowImportSources() {
return $this->showImportSources;
}
public function render() {
return $this->newTable();
}
public function newTable() {
$viewer = $this->getViewer();
$logs = $this->getLogs();
$show_sources = $this->getShowImportSources();
$rows = array();
foreach ($logs as $log) {
$icon = $log->getDisplayIcon($viewer);
$color = $log->getDisplayColor($viewer);
$name = $log->getDisplayType($viewer);
$description = $log->getDisplayDescription($viewer);
$rows[] = array(
$log->getID(),
($show_sources
? $viewer->renderHandle($log->getImport()->getPHID())
: null),
id(new PHUIIconView())->setIcon($icon, $color),
$name,
$description,
phabricator_datetime($log->getDateCreated(), $viewer),
);
}
$table = id(new AphrontTableView($rows))
->setHeaders(
array(
pht('ID'),
pht('Source'),
null,
pht('Type'),
pht('Mesage'),
pht('Date'),
))
->setColumnVisibility(
array(
true,
$show_sources,
))
->setColumnClasses(
array(
null,
null,
null,
'pri',
'wide',
null,
));
return $table;
}
}