diff --git a/web/src/stream_data.js b/web/src/stream_data.js index e9ceaf83f2..9e61b71a9f 100644 --- a/web/src/stream_data.js +++ b/web/src/stream_data.js @@ -6,6 +6,7 @@ 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"; import * as sub_store from "./sub_store"; import * as user_groups from "./user_groups"; import {user_settings} from "./user_settings"; @@ -516,8 +517,13 @@ export function can_view_subscribers(sub) { } export function can_subscribe_others(sub) { - // User can add other users to stream if stream is public or user is subscribed to stream. - return !page_params.is_guest && (!sub.invite_only || sub.subscribed); + // User can add other users to stream if stream is public or user is subscribed to stream + // and realm level setting allows user to add subscribers. + return ( + !page_params.is_guest && + (!sub.invite_only || sub.subscribed) && + settings_data.user_can_subscribe_other_users() + ); } export function can_unsubscribe_others(sub) { diff --git a/web/src/stream_ui_updates.js b/web/src/stream_ui_updates.js index 390e908e0f..c9be1a177f 100644 --- a/web/src/stream_ui_updates.js +++ b/web/src/stream_ui_updates.js @@ -7,6 +7,7 @@ import render_stream_settings_tip from "../templates/stream_settings/stream_sett import * as hash_util from "./hash_util"; import {$t} from "./i18n"; import {page_params} from "./page_params"; +import * as settings_data from "./settings_data"; import * as settings_org from "./settings_org"; import * as stream_data from "./stream_data"; import * as stream_edit from "./stream_edit"; @@ -252,11 +253,22 @@ export function update_add_subscriptions_elements(sub) { enable_or_disable_add_subscribers_elements($add_subscribers_container, allow_user_to_add_subs); if (!allow_user_to_add_subs) { + let tooltip_message; + if (!settings_data.user_can_subscribe_other_users()) { + tooltip_message = $t({ + defaultMessage: + "You do not have permission to add other users to streams in this organization.", + }); + } else { + tooltip_message = $t({ + defaultMessage: "Only stream members can add users to a private stream.", + }); + } initialize_disable_btn_hint_popover( $add_subscribers_container, $input_element, $button_element, - $t({defaultMessage: "Only stream members can add users to a private stream"}), + tooltip_message, ); } }