Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
rendered_markdown: Render stream privacy icons in message links.
Aadyot16f9407d96fcf
diff --git a/web/src/rendered_markdown.ts b/web/src/rendered_markdown.tsindex b8500ff1bce..7944f09acf2 100644--- a/web/src/rendered_markdown.ts+++ b/web/src/rendered_markdown.ts@@ -257,7 +257,7 @@ export const update_elements = ($content: JQuery): void => {});$(this).replaceWith($(topic_link_html));} else {- const message_link_html = render_channel_message_link(context);+ const message_link_html = render_channel_message_link({stream: sub, ...context});$(this).replaceWith($(message_link_html));}}diff --git a/web/templates/channel_message_link.hbs b/web/templates/channel_message_link.hbsindex d7ea2162eed..f4f4b27afe9 100644--- a/web/templates/channel_message_link.hbs+++ b/web/templates/channel_message_link.hbs@@ -1,13 +1,21 @@{{#if is_empty_string_topic}}<a class="message-link" href="{{href}}">{{~!-- squash whitespace --~}}- #{{channel_name}} > <span class="empty-topic-display">{{topic_display_name}}</span> @ 💬+ {{#if stream~}}+ {{~> decorated_channel_name stream=stream inline_with_text=true show_colored_icon=false}}+ {{~else~}}+ #{{channel_name}}+ {{~/if}} > <span class="empty-topic-display">{{topic_display_name}}</span> @ 💬{{~!-- squash whitespace --~}}</a>{{~else}}<a class="message-link" href="{{href}}">{{~!-- squash whitespace --~}}- #{{channel_name}} > {{topic_display_name}} @ 💬+ {{#if stream~}}+ {{~> decorated_channel_name stream=stream inline_with_text=true show_colored_icon=false}}+ {{~else~}}+ #{{channel_name}}+ {{~/if}} > {{topic_display_name}} @ 💬{{~!-- squash whitespace --~}}</a>{{~/if}}diff --git a/web/tests/rendered_markdown.test.cjs b/web/tests/rendered_markdown.test.cjsindex c1551c412af..0fca13d4b3b 100644--- a/web/tests/rendered_markdown.test.cjs+++ b/web/tests/rendered_markdown.test.cjs@@ -527,6 +527,7 @@ run_test("message-links", ({mock_template}) => {topic_display_name: `translated: ${REALM_EMPTY_TOPIC_DISPLAY_NAME}`,is_empty_string_topic: true,href: `/#narrow/channel/${stream.stream_id}-test/topic//near/123`,+ stream,});assert.ok(channel_message_link_rendered_html.includes("empty-topic-display"));});@@ -844,8 +845,16 @@ run_test("stream-private", ({mock_template}) => {$topic.addClass("stream-topic");$topic[0].replaceWith = noop;+ const $message_link = $.create("a.message-link");+ $message_link.attr(+ "href",+ `/#narrow/channel/${private_stream.stream_id}-secret-stream/topic/test/near/123`,+ );+ $message_link.set_find_results(".highlight", []);+ $message_link[0].replaceWith = noop;+$content.set_find_results("a.stream", $stream);- $content.set_find_results("a.stream-topic, a.message-link", $topic);+ $content.set_find_results("a.stream-topic, a.message-link", [...$topic, ...$message_link]);let stream_name_context;mock_template("decorated_channel_name.hbs", true, (data, html) => {@@ -859,6 +868,12 @@ run_test("stream-private", ({mock_template}) => {return html;});+ let message_link_context;+ mock_template("channel_message_link.hbs", true, (data, html) => {+ message_link_context = data;+ return html;+ });+rm.update_elements($content);// Verify decorated_channel_name was called with the private stream.@@ -868,6 +883,10 @@ run_test("stream-private", ({mock_template}) => {// Verify topic_link was called with the private stream.assert.ok(topic_link_context, "topic_link should be called");assert.ok(topic_link_context.stream.invite_only, "Topic stream should be private");++ // Verify channel_message_link was called with the private stream.+ assert.ok(message_link_context, "channel_message_link should be called");+ assert.ok(message_link_context.stream.invite_only, "Message link stream should be private");});run_test("stream-web-public", ({mock_template}) => {@@ -895,8 +914,16 @@ run_test("stream-web-public", ({mock_template}) => {$topic.addClass("stream-topic");$topic[0].replaceWith = noop;+ const $message_link = $.create("a.message-link");+ $message_link.attr(+ "href",+ `/#narrow/channel/${web_public_stream.stream_id}-web-public-stream/topic/test/near/123`,+ );+ $message_link.set_find_results(".highlight", []);+ $message_link[0].replaceWith = noop;+$content.set_find_results("a.stream", $stream);- $content.set_find_results("a.stream-topic, a.message-link", $topic);+ $content.set_find_results("a.stream-topic, a.message-link", [...$topic, ...$message_link]);let stream_name_context;mock_template("decorated_channel_name.hbs", true, (data, html) => {@@ -910,6 +937,12 @@ run_test("stream-web-public", ({mock_template}) => {return html;});+ let message_link_context;+ mock_template("channel_message_link.hbs", true, (data, html) => {+ message_link_context = data;+ return html;+ });+rm.update_elements($content);// Verify decorated_channel_name was called with the web-public stream.@@ -919,6 +952,13 @@ run_test("stream-web-public", ({mock_template}) => {// Verify topic_link was called with the web-public stream.assert.ok(topic_link_context, "topic_link should be called");assert.ok(topic_link_context.stream.is_web_public, "Topic stream should be web-public");++ // Verify channel_message_link was called with the web-public stream.+ assert.ok(message_link_context, "channel_message_link should be called");+ assert.ok(+ message_link_context.stream.is_web_public,+ "Message link stream should be web-public",+ );});run_test("stream-archived", ({mock_template}) => {@@ -943,8 +983,16 @@ run_test("stream-archived", ({mock_template}) => {$topic.addClass("stream-topic");$topic[0].replaceWith = noop;+ const $message_link = $.create("a.message-link");+ $message_link.attr(+ "href",+ `/#narrow/channel/${archived_stream.stream_id}-old-stream/topic/test/near/123`,+ );+ $message_link.set_find_results(".highlight", []);+ $message_link[0].replaceWith = noop;+$content.set_find_results("a.stream", $stream);- $content.set_find_results("a.stream-topic, a.message-link", $topic);+ $content.set_find_results("a.stream-topic, a.message-link", [...$topic, ...$message_link]);let stream_name_context;mock_template("decorated_channel_name.hbs", true, (data, html) => {@@ -958,6 +1006,12 @@ run_test("stream-archived", ({mock_template}) => {return html;});+ let message_link_context;+ mock_template("channel_message_link.hbs", true, (data, html) => {+ message_link_context = data;+ return html;+ });+rm.update_elements($content);// Verify decorated_channel_name was called with the archived stream.@@ -967,6 +1021,10 @@ run_test("stream-archived", ({mock_template}) => {// Verify topic_link was called with the archived stream.assert.ok(topic_link_context, "topic_link should be called");assert.ok(topic_link_context.stream.is_archived, "Topic stream should be archived");++ // Verify channel_message_link was called with the archived stream.+ assert.ok(message_link_context, "channel_message_link should be called");+ assert.ok(message_link_context.stream.is_archived, "Message link stream should be archived");});run_test("rtl", () => {