mirror of https://github.com/zulip/zulip.git
settings_data: Move checks for nobody and owners_only case to user_has_permission.
This commit is contained in:
parent
30c190a120
commit
8411c6eb21
|
@ -113,6 +113,24 @@ export function user_can_change_logo(): boolean {
|
|||
}
|
||||
|
||||
function user_has_permission(policy_value: number): boolean {
|
||||
/* At present, nobody and by_owners_only is not present in
|
||||
* common_policy_values, but we include a check for it here,
|
||||
* so that code using create_web_public_stream_policy_values
|
||||
* or other supersets can use this function. */
|
||||
if (policy_value === settings_config.create_web_public_stream_policy_values.nobody.code) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (page_params.is_owner) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
policy_value === settings_config.create_web_public_stream_policy_values.by_owners_only.code
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (page_params.is_admin) {
|
||||
return true;
|
||||
}
|
||||
|
@ -189,20 +207,6 @@ export function user_can_create_web_public_streams(): boolean {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
page_params.realm_create_web_public_stream_policy ===
|
||||
settings_config.create_web_public_stream_policy_values.nobody.code
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
page_params.realm_create_web_public_stream_policy ===
|
||||
settings_config.create_web_public_stream_policy_values.by_owners_only.code
|
||||
) {
|
||||
return page_params.is_owner;
|
||||
}
|
||||
|
||||
return user_has_permission(page_params.realm_create_web_public_stream_policy);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue