Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
popovers: Migrate "all messages" popover to Tippy.
Daniil Fadeev1337c0fec1bb
diff --git a/web/src/hotkey.js b/web/src/hotkey.jsindex b7f59fcbcea..2125fdaec03 100644--- a/web/src/hotkey.js+++ b/web/src/hotkey.js@@ -402,11 +402,6 @@ function handle_popover_events(event_name) {return true;}- if (stream_popover.all_messages_popped()) {- stream_popover.all_messages_sidebar_menu_handle_keyboard(event_name);- return true;- }-return false;}diff --git a/web/src/popover_menus.js b/web/src/popover_menus.jsindex 9142c99ec80..43d0e08409f 100644--- a/web/src/popover_menus.js+++ b/web/src/popover_menus.js@@ -7,6 +7,7 @@ import $ from "jquery";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_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_drafts_sidebar_actions from "../templates/drafts_sidebar_action.hbs";@@ -51,6 +52,7 @@ const popover_instances = {compose_control_buttons: null,starred_messages: null,drafts: null,+ all_messages: null,};export function sidebar_menu_instance_handle_keyboard(instance, key) {@@ -564,4 +566,27 @@ export function initialize() {popover_instances.drafts = undefined;},});++ // All messages popover+ tippy_no_propagation(".all-messages-sidebar-menu-icon", {+ ...left_sidebar_tippy_options,+ onMount(instance) {+ const $popper = $(instance.popper);+ $popper.addClass("all-messages-popover");+ popover_instances.all_messages = instance;++ $popper.one("click", "#mark_all_messages_as_read", () => {+ unread_ops.confirm_mark_all_as_read();+ instance.hide();+ });+ },+ onShow(instance) {+ popovers.hide_all_except_sidebars();+ instance.setContent(parse_html(render_all_messages_sidebar_actions()));+ },+ onHidden(instance) {+ instance.destroy();+ popover_instances.all_messages = undefined;+ },+ });}diff --git a/web/src/popovers.js b/web/src/popovers.jsindex 34765946745..e8c813da378 100644--- a/web/src/popovers.js+++ b/web/src/popovers.js@@ -1141,7 +1141,6 @@ export function hide_all_except_sidebars(opts) {giphy.hide_giphy_popover();stream_popover.hide_stream_popover();stream_popover.hide_topic_popover();- stream_popover.hide_all_messages_popover();hide_all_user_info_popovers();hide_playground_links_popover();diff --git a/web/src/stream_popover.js b/web/src/stream_popover.jsindex b191b3c8e5f..bab0fabf398 100644--- a/web/src/stream_popover.js+++ b/web/src/stream_popover.js@@ -2,7 +2,6 @@ import ClipboardJS from "clipboard";import $ from "jquery";import * as resolved_topic from "../shared/src/resolved_topic";-import render_all_messages_sidebar_actions from "../templates/all_messages_sidebar_actions.hbs";import render_delete_topic_modal from "../templates/confirm_dialog/confirm_delete_topic.hbs";import render_move_topic_to_stream from "../templates/move_topic_to_stream.hbs";import render_stream_sidebar_actions from "../templates/stream_sidebar_actions.hbs";@@ -39,7 +38,6 @@ import * as user_topics from "./user_topics";// module. Both are popped up from the left sidebar.let current_stream_sidebar_elem;let current_topic_sidebar_elem;-let all_messages_sidebar_elem;let stream_widget;let $stream_header_colorblock;@@ -77,11 +75,6 @@ export function topic_sidebar_menu_handle_keyboard(key) {popovers.popover_items_handle_keyboard(key, items);}-export function all_messages_sidebar_menu_handle_keyboard(key) {- const items = get_popover_menu_items(all_messages_sidebar_elem);- popovers.popover_items_handle_keyboard(key, items);-}-function elem_to_stream_id($elem) {const stream_id = Number.parseInt($elem.attr("data-stream-id"), 10);@@ -104,10 +97,6 @@ export function topic_popped() {return current_topic_sidebar_elem !== undefined;}-export function all_messages_popped() {- return all_messages_sidebar_elem !== undefined;-}-export function hide_stream_popover() {if (stream_popped()) {$(current_stream_sidebar_elem).popover("destroy");@@ -124,14 +113,6 @@ export function hide_topic_popover() {}}-export function hide_all_messages_popover() {- if (all_messages_popped()) {- $(all_messages_sidebar_elem).popover("destroy");- hide_left_sidebar_menu_icon();- all_messages_sidebar_elem = undefined;- }-}-export function show_streamlist_sidebar() {$(".app-main .column-left").addClass("expanded");resize.resize_stream_filters_container();@@ -286,32 +267,6 @@ function build_topic_popover(opts) {show_left_sidebar_menu_icon(elt);}-function build_all_messages_popover(e) {- const elt = e.target;-- if (all_messages_popped() && all_messages_sidebar_elem === elt) {- hide_all_messages_popover();- e.stopPropagation();- return;- }-- popovers.hide_all_except_sidebars();-- const content = render_all_messages_sidebar_actions();-- $(elt).popover({- content,- html: true,- trigger: "manual",- fixed: true,- });-- $(elt).popover("show");- all_messages_sidebar_elem = elt;- show_left_sidebar_menu_icon(elt);- e.stopPropagation();-}-export function build_move_topic_to_stream_popover(current_stream_id, topic_name, message) {const current_stream_name = stream_data.maybe_get_stream_name(current_stream_id);const args = {@@ -532,8 +487,6 @@ export function register_click_handlers() {build_topic_link_clipboard(url);});- $("#global_filters").on("click", ".all-messages-sidebar-menu-icon", build_all_messages_popover);-$("body").on("click keypress", ".move-topic-dropdown .list_item", (e) => {// We want the dropdown to collapse once any of the list item is pressed// and thus don't want to kill the natural bubbling of event.@@ -579,13 +532,6 @@ export function register_stream_handlers() {e.stopPropagation();});- // Mark all messages as read- $("body").on("click", "#mark_all_messages_as_read", (e) => {- hide_all_messages_popover();- e.stopPropagation();- unread_ops.confirm_mark_all_as_read();- });-// Unstar all messages in topic$("body").on("click", ".sidebar-popover-unstar-all-in-topic", (e) => {e.preventDefault();diff --git a/web/tests/hotkey.test.js b/web/tests/hotkey.test.jsindex d805f26a52e..26fad210998 100644--- a/web/tests/hotkey.test.js+++ b/web/tests/hotkey.test.js@@ -86,7 +86,6 @@ mock_esm("../src/recent_topics_util", {const stream_popover = mock_esm("../src/stream_popover", {stream_popped: () => false,topic_popped: () => false,- all_messages_popped: () => false,});message_lists.current = {diff --git a/web/tests/popovers.test.js b/web/tests/popovers.test.jsindex 7f0b7838ed4..c78b5bf6644 100644--- a/web/tests/popovers.test.js+++ b/web/tests/popovers.test.js@@ -32,7 +32,6 @@ const message_lists = mock_esm("../src/message_lists", {mock_esm("../src/stream_popover", {hide_stream_popover: noop,hide_topic_popover: noop,- hide_all_messages_popover: noop,hide_drafts_popover: noop,hide_streamlist_sidebar: noop,});