From dcc69977932be59194f8358aafe8fe4c5571c132 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:44:18 -0700 Subject: [PATCH] Modernize "users" typeahead datasource Summary: Ref T4420. Modernize users. Test Plan: - Edited "Commit Authors" on Audit search. - Edited "Created By" on calendar search. - Edited "invited" on calendar search. - Edited "To" on "New conpherence message". - Edited user on "Add user to conpherence thread". - Edited "Authors" on countdown search. - Edited "Author" on differential search. - Edited "Responsible users" on differential search. - Edited "Owner" on Diffusion lint search. - Edited "include users" on Feed search. - Edited "Authors" on file search. - Edited "Authors" on Herald rule search. - Edited a couple of user-selecting Herald fields on rules. - Edited "user" on legalpad signature exemption. - Edited "creator" on legalpad search. - Edited "contributors" on legalpad search. - Edited "signers" on legalpad signature search. - Edited "Authors" on macro search. - Edited "Reassign/claim" on task detail. - Edited "assigned to" on task edit. - Edited "assigned to", "users projects", "authors" on task search. - Edited "creators" on oauthserver. - Edited "authors" on paste search. - Edited "actors" and "users" on activity log search. - Edited "authors" on pholio search. - Edited "users" on phrequent search. - Edited "authors", "answered by" on Ponder search. - Edited "add members" on project membership editor. - Edited "members" on project search. - Edited "pushers" on releeph product edit. - Edited "requestors" on releeph request search. - Edited "pushers" on diffusion push log. - Edited "authors", "owners", "subscribers" on global search. - Edited "authors" on slowvote search. - Edited users in custom policy. - Grepped for "common/authors", no hits. - Grepped for "common/users", no (relevant) hits. - Grepped for "common/accounts", no (relevant) hits. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4420 Differential Revision: https://secure.phabricator.com/D9885 --- resources/celerity/map.php | 26 ++-- src/__phutil_library_map__.php | 2 + .../query/PhabricatorCommitSearchEngine.php | 2 +- .../PhabricatorCalendarEventSearchEngine.php | 4 +- .../controller/ConpherenceNewController.php | 2 +- .../ConpherenceUpdateController.php | 2 +- .../PhabricatorCountdownSearchEngine.php | 2 +- .../DifferentialRevisionSearchEngine.php | 4 +- .../controller/DiffusionLintController.php | 2 +- .../query/PhabricatorFeedSearchEngine.php | 2 +- .../query/PhabricatorFileSearchEngine.php | 2 +- .../controller/HeraldRuleController.php | 2 +- .../herald/query/HeraldRuleSearchEngine.php | 2 +- ...LegalpadDocumentSignatureAddController.php | 2 +- .../query/LegalpadDocumentSearchEngine.php | 4 +- .../LegalpadDocumentSignatureSearchEngine.php | 2 +- .../query/PhabricatorMacroSearchEngine.php | 2 +- .../ManiphestTaskDetailController.php | 5 +- .../ManiphestTaskEditController.php | 2 +- .../query/ManiphestTaskSearchEngine.php | 6 +- ...abricatorOAuthServerClientSearchEngine.php | 2 +- .../query/PhabricatorPasteSearchEngine.php | 2 +- .../PhabricatorPeopleLogSearchEngine.php | 4 +- .../typeahead/PhabricatorPeopleDatasource.php | 121 ++++++++++++++++++ .../pholio/query/PholioMockSearchEngine.php | 2 +- .../phrequent/query/PhrequentSearchEngine.php | 2 +- .../rule/PhabricatorPolicyRuleUsers.php | 6 +- .../query/PonderQuestionSearchEngine.php | 4 +- ...habricatorProjectMembersEditController.php | 2 +- .../query/PhabricatorProjectSearchEngine.php | 2 +- .../product/ReleephProductEditController.php | 2 +- .../query/ReleephRequestSearchEngine.php | 2 +- ...abricatorRepositoryPushLogSearchEngine.php | 2 +- ...abricatorSearchApplicationSearchEngine.php | 4 +- .../query/PhabricatorSlowvoteSearchEngine.php | 2 +- ...torTypeaheadCommonDatasourceController.php | 5 - .../PhabricatorStandardCustomFieldUsers.php | 4 +- .../policy/behavior-policy-rule-editor.js | 4 +- 38 files changed, 185 insertions(+), 64 deletions(-) create mode 100644 src/applications/people/typeahead/PhabricatorPeopleDatasource.php diff --git a/resources/celerity/map.php b/resources/celerity/map.php index f46043717b..7d6d649570 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -414,7 +414,7 @@ return array( 'rsrc/js/application/phortune/behavior-test-payment-form.js' => 'ab8d2723', 'rsrc/js/application/phortune/phortune-credit-card-form.js' => '2290aeef', 'rsrc/js/application/policy/behavior-policy-control.js' => 'f3fef818', - 'rsrc/js/application/policy/behavior-policy-rule-editor.js' => '92918fcb', + 'rsrc/js/application/policy/behavior-policy-rule-editor.js' => '0ea85aa3', 'rsrc/js/application/ponder/behavior-votebox.js' => '4e9b766b', 'rsrc/js/application/projects/behavior-boards-dropdown.js' => '0ec56e1d', 'rsrc/js/application/projects/behavior-project-boards.js' => 'c6b95cbd', @@ -641,7 +641,7 @@ return array( 'javelin-behavior-phui-object-box-tabs' => 'a3e2244e', 'javelin-behavior-phui-timeline-dropdown-menu' => '4d94d9c3', 'javelin-behavior-policy-control' => 'f3fef818', - 'javelin-behavior-policy-rule-editor' => '92918fcb', + 'javelin-behavior-policy-rule-editor' => '0ea85aa3', 'javelin-behavior-ponder-votebox' => '4e9b766b', 'javelin-behavior-project-boards' => 'c6b95cbd', 'javelin-behavior-project-create' => '065227cc', @@ -899,6 +899,17 @@ return array( 3 => 'javelin-util', 4 => 'phabricator-notification-css', ), + '0ea85aa3' => array( + 0 => 'javelin-behavior', + 1 => 'multirow-row-manager', + 2 => 'javelin-dom', + 3 => 'javelin-util', + 4 => 'phabricator-prefab', + 5 => 'javelin-tokenizer', + 6 => 'javelin-typeahead', + 7 => 'javelin-typeahead-ondemand-source', + 8 => 'javelin-json', + ), '0ec56e1d' => array( 0 => 'javelin-behavior', 1 => 'javelin-dom', @@ -1450,17 +1461,6 @@ return array( 1 => 'javelin-uri', 2 => 'phabricator-notification', ), - '92918fcb' => array( - 0 => 'javelin-behavior', - 1 => 'multirow-row-manager', - 2 => 'javelin-dom', - 3 => 'javelin-util', - 4 => 'phabricator-prefab', - 5 => 'javelin-tokenizer', - 6 => 'javelin-typeahead', - 7 => 'javelin-typeahead-preloaded-source', - 8 => 'javelin-json', - ), '92eb531d' => array( 0 => 'javelin-behavior', 1 => 'javelin-dom', diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index fec80ea1af..e1bd18076b 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1910,6 +1910,7 @@ phutil_register_library_map(array( 'PhabricatorPeopleCalendarController' => 'applications/people/controller/PhabricatorPeopleCalendarController.php', 'PhabricatorPeopleController' => 'applications/people/controller/PhabricatorPeopleController.php', 'PhabricatorPeopleCreateController' => 'applications/people/controller/PhabricatorPeopleCreateController.php', + 'PhabricatorPeopleDatasource' => 'applications/people/typeahead/PhabricatorPeopleDatasource.php', 'PhabricatorPeopleDeleteController' => 'applications/people/controller/PhabricatorPeopleDeleteController.php', 'PhabricatorPeopleDisableController' => 'applications/people/controller/PhabricatorPeopleDisableController.php', 'PhabricatorPeopleEmpowerController' => 'applications/people/controller/PhabricatorPeopleEmpowerController.php', @@ -4711,6 +4712,7 @@ phutil_register_library_map(array( 'PhabricatorPeopleCalendarController' => 'PhabricatorPeopleController', 'PhabricatorPeopleController' => 'PhabricatorController', 'PhabricatorPeopleCreateController' => 'PhabricatorPeopleController', + 'PhabricatorPeopleDatasource' => 'PhabricatorTypeaheadDatasource', 'PhabricatorPeopleDeleteController' => 'PhabricatorPeopleController', 'PhabricatorPeopleDisableController' => 'PhabricatorPeopleController', 'PhabricatorPeopleEmpowerController' => 'PhabricatorPeopleController', diff --git a/src/applications/audit/query/PhabricatorCommitSearchEngine.php b/src/applications/audit/query/PhabricatorCommitSearchEngine.php index 0a76163264..c448d458f2 100644 --- a/src/applications/audit/query/PhabricatorCommitSearchEngine.php +++ b/src/applications/audit/query/PhabricatorCommitSearchEngine.php @@ -91,7 +91,7 @@ final class PhabricatorCommitSearchEngine ->setValue(array_select_keys($handles, $auditor_phids))) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('authors') ->setLabel(pht('Commit Authors')) ->setValue(array_select_keys($handles, $commit_author_phids))) diff --git a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php index c2f5674af5..ccb340653e 100644 --- a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php +++ b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php @@ -106,13 +106,13 @@ final class PhabricatorCalendarEventSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/accounts/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('creators') ->setLabel(pht('Created By')) ->setValue($creator_handles)) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/accounts/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('invited') ->setLabel(pht('Invited')) ->setValue($invited_handles)) diff --git a/src/applications/conpherence/controller/ConpherenceNewController.php b/src/applications/conpherence/controller/ConpherenceNewController.php index f224de2a13..dad9a95608 100644 --- a/src/applications/conpherence/controller/ConpherenceNewController.php +++ b/src/applications/conpherence/controller/ConpherenceNewController.php @@ -82,7 +82,7 @@ final class ConpherenceNewController extends ConpherenceController { ->setName('participants') ->setValue($participant_handles) ->setUser($user) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setLabel(pht('To')) ->setError($e_participants)) ->appendChild( diff --git a/src/applications/conpherence/controller/ConpherenceUpdateController.php b/src/applications/conpherence/controller/ConpherenceUpdateController.php index 137d9f13ac..847dc26790 100644 --- a/src/applications/conpherence/controller/ConpherenceUpdateController.php +++ b/src/applications/conpherence/controller/ConpherenceUpdateController.php @@ -206,7 +206,7 @@ final class ConpherenceUpdateController id(new AphrontFormTokenizerControl()) ->setName('add_person') ->setUser($user) - ->setDatasource('/typeahead/common/users/')); + ->setDatasource(new PhabricatorPeopleDatasource())); require_celerity_resource('conpherence-update-css'); return id(new AphrontDialogView()) diff --git a/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php b/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php index d0fc715683..b6e255134c 100644 --- a/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php +++ b/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php @@ -51,7 +51,7 @@ final class PhabricatorCountdownSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('authors') ->setLabel(pht('Authors')) ->setValue($author_handles)) diff --git a/src/applications/differential/query/DifferentialRevisionSearchEngine.php b/src/applications/differential/query/DifferentialRevisionSearchEngine.php index 872bab85e0..7a26ee13a9 100644 --- a/src/applications/differential/query/DifferentialRevisionSearchEngine.php +++ b/src/applications/differential/query/DifferentialRevisionSearchEngine.php @@ -143,13 +143,13 @@ final class DifferentialRevisionSearchEngine id(new AphrontFormTokenizerControl()) ->setLabel(pht('Responsible Users')) ->setName('responsibles') - ->setDatasource('/typeahead/common/accounts/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setValue(array_select_keys($handles, $responsible_phids))) ->appendChild( id(new AphrontFormTokenizerControl()) ->setLabel(pht('Authors')) ->setName('authors') - ->setDatasource('/typeahead/common/accounts/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setValue(array_select_keys($handles, $author_phids))) ->appendChild( id(new AphrontFormTokenizerControl()) diff --git a/src/applications/diffusion/controller/DiffusionLintController.php b/src/applications/diffusion/controller/DiffusionLintController.php index b6ce4a423d..fa8693aa62 100644 --- a/src/applications/diffusion/controller/DiffusionLintController.php +++ b/src/applications/diffusion/controller/DiffusionLintController.php @@ -112,7 +112,7 @@ final class DiffusionLintController extends DiffusionController { ->setMethod('GET') ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setLimit(1) ->setName('owner') ->setLabel(pht('Owner')) diff --git a/src/applications/feed/query/PhabricatorFeedSearchEngine.php b/src/applications/feed/query/PhabricatorFeedSearchEngine.php index f9c996c5a6..268406a335 100644 --- a/src/applications/feed/query/PhabricatorFeedSearchEngine.php +++ b/src/applications/feed/query/PhabricatorFeedSearchEngine.php @@ -78,7 +78,7 @@ final class PhabricatorFeedSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('users') ->setLabel(pht('Include Users')) ->setValue($user_handles)) diff --git a/src/applications/files/query/PhabricatorFileSearchEngine.php b/src/applications/files/query/PhabricatorFileSearchEngine.php index afde191e62..d91110f8b9 100644 --- a/src/applications/files/query/PhabricatorFileSearchEngine.php +++ b/src/applications/files/query/PhabricatorFileSearchEngine.php @@ -61,7 +61,7 @@ final class PhabricatorFileSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('authors') ->setLabel(pht('Authors')) ->setValue($author_handles)) diff --git a/src/applications/herald/controller/HeraldRuleController.php b/src/applications/herald/controller/HeraldRuleController.php index 6bf1cb7c3f..b660618a0e 100644 --- a/src/applications/herald/controller/HeraldRuleController.php +++ b/src/applications/herald/controller/HeraldRuleController.php @@ -596,12 +596,12 @@ final class HeraldRuleController extends HeraldController { 'arcanistprojects' => new DiffusionArcanistProjectDatasource(), 'package' => new PhabricatorOwnersPackageDatasource(), 'project' => new PhabricatorProjectDatasource(), + 'user' => new PhabricatorPeopleDatasource(), ); $sources = mpull($sources, 'getDatasourceURI'); $sources += array( 'email' => '/typeahead/common/mailable/', - 'user' => '/typeahead/common/accounts/', 'userorproject' => '/typeahead/common/accountsorprojects/', ); diff --git a/src/applications/herald/query/HeraldRuleSearchEngine.php b/src/applications/herald/query/HeraldRuleSearchEngine.php index 4b009a113f..90fc510b62 100644 --- a/src/applications/herald/query/HeraldRuleSearchEngine.php +++ b/src/applications/herald/query/HeraldRuleSearchEngine.php @@ -71,7 +71,7 @@ final class HeraldRuleSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('authors') ->setLabel(pht('Authors')) ->setValue($author_handles)) diff --git a/src/applications/legalpad/controller/LegalpadDocumentSignatureAddController.php b/src/applications/legalpad/controller/LegalpadDocumentSignatureAddController.php index e85e7a70c7..47ad308508 100644 --- a/src/applications/legalpad/controller/LegalpadDocumentSignatureAddController.php +++ b/src/applications/legalpad/controller/LegalpadDocumentSignatureAddController.php @@ -130,7 +130,7 @@ final class LegalpadDocumentSignatureAddController extends LegalpadController { ->setLabel(pht('Exempt User')) ->setName('users') ->setLimit(1) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setValue($user_handles) ->setError($e_user)); } else { diff --git a/src/applications/legalpad/query/LegalpadDocumentSearchEngine.php b/src/applications/legalpad/query/LegalpadDocumentSearchEngine.php index 9480273c7b..d80386b815 100644 --- a/src/applications/legalpad/query/LegalpadDocumentSearchEngine.php +++ b/src/applications/legalpad/query/LegalpadDocumentSearchEngine.php @@ -95,13 +95,13 @@ final class LegalpadDocumentSearchEngine ->setDisabled(!$this->requireViewer()->getPHID())) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('creators') ->setLabel(pht('Creators')) ->setValue(array_select_keys($handles, $creator_phids))) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('contributors') ->setLabel(pht('Contributors')) ->setValue(array_select_keys($handles, $contributor_phids))); diff --git a/src/applications/legalpad/query/LegalpadDocumentSignatureSearchEngine.php b/src/applications/legalpad/query/LegalpadDocumentSignatureSearchEngine.php index 2883c6bbef..da1d792998 100644 --- a/src/applications/legalpad/query/LegalpadDocumentSignatureSearchEngine.php +++ b/src/applications/legalpad/query/LegalpadDocumentSignatureSearchEngine.php @@ -99,7 +99,7 @@ final class LegalpadDocumentSignatureSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('signers') ->setLabel(pht('Signers')) ->setValue(array_select_keys($handles, $signer_phids))) diff --git a/src/applications/macro/query/PhabricatorMacroSearchEngine.php b/src/applications/macro/query/PhabricatorMacroSearchEngine.php index c6af71ede2..9abf99d3aa 100644 --- a/src/applications/macro/query/PhabricatorMacroSearchEngine.php +++ b/src/applications/macro/query/PhabricatorMacroSearchEngine.php @@ -93,7 +93,7 @@ final class PhabricatorMacroSearchEngine ->setValue($status)) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('authors') ->setLabel(pht('Authors')) ->setValue($author_handles)) diff --git a/src/applications/maniphest/controller/ManiphestTaskDetailController.php b/src/applications/maniphest/controller/ManiphestTaskDetailController.php index 6465919ed9..de6e767dfe 100644 --- a/src/applications/maniphest/controller/ManiphestTaskDetailController.php +++ b/src/applications/maniphest/controller/ManiphestTaskDetailController.php @@ -283,6 +283,7 @@ final class ManiphestTaskDetailController extends ManiphestController { ); $projects_source = new PhabricatorProjectDatasource(); + $users_source = new PhabricatorPeopleDatasource(); $tokenizer_map = array( ManiphestTransaction::TYPE_PROJECTS => array( @@ -292,10 +293,10 @@ final class ManiphestTaskDetailController extends ManiphestController { ), ManiphestTransaction::TYPE_OWNER => array( 'id' => 'assign-tokenizer', - 'src' => '/typeahead/common/users/', + 'src' => $users_source->getDatasourceURI(), 'value' => $default_claim, 'limit' => 1, - 'placeholder' => pht('Type a user name...'), + 'placeholder' => $users_source->getPlaceholderText(), ), ManiphestTransaction::TYPE_CCS => array( 'id' => 'cc-tokenizer', diff --git a/src/applications/maniphest/controller/ManiphestTaskEditController.php b/src/applications/maniphest/controller/ManiphestTaskEditController.php index de6b272068..e08b675e52 100644 --- a/src/applications/maniphest/controller/ManiphestTaskEditController.php +++ b/src/applications/maniphest/controller/ManiphestTaskEditController.php @@ -602,7 +602,7 @@ final class ManiphestTaskEditController extends ManiphestController { ->setName('assigned_to') ->setValue($assigned_value) ->setUser($user) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setLimit(1)); } diff --git a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php index 9a948ffc65..0acaba4374 100644 --- a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php +++ b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php @@ -309,7 +309,7 @@ final class ManiphestTaskSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/accounts/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('assigned') ->setLabel(pht('Assigned To')) ->setValue($assigned_handles)) @@ -353,13 +353,13 @@ final class ManiphestTaskSearchEngine ->setValue($exclude_project_handles)) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/accounts/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('userProjects') ->setLabel(pht('In Users\' Projects')) ->setValue($user_project_handles)) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/accounts/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('authors') ->setLabel(pht('Authors')) ->setValue($author_handles)) diff --git a/src/applications/oauthserver/query/PhabricatorOAuthServerClientSearchEngine.php b/src/applications/oauthserver/query/PhabricatorOAuthServerClientSearchEngine.php index 25323f5129..ac777c3f59 100644 --- a/src/applications/oauthserver/query/PhabricatorOAuthServerClientSearchEngine.php +++ b/src/applications/oauthserver/query/PhabricatorOAuthServerClientSearchEngine.php @@ -45,7 +45,7 @@ final class PhabricatorOAuthServerClientSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('creators') ->setLabel(pht('Creators')) ->setValue($creator_handles)); diff --git a/src/applications/paste/query/PhabricatorPasteSearchEngine.php b/src/applications/paste/query/PhabricatorPasteSearchEngine.php index b589b25907..79cf87b9f6 100644 --- a/src/applications/paste/query/PhabricatorPasteSearchEngine.php +++ b/src/applications/paste/query/PhabricatorPasteSearchEngine.php @@ -67,7 +67,7 @@ final class PhabricatorPasteSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('authors') ->setLabel(pht('Authors')) ->setValue($author_handles)) diff --git a/src/applications/people/query/PhabricatorPeopleLogSearchEngine.php b/src/applications/people/query/PhabricatorPeopleLogSearchEngine.php index 8af0e65838..772ae6005e 100644 --- a/src/applications/people/query/PhabricatorPeopleLogSearchEngine.php +++ b/src/applications/people/query/PhabricatorPeopleLogSearchEngine.php @@ -124,13 +124,13 @@ final class PhabricatorPeopleLogSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/accounts/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('actors') ->setLabel(pht('Actors')) ->setValue($actor_handles)) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/accounts/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('users') ->setLabel(pht('Users')) ->setValue($user_handles)) diff --git a/src/applications/people/typeahead/PhabricatorPeopleDatasource.php b/src/applications/people/typeahead/PhabricatorPeopleDatasource.php new file mode 100644 index 0000000000..26e7cbe9f2 --- /dev/null +++ b/src/applications/people/typeahead/PhabricatorPeopleDatasource.php @@ -0,0 +1,121 @@ +getViewer(); + $raw_query = $this->getRawQuery(); + + $results = array(); + + $users = array(); + if (strlen($raw_query)) { + // This is an arbitrary limit which is just larger than any limit we + // actually use in the application. + + // TODO: The datasource should pass this in the query. + $limit = 15; + + $user_table = new PhabricatorUser(); + $conn_r = $user_table->establishConnection('r'); + $ids = queryfx_all( + $conn_r, + 'SELECT id FROM %T WHERE username LIKE %> + ORDER BY username ASC LIMIT %d', + $user_table->getTableName(), + $raw_query, + $limit); + $ids = ipull($ids, 'id'); + + if (count($ids) < $limit) { + // If we didn't find enough username hits, look for real name hits. + // We need to pull the entire pagesize so that we end up with the + // right number of items if this query returns many duplicate IDs + // that we've already selected. + + $realname_ids = queryfx_all( + $conn_r, + 'SELECT DISTINCT userID FROM %T WHERE token LIKE %> + ORDER BY token ASC LIMIT %d', + PhabricatorUser::NAMETOKEN_TABLE, + $raw_query, + $limit); + $realname_ids = ipull($realname_ids, 'userID'); + $ids = array_merge($ids, $realname_ids); + + $ids = array_unique($ids); + $ids = array_slice($ids, 0, $limit); + } + + // Always add the logged-in user because some tokenizers autosort them + // first. They'll be filtered out on the client side if they don't + // match the query. + if ($viewer->getID()) { + $ids[] = $viewer->getID(); + } + + if ($ids) { + $users = id(new PhabricatorPeopleQuery()) + ->setViewer($viewer) + ->withIDs($ids) + ->execute(); + } + } + + // TODO: Restore this when mainsearch moves here. + /* + + if ($need_rich_data) { + $phids = mpull($users, 'getPHID'); + $handles = $this->loadViewerHandles($phids); + } + + */ + + foreach ($users as $user) { + $closed = null; + if ($user->getIsDisabled()) { + $closed = pht('Disabled'); + } else if ($user->getIsSystemAgent()) { + $closed = pht('Bot/Script'); + } + + $result = id(new PhabricatorTypeaheadResult()) + ->setName($user->getFullName()) + ->setURI('/p/'.$user->getUsername()) + ->setPHID($user->getPHID()) + ->setPriorityString($user->getUsername()) + ->setIcon('fa-user bluegrey') + ->setPriorityType('user') + ->setClosed($closed); + + // TODO: Restore this too. + /* + + if ($need_rich_data) { + $display_type = 'User'; + if ($user->getIsAdmin()) { + $display_type = 'Administrator'; + } + $result->setDisplayType($display_type); + $result->setImageURI($handles[$user->getPHID()]->getImageURI()); + } + + */ + + $results[] = $result; + } + + return $results; + } + +} diff --git a/src/applications/pholio/query/PholioMockSearchEngine.php b/src/applications/pholio/query/PholioMockSearchEngine.php index 231d020ca5..3b214e7d63 100644 --- a/src/applications/pholio/query/PholioMockSearchEngine.php +++ b/src/applications/pholio/query/PholioMockSearchEngine.php @@ -55,7 +55,7 @@ final class PholioMockSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('authors') ->setLabel(pht('Authors')) ->setValue($author_handles)) diff --git a/src/applications/phrequent/query/PhrequentSearchEngine.php b/src/applications/phrequent/query/PhrequentSearchEngine.php index 1a90463bd2..6c3a4e1566 100644 --- a/src/applications/phrequent/query/PhrequentSearchEngine.php +++ b/src/applications/phrequent/query/PhrequentSearchEngine.php @@ -69,7 +69,7 @@ final class PhrequentSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('users') ->setLabel(pht('Users')) ->setValue($handles)) diff --git a/src/applications/policy/rule/PhabricatorPolicyRuleUsers.php b/src/applications/policy/rule/PhabricatorPolicyRuleUsers.php index d405fb115a..16d038e5d2 100644 --- a/src/applications/policy/rule/PhabricatorPolicyRuleUsers.php +++ b/src/applications/policy/rule/PhabricatorPolicyRuleUsers.php @@ -21,10 +21,12 @@ final class PhabricatorPolicyRuleUsers } public function getValueControlTemplate() { + $users_datasource = new PhabricatorPeopleDatasource(); + return array( 'markup' => new AphrontTokenizerTemplateView(), - 'uri' => '/typeahead/common/accounts/', - 'placeholder' => pht('Type a user name...'), + 'uri' => $users_datasource->getDatasourceURI(), + 'placeholder' => $users_datasource->getPlaceholderText(), ); } diff --git a/src/applications/ponder/query/PonderQuestionSearchEngine.php b/src/applications/ponder/query/PonderQuestionSearchEngine.php index 9592341530..8be8ec1b9c 100644 --- a/src/applications/ponder/query/PonderQuestionSearchEngine.php +++ b/src/applications/ponder/query/PonderQuestionSearchEngine.php @@ -73,13 +73,13 @@ final class PonderQuestionSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('authors') ->setLabel(pht('Authors')) ->setValue(array_select_keys($handles, $author_phids))) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('answerers') ->setLabel(pht('Answered By')) ->setValue(array_select_keys($handles, $answerer_phids))) diff --git a/src/applications/project/controller/PhabricatorProjectMembersEditController.php b/src/applications/project/controller/PhabricatorProjectMembersEditController.php index 24663967bd..7fc8bb4019 100644 --- a/src/applications/project/controller/PhabricatorProjectMembersEditController.php +++ b/src/applications/project/controller/PhabricatorProjectMembersEditController.php @@ -83,7 +83,7 @@ final class PhabricatorProjectMembersEditController id(new AphrontFormTokenizerControl()) ->setName('phids') ->setLabel(pht('Add Members')) - ->setDatasource('/typeahead/common/accounts/')) + ->setDatasource(new PhabricatorPeopleDatasource())) ->appendChild( id(new AphrontFormSubmitControl()) ->addCancelButton('/project/view/'.$project->getID().'/') diff --git a/src/applications/project/query/PhabricatorProjectSearchEngine.php b/src/applications/project/query/PhabricatorProjectSearchEngine.php index d842dab983..0122e17d0b 100644 --- a/src/applications/project/query/PhabricatorProjectSearchEngine.php +++ b/src/applications/project/query/PhabricatorProjectSearchEngine.php @@ -63,7 +63,7 @@ final class PhabricatorProjectSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('members') ->setLabel(pht('Members')) ->setValue($member_handles)) diff --git a/src/applications/releeph/controller/product/ReleephProductEditController.php b/src/applications/releeph/controller/product/ReleephProductEditController.php index 855ef06530..bd4a108ca1 100644 --- a/src/applications/releeph/controller/product/ReleephProductEditController.php +++ b/src/applications/releeph/controller/product/ReleephProductEditController.php @@ -194,7 +194,7 @@ final class ReleephProductEditController extends ReleephProductController { id(new AphrontFormTokenizerControl()) ->setLabel(pht('Pushers')) ->setName('pushers') - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setValue($pusher_handles)) ->appendChild($branch_template_input) ->appendChild($branch_template_preview) diff --git a/src/applications/releeph/query/ReleephRequestSearchEngine.php b/src/applications/releeph/query/ReleephRequestSearchEngine.php index cbae3ab65a..072bb334ef 100644 --- a/src/applications/releeph/query/ReleephRequestSearchEngine.php +++ b/src/applications/releeph/query/ReleephRequestSearchEngine.php @@ -84,7 +84,7 @@ final class ReleephRequestSearchEngine ->setOptions($this->getSeverityOptions())) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('requestors') ->setLabel(pht('Requestors')) ->setValue($requestor_handles)); diff --git a/src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php b/src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php index 757ef03f27..cb4f1fdd8e 100644 --- a/src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php +++ b/src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php @@ -80,7 +80,7 @@ final class PhabricatorRepositoryPushLogSearchEngine ->setValue($repository_handles)) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/accounts/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('pushers') ->setLabel(pht('Pushers')) ->setValue($pusher_handles)); diff --git a/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php b/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php index 249089f380..76c7b4013f 100644 --- a/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php +++ b/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php @@ -136,7 +136,7 @@ final class PhabricatorSearchApplicationSearchEngine id(new AphrontFormTokenizerControl()) ->setName('authorPHIDs') ->setLabel('Authors') - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setValue($author_handles)) ->appendChild( id(new AphrontFormTokenizerControl()) @@ -155,7 +155,7 @@ final class PhabricatorSearchApplicationSearchEngine id(new AphrontFormTokenizerControl()) ->setName('subscriberPHIDs') ->setLabel('Subscribers') - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setValue($subscriber_handles)) ->appendChild( id(new AphrontFormTokenizerControl()) diff --git a/src/applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php b/src/applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php index d822e740be..e0e8baf0ba 100644 --- a/src/applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php +++ b/src/applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php @@ -55,7 +55,7 @@ final class PhabricatorSlowvoteSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('authors') ->setLabel(pht('Authors')) ->setValue($author_handles)) diff --git a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php index b424ea00a8..7a52bbb3a6 100644 --- a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php +++ b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php @@ -48,11 +48,6 @@ final class PhabricatorTypeaheadCommonDatasourceController $need_projs = true; $need_noproject = true; break; - case 'users': - case 'accounts': - case 'authors': - $need_users = true; - break; case 'mailable': case 'allmailable': $need_users = true; diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldUsers.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldUsers.php index 2ff1d4589c..440ac7dab7 100644 --- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldUsers.php +++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldUsers.php @@ -18,7 +18,7 @@ final class PhabricatorStandardCustomFieldUsers $control = id(new AphrontFormTokenizerControl()) ->setLabel($this->getFieldName()) ->setName($this->getFieldKey()) - ->setDatasource('/typeahead/common/accounts/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setCaption($this->getCaption()) ->setValue($control_value); @@ -39,7 +39,7 @@ final class PhabricatorStandardCustomFieldUsers $control = id(new AphrontFormTokenizerControl()) ->setLabel($this->getFieldName()) ->setName($this->getFieldKey()) - ->setDatasource('/typeahead/common/accounts/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setValue($handles); $form->appendChild($control); diff --git a/webroot/rsrc/js/application/policy/behavior-policy-rule-editor.js b/webroot/rsrc/js/application/policy/behavior-policy-rule-editor.js index 94986df2f3..af3d382a99 100644 --- a/webroot/rsrc/js/application/policy/behavior-policy-rule-editor.js +++ b/webroot/rsrc/js/application/policy/behavior-policy-rule-editor.js @@ -7,7 +7,7 @@ * phabricator-prefab * javelin-tokenizer * javelin-typeahead - * javelin-typeahead-preloaded-source + * javelin-typeahead-ondemand-source * javelin-json */ JX.behavior('policy-rule-editor', function(config) { @@ -124,7 +124,7 @@ JX.behavior('policy-rule-editor', function(config) { node = JX.$H(template.markup).getNode(); node.id = ''; - var datasource = new JX.TypeaheadPreloadedSource(template.uri); + var datasource = new JX.TypeaheadOnDemandSource(template.uri); var typeahead = new JX.Typeahead(node); typeahead.setDatasource(datasource);