mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 17:36:27 +00:00
settings: Add nobody option for invite_to_realm_policy in frontend.
This commit is contained in:
@@ -259,3 +259,11 @@ run_test("using_dark_theme", () => {
|
|||||||
page_params.color_scheme = settings_config.color_scheme_values.day.code;
|
page_params.color_scheme = settings_config.color_scheme_values.day.code;
|
||||||
assert.equal(settings_data.using_dark_theme(), false);
|
assert.equal(settings_data.using_dark_theme(), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
run_test("user_can_invite_others_to_realm_nobody_case", () => {
|
||||||
|
page_params.is_admin = true;
|
||||||
|
page_params.is_guest = false;
|
||||||
|
page_params.realm_invite_to_realm_policy =
|
||||||
|
settings_config.invite_to_realm_policy_values.nobody.code;
|
||||||
|
assert.equal(settings_data.user_can_invite_others_to_realm(), false);
|
||||||
|
});
|
||||||
|
|||||||
@@ -130,6 +130,34 @@ export const common_policy_values = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const invite_to_realm_policy_values = {
|
||||||
|
nobody: {
|
||||||
|
order: 1,
|
||||||
|
code: 6,
|
||||||
|
description: $t({defaultMessage: "Nobody"}),
|
||||||
|
},
|
||||||
|
by_admins_only: {
|
||||||
|
order: 2,
|
||||||
|
code: 2,
|
||||||
|
description: $t({defaultMessage: "Admins"}),
|
||||||
|
},
|
||||||
|
by_moderators_only: {
|
||||||
|
order: 3,
|
||||||
|
code: 4,
|
||||||
|
description: $t({defaultMessage: "Admins and moderators"}),
|
||||||
|
},
|
||||||
|
by_full_members: {
|
||||||
|
order: 4,
|
||||||
|
code: 3,
|
||||||
|
description: $t({defaultMessage: "Admins and full members"}),
|
||||||
|
},
|
||||||
|
by_members: {
|
||||||
|
order: 5,
|
||||||
|
code: 1,
|
||||||
|
description: $t({defaultMessage: "Admins and members"}),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export const private_message_policy_values = {
|
export const private_message_policy_values = {
|
||||||
by_anyone: {
|
by_anyone: {
|
||||||
order: 1,
|
order: 1,
|
||||||
|
|||||||
@@ -137,6 +137,12 @@ function user_has_permission(policy_value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function user_can_invite_others_to_realm() {
|
export function user_can_invite_others_to_realm() {
|
||||||
|
if (
|
||||||
|
page_params.realm_invite_to_realm_policy ===
|
||||||
|
settings_config.invite_to_realm_policy_values.nobody.code
|
||||||
|
) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return user_has_permission(page_params.realm_invite_to_realm_policy);
|
return user_has_permission(page_params.realm_invite_to_realm_policy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,6 +104,9 @@ export function get_organization_settings_options() {
|
|||||||
options.common_message_policy_values = get_sorted_options_list(
|
options.common_message_policy_values = get_sorted_options_list(
|
||||||
settings_config.common_message_policy_values,
|
settings_config.common_message_policy_values,
|
||||||
);
|
);
|
||||||
|
options.invite_to_realm_policy_values = get_sorted_options_list(
|
||||||
|
settings_config.invite_to_realm_policy_values,
|
||||||
|
);
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<label for="realm_invite_to_realm_policy" class="dropdown-title">{{t "Who can invite users to this organization" }}</label>
|
<label for="realm_invite_to_realm_policy" class="dropdown-title">{{t "Who can invite users to this organization" }}</label>
|
||||||
<select name="realm_invite_to_realm_policy" id="id_realm_invite_to_realm_policy" class="prop-element" data-setting-widget-type="number">
|
<select name="realm_invite_to_realm_policy" id="id_realm_invite_to_realm_policy" class="prop-element" data-setting-widget-type="number">
|
||||||
{{> dropdown_options_widget option_values=common_policy_values}}
|
{{> dropdown_options_widget option_values=invite_to_realm_policy_values}}
|
||||||
</select>
|
</select>
|
||||||
{{> settings_checkbox
|
{{> settings_checkbox
|
||||||
setting_name="realm_invite_required"
|
setting_name="realm_invite_required"
|
||||||
|
|||||||
Reference in New Issue
Block a user