Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

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

Prakhar Pratyushcbde01e9e3e5
diff --git a/web/src/realm_user_settings_defaults.ts b/web/src/realm_user_settings_defaults.ts
index b0961449bc2..ac95efeda39 100644
--- a/web/src/realm_user_settings_defaults.ts
+++ b/web/src/realm_user_settings_defaults.ts
@@ -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;
diff --git a/web/src/settings.js b/web/src/settings.js
index 1d3d0a71305..531b80b968c 100644
--- a/web/src/settings.js
+++ b/web/src/settings.js
@@ -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",
diff --git a/web/src/settings_config.ts b/web/src/settings_config.ts
index 1f25171f226..0fead18e4dd 100644
--- a/web/src/settings_config.ts
+++ b/web/src/settings_config.ts
@@ -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,
diff --git a/web/src/user_settings.ts b/web/src/user_settings.ts
index a6dbb61cf5a..1f09d788215 100644
--- a/web/src/user_settings.ts
+++ b/web/src/user_settings.ts
@@ -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;
diff --git a/web/templates/settings/notification_settings.hbs b/web/templates/settings/notification_settings.hbs
index 266216393dd..7583a772cc1 100644
--- a/web/templates/settings/notification_settings.hbs
+++ b/web/templates/settings/notification_settings.hbs
@@ -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}}
diff --git a/web/tests/settings_config.test.js b/web/tests/settings_config.test.js
index 1626821fad4..ff613322b21 100644
--- a/web/tests/settings_config.test.js
+++ b/web/tests/settings_config.test.js
@@ -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",
+ },
+ ],
+ },
]);
});