diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index e1bd18076b..d4be5274a2 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1768,6 +1768,7 @@ phutil_register_library_map(array( 'PhabricatorMailReceiverTestCase' => 'applications/metamta/receiver/__tests__/PhabricatorMailReceiverTestCase.php', 'PhabricatorMailReplyHandler' => 'applications/metamta/replyhandler/PhabricatorMailReplyHandler.php', 'PhabricatorMailgunConfigOptions' => 'applications/config/option/PhabricatorMailgunConfigOptions.php', + 'PhabricatorMailingListDatasource' => 'applications/mailinglists/typeahead/PhabricatorMailingListDatasource.php', 'PhabricatorMailingListPHIDTypeList' => 'applications/mailinglists/phid/PhabricatorMailingListPHIDTypeList.php', 'PhabricatorMailingListQuery' => 'applications/mailinglists/query/PhabricatorMailingListQuery.php', 'PhabricatorMailingListSearchEngine' => 'applications/mailinglists/query/PhabricatorMailingListSearchEngine.php', @@ -1800,6 +1801,7 @@ phutil_register_library_map(array( 'PhabricatorMetaMTAMailBody' => 'applications/metamta/view/PhabricatorMetaMTAMailBody.php', 'PhabricatorMetaMTAMailBodyTestCase' => 'applications/metamta/view/__tests__/PhabricatorMetaMTAMailBodyTestCase.php', 'PhabricatorMetaMTAMailTestCase' => 'applications/metamta/storage/__tests__/PhabricatorMetaMTAMailTestCase.php', + 'PhabricatorMetaMTAMailableDatasource' => 'applications/metamta/typeahead/PhabricatorMetaMTAMailableDatasource.php', 'PhabricatorMetaMTAMailgunReceiveController' => 'applications/metamta/controller/PhabricatorMetaMTAMailgunReceiveController.php', 'PhabricatorMetaMTAMailingList' => 'applications/mailinglists/storage/PhabricatorMetaMTAMailingList.php', 'PhabricatorMetaMTAMemberQuery' => 'applications/metamta/query/PhabricatorMetaMTAMemberQuery.php', @@ -4567,6 +4569,7 @@ phutil_register_library_map(array( 'PhabricatorMailManagementWorkflow' => 'PhabricatorManagementWorkflow', 'PhabricatorMailReceiverTestCase' => 'PhabricatorTestCase', 'PhabricatorMailgunConfigOptions' => 'PhabricatorApplicationConfigOptions', + 'PhabricatorMailingListDatasource' => 'PhabricatorTypeaheadDatasource', 'PhabricatorMailingListPHIDTypeList' => 'PhabricatorPHIDType', 'PhabricatorMailingListQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorMailingListSearchEngine' => 'PhabricatorApplicationSearchEngine', @@ -4593,6 +4596,7 @@ phutil_register_library_map(array( 'PhabricatorMetaMTAMail' => 'PhabricatorMetaMTADAO', 'PhabricatorMetaMTAMailBodyTestCase' => 'PhabricatorTestCase', 'PhabricatorMetaMTAMailTestCase' => 'PhabricatorTestCase', + 'PhabricatorMetaMTAMailableDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 'PhabricatorMetaMTAMailgunReceiveController' => 'PhabricatorMetaMTAController', 'PhabricatorMetaMTAMailingList' => array( 0 => 'PhabricatorMetaMTADAO', diff --git a/src/applications/differential/customfield/DifferentialSubscribersField.php b/src/applications/differential/customfield/DifferentialSubscribersField.php index 4d2a9f016a..eba9a62025 100644 --- a/src/applications/differential/customfield/DifferentialSubscribersField.php +++ b/src/applications/differential/customfield/DifferentialSubscribersField.php @@ -44,7 +44,7 @@ final class DifferentialSubscribersField public function renderEditControl(array $handles) { return id(new AphrontFormTokenizerControl()) ->setName($this->getFieldKey()) - ->setDatasource('/typeahead/common/mailable/') + ->setDatasource(new PhabricatorMetaMTAMailableDatasource()) ->setValue($handles) ->setError($this->getFieldError()) ->setLabel($this->getFieldName()); diff --git a/src/applications/differential/query/DifferentialRevisionSearchEngine.php b/src/applications/differential/query/DifferentialRevisionSearchEngine.php index 7a26ee13a9..51ef4791ac 100644 --- a/src/applications/differential/query/DifferentialRevisionSearchEngine.php +++ b/src/applications/differential/query/DifferentialRevisionSearchEngine.php @@ -161,7 +161,7 @@ final class DifferentialRevisionSearchEngine id(new AphrontFormTokenizerControl()) ->setLabel(pht('Subscribers')) ->setName('subscribers') - ->setDatasource('/typeahead/common/allmailable/') + ->setDatasource(new PhabricatorMetaMTAMailableDatasource()) ->setValue(array_select_keys($handles, $subscriber_phids))) ->appendChild( id(new AphrontFormTokenizerControl()) diff --git a/src/applications/differential/view/DifferentialAddCommentView.php b/src/applications/differential/view/DifferentialAddCommentView.php index 9ccd73971c..48b70d6c99 100644 --- a/src/applications/differential/view/DifferentialAddCommentView.php +++ b/src/applications/differential/view/DifferentialAddCommentView.php @@ -108,6 +108,8 @@ final class DifferentialAddCommentView extends AphrontView { id(new AphrontFormSubmitControl()) ->setValue(pht('Submit'))); + $mailable_source = new PhabricatorMetaMTAMailableDatasource(); + Javelin::initBehavior( 'differential-add-reviewers-and-ccs', array( @@ -126,10 +128,10 @@ final class DifferentialAddCommentView extends AphrontView { ), 'add-ccs-tokenizer' => array( 'actions' => array('add_ccs' => 1), - 'src' => '/typeahead/common/mailable/', + 'src' => $mailable_source->getDatasourceURI(), 'value' => $this->ccs, 'row' => 'add-ccs', - 'placeholder' => pht('Type a user or mailing list...'), + 'placeholder' => $mailable_source->getPlaceholderText(), ), ), 'select' => 'comment-action', diff --git a/src/applications/diffusion/controller/DiffusionCommitController.php b/src/applications/diffusion/controller/DiffusionCommitController.php index 6716f0e033..3e672c19f7 100644 --- a/src/applications/diffusion/controller/DiffusionCommitController.php +++ b/src/applications/diffusion/controller/DiffusionCommitController.php @@ -771,6 +771,8 @@ final class DiffusionCommitController extends DiffusionController { require_celerity_resource('phabricator-transaction-view-css'); + $mailable_source = new PhabricatorMetaMTAMailableDatasource(); + Javelin::initBehavior( 'differential-add-reviewers-and-ccs', array( @@ -783,9 +785,9 @@ final class DiffusionCommitController extends DiffusionController { ), 'add-ccs-tokenizer' => array( 'actions' => array('add_ccs' => 1), - 'src' => '/typeahead/common/mailable/', + 'src' => $mailable_source->getDatasourceURI(), 'row' => 'add-ccs', - 'placeholder' => pht('Type a user or mailing list...'), + 'placeholder' => $mailable_source->getPlaceholderText(), ), ), 'select' => 'audit-action', diff --git a/src/applications/herald/controller/HeraldRuleController.php b/src/applications/herald/controller/HeraldRuleController.php index b660618a0e..b31329a09e 100644 --- a/src/applications/herald/controller/HeraldRuleController.php +++ b/src/applications/herald/controller/HeraldRuleController.php @@ -597,11 +597,11 @@ final class HeraldRuleController extends HeraldController { 'package' => new PhabricatorOwnersPackageDatasource(), 'project' => new PhabricatorProjectDatasource(), 'user' => new PhabricatorPeopleDatasource(), + 'email' => new PhabricatorMetaMTAMailableDatasource(), ); $sources = mpull($sources, 'getDatasourceURI'); $sources += array( - 'email' => '/typeahead/common/mailable/', 'userorproject' => '/typeahead/common/accountsorprojects/', ); diff --git a/src/applications/mailinglists/typeahead/PhabricatorMailingListDatasource.php b/src/applications/mailinglists/typeahead/PhabricatorMailingListDatasource.php new file mode 100644 index 0000000000..48f5b83da7 --- /dev/null +++ b/src/applications/mailinglists/typeahead/PhabricatorMailingListDatasource.php @@ -0,0 +1,33 @@ +getViewer(); + $raw_query = $this->getRawQuery(); + + $results = array(); + + $lists = id(new PhabricatorMailingListQuery()) + ->setViewer($viewer) + ->execute(); + foreach ($lists as $list) { + $results[] = id(new PhabricatorTypeaheadResult()) + ->setName($list->getName()) + ->setURI($list->getURI()) + ->setPHID($list->getPHID()); + } + + return $results; + } + +} diff --git a/src/applications/maniphest/controller/ManiphestBatchEditController.php b/src/applications/maniphest/controller/ManiphestBatchEditController.php index 5dfaba42f3..59f361931a 100644 --- a/src/applications/maniphest/controller/ManiphestBatchEditController.php +++ b/src/applications/maniphest/controller/ManiphestBatchEditController.php @@ -62,6 +62,7 @@ final class ManiphestBatchEditController extends ManiphestController { $template = $template->render(); $projects_source = new PhabricatorProjectDatasource(); + $mailable_source = new PhabricatorMetaMTAMailableDatasource(); require_celerity_resource('maniphest-batch-editor'); Javelin::initBehavior( @@ -81,8 +82,8 @@ final class ManiphestBatchEditController extends ManiphestController { 'limit' => 1, ), 'cc' => array( - 'src' => '/typeahead/common/mailable/', - 'placeholder' => pht('Type a user name...'), + 'src' => $mailable_source->getDatasourceURI(), + 'placeholder' => $mailable_source->getPlaceholderText(), ) ), 'input' => 'batch-form-actions', diff --git a/src/applications/maniphest/controller/ManiphestTaskDetailController.php b/src/applications/maniphest/controller/ManiphestTaskDetailController.php index de6e767dfe..60a8fe5e7c 100644 --- a/src/applications/maniphest/controller/ManiphestTaskDetailController.php +++ b/src/applications/maniphest/controller/ManiphestTaskDetailController.php @@ -284,6 +284,7 @@ final class ManiphestTaskDetailController extends ManiphestController { $projects_source = new PhabricatorProjectDatasource(); $users_source = new PhabricatorPeopleDatasource(); + $mailable_source = new PhabricatorMetaMTAMailableDatasource(); $tokenizer_map = array( ManiphestTransaction::TYPE_PROJECTS => array( @@ -300,8 +301,8 @@ final class ManiphestTaskDetailController extends ManiphestController { ), ManiphestTransaction::TYPE_CCS => array( 'id' => 'cc-tokenizer', - 'src' => '/typeahead/common/mailable/', - 'placeholder' => pht('Type a user or mailing list...'), + 'src' => $mailable_source->getDatasourceURI(), + 'placeholder' => $mailable_source->getPlaceholderText(), ), ); diff --git a/src/applications/maniphest/controller/ManiphestTaskEditController.php b/src/applications/maniphest/controller/ManiphestTaskEditController.php index e08b675e52..b8bf1a7017 100644 --- a/src/applications/maniphest/controller/ManiphestTaskEditController.php +++ b/src/applications/maniphest/controller/ManiphestTaskEditController.php @@ -613,7 +613,7 @@ final class ManiphestTaskEditController extends ManiphestController { ->setName('cc') ->setValue($cc_value) ->setUser($user) - ->setDatasource('/typeahead/common/mailable/')); + ->setDatasource(new PhabricatorMetaMTAMailableDatasource())); if ($can_edit_priority) { $form diff --git a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php index 0acaba4374..8079a45380 100644 --- a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php +++ b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php @@ -365,7 +365,7 @@ final class ManiphestTaskSearchEngine ->setValue($author_handles)) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/mailable/') + ->setDatasource(new PhabricatorMetaMTAMailableDatasource()) ->setName('subscribers') ->setLabel(pht('Subscribers')) ->setValue($subscriber_handles)) diff --git a/src/applications/metamta/typeahead/PhabricatorMetaMTAMailableDatasource.php b/src/applications/metamta/typeahead/PhabricatorMetaMTAMailableDatasource.php new file mode 100644 index 0000000000..0a6b5ea0b4 --- /dev/null +++ b/src/applications/metamta/typeahead/PhabricatorMetaMTAMailableDatasource.php @@ -0,0 +1,22 @@ +setName('cc') ->setValue($handles) ->setUser($user) - ->setDatasource('/typeahead/common/mailable/')) + ->setDatasource(new PhabricatorMetaMTAMailableDatasource())) ->appendChild( id(new AphrontFormPolicyControl()) ->setUser($user) diff --git a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php index 7a52bbb3a6..ccf19e23a5 100644 --- a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php +++ b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php @@ -24,7 +24,6 @@ final class PhabricatorTypeaheadCommonDatasourceController $need_users = false; $need_agents = false; $need_applications = false; - $need_lists = false; $need_projs = false; $need_packages = false; $need_upforgrabs = false; @@ -48,12 +47,6 @@ final class PhabricatorTypeaheadCommonDatasourceController $need_projs = true; $need_noproject = true; break; - case 'mailable': - case 'allmailable': - $need_users = true; - $need_lists = true; - $need_projs = true; - break; case 'usersorprojects': case 'accountsorprojects': $need_users = true; @@ -179,18 +172,6 @@ final class PhabricatorTypeaheadCommonDatasourceController } } - if ($need_lists) { - $lists = id(new PhabricatorMailingListQuery()) - ->setViewer($viewer) - ->execute(); - foreach ($lists as $list) { - $results[] = id(new PhabricatorTypeaheadResult()) - ->setName($list->getName()) - ->setURI($list->getURI()) - ->setPHID($list->getPHID()); - } - } - if ($need_projs) { $projs = id(new PhabricatorProjectQuery()) ->setViewer($viewer) diff --git a/src/view/form/control/AphrontFormTokenizerControl.php b/src/view/form/control/AphrontFormTokenizerControl.php index ff82986a99..31d683db83 100644 --- a/src/view/form/control/AphrontFormTokenizerControl.php +++ b/src/view/form/control/AphrontFormTokenizerControl.php @@ -95,19 +95,9 @@ final class AphrontFormTokenizerControl extends AphrontFormControl { $request = $matches[1]; $map = array( - 'users' => pht('Type a user name...'), - 'authors' => pht('Type a user name...'), 'usersorprojects' => pht('Type a user or project name...'), 'searchowner' => pht('Type a user name...'), - 'accounts' => pht('Type a user name...'), - 'mailable' => pht('Type a user, project, or mailing list...'), - 'allmailable' => pht('Type a user, project, or mailing list...'), 'searchproject' => pht('Type a project name...'), - 'projects' => pht('Type a project name...'), - 'repositories' => pht('Type a repository name...'), - 'packages' => pht('Type a package name...'), - 'macros' => pht('Type a macro name...'), - 'arcanistproject' => pht('Type an arc project name...'), 'accountsorprojects' => pht('Type a user or project name...'), 'usersprojectsorpackages' => pht('Type a user, project, or package name...'),