diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -5,7 +5,6 @@ * @generated * @phutil-library-version 2 */ - phutil_register_library_map(array( '__library_version__' => 2, 'class' => @@ -544,6 +543,7 @@ 'DiffusionRenameHistoryQuery' => 'applications/diffusion/query/DiffusionRenameHistoryQuery.php', 'DiffusionRepositoryController' => 'applications/diffusion/controller/DiffusionRepositoryController.php', 'DiffusionRepositoryCreateController' => 'applications/diffusion/controller/DiffusionRepositoryCreateController.php', + 'DiffusionRepositoryDatasource' => 'applications/diffusion/typeahead/DiffusionRepositoryDatasource.php', 'DiffusionRepositoryDefaultController' => 'applications/diffusion/controller/DiffusionRepositoryDefaultController.php', 'DiffusionRepositoryEditActionsController' => 'applications/diffusion/controller/DiffusionRepositoryEditActionsController.php', 'DiffusionRepositoryEditActivateController' => 'applications/diffusion/controller/DiffusionRepositoryEditActivateController.php', @@ -3245,6 +3245,7 @@ 'DiffusionRefNotFoundException' => 'Exception', 'DiffusionRepositoryController' => 'DiffusionController', 'DiffusionRepositoryCreateController' => 'DiffusionRepositoryEditController', + 'DiffusionRepositoryDatasource' => 'PhabricatorTypeaheadDatasource', 'DiffusionRepositoryDefaultController' => 'DiffusionController', 'DiffusionRepositoryEditActionsController' => 'DiffusionRepositoryEditController', 'DiffusionRepositoryEditActivateController' => 'DiffusionRepositoryEditController', diff --git a/src/applications/differential/customfield/DifferentialRepositoryField.php b/src/applications/differential/customfield/DifferentialRepositoryField.php --- a/src/applications/differential/customfield/DifferentialRepositoryField.php +++ b/src/applications/differential/customfield/DifferentialRepositoryField.php @@ -49,7 +49,7 @@ return id(new AphrontFormTokenizerControl()) ->setName($this->getFieldKey()) - ->setDatasource('/typeahead/common/repositories/') + ->setDatasource(new DiffusionRepositoryDatasource()) ->setValue($control_value) ->setError($this->getFieldError()) ->setLabel($this->getFieldName()) diff --git a/src/applications/differential/query/DifferentialRevisionSearchEngine.php b/src/applications/differential/query/DifferentialRevisionSearchEngine.php --- a/src/applications/differential/query/DifferentialRevisionSearchEngine.php +++ b/src/applications/differential/query/DifferentialRevisionSearchEngine.php @@ -167,7 +167,7 @@ id(new AphrontFormTokenizerControl()) ->setLabel(pht('Repositories')) ->setName('repositories') - ->setDatasource('/typeahead/common/repositories/') + ->setDatasource(new DiffusionRepositoryDatasource()) ->setValue(array_select_keys($handles, $repository_phids))) ->appendChild( id(new AphrontFormSelectControl()) diff --git a/src/applications/diffusion/typeahead/DiffusionRepositoryDatasource.php b/src/applications/diffusion/typeahead/DiffusionRepositoryDatasource.php new file mode 100644 --- /dev/null +++ b/src/applications/diffusion/typeahead/DiffusionRepositoryDatasource.php @@ -0,0 +1,35 @@ +getViewer(); + $raw_query = $this->getRawQuery(); + + $results = array(); + + $repos = id(new PhabricatorRepositoryQuery()) + ->setViewer($viewer) + ->execute(); + foreach ($repos as $repo) { + $results[] = id(new PhabricatorTypeaheadResult()) + ->setName($repo->getMonogram().' '.$repo->getName()) + ->setURI('/diffusion/'.$repo->getCallsign().'/') + ->setPHID($repo->getPHID()) + ->setPriorityString($repo->getMonogram()) + ->setIcon('fa-database bluegrey'); + } + + return $results; + } + +} diff --git a/src/applications/herald/controller/HeraldRuleController.php b/src/applications/herald/controller/HeraldRuleController.php --- a/src/applications/herald/controller/HeraldRuleController.php +++ b/src/applications/herald/controller/HeraldRuleController.php @@ -592,7 +592,8 @@ 'source' => array( 'email' => '/typeahead/common/mailable/', 'user' => '/typeahead/common/accounts/', - 'repository' => '/typeahead/common/repositories/', + 'repository' => + id(new DiffusionRepositoryDatasource())->getDatasourceURI(), 'package' => '/typeahead/common/packages/', 'project' => '/typeahead/common/projects/', 'userorproject' => '/typeahead/common/accountsorprojects/', diff --git a/src/applications/repository/phid/PhabricatorRepositoryPHIDTypeRepository.php b/src/applications/repository/phid/PhabricatorRepositoryPHIDTypeRepository.php --- a/src/applications/repository/phid/PhabricatorRepositoryPHIDTypeRepository.php +++ b/src/applications/repository/phid/PhabricatorRepositoryPHIDTypeRepository.php @@ -33,12 +33,14 @@ foreach ($handles as $phid => $handle) { $repository = $objects[$phid]; + $monogram = $repository->getMonogram(); $callsign = $repository->getCallsign(); $name = $repository->getName(); - $handle->setName("r{$callsign}"); - $handle->setFullName("r{$callsign} ({$name})"); + $handle->setName($monogram); + $handle->setFullName("{$monogram} {$name}"); $handle->setURI("/diffusion/{$callsign}/"); + $handle->setIcon('fa-database'); } } diff --git a/src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php b/src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php --- a/src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php +++ b/src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php @@ -74,7 +74,7 @@ $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/repositories/') + ->setDatasource(new DiffusionRepositoryDatasource()) ->setName('repositories') ->setLabel(pht('Repositories')) ->setValue($repository_handles)) diff --git a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php --- a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php +++ b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php @@ -26,7 +26,6 @@ $need_applications = false; $need_lists = false; $need_projs = false; - $need_repos = false; $need_packages = false; $need_upforgrabs = false; $need_arcanist_projects = false; @@ -78,9 +77,6 @@ $need_projs = true; $need_packages = true; break; - case 'repositories': - $need_repos = true; - break; case 'packages': $need_packages = true; break; @@ -298,19 +294,6 @@ } } - if ($need_repos) { - $repos = id(new PhabricatorRepositoryQuery()) - ->setViewer($viewer) - ->execute(); - foreach ($repos as $repo) { - $results[] = id(new PhabricatorTypeaheadResult()) - ->setName('r'.$repo->getCallsign().' ('.$repo->getName().')') - ->setURI('/diffusion/'.$repo->getCallsign().'/') - ->setPHID($repo->getPHID()) - ->setPriorityString('r'.$repo->getCallsign()); - } - } - if ($need_packages) { $packages = id(new PhabricatorOwnersPackage())->loadAll(); foreach ($packages as $package) { diff --git a/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php b/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php --- a/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php +++ b/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php @@ -43,6 +43,10 @@ return $this->query; } + public function getDatasourceURI() { + return '/typeahead/class/'.get_class($this).'/'; + } + abstract public function getPlaceholderText(); abstract public function getDatasourceApplicationClass(); abstract public function loadResults(); diff --git a/src/view/form/control/AphrontFormTokenizerControl.php b/src/view/form/control/AphrontFormTokenizerControl.php --- a/src/view/form/control/AphrontFormTokenizerControl.php +++ b/src/view/form/control/AphrontFormTokenizerControl.php @@ -43,8 +43,10 @@ $id = celerity_generate_unique_node_id(); } - if (!$this->placeholder) { - $this->placeholder = $this->getDefaultPlaceholder(); + if (!strlen($this->placeholder)) { + $placeholder = $this->getDefaultPlaceholder(); + } else { + $placeholder = $this->placeholder; } $template = new AphrontTokenizerTemplateView(); @@ -57,15 +59,21 @@ $username = $this->user->getUsername(); } + if ($this->datasource instanceof PhabricatorTypeaheadDatasource) { + $datasource_uri = $this->datasource->getDatasourceURI(); + } else { + $datasource_uri = $this->datasource; + } + if (!$this->disableBehavior) { Javelin::initBehavior('aphront-basic-tokenizer', array( 'id' => $id, - 'src' => $this->datasource, + 'src' => $datasource_uri, 'value' => mpull($values, 'getFullName', 'getPHID'), 'icons' => mpull($values, 'getIcon', 'getPHID'), 'limit' => $this->limit, 'username' => $username, - 'placeholder' => $this->placeholder, + 'placeholder' => $placeholder, )); } @@ -75,6 +83,10 @@ private function getDefaultPlaceholder() { $datasource = $this->datasource; + if ($datasource instanceof PhabricatorTypeaheadDatasource) { + return $datasource->getPlaceholderText(); + } + $matches = null; if (!preg_match('@^/typeahead/common/(.*)/$@', $datasource, $matches)) { return null;