refactor: Export settings_bots.render_bots().

We also now call this explicitly when we need to
re-render (instead of triggering a custom event).
This commit is contained in:
Steve Howell
2018-07-02 18:06:09 +00:00
committed by Tim Abbott
parent b938523592
commit 26b48b95dc
4 changed files with 6 additions and 10 deletions

View File

@@ -1,10 +1,9 @@
zrequire('people'); zrequire('people');
zrequire('bot_data'); zrequire('bot_data');
set_global('$', () => { set_global('settings_bots', {
return {trigger: () => {}}; render_bots: () => {},
}); });
set_global('document', null);
const page_params = { const page_params = {
realm_bots: [{email: 'bot0@zulip.com', user_id: 42, full_name: 'Bot 0'}, realm_bots: [{email: 'bot0@zulip.com', user_id: 42, full_name: 'Bot 0'},

View File

@@ -16,7 +16,6 @@ set_global("avatar", {});
set_global('$', global.make_zjquery()); set_global('$', global.make_zjquery());
set_global('i18n', global.stub_i18n); set_global('i18n', global.stub_i18n);
set_global('document', 'document-stub');
zrequire('bot_data'); zrequire('bot_data');
zrequire('settings_bots'); zrequire('settings_bots');

View File

@@ -12,7 +12,7 @@ var bot_data = (function () {
'config_data', 'service_name', 'token']; 'config_data', 'service_name', 'token'];
var send_change_event = _.debounce(function () { var send_change_event = _.debounce(function () {
$(document).trigger('zulip.bot_data_changed'); settings_bots.render_bots();
}, 50); }, 50);
var set_can_admin = function bot_data__set_can_admin(bot) { var set_can_admin = function bot_data__set_can_admin(bot) {

View File

@@ -51,7 +51,7 @@ exports.type_id_to_string = function (type_id) {
return i18n.t(name); return i18n.t(name);
}; };
function render_bots() { exports.render_bots = function () {
$('#active_bots_list').empty(); $('#active_bots_list').empty();
$('#inactive_bots_list').empty(); $('#inactive_bots_list').empty();
@@ -92,7 +92,7 @@ function render_bots() {
$("#active_bots_list").hide(); $("#active_bots_list").hide();
$("#inactive_bots_list").show(); $("#inactive_bots_list").show();
} }
} };
exports.generate_zuliprc_uri = function (bot_id) { exports.generate_zuliprc_uri = function (bot_id) {
var bot = bot_data.get(bot_id); var bot = bot_data.get(bot_id);
@@ -208,9 +208,7 @@ exports.set_up = function () {
$(this).attr("href", "data:application/octet-stream;charset=utf-8," + encodeURIComponent(content)); $(this).attr("href", "data:application/octet-stream;charset=utf-8," + encodeURIComponent(content));
}); });
// TODO: render bots xxxx exports.render_bots();
render_bots();
$(document).on('zulip.bot_data_changed', render_bots);
$.validator.addMethod("bot_local_part", $.validator.addMethod("bot_local_part",
function (value, element) { function (value, element) {