compose: Hide sub-btn in compose-to-unsub warning if user can't subscribe.

Hide subscription button in compose-message-to-unsubscribe-stream
warning, if user can't subscribe back to stream.
This commit is contained in:
Yashashvi Dave
2018-11-01 00:29:40 +05:30
parent 7dc021a6b2
commit f6b4e65b92
3 changed files with 9 additions and 2 deletions

View File

@@ -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', () => {

View File

@@ -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;
}

View File

@@ -5,6 +5,8 @@
{{/tr}}
</p>
<div>
{{#if should_display_sub_button}}
<button id="error-message-sub-button" class="btn btn-warning subscribe-button sub_unsub_button">{{t "Subscribe" }}</button><button type="button" id="compose_not_subscribed_close" class="close">&times;</button>
{{/if}}
</div>
</div>