1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 22:10:55 +01:00

Support "parentPHIDs" and "ancestorPHIDs" as constraints in project.search API

Summary:
Ref T12074. Allows querying for project by direct parent (find only immediate children) or any ancestor (find all descendants) using the API.

There's no proper web UI for this since I'm not sure how useful it is, but you can `/project/?parent=PHID-PROJ-...` or `/project/?ancestor=...` for now. We can add UI later if/when use cases arise, but it's not immediately clear to me that this is useful to do from the web.

Test Plan:
 - From API, queried with `parentPHIDs` and `ancestorPHIDs`, finding direct children only and all descendants, respectively.
 - From web UI, fiddled with `?parent=...` and `?ancestor=...` to make sure they work too. This isn't intended to be a user-facing feature.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12074

Differential Revision: https://secure.phabricator.com/D17155
This commit is contained in:
epriestley 2017-01-08 11:51:17 -08:00
parent c0bec6c0ed
commit 9fa7355edc

View file

@ -52,6 +52,17 @@ final class PhabricatorProjectSearchEngine
->setLabel(pht('Colors')) ->setLabel(pht('Colors'))
->setKey('colors') ->setKey('colors')
->setOptions($this->getColorOptions()), ->setOptions($this->getColorOptions()),
id(new PhabricatorPHIDsSearchField())
->setLabel(pht('Parent Projects'))
->setKey('parentPHIDs')
->setAliases(array('parent', 'parents', 'parentPHID'))
->setDescription(pht('Find direct subprojects of specified parents.')),
id(new PhabricatorPHIDsSearchField())
->setLabel(pht('Ancestor Projects'))
->setKey('ancestorPHIDs')
->setAliases(array('ancestor', 'ancestors', 'ancestorPHID'))
->setDescription(
pht('Find all subprojects beneath specified ancestors.')),
); );
} }
@ -91,6 +102,14 @@ final class PhabricatorProjectSearchEngine
$query->withIsMilestone($map['isMilestone']); $query->withIsMilestone($map['isMilestone']);
} }
if ($map['parentPHIDs']) {
$query->withParentProjectPHIDs($map['parentPHIDs']);
}
if ($map['ancestorPHIDs']) {
$query->withAncestorProjectPHIDs($map['ancestorPHIDs']);
}
return $query; return $query;
} }