mirror of https://github.com/zulip/zulip.git
user groups: Add support for user group update event.
This commit is contained in:
parent
6147f2bd7a
commit
c0cd6f7f04
|
@ -239,13 +239,22 @@ run_test("user groups", ({override}) => {
|
||||||
event = event_fixtures.user_group__update;
|
event = event_fixtures.user_group__update;
|
||||||
{
|
{
|
||||||
const stub = make_stub();
|
const stub = make_stub();
|
||||||
|
const user_group_settings_ui_stub = make_stub();
|
||||||
|
|
||||||
override(user_groups, "update", stub.f);
|
override(user_groups, "update", stub.f);
|
||||||
|
override(user_groups_settings_ui, "update_group", user_group_settings_ui_stub.f);
|
||||||
|
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
assert.equal(stub.num_calls, 1);
|
assert.equal(stub.num_calls, 1);
|
||||||
const args = stub.get_args("event");
|
assert.equal(user_group_settings_ui_stub.num_calls, 1);
|
||||||
|
|
||||||
|
let args = stub.get_args("event");
|
||||||
assert_same(args.event.group_id, event.group_id);
|
assert_same(args.event.group_id, event.group_id);
|
||||||
assert_same(args.event.data.name, event.data.name);
|
assert_same(args.event.data.name, event.data.name);
|
||||||
assert_same(args.event.data.description, event.data.description);
|
assert_same(args.event.data.description, event.data.description);
|
||||||
|
|
||||||
|
args = user_group_settings_ui_stub.get_args("group_id");
|
||||||
|
assert_same(args.group_id, event.group_id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -776,6 +776,7 @@ export function dispatch_normal_event(event) {
|
||||||
break;
|
break;
|
||||||
case "update":
|
case "update":
|
||||||
user_groups.update(event);
|
user_groups.update(event);
|
||||||
|
user_groups_settings_ui.update_group(event.group_id);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
blueslip.error("Unexpected event type user_group/" + event.op);
|
blueslip.error("Unexpected event type user_group/" + event.op);
|
||||||
|
|
|
@ -80,6 +80,12 @@ function show_membership_settings(group) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function update_settings_pane(group) {
|
||||||
|
const $edit_container = get_edit_container(group);
|
||||||
|
$edit_container.find(".group-name").text(group.name);
|
||||||
|
$edit_container.find(".group-description").text(group.description);
|
||||||
|
}
|
||||||
|
|
||||||
export function show_settings_for(node) {
|
export function show_settings_for(node) {
|
||||||
const group = get_user_group_for_target(node);
|
const group = get_user_group_for_target(node);
|
||||||
const html = render_user_group_settings({
|
const html = render_user_group_settings({
|
||||||
|
|
|
@ -133,6 +133,24 @@ export function add_group_to_table(group) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function update_group(group_id) {
|
||||||
|
if (!overlays.groups_open()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const group = user_groups.get_user_group_from_id(group_id);
|
||||||
|
const $group_row = row_for_group_id(group_id);
|
||||||
|
// update left side pane
|
||||||
|
$group_row.find(".group-name").text(group.name);
|
||||||
|
$group_row.find(".description").text(group.description);
|
||||||
|
|
||||||
|
if (get_active_data().id === group.id) {
|
||||||
|
// update right side pane
|
||||||
|
user_group_edit.update_settings_pane(group);
|
||||||
|
// update settings title
|
||||||
|
$("#groups_overlay .user-group-info-title").text(group.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function change_state(section) {
|
export function change_state(section) {
|
||||||
if (!section) {
|
if (!section) {
|
||||||
show_user_group_settings_pane.nothing_selected();
|
show_user_group_settings_pane.nothing_selected();
|
||||||
|
|
Loading…
Reference in New Issue