Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
stream_data: Add can_edit_description function.
opmkumard4b1d0a68ee5
diff --git a/web/src/stream_card_popover.ts b/web/src/stream_card_popover.tsindex 9738f07847c..df5e278653f 100644--- a/web/src/stream_card_popover.ts+++ b/web/src/stream_card_popover.ts@@ -7,7 +7,6 @@ import * as browser_history from "./browser_history";import * as hash_util from "./hash_util";import * as modals from "./modals";import * as popover_menus from "./popover_menus";-import {current_user} from "./state_data";import * as stream_data from "./stream_data";import * as sub_store from "./sub_store";import * as ui_util from "./ui_util";@@ -49,7 +48,7 @@ export function initialize(): void {// modals.close_active_if_any() is mainly used to handle navigation to channel settings// using the popover that is opened when clicking on channel pills in the invite user modal.modals.close_active_if_any();- const can_change_name_description = current_user.is_admin;+ const can_change_name_description = stream_data.can_edit_description();const can_change_stream_permissions = stream_data.can_change_permissions(sub);let stream_edit_hash = hash_util.channels_settings_edit_url(sub, "general");if (!can_change_stream_permissions && !can_change_name_description) {diff --git a/web/src/stream_data.ts b/web/src/stream_data.tsindex 3e5f5ba6d5d..3361ac59fa5 100644--- a/web/src/stream_data.ts+++ b/web/src/stream_data.ts@@ -506,6 +506,10 @@ export function can_change_permissions(sub: StreamSubscription): boolean {return current_user.is_admin && (!sub.invite_only || sub.subscribed);}+export function can_edit_description(): boolean {+ return current_user.is_admin;+}+export function can_view_subscribers(sub: StreamSubscription): boolean {// Guest users can't access subscribers of any(public or private) non-subscribed streams.return current_user.is_admin || sub.subscribed || (!current_user.is_guest && !sub.invite_only);diff --git a/web/src/stream_popover.js b/web/src/stream_popover.jsindex 993357ffd8d..4b1d4957998 100644--- a/web/src/stream_popover.js+++ b/web/src/stream_popover.js@@ -21,7 +21,6 @@ import * as popover_menus from "./popover_menus";import {left_sidebar_tippy_options} from "./popover_menus";import {web_channel_default_view_values} from "./settings_config";import * as settings_data from "./settings_data";-import {current_user} from "./state_data";import * as stream_color from "./stream_color";import * as stream_data from "./stream_data";import * as stream_settings_api from "./stream_settings_api";@@ -153,7 +152,7 @@ function build_stream_popover(opts) {// Admin can change any stream's name & description either stream is public or// private, subscribed or unsubscribed.- const can_change_name_description = current_user.is_admin;+ const can_change_name_description = stream_data.can_edit_description();const can_change_stream_permissions = stream_data.can_change_permissions(sub);let stream_edit_hash = hash_util.channels_settings_edit_url(sub, "general");if (!can_change_stream_permissions && !can_change_name_description) {diff --git a/web/src/stream_settings_data.ts b/web/src/stream_settings_data.tsindex 752318ee2b7..660bf63a86a 100644--- a/web/src/stream_settings_data.ts+++ b/web/src/stream_settings_data.ts@@ -42,7 +42,7 @@ export function get_sub_for_settings(sub: StreamSubscription): SettingsSubscriptis_realm_admin: current_user.is_admin,// Admin can change any stream's name & description either stream is public or// private, subscribed or unsubscribed.- can_change_name_description: current_user.is_admin,+ can_change_name_description: stream_data.can_edit_description(),should_display_subscription_button: stream_data.can_toggle_subscription(sub),should_display_preview_button: stream_data.can_preview(sub),