From fcaf56332fad07004132939385e09a250ff2b69a Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 23 Apr 2015 05:13:12 -0700 Subject: [PATCH] Use parameterized datasources for Maniphest authors and subscribers Summary: Ref T4100. Update these controls to allow functions like `viewer()`. Test Plan: Used the new controls. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4100 Differential Revision: https://secure.phabricator.com/D12527 --- .../query/ManiphestTaskSearchEngine.php | 19 ++++++++++++++----- .../PhabricatorProjectMembersDatasource.php | 1 + 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php index 6edf7badf6..adeced3031 100644 --- a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php +++ b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php @@ -55,7 +55,7 @@ final class ManiphestTaskSearchEngine $saved->setParameter( 'subscriberPHIDs', - $this->readPHIDsFromRequest($request, 'subscribers')); + $this->readSubscribersFromRequest($request, 'subscribers')); $saved->setParameter( 'statuses', @@ -111,12 +111,21 @@ final class ManiphestTaskSearchEngine $query = id(new ManiphestTaskQuery()) ->needProjectPHIDs(true); - $author_phids = $saved->getParameter('authorPHIDs'); + $viewer = $this->requireViewer(); + + $datasource = id(new PhabricatorTypeaheadUserParameterizedDatasource()) + ->setViewer($viewer); + + $author_phids = $saved->getParameter('authorPHIDs', array()); + $author_phids = $datasource->evaluateTokens($author_phids); if ($author_phids) { $query->withAuthors($author_phids); } - $subscriber_phids = $saved->getParameter('subscriberPHIDs'); + $datasource = id(new PhabricatorMetaMTAMailableFunctionDatasource()) + ->setViewer($viewer); + $subscriber_phids = $saved->getParameter('subscriberPHIDs', array()); + $subscriber_phids = $datasource->evaluateTokens($subscriber_phids); if ($subscriber_phids) { $query->withSubscribers($subscriber_phids); } @@ -274,13 +283,13 @@ final class ManiphestTaskSearchEngine ->setValue($projects)) ->appendControl( id(new AphrontFormTokenizerControl()) - ->setDatasource(new PhabricatorPeopleDatasource()) + ->setDatasource(new PhabricatorTypeaheadUserParameterizedDatasource()) ->setName('authors') ->setLabel(pht('Authors')) ->setValue($author_phids)) ->appendControl( id(new AphrontFormTokenizerControl()) - ->setDatasource(new PhabricatorMetaMTAMailableDatasource()) + ->setDatasource(new PhabricatorMetaMTAMailableFunctionDatasource()) ->setName('subscribers') ->setLabel(pht('Subscribers')) ->setValue($subscriber_phids)) diff --git a/src/applications/project/typeahead/PhabricatorProjectMembersDatasource.php b/src/applications/project/typeahead/PhabricatorProjectMembersDatasource.php index efeb5a423a..0b4a33f7a2 100644 --- a/src/applications/project/typeahead/PhabricatorProjectMembersDatasource.php +++ b/src/applications/project/typeahead/PhabricatorProjectMembersDatasource.php @@ -41,6 +41,7 @@ final class PhabricatorProjectMembersDatasource $result ->setTokenType(PhabricatorTypeaheadTokenView::TYPE_FUNCTION) ->setIcon('fa-users') + ->setColor(null) ->setPHID('members('.$result->getPHID().')') ->setDisplayName(pht('Members: %s', $result->getDisplayName())) ->setName($result->getName().' members');