From 9fc6b93347a735d398351f695bbe914be468e849 Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Wed, 3 Jul 2024 10:43:47 +0000 Subject: [PATCH] user_settings: Add option to configure channel click behavior. This commit does not implement the setting's behavior, just the API change and settings UI. --- api_docs/changelog.md | 8 +++ version.py | 2 +- web/src/admin.js | 1 + web/src/realm_user_settings_defaults.ts | 1 + web/src/server_events_dispatch.js | 1 + web/src/settings.js | 1 + web/src/settings_config.ts | 11 ++++ web/src/settings_preferences.ts | 3 + web/src/user_settings.ts | 1 + web/templates/settings/display_settings.hbs | 7 +++ web/tests/dispatch.test.js | 5 ++ web/tests/lib/events.js | 7 +++ ...fault_web_channel_default_view_and_more.py | 22 ++++++++ zerver/models/users.py | 18 ++++++ zerver/openapi/zulip.yaml | 56 +++++++++++++++++++ zerver/tests/test_events.py | 2 + zerver/tests/test_realm.py | 1 + zerver/tests/test_settings.py | 3 + zerver/views/realm.py | 4 ++ zerver/views/user_settings.py | 4 ++ 20 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 zerver/migrations/0548_realmuserdefault_web_channel_default_view_and_more.py diff --git a/api_docs/changelog.md b/api_docs/changelog.md index d5cd7fcbf7..e212931c28 100644 --- a/api_docs/changelog.md +++ b/api_docs/changelog.md @@ -20,6 +20,14 @@ format used by the Zulip server that they are interacting with. ## Changes in Zulip 9.0 +**Feature level 269** + +* [`POST /register`](/api/register-queue), [`PATCH + /settings`](/api/update-settings), [`PATCH + /realm/user_settings_defaults`](/api/update-realm-user-settings-defaults): + Added new user setting `web_channel_default_view`, controlling the + behavior of clicking a channel link in the web/desktop apps. + **Feature level 268** * [`PATCH /realm/user_settings_defaults`](/api/update-realm-user-settings-defaults), diff --git a/version.py b/version.py index c6afe0f585..07ca1c5f74 100644 --- a/version.py +++ b/version.py @@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.9.3" # Changes should be accompanied by documentation explaining what the # new level means in api_docs/changelog.md, as well as "**Changes**" # entries in the endpoint's documentation in `zulip.yaml`. -API_FEATURE_LEVEL = 268 +API_FEATURE_LEVEL = 269 # Bump the minor PROVISION_VERSION to indicate that folks should provision # only when going from an old version of the code to a newer version. Bump diff --git a/web/src/admin.js b/web/src/admin.js index dfd1ec54fa..46f9937704 100644 --- a/web/src/admin.js +++ b/web/src/admin.js @@ -188,6 +188,7 @@ export function build_page() { demote_inactive_streams_values: settings_config.demote_inactive_streams_values, web_mark_read_on_scroll_policy_values: settings_config.web_mark_read_on_scroll_policy_values, + web_channel_default_view_values: settings_config.web_channel_default_view_values, user_list_style_values: settings_config.user_list_style_values, web_stream_unreads_count_display_policy_values: settings_config.web_stream_unreads_count_display_policy_values, diff --git a/web/src/realm_user_settings_defaults.ts b/web/src/realm_user_settings_defaults.ts index 166c18192a..e67562501b 100644 --- a/web/src/realm_user_settings_defaults.ts +++ b/web/src/realm_user_settings_defaults.ts @@ -52,6 +52,7 @@ export const realm_default_settings_schema = z.object({ translate_emoticons: z.boolean(), twenty_four_hour_time: z.boolean(), user_list_style: z.number(), + web_channel_default_view: z.number(), web_escape_navigates_to_home_view: z.boolean(), web_font_size_px: z.number(), web_home_view: z.string(), diff --git a/web/src/server_events_dispatch.js b/web/src/server_events_dispatch.js index 2a341c7778..5e91a0085e 100644 --- a/web/src/server_events_dispatch.js +++ b/web/src/server_events_dispatch.js @@ -704,6 +704,7 @@ export function dispatch_normal_event(event) { "demote_inactive_streams", "dense_mode", "web_mark_read_on_scroll_policy", + "web_channel_default_view", "emojiset", "web_escape_navigates_to_home_view", "fluid_layout_width", diff --git a/web/src/settings.js b/web/src/settings.js index 8fdd7427c8..a4456be908 100644 --- a/web/src/settings.js +++ b/web/src/settings.js @@ -103,6 +103,7 @@ export function build_page() { demote_inactive_streams_values: settings_config.demote_inactive_streams_values, web_mark_read_on_scroll_policy_values: settings_config.web_mark_read_on_scroll_policy_values, + web_channel_default_view_values: settings_config.web_channel_default_view_values, user_list_style_values: settings_config.user_list_style_values, web_stream_unreads_count_display_policy_values: settings_config.web_stream_unreads_count_display_policy_values, diff --git a/web/src/settings_config.ts b/web/src/settings_config.ts index 82400c641e..76589bba21 100644 --- a/web/src/settings_config.ts +++ b/web/src/settings_config.ts @@ -57,6 +57,17 @@ export const web_mark_read_on_scroll_policy_values = { }, }; +export const web_channel_default_view_values = { + top_topic_in_channel: { + code: 1, + description: $t({defaultMessage: "Top topic in the channel"}), + }, + channel_feed: { + code: 2, + description: $t({defaultMessage: "Channel feed"}), + }, +}; + export const user_list_style_values = { compact: { code: 1, diff --git a/web/src/settings_preferences.ts b/web/src/settings_preferences.ts index 99a4f0f710..ee20f45c17 100644 --- a/web/src/settings_preferences.ts +++ b/web/src/settings_preferences.ts @@ -208,6 +208,9 @@ export function set_up(settings_panel: SettingsPanel): void { $container .find(".setting_web_mark_read_on_scroll_policy") .val(settings_object.web_mark_read_on_scroll_policy); + $container + .find(".setting_web_channel_default_view") + .val(settings_object.web_channel_default_view); $container .find(`.setting_emojiset_choice[value="${CSS.escape(settings_object.emojiset)}"]`) .prop("checked", true); diff --git a/web/src/user_settings.ts b/web/src/user_settings.ts index 7158240b58..4e5a8b755e 100644 --- a/web/src/user_settings.ts +++ b/web/src/user_settings.ts @@ -71,6 +71,7 @@ export const user_settings_schema = stream_notification_settings_schema translate_emoticons: z.boolean(), twenty_four_hour_time: z.boolean(), user_list_style: z.number(), + web_channel_default_view: z.number(), web_escape_navigates_to_home_view: z.boolean(), web_font_size_px: z.number(), web_home_view: z.enum(["inbox", "recent_topics", "all_messages"]), diff --git a/web/templates/settings/display_settings.hbs b/web/templates/settings/display_settings.hbs index 27b9e07d01..f6492e4cce 100644 --- a/web/templates/settings/display_settings.hbs +++ b/web/templates/settings/display_settings.hbs @@ -145,6 +145,13 @@ label=settings_label.web_navigate_to_sent_message prefix=prefix}} +
+ + +
+