Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15397612
D7658.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D7658.id.diff
View Options
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);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Mar 17, 9:19 PM (2 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7654976
Default Alt Text
D7658.id.diff (3 KB)
Attached To
Mode
D7658: Turn the macro selector into a tokenizer
Attached
Detach File
Event Timeline
Log In to Comment