settings: Improve permissions banners on Invitations panel.

Fixes #24158
This commit is contained in:
Ujjawal Modi 2023-01-24 13:06:05 +05:30 committed by Tim Abbott
parent e0f9332280
commit 836b9e483e
5 changed files with 59 additions and 2 deletions

View File

@ -337,6 +337,7 @@ run_test("realm settings", ({override}) => {
override(settings_org, "sync_realm_settings", noop);
override(settings_bots, "update_bot_permissions_ui", noop);
override(settings_invites, "update_invite_users_setting_tip", noop);
override(notifications, "redraw_title", noop);
function test_electron_dispatch(event, fake_send_event) {

View File

@ -11,6 +11,7 @@ import * as settings from "./settings";
import * as settings_bots from "./settings_bots";
import * as settings_config from "./settings_config";
import * as settings_data from "./settings_data";
import * as settings_invites from "./settings_invites";
import * as settings_org from "./settings_org";
import * as settings_panel_menu from "./settings_panel_menu";
import * as settings_sections from "./settings_sections";
@ -215,6 +216,7 @@ export function build_page() {
$("#settings_content .alert").removeClass("show");
settings_bots.update_bot_settings_tip();
settings_invites.update_invite_users_setting_tip();
insert_tip_box();
$("#id_realm_bot_creation_policy").val(page_params.realm_bot_creation_policy);

View File

@ -204,7 +204,7 @@ export function dispatch_normal_event(event) {
disallow_disposable_email_addresses: noop,
inline_image_preview: noop,
inline_url_embed_preview: noop,
invite_to_realm_policy: noop,
invite_to_realm_policy: settings_invites.update_invite_users_setting_tip,
invite_required: noop,
mandatory_topics: noop,
message_content_edit_limit_seconds: noop,

View File

@ -13,6 +13,7 @@ import * as loading from "./loading";
import {page_params} from "./page_params";
import * as people from "./people";
import * as settings_config from "./settings_config";
import * as settings_data from "./settings_data";
import * as timerender from "./timerender";
import * as ui_report from "./ui_report";
import * as util from "./util";
@ -233,3 +234,55 @@ export function on_load_success(invites_data, initialize_event_handlers) {
$(".dialog_submit_button").attr("data-invite-id", meta.invite_id);
});
}
export function update_invite_users_setting_tip() {
if (settings_data.user_can_invite_others_to_realm() && !page_params.is_admin) {
$(".invite-user-settings-tip").hide();
return;
}
const permission_type = settings_config.invite_to_realm_policy_values;
const current_permission = page_params.realm_invite_to_realm_policy;
let tip_text;
switch (current_permission) {
case permission_type.by_admins_only.code: {
tip_text = $t({
defaultMessage:
"This organization is configured so that admins can invite users to this organization.",
});
break;
}
case permission_type.by_moderators_only.code: {
tip_text = $t({
defaultMessage:
"This organization is configured so that admins and moderators can invite users to this organization.",
});
break;
}
case permission_type.by_members.code: {
tip_text = $t({
defaultMessage:
"This organization is configured so that admins, moderators and members can invite users to this organization.",
});
break;
}
case permission_type.by_full_members.code: {
tip_text = $t({
defaultMessage:
"This organization is configured so that admins, moderators and full members can invite users to this organization.",
});
break;
}
default: {
tip_text = $t({
defaultMessage:
"This organization is configured so that nobody can invite users to this organization.",
});
}
}
$(".invite-user-settings-tip").show();
$(".invite-user-settings-tip").text(tip_text);
}

View File

@ -1,6 +1,7 @@
<div id="admin-invites-list" class="settings-section" data-name="invites-list-admin">
<div class="tip invite-user-settings-tip"></div>
{{#unless is_admin }}
<div class="tip">{{t "Members can only view or manage invitations that you yourself sent." }}</div>
<div class="tip">{{t "You can only view or manage invitations that you sent." }}</div>
{{/unless}}
{{#if can_invite_others_to_realm}}
<a class="invite-user-link" href="#invite"><i class="fa fa-user-plus" aria-hidden="true"></i>{{t "Invite more users" }}</a>