Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
org_settings: Add main feature to change bot role.
somesh2026ef8cdb38018
diff --git a/static/js/settings_users.js b/static/js/settings_users.jsindex 773639b1438..b6ddd6aaed0 100644--- a/static/js/settings_users.js+++ b/static/js/settings_users.js@@ -645,16 +645,20 @@ function handle_bot_form($tbody) {user_id,email: bot.email,full_name: bot.full_name,+ user_role_values: settings_config.user_role_values,+ disable_role_dropdown: bot.is_owner && !page_params.is_owner,});let owner_widget;function submit_bot_details() {+ const role = Number.parseInt($("#bot-role-select").val().trim(), 10);const $full_name = $("#dialog_widget_modal").find("input[name='full_name']");const url = "/json/bots/" + encodeURIComponent(user_id);const data = {full_name: $full_name.val(),+ role: JSON.stringify(role),};if (owner_widget === undefined) {@@ -668,7 +672,7 @@ function handle_bot_form($tbody) {dialog_widget.submit_api_request(channel.patch, url, data);}- function get_bot_owner_widget() {+ function get_bot_owner_widget_and_set_role_values() {const owner_id = bot_data.get(user_id).owner_id;const user_ids = people.get_active_human_ids();@@ -687,6 +691,17 @@ function handle_bot_form($tbody) {// organizations with 10Ks of users.owner_widget = new DropdownListWidget(opts);owner_widget.setup();++ $("#bot-role-select").val(bot.role);+ if (!page_params.is_owner) {+ $("#bot-role-select")+ .find(+ `option[value="${CSS.escape(+ settings_config.user_role_values.owner.code,+ )}"]`,+ )+ .hide();+ }}dialog_widget.launch({@@ -694,7 +709,7 @@ function handle_bot_form($tbody) {html_body,id: "edit_bot_modal",on_click: submit_bot_details,- post_render: get_bot_owner_widget,+ post_render: get_bot_owner_widget_and_set_role_values,});});}diff --git a/static/templates/settings/admin_bot_form.hbs b/static/templates/settings/admin_bot_form.hbsindex 2e62556cc7e..d015c8285cf 100644--- a/static/templates/settings/admin_bot_form.hbs+++ b/static/templates/settings/admin_bot_form.hbs@@ -13,6 +13,14 @@<label for="user_id">{{t "User ID" }}</label><input type="text" autocomplete="off" name="user_id" value="{{ user_id }}" readonly/></div>+ <div class="input-group">+ <label class="input-label" for="bot-role-select">{{t 'Role' }}+ {{> ../help_link_widget link="/help/roles-and-permissions" }}+ </label>+ <select name="bot-role-select" id="bot-role-select" data-setting-widget-type="number" {{#if disable_role_dropdown}}disabled{{/if}}>+ {{> dropdown_options_widget option_values=user_role_values}}+ </select>+ </div><div class="input-group edit_bot_owner_container"><label for="bot_owner_select">{{t "Owner" }}</label>{{> dropdown_list_widget