From 6eb879210a4f63e6b5d7481e9f2c99db8f393245 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 10 Jul 2014 16:21:21 -0700 Subject: [PATCH] Modernize "owners" datasource Summary: Ref T4420. Update owners. Test Plan: - Used typeahead from Herald. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4420 Differential Revision: https://secure.phabricator.com/D9880 --- src/__phutil_library_map__.php | 2 ++ .../controller/HeraldRuleController.php | 2 +- .../PhabricatorOwnersPackageDatasource.php | 35 +++++++++++++++++++ ...torTypeaheadCommonDatasourceController.php | 3 -- 4 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 src/applications/owners/typeahead/PhabricatorOwnersPackageDatasource.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index d8f5f33152..305ed09675 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1866,6 +1866,7 @@ phutil_register_library_map(array( 'PhabricatorOwnersOwner' => 'applications/owners/storage/PhabricatorOwnersOwner.php', 'PhabricatorOwnersPHIDTypePackage' => 'applications/owners/phid/PhabricatorOwnersPHIDTypePackage.php', 'PhabricatorOwnersPackage' => 'applications/owners/storage/PhabricatorOwnersPackage.php', + 'PhabricatorOwnersPackageDatasource' => 'applications/owners/typeahead/PhabricatorOwnersPackageDatasource.php', 'PhabricatorOwnersPackagePathValidator' => 'applications/repository/worker/commitchangeparser/PhabricatorOwnersPackagePathValidator.php', 'PhabricatorOwnersPackageQuery' => 'applications/owners/query/PhabricatorOwnersPackageQuery.php', 'PhabricatorOwnersPackageTestCase' => 'applications/owners/storage/__tests__/PhabricatorOwnersPackageTestCase.php', @@ -4718,6 +4719,7 @@ phutil_register_library_map(array( 0 => 'PhabricatorOwnersDAO', 1 => 'PhabricatorPolicyInterface', ), + 'PhabricatorOwnersPackageDatasource' => 'PhabricatorTypeaheadDatasource', 'PhabricatorOwnersPackageQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorOwnersPackageTestCase' => 'PhabricatorTestCase', 'PhabricatorOwnersPath' => 'PhabricatorOwnersDAO', diff --git a/src/applications/herald/controller/HeraldRuleController.php b/src/applications/herald/controller/HeraldRuleController.php index e149b27a65..e91da23692 100644 --- a/src/applications/herald/controller/HeraldRuleController.php +++ b/src/applications/herald/controller/HeraldRuleController.php @@ -594,13 +594,13 @@ final class HeraldRuleController extends HeraldController { 'taskpriority' => new ManiphestTaskPriorityDatasource(), 'buildplan' => new HarbormasterBuildPlanDatasource(), 'arcanistprojects' => new DiffusionArcanistProjectDatasource(), + 'package' => new PhabricatorOwnersPackageDatasource(), ); $sources = mpull($sources, 'getDatasourceURI'); $sources += array( 'email' => '/typeahead/common/mailable/', 'user' => '/typeahead/common/accounts/', - 'package' => '/typeahead/common/packages/', 'project' => '/typeahead/common/projects/', 'userorproject' => '/typeahead/common/accountsorprojects/', ); diff --git a/src/applications/owners/typeahead/PhabricatorOwnersPackageDatasource.php b/src/applications/owners/typeahead/PhabricatorOwnersPackageDatasource.php new file mode 100644 index 0000000000..edbcf758ce --- /dev/null +++ b/src/applications/owners/typeahead/PhabricatorOwnersPackageDatasource.php @@ -0,0 +1,35 @@ +getViewer(); + $raw_query = $this->getRawQuery(); + + $results = array(); + + $packages = id(new PhabricatorOwnersPackageQuery()) + ->setViewer($viewer) + ->execute(); + + foreach ($packages as $package) { + $results[] = id(new PhabricatorTypeaheadResult()) + ->setIcon('fa-list-alt bluegrey') + ->setName($package->getName()) + ->setURI('/owners/package/'.$package->getID().'/') + ->setPHID($package->getPHID()); + } + + return $results; + } + +} diff --git a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php index cc671b89ae..1dfb0983d5 100644 --- a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php +++ b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php @@ -72,9 +72,6 @@ final class PhabricatorTypeaheadCommonDatasourceController $need_projs = true; $need_packages = true; break; - case 'packages': - $need_packages = true; - break; } $results = array();