diff --git a/src/applications/maniphest/relationship/ManiphestTaskCloseAsDuplicateRelationship.php b/src/applications/maniphest/relationship/ManiphestTaskCloseAsDuplicateRelationship.php index 696ceb615e..6428c79b55 100644 --- a/src/applications/maniphest/relationship/ManiphestTaskCloseAsDuplicateRelationship.php +++ b/src/applications/maniphest/relationship/ManiphestTaskCloseAsDuplicateRelationship.php @@ -38,7 +38,8 @@ final class ManiphestTaskCloseAsDuplicateRelationship } protected function newRelationshipSource() { - return new ManiphestTaskRelationshipSource(); + return id(new ManiphestTaskRelationshipSource()) + ->setSelectedFilter('open'); } public function getRequiredRelationshipCapabilities() { diff --git a/src/applications/maniphest/relationship/ManiphestTaskHasParentRelationship.php b/src/applications/maniphest/relationship/ManiphestTaskHasParentRelationship.php index 6210e3c4d4..6cfd11ff09 100644 --- a/src/applications/maniphest/relationship/ManiphestTaskHasParentRelationship.php +++ b/src/applications/maniphest/relationship/ManiphestTaskHasParentRelationship.php @@ -38,7 +38,8 @@ final class ManiphestTaskHasParentRelationship } protected function newRelationshipSource() { - return new ManiphestTaskRelationshipSource(); + return id(new ManiphestTaskRelationshipSource()) + ->setSelectedFilter('open'); } } diff --git a/src/applications/maniphest/relationship/ManiphestTaskHasSubtaskRelationship.php b/src/applications/maniphest/relationship/ManiphestTaskHasSubtaskRelationship.php index 335ac03d42..2fb69e90fb 100644 --- a/src/applications/maniphest/relationship/ManiphestTaskHasSubtaskRelationship.php +++ b/src/applications/maniphest/relationship/ManiphestTaskHasSubtaskRelationship.php @@ -38,7 +38,8 @@ final class ManiphestTaskHasSubtaskRelationship } protected function newRelationshipSource() { - return new ManiphestTaskRelationshipSource(); + return id(new ManiphestTaskRelationshipSource()) + ->setSelectedFilter('open'); } } diff --git a/src/applications/maniphest/relationship/ManiphestTaskMergeInRelationship.php b/src/applications/maniphest/relationship/ManiphestTaskMergeInRelationship.php index 5bf45b7911..c8442c428f 100644 --- a/src/applications/maniphest/relationship/ManiphestTaskMergeInRelationship.php +++ b/src/applications/maniphest/relationship/ManiphestTaskMergeInRelationship.php @@ -38,7 +38,8 @@ final class ManiphestTaskMergeInRelationship } protected function newRelationshipSource() { - return new ManiphestTaskRelationshipSource(); + return id(new ManiphestTaskRelationshipSource()) + ->setSelectedFilter('open'); } public function getRequiredRelationshipCapabilities() { diff --git a/src/applications/search/controller/PhabricatorSearchRelationshipController.php b/src/applications/search/controller/PhabricatorSearchRelationshipController.php index 767c756813..14c705ac62 100644 --- a/src/applications/search/controller/PhabricatorSearchRelationshipController.php +++ b/src/applications/search/controller/PhabricatorSearchRelationshipController.php @@ -150,14 +150,6 @@ final class PhabricatorSearchRelationshipController $handles = iterator_to_array($handles); $handles = array_select_keys($handles, $dst_phids); - // TODO: These are hard-coded for now. - $filters = array( - 'assigned' => pht('Assigned to Me'), - 'created' => pht('Created By Me'), - 'open' => pht('All Open Objects'), - 'all' => pht('All Objects'), - ); - $dialog_title = $relationship->getDialogTitleText(); $dialog_header = $relationship->getDialogHeaderText(); $dialog_button = $relationship->getDialogButtonText(); @@ -165,12 +157,17 @@ final class PhabricatorSearchRelationshipController $source_uri = $relationship->getSourceURI($object); + $source = $relationship->newSource(); + + $filters = $source->getFilters(); + $selected_filter = $source->getSelectedFilter(); + return id(new PhabricatorObjectSelectorDialog()) ->setUser($viewer) ->setInitialPHIDs($initial_phids) ->setHandles($handles) ->setFilters($filters) - ->setSelectedFilter('created') + ->setSelectedFilter($selected_filter) ->setExcluded($src_phid) ->setCancelURI($done_uri) ->setSearchURI($source_uri) diff --git a/src/applications/search/relationship/DiffusionCommitRelationshipSource.php b/src/applications/search/relationship/DiffusionCommitRelationshipSource.php index 31fc918011..25c799caf4 100644 --- a/src/applications/search/relationship/DiffusionCommitRelationshipSource.php +++ b/src/applications/search/relationship/DiffusionCommitRelationshipSource.php @@ -17,4 +17,10 @@ final class DiffusionCommitRelationshipSource ); } + public function getFilters() { + $filters = parent::getFilters(); + unset($filters['assigned']); + return $filters; + } + } diff --git a/src/applications/search/relationship/PhabricatorObjectRelationshipSource.php b/src/applications/search/relationship/PhabricatorObjectRelationshipSource.php index a1fc9a6370..9990740b4f 100644 --- a/src/applications/search/relationship/PhabricatorObjectRelationshipSource.php +++ b/src/applications/search/relationship/PhabricatorObjectRelationshipSource.php @@ -3,6 +3,7 @@ abstract class PhabricatorObjectRelationshipSource extends Phobject { private $viewer; + private $selectedFilter; final public function setViewer(PhabricatorUser $viewer) { $this->viewer = $viewer; @@ -16,4 +17,32 @@ abstract class PhabricatorObjectRelationshipSource extends Phobject { abstract public function isEnabledForObject($object); abstract public function getResultPHIDTypes(); + protected function getDefaultFilter() { + return 'created'; + } + + final public function setSelectedFilter($selected_filter) { + $this->selectedFilter = $selected_filter; + return $this; + } + + final public function getSelectedFilter() { + if ($this->selectedFilter === null) { + return $this->getDefaultFilter(); + } + + return $this->selectedFilter; + } + + public function getFilters() { + // TODO: These are hard-coded for now, and all of this will probably be + // rewritten when we move to ApplicationSearch. + return array( + 'assigned' => pht('Assigned to Me'), + 'created' => pht('Created By Me'), + 'open' => pht('All Open Objects'), + 'all' => pht('All Objects'), + ); + } + } diff --git a/src/applications/search/relationship/PholioMockRelationshipSource.php b/src/applications/search/relationship/PholioMockRelationshipSource.php index b378f8ef41..b21fd6624b 100644 --- a/src/applications/search/relationship/PholioMockRelationshipSource.php +++ b/src/applications/search/relationship/PholioMockRelationshipSource.php @@ -17,4 +17,10 @@ final class PholioMockRelationshipSource ); } + public function getFilters() { + $filters = parent::getFilters(); + unset($filters['assigned']); + return $filters; + } + } diff --git a/src/applications/search/storage/document/PhabricatorSearchDocument.php b/src/applications/search/storage/document/PhabricatorSearchDocument.php index 161e791316..3e177c9813 100644 --- a/src/applications/search/storage/document/PhabricatorSearchDocument.php +++ b/src/applications/search/storage/document/PhabricatorSearchDocument.php @@ -26,6 +26,9 @@ final class PhabricatorSearchDocument extends PhabricatorSearchDAO { 'documentCreated' => array( 'columns' => array('documentCreated'), ), + 'key_type' => array( + 'columns' => array('documentType', 'documentCreated'), + ), ), ) + parent::getConfiguration(); }