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.

compose: Display current narrow in go to conversation tooltip.

Dinesh68572e6bc8c5
diff --git a/static/js/tippyjs.js b/static/js/tippyjs.js
index d83f8d683a7..7d884b8bd41 100644
--- a/static/js/tippyjs.js
+++ b/static/js/tippyjs.js
@@ -1,12 +1,18 @@
import $ from "jquery";
+import _ from "lodash";
import tippy, {delegate} from "tippy.js";
import render_message_inline_image_tooltip from "../templates/message_inline_image_tooltip.hbs";
+import render_narrow_to_compose_recipients_tooltip from "../templates/narrow_to_compose_recipients_tooltip.hbs";
+import * as common from "./common";
+import * as compose_state from "./compose_state";
import {$t} from "./i18n";
import * as message_lists from "./message_lists";
+import * as narrow_state from "./narrow_state";
import * as popover_menus from "./popover_menus";
import * as reactions from "./reactions";
+import * as recent_topics_util from "./recent_topics_util";
import * as rows from "./rows";
import * as timerender from "./timerender";
import {parse_html} from "./ui_util";
@@ -229,7 +235,6 @@ export function initialize() {
".rendered_markdown .copy_codeblock",
"#compose_top_right [data-tippy-content]",
"#compose_top_right [data-tooltip-template-id]",
- ".narrow_to_compose_recipients",
],
appendTo: () => document.body,
onHidden(instance) {
@@ -237,6 +242,43 @@ export function initialize() {
},
});
+ delegate("body", {
+ target: ".narrow_to_compose_recipients",
+ appendTo: () => document.body,
+ content() {
+ const narrow_filter = narrow_state.filter();
+ let display_current_view;
+ if (!recent_topics_util.is_visible()) {
+ if (narrow_filter === undefined) {
+ display_current_view = $t({defaultMessage: "Currently viewing all messages."});
+ } else if (
+ _.isEqual(narrow_filter.sorted_term_types(), ["stream"]) &&
+ compose_state.get_message_type() === "stream" &&
+ narrow_filter.operands("stream")[0] === compose_state.stream_name()
+ ) {
+ display_current_view = $t({
+ defaultMessage: "Currently viewing the entire stream.",
+ });
+ } else if (
+ _.isEqual(narrow_filter.sorted_term_types(), ["is-private"]) &&
+ compose_state.get_message_type() === "private"
+ ) {
+ display_current_view = $t({
+ defaultMessage: "Currently viewing all private messages.",
+ });
+ }
+ }
+
+ const shortcut_html = (common.has_mac_keyboard() ? "⌘" : "Ctrl") + " + .";
+ return parse_html(
+ render_narrow_to_compose_recipients_tooltip({shortcut_html, display_current_view}),
+ );
+ },
+ onHidden(instance) {
+ instance.destroy();
+ },
+ });
+
delegate("body", {
target: [".enter_sends_true", ".enter_sends_false"],
content: $t({defaultMessage: "Change send shortcut"}),
diff --git a/static/styles/compose.css b/static/styles/compose.css
index 7b928e93a64..58e5fe82c1b 100644
--- a/static/styles/compose.css
+++ b/static/styles/compose.css
@@ -84,6 +84,13 @@
opacity: 1;
}
+.narrow_to_compose_recipient_current_view_help {
+ margin: 0;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+
.compose_table {
height: 100%;
display: flex;
diff --git a/static/templates/compose.hbs b/static/templates/compose.hbs
index 31672e55307..1ffe7fa026d 100644
--- a/static/templates/compose.hbs
+++ b/static/templates/compose.hbs
@@ -83,7 +83,6 @@
<i class="zulip-icon zulip-icon-globe" title="{{t 'This is a web-public stream' }}" aria-hidden="true"></i>
</span>
<a role="button" class="narrow_to_compose_recipients zulip-icon zulip-icon-arrow-left-circle order-1" data-tooltip-template-id="narrow_to_compose_recipients_tooltip" tabindex="0">
- <template id="narrow_to_compose_recipients_tooltip">{{t 'Go to conversation' }} <span class="hotkey-hint">({{narrow_to_compose_recipients_key_html}})</span></template>
</a>
<input type="text" class="recipient_box" name="stream_message_recipient_stream" id="stream_message_recipient_stream" maxlength="30" value="" placeholder="{{t 'Stream' }}" autocomplete="off" tabindex="0" aria-label="{{t 'Stream' }}" />
<i class="fa fa-angle-right" aria-hidden="true"></i>
diff --git a/static/templates/narrow_to_compose_recipients_tooltip.hbs b/static/templates/narrow_to_compose_recipients_tooltip.hbs
new file mode 100644
index 00000000000..daebbe366fc
--- /dev/null
+++ b/static/templates/narrow_to_compose_recipients_tooltip.hbs
@@ -0,0 +1,4 @@
+<b><span>{{t 'Go to conversation' }}</span> <span class="hotkey-hint">({{shortcut_html}})</span></b>
+{{#if display_current_view}}
+<p class="narrow_to_compose_recipient_current_view_help">{{display_current_view}}</p>
+{{/if}}