diff --git a/frontend_tests/node_tests/templates.js b/frontend_tests/node_tests/templates.js index 0a26f7d7c7..518b04466d 100644 --- a/frontend_tests/node_tests/templates.js +++ b/frontend_tests/node_tests/templates.js @@ -1251,12 +1251,14 @@ run_test('handlebars_bug', () => { }; var html = render('subscription_stream_privacy_modal', args); - var stream_desc = $(html).find(".modal-body b"); - assert.equal(stream_desc.text(), 'an invite-only stream'); + var other_options = $(html).find("input[name=privacy]"); + assert.equal(other_options[0].value, 'public'); + assert.equal(other_options[1].value, 'invite-only'); + assert.equal(other_options[2].value, 'invite-only-public-history'); var button = $(html).find("#change-stream-privacy-button"); - assert(button.hasClass("btn-primary")); - assert.equal(button.text().trim(), "translated: Make stream public"); + assert(button.hasClass("btn-danger")); + assert.equal(button.text().trim(), "translated: Change privacy"); }()); diff --git a/static/js/stream_create.js b/static/js/stream_create.js index e713d1fbab..63db55a469 100644 --- a/static/js/stream_create.js +++ b/static/js/stream_create.js @@ -97,7 +97,8 @@ var stream_name_error = (function () { return self; }()); -function ajaxSubscribeForCreation(stream_name, description, principals, invite_only, announce) { +function ajaxSubscribeForCreation(stream_name, description, principals, invite_only, + announce, history_public_to_subscribers) { // Subscribe yourself and possible other people to a new stream. return channel.post({ url: "/json/users/me/subscriptions", @@ -106,6 +107,7 @@ function ajaxSubscribeForCreation(stream_name, description, principals, invite_o principals: JSON.stringify(principals), invite_only: JSON.stringify(invite_only), announce: JSON.stringify(announce), + history_public_to_subscribers: JSON.stringify(history_public_to_subscribers), }, success: function () { $("#create_stream_name").val(""); @@ -168,9 +170,23 @@ function get_principals() { function create_stream() { var stream_name = $.trim($("#create_stream_name").val()); var description = $.trim($("#create_stream_description").val()); - var is_invite_only = $('#stream_creation_form input[name=privacy]:checked').val() === "invite-only"; + var privacy_setting = $('#stream_creation_form input[name=privacy]:checked').val(); var principals = get_principals(); + var invite_only; + var history_public_to_subscribers; + + if (privacy_setting === 'invite-only') { + invite_only = true; + history_public_to_subscribers = false; + } else if (privacy_setting === 'invite-only-public-history') { + invite_only = true; + history_public_to_subscribers = true; + } else { + invite_only = false; + history_public_to_subscribers = true; + } + created_stream = stream_name; var announce = (!!page_params.notifications_stream && @@ -182,8 +198,9 @@ function create_stream() { stream_name, description, principals, - is_invite_only, - announce + invite_only, + announce, + history_public_to_subscribers ); } diff --git a/static/js/stream_edit.js b/static/js/stream_edit.js index d481da18ca..665fde1cd2 100644 --- a/static/js/stream_edit.js +++ b/static/js/stream_edit.js @@ -343,11 +343,28 @@ function change_stream_privacy(e) { var stream_id = $(e.target).data("stream-id"); var sub = stream_data.get_sub_by_id(stream_id); + var privacy_setting = $('#stream_privacy_modal input[name=privacy]:checked').val(); + + var invite_only; + var history_public_to_subscribers; + + if (privacy_setting === 'invite-only') { + invite_only = true; + history_public_to_subscribers = false; + } else if (privacy_setting === 'invite-only-public-history') { + invite_only = true; + history_public_to_subscribers = true; + } else { + invite_only = false; + history_public_to_subscribers = true; + } + $(".stream_change_property_info").hide(); var data = { stream_name: sub.name, // toggle the privacy setting - is_private: !sub.invite_only, + is_private: JSON.stringify(invite_only), + history_public_to_subscribers: JSON.stringify(history_public_to_subscribers), }; channel.patch({ @@ -358,7 +375,8 @@ function change_stream_privacy(e) { var sub_row = $(".stream-row[data-stream-id='" + stream_id + "']"); // save new privacy settings. - sub.invite_only = !sub.invite_only; + sub.invite_only = invite_only; + sub.history_public_to_subscribers = history_public_to_subscribers; redraw_privacy_related_stuff(sub_row, sub); $("#stream_privacy_modal").remove(); @@ -488,8 +506,12 @@ exports.initialize = function () { var stream_id = get_stream_id(e.target); var stream = stream_data.get_sub_by_id(stream_id); var template_data = { - is_private: stream.can_make_public, stream_id: stream_id, + stream_name: stream.name, + is_public: !stream.invite_only, + is_private: stream.invite_only && !stream.history_public_to_subscribers, + is_private_with_public_history: (stream.invite_only && + stream.history_public_to_subscribers), }; var change_privacy_modal = templates.render("subscription_stream_privacy_modal", template_data); diff --git a/static/styles/night_mode.scss b/static/styles/night_mode.scss index ec504a86ad..fb89b5e53b 100644 --- a/static/styles/night_mode.scss +++ b/static/styles/night_mode.scss @@ -284,6 +284,7 @@ body.night-mode .subscriptions-container .left, body.night-mode .subscriber-list-box, body.night-mode .subscriber-list tr, body.night-mode #subscription_overlay ul.grey-box li, +body.night-mode #stream_privacy_modal ul.grey-box li, body.night-mode #settings_page .sidebar, body.night-mode #settings_page .sidebar *, body.night-mode table, diff --git a/static/styles/subscriptions.scss b/static/styles/subscriptions.scss index 5b9ffaf00d..734f597083 100644 --- a/static/styles/subscriptions.scss +++ b/static/styles/subscriptions.scss @@ -952,23 +952,32 @@ form#add_new_subscription { display: block; } +#stream_privacy_modal ul.grey-box { + border-style: none; +} + +#stream_privacy_modal ul.grey-box li, #subscription_overlay ul.grey-box li { border-bottom: 1px solid hsl(0, 0%, 86%); padding: 5px 0px; } +#stream_privacy_modal ul.grey-box li input[type=checkbox], #subscription_overlay ul.grey-box li input[type=checkbox] { margin-top: 0px; } +#stream_privacy_modal ul.grey-box li:last-of-type, #subscription_overlay ul.grey-box li:last-of-type { border-bottom: none; } +#stream_privacy_modal ul.grey-box li .sp-replacer, #subscription_overlay ul.grey-box li .sp-replacer { box-shadow: none; } +#stream_privacy_modal ul.grey-box li input[type=radio], #subscription_overlay ul.grey-box li input[type=radio] { margin-right: 5px; } diff --git a/static/templates/stream_types.handlebars b/static/templates/stream_types.handlebars new file mode 100644 index 0000000000..58819e6a83 --- /dev/null +++ b/static/templates/stream_types.handlebars @@ -0,0 +1,26 @@ +