settings: Focus "Add a new bot" tab when there is no active bot.

Fixes: #8872.
This commit is contained in:
Shubham Dhama
2018-03-30 01:41:32 +05:30
parent 0ef195ecc2
commit aca2364455
2 changed files with 15 additions and 1 deletions

View File

@@ -55,7 +55,10 @@ function render_bots() {
$('#active_bots_list').empty();
$('#inactive_bots_list').empty();
_.each(bot_data.get_all_bots_for_current_user(), function (elem) {
var all_bots_for_current_user = bot_data.get_all_bots_for_current_user();
var user_owns_an_active_bot = false;
_.each(all_bots_for_current_user, function (elem) {
add_bot_row({
name: elem.full_name,
email: elem.email,
@@ -66,8 +69,17 @@ function render_bots() {
is_active: elem.is_active,
zuliprc: 'zuliprc', // Most browsers do not allow filename starting with `.`
});
user_owns_an_active_bot = user_owns_an_active_bot || elem.is_active;
});
if (page_params.is_admin || page_params.realm_bot_creation_policy !==
exports.bot_creation_policy_values.admins_only.code) {
if (!user_owns_an_active_bot) {
focus_tab.add_a_new_bot_tab();
return;
}
}
if ($("#bots_lists_navbar .add-a-new-bot-tab").hasClass("active")) {
$("#add-a-new-bot-form").show();
$("#active_bots_list").hide();