narrow_banner: Add special notice for spectators.

On non web public stream narrows, tell user that stream is not
web public or does not exist.
This commit is contained in:
Aman Agrawal 2022-02-15 11:25:11 +00:00 committed by Tim Abbott
parent fd0f26dc1b
commit 3736c943b3
2 changed files with 49 additions and 0 deletions

View File

@ -228,6 +228,34 @@ run_test("show_empty_narrow_message", ({mock_template}) => {
), ),
); );
// for non web public stream for spectator
page_params.is_spectator = true;
set_filter([["stream", "Rome"]]);
hide_all_empty_narrow_messages();
narrow_banner.show_empty_narrow_message();
assert.equal(
$(".empty_feed_notice_main").html(),
empty_narrow_html(
"",
'translated HTML: This stream does not exist or is not <a href="https://zulip.com/help/web-public-streams">web-public</a>.',
),
);
set_filter([
["stream", "Rome"],
["topic", "foo"],
]);
hide_all_empty_narrow_messages();
narrow_banner.show_empty_narrow_message();
assert.equal(
$(".empty_feed_notice_main").html(),
empty_narrow_html(
"",
'translated HTML: This stream does not exist or is not <a href="https://zulip.com/help/web-public-streams">web-public</a>.',
),
);
page_params.is_spectator = false;
set_filter([["is", "starred"]]); set_filter([["is", "starred"]]);
hide_all_empty_narrow_messages(); hide_all_empty_narrow_messages();
narrow_banner.show_empty_narrow_message(); narrow_banner.show_empty_narrow_message();

View File

@ -7,6 +7,19 @@ import {page_params} from "./page_params";
import * as people from "./people"; import * as people from "./people";
import * as stream_data from "./stream_data"; import * as stream_data from "./stream_data";
const SPECTATOR_STREAM_NARROW_BANNER = {
title: "",
html: $t_html(
{
defaultMessage: "This stream does not exist or is not <z-link>web-public</z-link>.",
},
{
"z-link": (content_html) =>
`<a href="https://zulip.com/help/web-public-streams">${content_html}</a>`,
},
),
};
function retrieve_search_query_data() { function retrieve_search_query_data() {
// when search bar contains multiple filters, only retrieve search queries // when search bar contains multiple filters, only retrieve search queries
const current_filter = narrow_state.filter(); const current_filter = narrow_state.filter();
@ -118,6 +131,10 @@ function pick_empty_narrow_banner() {
}; };
} }
if (page_params.is_spectator) {
return SPECTATOR_STREAM_NARROW_BANNER;
}
// For other multi-operator narrows, we just use the default banner // For other multi-operator narrows, we just use the default banner
return default_banner; return default_banner;
} }
@ -186,6 +203,10 @@ function pick_empty_narrow_banner() {
// You are narrowed to a stream which does not exist or is a private stream // You are narrowed to a stream which does not exist or is a private stream
// in which you were never subscribed. // in which you were never subscribed.
if (page_params.is_spectator) {
return SPECTATOR_STREAM_NARROW_BANNER;
}
function can_toggle_narrowed_stream() { function can_toggle_narrowed_stream() {
const stream_name = narrow_state.stream(); const stream_name = narrow_state.stream();