settings: Add move_messages_between_streams_limit_seconds element in UI.

This commit adds dropdown for move_messages_between_streams_limit_seconds
setting which is used to control for how long the user is allowed to
edit stream.
This commit is contained in:
Sahil Batra 2023-01-30 16:45:36 +05:30 committed by Tim Abbott
parent 4378b1639d
commit 2eb204f699
5 changed files with 67 additions and 4 deletions

View File

@ -535,6 +535,9 @@ test("set_up", ({override, override_rewire}) => {
$("#id_realm_move_messages_within_stream_limit_minutes").set_parent(
$.create("<stub move within stream custom input parent>"),
);
$("#id_realm_move_messages_between_streams_limit_minutes").set_parent(
$.create("<stub move between streams custom input parent>"),
);
$("#id_realm_message_content_delete_limit_minutes").set_parent(
$.create("<stub delete limit custom input parent>"),
);
@ -550,6 +553,13 @@ test("set_up", ({override, override_rewire}) => {
$stub_move_within_stream_limit_parent,
);
const $stub_move_between_streams_limit_parent = $.create(
"<stub move_between_streams_limit parent",
);
$("#id_realm_move_messages_between_streams_limit_seconds").set_parent(
$stub_move_between_streams_limit_parent,
);
const $stub_message_content_delete_limit_parent = $.create(
"<stub message_content_delete_limit parent",
);
@ -576,6 +586,18 @@ test("set_up", ({override, override_rewire}) => {
"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",

View File

@ -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,

View File

@ -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,

View File

@ -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;
}

View File

@ -217,10 +217,28 @@
<div class="input-group">
<label for="realm_move_messages_between_streams_policy">{{t "Who can move messages to another stream" }}
</label>
<select name="realm_move_messages_between_streams_policy" class="setting-widget prop-element bootstrap-focus-style" id="id_realm_move_messages_between_streams_policy" data-setting-widget-type="number">
<select name="realm_move_messages_between_streams_policy" class="setting-widget prop-element bootstrap-focus-style move-message-policy-setting" id="id_realm_move_messages_between_streams_policy" data-setting-widget-type="number">
{{> dropdown_options_widget option_values=move_messages_between_streams_policy_values}}
</select>
</div>
<div class="input-group time-limit-setting">
<label for="realm_move_messages_between_streams_limit_seconds" class="dropdown-title">{{t "Time limit for moving messages between streams" }} <i>({{t "does not apply to moderators and administrators" }})</i></label>
<select name="realm_move_messages_between_streams_limit_seconds" id="id_realm_move_messages_between_streams_limit_seconds" class="prop-element bootstrap-focus-style" data-setting-widget-type="time-limit">
{{#each msg_move_limit_dropdown_values}}
<option value="{{value}}">{{text}}</option>
{{/each}}
</select>
<div class="dependent-settings-block">
<label for="id_realm_move_messages_between_streams_limit_minutes" class="inline-block realm-time-limit-label">
{{t 'Duration editing is allowed after posting (minutes)'}}:&nbsp;
</label>
<input type="text" id="id_realm_move_messages_between_streams_limit_minutes"
name="realm_move_messages_between_streams_limit_minutes"
class="time-limit-custom-input"
autocomplete="off"/>
</div>
</div>
</div>
<div id="org-msg-deletion" class="settings-subsection-parent">