subscriptions: Confirm inviting 100+ users to a new stream.

Our current workflow for creating a new stream allows the user to
invite as many other users as they like but since there can be
mistakes in doing so, we now open a modal with a warning if the
number of invites are more than 100 just to confirm that user indeed
wanted to do this.

Fixes: #1663.
This commit is contained in:
Harshit Bansal
2017-06-02 13:06:33 +00:00
committed by Tim Abbott
parent 054f7db63b
commit 60e5071843
4 changed files with 50 additions and 1 deletions

View File

@@ -164,6 +164,14 @@ function create_stream() {
announce
);
}
function show_large_invites_warning(count) {
var invites_warning_modal = templates.render('subscription_invites_warning_modal');
$('#stream-creation').append(invites_warning_modal);
var confirm_button = $('#invites-warning-overlay').find('.confirm-invites-warning-modal');
confirm_button.text(i18n.t('Invite __count__ users!', {count: count}));
}
exports.new_stream_clicked = function (stream) {
// this changes the tab switcher (settings/preview) which isn't necessary
// to a add new stream title.
@@ -313,13 +321,27 @@ $(function () {
$(".subscriptions").on("submit", "#stream_creation_form", function (e) {
e.preventDefault();
var stream = $.trim($("#create_stream_name").val());
var name_ok = stream_name_error.validate_for_submit(stream);
if (!name_ok) {
return;
}
var principals = get_principals();
if (principals.length > 100) {
show_large_invites_warning(principals.length);
} else {
create_stream();
}
});
$(document).on("click", ".close-invites-warning-modal", function () {
$("#invites-warning-overlay").remove();
});
$(document).on("click", ".confirm-invites-warning-modal", function () {
create_stream();
$("#invites-warning-overlay").remove();
});
$(".subscriptions").on("input", "#create_stream_name", function () {