Page MenuHomePhabricator

D16719.id40265.diff
No OneTemporary

D16719.id40265.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2119,8 +2119,11 @@
'PhabricatorCalendarImportIgnoredNodeLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportIgnoredNodeLogType.php',
'PhabricatorCalendarImportListController' => 'applications/calendar/controller/PhabricatorCalendarImportListController.php',
'PhabricatorCalendarImportLog' => 'applications/calendar/storage/PhabricatorCalendarImportLog.php',
+ 'PhabricatorCalendarImportLogListController' => 'applications/calendar/controller/PhabricatorCalendarImportLogListController.php',
'PhabricatorCalendarImportLogQuery' => 'applications/calendar/query/PhabricatorCalendarImportLogQuery.php',
+ 'PhabricatorCalendarImportLogSearchEngine' => 'applications/calendar/query/PhabricatorCalendarImportLogSearchEngine.php',
'PhabricatorCalendarImportLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportLogType.php',
+ 'PhabricatorCalendarImportLogView' => 'applications/calendar/view/PhabricatorCalendarImportLogView.php',
'PhabricatorCalendarImportNameTransaction' => 'applications/calendar/xaction/PhabricatorCalendarImportNameTransaction.php',
'PhabricatorCalendarImportOriginalLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportOriginalLogType.php',
'PhabricatorCalendarImportOrphanLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportOrphanLogType.php',
@@ -6952,8 +6955,11 @@
'PhabricatorPolicyInterface',
'PhabricatorDestructibleInterface',
),
+ 'PhabricatorCalendarImportLogListController' => 'PhabricatorCalendarController',
'PhabricatorCalendarImportLogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
+ 'PhabricatorCalendarImportLogSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhabricatorCalendarImportLogType' => 'Phobject',
+ 'PhabricatorCalendarImportLogView' => 'AphrontView',
'PhabricatorCalendarImportNameTransaction' => 'PhabricatorCalendarImportTransactionType',
'PhabricatorCalendarImportOriginalLogType' => 'PhabricatorCalendarImportLogType',
'PhabricatorCalendarImportOrphanLogType' => 'PhabricatorCalendarImportLogType',
diff --git a/src/applications/calendar/application/PhabricatorCalendarApplication.php b/src/applications/calendar/application/PhabricatorCalendarApplication.php
--- a/src/applications/calendar/application/PhabricatorCalendarApplication.php
+++ b/src/applications/calendar/application/PhabricatorCalendarApplication.php
@@ -83,6 +83,10 @@
=> 'PhabricatorCalendarImportViewController',
'disable/(?P<id>[1-9]\d*)/'
=> 'PhabricatorCalendarImportDisableController',
+ 'log/' => array(
+ $this->getQueryRoutePattern()
+ => 'PhabricatorCalendarImportLogListController',
+ ),
),
),
);
diff --git a/src/applications/calendar/controller/PhabricatorCalendarImportLogListController.php b/src/applications/calendar/controller/PhabricatorCalendarImportLogListController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/calendar/controller/PhabricatorCalendarImportLogListController.php
@@ -0,0 +1,12 @@
+<?php
+
+final class PhabricatorCalendarImportLogListController
+ extends PhabricatorCalendarController {
+
+ public function handleRequest(AphrontRequest $request) {
+ return id(new PhabricatorCalendarImportLogSearchEngine())
+ ->setController($this)
+ ->buildResponse();
+ }
+
+}
diff --git a/src/applications/calendar/controller/PhabricatorCalendarImportViewController.php b/src/applications/calendar/controller/PhabricatorCalendarImportViewController.php
--- a/src/applications/calendar/controller/PhabricatorCalendarImportViewController.php
+++ b/src/applications/calendar/controller/PhabricatorCalendarImportViewController.php
@@ -145,39 +145,9 @@
->setLimit(25)
->execute();
- $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(),
- 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,
- ));
+ $logs_view = id(new PhabricatorCalendarImportLogView())
+ ->setViewer($viewer)
+ ->setLogs($logs);
$all_uri = $this->getApplicationURI('import/log/');
$all_uri = (string)id(new PhutilURI($all_uri))
@@ -196,7 +166,7 @@
return id(new PHUIObjectBoxView())
->setHeader($header)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
- ->setTable($table);
+ ->setTable($logs_view);
}
private function buildImportedEvents(PhabricatorCalendarImport $import) {
diff --git a/src/applications/calendar/query/PhabricatorCalendarImportLogSearchEngine.php b/src/applications/calendar/query/PhabricatorCalendarImportLogSearchEngine.php
new file mode 100644
--- /dev/null
+++ b/src/applications/calendar/query/PhabricatorCalendarImportLogSearchEngine.php
@@ -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());
+ }
+}
diff --git a/src/applications/calendar/view/PhabricatorCalendarImportLogView.php b/src/applications/calendar/view/PhabricatorCalendarImportLogView.php
new file mode 100644
--- /dev/null
+++ b/src/applications/calendar/view/PhabricatorCalendarImportLogView.php
@@ -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;
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 6, 8:28 PM (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6737282
Default Alt Text
D16719.id40265.diff (9 KB)

Event Timeline