mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
settings: Call maybe_disable_widgets() in set_up() methods.
We now rely on set_up() methods to call their own module-specific versions of maybe_disable_widgets() in the codepath for admin_sections.load_admin_section(). And then for live updates, we just explicitly call all four modules that support maybe_disable_widgets(). This should make switching between sections slightly faster, and it also reduces the risk of module A messing with module B's state. (Granted, we have lots of other ways that modules can mess with each other's state.)
This commit is contained in:
@@ -689,6 +689,7 @@ run_test('set_up', () => {
|
||||
|
||||
// TEST set_up() here, but this mostly just allows us to
|
||||
// get access to the click handlers.
|
||||
settings_org.maybe_disable_widgets = noop;
|
||||
settings_org.set_up();
|
||||
|
||||
verify_realm_domains();
|
||||
|
||||
@@ -6,12 +6,23 @@ zrequire('user_events');
|
||||
set_global('activity', {
|
||||
redraw: function () {},
|
||||
});
|
||||
|
||||
set_global('settings_filters', {
|
||||
maybe_disable_widgets: function () {},
|
||||
});
|
||||
set_global('settings_org', {
|
||||
maybe_disable_widgets: function () {},
|
||||
});
|
||||
set_global('settings_profile_fields', {
|
||||
maybe_disable_widgets: function () {},
|
||||
});
|
||||
set_global('settings_streams', {
|
||||
maybe_disable_widgets: function () {},
|
||||
});
|
||||
set_global('settings_users', {
|
||||
update_user_data: function () {},
|
||||
});
|
||||
set_global('admin_sections', {
|
||||
maybe_disable_widgets: function () {},
|
||||
});
|
||||
|
||||
set_global('gear_menu', {
|
||||
update_org_settings_menu_item: function () {},
|
||||
});
|
||||
|
||||
@@ -4,13 +4,6 @@ var exports = {};
|
||||
|
||||
var is_loaded = new Dict(); // section -> bool
|
||||
|
||||
exports.maybe_disable_widgets = function () {
|
||||
settings_org.maybe_disable_widgets();
|
||||
settings_streams.maybe_disable_widgets();
|
||||
settings_filters.maybe_disable_widgets();
|
||||
settings_profile_fields.maybe_disable_widgets();
|
||||
};
|
||||
|
||||
exports.load_admin_section = function (name) {
|
||||
var section;
|
||||
|
||||
@@ -85,8 +78,6 @@ exports.load_admin_section = function (name) {
|
||||
return;
|
||||
}
|
||||
|
||||
exports.maybe_disable_widgets();
|
||||
|
||||
is_loaded.set(section, true);
|
||||
};
|
||||
|
||||
|
||||
@@ -44,6 +44,11 @@ exports.populate_filters = function (filters_data) {
|
||||
};
|
||||
|
||||
exports.set_up = function () {
|
||||
exports.build_page();
|
||||
exports.maybe_disable_widgets();
|
||||
};
|
||||
|
||||
exports.build_page = function () {
|
||||
meta.loaded = true;
|
||||
|
||||
// create loading indicators
|
||||
|
||||
@@ -548,6 +548,11 @@ exports.change_save_button_state = function ($element, state) {
|
||||
};
|
||||
|
||||
exports.set_up = function () {
|
||||
exports.build_page();
|
||||
exports.maybe_disable_widgets();
|
||||
};
|
||||
|
||||
exports.build_page = function () {
|
||||
meta.loaded = true;
|
||||
|
||||
loading.make_indicator($('#admin_page_auth_methods_loading_indicator'));
|
||||
|
||||
@@ -351,7 +351,11 @@ function set_up_choices_field() {
|
||||
}
|
||||
|
||||
exports.set_up = function () {
|
||||
exports.build_page();
|
||||
exports.maybe_disable_widgets();
|
||||
};
|
||||
|
||||
exports.build_page = function () {
|
||||
// create loading indicators
|
||||
loading.make_indicator($('#admin_page_profile_fields_loading_indicator'));
|
||||
// Populate profile_fields table
|
||||
|
||||
@@ -109,6 +109,11 @@ exports.delete_default_stream = function (stream_name, default_stream_row, alert
|
||||
};
|
||||
|
||||
exports.set_up = function () {
|
||||
exports.build_page();
|
||||
exports.maybe_disable_widgets();
|
||||
};
|
||||
|
||||
exports.build_page = function () {
|
||||
meta.loaded = true;
|
||||
|
||||
exports.update_default_streams_table();
|
||||
|
||||
@@ -58,7 +58,10 @@ exports.update_person = function update(person) {
|
||||
if (people.is_my_user_id(person.user_id)) {
|
||||
page_params.is_admin = person.is_admin;
|
||||
gear_menu.update_org_settings_menu_item();
|
||||
admin_sections.maybe_disable_widgets();
|
||||
settings_filters.maybe_disable_widgets();
|
||||
settings_org.maybe_disable_widgets();
|
||||
settings_profile_fields.maybe_disable_widgets();
|
||||
settings_streams.maybe_disable_widgets();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user