Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
bots: Fix error handling for API key requests.
Sahil Batrab1e384b48211
diff --git a/web/src/bot_helper.ts b/web/src/bot_helper.tsindex 0b5580f26b5..5590255c9ca 100644--- a/web/src/bot_helper.ts+++ b/web/src/bot_helper.ts@@ -5,6 +5,7 @@ import * as z from "zod/mini";import render_bot_api_key_details from "../templates/settings/bot_api_key_details.hbs";+import * as banners from "./banners.ts";import * as bot_data from "./bot_data.ts";import type {Bot} from "./bot_data.ts";import * as buttons from "./buttons.ts";@@ -15,7 +16,6 @@ import * as dialog_widget from "./dialog_widget.ts";import {$t_html} from "./i18n.ts";import * as scroll_util from "./scroll_util.ts";import {realm} from "./state_data.ts";-import * as ui_report from "./ui_report.ts";export function validate_bot_short_name(value: string): boolean {// Adapted from Django's EmailValidator@@ -76,7 +76,19 @@ export async function fetch_bot_api_key(const raw_data = await channel.get({url: `/json/bots/${bot_id}/api_key`,error(xhr) {- ui_report.error($t_html({defaultMessage: "Failed"}), xhr, $error_element);+ const error_message = channel.xhr_error_message(+ $t_html({defaultMessage: "Failed"}),+ xhr,+ );+ banners.open(+ {+ intent: "danger",+ label: error_message,+ buttons: [],+ close_button: false,+ },+ $error_element,+ );},});@@ -136,7 +148,7 @@ export async function show_api_key_modal(bot_id: number): Promise<void> {if (!api_key) {scroll_util.scroll_element_into_container($("#bot-edit-form-error"),- $("#user-profile-modal .modal__body"),+ $("#user-profile-modal .modal__content"),);return;}diff --git a/web/src/user_profile.ts b/web/src/user_profile.tsindex 9bea11f73bd..b65a0c466ce 100644--- a/web/src/user_profile.ts+++ b/web/src/user_profile.ts@@ -1129,7 +1129,7 @@ export function show_edit_bot_info_modal(user_id: number, $container: JQuery): vif (!api_key) {scroll_util.scroll_element_into_container($("#bot-edit-form-error"),- $("#user-profile-modal .modal__body"),+ $("#user-profile-modal .modal__content"),);return;}diff --git a/web/templates/settings/bot_list_admin.hbs b/web/templates/settings/bot_list_admin.hbsindex b2973fd225d..d22b898961f 100644--- a/web/templates/settings/bot_list_admin.hbs+++ b/web/templates/settings/bot_list_admin.hbs@@ -13,7 +13,7 @@</div><div class="tab-container"></div><div id="admin-all-bots-list" class="bot-settings-section user-or-bot-settings-section" data-bot-settings-section="all-bots">- <div class="bot-list-error alert"></div>+ <div class="bot-list-error banner-wrapper"></div>{{> bot_listsection_name="all_bots"section_title=(t "All bots")@@ -21,7 +21,7 @@}}</div><div id="admin-your-bots-list" class="bot-settings-section user-or-bot-settings-section" data-bot-settings-section="your-bots">- <div class="bot-list-error alert"></div>+ <div class="bot-list-error banner-wrapper"></div><div id="botserverrc-text-container" class="config-download-text"><span>{{t 'Download config of all active outgoing webhook bots in Zulip Botserver format.' }}</span><a type="submit" download="botserverrc" id= "hidden-botserverrc-download" hidden></a>