@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 more information (colors, members, watchers) to project.search

Summary: Fixes T6501. This adds more API information to the newish `project.search` API method.

Test Plan: Called `project.search`, used attachments.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T6501

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

+88 -1
+4
src/__phutil_library_map__.php
··· 2954 2954 'PhabricatorProjectsEditEngineExtension' => 'applications/project/engineextension/PhabricatorProjectsEditEngineExtension.php', 2955 2955 'PhabricatorProjectsEditField' => 'applications/transactions/editfield/PhabricatorProjectsEditField.php', 2956 2956 'PhabricatorProjectsFulltextEngineExtension' => 'applications/project/engineextension/PhabricatorProjectsFulltextEngineExtension.php', 2957 + 'PhabricatorProjectsMembersSearchEngineAttachment' => 'applications/project/engineextension/PhabricatorProjectsMembersSearchEngineAttachment.php', 2957 2958 'PhabricatorProjectsMembershipIndexEngineExtension' => 'applications/project/engineextension/PhabricatorProjectsMembershipIndexEngineExtension.php', 2958 2959 'PhabricatorProjectsPolicyRule' => 'applications/project/policyrule/PhabricatorProjectsPolicyRule.php', 2959 2960 'PhabricatorProjectsSearchEngineAttachment' => 'applications/project/engineextension/PhabricatorProjectsSearchEngineAttachment.php', 2960 2961 'PhabricatorProjectsSearchEngineExtension' => 'applications/project/engineextension/PhabricatorProjectsSearchEngineExtension.php', 2962 + 'PhabricatorProjectsWatchersSearchEngineAttachment' => 'applications/project/engineextension/PhabricatorProjectsWatchersSearchEngineAttachment.php', 2961 2963 'PhabricatorProtocolAdapter' => 'infrastructure/daemon/bot/adapter/PhabricatorProtocolAdapter.php', 2962 2964 'PhabricatorPygmentSetupCheck' => 'applications/config/check/PhabricatorPygmentSetupCheck.php', 2963 2965 'PhabricatorQuery' => 'infrastructure/query/PhabricatorQuery.php', ··· 7370 7372 'PhabricatorProjectsEditEngineExtension' => 'PhabricatorEditEngineExtension', 7371 7373 'PhabricatorProjectsEditField' => 'PhabricatorTokenizerEditField', 7372 7374 'PhabricatorProjectsFulltextEngineExtension' => 'PhabricatorFulltextEngineExtension', 7375 + 'PhabricatorProjectsMembersSearchEngineAttachment' => 'PhabricatorSearchEngineAttachment', 7373 7376 'PhabricatorProjectsMembershipIndexEngineExtension' => 'PhabricatorIndexEngineExtension', 7374 7377 'PhabricatorProjectsPolicyRule' => 'PhabricatorPolicyRule', 7375 7378 'PhabricatorProjectsSearchEngineAttachment' => 'PhabricatorSearchEngineAttachment', 7376 7379 'PhabricatorProjectsSearchEngineExtension' => 'PhabricatorSearchEngineExtension', 7380 + 'PhabricatorProjectsWatchersSearchEngineAttachment' => 'PhabricatorSearchEngineAttachment', 7377 7381 'PhabricatorProtocolAdapter' => 'Phobject', 7378 7382 'PhabricatorPygmentSetupCheck' => 'PhabricatorSetupCheck', 7379 7383 'PhabricatorQuery' => 'Phobject',
+31
src/applications/project/engineextension/PhabricatorProjectsMembersSearchEngineAttachment.php
··· 1 + <?php 2 + 3 + final class PhabricatorProjectsMembersSearchEngineAttachment 4 + extends PhabricatorSearchEngineAttachment { 5 + 6 + public function getAttachmentName() { 7 + return pht('Project Members'); 8 + } 9 + 10 + public function getAttachmentDescription() { 11 + return pht('Get the member list for the project.'); 12 + } 13 + 14 + public function willLoadAttachmentData($query, $spec) { 15 + $query->needMembers(true); 16 + } 17 + 18 + public function getAttachmentForObject($object, $data, $spec) { 19 + $members = array(); 20 + foreach ($object->getMemberPHIDs() as $member_phid) { 21 + $members[] = array( 22 + 'phid' => $member_phid, 23 + ); 24 + } 25 + 26 + return array( 27 + 'members' => $members, 28 + ); 29 + } 30 + 31 + }
+31
src/applications/project/engineextension/PhabricatorProjectsWatchersSearchEngineAttachment.php
··· 1 + <?php 2 + 3 + final class PhabricatorProjectsWatchersSearchEngineAttachment 4 + extends PhabricatorSearchEngineAttachment { 5 + 6 + public function getAttachmentName() { 7 + return pht('Project Watchers'); 8 + } 9 + 10 + public function getAttachmentDescription() { 11 + return pht('Get the watcher list for the project.'); 12 + } 13 + 14 + public function willLoadAttachmentData($query, $spec) { 15 + $query->needWatchers(true); 16 + } 17 + 18 + public function getAttachmentForObject($object, $data, $spec) { 19 + $watchers = array(); 20 + foreach ($object->getWatcherPHIDs() as $watcher_phid) { 21 + $watchers[] = array( 22 + 'phid' => $watcher_phid, 23 + ); 24 + } 25 + 26 + return array( 27 + 'watchers' => $watchers, 28 + ); 29 + } 30 + 31 + }
+5
src/applications/project/icon/PhabricatorProjectIconSet.php
··· 336 336 return $list; 337 337 } 338 338 339 + public static function getColorName($color_key) { 340 + $map = self::getColorMap(); 341 + return idx($map, $color_key); 342 + } 343 + 339 344 public static function getDefaultColorMap() { 340 345 return array( 341 346 array(
+17 -1
src/applications/project/storage/PhabricatorProject.php
··· 628 628 ->setKey('icon') 629 629 ->setType('map<string, wild>') 630 630 ->setDescription(pht('Information about the project icon.')), 631 + id(new PhabricatorConduitSearchFieldSpecification()) 632 + ->setKey('color') 633 + ->setType('map<string, wild>') 634 + ->setDescription(pht('Information about the project color.')), 631 635 ); 632 636 } 633 637 634 638 public function getFieldValuesForConduit() { 639 + $color_key = $this->getColor(); 640 + $color_name = PhabricatorProjectIconSet::getColorName($color_key); 641 + 635 642 return array( 636 643 'name' => $this->getName(), 637 644 'slug' => $this->getPrimarySlug(), ··· 640 647 'name' => $this->getDisplayIconName(), 641 648 'icon' => $this->getDisplayIconIcon(), 642 649 ), 650 + 'color' => array( 651 + 'key' => $color_key, 652 + 'name' => $color_name, 653 + ), 643 654 ); 644 655 } 645 656 646 657 public function getConduitSearchAttachments() { 647 - return array(); 658 + return array( 659 + id(new PhabricatorProjectsMembersSearchEngineAttachment()) 660 + ->setAttachmentKey('members'), 661 + id(new PhabricatorProjectsWatchersSearchEngineAttachment()) 662 + ->setAttachmentKey('watchers'), 663 + ); 648 664 } 649 665 650 666 }