mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Move workboard "View as Query" workflow to a separate controller
Summary: Depends on D20632. Ref T4900. As with other workflows on the board controller, this one is currently in the giant main "do everything" method. Move it to a separate controller. This makes one material improvement: previously, we built the full board and did layout on all the cards before building the query. However, we do not actually need to do this: we don't need the cards. Instead, just do layout without handing over any card PHIDs. This is slightly faster, particularly on large boards. Test Plan: - Clicked "View as Query" on a board, got a query page for the column. - Applied a custom filter, then clicked "View as Query" on a board. Got a query page merging the two filters. - Applied a custom filter, then clicked "Veiw as Query" on a board, in a subproject column. Got a query page merging the two filters, respecting the project-ness of the column. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T4900 Differential Revision: https://secure.phabricator.com/D20633
This commit is contained in:
parent
577020aea9
commit
9ea7227f0f
4 changed files with 79 additions and 42 deletions
|
@ -4198,6 +4198,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectColumnTransactionQuery' => 'applications/project/query/PhabricatorProjectColumnTransactionQuery.php',
|
||||
'PhabricatorProjectColumnTransactionType' => 'applications/project/xaction/column/PhabricatorProjectColumnTransactionType.php',
|
||||
'PhabricatorProjectColumnTriggerTransaction' => 'applications/project/xaction/column/PhabricatorProjectColumnTriggerTransaction.php',
|
||||
'PhabricatorProjectColumnViewQueryController' => 'applications/project/controller/PhabricatorProjectColumnViewQueryController.php',
|
||||
'PhabricatorProjectConfigOptions' => 'applications/project/config/PhabricatorProjectConfigOptions.php',
|
||||
'PhabricatorProjectConfiguredCustomField' => 'applications/project/customfield/PhabricatorProjectConfiguredCustomField.php',
|
||||
'PhabricatorProjectController' => 'applications/project/controller/PhabricatorProjectController.php',
|
||||
|
@ -10473,6 +10474,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectColumnTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
||||
'PhabricatorProjectColumnTransactionType' => 'PhabricatorModularTransactionType',
|
||||
'PhabricatorProjectColumnTriggerTransaction' => 'PhabricatorProjectColumnTransactionType',
|
||||
'PhabricatorProjectColumnViewQueryController' => 'PhabricatorProjectBoardController',
|
||||
'PhabricatorProjectConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
||||
'PhabricatorProjectConfiguredCustomField' => array(
|
||||
'PhabricatorProjectStandardCustomField',
|
||||
|
|
|
@ -79,6 +79,8 @@ final class PhabricatorProjectApplication extends PhabricatorApplication {
|
|||
=> 'PhabricatorProjectColumnHideController',
|
||||
'column/(?:(?P<id>\d+)/)?'
|
||||
=> 'PhabricatorProjectColumnDetailController',
|
||||
'viewquery/(?P<columnID>\d+)/'
|
||||
=> 'PhabricatorProjectColumnViewQueryController',
|
||||
'import/'
|
||||
=> 'PhabricatorProjectBoardImportController',
|
||||
'reorder/'
|
||||
|
|
|
@ -122,46 +122,6 @@ final class PhabricatorProjectBoardViewController
|
|||
->appendChild($content);
|
||||
}
|
||||
|
||||
// If the user wants to turn a particular column into a query, build an
|
||||
// apropriate filter and redirect them to the query results page.
|
||||
$query_column_id = $request->getInt('queryColumnID');
|
||||
if ($query_column_id) {
|
||||
$column_id_map = mpull($columns, null, 'getID');
|
||||
$query_column = idx($column_id_map, $query_column_id);
|
||||
if (!$query_column) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
// Create a saved query to combine the active filter on the workboard
|
||||
// with the column filter. If the user currently has constraints on the
|
||||
// board, we want to add a new column or project constraint, not
|
||||
// completely replace the constraints.
|
||||
$saved_query = $saved->newCopy();
|
||||
|
||||
if ($query_column->getProxyPHID()) {
|
||||
$project_phids = $saved_query->getParameter('projectPHIDs');
|
||||
if (!$project_phids) {
|
||||
$project_phids = array();
|
||||
}
|
||||
$project_phids[] = $query_column->getProxyPHID();
|
||||
$saved_query->setParameter('projectPHIDs', $project_phids);
|
||||
} else {
|
||||
$saved_query->setParameter(
|
||||
'columnPHIDs',
|
||||
array($query_column->getPHID()));
|
||||
}
|
||||
|
||||
$search_engine = id(new ManiphestTaskSearchEngine())
|
||||
->setViewer($viewer);
|
||||
$search_engine->saveQuery($saved_query);
|
||||
|
||||
$query_key = $saved_query->getQueryKey();
|
||||
$query_uri = new PhutilURI("/maniphest/query/{$query_key}/#R");
|
||||
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI($query_uri);
|
||||
}
|
||||
|
||||
$task_can_edit_map = id(new PhabricatorPolicyFilter())
|
||||
->setViewer($viewer)
|
||||
->requireCapabilities(array(PhabricatorPolicyCapability::CAN_EDIT))
|
||||
|
@ -1004,6 +964,7 @@ final class PhabricatorProjectBoardViewController
|
|||
|
||||
$request = $this->getRequest();
|
||||
$viewer = $request->getUser();
|
||||
$state = $this->getViewState();
|
||||
|
||||
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||
$viewer,
|
||||
|
@ -1062,8 +1023,8 @@ final class PhabricatorProjectBoardViewController
|
|||
->setHref($batch_move_uri)
|
||||
->setWorkflow(true);
|
||||
|
||||
$query_uri = $request->getRequestURI();
|
||||
$query_uri->replaceQueryParam('queryColumnID', $column->getID());
|
||||
$query_uri = urisprintf('viewquery/%d/', $column->getID());
|
||||
$query_uri = $state->newWorkboardURI($query_uri);
|
||||
|
||||
$column_items[] = id(new PhabricatorActionView())
|
||||
->setName(pht('View as Query'))
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorProjectColumnViewQueryController
|
||||
extends PhabricatorProjectBoardController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $request->getViewer();
|
||||
|
||||
$response = $this->loadProject();
|
||||
if ($response) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$project = $this->getProject();
|
||||
$state = $this->getViewState();
|
||||
$board_uri = $state->newWorkboardURI();
|
||||
|
||||
// NOTE: We're performing layout without handing the "LayoutEngine" any
|
||||
// object PHIDs. We only want to get access to the column object the user
|
||||
// is trying to query, so we do not need to actually position any cards on
|
||||
// the board.
|
||||
|
||||
$board_phid = $project->getPHID();
|
||||
|
||||
$layout_engine = id(new PhabricatorBoardLayoutEngine())
|
||||
->setViewer($viewer)
|
||||
->setBoardPHIDs(array($board_phid))
|
||||
->setFetchAllBoards(true)
|
||||
->executeLayout();
|
||||
|
||||
$columns = $layout_engine->getColumns($board_phid);
|
||||
$columns = mpull($columns, null, 'getID');
|
||||
|
||||
$column_id = $request->getURIData('columnID');
|
||||
$column = idx($columns, $column_id);
|
||||
if (!$column) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
// Create a saved query to combine the active filter on the workboard
|
||||
// with the column filter. If the user currently has constraints on the
|
||||
// board, we want to add a new column or project constraint, not
|
||||
// completely replace the constraints.
|
||||
$default_query = $state->getSavedQuery();
|
||||
$saved_query = $default_query->newCopy();
|
||||
|
||||
if ($column->getProxyPHID()) {
|
||||
$project_phids = $saved_query->getParameter('projectPHIDs');
|
||||
if (!$project_phids) {
|
||||
$project_phids = array();
|
||||
}
|
||||
$project_phids[] = $column->getProxyPHID();
|
||||
$saved_query->setParameter('projectPHIDs', $project_phids);
|
||||
} else {
|
||||
$saved_query->setParameter(
|
||||
'columnPHIDs',
|
||||
array($column->getPHID()));
|
||||
}
|
||||
|
||||
$search_engine = id(new ManiphestTaskSearchEngine())
|
||||
->setViewer($viewer);
|
||||
|
||||
$search_engine->saveQuery($saved_query);
|
||||
|
||||
$query_key = $saved_query->getQueryKey();
|
||||
$query_uri = new PhutilURI("/maniphest/query/{$query_key}/#R");
|
||||
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI($query_uri);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue