Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
popovers: Add search typeahead to Move topic popover.
aryanshridhar42c02f0788eb
diff --git a/static/js/stream_popover.js b/static/js/stream_popover.jsindex 36f616254af..f1f2f280557 100644--- a/static/js/stream_popover.js+++ b/static/js/stream_popover.js@@ -11,7 +11,9 @@ import * as blueslip from "./blueslip";import * as browser_history from "./browser_history";import * as channel from "./channel";import * as compose_actions from "./compose_actions";+import {DropdownListWidget as dropdown_list_widget} from "./dropdown_list_widget";import * as hash_util from "./hash_util";+import {$t} from "./i18n";import * as message_edit from "./message_edit";import * as muting from "./muting";import * as muting_ui from "./muting_ui";@@ -33,6 +35,8 @@ let current_stream_sidebar_elem;let current_topic_sidebar_elem;let all_messages_sidebar_elem;let starred_messages_sidebar_elem;+let stream_widget;+let stream_header_colorblock;function get_popover_menu_items(sidebar_elem) {if (!sidebar_elem) {@@ -323,32 +327,36 @@ function build_move_topic_to_stream_popover(e, current_stream_id, topic_name) {// NOTE: Private streams are also included in this list. We// likely will make it possible to move messages to/from private// streams in the future.- const available_streams = stream_data- .subscribed_subs()- .filter((s) => s.stream_id !== current_stream_id);const current_stream_name = stream_data.maybe_get_stream_name(current_stream_id);const args = {- available_streams,topic_name,current_stream_id,- current_stream_name,notify_new_thread: message_edit.notify_new_thread_default,notify_old_thread: message_edit.notify_old_thread_default,};+ const streams_list = stream_data.subscribed_subs().map((stream) => ({+ name: stream.name,+ value: stream.stream_id.toString(),+ }));+ const opts = {+ widget_name: "select_stream",+ data: streams_list,+ default_text: $t({defaultMessage: "No streams"}),+ include_current_item: false,+ value: current_stream_id,+ };+hide_topic_popover();$("#move-a-topic-modal-holder").html(render_move_topic_to_stream(args));- const stream_header_colorblock = $(".topic_stream_edit_header").find(+ stream_widget = dropdown_list_widget(opts);+ stream_header_colorblock = $("#move_topic_modal .topic_stream_edit_header").find(".stream_header_colorblock",);- stream_bar.decorate(current_stream_name, stream_header_colorblock, false);- $("#select_stream_id").on("change", function () {- const stream_name = stream_data.maybe_get_stream_name(Number.parseInt(this.value, 10));- stream_bar.decorate(stream_name, stream_header_colorblock, false);- });+ stream_bar.decorate(current_stream_name, stream_header_colorblock, false);$("#move_topic_modal").modal("show");}@@ -389,6 +397,21 @@ export function register_click_handlers() {build_starred_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.+ e.preventDefault();++ if (e.type === "keypress" && e.which !== 13) {+ return;+ }+ const stream_name = stream_data.maybe_get_stream_name(+ Number.parseInt(stream_widget.value(), 10),+ );++ stream_bar.decorate(stream_name, stream_header_colorblock, false);+ });+register_stream_handlers();register_topic_handlers();}@@ -610,7 +633,9 @@ export function register_topic_handlers() {.map(({name, value}) => [name, value]),);- const {old_topic_name, select_stream_id} = params;+ const {old_topic_name} = params;+ const select_stream_id = stream_widget.value();+let {current_stream_id,new_topic_name,diff --git a/static/styles/zulip.css b/static/styles/zulip.cssindex 93409be964f..f3a0ec1ba1f 100644--- a/static/styles/zulip.css+++ b/static/styles/zulip.css@@ -2357,6 +2357,12 @@ div.topic_edit_spinner .loading_indicator_spinner {max-height: 60vh;}+#move_topic_modal {+ .stream_header_colorblock {+ margin-bottom: 20px;+ }+}+#invitee_emails {min-height: 40px;max-height: 300px;diff --git a/static/templates/move_topic_to_stream.hbs b/static/templates/move_topic_to_stream.hbsindex 94ca8358b12..c208708f3a2 100644--- a/static/templates/move_topic_to_stream.hbs+++ b/static/templates/move_topic_to_stream.hbs@@ -13,12 +13,11 @@<p>{{t "Select a stream below or change topic name." }}</p><div class="topic_stream_edit_header"><div class="stream_header_colorblock"></div>- <select name="select_stream_id" class="inline_select_topic_edit" id="select_stream_id">- <option value="{{ current_stream_id }}">#{{ current_stream_name }}</option>- {{#each available_streams}}- <option value="{{ this.stream_id }}">#{{this.name}}</option>- {{/each}}- </select>+ <div class="move-topic-dropdown">+ {{> settings/dropdown_list_widget+ widget_name="select_stream"+ list_placeholder=(t 'Filter streams')}}+ </div><i class="fa fa-angle-right" aria-hidden="true"></i><input name="new_topic_name" type="text" class="inline_topic_edit" value="{{topic_name}}" /><input name="old_topic_name" type="hidden" class="inline_topic_edit" value="{{topic_name}}" />