@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Correct help for Typeahead Datasource Controls without functions

Summary:
Do not display an empty table of Functions and irrelevant instructions when the Typeahead Datasource Control does not support any typeahead functions in order to avoid confusion.

Closes T16169

Test Plan:
* Go to http://phorge.localhost/typeahead/help/PhabricatorPeopleUserFunctionDatasource/ and still see functions listed as expected (no change)
* Go to http://phorge.localhost/typeahead/help/ConpherenceThreadDatasource/ or http://phorge.localhost/typeahead/help/PhabricatorSearchDatasource/ and see much less text and instead information that this control does not support typeahead functions.

Reviewers: O1 Blessed Committers, mainframe98

Reviewed By: O1 Blessed Committers, mainframe98

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T16169

Differential Revision: https://we.phorge.it/D26176

+62 -55
+62 -55
src/applications/typeahead/controller/PhabricatorTypeaheadFunctionHelpController.php
··· 52 52 53 53 $title = pht('Typeahead Function Help'); 54 54 55 - $functions = $source->getAllDatasourceFunctions(); 56 - ksort($functions); 57 - 58 55 $content = array(); 59 56 60 57 $content[] = '= '.pht('Overview'); ··· 72 69 'to review which functions are available for that control.', 73 70 PhabricatorEnv::getDoclink('Search User Guide')); 74 71 75 - $table = array(); 72 + $content[] = '= '.pht('Function Quick Reference'); 76 73 77 - $table_header = array( 78 - pht('Function'), 79 - pht('Token Name'), 80 - pht('Summary'), 81 - ); 82 - $table[] = '| '.implode(' | ', $table_header).' |'; 83 - $table[] = '|---|---|---|'; 74 + $functions = $source->getAllDatasourceFunctions(); 75 + if (!$functions) { 76 + $content[] = pht( 77 + 'This control does not support typeahead functions.'); 78 + } else { 84 79 85 - foreach ($functions as $function => $spec) { 86 - $spec = $spec + array( 87 - 'summary' => null, 88 - 'arguments' => null, 80 + ksort($functions); 81 + 82 + $table = array(); 83 + 84 + $table_header = array( 85 + pht('Function'), 86 + pht('Token Name'), 87 + pht('Summary'), 89 88 ); 89 + $table[] = '| '.implode(' | ', $table_header).' |'; 90 + $table[] = '|---|---|---|'; 90 91 91 - if (idx($spec, 'arguments')) { 92 - $signature = '**'.$function.'(**//'.$spec['arguments'].'//**)**'; 93 - } else { 94 - $signature = '**'.$function.'()**'; 95 - } 92 + foreach ($functions as $function => $spec) { 93 + $spec = $spec + array( 94 + 'summary' => null, 95 + 'arguments' => null, 96 + ); 97 + 98 + if (idx($spec, 'arguments')) { 99 + $signature = '**'.$function.'(**//'.$spec['arguments'].'//**)**'; 100 + } else { 101 + $signature = '**'.$function.'()**'; 102 + } 96 103 97 - $name = idx($spec, 'name', ''); 98 - $summary = idx($spec, 'summary', ''); 104 + $name = idx($spec, 'name', ''); 105 + $summary = idx($spec, 'summary', ''); 99 106 100 - $table[] = '| '.$signature.' | '.$name.' | '.$summary.' |'; 101 - } 107 + $table[] = '| '.$signature.' | '.$name.' | '.$summary.' |'; 108 + } 102 109 103 - $table = implode("\n", $table); 104 - $content[] = '= '.pht('Function Quick Reference'); 105 - $content[] = pht( 106 - 'This table briefly describes available functions for this control. '. 107 - 'For details on a particular function, see the corresponding section '. 108 - 'below.'); 109 - $content[] = $table; 110 + $table = implode("\n", $table); 111 + $content[] = pht( 112 + 'This table briefly describes available functions for this control. '. 113 + 'For details on a particular function, see the corresponding section '. 114 + 'below.'); 115 + $content[] = $table; 110 116 111 - $content[] = '= '.pht('Using Typeahead Functions'); 112 - $content[] = pht( 113 - "In addition to typing user and project names to build queries, you can ". 114 - "also type the names of special functions which give you more options ". 115 - "and the ability to express more complex queries.\n\n". 116 - "Functions have an internal name (like `%s`) and a human-readable name, ". 117 - "like `Current Viewer`. In general, you can type either one to select ". 118 - "the function. You can also click the {nav icon=search} button on any ". 119 - "typeahead control to browse available functions and find this ". 120 - "documentation.\n\n". 121 - "This documentation uses the internal names to make it clear where ". 122 - "tokens begin and end. Specifically, you will find queries written ". 123 - "out like this in the documentation:\n\n%s\n\n". 124 - "When this query is actually shown in the control, it will look more ". 125 - "like this:\n\n%s", 126 - 'viewer()', 127 - '> viewer(), alincoln', 128 - '> {nav Current Viewer} {nav alincoln (Abraham Lincoln)}'); 117 + $content[] = '= '.pht('Using Typeahead Functions'); 118 + $content[] = pht( 119 + "In addition to typing user and project names to build queries, you ". 120 + "can also type the names of special functions which give you more ". 121 + "options and the ability to express more complex queries.\n\n". 122 + "Functions have an internal name (like `%s`) and a human-readable ". 123 + "name, like `Current Viewer`. In general, you can type either one to ". 124 + "select the function. You can also click the {nav icon=search} ". 125 + "button on any typeahead control to browse available functions and ". 126 + "find this documentation.\n\n". 127 + "This documentation uses the internal names to make it clear where ". 128 + "tokens begin and end. Specifically, you will find queries written ". 129 + "out like this in the documentation:\n\n%s\n\n". 130 + "When this query is actually shown in the control, it will look more ". 131 + "like this:\n\n%s", 132 + 'viewer()', 133 + '> viewer(), alincoln', 134 + '> {nav Current Viewer} {nav alincoln (Abraham Lincoln)}'); 129 135 130 136 131 - $middot = "\xC2\xB7"; 132 - foreach ($functions as $function => $spec) { 133 - $arguments = idx($spec, 'arguments', ''); 134 - $name = idx($spec, 'name'); 135 - $content[] = '= '.$function.'('.$arguments.') '.$middot.' '.$name; 136 - $content[] = $spec['description']; 137 + $middot = "\xC2\xB7"; 138 + foreach ($functions as $function => $spec) { 139 + $arguments = idx($spec, 'arguments', ''); 140 + $name = idx($spec, 'name'); 141 + $content[] = '= '.$function.'('.$arguments.') '.$middot.' '.$name; 142 + $content[] = $spec['description']; 143 + } 137 144 } 138 145 139 146 $content = implode("\n\n", $content);