mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-23 15:22:41 +01:00
Introduce ManiphestTaskSearchEngine plus ManiphestTaskListControllerPro
Summary: Ref T603. Ref T2625. Cutting this over is tricky because of Maniphest's existing saved queries. Plan here is: - Build out the "pro" controller at `/maniphest/query/`. - Once it's at parity, migrate custom queries. - Nuke the old UI. This provides a minimal implementation with no filter support. Test Plan: Looked at `/maniphest/query/`, saw results technically available. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T603, T2625 Differential Revision: https://secure.phabricator.com/D6933
This commit is contained in:
parent
1f86c73428
commit
e814291526
4 changed files with 136 additions and 0 deletions
|
@ -718,6 +718,7 @@ phutil_register_library_map(array(
|
|||
'ManiphestTaskEditController' => 'applications/maniphest/controller/ManiphestTaskEditController.php',
|
||||
'ManiphestTaskExtensions' => 'applications/maniphest/extensions/ManiphestTaskExtensions.php',
|
||||
'ManiphestTaskListController' => 'applications/maniphest/controller/ManiphestTaskListController.php',
|
||||
'ManiphestTaskListControllerPro' => 'applications/maniphest/controller/ManiphestTaskListControllerPro.php',
|
||||
'ManiphestTaskListView' => 'applications/maniphest/view/ManiphestTaskListView.php',
|
||||
'ManiphestTaskMailReceiver' => 'applications/maniphest/mail/ManiphestTaskMailReceiver.php',
|
||||
'ManiphestTaskOwner' => 'applications/maniphest/constants/ManiphestTaskOwner.php',
|
||||
|
@ -725,6 +726,7 @@ phutil_register_library_map(array(
|
|||
'ManiphestTaskProject' => 'applications/maniphest/storage/ManiphestTaskProject.php',
|
||||
'ManiphestTaskProjectsView' => 'applications/maniphest/view/ManiphestTaskProjectsView.php',
|
||||
'ManiphestTaskQuery' => 'applications/maniphest/ManiphestTaskQuery.php',
|
||||
'ManiphestTaskSearchEngine' => 'applications/maniphest/query/ManiphestTaskSearchEngine.php',
|
||||
'ManiphestTaskStatus' => 'applications/maniphest/constants/ManiphestTaskStatus.php',
|
||||
'ManiphestTaskSubscriber' => 'applications/maniphest/storage/ManiphestTaskSubscriber.php',
|
||||
'ManiphestTransaction' => 'applications/maniphest/storage/ManiphestTransaction.php',
|
||||
|
@ -2786,6 +2788,11 @@ phutil_register_library_map(array(
|
|||
'ManiphestTaskDetailController' => 'ManiphestController',
|
||||
'ManiphestTaskEditController' => 'ManiphestController',
|
||||
'ManiphestTaskListController' => 'ManiphestController',
|
||||
'ManiphestTaskListControllerPro' =>
|
||||
array(
|
||||
0 => 'ManiphestController',
|
||||
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
|
||||
),
|
||||
'ManiphestTaskListView' => 'ManiphestView',
|
||||
'ManiphestTaskMailReceiver' => 'PhabricatorObjectMailReceiver',
|
||||
'ManiphestTaskOwner' => 'ManiphestConstants',
|
||||
|
@ -2793,6 +2800,7 @@ phutil_register_library_map(array(
|
|||
'ManiphestTaskProject' => 'ManiphestDAO',
|
||||
'ManiphestTaskProjectsView' => 'ManiphestView',
|
||||
'ManiphestTaskQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'ManiphestTaskSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||
'ManiphestTaskStatus' => 'ManiphestConstants',
|
||||
'ManiphestTaskSubscriber' => 'ManiphestDAO',
|
||||
'ManiphestTransaction' =>
|
||||
|
|
|
@ -50,6 +50,7 @@ final class PhabricatorApplicationManiphest extends PhabricatorApplication {
|
|||
'/T(?P<id>[1-9]\d*)' => 'ManiphestTaskDetailController',
|
||||
'/maniphest/' => array(
|
||||
'' => 'ManiphestTaskListController',
|
||||
'query/(?:(?P<queryKey>[^/]+)/)?' => 'ManiphestTaskListControllerPro',
|
||||
'view/(?P<view>\w+)/' => 'ManiphestTaskListController',
|
||||
'report/(?:(?P<view>\w+)/)?' => 'ManiphestReportController',
|
||||
'batch/' => 'ManiphestBatchEditController',
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
final class ManiphestTaskListControllerPro
|
||||
extends ManiphestController
|
||||
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 ManiphestTaskSearchEngine())
|
||||
->setNavigation($this->buildSideNavView());
|
||||
|
||||
return $this->delegateToController($controller);
|
||||
}
|
||||
|
||||
public function renderResultsList(
|
||||
array $tasks,
|
||||
PhabricatorSavedQuery $query) {
|
||||
assert_instances_of($tasks, 'ManiphestTask');
|
||||
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
|
||||
$list = new PHUIObjectItemListView();
|
||||
$list->setUser($viewer);
|
||||
foreach ($tasks as $task) {
|
||||
$item = id(new PHUIObjectItemView())
|
||||
->setObjectName('T'.$task->getID())
|
||||
->setHeader($task->getTitle())
|
||||
->setHref('/T'.$task->getID())
|
||||
->setObject($task);
|
||||
|
||||
$list->addItem($item);
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function buildSideNavView($for_app = false) {
|
||||
$user = $this->getRequest()->getUser();
|
||||
|
||||
$nav = new AphrontSideNavFilterView();
|
||||
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
|
||||
|
||||
if ($for_app) {
|
||||
$nav->addFilter('create', pht('Create Task'));
|
||||
}
|
||||
|
||||
id(new ManiphestTaskSearchEngine())
|
||||
->setViewer($user)
|
||||
->addNavigationItems($nav->getMenu());
|
||||
|
||||
$nav->selectFilter(null);
|
||||
|
||||
return $nav;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
final class ManiphestTaskSearchEngine
|
||||
extends PhabricatorApplicationSearchEngine {
|
||||
|
||||
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
||||
$saved = new PhabricatorSavedQuery();
|
||||
|
||||
return $saved;
|
||||
}
|
||||
|
||||
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
|
||||
$query = id(new ManiphestTaskQuery());
|
||||
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function buildSearchForm(
|
||||
AphrontFormView $form,
|
||||
PhabricatorSavedQuery $saved_query) {
|
||||
|
||||
}
|
||||
|
||||
protected function getURI($path) {
|
||||
return '/maniphest/'.$path;
|
||||
}
|
||||
|
||||
public function getBuiltinQueryNames() {
|
||||
$names = array();
|
||||
|
||||
if ($this->requireViewer()->isLoggedIn()) {
|
||||
$names['assigned'] = pht('Assigned');
|
||||
$names['authored'] = pht('Authored');
|
||||
}
|
||||
|
||||
$names['all'] = pht('All Tasks');
|
||||
|
||||
return $names;
|
||||
}
|
||||
|
||||
public function buildSavedQueryFromBuiltin($query_key) {
|
||||
|
||||
$query = $this->newSavedQuery();
|
||||
$query->setQueryKey($query_key);
|
||||
|
||||
switch ($query_key) {
|
||||
case 'all':
|
||||
return $query;
|
||||
case 'assigned':
|
||||
return $query;
|
||||
case 'authored':
|
||||
return $query;
|
||||
}
|
||||
|
||||
return parent::buildSavedQueryFromBuiltin($query_key);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue