settings: Add moderators option for wildcard_mention_policy in frontend.

This commit is contained in:
sahil839 2021-05-02 13:41:02 +05:30 committed by Tim Abbott
parent 6e672ebbee
commit 51e40dd668
3 changed files with 21 additions and 1 deletions

View File

@ -367,6 +367,14 @@ test_ui("test_wildcard_mention_allowed", () => {
page_params.is_guest = false;
assert(compose.wildcard_mention_allowed());
page_params.realm_wildcard_mention_policy =
settings_config.wildcard_mention_policy_values.by_moderators_only.code;
page_params.is_moderator = false;
assert(!compose.wildcard_mention_allowed());
page_params.is_moderator = true;
assert(compose.wildcard_mention_allowed());
page_params.realm_wildcard_mention_policy =
settings_config.wildcard_mention_policy_values.by_stream_admins_only.code;
page_params.is_admin = false;

View File

@ -522,6 +522,13 @@ export function wildcard_mention_allowed() {
// TODO: Check the user's stream-level role once stream-level admins exist.
return page_params.is_admin;
}
if (
page_params.realm_wildcard_mention_policy ===
settings_config.wildcard_mention_policy_values.by_moderators_only.code
) {
return page_params.is_admin || page_params.is_moderator;
}
// TODO: Uncomment when we add support for stream-level administrators.
// if (
// page_params.realm_wildcard_mention_policy ===

View File

@ -168,11 +168,16 @@ export const wildcard_mention_policy_values = {
code: 3,
description: $t({defaultMessage: "Admins and full members"}),
},
by_moderators_only: {
order: 4,
code: 7,
description: $t({defaultMessage: "Admins and moderators"}),
},
// Until we add stream administrators, we mislabel this choice
// (which we intend to be the long-term default) as "Admins only"
// and don't offer the long-term "Admins only" option.
by_stream_admins_only: {
order: 4,
order: 5,
code: 4,
// description: $t({defaultMessage: "Organization and stream admins"}),
description: $t({defaultMessage: "Admins only"}),