Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14831732
D7832.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D7832.id.diff
View Options
Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -660,8 +660,9 @@
'DrydockLocalCommandInterface' => 'applications/drydock/interface/command/DrydockLocalCommandInterface.php',
'DrydockLocalHostBlueprintImplementation' => 'applications/drydock/blueprint/DrydockLocalHostBlueprintImplementation.php',
'DrydockLog' => 'applications/drydock/storage/DrydockLog.php',
- 'DrydockLogController' => 'applications/drydock/controller/DrydockLogController.php',
+ 'DrydockLogListController' => 'applications/drydock/controller/DrydockLogListController.php',
'DrydockLogQuery' => 'applications/drydock/query/DrydockLogQuery.php',
+ 'DrydockLogSearchEngine' => 'applications/drydock/query/DrydockLogSearchEngine.php',
'DrydockManagementCloseWorkflow' => 'applications/drydock/management/DrydockManagementCloseWorkflow.php',
'DrydockManagementCreateResourceWorkflow' => 'applications/drydock/management/DrydockManagementCreateResourceWorkflow.php',
'DrydockManagementLeaseWorkflow' => 'applications/drydock/management/DrydockManagementLeaseWorkflow.php',
@@ -3073,9 +3074,18 @@
'DrydockLeaseViewController' => 'DrydockController',
'DrydockLocalCommandInterface' => 'DrydockCommandInterface',
'DrydockLocalHostBlueprintImplementation' => 'DrydockBlueprintImplementation',
- 'DrydockLog' => 'DrydockDAO',
- 'DrydockLogController' => 'DrydockController',
- 'DrydockLogQuery' => 'PhabricatorOffsetPagedQuery',
+ 'DrydockLog' =>
+ array(
+ 0 => 'DrydockDAO',
+ 1 => 'PhabricatorPolicyInterface',
+ ),
+ 'DrydockLogListController' =>
+ array(
+ 0 => 'DrydockController',
+ 1 => 'PhabricatorApplicationSearchResultsControllerInterface',
+ ),
+ 'DrydockLogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
+ 'DrydockLogSearchEngine' => 'PhabricatorApplicationSearchEngine',
'DrydockManagementCloseWorkflow' => 'DrydockManagementWorkflow',
'DrydockManagementCreateResourceWorkflow' => 'DrydockManagementWorkflow',
'DrydockManagementLeaseWorkflow' => 'DrydockManagementWorkflow',
Index: src/applications/drydock/application/PhabricatorApplicationDrydock.php
===================================================================
--- src/applications/drydock/application/PhabricatorApplicationDrydock.php
+++ src/applications/drydock/application/PhabricatorApplicationDrydock.php
@@ -50,7 +50,9 @@
'(?P<id>[1-9]\d*)/' => 'DrydockLeaseViewController',
'(?P<id>[1-9]\d*)/release/' => 'DrydockLeaseReleaseController',
),
- 'log/' => 'DrydockLogController',
+ 'log/' => array(
+ '(?:query/(?P<queryKey>[^/]+)/)?' => 'DrydockLogListController',
+ ),
),
);
}
Index: src/applications/drydock/controller/DrydockController.php
===================================================================
--- src/applications/drydock/controller/DrydockController.php
+++ src/applications/drydock/controller/DrydockController.php
@@ -18,8 +18,9 @@
->setViewer($this->getRequest()->getUser())
->addNavigationItems($nav->getMenu(), pht('Resources'));
- $nav->addLabel(pht('Logs'));
- $nav->addFilter('log', 'Logs');
+ id(new DrydockLogSearchEngine())
+ ->setViewer($this->getRequest()->getUser())
+ ->addNavigationItems($nav->getMenu(), pht('Logs'));
$nav->selectFilter($selected, 'resource');
Index: src/applications/drydock/controller/DrydockLogController.php
===================================================================
--- src/applications/drydock/controller/DrydockLogController.php
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-
-final class DrydockLogController extends DrydockController {
-
- public function processRequest() {
- $request = $this->getRequest();
- $user = $request->getUser();
-
- $nav = $this->buildSideNav('log');
-
- $query = id(new DrydockLogQuery())
- ->setViewer($user);
-
- $resource_ids = $request->getStrList('resource');
- if ($resource_ids) {
- $query->withResourceIDs($resource_ids);
- }
-
- $lease_ids = $request->getStrList('lease');
- if ($lease_ids) {
- $query->withLeaseIDs($lease_ids);
- }
-
- $pager = new AphrontPagerView();
- $pager->setPageSize(500);
- $pager->setOffset($request->getInt('offset'));
- $pager->setURI($request->getRequestURI(), 'offset');
-
- $logs = $query->executeWithOffsetPager($pager);
-
- $title = pht('Logs');
-
- $header = id(new PHUIHeaderView())
- ->setHeader($title);
-
- $table = $this->buildLogTableView($logs);
- $table->appendChild($pager);
-
- $nav->appendChild(
- array(
- $header,
- $table,
- $pager,
- ));
-
- $crumbs = $this->buildApplicationCrumbs();
- $crumbs->addTextCrumb($title, $this->getApplicationURI('/logs/'));
- $nav->setCrumbs($crumbs);
-
- return $this->buildApplicationPage(
- $nav,
- array(
- 'title' => $title,
- 'device' => true,
- ));
-
- }
-
-}
Index: src/applications/drydock/controller/DrydockLogListController.php
===================================================================
--- /dev/null
+++ src/applications/drydock/controller/DrydockLogListController.php
@@ -0,0 +1,34 @@
+<?php
+
+final class DrydockLogListController extends DrydockController
+ implements PhabricatorApplicationSearchResultsControllerInterface {
+
+ private $queryKey;
+
+ public function shouldAllowPublic() {
+ return true;
+ }
+
+ public function willProcessRequest(array $data) {
+ $this->queryKey = idx($data, 'queryKey');
+ }
+
+ public function processRequest() {
+ $request = $this->getRequest();
+ $controller = id(new PhabricatorApplicationSearchController($request))
+ ->setQueryKey($this->queryKey)
+ ->setSearchEngine(new DrydockLogSearchEngine())
+ ->setNavigation($this->buildSideNav());
+
+ return $this->delegateToController($controller);
+ }
+
+ public function renderResultsList(
+ array $logs,
+ PhabricatorSavedQuery $query) {
+ assert_instances_of($logs, 'DrydockLog');
+
+ return $this->buildLogTableView($logs);
+ }
+
+}
Index: src/applications/drydock/query/DrydockLogSearchEngine.php
===================================================================
--- /dev/null
+++ src/applications/drydock/query/DrydockLogSearchEngine.php
@@ -0,0 +1,48 @@
+<?php
+
+final class DrydockLogSearchEngine
+ extends PhabricatorApplicationSearchEngine {
+
+ public function buildSavedQueryFromRequest(AphrontRequest $request) {
+ $saved = new PhabricatorSavedQuery();
+
+ return $saved;
+ }
+
+ public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
+ $query = id(new DrydockLogQuery());
+
+ return $query;
+ }
+
+ public function buildSearchForm(
+ AphrontFormView $form,
+ PhabricatorSavedQuery $saved) {
+
+ }
+
+ protected function getURI($path) {
+ return '/drydock/log/'.$path;
+ }
+
+ public 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);
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 31, 2:53 AM (6 h, 9 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7076895
Default Alt Text
D7832.id.diff (7 KB)
Attached To
Mode
D7832: Use ApplicationSearch for DrydockLog
Attached
Detach File
Event Timeline
Log In to Comment