@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+79 -42
+2
src/__phutil_library_map__.php
··· 4198 4198 'PhabricatorProjectColumnTransactionQuery' => 'applications/project/query/PhabricatorProjectColumnTransactionQuery.php', 4199 4199 'PhabricatorProjectColumnTransactionType' => 'applications/project/xaction/column/PhabricatorProjectColumnTransactionType.php', 4200 4200 'PhabricatorProjectColumnTriggerTransaction' => 'applications/project/xaction/column/PhabricatorProjectColumnTriggerTransaction.php', 4201 + 'PhabricatorProjectColumnViewQueryController' => 'applications/project/controller/PhabricatorProjectColumnViewQueryController.php', 4201 4202 'PhabricatorProjectConfigOptions' => 'applications/project/config/PhabricatorProjectConfigOptions.php', 4202 4203 'PhabricatorProjectConfiguredCustomField' => 'applications/project/customfield/PhabricatorProjectConfiguredCustomField.php', 4203 4204 'PhabricatorProjectController' => 'applications/project/controller/PhabricatorProjectController.php', ··· 10473 10474 'PhabricatorProjectColumnTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 10474 10475 'PhabricatorProjectColumnTransactionType' => 'PhabricatorModularTransactionType', 10475 10476 'PhabricatorProjectColumnTriggerTransaction' => 'PhabricatorProjectColumnTransactionType', 10477 + 'PhabricatorProjectColumnViewQueryController' => 'PhabricatorProjectBoardController', 10476 10478 'PhabricatorProjectConfigOptions' => 'PhabricatorApplicationConfigOptions', 10477 10479 'PhabricatorProjectConfiguredCustomField' => array( 10478 10480 'PhabricatorProjectStandardCustomField',
+2
src/applications/project/application/PhabricatorProjectApplication.php
··· 79 79 => 'PhabricatorProjectColumnHideController', 80 80 'column/(?:(?P<id>\d+)/)?' 81 81 => 'PhabricatorProjectColumnDetailController', 82 + 'viewquery/(?P<columnID>\d+)/' 83 + => 'PhabricatorProjectColumnViewQueryController', 82 84 'import/' 83 85 => 'PhabricatorProjectBoardImportController', 84 86 'reorder/'
+3 -42
src/applications/project/controller/PhabricatorProjectBoardViewController.php
··· 122 122 ->appendChild($content); 123 123 } 124 124 125 - // If the user wants to turn a particular column into a query, build an 126 - // apropriate filter and redirect them to the query results page. 127 - $query_column_id = $request->getInt('queryColumnID'); 128 - if ($query_column_id) { 129 - $column_id_map = mpull($columns, null, 'getID'); 130 - $query_column = idx($column_id_map, $query_column_id); 131 - if (!$query_column) { 132 - return new Aphront404Response(); 133 - } 134 - 135 - // Create a saved query to combine the active filter on the workboard 136 - // with the column filter. If the user currently has constraints on the 137 - // board, we want to add a new column or project constraint, not 138 - // completely replace the constraints. 139 - $saved_query = $saved->newCopy(); 140 - 141 - if ($query_column->getProxyPHID()) { 142 - $project_phids = $saved_query->getParameter('projectPHIDs'); 143 - if (!$project_phids) { 144 - $project_phids = array(); 145 - } 146 - $project_phids[] = $query_column->getProxyPHID(); 147 - $saved_query->setParameter('projectPHIDs', $project_phids); 148 - } else { 149 - $saved_query->setParameter( 150 - 'columnPHIDs', 151 - array($query_column->getPHID())); 152 - } 153 - 154 - $search_engine = id(new ManiphestTaskSearchEngine()) 155 - ->setViewer($viewer); 156 - $search_engine->saveQuery($saved_query); 157 - 158 - $query_key = $saved_query->getQueryKey(); 159 - $query_uri = new PhutilURI("/maniphest/query/{$query_key}/#R"); 160 - 161 - return id(new AphrontRedirectResponse()) 162 - ->setURI($query_uri); 163 - } 164 - 165 125 $task_can_edit_map = id(new PhabricatorPolicyFilter()) 166 126 ->setViewer($viewer) 167 127 ->requireCapabilities(array(PhabricatorPolicyCapability::CAN_EDIT)) ··· 1004 964 1005 965 $request = $this->getRequest(); 1006 966 $viewer = $request->getUser(); 967 + $state = $this->getViewState(); 1007 968 1008 969 $can_edit = PhabricatorPolicyFilter::hasCapability( 1009 970 $viewer, ··· 1062 1023 ->setHref($batch_move_uri) 1063 1024 ->setWorkflow(true); 1064 1025 1065 - $query_uri = $request->getRequestURI(); 1066 - $query_uri->replaceQueryParam('queryColumnID', $column->getID()); 1026 + $query_uri = urisprintf('viewquery/%d/', $column->getID()); 1027 + $query_uri = $state->newWorkboardURI($query_uri); 1067 1028 1068 1029 $column_items[] = id(new PhabricatorActionView()) 1069 1030 ->setName(pht('View as Query'))
+72
src/applications/project/controller/PhabricatorProjectColumnViewQueryController.php
··· 1 + <?php 2 + 3 + final class PhabricatorProjectColumnViewQueryController 4 + extends PhabricatorProjectBoardController { 5 + 6 + public function handleRequest(AphrontRequest $request) { 7 + $viewer = $request->getViewer(); 8 + 9 + $response = $this->loadProject(); 10 + if ($response) { 11 + return $response; 12 + } 13 + 14 + $project = $this->getProject(); 15 + $state = $this->getViewState(); 16 + $board_uri = $state->newWorkboardURI(); 17 + 18 + // NOTE: We're performing layout without handing the "LayoutEngine" any 19 + // object PHIDs. We only want to get access to the column object the user 20 + // is trying to query, so we do not need to actually position any cards on 21 + // the board. 22 + 23 + $board_phid = $project->getPHID(); 24 + 25 + $layout_engine = id(new PhabricatorBoardLayoutEngine()) 26 + ->setViewer($viewer) 27 + ->setBoardPHIDs(array($board_phid)) 28 + ->setFetchAllBoards(true) 29 + ->executeLayout(); 30 + 31 + $columns = $layout_engine->getColumns($board_phid); 32 + $columns = mpull($columns, null, 'getID'); 33 + 34 + $column_id = $request->getURIData('columnID'); 35 + $column = idx($columns, $column_id); 36 + if (!$column) { 37 + return new Aphront404Response(); 38 + } 39 + 40 + // Create a saved query to combine the active filter on the workboard 41 + // with the column filter. If the user currently has constraints on the 42 + // board, we want to add a new column or project constraint, not 43 + // completely replace the constraints. 44 + $default_query = $state->getSavedQuery(); 45 + $saved_query = $default_query->newCopy(); 46 + 47 + if ($column->getProxyPHID()) { 48 + $project_phids = $saved_query->getParameter('projectPHIDs'); 49 + if (!$project_phids) { 50 + $project_phids = array(); 51 + } 52 + $project_phids[] = $column->getProxyPHID(); 53 + $saved_query->setParameter('projectPHIDs', $project_phids); 54 + } else { 55 + $saved_query->setParameter( 56 + 'columnPHIDs', 57 + array($column->getPHID())); 58 + } 59 + 60 + $search_engine = id(new ManiphestTaskSearchEngine()) 61 + ->setViewer($viewer); 62 + 63 + $search_engine->saveQuery($saved_query); 64 + 65 + $query_key = $saved_query->getQueryKey(); 66 + $query_uri = new PhutilURI("/maniphest/query/{$query_key}/#R"); 67 + 68 + return id(new AphrontRedirectResponse()) 69 + ->setURI($query_uri); 70 + } 71 + 72 + }