2021-02-28 01:19:36 +01:00
|
|
|
import * as alert_words_ui from "./alert_words_ui";
|
|
|
|
import * as attachments_ui from "./attachments_ui";
|
2021-03-16 23:38:59 +01:00
|
|
|
import * as blueslip from "./blueslip";
|
2021-02-28 01:19:36 +01:00
|
|
|
import * as settings_account from "./settings_account";
|
|
|
|
import * as settings_bots from "./settings_bots";
|
|
|
|
import * as settings_display from "./settings_display";
|
2021-02-28 01:19:58 +01:00
|
|
|
import * as settings_emoji from "./settings_emoji";
|
2021-02-28 01:20:19 +01:00
|
|
|
import * as settings_exports from "./settings_exports";
|
2021-02-28 01:22:20 +01:00
|
|
|
import * as settings_invites from "./settings_invites";
|
2021-02-28 01:21:57 +01:00
|
|
|
import * as settings_linkifiers from "./settings_linkifiers";
|
2021-02-28 01:19:36 +01:00
|
|
|
import * as settings_muting from "./settings_muting";
|
|
|
|
import * as settings_notifications from "./settings_notifications";
|
2021-02-28 01:20:46 +01:00
|
|
|
import * as settings_org from "./settings_org";
|
2021-02-28 21:34:05 +01:00
|
|
|
import * as settings_profile_fields from "./settings_profile_fields";
|
2021-02-28 01:21:35 +01:00
|
|
|
import * as settings_streams from "./settings_streams";
|
2021-02-28 01:22:43 +01:00
|
|
|
import * as settings_user_groups from "./settings_user_groups";
|
2021-02-28 01:21:11 +01:00
|
|
|
import * as settings_users from "./settings_users";
|
2021-02-10 17:06:24 +01:00
|
|
|
|
2020-02-03 09:39:58 +01:00
|
|
|
const load_func_dict = new Map(); // group -> function
|
2020-02-01 04:50:07 +01:00
|
|
|
const loaded_groups = new Set();
|
2018-12-08 19:28:26 +01:00
|
|
|
|
2021-02-28 01:19:36 +01:00
|
|
|
export function get_group(section) {
|
2018-12-08 19:28:26 +01:00
|
|
|
// Sometimes several sections all share the same code.
|
|
|
|
|
|
|
|
switch (section) {
|
2020-07-15 02:14:03 +02:00
|
|
|
case "organization-profile":
|
|
|
|
case "organization-settings":
|
|
|
|
case "organization-permissions":
|
|
|
|
case "auth-methods":
|
|
|
|
return "org_misc";
|
2018-12-08 19:28:26 +01:00
|
|
|
|
2020-07-15 02:14:03 +02:00
|
|
|
case "bot-list-admin":
|
|
|
|
return "org_bots";
|
2020-05-09 20:06:14 +02:00
|
|
|
|
2020-07-15 02:14:03 +02:00
|
|
|
case "user-list-admin":
|
|
|
|
case "deactivated-users-admin":
|
|
|
|
return "org_users";
|
2018-12-08 19:28:26 +01:00
|
|
|
|
2020-07-15 02:14:03 +02:00
|
|
|
default:
|
|
|
|
return section;
|
2018-12-08 19:28:26 +01:00
|
|
|
}
|
2021-02-28 01:19:36 +01:00
|
|
|
}
|
2017-04-07 01:30:13 +02:00
|
|
|
|
2021-02-28 01:19:36 +01:00
|
|
|
export function initialize() {
|
2018-12-08 19:28:26 +01:00
|
|
|
// personal
|
2020-07-15 01:29:15 +02:00
|
|
|
load_func_dict.set("your-account", settings_account.set_up);
|
|
|
|
load_func_dict.set("display-settings", settings_display.set_up);
|
|
|
|
load_func_dict.set("notifications", settings_notifications.set_up);
|
|
|
|
load_func_dict.set("your-bots", settings_bots.set_up);
|
|
|
|
load_func_dict.set("alert-words", alert_words_ui.set_up_alert_words);
|
|
|
|
load_func_dict.set("uploaded-files", attachments_ui.set_up_attachments);
|
|
|
|
load_func_dict.set("muted-topics", settings_muting.set_up);
|
2018-12-08 19:28:26 +01:00
|
|
|
|
|
|
|
// org
|
2020-07-15 01:29:15 +02:00
|
|
|
load_func_dict.set("org_misc", settings_org.set_up);
|
|
|
|
load_func_dict.set("org_bots", settings_users.set_up_bots);
|
|
|
|
load_func_dict.set("org_users", settings_users.set_up_humans);
|
|
|
|
load_func_dict.set("emoji-settings", settings_emoji.set_up);
|
|
|
|
load_func_dict.set("default-streams-list", settings_streams.set_up);
|
2021-03-13 18:15:14 +01:00
|
|
|
load_func_dict.set("linkifier-settings", settings_linkifiers.set_up);
|
2020-07-15 01:29:15 +02:00
|
|
|
load_func_dict.set("invites-list-admin", settings_invites.set_up);
|
|
|
|
load_func_dict.set("user-groups-admin", settings_user_groups.set_up);
|
|
|
|
load_func_dict.set("profile-field-settings", settings_profile_fields.set_up);
|
|
|
|
load_func_dict.set("data-exports-admin", settings_exports.set_up);
|
2021-02-28 01:19:36 +01:00
|
|
|
}
|
2017-04-07 01:30:13 +02:00
|
|
|
|
2021-02-28 01:19:36 +01:00
|
|
|
export function load_settings_section(section) {
|
|
|
|
const group = get_group(section);
|
2018-12-08 19:28:26 +01:00
|
|
|
|
|
|
|
if (!load_func_dict.has(group)) {
|
2020-07-15 01:29:15 +02:00
|
|
|
blueslip.error("Unknown section " + section);
|
2017-04-07 01:30:13 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-02-01 04:50:07 +01:00
|
|
|
if (loaded_groups.has(group)) {
|
2018-12-08 19:28:26 +01:00
|
|
|
// We only load groups once (unless somebody calls
|
2017-04-07 01:30:13 +02:00
|
|
|
// reset_sections).
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-11-02 00:06:25 +01:00
|
|
|
const load_func = load_func_dict.get(group);
|
2017-04-07 01:30:13 +02:00
|
|
|
|
|
|
|
// Do the real work here!
|
|
|
|
load_func();
|
2020-02-01 04:50:07 +01:00
|
|
|
loaded_groups.add(group);
|
2021-02-28 01:19:36 +01:00
|
|
|
}
|
2017-04-07 01:30:13 +02:00
|
|
|
|
2021-02-28 01:19:36 +01:00
|
|
|
export function reset_sections() {
|
2020-02-01 04:50:07 +01:00
|
|
|
loaded_groups.clear();
|
2018-12-08 19:28:26 +01:00
|
|
|
settings_emoji.reset();
|
2019-04-09 21:49:07 +02:00
|
|
|
settings_exports.reset();
|
2018-12-17 21:28:25 +01:00
|
|
|
settings_linkifiers.reset();
|
2018-12-08 19:28:26 +01:00
|
|
|
settings_invites.reset();
|
|
|
|
settings_org.reset();
|
|
|
|
settings_profile_fields.reset();
|
|
|
|
settings_streams.reset();
|
|
|
|
settings_user_groups.reset();
|
2020-07-12 00:13:47 +02:00
|
|
|
settings_muting.reset();
|
2020-05-09 20:20:26 +02:00
|
|
|
// settings_users doesn't need a reset()
|
2021-02-28 01:19:36 +01:00
|
|
|
}
|