Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

streams: Fix warning shown when unsubscribing from private stream.

Sahil Batrad3c06234e276
diff --git a/web/src/stream_edit_subscribers.ts b/web/src/stream_edit_subscribers.ts
index dd81b84cfba..5fe8e0b20ae 100644
--- a/web/src/stream_edit_subscribers.ts
+++ b/web/src/stream_edit_subscribers.ts
@@ -352,7 +352,10 @@ function remove_subscriber({
const html_body = render_unsubscribe_private_stream_modal({
unsubscribing_other_user,
- display_stream_archive_warning: sub_count === 1,
+ organization_will_lose_content_access:
+ sub_count === 1 &&
+ user_groups.is_setting_group_set_to_nobody_group(sub.can_subscribe_group) &&
+ user_groups.is_setting_group_set_to_nobody_group(sub.can_add_subscribers_group),
});
let html_heading;
diff --git a/web/src/stream_settings_components.ts b/web/src/stream_settings_components.ts
index 88691a1ecd3..78c96a46d1f 100644
--- a/web/src/stream_settings_components.ts
+++ b/web/src/stream_settings_components.ts
@@ -19,6 +19,7 @@ import * as stream_data from "./stream_data.ts";
import * as stream_settings_data from "./stream_settings_data.ts";
import type {StreamSubscription} from "./sub_store.ts";
import * as ui_report from "./ui_report.ts";
+import * as user_groups from "./user_groups.ts";
export let filter_dropdown_widget: DropdownWidget;
@@ -228,7 +229,11 @@ export function unsubscribe_from_private_stream(sub: StreamSubscription): void {
const html_body = render_unsubscribe_private_stream_modal({
unsubscribing_other_user: false,
- display_stream_archive_warning: sub_count === 1 && invite_only,
+ organization_will_lose_content_access:
+ sub_count === 1 &&
+ invite_only &&
+ user_groups.is_setting_group_set_to_nobody_group(sub.can_subscribe_group) &&
+ user_groups.is_setting_group_set_to_nobody_group(sub.can_add_subscribers_group),
});
function unsubscribe_from_stream(): void {
diff --git a/web/src/user_groups.ts b/web/src/user_groups.ts
index d67a88377ac..011327c4156 100644
--- a/web/src/user_groups.ts
+++ b/web/src/user_groups.ts
@@ -305,6 +305,19 @@ export function is_setting_group_empty(setting_group: GroupSettingValue): boolea
return true;
}
+export function is_setting_group_set_to_nobody_group(setting_group: GroupSettingValue): boolean {
+ if (typeof setting_group === "number") {
+ const user_group = get_user_group_from_id(setting_group);
+ if (user_group.name === "role:nobody") {
+ return true;
+ }
+
+ return false;
+ }
+
+ return setting_group.direct_subgroups.length === 0 && setting_group.direct_members.length === 0;
+}
+
export function get_user_groups_of_user(
user_id: number,
include_deactivated_groups = false,
diff --git a/web/templates/confirm_dialog/confirm_unsubscribe_private_stream.hbs b/web/templates/confirm_dialog/confirm_unsubscribe_private_stream.hbs
index e480c9c584e..8d2d42ddfa1 100644
--- a/web/templates/confirm_dialog/confirm_unsubscribe_private_stream.hbs
+++ b/web/templates/confirm_dialog/confirm_unsubscribe_private_stream.hbs
@@ -1,18 +1,8 @@
{{#unless unsubscribing_other_user}}
<p>{{t "Once you leave this channel, you will not be able to rejoin."}}</p>
{{/unless}}
-{{#if display_stream_archive_warning}}
+{{#if organization_will_lose_content_access}}
<p>
- {{#if unsubscribing_other_user}}
- {{#tr}}
- Because you are removing the last subscriber from a private channel, it will be automatically <z-link>archived</z-link>.
- {{#*inline "z-link"}}<a target="_blank" rel="noopener noreferrer" href="/help/archive-a-channel">{{> @partial-block}}</a>{{/inline}}
- {{/tr}}
- {{else}}
- {{#tr}}
- Because you are the only subscriber, this channel will be automatically <z-link>archived</z-link>.
- {{#*inline "z-link"}}<a target="_blank" rel="noopener noreferrer" href="/help/archive-a-channel">{{> @partial-block}}</a>{{/inline}}
- {{/tr}}
- {{/if}}
+ {{t "Your organization will lose access content in this channel, and nobody will be able to subscribe to it in the future."}}
</p>
{{/if}}