mirror of https://github.com/zulip/zulip.git
refactor: Extract stream_data.can_change_permissions().
This commit is contained in:
parent
b27ff978c7
commit
ea972569a3
|
@ -511,6 +511,10 @@ export function can_preview(sub) {
|
|||
return sub.subscribed || !sub.invite_only || sub.previously_subscribed;
|
||||
}
|
||||
|
||||
export function can_change_permissions(sub) {
|
||||
return page_params.is_admin && (!sub.invite_only || sub.subscribed);
|
||||
}
|
||||
|
||||
export function is_subscribed(stream_name) {
|
||||
const sub = get_sub(stream_name);
|
||||
return sub !== undefined && sub.subscribed;
|
||||
|
|
|
@ -53,8 +53,7 @@ export function update_calculated_fields(sub) {
|
|||
|
||||
sub.should_display_subscription_button = stream_data.can_toggle_subscription(sub);
|
||||
sub.should_display_preview_button = stream_data.can_preview(sub);
|
||||
sub.can_change_stream_permissions =
|
||||
page_params.is_admin && (!sub.invite_only || sub.subscribed);
|
||||
sub.can_change_stream_permissions = stream_data.can_change_permissions(sub);
|
||||
// User can add other users to stream if stream is public or user is subscribed to stream.
|
||||
// Guest users can't access subscribers of any(public or private) non-subscribed streams.
|
||||
sub.can_access_subscribers =
|
||||
|
|
Loading…
Reference in New Issue