Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
inbox_ui: Move common widget params to views_util.
Aman Agrawalde767cc9ad25
diff --git a/web/src/inbox_ui.js b/web/src/inbox_ui.jsindex ad515f3861e..c181d6cfdfd 100644--- a/web/src/inbox_ui.js+++ b/web/src/inbox_ui.js@@ -11,7 +11,6 @@ import * as compose_closed_ui from "./compose_closed_ui";import * as compose_state from "./compose_state";import * as dropdown_widget from "./dropdown_widget";import * as hash_util from "./hash_util";-import {$t} from "./i18n";import {is_visible, set_visible} from "./inbox_util";import * as keydown_util from "./keydown_util";import * as left_sidebar_navigation_area from "./left_sidebar_navigation_area";@@ -497,35 +496,6 @@ function show_empty_inbox_text(has_visible_unreads) {}}-function filters_dropdown_options() {- return [- {- unique_id: views_util.FILTERS.FOLLOWED_TOPICS,- name: $t({defaultMessage: "Followed topics"}),- description: $t({defaultMessage: "Only topics you follow"}),- bold_current_selection:- filters_dropdown_widget &&- filters_dropdown_widget.current_value === views_util.FILTERS.FOLLOWED_TOPICS,- },- {- unique_id: views_util.FILTERS.UNMUTED_TOPICS,- name: $t({defaultMessage: "Standard view"}),- description: $t({defaultMessage: "All unmuted topics"}),- bold_current_selection:- filters_dropdown_widget &&- filters_dropdown_widget.current_value === views_util.FILTERS.UNMUTED_TOPICS,- },- {- unique_id: views_util.FILTERS.ALL_TOPICS,- name: $t({defaultMessage: "All topics"}),- description: $t({defaultMessage: "Includes muted topics and streams"}),- bold_current_selection:- filters_dropdown_widget &&- filters_dropdown_widget.current_value === views_util.FILTERS.ALL_TOPICS,- },- ];-}-function filter_click_handler(event, dropdown, widget) {event.preventDefault();event.stopPropagation();@@ -567,18 +537,11 @@ export function complete_rerender() {}, 0);filters_dropdown_widget = new dropdown_widget.DropdownWidget({+ ...views_util.COMMON_DROPDOWN_WIDGET_PARAMS,widget_name: "inbox-filter",- get_options: filters_dropdown_options,item_click_callback: filter_click_handler,$events_container: $("#inbox-main"),- tippy_props: {- placement: "bottom-start",- offset: [0, 2],- },- unique_id_type: dropdown_widget.DATA_TYPES.STRING,default_id: filters.values().next().value,- hide_search_box: true,- bold_current_selection: true,});filters_dropdown_widget.setup();}diff --git a/web/src/views_util.js b/web/src/views_util.jsindex 7101de81159..64b3dad6f27 100644--- a/web/src/views_util.js+++ b/web/src/views_util.js@@ -1,6 +1,8 @@import $ from "jquery";import * as compose_recipient from "./compose_recipient";+import * as dropdown_widget from "./dropdown_widget";+import {$t} from "./i18n";import * as message_lists from "./message_lists";import * as message_view_header from "./message_view_header";import * as message_viewport from "./message_viewport";@@ -18,6 +20,42 @@ export const FILTERS = {FOLLOWED_TOPICS: "followed_topics",};+export const COMMON_DROPDOWN_WIDGET_PARAMS = {+ get_options: filters_dropdown_options,+ tippy_props: {+ placement: "bottom-start",+ offset: [0, 2],+ },+ unique_id_type: dropdown_widget.DATA_TYPES.STRING,+ hide_search_box: true,+ bold_current_selection: true,+};++export function filters_dropdown_options() {+ return [+ {+ unique_id: FILTERS.FOLLOWED_TOPICS,+ name: $t({defaultMessage: "Followed topics"}),+ description: $t({defaultMessage: "Only topics you follow"}),+ bold_current_selection: this.current_value === FILTERS.FOLLOWED_TOPICS,+ },+ {+ unique_id: FILTERS.UNMUTED_TOPICS,+ name: $t({defaultMessage: "Standard view"}),+ description: $t({defaultMessage: "All unmuted topics"}),+ bold_current_selection: this.current_value === FILTERS.UNMUTED_TOPICS,+ },+ {+ unique_id: FILTERS.ALL_TOPICS,+ name: $t({defaultMessage: "All topics"}),+ description: $t({+ defaultMessage: "Includes muted streams and topics",+ }),+ bold_current_selection: this.current_value === FILTERS.ALL_TOPICS,+ },+ ];+}+export function show(opts) {if (narrow_state.has_shown_message_list_view) {message_lists.save_pre_narrow_offset_for_reload();