Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

group_settings: Show relevant groups in left panel.

tnmkr9275a8ded4f7
diff --git a/web/src/hashchange.js b/web/src/hashchange.js
index 50e39da8425..4e2811437f7 100644
--- a/web/src/hashchange.js
+++ b/web/src/hashchange.js
@@ -64,6 +64,13 @@ function show_all_message_view() {
});
}
+function is_somebody_else_profile_open() {
+ return (
+ user_profile.get_user_id_if_user_profile_modal_open() !== undefined &&
+ user_profile.get_user_id_if_user_profile_modal_open() !== people.my_current_user_id()
+ );
+}
+
export function set_hash_to_home_view() {
let home_view_hash = `#${user_settings.web_home_view}`;
if (home_view_hash === "#recent_topics") {
@@ -277,7 +284,7 @@ function do_hashchange_overlay(old_hash) {
if (base === "groups") {
const right_side_tab = hash_parser.get_current_nth_hash_section(3);
- user_group_edit.change_state(section, right_side_tab);
+ user_group_edit.change_state(section, undefined, right_side_tab);
}
if (base === "settings") {
@@ -345,7 +352,17 @@ function do_hashchange_overlay(old_hash) {
if (base === "groups") {
const right_side_tab = hash_parser.get_current_nth_hash_section(3);
- user_group_edit.launch(section, right_side_tab);
+
+ if (is_somebody_else_profile_open()) {
+ user_group_edit.launch(section, "all-groups", right_side_tab);
+ return;
+ }
+
+ // We pass left_side_tab as undefined in change_state to
+ // select the tab based on user's membership. "My groups" is
+ // selected if user is a member of group being edited.
+ // Otherwise "All groups" is selected.
+ user_group_edit.launch(section, undefined, right_side_tab);
return;
}
diff --git a/web/src/user_group_edit.js b/web/src/user_group_edit.js
index fc8292a322b..fc86238e3b7 100644
--- a/web/src/user_group_edit.js
+++ b/web/src/user_group_edit.js
@@ -555,7 +555,7 @@ export function update_group(group_id) {
}
}
-export function change_state(section, right_side_tab) {
+export function change_state(section, left_side_tab, right_side_tab) {
if (section === "new") {
do_open_create_user_group();
redraw_user_group_list();
@@ -573,11 +573,22 @@ export function change_state(section, right_side_tab) {
const group_id = Number.parseInt(section, 10);
const group = user_groups.get_user_group_from_id(group_id);
show_right_section();
- // We show the list of user groups in the left panel
- // based on the tab that is active. It is `your-groups`
- // tab by default.
- redraw_user_group_list();
select_tab = right_side_tab;
+
+ if (left_side_tab === undefined) {
+ left_side_tab = "all-groups";
+ if (user_groups.is_direct_member_of(current_user.user_id, group_id)) {
+ left_side_tab = "your-groups";
+ }
+ }
+
+ // Callback to .goto() will update browser_history unless a
+ // group is being edited. We are always editing a group here
+ // so its safe to call
+ if (left_side_tab !== group_list_toggler.value()) {
+ set_active_group_id(group.id);
+ group_list_toggler.goto(left_side_tab);
+ }
switch_to_group_row(group);
return;
}
@@ -954,7 +965,7 @@ export function initialize() {
);
}
-export function launch(section, right_side_tab) {
+export function launch(section, left_side_tab, right_side_tab) {
setup_page(() => {
overlays.open_overlay({
name: "group_subscriptions",
@@ -963,7 +974,7 @@ export function launch(section, right_side_tab) {
browser_history.exit_overlay();
},
});
- change_state(section, right_side_tab);
+ change_state(section, left_side_tab, right_side_tab);
});
if (!get_active_data().id) {
if (section === "new") {