mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 15:33:30 +00:00
user groups: Add support for removing user groups.
The new `#groups` overlay had no way for user groups to be deleted. This commit adds UI support for removing user groups along with adding support for live update of `#groups` overlay on remove event for user groups.
This commit is contained in:
committed by
Tim Abbott
parent
c0cd6f7f04
commit
1f03042a48
@@ -1,5 +1,6 @@
|
||||
import $ from "jquery";
|
||||
|
||||
import render_confirm_delete_user from "../templates/confirm_dialog/confirm_delete_user.hbs";
|
||||
import render_change_user_group_info_modal from "../templates/user_group_settings/change_user_group_info_modal.hbs";
|
||||
import render_user_group_settings from "../templates/user_group_settings/user_group_settings.hbs";
|
||||
|
||||
@@ -7,6 +8,7 @@ import * as blueslip from "./blueslip";
|
||||
import * as browser_history from "./browser_history";
|
||||
import * as channel from "./channel";
|
||||
import * as components from "./components";
|
||||
import * as confirm_dialog from "./confirm_dialog";
|
||||
import * as dialog_widget from "./dialog_widget";
|
||||
import * as hash_util from "./hash_util";
|
||||
import {$t, $t_html} from "./i18n";
|
||||
@@ -15,6 +17,7 @@ import * as people from "./people";
|
||||
import * as settings_data from "./settings_data";
|
||||
import * as settings_ui from "./settings_ui";
|
||||
import * as ui from "./ui";
|
||||
import * as ui_report from "./ui_report";
|
||||
import * as user_group_edit_members from "./user_group_edit_members";
|
||||
import * as user_group_ui_updates from "./user_group_ui_updates";
|
||||
import * as user_groups from "./user_groups";
|
||||
@@ -121,6 +124,19 @@ export function setup_group_settings(node) {
|
||||
show_settings_for(node);
|
||||
}
|
||||
|
||||
function open_right_panel_empty() {
|
||||
$(".group-row.active").removeClass("active");
|
||||
user_group_settings_ui.show_user_group_settings_pane.nothing_selected();
|
||||
browser_history.update("#groups");
|
||||
}
|
||||
|
||||
export function handle_deleted_group(group_id) {
|
||||
if (!hash_util.is_editing_group(group_id)) {
|
||||
return;
|
||||
}
|
||||
open_right_panel_empty();
|
||||
}
|
||||
|
||||
export function open_group_edit_panel_for_row(group_row) {
|
||||
const group = get_user_group_for_target(group_row);
|
||||
|
||||
@@ -164,6 +180,46 @@ export function initialize() {
|
||||
});
|
||||
});
|
||||
|
||||
$("#manage_groups_container").on("click", ".group_settings_header .btn-danger", () => {
|
||||
const active_group_data = user_group_settings_ui.get_active_data();
|
||||
const group_id = active_group_data.id;
|
||||
const user_group = user_groups.get_user_group_from_id(group_id);
|
||||
|
||||
if (!user_group || !can_edit(group_id)) {
|
||||
return;
|
||||
}
|
||||
function delete_user_group() {
|
||||
channel.del({
|
||||
url: "/json/user_groups/" + group_id,
|
||||
data: {
|
||||
id: group_id,
|
||||
},
|
||||
success() {
|
||||
active_group_data.$row.remove();
|
||||
},
|
||||
error(xhr) {
|
||||
ui_report.error(
|
||||
$t_html({defaultMessage: "Failed"}),
|
||||
xhr,
|
||||
$(".group_change_property_info"),
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const html_body = render_confirm_delete_user({
|
||||
group_name: user_group.name,
|
||||
});
|
||||
|
||||
const user_group_name = user_group.name;
|
||||
|
||||
confirm_dialog.launch({
|
||||
html_heading: $t_html({defaultMessage: "Delete {user_group_name}?"}, {user_group_name}),
|
||||
html_body,
|
||||
on_click: delete_user_group,
|
||||
});
|
||||
});
|
||||
|
||||
function save_group_info(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
Reference in New Issue
Block a user