Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

inbox: Add topic visibility indicator.

Aman Agrawale9c86dc5246b
diff --git a/web/src/inbox_ui.js b/web/src/inbox_ui.js
index 0f99aa573bc..210a1e6a4e8 100644
--- a/web/src/inbox_ui.js
+++ b/web/src/inbox_ui.js
@@ -16,6 +16,7 @@ import * as left_sidebar_navigation_area from "./left_sidebar_navigation_area";
import {localstorage} from "./localstorage";
import * as message_store from "./message_store";
import * as overlays from "./overlays";
+import {page_params} from "./page_params";
import * as people from "./people";
import * as popovers from "./popovers";
import * as sidebar_ui from "./sidebar_ui";
@@ -38,7 +39,8 @@ const COLUMNS = {
COLLAPSE_BUTTON: 0,
RECIPIENT: 1,
UNREAD_COUNT: 2,
- ACTION_MENU: 3,
+ TOPIC_VISIBILITY: 3,
+ ACTION_MENU: 4,
};
let col_focus = COLUMNS.COLLAPSE_BUTTON;
let row_focus = 0;
@@ -310,6 +312,15 @@ function format_topic(stream_id, topic, topic_unread_count, latest_msg_id) {
is_collapsed: collapsed_containers.has(STREAM_HEADER_PREFIX + stream_id),
mention_in_unread: unread.topic_has_any_unread_mentions(stream_id, topic),
latest_msg_id,
+ // The following two fields (development & all_visibility_policies)
+ // are not specific to this context, but this is the easiest way
+ // we've figured out for passing the data to the template rendering.
+ development: page_params.development_environment,
+ all_visibility_policies: user_topics.all_visibility_policies,
+ visibility_policy: user_topics.get_topic_visibility_policy(stream_id, topic),
+ topic_muted: Boolean(user_topics.is_topic_muted(stream_id, topic)),
+ topic_unmuted: Boolean(user_topics.is_topic_unmuted(stream_id, topic)),
+ stream_muted: sub_store.get(stream_id).is_muted,
};
return context;
@@ -680,7 +691,9 @@ function set_list_focus(input_key) {
}
const $row_to_focus = $($all_rows.get(row_focus));
- // This includes a fake collapse button for `inbox-row`.
+ // This includes a fake collapse button for `inbox-row` and a fake topic visibility
+ // button for `inbox-header`. The fake buttons help simplify code here and
+ // `$($cols_to_focus[col_focus]).trigger("focus");` at the end of this function.
const $cols_to_focus = [$row_to_focus, ...$row_to_focus.find("[tabindex=0]")];
const total_cols = $cols_to_focus.length;
current_focus_id = $row_to_focus.attr("id");
@@ -718,6 +731,14 @@ function set_list_focus(input_key) {
$row_to_focus.trigger("focus");
return;
}
+ } else if (is_header_row && col_focus === COLUMNS.TOPIC_VISIBILITY) {
+ // `inbox-header` doesn't have a topic visibility indicator, so focus on
+ // button around it instead.
+ if (LEFT_NAVIGATION_KEYS.includes(input_key)) {
+ col_focus = COLUMNS.UNREAD_COUNT;
+ } else {
+ col_focus = COLUMNS.ACTION_MENU;
+ }
}
$($cols_to_focus[col_focus]).trigger("focus");
@@ -948,10 +969,19 @@ function get_focus_class_for_header() {
function get_focus_class_for_row() {
let focus_class = ".inbox-left-part";
- if (col_focus === COLUMNS.UNREAD_COUNT) {
- focus_class = ".unread_count";
- } else if (col_focus === COLUMNS.ACTION_MENU) {
- focus_class = ".inbox-topic-menu";
+ switch (col_focus) {
+ case COLUMNS.UNREAD_COUNT: {
+ focus_class = ".unread_count";
+ break;
+ }
+ case COLUMNS.ACTION_MENU: {
+ focus_class = ".inbox-topic-menu";
+ break;
+ }
+ case COLUMNS.TOPIC_VISIBILITY: {
+ focus_class = ".change_visibility_policy";
+ break;
+ }
}
return focus_class;
}
diff --git a/web/styles/inbox.css b/web/styles/inbox.css
index 1b881e4865c..bc23fdaf1d8 100644
--- a/web/styles/inbox.css
+++ b/web/styles/inbox.css
@@ -296,6 +296,26 @@
.inbox-topic-name {
grid-area: recipient_info;
}
+
+ .inbox-right-part-wrapper {
+ flex-grow: 1;
+
+ .inbox-right-part {
+ display: flex;
+ justify-content: space-between;
+ flex-grow: 1;
+ }
+ }
+
+ .visibility-policy-indicator {
+ display: flex;
+ align-items: center;
+ border-radius: 3px;
+
+ &:focus {
+ outline: 2px solid var(--color-outline-focus);
+ }
+ }
}
.unread_count {
diff --git a/web/templates/inbox_view/inbox_row.hbs b/web/templates/inbox_view/inbox_row.hbs
index 88660893b93..12d79d95ed0 100644
--- a/web/templates/inbox_view/inbox_row.hbs
+++ b/web/templates/inbox_view/inbox_row.hbs
@@ -40,6 +40,35 @@
{{#unless is_direct}}
<div class="inbox-right-part-wrapper">
<div class="inbox-right-part">
+ {{#if is_topic}}
+ {{#if development}}
+ <span class="visibility-policy-indicator change_visibility_policy hidden-for-spectators" data-stream-id="{{stream_id}}" data-topic-name="{{topic_name}}" tabindex="0">
+ {{#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" 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" 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" 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" aria-haspopup="true" aria-label="{{t 'You will get default notifications for this topic' }}"></i>
+ {{/if}}
+ </span>
+ {{else}}
+ <span class="visibility-policy-indicator" tabindex="0">
+ {{#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 tippy-zulip-tooltip" data-stream-id="{{stream_id}}" data-topic-name="{{topic_name}}" role="button"
+ {{#if topic_unmuted}} data-tippy-content="{{t 'Mute topic' }}" aria-label="{{t 'Mute topic' }}" {{else}} data-tippy-content="{{t 'Unmute topic' }}" aria-label="{{t 'Unmute topic' }}" {{/if}} data-tippy-trigger="mouseenter"></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 tippy-zulip-tooltip" data-stream-id="{{stream_id}}" data-topic-name="{{topic_name}}" role="button"
+ {{#if topic_muted}} data-tippy-content="{{t 'Unmute topic' }}" aria-label="{{t 'Unmute topic' }}" {{else}} data-tippy-content="{{t 'Mute topic' }}" aria-label="{{t 'Mute topic' }}" {{/if}} data-tippy-trigger="mouseenter"></i>
+ {{/if}}
+ </span>
+ {{/if}}
+ {{/if}}
<div class="inbox-action-button inbox-topic-menu"
{{#if is_topic}}data-stream-id="{{stream_id}}" data-topic-name="{{topic_name}}"
data-topic-url="{{topic_url}}"{{/if}} tabindex="0">
diff --git a/web/templates/inbox_view/inbox_stream_header_row.hbs b/web/templates/inbox_view/inbox_stream_header_row.hbs
index 8882ddeba72..52b815fc5f0 100644
--- a/web/templates/inbox_view/inbox_stream_header_row.hbs
+++ b/web/templates/inbox_view/inbox_stream_header_row.hbs
@@ -15,6 +15,7 @@
{{#unless mention_in_unread}}hidden{{/unless}}"
data-tippy-content="{{t 'You have mentions'}}">@</span>
<span class="unread_count tippy-zulip-tooltip on_hover_topic_read" data-stream-id="{{stream_id}}" data-tippy-content="{{t 'Mark as read' }}" role="button" tabindex="0" aria-label="{{t 'Mark as read' }}">{{unread_count}}</span>
+ <div class="topic-visibility-indicator invisible" tabindex="0"></div>
</div>
</div>
<div class="inbox-right-part-wrapper">