Herald - make tokenizers have the purdy icons

Summary: ...use the prefab stuff as it does fancier things than we were doing. Only trick then really is to pass username and the map of handle phids => icons to the client so prefab can work nicely. Fixes T4775.

Test Plan: made a herald rule with projects and users. Saw nice icons. Reloaded page and still saw nice icons.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T4775

Differential Revision: https://secure.phabricator.com/D8749
This commit is contained in:
Bob Trahan
2014-04-10 12:38:15 -07:00
parent facd3ea8ef
commit 4b56dbed3a
3 changed files with 31 additions and 36 deletions

View File

@@ -379,7 +379,7 @@ return array(
'rsrc/js/application/files/behavior-icon-composer.js' => '8ef9ab58', 'rsrc/js/application/files/behavior-icon-composer.js' => '8ef9ab58',
'rsrc/js/application/files/behavior-launch-icon-composer.js' => '48086888', 'rsrc/js/application/files/behavior-launch-icon-composer.js' => '48086888',
'rsrc/js/application/harbormaster/behavior-reorder-steps.js' => '957a7fde', 'rsrc/js/application/harbormaster/behavior-reorder-steps.js' => '957a7fde',
'rsrc/js/application/herald/HeraldRuleEditor.js' => '4173dbd8', 'rsrc/js/application/herald/HeraldRuleEditor.js' => '6291cf4a',
'rsrc/js/application/herald/PathTypeahead.js' => 'f7fc67ec', 'rsrc/js/application/herald/PathTypeahead.js' => 'f7fc67ec',
'rsrc/js/application/herald/herald-rule-editor.js' => '7ebaeed3', 'rsrc/js/application/herald/herald-rule-editor.js' => '7ebaeed3',
'rsrc/js/application/maniphest/behavior-batch-editor.js' => 'fe80fb6d', 'rsrc/js/application/maniphest/behavior-batch-editor.js' => 'fe80fb6d',
@@ -522,7 +522,7 @@ return array(
'global-drag-and-drop-css' => '697324ad', 'global-drag-and-drop-css' => '697324ad',
'harbormaster-css' => 'cec833b7', 'harbormaster-css' => 'cec833b7',
'herald-css' => '59d48f01', 'herald-css' => '59d48f01',
'herald-rule-editor' => '4173dbd8', 'herald-rule-editor' => '6291cf4a',
'herald-test-css' => '2b7d0f54', 'herald-test-css' => '2b7d0f54',
'inline-comment-summary-css' => '14a91639', 'inline-comment-summary-css' => '14a91639',
'javelin-aphlict' => '493665ee', 'javelin-aphlict' => '493665ee',
@@ -1054,19 +1054,6 @@ return array(
0 => 'javelin-install', 0 => 'javelin-install',
1 => 'javelin-event', 1 => 'javelin-event',
), ),
'4173dbd8' =>
array(
0 => 'multirow-row-manager',
1 => 'javelin-install',
2 => 'javelin-typeahead',
3 => 'javelin-util',
4 => 'javelin-dom',
5 => 'javelin-tokenizer',
6 => 'javelin-typeahead-preloaded-source',
7 => 'javelin-stratcom',
8 => 'javelin-json',
9 => 'phabricator-prefab',
),
'441f2137' => '441f2137' =>
array( array(
0 => 'javelin-behavior', 0 => 'javelin-behavior',
@@ -1202,12 +1189,15 @@ return array(
2 => 'javelin-util', 2 => 'javelin-util',
3 => 'phabricator-shaped-request', 3 => 'phabricator-shaped-request',
), ),
'62e18640' => '6291cf4a' =>
array( array(
0 => 'javelin-install', 0 => 'multirow-row-manager',
1 => 'javelin-util', 1 => 'javelin-install',
2 => 'javelin-dom', 2 => 'javelin-util',
3 => 'javelin-typeahead-normalizer', 3 => 'javelin-dom',
4 => 'javelin-stratcom',
5 => 'javelin-json',
6 => 'phabricator-prefab',
), ),
'6453c869' => '6453c869' =>
array( array(
@@ -1242,6 +1232,13 @@ return array(
0 => 'javelin-behavior', 0 => 'javelin-behavior',
1 => 'javelin-dom', 1 => 'javelin-dom',
), ),
'62e18640' =>
array(
0 => 'javelin-install',
1 => 'javelin-util',
2 => 'javelin-dom',
3 => 'javelin-typeahead-normalizer',
),
'75903ee1' => '75903ee1' =>
array( array(
0 => 'javelin-behavior', 0 => 'javelin-behavior',

View File

@@ -496,7 +496,7 @@ final class HeraldRuleController extends HeraldController {
'default' => PhabricatorRepositoryPushLog::CHANGEFLAG_ADD, 'default' => PhabricatorRepositoryPushLog::CHANGEFLAG_ADD,
), ),
), ),
'template' => $this->buildTokenizerTemplates() + array( 'template' => $this->buildTokenizerTemplates($handles) + array(
'rules' => $all_rules, 'rules' => $all_rules,
), ),
'author' => array($rule->getAuthorPHID() => 'author' => array($rule->getAuthorPHID() =>
@@ -581,7 +581,7 @@ final class HeraldRuleController extends HeraldController {
} }
protected function buildTokenizerTemplates() { protected function buildTokenizerTemplates(array $handles) {
$template = new AphrontTokenizerTemplateView(); $template = new AphrontTokenizerTemplateView();
$template = $template->render(); $template = $template->render();
@@ -597,6 +597,8 @@ final class HeraldRuleController extends HeraldController {
'taskpriority' => '/typeahead/common/taskpriority/', 'taskpriority' => '/typeahead/common/taskpriority/',
'arcanistprojects' => '/typeahead/common/arcanistprojects/', 'arcanistprojects' => '/typeahead/common/arcanistprojects/',
), ),
'username' => $this->getRequest()->getUser()->getUserName(),
'icons' => mpull($handles, 'getTypeIcon', 'getPHID'),
'markup' => $template, 'markup' => $template,
); );
} }

View File

@@ -1,11 +1,8 @@
/** /**
* @requires multirow-row-manager * @requires multirow-row-manager
* javelin-install * javelin-install
* javelin-typeahead
* javelin-util * javelin-util
* javelin-dom * javelin-dom
* javelin-tokenizer
* javelin-typeahead-preloaded-source
* javelin-stratcom * javelin-stratcom
* javelin-json * javelin-json
* phabricator-prefab * phabricator-prefab
@@ -284,25 +281,24 @@ JX.install('HeraldRuleEditor', {
template = template.firstChild; template = template.firstChild;
template.id = ''; template.id = '';
var datasource = new JX.TypeaheadPreloadedSource( var tokenizerConfig = {
this._config.template.source[type]); root : template,
src : this._config.template.source[type],
icons : this._config.template.icons,
username : this._config.username
};
var typeahead = new JX.Typeahead(template); var build = JX.Prefab.buildTokenizer(tokenizerConfig);
typeahead.setDatasource(datasource); build.tokenizer.start();
var tokenizer = new JX.Tokenizer(template);
tokenizer.setLimit(limit);
tokenizer.setTypeahead(typeahead);
tokenizer.start();
return [ return [
template, template,
function() { function() {
return tokenizer.getTokens(); return build.tokenizer.getTokens();
}, },
function(map) { function(map) {
for (var k in map) { for (var k in map) {
tokenizer.addToken(k, map[k]); build.tokenizer.addToken(k, map[k]);
} }
}]; }];
}, },