Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
user_settings: Add option to configure channel click behavior.
Aman Agrawal9fc6b93347a7
diff --git a/api_docs/changelog.md b/api_docs/changelog.mdindex d5cd7fcbf7a..e212931c286 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.pyindex c6afe0f585e..07ca1c5f745 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. Bumpdiff --git a/web/src/admin.js b/web/src/admin.jsindex dfd1ec54fac..46f99377048 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.tsindex 166c18192a6..e67562501b6 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.jsindex 2a341c7778e..5e91a0085e3 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.jsindex 8fdd7427c85..a4456be9087 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.tsindex 82400c641ee..76589bba21a 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.tsindex 99a4f0f7106..ee20f45c17e 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.tsindex 7158240b582..4e5a8b755e4 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_schematranslate_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.hbsindex 27b9e07d012..f6492e4cce5 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_messageprefix=prefix}}+ <div class="input-group">+ <label for="web_channel_default_view" class="settings-field-label">{{t "Channel links in the left sidebar go to" }}</label>+ <select name="web_channel_default_view" class="setting_web_channel_default_view prop-element settings_select bootstrap-focus-style" id="{{prefix}}web_channel_default_view" data-setting-widget-type="number">+ {{> dropdown_options_widget option_values=web_channel_default_view_values}}+ </select>+ </div>+<div class="input-group"><label for="demote_inactive_streams" class="settings-field-label">{{t "Demote inactive channels" }}{{> ../help_link_widget link="/help/manage-inactive-channels" }}diff --git a/web/tests/dispatch.test.js b/web/tests/dispatch.test.jsindex ea3a120c469..d520c9c4be8 100644--- a/web/tests/dispatch.test.js+++ b/web/tests/dispatch.test.js@@ -945,6 +945,11 @@ run_test("user_settings", ({override}) => {dispatch(event);assert_same(user_settings.web_mark_read_on_scroll_policy, 1);+ event = event_fixtures.user_settings__web_channel_default_view;+ user_settings.web_channel_default_view = 2;+ dispatch(event);+ assert_same(user_settings.web_channel_default_view, 1);+event = event_fixtures.user_settings__dense_mode;user_settings.dense_mode = false;override(information_density, "set_base_typography_css_variables", noop);diff --git a/web/tests/lib/events.js b/web/tests/lib/events.jsindex 5ead67fc47e..b24f7594378 100644--- a/web/tests/lib/events.js+++ b/web/tests/lib/events.js@@ -1022,6 +1022,13 @@ exports.fixtures = {value: 2,},+ user_settings__web_channel_default_view: {+ type: "user_settings",+ op: "update",+ property: "web_channel_default_view",+ value: 1,+ },+user_settings__web_escape_navigates_to_home_view: {type: "user_settings",op: "update",diff --git a/zerver/migrations/0548_realmuserdefault_web_channel_default_view_and_more.py b/zerver/migrations/0548_realmuserdefault_web_channel_default_view_and_more.pynew file mode 100644index 00000000000..1571a64e1f6--- /dev/null+++ b/zerver/migrations/0548_realmuserdefault_web_channel_default_view_and_more.py@@ -0,0 +1,22 @@+# Generated by Django 5.0.6 on 2024-07-08 18:20++from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ ("zerver", "0547_realmuserdefault_web_navigate_to_sent_message_and_more"),+ ]++ operations = [+ migrations.AddField(+ model_name="realmuserdefault",+ name="web_channel_default_view",+ field=models.SmallIntegerField(db_default=1, default=1),+ ),+ migrations.AddField(+ model_name="userprofile",+ name="web_channel_default_view",+ field=models.SmallIntegerField(db_default=1, default=1),+ ),+ ]diff --git a/zerver/models/users.py b/zerver/models/users.pyindex 24431db5a53..2e147fab136 100644--- a/zerver/models/users.py+++ b/zerver/models/users.py@@ -116,6 +116,23 @@ class UserBaseSettings(models.Model):web_mark_read_on_scroll_policy = models.SmallIntegerField(default=MARK_READ_ON_SCROLL_ALWAYS)+ # UI setting controlling if clicking on a channel link should open+ # the channel feed (interleaved view) or narrow to the first topic+ # in the channel.++ WEB_CHANNEL_DEFAULT_VIEW_FIRST_TOPIC = 1+ WEB_CHANNEL_DEFAULT_VIEW_CHANNEL_FEED = 2++ WEB_CHANNEL_DEFAULT_VIEW_CHOICES = [+ WEB_CHANNEL_DEFAULT_VIEW_FIRST_TOPIC,+ WEB_CHANNEL_DEFAULT_VIEW_CHANNEL_FEED,+ ]++ web_channel_default_view = models.SmallIntegerField(+ default=WEB_CHANNEL_DEFAULT_VIEW_FIRST_TOPIC,+ db_default=WEB_CHANNEL_DEFAULT_VIEW_FIRST_TOPIC,+ )+# Emoji setsGOOGLE_EMOJISET = "google"GOOGLE_BLOB_EMOJISET = "google-blob"@@ -329,6 +346,7 @@ class UserBaseSettings(models.Model):send_read_receipts=bool,send_stream_typing_notifications=bool,web_mark_read_on_scroll_policy=int,+ web_channel_default_view=int,user_list_style=int,web_stream_unreads_count_display_policy=int,web_font_size_px=int,diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yamlindex 87a9190e422..1773737e3e4 100644--- a/zerver/openapi/zulip.yaml+++ b/zerver/openapi/zulip.yaml@@ -11140,6 +11140,21 @@ paths:- 2- 3example: 1+ web_channel_default_view:+ description: |+ Web/desktop app setting controlling the default navigation+ behavior when clicking on a channel link.++ - 1 - Top topic in the channel+ - 2 - Channel feed++ **Changes**: New in Zulip 9.0 (feature level 269). Previously, this+ was not configurable, and every user had the "Channel feed" behavior.+ type: integer+ enum:+ - 1+ - 2+ example: 1web_font_size_px:description: |User-configured primary `font-size` for the web application, in pixels.@@ -11574,6 +11589,8 @@ paths:contentType: application/jsonweb_mark_read_on_scroll_policy:contentType: application/json+ web_channel_default_view:+ contentType: application/jsonweb_font_size_px:contentType: application/jsonweb_line_height_percent:@@ -14093,6 +14110,17 @@ paths:**Changes**: New in Zulip 7.0 (feature level 175). Previously, there was noway for the user to configure this behavior on the web, and the Zulip web anddesktop apps behaved like the "Always" setting when marking messages as read.+ web_channel_default_view:+ type: integer+ description: |+ Web/desktop app setting controlling the default navigation+ behavior when clicking on a channel link.++ - 1 - Top topic in the channel+ - 2 - Channel feed++ **Changes**: New in Zulip 9.0 (feature level 269). Previously, this+ was not configurable, and every user had the "Channel feed" behavior.starred_message_counts:type: booleandescription: |@@ -16489,6 +16517,17 @@ paths:**Changes**: New in Zulip 7.0 (feature level 175). Previously, there was noway for the user to configure this behavior on the web, and the Zulip web anddesktop apps behaved like the "Always" setting when marking messages as read.+ web_channel_default_view:+ type: integer+ description: |+ Web/desktop app setting controlling the default navigation+ behavior when clicking on a channel link.++ - 1 - Top topic in the channel+ - 2 - Channel feed++ **Changes**: New in Zulip 9.0 (feature level 269). Previously, this+ was not configurable, and every user had the "Channel feed" behavior.starred_message_counts:type: booleandescription: |@@ -17599,6 +17638,21 @@ paths:- 2- 3example: 1+ web_channel_default_view:+ description: |+ Web/desktop app setting controlling the default navigation+ behavior when clicking on a channel link.++ - 1 - Top topic in the channel+ - 2 - Channel feed++ **Changes**: New in Zulip 9.0 (feature level 269). Previously, this+ was not configurable, and every user had the "Channel feed" behavior.+ type: integer+ enum:+ - 1+ - 2+ example: 1starred_message_counts:description: |Whether clients should display the [number of starred@@ -18183,6 +18237,8 @@ paths:contentType: application/jsonweb_mark_read_on_scroll_policy:contentType: application/json+ web_channel_default_view:+ contentType: application/jsonstarred_message_counts:contentType: application/jsonreceives_typing_notifications:diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.pyindex 1d9f9cf81ba..aa969ca3dba 100644--- a/zerver/tests/test_events.py+++ b/zerver/tests/test_events.py@@ -3750,6 +3750,7 @@ class RealmPropertyActionTest(BaseAction):emojiset=[emojiset["key"] for emojiset in RealmUserDefault.emojiset_choices()],demote_inactive_streams=UserProfile.DEMOTE_STREAMS_CHOICES,web_mark_read_on_scroll_policy=UserProfile.WEB_MARK_READ_ON_SCROLL_POLICY_CHOICES,+ web_channel_default_view=UserProfile.WEB_CHANNEL_DEFAULT_VIEW_CHOICES,user_list_style=UserProfile.USER_LIST_STYLE_CHOICES,web_stream_unreads_count_display_policy=UserProfile.WEB_STREAM_UNREADS_COUNT_DISPLAY_POLICY_CHOICES,desktop_icon_count_display=UserProfile.DESKTOP_ICON_COUNT_DISPLAY_CHOICES,@@ -3878,6 +3879,7 @@ class UserDisplayActionTest(BaseAction):web_home_view=["all_messages", "inbox", "recent_topics"],demote_inactive_streams=[2, 3, 1],web_mark_read_on_scroll_policy=[2, 3, 1],+ web_channel_default_view=[2, 1],user_list_style=[1, 2, 3],web_stream_unreads_count_display_policy=[1, 2, 3],web_font_size_px=[12, 16, 18],diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.pyindex 5bac17b85dc..bf3a7ea190b 100644--- a/zerver/tests/test_realm.py+++ b/zerver/tests/test_realm.py@@ -1945,6 +1945,7 @@ class RealmAPITest(ZulipTestCase):emojiset=[emojiset["key"] for emojiset in RealmUserDefault.emojiset_choices()],demote_inactive_streams=UserProfile.DEMOTE_STREAMS_CHOICES,web_mark_read_on_scroll_policy=UserProfile.WEB_MARK_READ_ON_SCROLL_POLICY_CHOICES,+ web_channel_default_view=UserProfile.WEB_CHANNEL_DEFAULT_VIEW_CHOICES,user_list_style=UserProfile.USER_LIST_STYLE_CHOICES,web_stream_unreads_count_display_policy=UserProfile.WEB_STREAM_UNREADS_COUNT_DISPLAY_POLICY_CHOICES,desktop_icon_count_display=UserProfile.DESKTOP_ICON_COUNT_DISPLAY_CHOICES,diff --git a/zerver/tests/test_settings.py b/zerver/tests/test_settings.pyindex 5a4870349eb..6eca17d8839 100644--- a/zerver/tests/test_settings.py+++ b/zerver/tests/test_settings.py@@ -350,6 +350,7 @@ class ChangeSettingsTest(ZulipTestCase):timezone="America/Denver",demote_inactive_streams=2,web_mark_read_on_scroll_policy=2,+ web_channel_default_view=2,user_list_style=2,web_stream_unreads_count_display_policy=2,web_font_size_px=14,@@ -375,6 +376,7 @@ class ChangeSettingsTest(ZulipTestCase):"user_list_style","color_scheme","web_mark_read_on_scroll_policy",+ "web_channel_default_view","web_stream_unreads_count_display_policy",]:data = {setting_name: test_value}@@ -403,6 +405,7 @@ class ChangeSettingsTest(ZulipTestCase):timezone="invalid_US/Mountain",demote_inactive_streams=10,web_mark_read_on_scroll_policy=10,+ web_channel_default_view=10,user_list_style=10,web_stream_unreads_count_display_policy=10,color_scheme=10,diff --git a/zerver/views/realm.py b/zerver/views/realm.pyindex 8f3b0a18155..ad407938ce8 100644--- a/zerver/views/realm.py+++ b/zerver/views/realm.py@@ -540,6 +540,10 @@ def update_realm_user_settings_defaults(json_validator=check_int_in(UserProfile.WEB_MARK_READ_ON_SCROLL_POLICY_CHOICES),default=None,),+ web_channel_default_view: Optional[int] = REQ(+ json_validator=check_int_in(UserProfile.WEB_CHANNEL_DEFAULT_VIEW_CHOICES),+ default=None,+ ),starred_message_counts: Optional[bool] = REQ(json_validator=check_bool, default=None),receives_typing_notifications: Optional[bool] = REQ(json_validator=check_bool, default=None),web_stream_unreads_count_display_policy: Optional[int] = REQ(diff --git a/zerver/views/user_settings.py b/zerver/views/user_settings.pyindex e4fbfaebd7d..25e993202c9 100644--- a/zerver/views/user_settings.py+++ b/zerver/views/user_settings.py@@ -207,6 +207,10 @@ def json_change_settings(json_validator=check_int_in(UserProfile.WEB_MARK_READ_ON_SCROLL_POLICY_CHOICES),default=None,),+ web_channel_default_view: Optional[int] = REQ(+ json_validator=check_int_in(UserProfile.WEB_CHANNEL_DEFAULT_VIEW_CHOICES),+ default=None,+ ),starred_message_counts: Optional[bool] = REQ(json_validator=check_bool, default=None),receives_typing_notifications: Optional[bool] = REQ(json_validator=check_bool, default=None),fluid_layout_width: Optional[bool] = REQ(json_validator=check_bool, default=None),