mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +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('drafts', 'launch');
|
||||||
stub('favicon', 'reset');
|
stub('favicon', 'reset');
|
||||||
stub('floating_recipient_bar', 'update');
|
stub('floating_recipient_bar', 'update');
|
||||||
stub('message_viewport', 'stop_auto_scrolling');
|
stub('message_viewport', 'stop_auto_scrolling');
|
||||||
stub('narrow', 'deactivate');
|
stub('narrow', 'deactivate');
|
||||||
stub('overlays', 'close_for_hash_change');
|
stub('overlays', 'close_for_hash_change');
|
||||||
stub('settings', 'setup_page');
|
stub('settings', 'launch');
|
||||||
stub('subs', 'launch');
|
stub('subs', 'launch');
|
||||||
stub('ui_util', 'blur_active_element');
|
stub('ui_util', 'blur_active_element');
|
||||||
|
|
||||||
@@ -268,8 +268,7 @@ run_test('hash_interactions', () => {
|
|||||||
window.onhashchange();
|
window.onhashchange();
|
||||||
helper.assert_events([
|
helper.assert_events([
|
||||||
'overlays.close_for_hash_change',
|
'overlays.close_for_hash_change',
|
||||||
'settings.setup_page',
|
'settings.launch',
|
||||||
'admin.setup_page',
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
window.location.hash = '#organization/user-list-admin';
|
window.location.hash = '#organization/user-list-admin';
|
||||||
@@ -278,8 +277,7 @@ run_test('hash_interactions', () => {
|
|||||||
window.onhashchange();
|
window.onhashchange();
|
||||||
helper.assert_events([
|
helper.assert_events([
|
||||||
'overlays.close_for_hash_change',
|
'overlays.close_for_hash_change',
|
||||||
'settings.setup_page',
|
'admin.launch',
|
||||||
'admin.setup_page',
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var called_back;
|
var called_back;
|
||||||
|
|||||||
@@ -75,28 +75,14 @@ exports.build_page = function () {
|
|||||||
admin_sections.reset_sections();
|
admin_sections.reset_sections();
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.setup_page = function () {
|
|
||||||
|
exports.launch = function (section) {
|
||||||
|
settings.build_page();
|
||||||
exports.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();
|
overlays.open_settings();
|
||||||
settings_panel_menu.org_settings.activate_section(section);
|
settings_panel_menu.org_settings.activate_section(section);
|
||||||
|
settings_toggle.highlight_toggle('organization');
|
||||||
};
|
};
|
||||||
|
|
||||||
return exports;
|
return exports;
|
||||||
|
|||||||
@@ -179,9 +179,21 @@ function do_hashchange_overlay(old_hash) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (/settings|organization/.test(base)) {
|
if (base === 'settings') {
|
||||||
settings.setup_page();
|
if (!section) {
|
||||||
admin.setup_page();
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -140,28 +140,13 @@ exports.build_page = function () {
|
|||||||
settings_sections.reset_sections();
|
settings_sections.reset_sections();
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.setup_page = function () {
|
exports.launch = function (section) {
|
||||||
exports.build_page();
|
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();
|
overlays.open_settings();
|
||||||
settings_panel_menu.normal_settings.activate_section(section);
|
settings_panel_menu.normal_settings.activate_section(section);
|
||||||
|
settings_toggle.highlight_toggle('settings');
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.set_settings_header = function (key) {
|
exports.set_settings_header = function (key) {
|
||||||
|
|||||||
Reference in New Issue
Block a user