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.
This commit is contained in:
Sahil Batra
2024-09-23 15:31:26 +05:30
committed by Tim Abbott
parent 521bb1f722
commit 2094e899b8

View File

@@ -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,
});
});