mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
settings: Focus "Add a new bot" tab when there is no active bot.
Fixes: #8872.
This commit is contained in:
@@ -9,6 +9,7 @@ set_global("page_params", {
|
|||||||
set_global("avatar", {});
|
set_global("avatar", {});
|
||||||
|
|
||||||
set_global('$', global.make_zjquery());
|
set_global('$', global.make_zjquery());
|
||||||
|
set_global('i18n', global.stub_i18n);
|
||||||
set_global('document', 'document-stub');
|
set_global('document', 'document-stub');
|
||||||
|
|
||||||
zrequire('bot_data');
|
zrequire('bot_data');
|
||||||
@@ -112,6 +113,7 @@ function test_create_bot_type_input_box_toggle(f) {
|
|||||||
global.compile_template('embedded_bot_config_item');
|
global.compile_template('embedded_bot_config_item');
|
||||||
avatar.build_bot_create_widget = function () {};
|
avatar.build_bot_create_widget = function () {};
|
||||||
avatar.build_bot_edit_widget = function () {};
|
avatar.build_bot_edit_widget = function () {};
|
||||||
|
settings_bots.setup_bot_creation_policy_values();
|
||||||
|
|
||||||
settings_bots.set_up();
|
settings_bots.set_up();
|
||||||
}());
|
}());
|
||||||
|
|||||||
@@ -55,7 +55,10 @@ function render_bots() {
|
|||||||
$('#active_bots_list').empty();
|
$('#active_bots_list').empty();
|
||||||
$('#inactive_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({
|
add_bot_row({
|
||||||
name: elem.full_name,
|
name: elem.full_name,
|
||||||
email: elem.email,
|
email: elem.email,
|
||||||
@@ -66,8 +69,17 @@ function render_bots() {
|
|||||||
is_active: elem.is_active,
|
is_active: elem.is_active,
|
||||||
zuliprc: 'zuliprc', // Most browsers do not allow filename starting with `.`
|
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")) {
|
if ($("#bots_lists_navbar .add-a-new-bot-tab").hasClass("active")) {
|
||||||
$("#add-a-new-bot-form").show();
|
$("#add-a-new-bot-form").show();
|
||||||
$("#active_bots_list").hide();
|
$("#active_bots_list").hide();
|
||||||
|
|||||||
Reference in New Issue
Block a user