Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
stream: Show warning when admin removes last user from a private stream.
Akarsh Jain545c4caa051f
diff --git a/web/src/stream_edit_subscribers.js b/web/src/stream_edit_subscribers.jsindex 6275d6859fa..9be3c9662f4 100644--- a/web/src/stream_edit_subscribers.js+++ b/web/src/stream_edit_subscribers.js@@ -256,22 +256,45 @@ function remove_subscriber({stream_id, target_user_id, $list_entry}) {);}- if (sub.invite_only && people.is_my_user_id(target_user_id)) {+ if (sub.invite_only) {const sub_count = peer_data.get_subscriber_count(stream_id);+ const unsubscribing_other_user = !people.is_my_user_id(target_user_id);++ if (!people.is_my_user_id(target_user_id) && sub_count !== 1) {+ // We do not show any confirmation modal if any other user is+ // being unsubscribed and that user is not the last subscriber+ // of that stream.+ remove_user_from_private_stream();+ return;+ }+const stream_name_with_privacy_symbol_html = render_inline_decorated_stream_name({stream: sub,});const html_body = render_unsubscribe_private_stream_modal({- unsubscribing_other_user: false,+ unsubscribing_other_user,display_stream_archive_warning: sub_count === 1,});- confirm_dialog.launch({- html_heading: $t_html(+ let html_heading;+ if (unsubscribing_other_user) {+ html_heading = $t_html(+ {defaultMessage: "Unsubscribe {full_name} from <z-link></z-link>?"},+ {+ full_name: people.get_full_name(target_user_id),+ "z-link": () => stream_name_with_privacy_symbol_html,+ },+ );+ } else {+ html_heading = $t_html({defaultMessage: "Unsubscribe from <z-link></z-link>?"},{"z-link": () => stream_name_with_privacy_symbol_html},- ),+ );+ }++ confirm_dialog.launch({+ html_heading,html_body,on_click: remove_user_from_private_stream,});diff --git a/web/src/user_profile.js b/web/src/user_profile.jsindex 181b64bd047..ef2d3dbf18c 100644--- a/web/src/user_profile.js+++ b/web/src/user_profile.js@@ -26,6 +26,7 @@ import * as ListWidget from "./list_widget";import * as loading from "./loading";import * as modals from "./modals";import {page_params} from "./page_params";+import * as peer_data from "./peer_data";import * as people from "./people";import * as settings_config from "./settings_config";import * as settings_data from "./settings_data";@@ -873,7 +874,11 @@ export function initialize() {ui_report.client_error(error_message, $alert_box, 1200);}- if (sub.invite_only && people.is_my_user_id(target_user_id)) {+ if (+ sub.invite_only &&+ (people.is_my_user_id(target_user_id) ||+ peer_data.get_subscriber_count(stream_id) === 1)+ ) {const new_hash = hash_util.stream_edit_url(sub);hide_user_profile();browser_history.go_to_location(new_hash);diff --git a/web/templates/confirm_dialog/confirm_unsubscribe_private_stream.hbs b/web/templates/confirm_dialog/confirm_unsubscribe_private_stream.hbsindex 3cb4b2f8a7c..d49a5885b6a 100644--- a/web/templates/confirm_dialog/confirm_unsubscribe_private_stream.hbs+++ b/web/templates/confirm_dialog/confirm_unsubscribe_private_stream.hbs@@ -3,9 +3,16 @@{{/unless}}{{#if display_stream_archive_warning}}<p>- {{#tr}}- Because you are the only subscriber, this stream will be automatically <z-link>archived</z-link>.- {{#*inline "z-link"}}<a target="_blank" rel="noopener noreferrer" href="/help/archive-a-stream">{{> @partial-block}}</a>{{/inline}}- {{/tr}}+ {{#if unsubscribing_other_user}}+ {{#tr}}+ Because you are removing the last subscriber from a private stream, it will be automatically <z-link>archived</z-link>.+ {{#*inline "z-link"}}<a target="_blank" rel="noopener noreferrer" href="/help/archive-a-stream">{{> @partial-block}}</a>{{/inline}}+ {{/tr}}+ {{else}}+ {{#tr}}+ Because you are the only subscriber, this stream will be automatically <z-link>archived</z-link>.+ {{#*inline "z-link"}}<a target="_blank" rel="noopener noreferrer" href="/help/archive-a-stream">{{> @partial-block}}</a>{{/inline}}+ {{/tr}}+ {{/if}}</p>{{/if}}