diff --git a/api_docs/changelog.md b/api_docs/changelog.md index fec0f149ca..5ed0a9678c 100644 --- a/api_docs/changelog.md +++ b/api_docs/changelog.md @@ -23,8 +23,11 @@ format used by the Zulip server that they are interacting with. **Feature level 200** * [`PATCH /streams/{stream_id}`](/api/update-stream): Added - `is_default_stream` parameter to add or remove the stream as a default - stream for new users. + `is_default_stream` parameter to change whether the stream is a + default stream for new users in the organization. +* [`POST /users/me/subscriptions`](/api/subscribe): Added + `is_default_stream` parameter which determines whether any streams + created by this request will be default streams for new users. **Feature level 199** diff --git a/version.py b/version.py index 1a07bf517e..695a3b5798 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 = 199 +API_FEATURE_LEVEL = 200 # 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/stream_create.js b/web/src/stream_create.js index d025d56970..af349b6b05 100644 --- a/web/src/stream_create.js +++ b/web/src/stream_create.js @@ -217,6 +217,9 @@ function create_stream() { data.invite_only = JSON.stringify(invite_only); data.history_public_to_subscribers = JSON.stringify(history_public_to_subscribers); + const default_stream = $("#stream_creation_form .is_default_stream").prop("checked"); + data.is_default_stream = JSON.stringify(default_stream); + const stream_post_policy = Number.parseInt( $("#stream_creation_form select[name=stream-post-policy]").val(), 10, @@ -370,8 +373,10 @@ export function show_new_stream_modal() { true, ); - // set default state for "announce stream" option. + // set default state for "announce stream" and "default stream" option. + $("#stream_creation_form .default-stream input").prop("checked", false); update_announce_stream_state(); + stream_ui_updates.update_default_stream_and_stream_privacy_state($("#stream-creation")); clear_error_display(); } @@ -381,7 +386,14 @@ export function set_up_handlers() { const $container = $("#stream-creation").expectOne(); - $container.on("change", ".stream-privacy-values input", update_announce_stream_state); + $container.on("change", ".stream-privacy-values input", () => { + update_announce_stream_state(); + stream_ui_updates.update_default_stream_and_stream_privacy_state($container); + }); + + $container.on("change", ".default-stream input", () => { + stream_ui_updates.update_default_stream_and_stream_privacy_state($container); + }); $container.on("click", ".finalize_create_stream", (e) => { e.preventDefault(); diff --git a/web/src/stream_settings_ui.js b/web/src/stream_settings_ui.js index 024abfda0a..33b0f08a1a 100644 --- a/web/src/stream_settings_ui.js +++ b/web/src/stream_settings_ui.js @@ -717,6 +717,7 @@ export function setup_page(callback) { stream_privacy_policy_values: stream_data.stream_privacy_policy_values, stream_privacy_policy, stream_post_policy_values: stream_data.stream_post_policy_values, + check_default_stream: false, zulip_plan_is_not_limited: page_params.zulip_plan_is_not_limited, org_level_message_retention_setting: stream_edit.get_display_text_for_realm_message_retention_setting(), diff --git a/web/src/stream_ui_updates.js b/web/src/stream_ui_updates.js index f09c71ed85..61bbff5bd9 100644 --- a/web/src/stream_ui_updates.js +++ b/web/src/stream_ui_updates.js @@ -115,6 +115,15 @@ export function update_regular_sub_settings(sub) { export function update_default_stream_and_stream_privacy_state($container) { const $default_stream = $container.find(".default-stream"); + const is_stream_creation = $container.attr("id") === "stream-creation"; + + // In the stream creation UI, if the user is a non-admin hide the + // "Default stream for new users" widget + if (is_stream_creation && !page_params.is_admin) { + $default_stream.hide(); + return; + } + const privacy_type = $container.find("input[type=radio][name=privacy]:checked").val(); const is_invite_only = privacy_type === "invite-only" || privacy_type === "invite-only-public-history"; diff --git a/web/templates/stream_settings/stream_types.hbs b/web/templates/stream_settings/stream_types.hbs index 99419f3259..5db410fd22 100644 --- a/web/templates/stream_settings/stream_types.hbs +++ b/web/templates/stream_settings/stream_types.hbs @@ -16,17 +16,15 @@ -{{#if is_stream_edit}} -
- {{> ../settings/settings_checkbox - prefix="id_" - setting_name="is_default_stream" - is_checked=check_default_stream - label="Default stream for new users" - help_link="/help/set-default-streams-for-new-users" - }} -
-{{/if}} +
+ {{> ../settings/settings_checkbox + prefix="id_" + setting_name="is_default_stream" + is_checked=check_default_stream + label="Default stream for new users" + help_link="/help/set-default-streams-for-new-users" + }} +