settings: Add a "Followed topics" row to Notification Triggers table.

This commit adds a "Followed topics" row to the 'Notification Triggers'
table in the 'Personal settings > Notifications' panel and the
'Organization settings > Default user settings' panel.

This adds support to control email, push, wildcard mention,
visual desktop, and audible desktop notifications for messages
sent to followed topics by toggling corresponding global
notification settings.

The "Followed topics" row is available in the development
environment only.
This commit is contained in:
Prakhar Pratyush 2023-06-13 16:48:55 +05:30 committed by Tim Abbott
parent 134058b06d
commit cbde01e9e3
6 changed files with 81 additions and 11 deletions

View File

@ -21,6 +21,11 @@ export type RealmDefaultSettings = {
enable_stream_desktop_notifications: boolean;
enable_stream_email_notifications: boolean;
enable_stream_push_notifications: boolean;
enable_followed_topic_desktop_notifications: boolean;
enable_followed_topic_audible_notifications: boolean;
enable_followed_topic_push_notifications: boolean;
enable_followed_topic_email_notifications: boolean;
enable_followed_topic_wildcard_mentions_notify: boolean;
enter_sends: boolean;
escape_navigates_to_default_view: boolean;
fluid_layout_width: boolean;

View File

@ -80,6 +80,7 @@ export function build_page() {
full_name: people.my_full_name(),
date_joined_text: get_parsed_date_of_joining(),
page_params,
development: page_params.development_environment,
enable_sound_select:
user_settings.enable_sounds || user_settings.enable_stream_audible_notifications,
zuliprc: "zuliprc",

View File

@ -5,6 +5,7 @@ import {page_params} from "./page_params";
import type {RealmDefaultSettings} from "./realm_user_settings_defaults";
import type {StreamSpecificNotificationSettings} from "./sub_store";
import type {
FollowedTopicNotificationSettings,
PmNotificationSettings,
StreamNotificationSettings,
UserSettings,
@ -649,6 +650,14 @@ export const pm_mention_notification_settings: (keyof PmNotificationSettings)[]
"enable_offline_email_notifications",
];
export const followed_topic_notification_settings: (keyof FollowedTopicNotificationSettings)[] = [
"enable_followed_topic_desktop_notifications",
"enable_followed_topic_audible_notifications",
"enable_followed_topic_push_notifications",
"enable_followed_topic_email_notifications",
"enable_followed_topic_wildcard_mentions_notify",
];
const desktop_notification_settings = ["pm_content_in_desktop_notifications"];
const mobile_notification_settings = ["enable_online_push_notifications"];
@ -716,6 +725,7 @@ const other_notification_settings = [
];
export const all_notification_settings = [
...followed_topic_notification_settings,
...other_notification_settings,
...pm_mention_notification_settings,
...stream_notification_settings,
@ -790,6 +800,13 @@ export const all_notifications = (settings_object: Settings): AllNotifications =
settings_object,
),
},
{
label: $t({defaultMessage: "Followed topics"}),
notification_settings: get_notifications_table_row_data(
followed_topic_notification_settings,
settings_object,
),
},
],
settings: {
desktop_notification_settings,

View File

@ -13,7 +13,17 @@ export type PmNotificationSettings = {
enable_offline_email_notifications: boolean;
};
export type UserSettings = (StreamNotificationSettings & PmNotificationSettings) & {
export type FollowedTopicNotificationSettings = {
enable_followed_topic_desktop_notifications: boolean;
enable_followed_topic_audible_notifications: boolean;
enable_followed_topic_push_notifications: boolean;
enable_followed_topic_email_notifications: boolean;
enable_followed_topic_wildcard_mentions_notify: boolean;
};
export type UserSettings = (StreamNotificationSettings &
PmNotificationSettings &
FollowedTopicNotificationSettings) & {
color_scheme: number;
default_language: string;
default_view: string;

View File

@ -28,16 +28,18 @@
</thead>
<tbody>
{{#each general_settings}}
<tr>
<td>{{ this.label }}</td>
{{#each this.notification_settings}}
{{> notification_settings_checkboxes
setting_name=this.setting_name
is_checked=this.is_checked
is_disabled=this.is_disabled
prefix=../../prefix }}
{{/each}}
</tr>
{{#unless (and (eq this.label "Followed topics") (not ../development))}}
<tr>
<td>{{ this.label }}</td>
{{#each this.notification_settings}}
{{> notification_settings_checkboxes
setting_name=this.setting_name
is_checked=this.is_checked
is_disabled=this.is_disabled
prefix=../../prefix }}
{{/each}}
</tr>
{{/unless}}
{{/each}}
</tbody>
{{#unless for_realm_settings}}

View File

@ -17,6 +17,11 @@ run_test("all_notifications", () => {
user_settings.enable_sounds = true;
user_settings.enable_offline_push_notifications = false;
user_settings.enable_offline_email_notifications = true;
user_settings.enable_followed_topic_desktop_notifications = false;
user_settings.enable_followed_topic_audible_notifications = true;
user_settings.enable_followed_topic_push_notifications = false;
user_settings.enable_followed_topic_email_notifications = true;
user_settings.enable_followed_topic_wildcard_mentions_notify = false;
// Check that it throws error if incorrect settings name
// is passed. In this case, we articulate that with
@ -97,5 +102,35 @@ run_test("all_notifications", () => {
},
],
},
{
label: "translated: Followed topics",
notification_settings: [
{
is_checked: false,
is_disabled: false,
setting_name: "enable_followed_topic_desktop_notifications",
},
{
is_checked: true,
is_disabled: false,
setting_name: "enable_followed_topic_audible_notifications",
},
{
is_checked: false,
is_disabled: true,
setting_name: "enable_followed_topic_push_notifications",
},
{
is_checked: true,
is_disabled: false,
setting_name: "enable_followed_topic_email_notifications",
},
{
is_checked: false,
is_disabled: false,
setting_name: "enable_followed_topic_wildcard_mentions_notify",
},
],
},
]);
});