From af214ecb657902de8dd4199ea493295a92115b70 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 21 Jul 2014 06:44:27 -0700 Subject: [PATCH] Fix rendering of project slugs in tokenizer UI Summary: Fixes T5659. When building a token after a user selection, we currently use the `value` as the token text, but sometimes that's an internal name which doesn't make much sense to users. For projects, it is now "sluga slugb Proper Display Name". If available, use `displayName` instead. Test Plan: Typed some projects into a tokenizer, got display names only. Reviewers: chad, joshuaspence Reviewed By: joshuaspence Subscribers: epriestley Maniphest Tasks: T5659 Differential Revision: https://secure.phabricator.com/D9996 --- resources/celerity/map.php | 30 +++++++++++++++--------------- src/__phutil_library_map__.php | 1 + webroot/rsrc/js/core/Prefab.js | 15 ++++++++------- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 5b9539dd00..f0e0f31fe6 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -8,7 +8,7 @@ return array( 'names' => array( 'core.pkg.css' => 'c2c68e64', - 'core.pkg.js' => 'dc4959a8', + 'core.pkg.js' => 'ba6a742f', 'darkconsole.pkg.js' => 'df001cab', 'differential.pkg.css' => '4a93db37', 'differential.pkg.js' => '7528cfc9', @@ -450,7 +450,7 @@ return array( 'rsrc/js/core/KeyboardShortcutManager.js' => 'ad7a69ca', 'rsrc/js/core/MultirowRowManager.js' => '41e47dea', 'rsrc/js/core/Notification.js' => '0c6946e7', - 'rsrc/js/core/Prefab.js' => 'c11bac49', + 'rsrc/js/core/Prefab.js' => 'bbae734c', 'rsrc/js/core/ShapedRequest.js' => '7cbe244b', 'rsrc/js/core/TextAreaUtils.js' => 'b3ec3cfc', 'rsrc/js/core/ToolTip.js' => '3915d490', @@ -737,7 +737,7 @@ return array( 'phabricator-notification-menu-css' => '8ae4a008', 'phabricator-object-selector-css' => '029a133d', 'phabricator-phtize' => 'd254d646', - 'phabricator-prefab' => 'c11bac49', + 'phabricator-prefab' => 'bbae734c', 'phabricator-profile-css' => 'b459416e', 'phabricator-remarkup-css' => 'ad4c0676', 'phabricator-search-results-css' => 'f240504c', @@ -1626,6 +1626,18 @@ return array( 1 => 'javelin-stratcom', 2 => 'javelin-dom', ), + 'bbae734c' => array( + 0 => 'javelin-install', + 1 => 'javelin-util', + 2 => 'javelin-dom', + 3 => 'javelin-typeahead', + 4 => 'javelin-tokenizer', + 5 => 'javelin-typeahead-preloaded-source', + 6 => 'javelin-typeahead-ondemand-source', + 7 => 'javelin-dom', + 8 => 'javelin-stratcom', + 9 => 'javelin-util', + ), 'bd4c8dca' => array( 0 => 'javelin-install', 1 => 'javelin-util', @@ -1652,18 +1664,6 @@ return array( 2 => 'javelin-util', 3 => 'phabricator-shaped-request', ), - 'c11bac49' => array( - 0 => 'javelin-install', - 1 => 'javelin-util', - 2 => 'javelin-dom', - 3 => 'javelin-typeahead', - 4 => 'javelin-tokenizer', - 5 => 'javelin-typeahead-preloaded-source', - 6 => 'javelin-typeahead-ondemand-source', - 7 => 'javelin-dom', - 8 => 'javelin-stratcom', - 9 => 'javelin-util', - ), 'c4569c05' => array( 0 => 'javelin-magical-init', 1 => 'javelin-install', diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 86ff4fc8cc..5fdf42a6fc 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -4610,6 +4610,7 @@ phutil_register_library_map(array( 'PhabricatorMetaMTAMailingList' => array( 0 => 'PhabricatorMetaMTADAO', 1 => 'PhabricatorPolicyInterface', + 2 => 'PhabricatorDestructableInterface', ), 'PhabricatorMetaMTAMemberQuery' => 'PhabricatorQuery', 'PhabricatorMetaMTAPermanentFailureException' => 'Exception', diff --git a/webroot/rsrc/js/core/Prefab.js b/webroot/rsrc/js/core/Prefab.js index 7f87b8c7a8..0cf2b5b8b3 100644 --- a/webroot/rsrc/js/core/Prefab.js +++ b/webroot/rsrc/js/core/Prefab.js @@ -155,19 +155,20 @@ JX.install('Prefab', { var tokenizer = new JX.Tokenizer(root); tokenizer.setTypeahead(typeahead); tokenizer.setRenderTokenCallback(function(value, key) { - var icon = datasource.getResult(key); - if (icon) { - icon = icon.icon; + var result = datasource.getResult(key); + + var icon; + if (result) { + icon = result.icon; + value = result.displayName; } else { icon = config.icons[key]; } - if (!icon) { - return value; + if (icon) { + icon = JX.Prefab._renderIcon(icon); } - icon = JX.Prefab._renderIcon(icon); - // TODO: Maybe we should render these closed tags in grey? Figure out // how we're going to use color.