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.

settings: Store current tab value in current_tab.

Shubham Padia78630b63955f
diff --git a/web/src/admin.js b/web/src/admin.js
index 9e41f6f49bf..1cff238c574 100644
--- a/web/src/admin.js
+++ b/web/src/admin.js
@@ -280,6 +280,8 @@ export function launch(section) {
settings_sections.reset_sections();
settings.open_settings_overlay();
- settings_panel_menu.org_settings.activate_section_or_default(section);
+ if (section !== "") {
+ settings_panel_menu.org_settings.set_current_tab(section);
+ }
settings_toggle.highlight_toggle("organization");
}
diff --git a/web/src/hashchange.js b/web/src/hashchange.js
index 1558f49cfde..584eea3b641 100644
--- a/web/src/hashchange.js
+++ b/web/src/hashchange.js
@@ -284,7 +284,7 @@ function do_hashchange_overlay(old_hash) {
window.history.replaceState(
null,
"",
- browser_history.get_full_url(base + "/" + settings_panel_object.current_tab()),
+ browser_history.get_full_url(base + "/" + settings_panel_object.current_tab),
);
}
@@ -366,9 +366,9 @@ function do_hashchange_overlay(old_hash) {
settings_hashes.has(base) && settings_hashes.has(old_base) && overlays.settings_open();
if (is_hashchange_internal) {
if (base === "settings") {
- settings_panel_menu.normal_settings.activate_section_or_default(section);
+ settings_panel_menu.normal_settings.set_current_tab(section);
} else {
- settings_panel_menu.org_settings.activate_section_or_default(section);
+ settings_panel_menu.org_settings.set_current_tab(section);
}
settings_toggle.highlight_toggle(base);
return;
diff --git a/web/src/settings.js b/web/src/settings.js
index 606ad7d4804..6b2a4d66759 100644
--- a/web/src/settings.js
+++ b/web/src/settings.js
@@ -161,7 +161,9 @@ export function launch(section) {
settings_sections.reset_sections();
open_settings_overlay();
- settings_panel_menu.normal_settings.activate_section_or_default(section);
+ if (section !== "") {
+ settings_panel_menu.normal_settings.set_current_tab(section);
+ }
settings_toggle.highlight_toggle("settings");
}
diff --git a/web/src/settings_panel_menu.js b/web/src/settings_panel_menu.js
index 96059d34f6a..9edd34dddbf 100644
--- a/web/src/settings_panel_menu.js
+++ b/web/src/settings_panel_menu.js
@@ -49,6 +49,7 @@ export class SettingsPanelMenu {
this.$main_elem = opts.$main_elem;
this.hash_prefix = opts.hash_prefix;
this.$curr_li = this.$main_elem.children("li").eq(0);
+ this.current_tab = this.$curr_li.data("section");
this.$main_elem.on("click", "li[data-section]", (e) => {
const section = $(e.currentTarget).attr("data-section");
@@ -64,7 +65,7 @@ export class SettingsPanelMenu {
show() {
this.$main_elem.show();
- const section = this.current_tab();
+ const section = this.current_tab;
if (two_column_mode()) {
// In one column mode want to show the settings list, not the first settings section.
this.activate_section_or_default(section);
@@ -76,10 +77,6 @@ export class SettingsPanelMenu {
this.$main_elem.hide();
}
- current_tab() {
- return this.$curr_li.data("section");
- }
-
li_for_section(section) {
const $li = $(`#settings_overlay_container li[data-section='${CSS.escape(section)}']`);
return $li;
@@ -123,6 +120,10 @@ export class SettingsPanelMenu {
return true;
}
+ set_current_tab(tab) {
+ this.current_tab = tab;
+ }
+
activate_section_or_default(section) {
popovers.hide_all();
if (!section) {
@@ -130,7 +131,7 @@ export class SettingsPanelMenu {
if (two_column_mode()) {
// In two column mode we resume to the last active section.
- section = this.current_tab();
+ section = this.current_tab;
} else {
// In single column mode we close the active section
// so that you always start at the settings list.
@@ -143,13 +144,14 @@ export class SettingsPanelMenu {
if ($li_for_section.length === 0) {
// This happens when there is no such section or the user does not have
// permission to view that section.
- section = this.current_tab();
+ section = this.current_tab;
} else {
this.$curr_li = $li_for_section;
}
this.$main_elem.children("li").removeClass("active");
this.$curr_li.addClass("active");
+ this.set_current_tab(section);
const settings_section_hash = "#" + this.hash_prefix + section;