diff --git a/api_docs/changelog.md b/api_docs/changelog.md index 83ede5b2c7..f6673e0718 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 8.0 +**Feature level 210** + +* [`POST /register`](/api/register-queue), [`PATCH /settings`](/api/update-settings), + [`PATCH /realm/user_settings_defaults`](/api/update-realm-user-settings-defaults): + Added new `web_stream_unreads_count_display_policy` display setting, which controls in + which streams (all/unmuted/none) unread messages count shows up + in left sidebar. + **Feature level 209** * `PATCH /realm`, [`POST /register`](/api/register-queue), diff --git a/version.py b/version.py index e10ee46433..2f0626b42d 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 = 209 +API_FEATURE_LEVEL = 210 # 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/zerver/migrations/0474_realmuserdefault_web_stream_unreads_count_display_policy_and_more.py b/zerver/migrations/0474_realmuserdefault_web_stream_unreads_count_display_policy_and_more.py new file mode 100644 index 0000000000..e6a8b2e584 --- /dev/null +++ b/zerver/migrations/0474_realmuserdefault_web_stream_unreads_count_display_policy_and_more.py @@ -0,0 +1,22 @@ +# Generated by Django 4.2.4 on 2023-08-27 04:01 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("zerver", "0473_remove_message_non_realm_id_indexes"), + ] + + operations = [ + migrations.AddField( + model_name="realmuserdefault", + name="web_stream_unreads_count_display_policy", + field=models.PositiveSmallIntegerField(default=2), + ), + migrations.AddField( + model_name="userprofile", + name="web_stream_unreads_count_display_policy", + field=models.PositiveSmallIntegerField(default=2), + ), + ] diff --git a/zerver/models.py b/zerver/models.py index 1a55cb2afd..8f12dc3bfe 100644 --- a/zerver/models.py +++ b/zerver/models.py @@ -1568,6 +1568,19 @@ class UserBaseSettings(models.Model): ] user_list_style = models.PositiveSmallIntegerField(default=USER_LIST_STYLE_WITH_STATUS) + # Show unread counts for + WEB_STREAM_UNREADS_COUNT_DISPLAY_POLICY_ALL_STREAMS = 1 + WEB_STREAM_UNREADS_COUNT_DISPLAY_POLICY_UNMUTED_STREAMS = 2 + WEB_STREAM_UNREADS_COUNT_DISPLAY_POLICY_NO_STREAMS = 3 + WEB_STREAM_UNREADS_COUNT_DISPLAY_POLICY_CHOICES = [ + WEB_STREAM_UNREADS_COUNT_DISPLAY_POLICY_ALL_STREAMS, + WEB_STREAM_UNREADS_COUNT_DISPLAY_POLICY_UNMUTED_STREAMS, + WEB_STREAM_UNREADS_COUNT_DISPLAY_POLICY_NO_STREAMS, + ] + web_stream_unreads_count_display_policy = models.PositiveSmallIntegerField( + default=WEB_STREAM_UNREADS_COUNT_DISPLAY_POLICY_UNMUTED_STREAMS + ) + ### Notifications settings. ### email_notifications_batching_period_seconds = models.IntegerField(default=120) @@ -1710,6 +1723,7 @@ class UserBaseSettings(models.Model): send_stream_typing_notifications=bool, web_mark_read_on_scroll_policy=int, user_list_style=int, + web_stream_unreads_count_display_policy=int, ) modern_notification_settings: Dict[str, Any] = dict( diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml index 030f2cff02..4ff76c07e3 100644 --- a/zerver/openapi/zulip.yaml +++ b/zerver/openapi/zulip.yaml @@ -9868,6 +9868,25 @@ paths: - 2 - 3 example: 1 + - name: web_stream_unreads_count_display_policy + in: query + description: | + Configuration for which streams should be displayed with a numeric unread count in the left sidebar. + Streams that do not have an unread count will have a simple dot indicator for whether there are any + unread messages. + + - 1 - All streams + - 2 - Unmuted streams + - 3 - No streams + + **Changes**: New in Zulip 8.0 (feature level 210). + schema: + type: integer + enum: + - 1 + - 2 + - 3 + example: 2 - name: enable_stream_desktop_notifications in: query description: | @@ -12116,6 +12135,18 @@ paths: - 3 - With avatar and status **Changes**: New in Zulip 6.0 (feature level 141). + web_stream_unreads_count_display_policy: + type: integer + description: | + Configuration for which streams should be displayed with a numeric unread count in the left sidebar. + Streams that do not have an unread count will have a simple dot indicator for whether there are any + unread messages. + + - 1 - All streams + - 2 - Unmuted streams + - 3 - No streams + + **Changes**: New in Zulip 8.0 (feature level 210). timezone: type: string description: | @@ -14229,6 +14260,18 @@ paths: - 3 - With avatar and status **Changes**: New in Zulip 6.0 (feature level 141). + web_stream_unreads_count_display_policy: + type: integer + description: | + Configuration for which streams should be displayed with a numeric unread count in the left sidebar. + Streams that do not have an unread count will have a simple dot indicator for whether there are any + unread messages. + + - 1 - All streams + - 2 - Unmuted streams + - 3 - No streams + + **Changes**: New in Zulip 8.0 (feature level 210). enable_stream_desktop_notifications: type: boolean description: | @@ -15301,6 +15344,25 @@ paths: - 2 - 3 example: 1 + - name: web_stream_unreads_count_display_policy + in: query + description: | + Configuration for which streams should be displayed with a numeric unread count in the left sidebar. + Streams that do not have an unread count will have a simple dot indicator for whether there are any + unread messages. + + - 1 - All streams + - 2 - Unmuted streams + - 3 - No streams + + **Changes**: New in Zulip 8.0 (feature level 210). + schema: + type: integer + enum: + - 1 + - 2 + - 3 + example: 2 - name: timezone in: query description: | diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py index 503a00b65b..e26f104e4d 100644 --- a/zerver/tests/test_events.py +++ b/zerver/tests/test_events.py @@ -3092,6 +3092,7 @@ class RealmPropertyActionTest(BaseAction): demote_inactive_streams=UserProfile.DEMOTE_STREAMS_CHOICES, web_mark_read_on_scroll_policy=UserProfile.WEB_MARK_READ_ON_SCROLL_POLICY_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=[1, 2, 3], notification_sound=["zulip", "ding"], email_notifications_batching_period_seconds=[120, 300], @@ -3171,6 +3172,7 @@ class UserDisplayActionTest(BaseAction): demote_inactive_streams=[2, 3, 1], web_mark_read_on_scroll_policy=[2, 3, 1], user_list_style=[1, 2, 3], + web_stream_unreads_count_display_policy=[1, 2, 3], color_scheme=[2, 3, 1], email_address_visibility=[5, 4, 1, 2, 3], ) diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.py index 75ffe83966..93aed4df05 100644 --- a/zerver/tests/test_realm.py +++ b/zerver/tests/test_realm.py @@ -1304,6 +1304,7 @@ class RealmAPITest(ZulipTestCase): demote_inactive_streams=UserProfile.DEMOTE_STREAMS_CHOICES, web_mark_read_on_scroll_policy=UserProfile.WEB_MARK_READ_ON_SCROLL_POLICY_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=[1, 2, 3], notification_sound=["zulip", "ding"], email_notifications_batching_period_seconds=[120, 300], diff --git a/zerver/tests/test_settings.py b/zerver/tests/test_settings.py index b901ee8d7e..007b28e1fd 100644 --- a/zerver/tests/test_settings.py +++ b/zerver/tests/test_settings.py @@ -355,6 +355,7 @@ class ChangeSettingsTest(ZulipTestCase): demote_inactive_streams=2, web_mark_read_on_scroll_policy=2, user_list_style=2, + web_stream_unreads_count_display_policy=2, color_scheme=2, email_notifications_batching_period_seconds=100, notification_sound="ding", @@ -374,6 +375,7 @@ class ChangeSettingsTest(ZulipTestCase): "user_list_style", "color_scheme", "web_mark_read_on_scroll_policy", + "web_stream_unreads_count_display_policy", ]: data = {setting_name: test_value} else: @@ -402,6 +404,7 @@ class ChangeSettingsTest(ZulipTestCase): demote_inactive_streams=10, web_mark_read_on_scroll_policy=10, user_list_style=10, + web_stream_unreads_count_display_policy=10, color_scheme=10, notification_sound="invalid_sound", desktop_icon_count_display=10, diff --git a/zerver/views/realm.py b/zerver/views/realm.py index 560f49987c..cb2a584b8c 100644 --- a/zerver/views/realm.py +++ b/zerver/views/realm.py @@ -438,6 +438,10 @@ def update_realm_user_settings_defaults( default=None, ), starred_message_counts: Optional[bool] = REQ(json_validator=check_bool, default=None), + web_stream_unreads_count_display_policy: Optional[int] = REQ( + json_validator=check_int_in(UserProfile.WEB_STREAM_UNREADS_COUNT_DISPLAY_POLICY_CHOICES), + default=None, + ), fluid_layout_width: Optional[bool] = REQ(json_validator=check_bool, default=None), high_contrast_mode: Optional[bool] = REQ(json_validator=check_bool, default=None), color_scheme: Optional[int] = REQ( diff --git a/zerver/views/user_settings.py b/zerver/views/user_settings.py index 248002bd0b..0bf390a73a 100644 --- a/zerver/views/user_settings.py +++ b/zerver/views/user_settings.py @@ -197,6 +197,10 @@ def json_change_settings( demote_inactive_streams: Optional[int] = REQ( json_validator=check_int_in(UserProfile.DEMOTE_STREAMS_CHOICES), default=None ), + web_stream_unreads_count_display_policy: Optional[int] = REQ( + json_validator=check_int_in(UserProfile.WEB_STREAM_UNREADS_COUNT_DISPLAY_POLICY_CHOICES), + default=None, + ), timezone: Optional[str] = REQ(str_validator=check_timezone, default=None), email_notifications_batching_period_seconds: Optional[int] = REQ( json_validator=check_int, default=None