diff --git a/frontend_tests/node_tests/settings_org.js b/frontend_tests/node_tests/settings_org.js index 5917dbb67a..d6918bdab1 100644 --- a/frontend_tests/node_tests/settings_org.js +++ b/frontend_tests/node_tests/settings_org.js @@ -535,6 +535,9 @@ test("set_up", ({override, override_rewire}) => { $("#id_realm_move_messages_within_stream_limit_minutes").set_parent( $.create(""), ); + $("#id_realm_move_messages_between_streams_limit_minutes").set_parent( + $.create(""), + ); $("#id_realm_message_content_delete_limit_minutes").set_parent( $.create(""), ); @@ -550,6 +553,13 @@ test("set_up", ({override, override_rewire}) => { $stub_move_within_stream_limit_parent, ); + const $stub_move_between_streams_limit_parent = $.create( + " { "id_realm_move_messages_within_stream_limit_minutes", ); + const $custom_move_between_streams_limit_input = $( + "#id_realm_move_messages_between_streams_limit_minutes", + ); + $stub_move_between_streams_limit_parent.set_find_results( + ".time-limit-custom-input", + $custom_move_between_streams_limit_input, + ); + $custom_move_between_streams_limit_input.attr( + "id", + "id_realm_move_messages_between_streams_limit_minutes", + ); + const $custom_delete_limit_input = $("#id_realm_message_content_delete_limit_minutes"); $stub_message_content_delete_limit_parent.set_find_results( ".time-limit-custom-input", diff --git a/static/js/server_events_dispatch.js b/static/js/server_events_dispatch.js index f5a2079022..1d25156929 100644 --- a/static/js/server_events_dispatch.js +++ b/static/js/server_events_dispatch.js @@ -211,6 +211,7 @@ export function dispatch_normal_event(event) { mandatory_topics: noop, message_content_edit_limit_seconds: noop, message_content_delete_limit_seconds: noop, + move_messages_between_streams_limit_seconds: noop, move_messages_within_stream_limit_seconds: noop, message_retention_days: noop, move_messages_between_streams_policy: noop, diff --git a/static/js/settings_org.js b/static/js/settings_org.js index b40dcab976..cbc7a84e84 100644 --- a/static/js/settings_org.js +++ b/static/js/settings_org.js @@ -363,7 +363,15 @@ function enable_or_disable_related_message_move_time_limit_setting(setting_name, function set_msg_move_limit_setting(property_name) { set_time_limit_setting(property_name); - const disable_setting = message_move_limit_setting_enabled("realm_edit_topic_policy"); + + let disable_setting; + if (property_name === "realm_move_messages_within_stream_limit_seconds") { + disable_setting = message_move_limit_setting_enabled("realm_edit_topic_policy"); + } else { + disable_setting = message_move_limit_setting_enabled( + "realm_move_messages_between_streams_policy", + ); + } enable_or_disable_related_message_move_time_limit_setting(property_name, disable_setting); } @@ -673,6 +681,7 @@ export function discard_property_element_changes(elem, for_realm_default_setting set_time_limit_setting(property_name); break; case "realm_move_messages_within_stream_limit_seconds": + case "realm_move_messages_between_streams_limit_seconds": set_msg_move_limit_setting(property_name); break; case "realm_message_retention_days": @@ -928,6 +937,7 @@ export function check_property_changed(elem, for_realm_default_settings, sub) { break; case "realm_message_content_edit_limit_seconds": case "realm_message_content_delete_limit_seconds": + case "realm_move_messages_between_streams_limit_seconds": case "realm_move_messages_within_stream_limit_seconds": case "realm_waiting_period_threshold": proposed_val = get_time_limit_setting_value($elem, false); @@ -1225,6 +1235,7 @@ export function build_page() { set_giphy_rating_dropdown(); set_msg_edit_limit_dropdown(); set_msg_move_limit_setting("realm_move_messages_within_stream_limit_seconds"); + set_msg_move_limit_setting("realm_move_messages_between_streams_limit_seconds"); set_msg_delete_limit_dropdown(); set_delete_own_message_policy_dropdown(page_params.realm_delete_own_message_policy); set_message_retention_setting_dropdown(); @@ -1250,6 +1261,10 @@ export function build_page() { update_custom_value_input("realm_message_content_edit_limit_seconds"); }); + $("#id_realm_move_messages_between_streams_limit_seconds").on("change", () => { + update_custom_value_input("realm_move_messages_between_streams_limit_seconds"); + }); + $("#id_realm_move_messages_within_stream_limit_seconds").on("change", () => { update_custom_value_input("realm_move_messages_within_stream_limit_seconds"); }); @@ -1304,7 +1319,13 @@ export function build_page() { const $policy_dropdown_elem = $(e.target); const property_name = extract_property_name($policy_dropdown_elem); const disable_time_limit_setting = message_move_limit_setting_enabled(property_name); - const time_limit_setting_name = "realm_move_messages_within_stream_limit_seconds"; + + let time_limit_setting_name; + if (property_name === "realm_edit_topic_policy") { + time_limit_setting_name = "realm_move_messages_within_stream_limit_seconds"; + } else { + time_limit_setting_name = "realm_move_messages_between_streams_limit_seconds"; + } enable_or_disable_related_message_move_time_limit_setting( time_limit_setting_name, diff --git a/static/styles/settings.css b/static/styles/settings.css index 273d2a7959..45d684c7b9 100644 --- a/static/styles/settings.css +++ b/static/styles/settings.css @@ -1482,7 +1482,8 @@ $option_title_width: 180px; #id_realm_message_content_edit_limit_seconds, #id_realm_delete_own_message_policy, #id_realm_message_content_delete_limit_seconds, -#id_realm_move_messages_within_stream_limit_seconds { +#id_realm_move_messages_within_stream_limit_seconds, +#id_realm_move_messages_between_streams_limit_seconds { width: 325px; } diff --git a/static/templates/settings/organization_permissions_admin.hbs b/static/templates/settings/organization_permissions_admin.hbs index 3eeb3bf303..c545cb01b4 100644 --- a/static/templates/settings/organization_permissions_admin.hbs +++ b/static/templates/settings/organization_permissions_admin.hbs @@ -217,10 +217,28 @@
- {{> dropdown_options_widget option_values=move_messages_between_streams_policy_values}}
+ +
+ + +
+ + +
+