From dba48656817f24a86b8c1b288bce954bbd204d58 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 10 Jul 2014 16:20:58 -0700 Subject: [PATCH] Modernize "build plans" typeahead datasource Summary: Ref T4420. Modernize build plans. Test Plan: - Used build plan typeahead in Harbormaster. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4420 Differential Revision: https://secure.phabricator.com/D9878 --- src/__phutil_library_map__.php | 2 ++ .../phid/HarbormasterPHIDTypeBuildPlan.php | 9 ++++-- .../HarbormasterBuildPlanDatasource.php | 32 +++++++++++++++++++ .../controller/HeraldRuleController.php | 2 +- ...torTypeaheadCommonDatasourceController.php | 15 --------- 5 files changed, 42 insertions(+), 18 deletions(-) create mode 100644 src/applications/harbormaster/typeahead/HarbormasterBuildPlanDatasource.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 9bedd47770..e5927dc6d9 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -729,6 +729,7 @@ phutil_register_library_map(array( 'HarbormasterBuildMessage' => 'applications/harbormaster/storage/HarbormasterBuildMessage.php', 'HarbormasterBuildMessageQuery' => 'applications/harbormaster/query/HarbormasterBuildMessageQuery.php', 'HarbormasterBuildPlan' => 'applications/harbormaster/storage/configuration/HarbormasterBuildPlan.php', + 'HarbormasterBuildPlanDatasource' => 'applications/harbormaster/typeahead/HarbormasterBuildPlanDatasource.php', 'HarbormasterBuildPlanEditor' => 'applications/harbormaster/editor/HarbormasterBuildPlanEditor.php', 'HarbormasterBuildPlanQuery' => 'applications/harbormaster/query/HarbormasterBuildPlanQuery.php', 'HarbormasterBuildPlanSearchEngine' => 'applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php', @@ -3470,6 +3471,7 @@ phutil_register_library_map(array( 1 => 'PhabricatorPolicyInterface', 2 => 'PhabricatorSubscribableInterface', ), + 'HarbormasterBuildPlanDatasource' => 'PhabricatorTypeaheadDatasource', 'HarbormasterBuildPlanEditor' => 'PhabricatorApplicationTransactionEditor', 'HarbormasterBuildPlanQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'HarbormasterBuildPlanSearchEngine' => 'PhabricatorApplicationSearchEngine', diff --git a/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildPlan.php b/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildPlan.php index 0a18c73d85..d5abaf8f0b 100644 --- a/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildPlan.php +++ b/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildPlan.php @@ -12,6 +12,10 @@ final class HarbormasterPHIDTypeBuildPlan extends PhabricatorPHIDType { return pht('Build Plan'); } + public function getTypeIcon() { + return 'fa-cubes'; + } + public function newObject() { return new HarbormasterBuildPlan(); } @@ -31,8 +35,9 @@ final class HarbormasterPHIDTypeBuildPlan extends PhabricatorPHIDType { foreach ($handles as $phid => $handle) { $build_plan = $objects[$phid]; - $handles[$phid]->setName($build_plan->getName()); - $handles[$phid]->setURI('/harbormaster/plan/'.$build_plan->getID()); + $id = $build_plan->getID(); + $handles[$phid]->setName(pht('Plan %d %s', $id, $build_plan->getName())); + $handles[$phid]->setURI('/harbormaster/plan/'.$id.'/'); } } diff --git a/src/applications/harbormaster/typeahead/HarbormasterBuildPlanDatasource.php b/src/applications/harbormaster/typeahead/HarbormasterBuildPlanDatasource.php new file mode 100644 index 0000000000..57c9f870ab --- /dev/null +++ b/src/applications/harbormaster/typeahead/HarbormasterBuildPlanDatasource.php @@ -0,0 +1,32 @@ +getViewer(); + $raw_query = $this->getRawQuery(); + + $results = array(); + + $plans = id(new HarbormasterBuildPlanQuery()) + ->setViewer($viewer) + ->execute(); + foreach ($plans as $plan) { + $results[] = id(new PhabricatorTypeaheadResult()) + ->setName($plan->getName()) + ->setPHID($plan->getPHID()); + } + + return $results; + } + +} diff --git a/src/applications/herald/controller/HeraldRuleController.php b/src/applications/herald/controller/HeraldRuleController.php index a7eff04027..77dd9f9b23 100644 --- a/src/applications/herald/controller/HeraldRuleController.php +++ b/src/applications/herald/controller/HeraldRuleController.php @@ -592,6 +592,7 @@ final class HeraldRuleController extends HeraldController { 'repository' => new DiffusionRepositoryDatasource(), 'legaldocuments' => new LegalpadDocumentDatasource(), 'taskpriority' => new ManiphestTaskPriorityDatasource(), + 'buildplan' => new HarbormasterBuildPlanDatasource(), ); $sources = mpull($sources, 'getDatasourceURI'); @@ -601,7 +602,6 @@ final class HeraldRuleController extends HeraldController { 'package' => '/typeahead/common/packages/', 'project' => '/typeahead/common/projects/', 'userorproject' => '/typeahead/common/accountsorprojects/', - 'buildplan' => '/typeahead/common/buildplans/', 'arcanistprojects' => '/typeahead/common/arcanistprojects/', ); diff --git a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php index 47c3fcc26e..9596d85001 100644 --- a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php +++ b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php @@ -32,7 +32,6 @@ final class PhabricatorTypeaheadCommonDatasourceController $need_noproject = false; $need_symbols = false; $need_jump_objects = false; - $need_build_plans = false; switch ($this->type) { case 'mainsearch': $need_users = true; @@ -80,9 +79,6 @@ final class PhabricatorTypeaheadCommonDatasourceController case 'arcanistprojects': $need_arcanist_projects = true; break; - case 'buildplans': - $need_build_plans = true; - break; } $results = array(); @@ -210,17 +206,6 @@ final class PhabricatorTypeaheadCommonDatasourceController } } - if ($need_build_plans) { - $plans = id(new HarbormasterBuildPlanQuery()) - ->setViewer($viewer) - ->execute(); - foreach ($plans as $plan) { - $results[] = id(new PhabricatorTypeaheadResult()) - ->setName($plan->getName()) - ->setPHID($plan->getPHID()); - } - } - if ($need_projs) { $projs = id(new PhabricatorProjectQuery()) ->setViewer($viewer)