topic_popover: Add support to follow a topic from the topic_popover.

This commit adds support for following a topic from the topic
three-dot menu in the left sidebar.

Three options, i.e., 'Mute topic', 'Unmute topic', and 'Follow topic',
are shown at the top of the menu (in the mentioned order), regardless
of whether the stream is muted or unmuted.

We can no longer set the topic's visibility_policy to INHERIT
(the default value) from this menu.

The changes are visible in the development environment only.

Fixes #25917.

Co-authored-by: Prakhar Pratyush <prakhar841301@gmail.com>
Co-authored-by: Hardik Dharmani <Ddharmani99@gmail.com>
This commit is contained in:
Prakhar Pratyush 2023-06-14 15:11:48 +05:30 committed by Tim Abbott
parent 93a18b999a
commit 237f9f4799
8 changed files with 122 additions and 26 deletions

BIN
web/shared/icons/follow.svg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B

View File

@ -483,6 +483,18 @@ export function initialize() {
return;
}
$popper.on("click", ".tab-option", (e) => {
$(".tab-option").removeClass("selected-tab");
$(e.currentTarget).addClass("selected-tab");
const visibility_policy = $(e.currentTarget).attr("data-visibility-policy");
user_topics.set_user_topic_visibility_policy(
stream_id,
topic_name,
visibility_policy,
);
});
$popper.one("click", ".sidebar-popover-unmute-topic", () => {
user_topics.set_user_topic_visibility_policy(
stream_id,

View File

@ -130,6 +130,8 @@ export function get_topic_popover_content_context({stream_id, topic_name, url})
const has_starred_messages = starred_messages.get_count_in_topic(sub.stream_id, topic_name) > 0;
const can_move_topic = settings_data.user_can_move_messages_between_streams();
const can_rename_topic = settings_data.user_can_move_messages_to_another_topic();
const visibility_policy = user_topics.get_topic_visibility_policy(sub.stream_id, topic_name);
const all_visibility_policies = user_topics.all_visibility_policies;
return {
stream_name: sub.name,
stream_id: sub.stream_id,
@ -144,5 +146,8 @@ export function get_topic_popover_content_context({stream_id, topic_name, url})
color: sub.color,
has_starred_messages,
url,
visibility_policy,
all_visibility_policies,
development: page_params.development_environment,
};
}

View File

@ -1044,3 +1044,44 @@ div.overlay {
0 0 8px hsl(206deg 80% 62% / 60%);
}
}
/* Icon-based tab picker used for topics popover. */
.tabs-container {
display: flex;
justify-content: center;
align-items: center;
box-sizing: border-box;
width: 100%;
height: 27px;
background-color: hsl(0deg 0% 0% / 7%);
position: relative;
border-radius: 5px;
& i {
z-index: 2;
color: hsl(200deg 100% 40%);
font-size: 17px;
}
.selected-tab {
background-color: hsl(0deg 0% 100%);
border: 1px solid hsl(0deg 0% 0% / 30%);
z-index: 1;
}
.tab-option {
display: flex;
justify-content: center;
align-items: center;
box-sizing: border-box;
width: 100%;
height: 100%;
cursor: pointer;
border-radius: 5px;
&:hover:not(.selected-tab) {
background-color: hsl(0deg 0% 100%);
border: 1px solid hsl(0deg 0% 0% / 30%);
}
}
}

View File

@ -1543,6 +1543,26 @@
}
}
}
.tabs-container {
background-color: hsl(0deg 0% 0% / 30%);
& i {
color: hsl(0deg 0% 80%);
}
.selected-tab {
background-color: hsl(0deg 0% 17% / 50%);
border: 1px solid hsl(0deg 0% 100% / 12%);
}
.tab-option {
&:hover:not(.selected-tab) {
background-color: hsl(0deg 0% 17% / 50%);
border: 1px solid hsl(0deg 0% 100% / 12%);
}
}
}
}
@supports (-moz-appearance: none) {

View File

@ -8,6 +8,23 @@
<hr />
{{#if development}}
<li class="hidden-for-spectators">
<div class="tabs-container">
<div class="tab-option tippy-zulip-tooltip {{#if (eq visibility_policy all_visibility_policies.MUTED)}}selected-tab{{/if}}" data-visibility-policy="{{all_visibility_policies.MUTED}}" data-tippy-content="{{t 'Mute topic' }}" aria-label="{{t 'Mute topic' }}">
<i class="zulip-icon zulip-icon-mute-new"></i>
</div>
<div class="tab-option tippy-zulip-tooltip {{#if (eq visibility_policy all_visibility_policies.UNMUTED)}}selected-tab{{/if}}" data-visibility-policy="{{all_visibility_policies.UNMUTED}}" data-tippy-content="{{t 'Unmute topic' }}" aria-label="{{t 'Unmute topic' }}">
<i class="zulip-icon zulip-icon-unmute-new"></i>
</div>
<div class="tab-option tippy-zulip-tooltip {{#if (eq visibility_policy all_visibility_policies.FOLLOWED)}}selected-tab{{/if}}" data-visibility-policy="{{all_visibility_policies.FOLLOWED}}" data-tippy-content="{{t 'Follow topic' }}" aria-label="{{t 'Follow topic' }}">
<i class="zulip-icon zulip-icon-follow"></i>
</div>
</div>
</li>
<hr/>
{{else}}
{{#if stream_muted}}
{{#unless topic_unmuted}}
<li class="hidden-for-spectators">
@ -41,6 +58,7 @@
</li>
{{/unless}}
{{/if}}
{{/if}}
{{#if has_starred_messages}}
<li class="hidden-for-spectators">