From cab442fe8ce8f0fbbcc609e798eebe7af8795bb0 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:45:21 -0700 Subject: [PATCH] Modernize "user, project or package" typeahead datasource Summary: Ref T4420. Call this "auditor" since that's what it is. Test Plan: - Edited auditors in auditor search. - Edited auditors in "add auditors" in Diffusion. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4420 Differential Revision: https://secure.phabricator.com/D9888 --- src/__phutil_library_map__.php | 2 ++ .../query/PhabricatorCommitSearchEngine.php | 2 +- .../controller/DiffusionCommitController.php | 5 +++-- .../typeahead/DiffusionAuditorDatasource.php | 22 +++++++++++++++++++ ...torTypeaheadCommonDatasourceController.php | 18 --------------- .../control/AphrontFormTokenizerControl.php | 2 -- 6 files changed, 28 insertions(+), 23 deletions(-) create mode 100644 src/applications/diffusion/typeahead/DiffusionAuditorDatasource.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 23efd54c85..c1997e3206 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -465,6 +465,7 @@ phutil_register_library_map(array( 'DifferentialUnitTestResult' => 'applications/differential/constants/DifferentialUnitTestResult.php', 'DifferentialViewPolicyField' => 'applications/differential/customfield/DifferentialViewPolicyField.php', 'DiffusionArcanistProjectDatasource' => 'applications/diffusion/typeahead/DiffusionArcanistProjectDatasource.php', + 'DiffusionAuditorDatasource' => 'applications/diffusion/typeahead/DiffusionAuditorDatasource.php', 'DiffusionBranchTableController' => 'applications/diffusion/controller/DiffusionBranchTableController.php', 'DiffusionBranchTableView' => 'applications/diffusion/view/DiffusionBranchTableView.php', 'DiffusionBrowseController' => 'applications/diffusion/controller/DiffusionBrowseController.php', @@ -3186,6 +3187,7 @@ phutil_register_library_map(array( 'DifferentialUnitField' => 'DifferentialCustomField', 'DifferentialViewPolicyField' => 'DifferentialCoreCustomField', 'DiffusionArcanistProjectDatasource' => 'PhabricatorTypeaheadDatasource', + 'DiffusionAuditorDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 'DiffusionBranchTableController' => 'DiffusionController', 'DiffusionBranchTableView' => 'DiffusionView', 'DiffusionBrowseController' => 'DiffusionController', diff --git a/src/applications/audit/query/PhabricatorCommitSearchEngine.php b/src/applications/audit/query/PhabricatorCommitSearchEngine.php index c448d458f2..cc665358be 100644 --- a/src/applications/audit/query/PhabricatorCommitSearchEngine.php +++ b/src/applications/audit/query/PhabricatorCommitSearchEngine.php @@ -85,7 +85,7 @@ final class PhabricatorCommitSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/usersprojectsorpackages/') + ->setDatasource(new DiffusionAuditorDatasource()) ->setName('auditorPHIDs') ->setLabel(pht('Auditors')) ->setValue(array_select_keys($handles, $auditor_phids))) diff --git a/src/applications/diffusion/controller/DiffusionCommitController.php b/src/applications/diffusion/controller/DiffusionCommitController.php index 3e672c19f7..86f3996135 100644 --- a/src/applications/diffusion/controller/DiffusionCommitController.php +++ b/src/applications/diffusion/controller/DiffusionCommitController.php @@ -772,6 +772,7 @@ final class DiffusionCommitController extends DiffusionController { require_celerity_resource('phabricator-transaction-view-css'); $mailable_source = new PhabricatorMetaMTAMailableDatasource(); + $auditor_source = new DiffusionAuditorDatasource(); Javelin::initBehavior( 'differential-add-reviewers-and-ccs', @@ -779,9 +780,9 @@ final class DiffusionCommitController extends DiffusionController { 'dynamic' => array( 'add-auditors-tokenizer' => array( 'actions' => array('add_auditors' => 1), - 'src' => '/typeahead/common/usersprojectsorpackages/', + 'src' => $auditor_source->getDatasourceURI(), 'row' => 'add-auditors', - 'placeholder' => pht('Type a user, project, or package name...'), + 'placeholder' => $auditor_source->getPlaceholderText(), ), 'add-ccs-tokenizer' => array( 'actions' => array('add_ccs' => 1), diff --git a/src/applications/diffusion/typeahead/DiffusionAuditorDatasource.php b/src/applications/diffusion/typeahead/DiffusionAuditorDatasource.php new file mode 100644 index 0000000000..ae0eff9138 --- /dev/null +++ b/src/applications/diffusion/typeahead/DiffusionAuditorDatasource.php @@ -0,0 +1,22 @@ +loadAll(); - foreach ($packages as $package) { - $results[] = id(new PhabricatorTypeaheadResult()) - ->setIcon('fa-list-alt bluegrey') - ->setName($package->getName()) - ->setURI('/owners/package/'.$package->getID().'/') - ->setPHID($package->getPHID()); - } - } - if ($need_applications) { $applications = PhabricatorApplication::getAllInstalledApplications(); foreach ($applications as $application) { diff --git a/src/view/form/control/AphrontFormTokenizerControl.php b/src/view/form/control/AphrontFormTokenizerControl.php index 04f824338e..258071a4a4 100644 --- a/src/view/form/control/AphrontFormTokenizerControl.php +++ b/src/view/form/control/AphrontFormTokenizerControl.php @@ -97,8 +97,6 @@ final class AphrontFormTokenizerControl extends AphrontFormControl { $map = array( 'searchowner' => pht('Type a user name...'), 'searchproject' => pht('Type a project name...'), - 'usersprojectsorpackages' => - pht('Type a user, project, or package name...'), ); return idx($map, $request);