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

Add "parent" and "ancestor" information to the project.search API

Summary:
Ref T12074.

- Adds a new "parent" property on main results. This shows an abbreviated version of the project's parent, or `null` if the project is a root project.
- Adds a new "ancestor" attachment to pull the entire ancestor list.
- Adds a new "depth" property on main results.
- You can use "parent" or "depth" to tell if a project is a subproject or not.

These attempt to balance convenience, power, and performance: the full ancestor list can be big so I made it an attachment, but the other stuff isn't too big and is cheap and seems reasonable to always include.

Test Plan:
In API results:

- Saw null parent (root projects) and non-null parent (subprojects/milestones).
- Used "ancestors" attchment, got full list of ancestors.
- Saw appropriate "depth" values.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12074

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

+69
+2
src/__phutil_library_map__.php
··· 3514 3514 'PhabricatorProjectWatcherListView' => 'applications/project/view/PhabricatorProjectWatcherListView.php', 3515 3515 'PhabricatorProjectWorkboardBackgroundColor' => 'applications/project/constants/PhabricatorProjectWorkboardBackgroundColor.php', 3516 3516 'PhabricatorProjectWorkboardProfileMenuItem' => 'applications/project/menuitem/PhabricatorProjectWorkboardProfileMenuItem.php', 3517 + 'PhabricatorProjectsAncestorsSearchEngineAttachment' => 'applications/project/engineextension/PhabricatorProjectsAncestorsSearchEngineAttachment.php', 3517 3518 'PhabricatorProjectsCurtainExtension' => 'applications/project/engineextension/PhabricatorProjectsCurtainExtension.php', 3518 3519 'PhabricatorProjectsEditEngineExtension' => 'applications/project/engineextension/PhabricatorProjectsEditEngineExtension.php', 3519 3520 'PhabricatorProjectsEditField' => 'applications/transactions/editfield/PhabricatorProjectsEditField.php', ··· 8666 8667 'PhabricatorProjectWatcherListView' => 'PhabricatorProjectUserListView', 8667 8668 'PhabricatorProjectWorkboardBackgroundColor' => 'Phobject', 8668 8669 'PhabricatorProjectWorkboardProfileMenuItem' => 'PhabricatorProfileMenuItem', 8670 + 'PhabricatorProjectsAncestorsSearchEngineAttachment' => 'PhabricatorSearchEngineAttachment', 8669 8671 'PhabricatorProjectsCurtainExtension' => 'PHUICurtainExtension', 8670 8672 'PhabricatorProjectsEditEngineExtension' => 'PhabricatorEditEngineExtension', 8671 8673 'PhabricatorProjectsEditField' => 'PhabricatorTokenizerEditField',
+30
src/applications/project/engineextension/PhabricatorProjectsAncestorsSearchEngineAttachment.php
··· 1 + <?php 2 + 3 + final class PhabricatorProjectsAncestorsSearchEngineAttachment 4 + extends PhabricatorSearchEngineAttachment { 5 + 6 + public function getAttachmentName() { 7 + return pht('Project Ancestors'); 8 + } 9 + 10 + public function getAttachmentDescription() { 11 + return pht('Get the full ancestor list for each project.'); 12 + } 13 + 14 + public function getAttachmentForObject($object, $data, $spec) { 15 + $ancestors = $object->getAncestorProjects(); 16 + 17 + // Order ancestors by depth, ascending. 18 + $ancestors = array_reverse($ancestors); 19 + 20 + $results = array(); 21 + foreach ($ancestors as $ancestor) { 22 + $results[] = $ancestor->getRefForConduit(); 23 + } 24 + 25 + return array( 26 + 'ancestors' => $results, 27 + ); 28 + } 29 + 30 + }
+37
src/applications/project/storage/PhabricatorProject.php
··· 746 746 ->setType('int?') 747 747 ->setDescription(pht('For milestones, milestone sequence number.')), 748 748 id(new PhabricatorConduitSearchFieldSpecification()) 749 + ->setKey('parent') 750 + ->setType('map<string, wild>?') 751 + ->setDescription( 752 + pht( 753 + 'For subprojects and milestones, a brief description of the '. 754 + 'parent project.')), 755 + id(new PhabricatorConduitSearchFieldSpecification()) 756 + ->setKey('depth') 757 + ->setType('int') 758 + ->setDescription( 759 + pht( 760 + 'For subprojects and milestones, depth of this project in the '. 761 + 'tree. Root projects have depth 0.')), 762 + id(new PhabricatorConduitSearchFieldSpecification()) 749 763 ->setKey('icon') 750 764 ->setType('map<string, wild>') 751 765 ->setDescription(pht('Information about the project icon.')), ··· 766 780 $milestone = null; 767 781 } 768 782 783 + $parent = $this->getParentProject(); 784 + if ($parent) { 785 + $parent_ref = $parent->getRefForConduit(); 786 + } else { 787 + $parent_ref = null; 788 + } 789 + 769 790 return array( 770 791 'name' => $this->getName(), 771 792 'slug' => $this->getPrimarySlug(), 772 793 'milestone' => $milestone, 794 + 'depth' => (int)$this->getProjectDepth(), 795 + 'parent' => $parent_ref, 773 796 'icon' => array( 774 797 'key' => $this->getDisplayIconKey(), 775 798 'name' => $this->getDisplayIconName(), ··· 788 811 ->setAttachmentKey('members'), 789 812 id(new PhabricatorProjectsWatchersSearchEngineAttachment()) 790 813 ->setAttachmentKey('watchers'), 814 + id(new PhabricatorProjectsAncestorsSearchEngineAttachment()) 815 + ->setAttachmentKey('ancestors'), 816 + ); 817 + } 818 + 819 + /** 820 + * Get an abbreviated representation of this project for use in providing 821 + * "parent" and "ancestor" information. 822 + */ 823 + public function getRefForConduit() { 824 + return array( 825 + 'id' => (int)$this->getID(), 826 + 'phid' => $this->getPHID(), 827 + 'name' => $this->getName(), 791 828 ); 792 829 } 793 830