Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
message_header: Add support to follow topic from the message header bar.
Prakhar Pratyush41697f266384
diff --git a/web/src/message_list_tooltips.js b/web/src/message_list_tooltips.jsindex 9973cbeec51..bb05b427881 100644--- a/web/src/message_list_tooltips.js+++ b/web/src/message_list_tooltips.js@@ -1,6 +1,7 @@import $ from "jquery";import {delegate} from "tippy.js";+import render_change_visibility_policy_button_tooltip from "../templates/change_visibility_policy_button_tooltip.hbs";import render_message_edit_notice_tooltip from "../templates/message_edit_notice_tooltip.hbs";import render_message_inline_image_tooltip from "../templates/message_inline_image_tooltip.hbs";import render_narrow_tooltip from "../templates/narrow_tooltip.hbs";@@ -199,6 +200,22 @@ export function initialize() {message_list_tooltip(".code_external_link");+ message_list_tooltip(".change_visibility_policy > i", {+ delay: LONG_HOVER_DELAY,+ onShow(instance) {+ const $elem = $(instance.reference);+ const current_visibility_policy_str = $elem.attr("data-tippy-content");+ instance.setContent(+ parse_html(+ render_change_visibility_policy_button_tooltip({current_visibility_policy_str}),+ ),+ );+ },+ onHidden(instance) {+ instance.destroy();+ },+ });+message_list_tooltip([".recipient_bar_icon"], {delay: LONG_HOVER_DELAY,onHidden(instance) {diff --git a/web/src/message_list_view.js b/web/src/message_list_view.jsindex 17bb6532c11..8bb514bba72 100644--- a/web/src/message_list_view.js+++ b/web/src/message_list_view.js@@ -210,6 +210,15 @@ function populate_group_from_message_container(group, message_container) {group.topic_is_resolved = resolved_topic.is_resolved(group.topic);group.topic_muted = user_topics.is_topic_muted(group.stream_id, group.topic);group.topic_unmuted = user_topics.is_topic_unmuted(group.stream_id, group.topic);+ group.visibility_policy = user_topics.get_topic_visibility_policy(+ group.stream_id,+ group.topic,+ );++ // The following two fields are not specific to this group, but this is the+ // easiest way we've figured out for passing the data to the template rendering.+ group.development = page_params.development_environment;+ group.all_visibility_policies = user_topics.all_visibility_policies;} else if (group.is_private) {group.pm_with_url = message_container.pm_with_url;group.display_reply_to = message_store.get_pm_full_names(message_container.msg);diff --git a/web/src/popover_menus.js b/web/src/popover_menus.jsindex fa897b00e30..19970661fb2 100644--- a/web/src/popover_menus.js+++ b/web/src/popover_menus.js@@ -8,6 +8,7 @@ import tippy, {delegate} from "tippy.js";import render_actions_popover_content from "../templates/actions_popover_content.hbs";import render_all_messages_sidebar_actions from "../templates/all_messages_sidebar_actions.hbs";+import render_change_visibility_policy_popover from "../templates/change_visibility_policy_popover.hbs";import render_compose_control_buttons_popover from "../templates/compose_control_buttons_popover.hbs";import render_compose_select_enter_behaviour_popover from "../templates/compose_select_enter_behaviour_popover.hbs";import render_delete_topic_modal from "../templates/confirm_dialog/confirm_delete_topic.hbs";@@ -68,6 +69,7 @@ const popover_instances = {compose_enter_sends: null,topics_menu: null,send_later: null,+ change_visibility_policy: null,};export function sidebar_menu_instance_handle_keyboard(instance, key) {@@ -634,6 +636,65 @@ export function initialize() {},});+ register_popover_menu(".change_visibility_policy", {+ placement: "bottom",+ popperOptions: {+ modifiers: [+ {+ // The placement is set to bottom, but if that placement does not fit,+ // the opposite top placement will be used.+ name: "flip",+ options: {+ fallbackPlacements: ["top", "left"],+ },+ },+ ],+ },+ onShow(instance) {+ popover_instances.change_visibility_policy = instance;+ on_show_prep(instance);+ const elt = $(instance.reference).closest(".change_visibility_policy").expectOne()[0];+ const stream_id = $(elt).attr("data-stream-id");+ const topic_name = $(elt).attr("data-topic-name");++ instance.context =+ popover_menus_data.get_change_visibility_policy_popover_content_context(+ Number.parseInt(stream_id, 10),+ topic_name,+ );+ instance.setContent(+ parse_html(render_change_visibility_policy_popover(instance.context)),+ );+ },+ onMount(instance) {+ const $popper = $(instance.popper);+ const {stream_id, topic_name} = instance.context;++ if (!stream_id) {+ instance.hide();+ return;+ }++ // TODO: Figure out a good way to offer feedback if this request fails.+ $popper.on("click", ".visibility_policy_option", (e) => {+ $(".visibility_policy_option").removeClass("selected_visibility_policy");+ $(e.currentTarget).addClass("selected_visibility_policy");++ const visibility_policy = $(e.currentTarget).attr("data-visibility-policy");+ user_topics.set_user_topic_visibility_policy(+ stream_id,+ topic_name,+ visibility_policy,+ );+ instance.hide();+ });+ },+ onHidden(instance) {+ instance.destroy();+ popover_instances.change_visibility_policy = undefined;+ },+ });+register_popover_menu(".actions_hover .zulip-icon-ellipsis-v-solid", {// 320px is our minimum supported width for mobile. We will allow the value to flex// to a max of 350px but we shouldn't make the popover wider than this.diff --git a/web/src/popover_menus_data.js b/web/src/popover_menus_data.jsindex 04c644f3966..f271a3d3687 100644--- a/web/src/popover_menus_data.js+++ b/web/src/popover_menus_data.js@@ -151,3 +151,18 @@ export function get_topic_popover_content_context({stream_id, topic_name, url})development: page_params.development_environment,};}++export function get_change_visibility_policy_popover_content_context(stream_id, topic_name) {+ const visibility_policy = user_topics.get_topic_visibility_policy(stream_id, topic_name);+ const sub = sub_store.get(stream_id);+ const all_visibility_policies = user_topics.all_visibility_policies;+ const topic_unmuted = visibility_policy === all_visibility_policies.UNMUTED;+ return {+ stream_id,+ topic_name,+ visibility_policy,+ stream_muted: sub.is_muted,+ topic_unmuted,+ all_visibility_policies,+ };+}diff --git a/web/styles/dark_theme.css b/web/styles/dark_theme.cssindex 9675d5df918..148746c3ffe 100644--- a/web/styles/dark_theme.css+++ b/web/styles/dark_theme.css@@ -1552,6 +1552,20 @@}}}++ .visibility_policy_popover {+ .visibility_policy_option {+ &:hover:not(.selected_visibility_policy) {+ background-color: hsl(0deg 0% 17% / 50%);+ border: 1px solid hsl(0deg 0% 100% / 12%);+ }+ }++ .selected_visibility_policy {+ background-color: hsl(0deg 0% 17% / 50%);+ border: 1px solid hsl(0deg 0% 100% / 12%);+ }+ }}@media screen {diff --git a/web/styles/popovers.css b/web/styles/popovers.cssindex bd8d37f66b2..b7f5852b823 100644--- a/web/styles/popovers.css+++ b/web/styles/popovers.css@@ -945,3 +945,40 @@ ul {padding-bottom: 16px;}}++.visibility_policy_popover {+ padding-left: 4px;+ padding-right: 4px;++ .visibility_policy_option {+ padding: 2px 13px;+ background-color: hsl(0deg 0% 0% / 7%);+ border-radius: 2px;+ border: 1px solid transparent;++ &:hover:not(.selected_visibility_policy) {+ background-color: hsl(0deg 0% 100%);+ border: 1px solid hsl(0deg 0% 0% / 30%);+ }++ .icon_and_text {+ display: flex;+ align-items: center;+ text-decoration: none;++ &:hover {+ background-color: transparent;+ }+ }++ .icon_and_text i {+ font-size: 17px;+ margin-right: 10px;+ }+ }++ .selected_visibility_policy {+ background-color: hsl(0deg 0% 100%);+ border: 1px solid hsl(0deg 0% 0% / 20%);+ }+}diff --git a/web/styles/zulip.css b/web/styles/zulip.cssindex d4918fd166a..a42ee180318 100644--- a/web/styles/zulip.css+++ b/web/styles/zulip.css@@ -961,6 +961,10 @@ strong {}}+#change_visibility_policy_button_tooltip {+ text-align: center;+}+.narrow-filter {display: block;position: relative;@@ -1449,6 +1453,15 @@ td.pointer {display: flex;flex-grow: 1;align-items: center;++ .change_visibility_policy {+ display: flex;+ cursor: pointer;++ i {+ font-size: 17px;+ }+ }}.recipient_row_date {diff --git a/web/templates/change_visibility_policy_button_tooltip.hbs b/web/templates/change_visibility_policy_button_tooltip.hbsnew file mode 100644index 00000000000..58cb4c02b53--- /dev/null+++ b/web/templates/change_visibility_policy_button_tooltip.hbs@@ -0,0 +1,5 @@+<div id="change_visibility_policy_button_tooltip">+ <strong>{{current_visibility_policy_str}}</strong>+ <br/>+ <span class="tooltip-inner-content italic">{{t 'Click to change notifications for this topic.' }}</span>+</div>diff --git a/web/templates/change_visibility_policy_popover.hbs b/web/templates/change_visibility_policy_popover.hbsnew file mode 100644index 00000000000..6a4bb8566bf--- /dev/null+++ b/web/templates/change_visibility_policy_popover.hbs@@ -0,0 +1,32 @@+<ul class="nav nav-list visibility_policy_popover hidden-for-spectators">+ <li class="visibility_policy_option {{#if (eq visibility_policy all_visibility_policies.MUTED)}}selected_visibility_policy{{/if}}"+ data-visibility-policy="{{ all_visibility_policies.MUTED }}">+ <a tabindex="0" class="icon_and_text">+ <i class="zulip-icon zulip-icon-mute-new" aria-hidden="true"></i>+ {{t "Mute"}}+ </a>+ </li>+ <li class="visibility_policy_option {{#if (eq visibility_policy all_visibility_policies.INHERIT)}}selected_visibility_policy{{/if}}"+ data-visibility-policy="{{ all_visibility_policies.INHERIT }}">+ <a tabindex="0" class="icon_and_text">+ <i class="zulip-icon zulip-icon-inherit" aria-hidden="true"></i>+ {{t "Default"}}+ </a>+ </li>+ {{#if (or stream_muted topic_unmuted)}}+ <li class="visibility_policy_option {{#if (eq visibility_policy all_visibility_policies.UNMUTED)}}selected_visibility_policy{{/if}}"+ data-visibility-policy="{{ all_visibility_policies.UNMUTED }}">+ <a tabindex="0" class="icon_and_text">+ <i class="zulip-icon zulip-icon-unmute-new" aria-hidden="true"></i>+ {{t "Unmute"}}+ </a>+ </li>+ {{/if}}+ <li class="visibility_policy_option {{#if (eq visibility_policy all_visibility_policies.FOLLOWED)}}selected_visibility_policy{{/if}}"+ data-visibility-policy="{{ all_visibility_policies.FOLLOWED }}">+ <a tabindex="0" class="icon_and_text">+ <i class="zulip-icon zulip-icon-follow" aria-hidden="true"></i>+ {{t "Follow"}}+ </a>+ </li>+</ul>diff --git a/web/templates/recipient_row.hbs b/web/templates/recipient_row.hbsindex 26263a6bd37..1b4b49ec695 100644--- a/web/templates/recipient_row.hbs+++ b/web/templates/recipient_row.hbs@@ -57,12 +57,30 @@{{/if}}{{/if}}- {{#if stream_muted}}- <i class="zulip-icon zulip-icon-unmute stream_muted {{#if topic_unmuted}} on_hover_topic_mute {{else}} on_hover_topic_unmute {{/if}} recipient_bar_icon hidden-for-spectators" data-stream-id="{{stream_id}}" data-topic-name="{{topic}}" role="button" tabindex="0"- {{#if topic_unmuted}} data-tooltip-template-id="topic-mute-tooltip-template" aria-label="{{t 'Mute topic' }}" {{else}} data-tooltip-template-id="topic-unmute-tooltip-template" aria-label="{{t 'Unmute topic' }}" {{/if}}></i>+ {{#if development}}+ <span class="change_visibility_policy hidden-for-spectators" data-stream-id="{{stream_id}}" data-topic-name="{{topic}}">+ {{#if (eq visibility_policy all_visibility_policies.FOLLOWED)}}+ <i class="zulip-icon zulip-icon-follow recipient_bar_icon" data-tippy-content="{{t 'You follow this topic'}}"+ role="button" tabindex="0" aria-haspopup="true" aria-label="{{t 'You follow this topic' }}"></i>+ {{else if (eq visibility_policy all_visibility_policies.UNMUTED)}}+ <i class="zulip-icon zulip-icon-unmute-new recipient_bar_icon" data-tippy-content="{{t 'You have unmuted this topic'}}"+ role="button" tabindex="0" aria-haspopup="true" aria-label="{{t 'You have unmuted this topic' }}"></i>+ {{else if (eq visibility_policy all_visibility_policies.MUTED)}}+ <i class="zulip-icon zulip-icon-mute-new recipient_bar_icon" data-tippy-content="{{t 'You have muted this topic'}}"+ role="button" tabindex="0" aria-haspopup="true" aria-label="{{t 'You have muted this topic' }}"></i>+ {{else}}+ <i class="zulip-icon zulip-icon-inherit recipient_bar_icon" data-tippy-content="{{t 'You will get default notifications for this topic'}}"+ role="button" tabindex="0" aria-haspopup="true" aria-label="{{t 'You will get default notifications for this topic' }}"></i>+ {{/if}}+ </span>{{else}}- <i class="zulip-icon zulip-icon-mute stream_unmuted{{#if topic_muted}} on_hover_topic_unmute {{else}} on_hover_topic_mute {{/if}} recipient_bar_icon hidden-for-spectators" data-stream-id="{{stream_id}}" data-topic-name="{{topic}}" role="button" tabindex="0"- {{#if topic_muted}} data-tooltip-template-id="topic-unmute-tooltip-template" aria-label="{{t 'Unmute topic' }}" {{else}} data-tooltip-template-id="topic-mute-tooltip-template" aria-label="{{t 'Mute topic' }}" {{/if}}></i>+ {{#if stream_muted}}+ <i class="zulip-icon zulip-icon-unmute stream_muted {{#if topic_unmuted}} on_hover_topic_mute {{else}} on_hover_topic_unmute {{/if}} recipient_bar_icon hidden-for-spectators" data-stream-id="{{stream_id}}" data-topic-name="{{topic}}" role="button" tabindex="0"+ {{#if topic_unmuted}} data-tooltip-template-id="topic-mute-tooltip-template" aria-label="{{t 'Mute topic' }}" {{else}} data-tooltip-template-id="topic-unmute-tooltip-template" aria-label="{{t 'Unmute topic' }}" {{/if}}></i>+ {{else}}+ <i class="zulip-icon zulip-icon-mute stream_unmuted{{#if topic_muted}} on_hover_topic_unmute {{else}} on_hover_topic_mute {{/if}} recipient_bar_icon hidden-for-spectators" data-stream-id="{{stream_id}}" data-topic-name="{{topic}}" role="button" tabindex="0"+ {{#if topic_muted}} data-tooltip-template-id="topic-unmute-tooltip-template" aria-label="{{t 'Unmute topic' }}" {{else}} data-tooltip-template-id="topic-mute-tooltip-template" aria-label="{{t 'Mute topic' }}" {{/if}}></i>+ {{/if}}{{/if}}</span>