refactor: Extract settings_config.

This moves some code from settings_display.js
into the new module settings_config.js.

Extracting this module breaks some dependencies
on settings_display.js (which has some annoying
transitive dependencies, including jQuery).

In particular this isolates stream_data from
from settings_display.js.

Two of the three structures that we moved here
weren't even directly used by settings_display.js,
since we do a lot of rendering in the modules
admin.js and setting.js.

We make get_all_display_settings() a function
to avoid a require-time dependency on page_params.

Breaking the dependencies simplifies a few
node tests.

Most of the node test complexity came from the
following commit in March 2019:

5a130097bf

The commit itself seems harmless enough, but
dependencies can have a somewhat "viral" nature,
where making stream_data depend on settings_display
caused us to modify four different node tests.
This commit is contained in:
Steve Howell
2020-02-21 13:26:11 +00:00
committed by Tim Abbott
parent 8aae02de68
commit 5e8279c2fb
10 changed files with 75 additions and 58 deletions

View File

@@ -1,3 +1,4 @@
const settings_config = require("./settings_config");
const render_admin_tab = require('../templates/admin_tab.hbs');
const admin_settings_label = {
@@ -31,7 +32,7 @@ exports.build_page = function () {
server_inline_image_preview: page_params.server_inline_image_preview,
realm_inline_url_embed_preview: page_params.realm_inline_url_embed_preview,
server_inline_url_embed_preview: page_params.server_inline_url_embed_preview,
realm_default_twenty_four_hour_time_values: settings_display.twenty_four_hour_time_values,
realm_default_twenty_four_hour_time_values: settings_config.twenty_four_hour_time_values,
realm_authentication_methods: page_params.realm_authentication_methods,
realm_create_stream_policy: page_params.realm_create_stream_policy,
realm_invite_to_stream_policy: page_params.realm_invite_to_stream_policy,