From 2094e899b8fce9bea73409883aa2af6ae76dd9f8 Mon Sep 17 00:00:00 2001 From: Sahil Batra Date: Mon, 23 Sep 2024 15:31:26 +0530 Subject: [PATCH] user_groups: Show deactivation error in modal itself. Previously, the error was shown besides the group name after the modal was closed, but it did not look good for long error messages like the one we get when the group being deactivated is being used for a setting. Updated the code to use dialog_widget.submit_api_request since it takes care of showing the error inside the modal and also added code to show loading spinner as the modal is not closed immediately to show the error. --- web/src/user_group_edit.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/web/src/user_group_edit.js b/web/src/user_group_edit.js index 200b7d8fce..4b8bf4079d 100644 --- a/web/src/user_group_edit.js +++ b/web/src/user_group_edit.js @@ -26,7 +26,6 @@ import * as settings_org from "./settings_org"; import {current_user, realm} from "./state_data"; import * as stream_data from "./stream_data"; import * as timerender from "./timerender"; -import * as ui_report from "./ui_report"; import * as user_group_components from "./user_group_components"; import * as user_group_create from "./user_group_create"; import * as user_group_edit_members from "./user_group_edit_members"; @@ -919,19 +918,13 @@ export function initialize() { return; } function deactivate_user_group() { - channel.post({ - url: "/json/user_groups/" + group_id + "/deactivate", - success() { + const url = "/json/user_groups/" + group_id + "/deactivate"; + const opts = { + success_continuation() { active_group_data.$row.remove(); }, - error(xhr) { - ui_report.error( - $t_html({defaultMessage: "Failed"}), - xhr, - $(".group_change_property_info"), - ); - }, - }); + }; + dialog_widget.submit_api_request(channel.post, url, {}, opts); } const html_body = render_confirm_delete_user({ @@ -947,6 +940,8 @@ export function initialize() { ), html_body, on_click: deactivate_user_group, + close_on_submit: false, + loading_spinner: true, }); });