From a9893fb6545beb755dfd54cfa4911de0d00341f5 Mon Sep 17 00:00:00 2001 From: Rishant Rokaha Date: Tue, 25 Oct 2022 13:39:16 -0400 Subject: [PATCH] settings: Add confirmation modal for reactivating a bot in personal settings. There's already a similar modal in organization settings, so this improves the consistency of the UI. Fixes #23281. --- static/js/settings_bots.js | 23 ++++++++++++++----- .../help/deactivate-or-reactivate-a-bot.md | 2 ++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/static/js/settings_bots.js b/static/js/settings_bots.js index 6038aecfb5..a6c678d449 100644 --- a/static/js/settings_bots.js +++ b/static/js/settings_bots.js @@ -19,6 +19,7 @@ import {$t, $t_html} from "./i18n"; import {page_params} from "./page_params"; import * as people from "./people"; import * as settings_config from "./settings_config"; +import * as settings_users from "./settings_users"; import * as ui_report from "./ui_report"; import * as user_profile from "./user_profile"; @@ -539,13 +540,23 @@ export function set_up() { $("#inactive_bots_list").on("click", "button.reactivate_bot", (e) => { const user_id = Number.parseInt($(e.currentTarget).attr("data-user-id"), 10); + e.stopPropagation(); + e.preventDefault(); - channel.post({ - url: "/json/users/" + encodeURIComponent(user_id) + "/reactivate", - error(xhr) { - bot_error(user_id, xhr); - }, - }); + function handle_confirm() { + channel.post({ + url: "/json/users/" + encodeURIComponent(user_id) + "/reactivate", + success() { + dialog_widget.close_modal(); + }, + error(xhr) { + ui_report.error($t_html({defaultMessage: "Failed"}), xhr, $("#dialog_error")); + dialog_widget.hide_dialog_spinner(); + }, + }); + } + + settings_users.confirm_reactivation(user_id, handle_confirm, true); }); $("#active_bots_list").on("click", "button.regenerate_bot_api_key", (e) => { diff --git a/templates/zerver/help/deactivate-or-reactivate-a-bot.md b/templates/zerver/help/deactivate-or-reactivate-a-bot.md index dab61f542c..a1f6f3b56e 100644 --- a/templates/zerver/help/deactivate-or-reactivate-a-bot.md +++ b/templates/zerver/help/deactivate-or-reactivate-a-bot.md @@ -55,6 +55,8 @@ bot, regardless of who owns them. 1. Click **Reactivate bot** on the profile card for the bot you want to reactivate. +1. Approve by clicking **Confirm**. + {tab|via-organization-settings} {settings_tab|bot-list-admin}