From 10c6fcb4bbf32ed762d0e9eafafb1177bee25f23 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 28 May 2011 14:13:12 -0700 Subject: [PATCH] Allow Maniphest filtering by "upforgrabs" explicitly Summary: Allow you to filter by "upforgrabs" to find unassigned tasks. Test Plan: Filtered by "upforgrabs". Reviewed By: tuomaspelkonen Reviewers: tuomaspelkonen, jungejason, aran Commenters: aran CC: sandra, anjali, aran, tuomaspelkonen, epriestley Differential Revision: 365 --- src/__phutil_library_map__.php | 1 + .../constants/owner/ManiphestTaskOwner.php | 23 ++++++++++ .../maniphest/constants/owner/__init__.php | 10 ++++ .../tasklist/ManiphestTaskListController.php | 46 ++++++++++++++++--- .../controller/tasklist/__init__.php | 1 + .../data/PhabricatorObjectHandleData.php | 3 +- .../phid/handle/data/__init__.php | 1 + .../PhabricatorSearchManiphestIndexer.php | 2 +- .../index/indexer/maniphest/__init__.php | 1 + ...torTypeaheadCommonDatasourceController.php | 4 +- .../typeahead/controller/common/__init__.php | 1 + 11 files changed, 82 insertions(+), 11 deletions(-) create mode 100644 src/applications/maniphest/constants/owner/ManiphestTaskOwner.php create mode 100644 src/applications/maniphest/constants/owner/__init__.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index a6d60ec60d..1344689d0c 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -268,6 +268,7 @@ phutil_register_library_map(array( 'ManiphestTaskEditController' => 'applications/maniphest/controller/taskedit', 'ManiphestTaskListController' => 'applications/maniphest/controller/tasklist', 'ManiphestTaskListView' => 'applications/maniphest/view/tasklist', + 'ManiphestTaskOwner' => 'applications/maniphest/constants/owner', 'ManiphestTaskPriority' => 'applications/maniphest/constants/priority', 'ManiphestTaskStatus' => 'applications/maniphest/constants/status', 'ManiphestTaskSummaryView' => 'applications/maniphest/view/tasksummary', diff --git a/src/applications/maniphest/constants/owner/ManiphestTaskOwner.php b/src/applications/maniphest/constants/owner/ManiphestTaskOwner.php new file mode 100644 index 0000000000..6a6ff59b4c --- /dev/null +++ b/src/applications/maniphest/constants/owner/ManiphestTaskOwner.php @@ -0,0 +1,23 @@ +appendChild( id(new AphrontFormTokenizerControl()) ->setLimit(1) - ->setDatasource('/typeahead/common/users/') + ->setDatasource('/typeahead/common/searchowner/') ->setName('view_user') ->setLabel('View User') + ->setCaption('Use "upforgrabs" to find unassigned tasks.') ->setValue( array( $view_phid => $handles[$view_phid]->getFullName(), @@ -211,6 +212,14 @@ class ManiphestTaskListController extends ManiphestController { private function loadTasks($view_phid, array $dict) { $phids = array($view_phid); + $include_upforgrabs = false; + foreach ($phids as $key => $phid) { + if ($phid == ManiphestTaskOwner::OWNER_UP_FOR_GRABS) { + unset($phids[$key]); + $include_upforgrabs = true; + } + } + $task = new ManiphestTask(); $argv = array(); @@ -229,16 +238,39 @@ class ManiphestTaskListController extends ManiphestController { $extra_clause = '1 = 1'; switch ($this->view) { case 'action': - $extra_clause = 'ownerPHID in (%Ls)'; - $argv[] = $phids; + $parts = array(); + if ($phids) { + $parts[] = 'ownerPHID in (%Ls)'; + $argv[] = $phids; + } + if ($include_upforgrabs) { + $parts[] = 'ownerPHID IS NULL'; + } + $extra_clause = '('.implode(' OR ', $parts).')'; break; case 'created': - $extra_clause = 'authorPHID in (%Ls)'; - $argv[] = $phids; + $parts = array(); + if ($phids) { + $parts[] = 'authorPHID in (%Ls)'; + $argv[] = $phids; + } + if ($include_upforgrabs) { + // This should be impossible since every task is supposed to have a + // valid author, but we might as well run the query. + $parts[] = 'authorPHID IS NULL'; + } + $extra_clause = '('.implode(' OR ', $parts).')'; break; case 'triage': - $extra_clause = 'ownerPHID in (%Ls) AND priority = %d'; - $argv[] = $phids; + $parts = array(); + if ($phids) { + $parts[] = 'ownerPHID in (%Ls)'; + $argv[] = $phids; + } + if ($include_upforgrabs) { + $parts[] = 'ownerPHID IS NULL'; + } + $extra_clause = '('.implode(' OR ', $parts).') AND priority = %d'; $argv[] = ManiphestTaskPriority::PRIORITY_TRIAGE; break; case 'alltriage': diff --git a/src/applications/maniphest/controller/tasklist/__init__.php b/src/applications/maniphest/controller/tasklist/__init__.php index ffd77b6ee2..16e6296085 100644 --- a/src/applications/maniphest/controller/tasklist/__init__.php +++ b/src/applications/maniphest/controller/tasklist/__init__.php @@ -7,6 +7,7 @@ phutil_require_module('phabricator', 'aphront/response/redirect'); +phutil_require_module('phabricator', 'applications/maniphest/constants/owner'); phutil_require_module('phabricator', 'applications/maniphest/constants/priority'); phutil_require_module('phabricator', 'applications/maniphest/constants/status'); phutil_require_module('phabricator', 'applications/maniphest/controller/base'); diff --git a/src/applications/phid/handle/data/PhabricatorObjectHandleData.php b/src/applications/phid/handle/data/PhabricatorObjectHandleData.php index 97f0a1e54d..9e1f4c9c65 100644 --- a/src/applications/phid/handle/data/PhabricatorObjectHandleData.php +++ b/src/applications/phid/handle/data/PhabricatorObjectHandleData.php @@ -94,8 +94,9 @@ class PhabricatorObjectHandleData { $handle->setPHID($phid); $handle->setType($type); switch ($phid) { - case 'PHID-!!!!-UP-FOR-GRABS': + case ManiphestTaskOwner::OWNER_UP_FOR_GRABS: $handle->setName('Up For Grabs'); + $handle->setFullName('upforgrabs (Up For Grabs)'); break; default: $handle->setName('Foul Magicks'); diff --git a/src/applications/phid/handle/data/__init__.php b/src/applications/phid/handle/data/__init__.php index aabb464c87..4ad54490fa 100644 --- a/src/applications/phid/handle/data/__init__.php +++ b/src/applications/phid/handle/data/__init__.php @@ -7,6 +7,7 @@ phutil_require_module('phabricator', 'applications/files/uri'); +phutil_require_module('phabricator', 'applications/maniphest/constants/owner'); phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/handle'); phutil_require_module('phabricator', 'applications/repository/constants/repositorytype'); diff --git a/src/applications/search/index/indexer/maniphest/PhabricatorSearchManiphestIndexer.php b/src/applications/search/index/indexer/maniphest/PhabricatorSearchManiphestIndexer.php index f4bf4cca02..c3ac348f47 100644 --- a/src/applications/search/index/indexer/maniphest/PhabricatorSearchManiphestIndexer.php +++ b/src/applications/search/index/indexer/maniphest/PhabricatorSearchManiphestIndexer.php @@ -100,7 +100,7 @@ class PhabricatorSearchManiphestIndexer } else { $doc->addRelationship( PhabricatorSearchRelationship::RELATIONSHIP_OWNER, - 'PHID-!!!!-UP-FOR-GRABS', + ManiphestTaskOwner::OWNER_UP_FOR_GRABS, PhabricatorPHIDConstants::PHID_TYPE_MAGIC, $owner ? $owner->getDateCreated() diff --git a/src/applications/search/index/indexer/maniphest/__init__.php b/src/applications/search/index/indexer/maniphest/__init__.php index a6e5eecdb5..df4bda6f78 100644 --- a/src/applications/search/index/indexer/maniphest/__init__.php +++ b/src/applications/search/index/indexer/maniphest/__init__.php @@ -6,6 +6,7 @@ +phutil_require_module('phabricator', 'applications/maniphest/constants/owner'); phutil_require_module('phabricator', 'applications/maniphest/constants/status'); phutil_require_module('phabricator', 'applications/maniphest/constants/transactiontype'); phutil_require_module('phabricator', 'applications/maniphest/storage/transaction'); diff --git a/src/applications/typeahead/controller/common/PhabricatorTypeaheadCommonDatasourceController.php b/src/applications/typeahead/controller/common/PhabricatorTypeaheadCommonDatasourceController.php index c3038485af..d3eb951c1e 100644 --- a/src/applications/typeahead/controller/common/PhabricatorTypeaheadCommonDatasourceController.php +++ b/src/applications/typeahead/controller/common/PhabricatorTypeaheadCommonDatasourceController.php @@ -63,9 +63,9 @@ class PhabricatorTypeaheadCommonDatasourceController if ($need_upforgrabs) { $data[] = array( - 'Up For Grabs', + 'upforgrabs (Up For Grabs)', null, - 'PHID-!!!!-UP-FOR-GRABS', + ManiphestTaskOwner::OWNER_UP_FOR_GRABS, ); } diff --git a/src/applications/typeahead/controller/common/__init__.php b/src/applications/typeahead/controller/common/__init__.php index 9e27c3e96f..850fce97d5 100644 --- a/src/applications/typeahead/controller/common/__init__.php +++ b/src/applications/typeahead/controller/common/__init__.php @@ -7,6 +7,7 @@ phutil_require_module('phabricator', 'aphront/response/ajax'); +phutil_require_module('phabricator', 'applications/maniphest/constants/owner'); phutil_require_module('phabricator', 'applications/metamta/storage/mailinglist'); phutil_require_module('phabricator', 'applications/owners/storage/package'); phutil_require_module('phabricator', 'applications/people/storage/user');