From f97da983cf5f035a2e264b971c6fd9ddd30962ab Mon Sep 17 00:00:00 2001 From: Sahil Batra Date: Tue, 1 Oct 2024 16:00:37 +0530 Subject: [PATCH] user_groups: Handle inaccessible streams in group deactivation error. If the user group being deactivated is used as a setting for a stream which cannot be accessed by the user trying to deactivate the group, we show "Unknown stream" in the banner mentioning where the group is used. --- web/src/user_group_edit.js | 13 +++++++++++-- .../cannot_deactivate_group_banner.hbs | 4 ++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/web/src/user_group_edit.js b/web/src/user_group_edit.js index 7a0bc6ff8b..60df835350 100644 --- a/web/src/user_group_edit.js +++ b/web/src/user_group_edit.js @@ -886,8 +886,17 @@ function parse_args_for_deactivation_banner(objections) { if (objection.type === "channel") { const stream_id = objection.channel_id; const sub = stream_data.get_sub_by_id(stream_id); - const setting_url = hash_util.channels_settings_edit_url(sub, "general"); - args.streams_using_group_for_setting.push({stream_name: sub.name, setting_url}); + if (sub !== undefined) { + args.streams_using_group_for_setting.push({ + stream_name: sub.name, + setting_url: hash_util.channels_settings_edit_url(sub, "general"), + }); + } else { + args.streams_using_group_for_setting.push({ + stream_name: $t({defaultMessage: "Unknown stream"}), + setting_url: undefined, + }); + } continue; } diff --git a/web/templates/user_group_settings/cannot_deactivate_group_banner.hbs b/web/templates/user_group_settings/cannot_deactivate_group_banner.hbs index 0a405cd210..0735c42f10 100644 --- a/web/templates/user_group_settings/cannot_deactivate_group_banner.hbs +++ b/web/templates/user_group_settings/cannot_deactivate_group_banner.hbs @@ -2,7 +2,11 @@ {{t "This group cannot be deactivated because it is used in following places:"}}