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.
This commit is contained in:
Sahil Batra
2024-10-01 16:00:37 +05:30
committed by Tim Abbott
parent 58ab97a0b4
commit f97da983cf
2 changed files with 15 additions and 2 deletions

View File

@@ -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;
}

View File

@@ -2,7 +2,11 @@
{{t "This group cannot be deactivated because it is used in following places:"}}
<ul>
{{#each streams_using_group_for_setting}}
{{#if this.setting_url}}
<li><a href="{{this.setting_url}}">#{{this.stream_name}}</a></li>
{{else}}
<li>{{this.stream_name}}</li>
{{/if}}
{{/each}}
{{#each groups_using_group_for_setting}}
<li><a href="{{this.setting_url}}">@{{this.group_name}}</a></li>