From 0f2d2201cec2b0a7d9ab8e5a628cb7ff475c183c Mon Sep 17 00:00:00 2001 From: vrana Date: Sat, 4 Feb 2012 00:43:49 -0800 Subject: [PATCH] Search owners by repository Summary: I've chosen passing callsign even if it is more complicated because it is nicer than PHID and can be written by hand. Test Plan: Search without repository. Search with repository. Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1571 --- .../list/PhabricatorOwnersListController.php | 47 ++++++++++++++++--- .../owners/controller/list/__init__.php | 2 + 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/applications/owners/controller/list/PhabricatorOwnersListController.php b/src/applications/owners/controller/list/PhabricatorOwnersListController.php index b3619937db..98427f8d6f 100644 --- a/src/applications/owners/controller/list/PhabricatorOwnersListController.php +++ b/src/applications/owners/controller/list/PhabricatorOwnersListController.php @@ -34,6 +34,13 @@ class PhabricatorOwnersListController extends PhabricatorOwnersController { $owner = new PhabricatorOwnersOwner(); $path = new PhabricatorOwnersPath(); + $repository_phid = ''; + if ($request->getStr('repository') != '') { + $repository_phid = id(new PhabricatorRepository()) + ->loadOneWhere('callsign = %s', $request->getStr('repository')) + ->getPHID(); + } + switch ($this->view) { case 'search': $packages = array(); @@ -50,17 +57,29 @@ class PhabricatorOwnersListController extends PhabricatorOwnersController { $request->getStr('name')); } - if ($request->getStr('path')) { + if ($repository_phid || $request->getStr('path')) { + $join[] = qsprintf( $conn_r, 'JOIN %T path ON path.packageID = p.id', $path->getTableName()); - $where[] = qsprintf( - $conn_r, - 'path.path LIKE %~ OR %s LIKE CONCAT(path.path, %s)', - $request->getStr('path'), - $request->getStr('path'), - '%'); + + if ($repository_phid) { + $where[] = qsprintf( + $conn_r, + 'path.repositoryPHID = %s', + $repository_phid); + } + + if ($request->getStr('path')) { + $where[] = qsprintf( + $conn_r, + 'path.path LIKE %~ OR %s LIKE CONCAT(path.path, %s)', + $request->getStr('path'), + $request->getStr('path'), + '%'); + } + } if ($request->getArr('owner')) { @@ -132,6 +151,14 @@ class PhabricatorOwnersListController extends PhabricatorOwnersController { ); } + $callsigns = array('' => '(Any Repository)'); + $repositories = id(new PhabricatorRepository()) + ->loadAllWhere('1 = 1 ORDER BY callsign'); + foreach ($repositories as $repository) { + $callsigns[$repository->getCallsign()] = + $repository->getCallsign().': '.$repository->getName(); + } + $form = id(new AphrontFormView()) ->setUser($user) ->setAction('/owners/view/search/') @@ -148,6 +175,12 @@ class PhabricatorOwnersListController extends PhabricatorOwnersController { ->setName('owner') ->setLabel('Owner') ->setValue($owners_search_value)) + ->appendChild( + id(new AphrontFormSelectControl()) + ->setName('repository') + ->setLabel('Repository') + ->setOptions($callsigns) + ->setValue($request->getStr('repository'))) ->appendChild( id(new AphrontFormTextControl()) ->setName('path') diff --git a/src/applications/owners/controller/list/__init__.php b/src/applications/owners/controller/list/__init__.php index e7bef95555..222c83cd5f 100644 --- a/src/applications/owners/controller/list/__init__.php +++ b/src/applications/owners/controller/list/__init__.php @@ -11,10 +11,12 @@ phutil_require_module('phabricator', 'applications/owners/storage/owner'); phutil_require_module('phabricator', 'applications/owners/storage/package'); phutil_require_module('phabricator', 'applications/owners/storage/path'); phutil_require_module('phabricator', 'applications/phid/handle/data'); +phutil_require_module('phabricator', 'applications/repository/storage/repository'); phutil_require_module('phabricator', 'storage/qsprintf'); phutil_require_module('phabricator', 'storage/queryfx'); phutil_require_module('phabricator', 'view/control/table'); phutil_require_module('phabricator', 'view/form/base'); +phutil_require_module('phabricator', 'view/form/control/select'); phutil_require_module('phabricator', 'view/form/control/submit'); phutil_require_module('phabricator', 'view/form/control/text'); phutil_require_module('phabricator', 'view/form/control/tokenizer');