@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.

Support querying projects by "Root Projects" in the UI, and "min/max depth" in the API

Summary:
Fixes T13441. Internally, projects can be queried by depth, but this is not exposed in the UI.

Add a "Is root project?" contraint in the UI, and "minDepth" / "maxDepth" constraints to the API.

Test Plan:
- Used the UI to query root projects, got only root projects back.
- Used "project.search" in the API to query combinations of root projects and projects at particular depths, got matching results.

Maniphest Tasks: T13441

Differential Revision: https://secure.phabricator.com/D20886

+89
+2
src/__phutil_library_map__.php
··· 4652 4652 'PhabricatorSearchHovercardController' => 'applications/search/controller/PhabricatorSearchHovercardController.php', 4653 4653 'PhabricatorSearchIndexVersion' => 'applications/search/storage/PhabricatorSearchIndexVersion.php', 4654 4654 'PhabricatorSearchIndexVersionDestructionEngineExtension' => 'applications/search/engineextension/PhabricatorSearchIndexVersionDestructionEngineExtension.php', 4655 + 'PhabricatorSearchIntField' => 'applications/search/field/PhabricatorSearchIntField.php', 4655 4656 'PhabricatorSearchManagementIndexWorkflow' => 'applications/search/management/PhabricatorSearchManagementIndexWorkflow.php', 4656 4657 'PhabricatorSearchManagementInitWorkflow' => 'applications/search/management/PhabricatorSearchManagementInitWorkflow.php', 4657 4658 'PhabricatorSearchManagementNgramsWorkflow' => 'applications/search/management/PhabricatorSearchManagementNgramsWorkflow.php', ··· 11273 11274 'PhabricatorSearchHovercardController' => 'PhabricatorSearchBaseController', 11274 11275 'PhabricatorSearchIndexVersion' => 'PhabricatorSearchDAO', 11275 11276 'PhabricatorSearchIndexVersionDestructionEngineExtension' => 'PhabricatorDestructionEngineExtension', 11277 + 'PhabricatorSearchIntField' => 'PhabricatorSearchField', 11276 11278 'PhabricatorSearchManagementIndexWorkflow' => 'PhabricatorSearchManagementWorkflow', 11277 11279 'PhabricatorSearchManagementInitWorkflow' => 'PhabricatorSearchManagementWorkflow', 11278 11280 'PhabricatorSearchManagementNgramsWorkflow' => 'PhabricatorSearchManagementWorkflow',
+65
src/applications/project/query/PhabricatorProjectSearchEngine.php
··· 65 65 pht( 66 66 'Pass true to find only milestones, or false to omit '. 67 67 'milestones.')), 68 + id(new PhabricatorSearchThreeStateField()) 69 + ->setLabel(pht('Root Projects')) 70 + ->setKey('isRoot') 71 + ->setOptions( 72 + pht('(Show All)'), 73 + pht('Show Only Root Projects'), 74 + pht('Hide Root Projects')) 75 + ->setDescription( 76 + pht( 77 + 'Pass true to find only root projects, or false to omit '. 78 + 'root projects.')), 79 + id(new PhabricatorSearchIntField()) 80 + ->setLabel(pht('Minimum Depth')) 81 + ->setKey('minDepth') 82 + ->setIsHidden(true) 83 + ->setDescription( 84 + pht( 85 + 'Find projects with a given minimum depth. Root projects '. 86 + 'have depth 0, their immediate children have depth 1, and '. 87 + 'so on.')), 88 + id(new PhabricatorSearchIntField()) 89 + ->setLabel(pht('Maximum Depth')) 90 + ->setKey('maxDepth') 91 + ->setIsHidden(true) 92 + ->setDescription( 93 + pht( 94 + 'Find projects with a given maximum depth. Root projects '. 95 + 'have depth 0, their immediate children have depth 1, and '. 96 + 'so on.')), 68 97 id(new PhabricatorSearchDatasourceField()) 69 98 ->setLabel(pht('Subtypes')) 70 99 ->setKey('subtypes') ··· 135 164 136 165 if ($map['isMilestone'] !== null) { 137 166 $query->withIsMilestone($map['isMilestone']); 167 + } 168 + 169 + $min_depth = $map['minDepth']; 170 + $max_depth = $map['maxDepth']; 171 + 172 + if ($min_depth !== null || $max_depth !== null) { 173 + if ($min_depth !== null && $max_depth !== null) { 174 + if ($min_depth > $max_depth) { 175 + throw new Exception( 176 + pht( 177 + 'Search constraint "minDepth" must be no larger than '. 178 + 'search constraint "maxDepth".')); 179 + } 180 + } 181 + } 182 + 183 + if ($map['isRoot'] !== null) { 184 + if ($map['isRoot']) { 185 + if ($max_depth === null) { 186 + $max_depth = 0; 187 + } else { 188 + $max_depth = min(0, $max_depth); 189 + } 190 + 191 + $query->withDepthBetween(null, 0); 192 + } else { 193 + if ($min_depth === null) { 194 + $min_depth = 1; 195 + } else { 196 + $min_depth = max($min_depth, 1); 197 + } 198 + } 199 + } 200 + 201 + if ($min_depth !== null || $max_depth !== null) { 202 + $query->withDepthBetween($min_depth, $max_depth); 138 203 } 139 204 140 205 if ($map['parentPHIDs']) {
+22
src/applications/search/field/PhabricatorSearchIntField.php
··· 1 + <?php 2 + 3 + final class PhabricatorSearchIntField 4 + extends PhabricatorSearchField { 5 + 6 + protected function getDefaultValue() { 7 + return null; 8 + } 9 + 10 + protected function getValueFromRequest(AphrontRequest $request, $key) { 11 + return $request->getInt($key); 12 + } 13 + 14 + protected function newControl() { 15 + return new AphrontFormTextControl(); 16 + } 17 + 18 + protected function newConduitParameterType() { 19 + return new ConduitIntParameterType(); 20 + } 21 + 22 + }