mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 20:10:55 +01:00
Modernize "macro" typeahead datasource
Summary: Ref T4420. Make this modern. Test Plan: - Used typeahead in remarkup comment area to select macro "derpdog". Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4420 Differential Revision: https://secure.phabricator.com/D9875
This commit is contained in:
parent
34628002fd
commit
a2caea13d6
6 changed files with 46 additions and 19 deletions
|
@ -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',
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorMacroDatasource
|
||||
extends PhabricatorTypeaheadDatasource {
|
||||
|
||||
public function getPlaceholderText() {
|
||||
return pht('Type a macro name...');
|
||||
}
|
||||
|
||||
public function getDatasourceApplicationClass() {
|
||||
return 'PhabricatorApplicationMacro';
|
||||
}
|
||||
|
||||
public function loadResults() {
|
||||
$viewer = $this->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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue