Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
narrow_banner: Add special notice for spectators.
Aman Agrawal3736c943b325
diff --git a/frontend_tests/node_tests/narrow.js b/frontend_tests/node_tests/narrow.jsindex 0d5b4cd63f5..ea91d2d658a 100644--- a/frontend_tests/node_tests/narrow.js+++ b/frontend_tests/node_tests/narrow.js@@ -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"]]);hide_all_empty_narrow_messages();narrow_banner.show_empty_narrow_message();diff --git a/static/js/narrow_banner.js b/static/js/narrow_banner.jsindex 5742506a334..7b73891ff6e 100644--- a/static/js/narrow_banner.js+++ b/static/js/narrow_banner.js@@ -7,6 +7,19 @@ import {page_params} from "./page_params";import * as people from "./people";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() {// when search bar contains multiple filters, only retrieve search queriesconst 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 bannerreturn 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// in which you were never subscribed.+ if (page_params.is_spectator) {+ return SPECTATOR_STREAM_NARROW_BANNER;+ }+function can_toggle_narrowed_stream() {const stream_name = narrow_state.stream();