mirror of https://github.com/zulip/zulip.git
settings: Pass handle_confirm function as argument to confirm_deactivation.
We pass handle_confirm function as an argument to confirm_deactivation because we will use confirm_deactivation to deactivate the user from user-info popover and the popover case will have a different handle_confirm function (which is called after clicking "Confirm" button of the modal) since error handling in that case will be different as there will be no overlay in the background.
This commit is contained in:
parent
1490c91011
commit
0a27c38af7
|
@ -424,7 +424,7 @@ function get_human_profile_data(fields_user_pills) {
|
|||
return new_profile_data;
|
||||
}
|
||||
|
||||
function confirm_deactivation(row, user_id, status_field) {
|
||||
function confirm_deactivation(user_id, handle_confirm) {
|
||||
const user = people.get_by_user_id(user_id);
|
||||
const opts = {
|
||||
username: user.full_name,
|
||||
|
@ -432,22 +432,6 @@ function confirm_deactivation(row, user_id, status_field) {
|
|||
};
|
||||
const html_body = render_settings_deactivation_user_modal(opts);
|
||||
|
||||
function handle_confirm() {
|
||||
const row = get_user_info_row(user_id);
|
||||
const row_deactivate_button = row.find("button.deactivate");
|
||||
row_deactivate_button.prop("disabled", true).text($t({defaultMessage: "Working…"}));
|
||||
const opts = {
|
||||
success_continuation() {
|
||||
update_view_on_deactivate(row);
|
||||
},
|
||||
error_continuation() {
|
||||
row_deactivate_button.text($t({defaultMessage: "Deactivate"}));
|
||||
},
|
||||
};
|
||||
const url = "/json/users/" + encodeURIComponent(user_id);
|
||||
settings_ui.do_settings_change(channel.del, url, {}, status_field, opts);
|
||||
}
|
||||
|
||||
confirm_dialog.launch({
|
||||
html_heading: $t_html({defaultMessage: "Deactivate {name}"}, {name: user.full_name}),
|
||||
html_body,
|
||||
|
@ -464,7 +448,24 @@ function handle_deactivation(tbody, status_field) {
|
|||
|
||||
const row = $(e.target).closest(".user_row");
|
||||
const user_id = row.data("user-id");
|
||||
confirm_deactivation(row, user_id, status_field);
|
||||
|
||||
function handle_confirm() {
|
||||
const row = get_user_info_row(user_id);
|
||||
const row_deactivate_button = row.find("button.deactivate");
|
||||
row_deactivate_button.prop("disabled", true).text($t({defaultMessage: "Working…"}));
|
||||
const opts = {
|
||||
success_continuation() {
|
||||
update_view_on_deactivate(row);
|
||||
},
|
||||
error_continuation() {
|
||||
row_deactivate_button.text($t({defaultMessage: "Deactivate"}));
|
||||
},
|
||||
};
|
||||
const url = "/json/users/" + encodeURIComponent(user_id);
|
||||
settings_ui.do_settings_change(channel.del, url, {}, status_field, opts);
|
||||
}
|
||||
|
||||
confirm_deactivation(user_id, handle_confirm);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue