diff --git a/frontend_tests/node_tests/templates.js b/frontend_tests/node_tests/templates.js index 1e99f02763..cfcbe8c7b4 100644 --- a/frontend_tests/node_tests/templates.js +++ b/frontend_tests/node_tests/templates.js @@ -569,9 +569,12 @@ run_test('compose_announce', () => { }); run_test('compose_not_subscribed', () => { - var html = render('compose_not_subscribed'); + var html = render('compose_not_subscribed', {should_display_sub_button: true}); var button = $(html).find("button:first"); assert.equal(button.text(), "translated: Subscribe"); + html = render('compose_not_subscribed', {should_display_sub_button: false}); + button = $(html).find("button:first"); + assert.equal(button.length, 0); }); run_test('compose_notification', () => { diff --git a/static/js/compose.js b/static/js/compose.js index 2cf5d32a6f..5355f6a7e3 100644 --- a/static/js/compose.js +++ b/static/js/compose.js @@ -471,7 +471,9 @@ exports.validation_error = function (error_type, stream_name) { compose_error(i18n.t("Error checking subscription"), $("#stream")); return false; case "not-subscribed": - var new_row = templates.render("compose_not_subscribed"); + var sub = stream_data.get_sub(stream_name); + var new_row = templates.render("compose_not_subscribed", { + should_display_sub_button: sub.should_display_subscription_button}); compose_not_subscribed_error(new_row, $('#stream')); return false; } diff --git a/static/templates/compose_not_subscribed.handlebars b/static/templates/compose_not_subscribed.handlebars index 2e57b6ca31..255755070b 100644 --- a/static/templates/compose_not_subscribed.handlebars +++ b/static/templates/compose_not_subscribed.handlebars @@ -5,6 +5,8 @@ {{/tr}}