Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
compose_box: Add button to go the narrow message is being composed to.
Dinesh43107e1424b2
diff --git a/frontend_tests/node_tests/compose.js b/frontend_tests/node_tests/compose.jsindex 267913107cd..05306b932a0 100644--- a/frontend_tests/node_tests/compose.js+++ b/frontend_tests/node_tests/compose.js@@ -504,6 +504,7 @@ test_ui("update_fade", ({override, override_rewire}) => {let set_focused_recipient_checked = false;let update_all_called = false;+ let update_narrow_to_recipient_visibility_called = false;override_rewire(compose_fade, "set_focused_recipient", (msg_type) => {assert.equal(msg_type, "private");@@ -514,15 +515,23 @@ test_ui("update_fade", ({override, override_rewire}) => {update_all_called = true;});+ override(compose_actions, "update_narrow_to_recipient_visibility", () => {+ update_narrow_to_recipient_visibility_called = true;+ });+compose_state.set_message_type(false);keyup_handler_func();assert.ok(!set_focused_recipient_checked);assert.ok(!update_all_called);+ assert.ok(update_narrow_to_recipient_visibility_called);++ update_narrow_to_recipient_visibility_called = false;compose_state.set_message_type("private");keyup_handler_func();assert.ok(set_focused_recipient_checked);assert.ok(update_all_called);+ assert.ok(update_narrow_to_recipient_visibility_called);});test_ui("trigger_submit_compose_form", ({override, override_rewire}) => {diff --git a/frontend_tests/node_tests/narrow_activate.js b/frontend_tests/node_tests/narrow_activate.jsindex 8ba796f3d44..115fc36fc87 100644--- a/frontend_tests/node_tests/narrow_activate.js+++ b/frontend_tests/node_tests/narrow_activate.js@@ -88,6 +88,7 @@ function test_helper() {stub(message_view_header, "initialize");stub(top_left_corner, "handle_narrow_activated");stub(typing_events, "render_notifications_for_narrow");+ stub(compose_actions, "update_narrow_to_recipient_visibility");stub(ui_util, "change_tab_to");stub(unread_ops, "process_visible");stub(compose_closed_ui, "update_buttons_for_stream");@@ -199,6 +200,7 @@ run_test("basics", () => {[stream_list, "handle_narrow_activated"],[typing_events, "render_notifications_for_narrow"],[message_view_header, "initialize"],+ [compose_actions, "update_narrow_to_recipient_visibility"],]);message_lists.current.selected_id = () => -1;diff --git a/frontend_tests/node_tests/recent_topics.js b/frontend_tests/node_tests/recent_topics.jsindex 2064cd41212..c3335c3df11 100644--- a/frontend_tests/node_tests/recent_topics.js+++ b/frontend_tests/node_tests/recent_topics.js@@ -103,6 +103,7 @@ mock_esm("../../static/js/muted_topics", {const narrow = mock_esm("../../static/js/narrow", {set_narrow_title: noop,hide_mark_as_read_turned_off_banner: noop,+ handle_middle_pane_transition: noop,has_shown_message_list_view: true,});mock_esm("../../static/js/recent_senders", {diff --git a/static/assets/icons/arrow-left-circle.svg b/static/assets/icons/arrow-left-circle.svgnew file mode 100644index 00000000000..3c54848306a--- /dev/null+++ b/static/assets/icons/arrow-left-circle.svg@@ -0,0 +1,14 @@+<svg+ width="19"+ height="19"+ viewBox="0 0 19 19"+ fill="none"+ xmlns="http://www.w3.org/2000/svg">+<path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="m 9.4999761,1.5474549 c -4.3920605,0 -7.9525213,3.5604611 -7.9525213,7.9525221 0,4.392026 3.5604608,7.952568 7.9525213,7.952568 4.3920259,0 7.9525679,-3.560542 7.9525679,-7.952568 0,-4.392061 -3.560542,-7.9525221 -7.9525679,-7.9525221 z M 0,9.499977 C 0,4.2532904 4.25329,0 9.4999761,0 14.746709,0 19,4.2532904 19,9.499977 19,14.746711 14.746709,19 9.4999761,19 4.25329,19 0,14.746711 0,9.499977 Z M 10.0471,5.4623763 c 0.30216,0.3021492 0.30216,0.7920525 0,1.0942134 L 7.8774175,8.7262495 h 5.1131045 c 0.427238,0 0.773727,0.3464088 0.773727,0.7737275 0,0.427283 -0.346489,0.773775 -0.773727,0.773775 H 7.8774175 L 10.0471,12.443329 c 0.30216,0.302161 0.30216,0.792111 0,1.094271 -0.3021606,0.302162 -0.7920754,0.302162 -1.0942246,0 L 5.4623757,10.047101 C 5.160215,9.74494 5.160215,9.2550253 5.4623757,8.952876 L 8.9528754,5.4623763 c 0.3021492,-0.302161 0.792064,-0.302161 1.0942246,0 z"+ fill="#666666"+ id="path2"+ style="stroke-width:1.16349" />+</svg>diff --git a/static/js/compose.js b/static/js/compose.jsindex 01ced4186d4..829220cb9e1 100644--- a/static/js/compose.js+++ b/static/js/compose.js@@ -17,6 +17,7 @@ import {$t, $t_html} from "./i18n";import * as loading from "./loading";import * as markdown from "./markdown";import * as message_edit from "./message_edit";+import * as narrow from "./narrow";import * as notifications from "./notifications";import {page_params} from "./page_params";import * as people from "./people";@@ -103,6 +104,7 @@ export function update_fade() {function update_on_recipient_change() {update_fade();+ compose_actions.update_narrow_to_recipient_visibility();}export function abort_xhr() {@@ -704,6 +706,11 @@ export function initialize() {compose_ui.make_compose_box_full_size();});+ $("#compose").on("click", ".narrow_to_compose_recipients", (e) => {+ e.preventDefault();+ narrow.to_compose_target();+ });+$("#compose").on("click", ".collapse_composebox_button", (e) => {e.preventDefault();e.stopPropagation();diff --git a/static/js/compose_actions.js b/static/js/compose_actions.jsindex 9406f6edd36..eff1546dbb9 100644--- a/static/js/compose_actions.js+++ b/static/js/compose_actions.js@@ -28,6 +28,7 @@ import * as spectators from "./spectators";import * as stream_bar from "./stream_bar";import * as stream_data from "./stream_data";import * as unread_ops from "./unread_ops";+import * as util from "./util";export function blur_compose_inputs() {$(".message_comp").find("input, textarea, button, #private_message_recipient").trigger("blur");@@ -136,6 +137,31 @@ export function expand_compose_box() {$(".message_comp").show();}+function composing_to_current_topic_narrow() {+ return (+ util.lower_same(compose_state.stream_name(), narrow_state.stream() || "") &&+ util.lower_same(compose_state.topic(), narrow_state.topic() || "")+ );+}++export function update_narrow_to_recipient_visibility() {+ const message_type = compose_state.get_message_type();+ if (message_type === "stream") {+ const stream_name = compose_state.stream_name();+ const stream_exists = Boolean(stream_data.get_stream_id(stream_name));++ if (+ stream_exists &&+ !composing_to_current_topic_narrow() &&+ !compose_state.is_topic_field_empty()+ ) {+ $(".narrow_to_compose_recipients").show();+ return;+ }+ }+ $(".narrow_to_compose_recipients").hide();+}+export function complete_starting_tasks(msg_type, opts) {// This is sort of a kitchen sink function, and it's called only// by compose.start() for now. Having this as a separate function@@ -146,6 +172,7 @@ export function complete_starting_tasks(msg_type, opts) {stream_bar.decorate(opts.stream, $("#stream-message .message_header_stream"), true);$(document).trigger(new $.Event("compose_started.zulip", opts));update_placeholder_text();+ update_narrow_to_recipient_visibility();}export function maybe_scroll_up_selected_message() {diff --git a/static/js/narrow.js b/static/js/narrow.jsindex 2aac15800bd..6885958c0dc 100644--- a/static/js/narrow.js+++ b/static/js/narrow.js@@ -168,6 +168,12 @@ export function reset_ui_state() {hide_mark_as_read_turned_off_banner();}+export function handle_middle_pane_transition() {+ if (compose_state.composing) {+ compose_actions.update_narrow_to_recipient_visibility();+ }+}+export function activate(raw_operators, opts) {/* Main entry point for switching to a new view / message list.Note that for historical reasons related to the current@@ -571,6 +577,10 @@ export function activate(raw_operators, opts) {typing_events.render_notifications_for_narrow();message_view_header.initialize();+ // It is important to call this after other important updates+ // like narrow filter and compose recipients happen.+ handle_middle_pane_transition();+msg_list.initial_core_time = new Date();setTimeout(() => {resize.resize_stream_filters_container();@@ -1031,6 +1041,7 @@ export function deactivate(coming_from_recent_topics = false) {condense.condense_and_collapse($("#zhome div.message_row"));reset_ui_state();+ handle_middle_pane_transition();hashchange.save_narrow();if (message_lists.current.selected_id() !== -1) {diff --git a/static/js/recent_topics_ui.js b/static/js/recent_topics_ui.jsindex 938944d1c1d..4a041aba5a2 100644--- a/static/js/recent_topics_ui.js+++ b/static/js/recent_topics_ui.js@@ -655,6 +655,7 @@ export function show() {narrow_state.reset_current_filter();narrow.set_narrow_title("Recent topics");message_view_header.render_title_area();+ narrow.handle_middle_pane_transition();complete_rerender();}diff --git a/static/js/tippyjs.js b/static/js/tippyjs.jsindex 1b9d9dea7e1..d83f8d683a7 100644--- a/static/js/tippyjs.js+++ b/static/js/tippyjs.js@@ -229,6 +229,7 @@ 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) {diff --git a/static/js/ui_init.js b/static/js/ui_init.jsindex 3019cae86c1..502dac86a68 100644--- a/static/js/ui_init.js+++ b/static/js/ui_init.js@@ -206,6 +206,8 @@ function initialize_compose_box() {scroll_to_bottom_key_html: common.has_mac_keyboard()? "Fn + <span class='tooltip_right_arrow'>→</span>": "End",+ narrow_to_compose_recipients_key_html:+ (common.has_mac_keyboard() ? "⌘" : "Ctrl") + " + .",}),);$(`.enter_sends_${user_settings.enter_sends}`).show();diff --git a/static/styles/compose.css b/static/styles/compose.cssindex e34718183c3..7b928e93a64 100644--- a/static/styles/compose.css+++ b/static/styles/compose.css@@ -109,6 +109,22 @@position: relative;margin: 0 5px;}++ a.narrow_to_compose_recipients {+ background: transparent;+ font-size: 18px;+ padding: 1px;+ line-height: 20px;+ opacity: 0.7;+ border: 0;+ margin-left: 3px;+ text-decoration: none;+ color: inherit;++ &:hover {+ opacity: 1;+ }+ }}.pm_recipient {diff --git a/static/styles/dark_theme.css b/static/styles/dark_theme.cssindex c4cbd3b03c1..3532f337e4f 100644--- a/static/styles/dark_theme.css+++ b/static/styles/dark_theme.css@@ -509,6 +509,7 @@ body.dark-theme {border-right-color: hsl(235, 18%, 7%);}+ .narrow_to_compose_recipients,.expand_composebox_button,.collapse_composebox_button,#message_edit_tooltip,@@ -526,6 +527,7 @@ body.dark-theme {color: hsl(236, 33%, 80%);}+ .narrow_to_compose_recipients:hover,.expand_composebox_button:hover,.collapse_composebox_button:hover,#message_edit_tooltip:hover,diff --git a/static/templates/compose.hbs b/static/templates/compose.hbsindex 94e17f56a26..31672e55307 100644--- a/static/templates/compose.hbs+++ b/static/templates/compose.hbs@@ -82,6 +82,9 @@<span id="compose-globe-icon"><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><input type="text" class="recipient_box" name="stream_message_recipient_topic" id="stream_message_recipient_topic" maxlength="60" value="" placeholder="{{t 'Topic' }}" autocomplete="off" tabindex="0" aria-label="{{t 'Topic' }}" />