mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +01:00
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
This commit is contained in:
parent
8efaaa188f
commit
9c28ae9ba7
5 changed files with 88 additions and 1 deletions
|
@ -2954,10 +2954,12 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorProjectsEditEngineExtension' => 'applications/project/engineextension/PhabricatorProjectsEditEngineExtension.php',
|
'PhabricatorProjectsEditEngineExtension' => 'applications/project/engineextension/PhabricatorProjectsEditEngineExtension.php',
|
||||||
'PhabricatorProjectsEditField' => 'applications/transactions/editfield/PhabricatorProjectsEditField.php',
|
'PhabricatorProjectsEditField' => 'applications/transactions/editfield/PhabricatorProjectsEditField.php',
|
||||||
'PhabricatorProjectsFulltextEngineExtension' => 'applications/project/engineextension/PhabricatorProjectsFulltextEngineExtension.php',
|
'PhabricatorProjectsFulltextEngineExtension' => 'applications/project/engineextension/PhabricatorProjectsFulltextEngineExtension.php',
|
||||||
|
'PhabricatorProjectsMembersSearchEngineAttachment' => 'applications/project/engineextension/PhabricatorProjectsMembersSearchEngineAttachment.php',
|
||||||
'PhabricatorProjectsMembershipIndexEngineExtension' => 'applications/project/engineextension/PhabricatorProjectsMembershipIndexEngineExtension.php',
|
'PhabricatorProjectsMembershipIndexEngineExtension' => 'applications/project/engineextension/PhabricatorProjectsMembershipIndexEngineExtension.php',
|
||||||
'PhabricatorProjectsPolicyRule' => 'applications/project/policyrule/PhabricatorProjectsPolicyRule.php',
|
'PhabricatorProjectsPolicyRule' => 'applications/project/policyrule/PhabricatorProjectsPolicyRule.php',
|
||||||
'PhabricatorProjectsSearchEngineAttachment' => 'applications/project/engineextension/PhabricatorProjectsSearchEngineAttachment.php',
|
'PhabricatorProjectsSearchEngineAttachment' => 'applications/project/engineextension/PhabricatorProjectsSearchEngineAttachment.php',
|
||||||
'PhabricatorProjectsSearchEngineExtension' => 'applications/project/engineextension/PhabricatorProjectsSearchEngineExtension.php',
|
'PhabricatorProjectsSearchEngineExtension' => 'applications/project/engineextension/PhabricatorProjectsSearchEngineExtension.php',
|
||||||
|
'PhabricatorProjectsWatchersSearchEngineAttachment' => 'applications/project/engineextension/PhabricatorProjectsWatchersSearchEngineAttachment.php',
|
||||||
'PhabricatorProtocolAdapter' => 'infrastructure/daemon/bot/adapter/PhabricatorProtocolAdapter.php',
|
'PhabricatorProtocolAdapter' => 'infrastructure/daemon/bot/adapter/PhabricatorProtocolAdapter.php',
|
||||||
'PhabricatorPygmentSetupCheck' => 'applications/config/check/PhabricatorPygmentSetupCheck.php',
|
'PhabricatorPygmentSetupCheck' => 'applications/config/check/PhabricatorPygmentSetupCheck.php',
|
||||||
'PhabricatorQuery' => 'infrastructure/query/PhabricatorQuery.php',
|
'PhabricatorQuery' => 'infrastructure/query/PhabricatorQuery.php',
|
||||||
|
@ -7370,10 +7372,12 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorProjectsEditEngineExtension' => 'PhabricatorEditEngineExtension',
|
'PhabricatorProjectsEditEngineExtension' => 'PhabricatorEditEngineExtension',
|
||||||
'PhabricatorProjectsEditField' => 'PhabricatorTokenizerEditField',
|
'PhabricatorProjectsEditField' => 'PhabricatorTokenizerEditField',
|
||||||
'PhabricatorProjectsFulltextEngineExtension' => 'PhabricatorFulltextEngineExtension',
|
'PhabricatorProjectsFulltextEngineExtension' => 'PhabricatorFulltextEngineExtension',
|
||||||
|
'PhabricatorProjectsMembersSearchEngineAttachment' => 'PhabricatorSearchEngineAttachment',
|
||||||
'PhabricatorProjectsMembershipIndexEngineExtension' => 'PhabricatorIndexEngineExtension',
|
'PhabricatorProjectsMembershipIndexEngineExtension' => 'PhabricatorIndexEngineExtension',
|
||||||
'PhabricatorProjectsPolicyRule' => 'PhabricatorPolicyRule',
|
'PhabricatorProjectsPolicyRule' => 'PhabricatorPolicyRule',
|
||||||
'PhabricatorProjectsSearchEngineAttachment' => 'PhabricatorSearchEngineAttachment',
|
'PhabricatorProjectsSearchEngineAttachment' => 'PhabricatorSearchEngineAttachment',
|
||||||
'PhabricatorProjectsSearchEngineExtension' => 'PhabricatorSearchEngineExtension',
|
'PhabricatorProjectsSearchEngineExtension' => 'PhabricatorSearchEngineExtension',
|
||||||
|
'PhabricatorProjectsWatchersSearchEngineAttachment' => 'PhabricatorSearchEngineAttachment',
|
||||||
'PhabricatorProtocolAdapter' => 'Phobject',
|
'PhabricatorProtocolAdapter' => 'Phobject',
|
||||||
'PhabricatorPygmentSetupCheck' => 'PhabricatorSetupCheck',
|
'PhabricatorPygmentSetupCheck' => 'PhabricatorSetupCheck',
|
||||||
'PhabricatorQuery' => 'Phobject',
|
'PhabricatorQuery' => 'Phobject',
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorProjectsMembersSearchEngineAttachment
|
||||||
|
extends PhabricatorSearchEngineAttachment {
|
||||||
|
|
||||||
|
public function getAttachmentName() {
|
||||||
|
return pht('Project Members');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttachmentDescription() {
|
||||||
|
return pht('Get the member list for the project.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function willLoadAttachmentData($query, $spec) {
|
||||||
|
$query->needMembers(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttachmentForObject($object, $data, $spec) {
|
||||||
|
$members = array();
|
||||||
|
foreach ($object->getMemberPHIDs() as $member_phid) {
|
||||||
|
$members[] = array(
|
||||||
|
'phid' => $member_phid,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'members' => $members,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorProjectsWatchersSearchEngineAttachment
|
||||||
|
extends PhabricatorSearchEngineAttachment {
|
||||||
|
|
||||||
|
public function getAttachmentName() {
|
||||||
|
return pht('Project Watchers');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttachmentDescription() {
|
||||||
|
return pht('Get the watcher list for the project.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function willLoadAttachmentData($query, $spec) {
|
||||||
|
$query->needWatchers(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttachmentForObject($object, $data, $spec) {
|
||||||
|
$watchers = array();
|
||||||
|
foreach ($object->getWatcherPHIDs() as $watcher_phid) {
|
||||||
|
$watchers[] = array(
|
||||||
|
'phid' => $watcher_phid,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'watchers' => $watchers,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -336,6 +336,11 @@ final class PhabricatorProjectIconSet
|
||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getColorName($color_key) {
|
||||||
|
$map = self::getColorMap();
|
||||||
|
return idx($map, $color_key);
|
||||||
|
}
|
||||||
|
|
||||||
public static function getDefaultColorMap() {
|
public static function getDefaultColorMap() {
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -628,10 +628,17 @@ final class PhabricatorProject extends PhabricatorProjectDAO
|
||||||
->setKey('icon')
|
->setKey('icon')
|
||||||
->setType('map<string, wild>')
|
->setType('map<string, wild>')
|
||||||
->setDescription(pht('Information about the project icon.')),
|
->setDescription(pht('Information about the project icon.')),
|
||||||
|
id(new PhabricatorConduitSearchFieldSpecification())
|
||||||
|
->setKey('color')
|
||||||
|
->setType('map<string, wild>')
|
||||||
|
->setDescription(pht('Information about the project color.')),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldValuesForConduit() {
|
public function getFieldValuesForConduit() {
|
||||||
|
$color_key = $this->getColor();
|
||||||
|
$color_name = PhabricatorProjectIconSet::getColorName($color_key);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'name' => $this->getName(),
|
'name' => $this->getName(),
|
||||||
'slug' => $this->getPrimarySlug(),
|
'slug' => $this->getPrimarySlug(),
|
||||||
|
@ -640,11 +647,20 @@ final class PhabricatorProject extends PhabricatorProjectDAO
|
||||||
'name' => $this->getDisplayIconName(),
|
'name' => $this->getDisplayIconName(),
|
||||||
'icon' => $this->getDisplayIconIcon(),
|
'icon' => $this->getDisplayIconIcon(),
|
||||||
),
|
),
|
||||||
|
'color' => array(
|
||||||
|
'key' => $color_key,
|
||||||
|
'name' => $color_name,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getConduitSearchAttachments() {
|
public function getConduitSearchAttachments() {
|
||||||
return array();
|
return array(
|
||||||
|
id(new PhabricatorProjectsMembersSearchEngineAttachment())
|
||||||
|
->setAttachmentKey('members'),
|
||||||
|
id(new PhabricatorProjectsWatchersSearchEngineAttachment())
|
||||||
|
->setAttachmentKey('watchers'),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue