streams: Add frontend to set/update message_retention_days of a stream.

This commit adds frontend support for setting and updating message
retention days of a stream from stream settings.

Message retention days can be changed from stream privacy modal of the
stream and can be set from stream_creation_form while creating streams.

Only admins can create streams with message_retention_days value other
than realm_default.

This commit also contains relevant changes to docs.
This commit is contained in:
sahil839
2020-06-15 20:30:00 +05:30
committed by Tim Abbott
parent 5f63d6b7f1
commit d9b7228444
9 changed files with 125 additions and 0 deletions

View File

@@ -169,6 +169,13 @@ function create_stream() {
data.stream_post_policy = JSON.stringify(stream_post_policy);
let message_retention_selection = $('#stream_creation_form select[name=stream_message_retention_setting]').val();
if (message_retention_selection === "retain_for_period") {
message_retention_selection = parseInt($('#stream_creation_form input[name=stream-message-retention-days]').val(), 10);
}
data.message_retention_days = JSON.stringify(message_retention_selection);
const announce = stream_data.realm_has_notifications_stream() &&
$('#announce-new-stream input').prop('checked');
data.announce = JSON.stringify(announce);
@@ -266,6 +273,8 @@ exports.show_new_stream_modal = function () {
// Make the options default to the same each time:
// public, "announce stream" on.
$('#make-invite-only input:radio[value=public]').prop('checked', true);
$("#stream_creation_form .stream-message-retention-days-input").hide();
$("#stream_creation_form select[name=stream_message_retention_setting]").val("realm_default");
if (stream_data.realm_has_notifications_stream()) {
$('#announce-new-stream').show();