settings: Move render_only settings to their own dictionary.

These values were only a part of `DisplaySettings` type objects. We're
moving them out of these type of objects to be a standalone object of
its own. This will make it easier to reference in the next few commits
when those `DisplaySettings` objects would be broken down into different
sections.
We've excluded the new function from coverage since there's not much to
be tested there and similar settings functions do the same.
This commit is contained in:
Shubham Padia 2024-07-11 05:51:19 +00:00 committed by Tim Abbott
parent 23e7363850
commit cfd46ac44e
4 changed files with 19 additions and 16 deletions

View File

@ -199,6 +199,7 @@ export function build_page() {
settings_object: realm_user_settings_defaults,
display_settings: settings_config.get_all_preferences(),
information_density_settings: settings_config.get_information_density_preferences(),
settings_render_only: settings_config.get_settings_render_only(),
settings_label: settings_config.realm_user_settings_defaults_labels,
desktop_icon_count_display_values: settings_config.desktop_icon_count_display_values,
enable_sound_select:

View File

@ -121,6 +121,7 @@ export function build_page() {
settings_config.all_notifications(user_settings).show_push_notifications_tooltip,
display_settings: settings_config.get_all_preferences(),
information_density_settings: settings_config.get_information_density_preferences(),
settings_render_only: settings_config.get_settings_render_only(),
user_can_change_name: settings_data.user_can_change_name(),
user_can_change_avatar: settings_data.user_can_change_avatar(),
user_can_change_email: settings_data.user_can_change_email(),

View File

@ -145,12 +145,6 @@ export type DisplaySettings = {
user_display_settings: string[];
};
render_group?: boolean;
render_only: {
dense_mode?: boolean;
high_contrast_mode?: boolean;
web_font_size_px?: boolean;
web_line_height_percent?: boolean;
};
};
/* istanbul ignore next */
@ -164,24 +158,31 @@ export const get_all_preferences = (): DisplaySettings => ({
"fluid_layout_width",
],
},
render_only: {
dense_mode: page_params.development_environment,
high_contrast_mode: page_params.development_environment,
},
});
/* istanbul ignore next */
export const get_information_density_preferences = (): DisplaySettings => ({
render_group: page_params.development_environment,
render_only: {
web_font_size_px: page_params.development_environment,
web_line_height_percent: page_params.development_environment,
},
settings: {
user_display_settings: ["web_font_size_px", "web_line_height_percent"],
},
});
type SettingsRenderOnly = {
dense_mode: boolean;
high_contrast_mode: boolean;
web_font_size_px: boolean;
web_line_height_percent: boolean;
};
/* istanbul ignore next */
export const get_settings_render_only = (): SettingsRenderOnly => ({
dense_mode: page_params.development_environment,
high_contrast_mode: page_params.development_environment,
web_font_size_px: page_params.development_environment,
web_line_height_percent: page_params.development_environment,
});
export const email_address_visibility_values = {
everyone: {
code: 1,

View File

@ -176,7 +176,7 @@
setting_name=this
setting_value=(lookup ../settings_object this)
label=(lookup ../settings_label this)
render_only=(lookup ../information_density_settings.render_only this)
render_only=(lookup ../settings_render_only.render_only this)
prefix=../prefix}}
{{/each}}
</div>
@ -187,7 +187,7 @@
setting_name=this
is_checked=(lookup ../settings_object this)
label=(lookup ../settings_label this)
render_only=(lookup ../display_settings.render_only this)
render_only=(lookup ../settings_render_only.render_only this)
prefix=../prefix}}
{{/each}}