From 4759f3f897eaf623a0612272c5d2661663e9327b Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 10 Jul 2014 16:20:40 -0700 Subject: [PATCH] Modernize "task priority" datasource Summary: Ref T4420. Test Plan: - Used typeahead in Herald rules. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4420 Differential Revision: https://secure.phabricator.com/D9877 --- src/__phutil_library_map__.php | 2 ++ .../controller/HeraldRuleController.php | 2 +- .../ManiphestTaskPriorityDatasource.php | 31 +++++++++++++++++++ ...torTypeaheadCommonDatasourceController.php | 14 --------- 4 files changed, 34 insertions(+), 15 deletions(-) create mode 100644 src/applications/maniphest/typeahead/ManiphestTaskPriorityDatasource.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index d499bfb27a..9bedd47770 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -944,6 +944,7 @@ phutil_register_library_map(array( 'ManiphestTaskMailReceiver' => 'applications/maniphest/mail/ManiphestTaskMailReceiver.php', 'ManiphestTaskOwner' => 'applications/maniphest/constants/ManiphestTaskOwner.php', 'ManiphestTaskPriority' => 'applications/maniphest/constants/ManiphestTaskPriority.php', + 'ManiphestTaskPriorityDatasource' => 'applications/maniphest/typeahead/ManiphestTaskPriorityDatasource.php', 'ManiphestTaskProject' => 'applications/maniphest/storage/ManiphestTaskProject.php', 'ManiphestTaskQuery' => 'applications/maniphest/query/ManiphestTaskQuery.php', 'ManiphestTaskResultListView' => 'applications/maniphest/view/ManiphestTaskResultListView.php', @@ -3724,6 +3725,7 @@ phutil_register_library_map(array( 'ManiphestTaskMailReceiver' => 'PhabricatorObjectMailReceiver', 'ManiphestTaskOwner' => 'ManiphestConstants', 'ManiphestTaskPriority' => 'ManiphestConstants', + 'ManiphestTaskPriorityDatasource' => 'PhabricatorTypeaheadDatasource', 'ManiphestTaskProject' => 'ManiphestDAO', 'ManiphestTaskQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'ManiphestTaskResultListView' => 'ManiphestView', diff --git a/src/applications/herald/controller/HeraldRuleController.php b/src/applications/herald/controller/HeraldRuleController.php index ae184ab1f3..a7eff04027 100644 --- a/src/applications/herald/controller/HeraldRuleController.php +++ b/src/applications/herald/controller/HeraldRuleController.php @@ -591,6 +591,7 @@ final class HeraldRuleController extends HeraldController { $sources = array( 'repository' => new DiffusionRepositoryDatasource(), 'legaldocuments' => new LegalpadDocumentDatasource(), + 'taskpriority' => new ManiphestTaskPriorityDatasource(), ); $sources = mpull($sources, 'getDatasourceURI'); @@ -601,7 +602,6 @@ final class HeraldRuleController extends HeraldController { 'project' => '/typeahead/common/projects/', 'userorproject' => '/typeahead/common/accountsorprojects/', 'buildplan' => '/typeahead/common/buildplans/', - 'taskpriority' => '/typeahead/common/taskpriority/', 'arcanistprojects' => '/typeahead/common/arcanistprojects/', ); diff --git a/src/applications/maniphest/typeahead/ManiphestTaskPriorityDatasource.php b/src/applications/maniphest/typeahead/ManiphestTaskPriorityDatasource.php new file mode 100644 index 0000000000..a6adc0a904 --- /dev/null +++ b/src/applications/maniphest/typeahead/ManiphestTaskPriorityDatasource.php @@ -0,0 +1,31 @@ +getViewer(); + $raw_query = $this->getRawQuery(); + + $results = array(); + + $priority_map = ManiphestTaskPriority::getTaskPriorityMap(); + foreach ($priority_map as $value => $name) { + // NOTE: $value is not a phid but is unique. This'll work. + $results[] = id(new PhabricatorTypeaheadResult()) + ->setPHID($value) + ->setName($name); + } + + return $results; + } + +} diff --git a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php index aa6512f547..47c3fcc26e 100644 --- a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php +++ b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php @@ -33,7 +33,6 @@ final class PhabricatorTypeaheadCommonDatasourceController $need_symbols = false; $need_jump_objects = false; $need_build_plans = false; - $need_task_priority = false; switch ($this->type) { case 'mainsearch': $need_users = true; @@ -84,9 +83,6 @@ final class PhabricatorTypeaheadCommonDatasourceController case 'buildplans': $need_build_plans = true; break; - case 'taskpriority': - $need_task_priority = true; - break; } $results = array(); @@ -225,16 +221,6 @@ final class PhabricatorTypeaheadCommonDatasourceController } } - if ($need_task_priority) { - $priority_map = ManiphestTaskPriority::getTaskPriorityMap(); - foreach ($priority_map as $value => $name) { - // NOTE: $value is not a phid but is unique. This'll work. - $results[] = id(new PhabricatorTypeaheadResult()) - ->setPHID($value) - ->setName($name); - } - } - if ($need_projs) { $projs = id(new PhabricatorProjectQuery()) ->setViewer($viewer)