From ba1fe7799628e4172b5670157b15ff51710e2dc9 Mon Sep 17 00:00:00 2001 From: Sahil Batra Date: Fri, 17 Sep 2021 16:21:31 +0530 Subject: [PATCH] settings: Add UI for realm-level default of enter_sends settings. --- static/js/settings_config.ts | 1 + static/js/settings_realm_user_settings_defaults.js | 13 +++++++++++++ .../organization_user_settings_defaults.hbs | 10 ++++++++++ tools/lib/capitalization.py | 1 + 4 files changed, 25 insertions(+) diff --git a/static/js/settings_config.ts b/static/js/settings_config.ts index 764ff7e697..dca6385471 100644 --- a/static/js/settings_config.ts +++ b/static/js/settings_config.ts @@ -411,6 +411,7 @@ export const realm_user_settings_defaults_labels = { }), realm_presence_enabled: $t({defaultMessage: "Display availability to other users when online"}), + realm_enter_sends: $t({defaultMessage: "Enter sends when composing a message"}), }; // NOTIFICATIONS diff --git a/static/js/settings_realm_user_settings_defaults.js b/static/js/settings_realm_user_settings_defaults.js index f9289ca6ab..75f0d2f55c 100644 --- a/static/js/settings_realm_user_settings_defaults.js +++ b/static/js/settings_realm_user_settings_defaults.js @@ -36,5 +36,18 @@ export function set_up() { ); }); + container.find(".enter_sends").on("change", (e) => { + e.preventDefault(); + e.stopPropagation(); + + const data = {enter_sends: container.find(".enter_sends").prop("checked")}; + settings_ui.do_settings_change( + channel.patch, + "/json/realm/user_settings_defaults", + data, + container.find(".other-setting-status").expectOne(), + ); + }); + maybe_disable_widgets(); } diff --git a/static/templates/settings/organization_user_settings_defaults.hbs b/static/templates/settings/organization_user_settings_defaults.hbs index a90576848e..5b3c7395dc 100644 --- a/static/templates/settings/organization_user_settings_defaults.hbs +++ b/static/templates/settings/organization_user_settings_defaults.hbs @@ -16,4 +16,14 @@ help_link="/help/status-and-availability" prefix="realm_"}} + +
+

{{t "Other settings" }}

+
+ {{> settings_checkbox + setting_name="enter_sends" + is_checked=settings_object.enter_sends + label=settings_label.realm_enter_sends + prefix="realm_"}} +
diff --git a/tools/lib/capitalization.py b/tools/lib/capitalization.py index 1ca60ee674..1f1ae139e7 100644 --- a/tools/lib/capitalization.py +++ b/tools/lib/capitalization.py @@ -118,6 +118,7 @@ IGNORED_PHRASES = [ # SPECIAL CASES # Enter is usually capitalized r"Press Enter to send", + r"Send message on pressing Enter", # Because topics usually are lower-case, this would look weird if it were capitalized r"more topics", # For consistency with "more topics"