stream settings: Warn users before locking them out of a stream.

Organization owners can make streams private even if they're not
subscribed to them, but cannot access private streams they're not
subscribed to. This means they're able to lock themself out of streams.

This change warns users of this and give them a chance to subscribe.

Fixes #26437.
This commit is contained in:
evykassirer
2023-08-09 13:30:51 -07:00
committed by Tim Abbott
parent e8b7aad462
commit 4c2995c613
3 changed files with 80 additions and 0 deletions

View File

@@ -466,6 +466,36 @@ export function initialize() {
return true;
});
$("#streams_overlay_container").on(
"click",
".stream-permissions-warning-banner .main-view-banner-close-button",
(event) => {
event.preventDefault();
$("#stream_permission_settings .stream-permissions-warning-banner").empty();
},
);
$("#streams_overlay_container").on(
"click",
".stream-permissions-warning-banner .main-view-banner-action-button",
(event) => {
event.preventDefault();
event.stopPropagation();
const $target = $(event.target).parents(".main-view-banner");
const stream_id = Number.parseInt($target.attr("data-stream-id"), 10);
// Makes sure we take the correct stream_row.
const $stream_row = $(
`#streams_overlay_container div.stream-row[data-stream-id='${CSS.escape(
stream_id,
)}']`,
);
const sub = sub_store.get(stream_id);
stream_settings_ui.sub_or_unsub(sub, $stream_row);
$("#stream_permission_settings .stream-permissions-warning-banner").empty();
},
);
function save_stream_info(e) {
const sub = get_sub_for_target(e.currentTarget);