diff --git a/web/src/dropdown_list_widget.js b/web/src/dropdown_list_widget.js index a01731f35f..3fe8ebf6cf 100644 --- a/web/src/dropdown_list_widget.js +++ b/web/src/dropdown_list_widget.js @@ -2,6 +2,7 @@ import $ from "jquery"; import _ from "lodash"; import tippy from "tippy.js"; +import render_inline_decorated_stream_name from "../templates/inline_decorated_stream_name.hbs"; import render_dropdown_list from "../templates/settings/dropdown_list.hbs"; import * as blueslip from "./blueslip"; @@ -63,8 +64,16 @@ export class DropdownListWidget { return; } - const text = this.render_text(item.name); - $elem.text(text); + if (item.stream !== undefined) { + const stream = item.stream; + const rendered_stream_name_with_privacy_symbol_html = + render_inline_decorated_stream_name({stream}); + $elem.html(rendered_stream_name_with_privacy_symbol_html); + } else { + const text = this.render_text(item.name); + $elem.text(text); + } + $elem.removeClass("text-warning"); $elem.closest(".input-group").find(".dropdown_list_reset_button").show(); } diff --git a/web/styles/app_components.css b/web/styles/app_components.css index 57edf17c24..4b704bf1aa 100644 --- a/web/styles/app_components.css +++ b/web/styles/app_components.css @@ -827,7 +827,7 @@ div.overlay { .stream-privacy-type-icon { position: relative; - top: 0.06em; + top: 0.06rem; padding-right: 1px; &.zulip-icon-globe, diff --git a/web/tests/settings_org.test.js b/web/tests/settings_org.test.js index a288e4eb11..44477f7dc2 100644 --- a/web/tests/settings_org.test.js +++ b/web/tests/settings_org.test.js @@ -769,7 +769,7 @@ test("test get_sorted_options_list", () => { assert.deepEqual(settings_org.get_sorted_options_list(option_values_2), expected_option_values); }); -test("misc", ({override_rewire}) => { +test("misc", ({override_rewire, mock_template}) => { page_params.is_admin = false; $("#user-avatar-upload-widget").length = 1; $("#user_details_section").length = 1; @@ -842,7 +842,7 @@ test("misc", ({override_rewire}) => { assert.ok(!$("#user-avatar-upload-widget .image_upload_button").hasClass("hide")); override_rewire(stream_settings_data, "get_streams_for_settings_page", () => [ - {name: "some_stream", stream_id: 75}, + {name: "some_stream", stream_id: 75, invite_only: true}, {name: "some_stream", stream_id: 42}, ]); @@ -873,8 +873,15 @@ test("misc", ({override_rewire}) => { let setting_name = "realm_notifications_stream_id"; let $elem = $(`#${CSS.escape(setting_name)}_widget #${CSS.escape(setting_name)}_name`); $elem.closest = () => $stub_notification_disable_parent; + let selected_stream_id = 42; + mock_template("inline_decorated_stream_name.hbs", true, (data, html) => { + assert.equal(data.stream.stream_id, selected_stream_id); + return html; + }); + settings_org.notifications_stream_widget.render(42); - assert.equal($elem.text(), "#some_stream"); + assert.ok($elem.html().indexOf("some_stream") > 0); + assert.ok($elem.html().indexOf("zulip-icon-hashtag") > 0); assert.ok(!$elem.hasClass("text-warning")); settings_org.notifications_stream_widget.render(undefined); @@ -884,8 +891,10 @@ test("misc", ({override_rewire}) => { setting_name = "realm_signup_notifications_stream_id"; $elem = $(`#${CSS.escape(setting_name)}_widget #${CSS.escape(setting_name)}_name`); $elem.closest = () => $stub_notification_disable_parent; + selected_stream_id = 75; settings_org.signup_notifications_stream_widget.render(75); - assert.equal($elem.text(), "#some_stream"); + assert.ok($elem.html().indexOf("some_stream") > 0); + assert.ok($elem.html().indexOf("zulip-icon-lock") > 0); assert.ok(!$elem.hasClass("text-warning")); settings_org.signup_notifications_stream_widget.render(undefined);