streams: Rename change_change_subscription_type to reference permissions.

This is a preparatory refactor for when we start having other
permissions options available in this UI (e.g. announcement-only streams).
This commit is contained in:
Tim Abbott 2018-05-21 16:14:18 -07:00
parent 9df3480263
commit 106d06b235
5 changed files with 8 additions and 8 deletions

View File

@ -328,7 +328,7 @@ run_test('admin_options', () => {
var sub = make_sub(); var sub = make_sub();
stream_data.update_calculated_fields(sub); stream_data.update_calculated_fields(sub);
assert(!sub.is_admin); assert(!sub.is_admin);
assert(!sub.can_change_subscription_type); assert(!sub.can_change_stream_permissions);
// just a sanity check that we leave "normal" fields alone // just a sanity check that we leave "normal" fields alone
assert.equal(sub.color, 'blue'); assert.equal(sub.color, 'blue');
@ -340,7 +340,7 @@ run_test('admin_options', () => {
sub = make_sub(); sub = make_sub();
stream_data.update_calculated_fields(sub); stream_data.update_calculated_fields(sub);
assert(sub.is_admin); assert(sub.is_admin);
assert(sub.can_change_subscription_type); assert(sub.can_change_stream_permissions);
// admins can only make private streams become public // admins can only make private streams become public
// if they are subscribed // if they are subscribed
@ -349,14 +349,14 @@ run_test('admin_options', () => {
sub.subscribed = false; sub.subscribed = false;
stream_data.update_calculated_fields(sub); stream_data.update_calculated_fields(sub);
assert(sub.is_admin); assert(sub.is_admin);
assert(!sub.can_change_subscription_type); assert(!sub.can_change_stream_permissions);
sub = make_sub(); sub = make_sub();
sub.invite_only = true; sub.invite_only = true;
sub.subscribed = true; sub.subscribed = true;
stream_data.update_calculated_fields(sub); stream_data.update_calculated_fields(sub);
assert(sub.is_admin); assert(sub.is_admin);
assert(sub.can_change_subscription_type); assert(sub.can_change_stream_permissions);
}); });
run_test('stream_settings', () => { run_test('stream_settings', () => {

View File

@ -1224,7 +1224,7 @@ run_test('handlebars_bug', () => {
render_subscribers: true, render_subscribers: true,
color: 'purple', color: 'purple',
invite_only: true, invite_only: true,
can_change_subscription_type: true, can_change_stream_permissions: true,
email_address: 'xxxxxxxxxxxxxxx@zulip.com', email_address: 'xxxxxxxxxxxxxxx@zulip.com',
stream_id: 888, stream_id: 888,
in_home_view: true, in_home_view: true,

View File

@ -206,7 +206,7 @@ exports.update_calculated_fields = function (sub) {
sub.should_display_subscription_button = !sub.invite_only || sub.subscribed; sub.should_display_subscription_button = !sub.invite_only || sub.subscribed;
sub.should_display_preview_button = sub.subscribed || !sub.invite_only || sub.should_display_preview_button = sub.subscribed || !sub.invite_only ||
sub.previously_subscribed; sub.previously_subscribed;
sub.can_change_subscription_type = page_params.is_admin && ( sub.can_change_stream_permissions = page_params.is_admin && (
!sub.invite_only || sub.subscribed); !sub.invite_only || sub.subscribed);
// User can add other users to stream if stream is public or user is subscribed to stream. // User can add other users to stream if stream is public or user is subscribed to stream.
sub.can_access_subscribers = !sub.invite_only || sub.subscribed || page_params.is_admin; sub.can_access_subscribers = !sub.invite_only || sub.subscribed || page_params.is_admin;

View File

@ -383,7 +383,7 @@ function change_stream_privacy(e) {
// For auto update, without rendering whole template // For auto update, without rendering whole template
stream_data.update_calculated_fields(sub); stream_data.update_calculated_fields(sub);
if (!sub.can_change_subscription_type) { if (!sub.can_change_stream_permissions) {
$(".change-stream-privacy").hide(); $(".change-stream-privacy").hide();
} }
}, },

View File

@ -37,7 +37,7 @@
<div class="subscription-type-text"> <div class="subscription-type-text">
{{partial "subscription_type"}} {{partial "subscription_type"}}
</div> </div>
{{#if can_change_subscription_type}} {{#if can_change_stream_permissions}}
<a class="change-stream-privacy">[{{t "Change" }}]</a> <a class="change-stream-privacy">[{{t "Change" }}]</a>
{{/if}} {{/if}}
</div> </div>