From ca5a2641a6d754b2cbbc5b673d32a6016de9775a Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:45:07 -0700 Subject: [PATCH] Modernize "user or project" typeahead datasources Summary: Ref T4420. These are used for some stuff like "reviewer". Test Plan: - Edited "reviewers" in differential edit. - Edited "reviewers" in differential search. - Edited "reviewers" in Differential "add reviewers..." action on detail page. - Edited a "reviewers" field in a herald rule. - Edited "owner" in owners search. - Edited "primary owner", "owners" on owners edit. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4420 Differential Revision: https://secure.phabricator.com/D9887 --- src/__phutil_library_map__.php | 2 ++ .../customfield/DifferentialReviewersField.php | 2 +- .../query/DifferentialRevisionSearchEngine.php | 2 +- .../view/DifferentialAddCommentView.php | 5 +++-- .../herald/controller/HeraldRuleController.php | 4 +--- .../PhabricatorOwnersEditController.php | 4 ++-- .../PhabricatorOwnersListController.php | 2 +- .../PhabricatorProjectOrUserDatasource.php | 17 +++++++++++++++++ ...catorTypeaheadCommonDatasourceController.php | 5 ----- .../control/AphrontFormTokenizerControl.php | 2 -- 10 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 src/applications/project/typeahead/PhabricatorProjectOrUserDatasource.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index d4be5274a2..23efd54c85 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2011,6 +2011,7 @@ phutil_register_library_map(array( 'PhabricatorProjectMoveController' => 'applications/project/controller/PhabricatorProjectMoveController.php', 'PhabricatorProjectNameCollisionException' => 'applications/project/exception/PhabricatorProjectNameCollisionException.php', 'PhabricatorProjectObjectHasProjectEdgeType' => 'applications/project/edge/PhabricatorProjectObjectHasProjectEdgeType.php', + 'PhabricatorProjectOrUserDatasource' => 'applications/project/typeahead/PhabricatorProjectOrUserDatasource.php', 'PhabricatorProjectPHIDTypeColumn' => 'applications/project/phid/PhabricatorProjectPHIDTypeColumn.php', 'PhabricatorProjectPHIDTypeProject' => 'applications/project/phid/PhabricatorProjectPHIDTypeProject.php', 'PhabricatorProjectProfileController' => 'applications/project/controller/PhabricatorProjectProfileController.php', @@ -4827,6 +4828,7 @@ phutil_register_library_map(array( 'PhabricatorProjectMoveController' => 'PhabricatorProjectController', 'PhabricatorProjectNameCollisionException' => 'Exception', 'PhabricatorProjectObjectHasProjectEdgeType' => 'PhabricatorEdgeType', + 'PhabricatorProjectOrUserDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 'PhabricatorProjectPHIDTypeColumn' => 'PhabricatorPHIDType', 'PhabricatorProjectPHIDTypeProject' => 'PhabricatorPHIDType', 'PhabricatorProjectProfileController' => 'PhabricatorProjectController', diff --git a/src/applications/differential/customfield/DifferentialReviewersField.php b/src/applications/differential/customfield/DifferentialReviewersField.php index 5ff0a2f9f2..d3f24b7d3a 100644 --- a/src/applications/differential/customfield/DifferentialReviewersField.php +++ b/src/applications/differential/customfield/DifferentialReviewersField.php @@ -69,7 +69,7 @@ final class DifferentialReviewersField public function renderEditControl(array $handles) { return id(new AphrontFormTokenizerControl()) ->setName($this->getFieldKey()) - ->setDatasource('/typeahead/common/usersorprojects/') + ->setDatasource(new PhabricatorProjectOrUserDatasource()) ->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 51ef4791ac..f47665fc85 100644 --- a/src/applications/differential/query/DifferentialRevisionSearchEngine.php +++ b/src/applications/differential/query/DifferentialRevisionSearchEngine.php @@ -155,7 +155,7 @@ final class DifferentialRevisionSearchEngine id(new AphrontFormTokenizerControl()) ->setLabel(pht('Reviewers')) ->setName('reviewers') - ->setDatasource('/typeahead/common/accountsorprojects/') + ->setDatasource(new PhabricatorProjectOrUserDatasource()) ->setValue(array_select_keys($handles, $reviewer_phids))) ->appendChild( id(new AphrontFormTokenizerControl()) diff --git a/src/applications/differential/view/DifferentialAddCommentView.php b/src/applications/differential/view/DifferentialAddCommentView.php index 48b70d6c99..acb657bd2e 100644 --- a/src/applications/differential/view/DifferentialAddCommentView.php +++ b/src/applications/differential/view/DifferentialAddCommentView.php @@ -109,6 +109,7 @@ final class DifferentialAddCommentView extends AphrontView { ->setValue(pht('Submit'))); $mailable_source = new PhabricatorMetaMTAMailableDatasource(); + $reviewer_source = new PhabricatorProjectOrUserDatasource(); Javelin::initBehavior( 'differential-add-reviewers-and-ccs', @@ -120,11 +121,11 @@ final class DifferentialAddCommentView extends AphrontView { 'add_reviewers' => 1, 'resign' => 1, ), - 'src' => '/typeahead/common/usersorprojects/', + 'src' => $reviewer_source->getDatasourceURI(), 'value' => $this->reviewers, 'row' => 'add-reviewers', 'labels' => $add_reviewers_labels, - 'placeholder' => pht('Type a user or project name...'), + 'placeholder' => $reviewer_source->getPlaceholderText(), ), 'add-ccs-tokenizer' => array( 'actions' => array('add_ccs' => 1), diff --git a/src/applications/herald/controller/HeraldRuleController.php b/src/applications/herald/controller/HeraldRuleController.php index b31329a09e..75a5c297e2 100644 --- a/src/applications/herald/controller/HeraldRuleController.php +++ b/src/applications/herald/controller/HeraldRuleController.php @@ -598,12 +598,10 @@ final class HeraldRuleController extends HeraldController { 'project' => new PhabricatorProjectDatasource(), 'user' => new PhabricatorPeopleDatasource(), 'email' => new PhabricatorMetaMTAMailableDatasource(), + 'userorproject' => new PhabricatorProjectOrUserDatasource(), ); $sources = mpull($sources, 'getDatasourceURI'); - $sources += array( - 'userorproject' => '/typeahead/common/accountsorprojects/', - ); return array( 'source' => $sources, diff --git a/src/applications/owners/controller/PhabricatorOwnersEditController.php b/src/applications/owners/controller/PhabricatorOwnersEditController.php index f35a9f5edc..aface6a277 100644 --- a/src/applications/owners/controller/PhabricatorOwnersEditController.php +++ b/src/applications/owners/controller/PhabricatorOwnersEditController.php @@ -181,7 +181,7 @@ final class PhabricatorOwnersEditController ->setError($e_name)) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/usersorprojects/') + ->setDatasource(new PhabricatorProjectOrUserDatasource()) ->setLabel(pht('Primary Owner')) ->setName('primary') ->setLimit(1) @@ -189,7 +189,7 @@ final class PhabricatorOwnersEditController ->setError($e_primary)) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/usersorprojects/') + ->setDatasource(new PhabricatorProjectOrUserDatasource()) ->setLabel(pht('Owners')) ->setName('owners') ->setValue($handles_all_owners)) diff --git a/src/applications/owners/controller/PhabricatorOwnersListController.php b/src/applications/owners/controller/PhabricatorOwnersListController.php index a861a9e933..6f35bef0a5 100644 --- a/src/applications/owners/controller/PhabricatorOwnersListController.php +++ b/src/applications/owners/controller/PhabricatorOwnersListController.php @@ -177,7 +177,7 @@ final class PhabricatorOwnersListController ->setValue($request->getStr('name'))) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/usersorprojects/') + ->setDatasource(new PhabricatorProjectOrUserDatasource()) ->setLimit(1) ->setName('owner') ->setLabel(pht('Owner')) diff --git a/src/applications/project/typeahead/PhabricatorProjectOrUserDatasource.php b/src/applications/project/typeahead/PhabricatorProjectOrUserDatasource.php new file mode 100644 index 0000000000..2024fa3b8b --- /dev/null +++ b/src/applications/project/typeahead/PhabricatorProjectOrUserDatasource.php @@ -0,0 +1,17 @@ + pht('Type a user or project name...'), 'searchowner' => pht('Type a user name...'), 'searchproject' => pht('Type a project name...'), - 'accountsorprojects' => pht('Type a user or project name...'), 'usersprojectsorpackages' => pht('Type a user, project, or package name...'), );