diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 0dc58dbcee..360cfbbf80 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1719,6 +1719,7 @@ phutil_register_library_map(array( 'PhabricatorMacroCommentController' => 'applications/macro/controller/PhabricatorMacroCommentController.php', 'PhabricatorMacroConfigOptions' => 'applications/macro/config/PhabricatorMacroConfigOptions.php', 'PhabricatorMacroController' => 'applications/macro/controller/PhabricatorMacroController.php', + 'PhabricatorMacroDatasource' => 'applications/macro/typeahead/PhabricatorMacroDatasource.php', 'PhabricatorMacroDisableController' => 'applications/macro/controller/PhabricatorMacroDisableController.php', 'PhabricatorMacroEditController' => 'applications/macro/controller/PhabricatorMacroEditController.php', 'PhabricatorMacroEditor' => 'applications/macro/editor/PhabricatorMacroEditor.php', @@ -4565,6 +4566,7 @@ phutil_register_library_map(array( 'PhabricatorMacroCommentController' => 'PhabricatorMacroController', 'PhabricatorMacroConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorMacroController' => 'PhabricatorController', + 'PhabricatorMacroDatasource' => 'PhabricatorTypeaheadDatasource', 'PhabricatorMacroDisableController' => 'PhabricatorMacroController', 'PhabricatorMacroEditController' => 'PhabricatorMacroController', 'PhabricatorMacroEditor' => 'PhabricatorApplicationTransactionEditor', diff --git a/src/applications/macro/controller/PhabricatorMacroMemeDialogController.php b/src/applications/macro/controller/PhabricatorMacroMemeDialogController.php index 307290dd72..65ffd39991 100644 --- a/src/applications/macro/controller/PhabricatorMacroMemeDialogController.php +++ b/src/applications/macro/controller/PhabricatorMacroMemeDialogController.php @@ -50,7 +50,7 @@ final class PhabricatorMacroMemeDialogController ->setLabel(pht('Macro')) ->setName('macro') ->setLimit(1) - ->setDatasource('/typeahead/common/macros/') + ->setDatasource(new PhabricatorMacroDatasource()) ->setError($e_macro)) ->appendChild( id(new AphrontFormTextControl()) diff --git a/src/applications/macro/phid/PhabricatorMacroPHIDTypeMacro.php b/src/applications/macro/phid/PhabricatorMacroPHIDTypeMacro.php index 106d2c1af7..3c9aeb3ea0 100644 --- a/src/applications/macro/phid/PhabricatorMacroPHIDTypeMacro.php +++ b/src/applications/macro/phid/PhabricatorMacroPHIDTypeMacro.php @@ -12,6 +12,10 @@ final class PhabricatorMacroPHIDTypeMacro extends PhabricatorPHIDType { return pht('Image Macro'); } + public function getTypeIcon() { + return 'fa-meh-o'; + } + public function newObject() { return new PhabricatorFileImageMacro(); } diff --git a/src/applications/macro/typeahead/PhabricatorMacroDatasource.php b/src/applications/macro/typeahead/PhabricatorMacroDatasource.php new file mode 100644 index 0000000000..a6c84d9cce --- /dev/null +++ b/src/applications/macro/typeahead/PhabricatorMacroDatasource.php @@ -0,0 +1,35 @@ +getViewer(); + $raw_query = $this->getRawQuery(); + + $results = array(); + + $macros = id(new PhabricatorMacroQuery()) + ->setViewer($viewer) + ->withStatus(PhabricatorMacroQuery::STATUS_ACTIVE) + ->execute(); + + foreach ($macros as $macro) { + $results[] = id(new PhabricatorTypeaheadResult()) + ->setPHID($macro->getPHID()) + ->setName($macro->getName()) + ->setIcon('fa-meh-o bluegrey'); + } + + return $results; + } + +} diff --git a/src/applications/repository/phid/PhabricatorRepositoryPHIDTypeRepository.php b/src/applications/repository/phid/PhabricatorRepositoryPHIDTypeRepository.php index 922b4767b0..4b92c2d6b3 100644 --- a/src/applications/repository/phid/PhabricatorRepositoryPHIDTypeRepository.php +++ b/src/applications/repository/phid/PhabricatorRepositoryPHIDTypeRepository.php @@ -13,6 +13,10 @@ final class PhabricatorRepositoryPHIDTypeRepository return pht('Repository'); } + public function getTypeIcon() { + return 'fa-database'; + } + public function newObject() { return new PhabricatorRepository(); } @@ -40,7 +44,6 @@ final class PhabricatorRepositoryPHIDTypeRepository $handle->setName($monogram); $handle->setFullName("{$monogram} {$name}"); $handle->setURI("/diffusion/{$callsign}/"); - $handle->setIcon('fa-database'); } } diff --git a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php index c9c080913c..171500ef6f 100644 --- a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php +++ b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php @@ -34,7 +34,6 @@ final class PhabricatorTypeaheadCommonDatasourceController $need_jump_objects = false; $need_build_plans = false; $need_task_priority = false; - $need_macros = false; $need_legalpad_documents = false; switch ($this->type) { case 'mainsearch': @@ -89,9 +88,6 @@ final class PhabricatorTypeaheadCommonDatasourceController case 'taskpriority': $need_task_priority = true; break; - case 'macros': - $need_macros = true; - break; case 'legalpaddocuments': $need_legalpad_documents = true; break; @@ -243,19 +239,6 @@ final class PhabricatorTypeaheadCommonDatasourceController } } - if ($need_macros) { - $macros = id(new PhabricatorMacroQuery()) - ->setViewer($viewer) - ->withStatus(PhabricatorMacroQuery::STATUS_ACTIVE) - ->execute(); - $macros = mpull($macros, 'getName', 'getPHID'); - foreach ($macros as $phid => $name) { - $results[] = id(new PhabricatorTypeaheadResult()) - ->setPHID($phid) - ->setName($name); - } - } - if ($need_legalpad_documents) { $documents = id(new LegalpadDocumentQuery()) ->setViewer($viewer)