1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00

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

View file

@ -496,7 +496,7 @@ final class HeraldRuleController extends HeraldController {
'default' => PhabricatorRepositoryPushLog::CHANGEFLAG_ADD,
),
),
'template' => $this->buildTokenizerTemplates() + array(
'template' => $this->buildTokenizerTemplates($handles) + array(
'rules' => $all_rules,
),
'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 = $template->render();
@ -597,6 +597,8 @@ final class HeraldRuleController extends HeraldController {
'taskpriority' => '/typeahead/common/taskpriority/',
'arcanistprojects' => '/typeahead/common/arcanistprojects/',
),
'username' => $this->getRequest()->getUser()->getUserName(),
'icons' => mpull($handles, 'getTypeIcon', 'getPHID'),
'markup' => $template,
);
}

View file

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