Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13968243
D12459.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D12459.id.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -5675,7 +5675,7 @@
'PhabricatorProjectIcon' => 'Phobject',
'PhabricatorProjectListController' => 'PhabricatorProjectController',
'PhabricatorProjectMemberOfProjectEdgeType' => 'PhabricatorEdgeType',
- 'PhabricatorProjectMembersDatasource' => 'PhabricatorTypeaheadDatasource',
+ 'PhabricatorProjectMembersDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
'PhabricatorProjectMembersEditController' => 'PhabricatorProjectController',
'PhabricatorProjectMembersRemoveController' => 'PhabricatorProjectController',
'PhabricatorProjectMoveController' => 'PhabricatorProjectController',
diff --git a/src/applications/people/typeahead/PhabricatorUserProjectsDatasource.php b/src/applications/people/typeahead/PhabricatorUserProjectsDatasource.php
--- a/src/applications/people/typeahead/PhabricatorUserProjectsDatasource.php
+++ b/src/applications/people/typeahead/PhabricatorUserProjectsDatasource.php
@@ -73,6 +73,7 @@
->setValue(pht('Projects: Invalid User'));
} else {
$token
+ ->setIcon('fa-users')
->setTokenType(PhabricatorTypeaheadTokenView::TYPE_FUNCTION)
->setKey('projects('.$token->getKey().')')
->setValue(pht('Projects: %s', $token->getValue()));
diff --git a/src/applications/project/typeahead/PhabricatorProjectMembersDatasource.php b/src/applications/project/typeahead/PhabricatorProjectMembersDatasource.php
--- a/src/applications/project/typeahead/PhabricatorProjectMembersDatasource.php
+++ b/src/applications/project/typeahead/PhabricatorProjectMembersDatasource.php
@@ -1,7 +1,7 @@
<?php
final class PhabricatorProjectMembersDatasource
- extends PhabricatorTypeaheadDatasource {
+ extends PhabricatorTypeaheadCompositeDatasource {
public function getPlaceholderText() {
return pht('Type members(<project>)...');
@@ -11,40 +11,33 @@
return 'PhabricatorProjectApplication';
}
- public function loadResults() {
- $viewer = $this->getViewer();
- $raw_query = $this->getRawQuery();
-
- $pattern = $raw_query;
- if (self::isFunctionToken($raw_query)) {
- $function = $this->parseFunction($raw_query, $allow_partial = true);
- if ($function) {
- $pattern = head($function['argv']);
- }
- }
-
- // Allow users to type "#qa" or "qa" to find "Quality Assurance".
- $pattern = ltrim($pattern, '#');
- $tokens = self::tokenizeString($pattern);
+ public function getComponentDatasources() {
+ return array(
+ new PhabricatorProjectDatasource(),
+ );
+ }
- $query = $this->newQuery();
- if ($tokens) {
- $query->withNameTokens($tokens);
- }
- $projects = $this->executeQuery($query);
+ public function getDatasourceFunctions() {
+ return array(
+ 'members' => array(
+ 'name' => pht('Find results for members of a project.'),
+ ),
+ );
+ }
- $results = array();
- foreach ($projects as $project) {
- $results[] = $this->buildProjectResult($project);
+ protected function didLoadResults(array $results) {
+ foreach ($results as $result) {
+ $result
+ ->setTokenType(PhabricatorTypeaheadTokenView::TYPE_FUNCTION)
+ ->setIcon('fa-users')
+ ->setPHID('members('.$result->getPHID().')')
+ ->setDisplayName(pht('Members: %s', $result->getDisplayName()))
+ ->setName($result->getName().' members');
}
return $results;
}
- protected function canEvaluateFunction($function) {
- return ($function == 'members');
- }
-
protected function evaluateFunction($function, array $argv_list) {
$phids = array();
foreach ($argv_list as $argv) {
@@ -73,51 +66,21 @@
$phids[] = head($argv);
}
- $projects = $this->newQuery()
- ->withPHIDs($phids)
- ->execute();
- $projects = mpull($projects, null, 'getPHID');
-
- $tokens = array();
- foreach ($phids as $phid) {
- $project = idx($projects, $phid);
- if ($project) {
- $result = $this->buildProjectResult($project);
- $tokens[] = PhabricatorTypeaheadTokenView::newFromTypeaheadResult(
- $result);
+ $tokens = $this->renderTokens($phids);
+ foreach ($tokens as $token) {
+ if ($token->isInvalid()) {
+ $token
+ ->setValue(pht('Members: Invalid Project'));
} else {
- $tokens[] = $this->newInvalidToken(pht('Members: Invalid Project'));
+ $token
+ ->setIcon('fa-users')
+ ->setTokenType(PhabricatorTypeaheadTokenView::TYPE_FUNCTION)
+ ->setKey('members('.$token->getKey().')')
+ ->setValue(pht('Members: %s', $token->getValue()));
}
}
return $tokens;
}
- private function newQuery() {
- return id(new PhabricatorProjectQuery())
- ->setViewer($this->getViewer())
- ->needImages(true)
- ->needSlugs(true);
- }
-
- private function buildProjectResult(PhabricatorProject $project) {
- $closed = null;
- if ($project->isArchived()) {
- $closed = pht('Archived');
- }
-
- $all_strings = mpull($project->getSlugs(), 'getSlug');
- $all_strings[] = 'members';
- $all_strings[] = $project->getName();
- $all_strings = implode(' ', $all_strings);
-
- return $this->newFunctionResult()
- ->setName($all_strings)
- ->setDisplayName(pht('Members: %s', $project->getName()))
- ->setURI('/tag/'.$project->getPrimarySlug().'/')
- ->setPHID('members('.$project->getPHID().')')
- ->setIcon('fa-users')
- ->setClosed($closed);
- }
-
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Oct 17 2024, 7:33 PM (4 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6723158
Default Alt Text
D12459.id.diff (5 KB)
Attached To
Mode
D12459: Simplify members() datasource function
Attached
Detach File
Event Timeline
Log In to Comment