settings: Fix banner shown on custom emoji panel.

Previously the banner was always shown to admins and to users who
cannot add emoji with the banner mentioning who can add emoji.

This commit updates the code to only show the banners who cannot
add emoji irrespective of their role, and just mention that they
do not have permission without any detail about who can add.
This commit is contained in:
Sahil Batra 2024-10-29 22:55:18 +05:30 committed by Tim Abbott
parent 891e58bb1a
commit 5fbc46f82c
4 changed files with 4 additions and 31 deletions

View File

@ -21,7 +21,6 @@ import * as settings_sections from "./settings_sections";
import * as settings_toggle from "./settings_toggle";
import * as settings_users from "./settings_users";
import {current_user, realm} from "./state_data";
import * as user_groups from "./user_groups";
const admin_settings_label = {
// Organization profile
@ -182,9 +181,6 @@ export function build_page() {
realm_invite_required: realm.realm_invite_required,
can_create_user_groups: settings_data.user_can_create_user_groups(),
policy_values: settings_config.common_policy_values,
realm_can_add_custom_emoji_group_name: user_groups.get_user_group_from_id(
realm.realm_can_add_custom_emoji_group,
).name,
...settings_org.get_organization_settings_options(),
demote_inactive_streams_values: settings_config.demote_inactive_streams_values,
web_mark_read_on_scroll_policy_values:

View File

@ -6,7 +6,6 @@ import render_confirm_deactivate_custom_emoji from "../templates/confirm_dialog/
import emoji_settings_warning_modal from "../templates/confirm_dialog/confirm_emoji_settings_warning.hbs";
import render_add_emoji from "../templates/settings/add_emoji.hbs";
import render_admin_emoji_list from "../templates/settings/admin_emoji_list.hbs";
import render_settings_emoji_settings_tip from "../templates/settings/emoji_settings_tip.hbs";
import * as channel from "./channel";
import * as confirm_dialog from "./confirm_dialog";
@ -19,10 +18,9 @@ import * as loading from "./loading";
import * as people from "./people";
import * as scroll_util from "./scroll_util";
import * as settings_data from "./settings_data";
import {current_user, realm} from "./state_data";
import {current_user} from "./state_data";
import * as ui_report from "./ui_report";
import * as upload_widget from "./upload_widget";
import * as user_groups from "./user_groups";
import * as util from "./util";
const meta = {
@ -44,12 +42,6 @@ function can_delete_emoji(emoji: ServerEmoji): boolean {
}
export function update_custom_emoji_ui(): void {
const rendered_tip = render_settings_emoji_settings_tip({
realm_can_add_custom_emoji_group_name: user_groups.get_user_group_from_id(
realm.realm_can_add_custom_emoji_group,
).name,
});
$("#emoji-settings").find(".emoji-settings-tip-container").html(rendered_tip);
if (!settings_data.user_can_add_custom_emoji()) {
$(".add-emoji-text").hide();
$("#add-custom-emoji-button").hide();
@ -58,11 +50,7 @@ export function update_custom_emoji_ui(): void {
} else {
$(".add-emoji-text").show();
$("#add-custom-emoji-button").show();
if (current_user.is_admin) {
$("#emoji-settings .emoji-settings-tip-container").show();
} else {
$("#emoji-settings .emoji-settings-tip-container").hide();
}
$("#emoji-settings .emoji-settings-tip-container").hide();
$(".org-settings-list li[data-section='emoji-settings'] .locked").hide();
}

View File

@ -1,6 +1,6 @@
<div id="emoji-settings" data-name="emoji-settings" class="settings-section">
<div class="emoji-settings-tip-container {{#unless (or is_admin (not can_add_emojis))}}hide{{/unless}}">
{{> emoji_settings_tip}}
<div class="emoji-settings-tip-container {{#if can_add_emojis}}hide{{/if}}">
<div class="tip">{{t "You do not have permission to add custom emoji."}}</div>
</div>
<p class="add-emoji-text {{#unless can_add_emojis}}hide{{/unless}}">
{{t "Add extra emoji for members of the {realm_name} organization." }}

View File

@ -1,11 +0,0 @@
{{#if is_guest}}
<div class='tip'>{{t "Guests cannot edit custom emoji." }}</div>
{{else if (eq realm_can_add_custom_emoji_group_name "role:administrators") }}
<div class='tip'>{{t "This organization is configured so that only administrators can add custom emoji." }}</div>
{{else if (eq realm_can_add_custom_emoji_group_name "role:moderators")}}
<div class='tip'>{{t 'This organization is configured so that administrators and moderators can add custom emoji.'}}</div>
{{else if (eq realm_can_add_custom_emoji_group_name "role:fullmembers")}}
<div class='tip'>{{t 'This organization is configured so that full members can add custom emoji.'}}</div>
{{else}}
<div class='tip'>{{t "This organization is configured so that any member of this organization can add custom emoji." }}</div>
{{/if}}