mirror of https://github.com/zulip/zulip.git
js: Break cyclic dependency between `admin.js` and `settings.js`.
There was a direct dependency between `admin.js` and `settings.js` which was due to the fact that we needed to call `build_page` of both modules in each other's `launch` function. This is solved by lifting those `build_page` calls up from both modules to `hashchange.js` which is the module which calls the `launch` function of both modules.
This commit is contained in:
parent
98176ddb57
commit
915b6cd9e7
|
@ -231,8 +231,6 @@ export function build_page() {
|
|||
}
|
||||
|
||||
export function launch(section) {
|
||||
settings.build_page();
|
||||
build_page();
|
||||
settings_sections.reset_sections();
|
||||
|
||||
settings.open_settings_overlay();
|
||||
|
|
|
@ -343,11 +343,15 @@ function do_hashchange_overlay(old_hash) {
|
|||
}
|
||||
|
||||
if (base === "settings") {
|
||||
settings.build_page();
|
||||
admin.build_page();
|
||||
settings.launch(section);
|
||||
return;
|
||||
}
|
||||
|
||||
if (base === "organization") {
|
||||
settings.build_page();
|
||||
admin.build_page();
|
||||
admin.launch(section);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import timezones from "../generated/timezones.json";
|
|||
import render_settings_overlay from "../templates/settings_overlay.hbs";
|
||||
import render_settings_tab from "../templates/settings_tab.hbs";
|
||||
|
||||
import * as admin from "./admin";
|
||||
import * as blueslip from "./blueslip";
|
||||
import * as browser_history from "./browser_history";
|
||||
import {$t, $t_html} from "./i18n";
|
||||
|
@ -134,8 +133,6 @@ export function open_settings_overlay() {
|
|||
}
|
||||
|
||||
export function launch(section) {
|
||||
build_page();
|
||||
admin.build_page();
|
||||
settings_sections.reset_sections();
|
||||
|
||||
open_settings_overlay();
|
||||
|
|
|
@ -125,11 +125,13 @@ function test_helper({override, change_tab}) {
|
|||
}
|
||||
|
||||
stub(admin, "launch");
|
||||
stub(admin, "build_page");
|
||||
stub(drafts, "launch");
|
||||
stub(message_viewport, "stop_auto_scrolling");
|
||||
stub(narrow, "deactivate");
|
||||
stub(overlays, "close_for_hash_change");
|
||||
stub(settings, "launch");
|
||||
stub(settings, "build_page");
|
||||
stub(stream_settings_ui, "launch");
|
||||
stub(ui_util, "blur_active_element");
|
||||
stub(ui_report, "error");
|
||||
|
@ -294,6 +296,8 @@ run_test("hash_interactions", ({override}) => {
|
|||
$window_stub.trigger("hashchange");
|
||||
helper.assert_events([
|
||||
[overlays, "close_for_hash_change"],
|
||||
[settings, "build_page"],
|
||||
[admin, "build_page"],
|
||||
[settings, "launch"],
|
||||
]);
|
||||
|
||||
|
@ -303,6 +307,8 @@ run_test("hash_interactions", ({override}) => {
|
|||
$window_stub.trigger("hashchange");
|
||||
helper.assert_events([
|
||||
[overlays, "close_for_hash_change"],
|
||||
[settings, "build_page"],
|
||||
[admin, "build_page"],
|
||||
[admin, "launch"],
|
||||
]);
|
||||
|
||||
|
|
Loading…
Reference in New Issue