From 81836303d4e24fb79ea36de82089b947189f6b99 Mon Sep 17 00:00:00 2001 From: Maneesh Shukla Date: Mon, 21 Oct 2024 00:56:20 +0530 Subject: [PATCH] settings: Fix email notification permission. Added `message_content_in_email_notifications` to the `disabled_notification_settings` object to keep track of the setting. Also added a tooltip message to display when the checkbox is disabled, indicating that the setting is controlled by the organization. Fixes: #27262. --- web/src/settings_config.ts | 3 +++ web/src/tippyjs.ts | 18 ++++++++++++++++++ .../settings/notification_settings.hbs | 1 + 3 files changed, 22 insertions(+) diff --git a/web/src/settings_config.ts b/web/src/settings_config.ts index 19c31b39da..bdfb6bcd97 100644 --- a/web/src/settings_config.ts +++ b/web/src/settings_config.ts @@ -862,6 +862,7 @@ export type AllNotifications = { disabled_notification_settings: { push_notifications: boolean; enable_online_push_notifications: boolean; + message_content_in_email_notifications: boolean; }; }; @@ -898,6 +899,8 @@ export const all_notifications = (settings_object: Settings): AllNotifications = disabled_notification_settings: { push_notifications: !realm.realm_push_notifications_enabled, enable_online_push_notifications: !realm.realm_push_notifications_enabled, + message_content_in_email_notifications: + !realm.realm_message_content_allowed_in_email_notifications, }, }); diff --git a/web/src/tippyjs.ts b/web/src/tippyjs.ts index 1edf8bb8d9..d2c6f1d5b0 100644 --- a/web/src/tippyjs.ts +++ b/web/src/tippyjs.ts @@ -531,6 +531,24 @@ export function initialize(): void { }, }); + tippy.delegate("body", { + target: "#user_message_content_in_email_notifications_label", + onShow(instance) { + if ($("#user_message_content_in_email_notifications").prop("disabled")) { + instance.setContent( + $t({ + defaultMessage: + "Including message content in message notification emails is not allowed in this organization.", + }), + ); + return undefined; + } + instance.destroy(); + return false; + }, + appendTo: () => document.body, + }); + tippy.delegate("body", { target: ".views-tooltip-target", onShow(instance) { diff --git a/web/templates/settings/notification_settings.hbs b/web/templates/settings/notification_settings.hbs index 79168a5cbe..4f654086f9 100644 --- a/web/templates/settings/notification_settings.hbs +++ b/web/templates/settings/notification_settings.hbs @@ -212,6 +212,7 @@ setting_name=this is_checked=(lookup ../settings_object this) label=(lookup ../settings_label this) + is_disabled=(lookup ../disabled_notification_settings this) prefix=../prefix}} {{/each}}