From c8bcb422f51b3e933a6dbb12e1f702037d89f20b Mon Sep 17 00:00:00 2001 From: Ujjawal Modi Date: Wed, 12 Jul 2023 16:27:57 +0530 Subject: [PATCH] streams: Rename `can_remove_subscribers_group_id` parameter. Earlier the API endpoints related to streams accepts and returns a field `can_remove_subscribers_group_id` which represents the ID of user_group whose members can remove subscribers from stream. This commit renames this field to `can_remove_subscribers_group`. --- api_docs/changelog.md | 11 ++++ version.py | 2 +- web/src/settings_org.js | 6 +- web/src/stream_create.js | 2 +- web/src/stream_data.js | 4 +- web/src/stream_edit.js | 4 +- web/src/stream_events.js | 2 +- web/src/stream_settings_ui.js | 4 +- .../stream_settings/stream_creation_form.hbs | 2 +- .../stream_settings/stream_settings.hbs | 2 +- web/tests/lib/events.js | 4 +- web/tests/stream_data.test.js | 18 +++--- web/tests/stream_events.test.js | 4 +- web/tests/stream_settings_ui.test.js | 10 ++-- zerver/actions/streams.py | 4 +- zerver/lib/event_schema.py | 4 +- zerver/lib/subscription_info.py | 7 +-- zerver/lib/types.py | 6 +- zerver/models.py | 2 +- zerver/openapi/zulip.yaml | 56 ++++++++++++------- zerver/tests/test_subs.py | 35 ++++++------ zerver/views/streams.py | 14 +++-- 22 files changed, 118 insertions(+), 85 deletions(-) diff --git a/api_docs/changelog.md b/api_docs/changelog.md index 1b704a3e67..1e7086a447 100644 --- a/api_docs/changelog.md +++ b/api_docs/changelog.md @@ -20,6 +20,17 @@ format used by the Zulip server that they are interacting with. ## Changes in Zulip 8.0 +**Feature level 197** + +* [`POST /users/me/subscriptions`](/api/subscribe), + [`PATCH /streams/{stream_id}`](/api/update-stream), + [`GET users/me/subscriptions`](/api/get-subscriptions), + [`GET /streams`](/api/get-streams), + [`POST /register`](/api/register-queue), + [`GET /events`](/api/get-events): Renamed + stream setting `can_remove_subscribers_group_id` + to `can_remove_subscribers_group`. + **Feature level 196** * [`POST /realm/playgrounds`](/api/add-code-playground): `url_prefix` is diff --git a/version.py b/version.py index 974b949e2a..09f0cd958b 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 = 196 +API_FEATURE_LEVEL = 197 # 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/settings_org.js b/web/src/settings_org.js index 4559ab09c5..55fe5a5e42 100644 --- a/web/src/settings_org.js +++ b/web/src/settings_org.js @@ -600,7 +600,7 @@ export function get_widget_for_dropdown_list_settings(property_name) { return signup_notifications_stream_widget; case "realm_default_code_block_language": return default_code_language_widget; - case "can_remove_subscribers_group_id": + case "can_remove_subscribers_group": return stream_edit.can_remove_subscribers_group_widget; default: blueslip.error("No dropdown list widget for property", {property_name}); @@ -641,7 +641,7 @@ export function discard_property_element_changes(elem, for_realm_default_setting case "realm_notifications_stream_id": case "realm_signup_notifications_stream_id": case "realm_default_code_block_language": - case "can_remove_subscribers_group_id": + case "can_remove_subscribers_group": set_dropdown_list_widget_setting_value(property_name, property_value); break; case "realm_default_language": @@ -957,7 +957,7 @@ export function check_property_changed(elem, for_realm_default_settings, sub) { case "realm_notifications_stream_id": case "realm_signup_notifications_stream_id": case "realm_default_code_block_language": - case "can_remove_subscribers_group_id": + case "can_remove_subscribers_group": proposed_val = get_dropdown_list_widget_setting_value($elem, false); break; case "email_notifications_batching_period_seconds": diff --git a/web/src/stream_create.js b/web/src/stream_create.js index 0efdb64eab..d025d56970 100644 --- a/web/src/stream_create.js +++ b/web/src/stream_create.js @@ -259,7 +259,7 @@ function create_stream() { stream_settings_ui.new_stream_can_remove_subscribers_group_widget.value(), 10, ); - data.can_remove_subscribers_group_id = can_remove_subscribers_group_id; + data.can_remove_subscribers_group = can_remove_subscribers_group_id; loading.make_indicator($("#stream_creating_indicator"), { text: $t({defaultMessage: "Creating stream..."}), diff --git a/web/src/stream_data.js b/web/src/stream_data.js index 0b6e2e7253..7fefa49fe5 100644 --- a/web/src/stream_data.js +++ b/web/src/stream_data.js @@ -430,7 +430,7 @@ export function update_message_retention_setting(sub, message_retention_days) { } export function update_can_remove_subscribers_group_id(sub, can_remove_subscribers_group_id) { - sub.can_remove_subscribers_group_id = can_remove_subscribers_group_id; + sub.can_remove_subscribers_group = can_remove_subscribers_group_id; } export function receives_notifications(stream_id, notification_name) { @@ -558,7 +558,7 @@ export function can_unsubscribe_others(sub) { } return user_groups.is_user_in_group( - sub.can_remove_subscribers_group_id, + sub.can_remove_subscribers_group, people.my_current_user_id(), ); } diff --git a/web/src/stream_edit.js b/web/src/stream_edit.js index 328f57c65a..b260d8c215 100644 --- a/web/src/stream_edit.js +++ b/web/src/stream_edit.js @@ -210,13 +210,13 @@ export function show_settings_for(node) { }); const opts = { - widget_name: "can_remove_subscribers_group_id", + widget_name: "can_remove_subscribers_group", data: user_groups.get_realm_user_groups_for_dropdown_list_widget( "can_remove_subscribers_group", ), default_text: $t({defaultMessage: "No user groups"}), include_current_item: false, - value: sub.can_remove_subscribers_group_id, + value: sub.can_remove_subscribers_group, on_update() { settings_org.save_discard_widget_status_handler( $("#stream_permission_settings"), diff --git a/web/src/stream_events.js b/web/src/stream_events.js index 773432086e..91aca7522d 100644 --- a/web/src/stream_events.js +++ b/web/src/stream_events.js @@ -93,7 +93,7 @@ export function update_property(stream_id, property, value, other_values) { case "message_retention_days": stream_settings_ui.update_message_retention_setting(sub, value); break; - case "can_remove_subscribers_group_id": + case "can_remove_subscribers_group": stream_settings_ui.update_can_remove_subscribers_group_id(sub, value); break; default: diff --git a/web/src/stream_settings_ui.js b/web/src/stream_settings_ui.js index a4cebb09b7..3def45dbf4 100644 --- a/web/src/stream_settings_ui.js +++ b/web/src/stream_settings_ui.js @@ -247,7 +247,7 @@ export function update_message_retention_setting(sub, new_value) { export function update_can_remove_subscribers_group_id(sub, new_value) { stream_data.update_can_remove_subscribers_group_id(sub, new_value); - stream_ui_updates.update_setting_element(sub, "can_remove_subscribers_group_id"); + stream_ui_updates.update_setting_element(sub, "can_remove_subscribers_group"); stream_edit_subscribers.rerender_subscribers_list(sub); } @@ -665,7 +665,7 @@ export function setup_page(callback) { $("#streams_overlay_container").empty(); const opts = { - widget_name: "new_stream_can_remove_subscribers_group_id", + widget_name: "new_stream_can_remove_subscribers_group", data: user_groups.get_realm_user_groups_for_dropdown_list_widget( "can_remove_subscribers_group", ), diff --git a/web/templates/stream_settings/stream_creation_form.hbs b/web/templates/stream_settings/stream_creation_form.hbs index 9409f777e0..0ae3e2b1e2 100644 --- a/web/templates/stream_settings/stream_creation_form.hbs +++ b/web/templates/stream_settings/stream_creation_form.hbs @@ -32,7 +32,7 @@ {{> stream_types stream_post_policy=stream_post_policy_values.everyone.code is_stream_edit=false - can_remove_subscribers_setting_widget_name="new_stream_can_remove_subscribers_group_id" }} + can_remove_subscribers_setting_widget_name="new_stream_can_remove_subscribers_group" }}
diff --git a/web/templates/stream_settings/stream_settings.hbs b/web/templates/stream_settings/stream_settings.hbs index 924038b906..84c9f557b6 100644 --- a/web/templates/stream_settings/stream_settings.hbs +++ b/web/templates/stream_settings/stream_settings.hbs @@ -61,7 +61,7 @@ is_business_type_org=../is_business_type_org org_level_message_retention_setting=../org_level_message_retention_setting is_stream_edit=true - can_remove_subscribers_setting_widget_name="can_remove_subscribers_group_id" }} + can_remove_subscribers_setting_widget_name="can_remove_subscribers_group" }} {{/with}}