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

Make search select fields usable over Conduit

Summary:
Previously, search select fields (@{class:PhabricatorSearchSelectField}) did
not support conduit queries, as they had no `newConduitParameterType` method.
Now they do. This takes a very simple approach and treats them similarly to how
@{class:PhabricatorSearchCheckboxesField} works.

Only these applications use search select fields presently:

- Calendar
- Dashboard
- Macro
- Maniphest
- Project
- Repository

Of those, only the following expose modern application search methods:

- Calendar
- Maniphest
- Project
- Repository

Calendar and Repository work without changes.

For Maniphest, `group` now works a bit better by including the project PHID grouped-by in the results, when grouping by project.

For Project, the status field has been lightly refactored to use constants for
consistency, and especially now the project status is included in the conduit
results.

Test Plan:
### Projects

1. attempt to use status field to query projects before this diff: get query error.
2. apply this diff.
3. attempt to use status field again: see that filtering works, and project
results include their status.

### Maniphest

1. do maniphest queries in the UI before this diff: see that grouping works.
2. look at the conduit page [[ /conduit/method/maniphest.search/ ]], see `group`.
3. Observe that `group` throws an error if you attempt to use it.
4. apply this diff.
5. return to the conduit page and find that using `group` no longer errors.
6. do more maniphest queries in the UI and see that grouping still works.

Reviewers: O1 Blessed Committers, aklapper

Reviewed By: O1 Blessed Committers, aklapper

Subscribers: aklapper, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D26166

amy bones 40aa5162 041899ff

+50 -7
+6
src/applications/maniphest/storage/ManiphestTask.php
··· 494 494 $closed_epoch = (int)$closed_epoch; 495 495 } 496 496 497 + $group_by_phid = $this->groupByProjectPHID; 498 + if ($group_by_phid === self::ATTACHABLE) { 499 + $group_by_phid = null; 500 + } 501 + 497 502 return array( 498 503 'name' => $this->getTitle(), 499 504 'description' => array( ··· 507 512 'subtype' => $this->getSubtype(), 508 513 'closerPHID' => $this->getCloserPHID(), 509 514 'dateClosed' => $closed_epoch, 515 + 'groupByProjectPHID' => $group_by_phid, 510 516 ); 511 517 } 512 518
+13
src/applications/project/constants/PhabricatorProjectStatus.php
··· 5 5 const STATUS_ACTIVE = 0; 6 6 const STATUS_ARCHIVED = 100; 7 7 8 + const STATUS_ACTIVE_KEY = 'active'; 9 + const STATUS_ARCHIVED_KEY = 'archived'; 10 + 8 11 public static function getNameForStatus($status) { 9 12 $map = array( 10 13 self::STATUS_ACTIVE => pht('Active'), ··· 21 24 ); 22 25 } 23 26 27 + public static function getStatusKeys() { 28 + return array( 29 + self::STATUS_ACTIVE_KEY => self::STATUS_ACTIVE, 30 + self::STATUS_ARCHIVED_KEY => self::STATUS_ARCHIVED, 31 + ); 32 + } 33 + 34 + public static function getKeyForStatus(int $status) { 35 + return array_flip(self::getStatusKeys())[$status]; 36 + } 24 37 }
+15 -7
src/applications/project/query/PhabricatorProjectSearchEngine.php
··· 247 247 // By default, do not show milestones in the list view. 248 248 $query->setParameter('isMilestone', false); 249 249 250 + $active = PhabricatorProjectStatus::STATUS_ACTIVE_KEY; 251 + 250 252 switch ($query_key) { 251 253 case 'all': 252 254 return $query; 253 255 case 'active': 254 256 return $query 255 - ->setParameter('status', 'active'); 257 + ->setParameter('status', $active); 256 258 case 'joined': 257 259 return $query 258 260 ->setParameter('memberPHIDs', array($viewer_phid)) 259 - ->setParameter('status', 'active'); 261 + ->setParameter('status', $active); 260 262 case 'watching': 261 263 return $query 262 264 ->setParameter('watcherPHIDs', array($viewer_phid)) 263 - ->setParameter('status', 'active'); 265 + ->setParameter('status', $active); 264 266 } 265 267 266 268 return parent::buildSavedQueryFromBuiltin($query_key); 267 269 } 268 270 269 271 private function getStatusOptions() { 272 + $active = PhabricatorProjectStatus::STATUS_ACTIVE_KEY; 273 + $archived = PhabricatorProjectStatus::STATUS_ARCHIVED_KEY; 274 + 270 275 return array( 271 - 'active' => pht('Show Only Active Projects'), 272 - 'archived' => pht('Show Only Archived Projects'), 276 + $active => pht('Show Only Active Projects'), 277 + $archived => pht('Show Only Archived Projects'), 273 278 'all' => pht('Show All Projects'), 274 279 ); 275 280 } 276 281 277 282 private function getStatusValues() { 283 + $active = PhabricatorProjectStatus::STATUS_ACTIVE_KEY; 284 + $archived = PhabricatorProjectStatus::STATUS_ARCHIVED_KEY; 285 + 278 286 return array( 279 - 'active' => PhabricatorProjectQuery::STATUS_ACTIVE, 280 - 'archived' => PhabricatorProjectQuery::STATUS_ARCHIVED, 287 + $active => PhabricatorProjectQuery::STATUS_ACTIVE, 288 + $archived => PhabricatorProjectQuery::STATUS_ARCHIVED, 281 289 'all' => PhabricatorProjectQuery::STATUS_ANY, 282 290 ); 283 291 }
+1
src/applications/project/storage/PhabricatorProject.php
··· 930 930 'key' => $color_key, 931 931 'name' => $color_name, 932 932 ), 933 + 'status' => PhabricatorProjectStatus::getKeyForStatus($this->getStatus()), 933 934 ); 934 935 } 935 936
+15
src/applications/search/field/PhabricatorSearchSelectField.php
··· 33 33 ->setOptions($this->getOptions()); 34 34 } 35 35 36 + protected function newConduitParameterType() { 37 + return new ConduitStringParameterType(); 38 + } 39 + 40 + public function newConduitConstants() { 41 + $list = array(); 42 + 43 + foreach ($this->getOptions() as $key => $option) { 44 + $list[] = id(new ConduitConstantDescription()) 45 + ->setKey($key) 46 + ->setValue($option); 47 + } 48 + 49 + return $list; 50 + } 36 51 }