From 1e3c10379a4b2190aacbc5e7054333b0fe081c93 Mon Sep 17 00:00:00 2001 From: Jason Ge Date: Fri, 7 Oct 2011 18:25:54 -0700 Subject: [PATCH] Enable typeahead's ondemand on details view page Summary: the details pages are using preload instead of ondemand for typeahead, but the most common actions on the pages are commenting which would not need the preloaded info. To improve the performance of the pages, turn on ondemand according to the setting in the config file. Test Plan: verify it is working with both modes, for both pages. Reviewers: epriestley, nh Reviewed By: epriestley CC: aran, epriestley Differential Revision: 995 --- .../addcomment/DifferentialAddCommentView.php | 2 ++ .../differential/view/addcomment/__init__.php | 1 + .../ManiphestTaskDetailController.php | 19 +++++++++++-------- .../controller/taskdetail/__init__.php | 1 + .../behavior-add-reviewers-and-ccs.js | 8 +++++++- .../behavior-transaction-controls.js | 8 +++++++- 6 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/applications/differential/view/addcomment/DifferentialAddCommentView.php b/src/applications/differential/view/addcomment/DifferentialAddCommentView.php index 036095c13e..a4b09f93d0 100644 --- a/src/applications/differential/view/addcomment/DifferentialAddCommentView.php +++ b/src/applications/differential/view/addcomment/DifferentialAddCommentView.php @@ -120,11 +120,13 @@ final class DifferentialAddCommentView extends AphrontView { 'tokenizer' => 'add-reviewers-tokenizer', 'src' => '/typeahead/common/users/', 'row' => 'add-reviewers', + 'ondemand' => PhabricatorEnv::getEnvConfig('tokenizer.ondemand'), ), 'add_ccs' => array( 'tokenizer' => 'add-ccs-tokenizer', 'src' => '/typeahead/common/mailable/', 'row' => 'add-ccs', + 'ondemand' => PhabricatorEnv::getEnvConfig('tokenizer.ondemand'), ), ), 'select' => 'comment-action', diff --git a/src/applications/differential/view/addcomment/__init__.php b/src/applications/differential/view/addcomment/__init__.php index 6ab7fb2cda..4ce14e0139 100644 --- a/src/applications/differential/view/addcomment/__init__.php +++ b/src/applications/differential/view/addcomment/__init__.php @@ -10,6 +10,7 @@ phutil_require_module('phabricator', 'applications/differential/constants/action phutil_require_module('phabricator', 'applications/differential/constants/lintstatus'); phutil_require_module('phabricator', 'applications/differential/constants/unitstatus'); phutil_require_module('phabricator', 'infrastructure/celerity/api'); +phutil_require_module('phabricator', 'infrastructure/env'); phutil_require_module('phabricator', 'infrastructure/javelin/api'); phutil_require_module('phabricator', 'view/base'); phutil_require_module('phabricator', 'view/form/base'); diff --git a/src/applications/maniphest/controller/taskdetail/ManiphestTaskDetailController.php b/src/applications/maniphest/controller/taskdetail/ManiphestTaskDetailController.php index 176f66afa3..a0a1ac1633 100644 --- a/src/applications/maniphest/controller/taskdetail/ManiphestTaskDetailController.php +++ b/src/applications/maniphest/controller/taskdetail/ManiphestTaskDetailController.php @@ -410,18 +410,21 @@ class ManiphestTaskDetailController extends ManiphestController { 'controlMap' => $control_map, 'tokenizers' => array( ManiphestTransactionType::TYPE_PROJECTS => array( - 'id' => 'projects-tokenizer', - 'src' => '/typeahead/common/projects/', + 'id' => 'projects-tokenizer', + 'src' => '/typeahead/common/projects/', + 'ondemand' => PhabricatorEnv::getEnvConfig('tokenizer.ondemand'), ), ManiphestTransactionType::TYPE_OWNER => array( - 'id' => 'assign-tokenizer', - 'src' => '/typeahead/common/users/', - 'value' => $default_claim, - 'limit' => 1, + 'id' => 'assign-tokenizer', + 'src' => '/typeahead/common/users/', + 'value' => $default_claim, + 'limit' => 1, + 'ondemand' => PhabricatorEnv::getEnvConfig('tokenizer.ondemand'), ), ManiphestTransactionType::TYPE_CCS => array( - 'id' => 'cc-tokenizer', - 'src' => '/typeahead/common/mailable/', + 'id' => 'cc-tokenizer', + 'src' => '/typeahead/common/mailable/', + 'ondemand' => PhabricatorEnv::getEnvConfig('tokenizer.ondemand'), ), ), )); diff --git a/src/applications/maniphest/controller/taskdetail/__init__.php b/src/applications/maniphest/controller/taskdetail/__init__.php index a8641f5343..53ac7baef7 100644 --- a/src/applications/maniphest/controller/taskdetail/__init__.php +++ b/src/applications/maniphest/controller/taskdetail/__init__.php @@ -21,6 +21,7 @@ phutil_require_module('phabricator', 'applications/markup/engine'); phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'infrastructure/celerity/api'); +phutil_require_module('phabricator', 'infrastructure/env'); phutil_require_module('phabricator', 'infrastructure/javelin/api'); phutil_require_module('phabricator', 'view/form/base'); phutil_require_module('phabricator', 'view/form/control/draganddropupload'); diff --git a/webroot/rsrc/js/application/differential/behavior-add-reviewers-and-ccs.js b/webroot/rsrc/js/application/differential/behavior-add-reviewers-and-ccs.js index e4759d4ea3..eb7fa521d2 100644 --- a/webroot/rsrc/js/application/differential/behavior-add-reviewers-and-ccs.js +++ b/webroot/rsrc/js/application/differential/behavior-add-reviewers-and-ccs.js @@ -11,7 +11,13 @@ JX.behavior('differential-add-reviewers-and-ccs', function(config) { function buildTokenizer(props) { var root = JX.$(props.tokenizer); - var datasource = new JX.TypeaheadPreloadedSource(props.src); + + var datasource; + if (props.ondemand) { + datasource = new JX.TypeaheadOnDemandSource(props.src); + } else { + datasource = new JX.TypeaheadPreloadedSource(props.src); + } var typeahead = new JX.Typeahead(root); typeahead.setDatasource(datasource); diff --git a/webroot/rsrc/js/application/maniphest/behavior-transaction-controls.js b/webroot/rsrc/js/application/maniphest/behavior-transaction-controls.js index 6a53bdb240..40f90a5849 100644 --- a/webroot/rsrc/js/application/maniphest/behavior-transaction-controls.js +++ b/webroot/rsrc/js/application/maniphest/behavior-transaction-controls.js @@ -14,7 +14,13 @@ JX.behavior('maniphest-transaction-controls', function(config) { for (var k in config.tokenizers) { var tconfig = config.tokenizers[k]; var root = JX.$(tconfig.id); - var datasource = new JX.TypeaheadPreloadedSource(tconfig.src); + + var datasource; + if (tconfig.ondemand) { + datasource = new JX.TypeaheadOnDemandSource(tconfig.src); + } else { + datasource = new JX.TypeaheadPreloadedSource(tconfig.src); + } var typeahead = new JX.Typeahead(root); typeahead.setDatasource(datasource);