mirror of
https://github.com/zulip/zulip.git
synced 2025-11-18 12:54:58 +00:00
settings: Streamline how we launch settings.
We can eliminate the janky `setup_page` methods and just pass in section from `hashchanged`. This sets us up to handle browser history more nicely when you load '#settings' and we could essentially redirect you to '#settings/your-account' (or similar things). A future commit will address that. We also use `launch` as the new entry point, which is more consistent with other modules.
This commit is contained in:
@@ -124,14 +124,14 @@ function test_helper() {
|
||||
};
|
||||
}
|
||||
|
||||
stub('admin', 'setup_page');
|
||||
stub('admin', 'launch');
|
||||
stub('drafts', 'launch');
|
||||
stub('favicon', 'reset');
|
||||
stub('floating_recipient_bar', 'update');
|
||||
stub('message_viewport', 'stop_auto_scrolling');
|
||||
stub('narrow', 'deactivate');
|
||||
stub('overlays', 'close_for_hash_change');
|
||||
stub('settings', 'setup_page');
|
||||
stub('settings', 'launch');
|
||||
stub('subs', 'launch');
|
||||
stub('ui_util', 'blur_active_element');
|
||||
|
||||
@@ -268,8 +268,7 @@ run_test('hash_interactions', () => {
|
||||
window.onhashchange();
|
||||
helper.assert_events([
|
||||
'overlays.close_for_hash_change',
|
||||
'settings.setup_page',
|
||||
'admin.setup_page',
|
||||
'settings.launch',
|
||||
]);
|
||||
|
||||
window.location.hash = '#organization/user-list-admin';
|
||||
@@ -278,8 +277,7 @@ run_test('hash_interactions', () => {
|
||||
window.onhashchange();
|
||||
helper.assert_events([
|
||||
'overlays.close_for_hash_change',
|
||||
'settings.setup_page',
|
||||
'admin.setup_page',
|
||||
'admin.launch',
|
||||
]);
|
||||
|
||||
var called_back;
|
||||
|
||||
@@ -75,28 +75,14 @@ exports.build_page = function () {
|
||||
admin_sections.reset_sections();
|
||||
};
|
||||
|
||||
exports.setup_page = function () {
|
||||
|
||||
exports.launch = function (section) {
|
||||
settings.build_page();
|
||||
exports.build_page();
|
||||
|
||||
var tab = (function () {
|
||||
var tab = false;
|
||||
var hash_sequence = window.location.hash.split(/\//);
|
||||
if (/#*(organization)/.test(hash_sequence[0])) {
|
||||
tab = hash_sequence[1];
|
||||
return tab || settings_panel_menu.org_settings.current_tab();
|
||||
}
|
||||
return tab;
|
||||
}());
|
||||
|
||||
if (tab) {
|
||||
exports.launch_page(tab);
|
||||
settings_toggle.highlight_toggle('organization');
|
||||
}
|
||||
};
|
||||
|
||||
exports.launch_page = function (section) {
|
||||
overlays.open_settings();
|
||||
settings_panel_menu.org_settings.activate_section(section);
|
||||
settings_toggle.highlight_toggle('organization');
|
||||
};
|
||||
|
||||
return exports;
|
||||
|
||||
@@ -179,9 +179,21 @@ function do_hashchange_overlay(old_hash) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (/settings|organization/.test(base)) {
|
||||
settings.setup_page();
|
||||
admin.setup_page();
|
||||
if (base === 'settings') {
|
||||
if (!section) {
|
||||
section = settings_panel_menu.normal_settings.current_tab();
|
||||
}
|
||||
|
||||
settings.launch(section);
|
||||
return;
|
||||
}
|
||||
|
||||
if (base === 'organization') {
|
||||
if (!section) {
|
||||
section = settings_panel_menu.org_settings.current_tab();
|
||||
}
|
||||
|
||||
admin.launch(section);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -140,28 +140,13 @@ exports.build_page = function () {
|
||||
settings_sections.reset_sections();
|
||||
};
|
||||
|
||||
exports.setup_page = function () {
|
||||
exports.launch = function (section) {
|
||||
exports.build_page();
|
||||
admin.build_page();
|
||||
|
||||
var tab = (function () {
|
||||
var tab = false;
|
||||
var hash_sequence = window.location.hash.split(/\//);
|
||||
if (/#*(settings)/.test(hash_sequence[0])) {
|
||||
tab = hash_sequence[1];
|
||||
return tab || settings_panel_menu.normal_settings.current_tab();
|
||||
}
|
||||
return tab;
|
||||
}());
|
||||
|
||||
if (tab) {
|
||||
exports.launch_page(tab);
|
||||
settings_toggle.highlight_toggle('settings');
|
||||
}
|
||||
};
|
||||
|
||||
exports.launch_page = function (section) {
|
||||
overlays.open_settings();
|
||||
settings_panel_menu.normal_settings.activate_section(section);
|
||||
settings_toggle.highlight_toggle('settings');
|
||||
};
|
||||
|
||||
exports.set_settings_header = function (key) {
|
||||
|
||||
Reference in New Issue
Block a user