Index: src/applications/macro/controller/PhabricatorMacroMemeDialogController.php =================================================================== --- src/applications/macro/controller/PhabricatorMacroMemeDialogController.php +++ src/applications/macro/controller/PhabricatorMacroMemeDialogController.php @@ -7,20 +7,20 @@ $request = $this->getRequest(); $user = $request->getUser(); - $name = $request->getStr('macro'); + $phid = head($request->getArr('macro')); $above = $request->getStr('above'); $below = $request->getStr('below'); $e_macro = true; $errors = array(); if ($request->isDialogFormPost()) { - if (!$name) { + if (!$phid) { $e_macro = pht('Required'); $errors[] = pht('Macro name is required.'); } else { $macro = id(new PhabricatorMacroQuery()) ->setViewer($user) - ->withNames(array($name)) + ->withPHIDs(array($phid)) ->executeOne(); if (!$macro) { $e_macro = pht('Invalid'); @@ -31,7 +31,7 @@ if (!$errors) { $options = new PhutilSimpleOptions(); $data = array( - 'src' => $name, + 'src' => $macro->getName(), 'above' => $above, 'below' => $below, ); @@ -46,10 +46,11 @@ $view = id(new PHUIFormLayoutView()) ->appendChild( - id(new AphrontFormTextControl()) + id(new AphrontFormTokenizerControl()) ->setLabel(pht('Macro')) ->setName('macro') - ->setValue($name) + ->setLimit(1) + ->setDatasource('/typeahead/common/macros/') ->setError($e_macro)) ->appendChild( id(new AphrontFormTextControl()) Index: src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php =================================================================== --- src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php +++ src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php @@ -36,6 +36,7 @@ $need_symbols = false; $need_jump_objects = false; $need_build_plans = false; + $need_macros = false; switch ($this->type) { case 'mainsearch': $need_users = true; @@ -97,6 +98,9 @@ case 'buildplans': $need_build_plans = true; break; + case 'macros': + $need_macros = true; + break; } $results = array(); @@ -113,6 +117,7 @@ ->setPHID(ManiphestTaskOwner::PROJECT_NO_PROJECT); } + if ($need_users) { $columns = array( 'isSystemAgent', @@ -234,6 +239,19 @@ } } + 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_projs) { $projs = id(new PhabricatorProjectQuery()) ->setViewer($viewer) Index: src/view/form/control/AphrontFormTokenizerControl.php =================================================================== --- src/view/form/control/AphrontFormTokenizerControl.php +++ src/view/form/control/AphrontFormTokenizerControl.php @@ -97,6 +97,7 @@ 'packages' => pht('Type a package name...'), 'arcanistproject' => pht('Type an arc project name...'), 'accountsorprojects' => pht('Type a user or project name...'), + 'macros' => pht('Type a macro name...'), ); return idx($map, $request);