composebox: Warn when linked to private streams.

Fix issue #6860
This commit is contained in:
Rhea Parekh
2017-10-14 18:48:21 +05:30
committed by showell
parent be56a99734
commit 1d826ae201
7 changed files with 122 additions and 4 deletions

View File

@@ -68,6 +68,11 @@ exports.clear_invites = function () {
$("#compose_invite_users").empty();
};
exports.clear_private_stream_alert = function () {
$("#compose_private_stream_alert").hide();
$("#compose_private_stream_alert").empty();
};
exports.reset_user_acknowledged_all_everyone_flag = function () {
user_acknowledged_all_everyone = undefined;
};
@@ -307,6 +312,7 @@ exports.enter_with_preview_open = function () {
exports.finish = function () {
exports.clear_invites();
exports.clear_private_stream_alert();
if (! compose.validate()) {
return false;
@@ -632,6 +638,39 @@ exports.initialize = function () {
}
});
// Show a warning if a private stream is linked
$(document).on('streamname_completed.zulip', function (event, data) {
if (compose_state.get_message_type() !== 'stream') {
return;
}
if (data !== undefined && data.stream !== undefined) {
var invite_only = data.stream.invite_only;
var stream_name = data.stream.name;
if (invite_only) {
var warning_area = $("#compose_private_stream_alert");
var context = { stream_name: stream_name, invite_only: invite_only };
var new_row = templates.render("compose_private_stream_alert", context);
warning_area.append(new_row);
warning_area.show();
}
}
});
$("#compose_private_stream_alert").on('click', '.compose_private_stream_alert_close', function (event) {
var stream_alert_row = $(event.target).parents('.compose_private_stream_alert');
var stream_alert = $("#compose_private_stream_alert");
stream_alert_row.remove();
if (stream_alert.children().length === 0) {
stream_alert.hide();
}
});
// Click event binding for "Attach files" button
// Triggers a click on a hidden file input field