Skip to content

Commit cbde01e

Browse files
prakhar1144timabbott
authored andcommitted
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.
1 parent 134058b commit cbde01e

File tree

6 files changed

+81
-11
lines changed

6 files changed

+81
-11
lines changed

web/src/realm_user_settings_defaults.ts

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ export type RealmDefaultSettings = {
2121
enable_stream_desktop_notifications: boolean;
2222
enable_stream_email_notifications: boolean;
2323
enable_stream_push_notifications: boolean;
24+
enable_followed_topic_desktop_notifications: boolean;
25+
enable_followed_topic_audible_notifications: boolean;
26+
enable_followed_topic_push_notifications: boolean;
27+
enable_followed_topic_email_notifications: boolean;
28+
enable_followed_topic_wildcard_mentions_notify: boolean;
2429
enter_sends: boolean;
2530
escape_navigates_to_default_view: boolean;
2631
fluid_layout_width: boolean;

web/src/settings.js

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export function build_page() {
8080
full_name: people.my_full_name(),
8181
date_joined_text: get_parsed_date_of_joining(),
8282
page_params,
83+
development: page_params.development_environment,
8384
enable_sound_select:
8485
user_settings.enable_sounds || user_settings.enable_stream_audible_notifications,
8586
zuliprc: "zuliprc",

web/src/settings_config.ts

+17
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {page_params} from "./page_params";
55
import type {RealmDefaultSettings} from "./realm_user_settings_defaults";
66
import type {StreamSpecificNotificationSettings} from "./sub_store";
77
import type {
8+
FollowedTopicNotificationSettings,
89
PmNotificationSettings,
910
StreamNotificationSettings,
1011
UserSettings,
@@ -649,6 +650,14 @@ export const pm_mention_notification_settings: (keyof PmNotificationSettings)[]
649650
"enable_offline_email_notifications",
650651
];
651652

653+
export const followed_topic_notification_settings: (keyof FollowedTopicNotificationSettings)[] = [
654+
"enable_followed_topic_desktop_notifications",
655+
"enable_followed_topic_audible_notifications",
656+
"enable_followed_topic_push_notifications",
657+
"enable_followed_topic_email_notifications",
658+
"enable_followed_topic_wildcard_mentions_notify",
659+
];
660+
652661
const desktop_notification_settings = ["pm_content_in_desktop_notifications"];
653662

654663
const mobile_notification_settings = ["enable_online_push_notifications"];
@@ -716,6 +725,7 @@ const other_notification_settings = [
716725
];
717726

718727
export const all_notification_settings = [
728+
...followed_topic_notification_settings,
719729
...other_notification_settings,
720730
...pm_mention_notification_settings,
721731
...stream_notification_settings,
@@ -790,6 +800,13 @@ export const all_notifications = (settings_object: Settings): AllNotifications =
790800
settings_object,
791801
),
792802
},
803+
{
804+
label: $t({defaultMessage: "Followed topics"}),
805+
notification_settings: get_notifications_table_row_data(
806+
followed_topic_notification_settings,
807+
settings_object,
808+
),
809+
},
793810
],
794811
settings: {
795812
desktop_notification_settings,

web/src/user_settings.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,17 @@ export type PmNotificationSettings = {
1313
enable_offline_email_notifications: boolean;
1414
};
1515

16-
export type UserSettings = (StreamNotificationSettings & PmNotificationSettings) & {
16+
export type FollowedTopicNotificationSettings = {
17+
enable_followed_topic_desktop_notifications: boolean;
18+
enable_followed_topic_audible_notifications: boolean;
19+
enable_followed_topic_push_notifications: boolean;
20+
enable_followed_topic_email_notifications: boolean;
21+
enable_followed_topic_wildcard_mentions_notify: boolean;
22+
};
23+
24+
export type UserSettings = (StreamNotificationSettings &
25+
PmNotificationSettings &
26+
FollowedTopicNotificationSettings) & {
1727
color_scheme: number;
1828
default_language: string;
1929
default_view: string;

web/templates/settings/notification_settings.hbs

+12-10
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,18 @@
2828
</thead>
2929
<tbody>
3030
{{#each general_settings}}
31-
<tr>
32-
<td>{{ this.label }}</td>
33-
{{#each this.notification_settings}}
34-
{{> notification_settings_checkboxes
35-
setting_name=this.setting_name
36-
is_checked=this.is_checked
37-
is_disabled=this.is_disabled
38-
prefix=../../prefix }}
39-
{{/each}}
40-
</tr>
31+
{{#unless (and (eq this.label "Followed topics") (not ../development))}}
32+
<tr>
33+
<td>{{ this.label }}</td>
34+
{{#each this.notification_settings}}
35+
{{> notification_settings_checkboxes
36+
setting_name=this.setting_name
37+
is_checked=this.is_checked
38+
is_disabled=this.is_disabled
39+
prefix=../../prefix }}
40+
{{/each}}
41+
</tr>
42+
{{/unless}}
4143
{{/each}}
4244
</tbody>
4345
{{#unless for_realm_settings}}

web/tests/settings_config.test.js

+35
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ run_test("all_notifications", () => {
1717
user_settings.enable_sounds = true;
1818
user_settings.enable_offline_push_notifications = false;
1919
user_settings.enable_offline_email_notifications = true;
20+
user_settings.enable_followed_topic_desktop_notifications = false;
21+
user_settings.enable_followed_topic_audible_notifications = true;
22+
user_settings.enable_followed_topic_push_notifications = false;
23+
user_settings.enable_followed_topic_email_notifications = true;
24+
user_settings.enable_followed_topic_wildcard_mentions_notify = false;
2025

2126
// Check that it throws error if incorrect settings name
2227
// is passed. In this case, we articulate that with
@@ -97,5 +102,35 @@ run_test("all_notifications", () => {
97102
},
98103
],
99104
},
105+
{
106+
label: "translated: Followed topics",
107+
notification_settings: [
108+
{
109+
is_checked: false,
110+
is_disabled: false,
111+
setting_name: "enable_followed_topic_desktop_notifications",
112+
},
113+
{
114+
is_checked: true,
115+
is_disabled: false,
116+
setting_name: "enable_followed_topic_audible_notifications",
117+
},
118+
{
119+
is_checked: false,
120+
is_disabled: true,
121+
setting_name: "enable_followed_topic_push_notifications",
122+
},
123+
{
124+
is_checked: true,
125+
is_disabled: false,
126+
setting_name: "enable_followed_topic_email_notifications",
127+
},
128+
{
129+
is_checked: false,
130+
is_disabled: false,
131+
setting_name: "enable_followed_topic_wildcard_mentions_notify",
132+
},
133+
],
134+
},
100135
]);
101136
});

0 commit comments

Comments
 (0)