Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
recent_view: Disable dropdown widget for spectators.
Aman Agrawala872dbb26097
diff --git a/web/src/dropdown_widget.js b/web/src/dropdown_widget.jsindex 8aa0436c19a..5c1c28f9961 100644--- a/web/src/dropdown_widget.js+++ b/web/src/dropdown_widget.js@@ -8,6 +8,7 @@ import render_inline_decorated_stream_name from "../templates/inline_decorated_simport * as blueslip from "./blueslip";import * as ListWidget from "./list_widget";+import {page_params} from "./page_params";import {default_popover_props} from "./popover_menus";import {parse_html} from "./ui_util";@@ -46,6 +47,8 @@ export class DropdownWidget {// Show disabled state if the default_id is not in `get_options()`.show_disabled_if_current_value_not_in_options = false,hide_search_box = false,+ // Disable the widget for spectators.+ disable_for_spectators = false,}) {this.widget_name = widget_name;this.widget_id = `#${CSS.escape(widget_name)}_widget`;@@ -70,6 +73,7 @@ export class DropdownWidget {this.show_disabled_if_current_value_not_in_options =show_disabled_if_current_value_not_in_options;this.hide_search_box = hide_search_box;+ this.disable_for_spectators = disable_for_spectators;}init() {@@ -88,6 +92,15 @@ export class DropdownWidget {}},);++ if (this.disable_for_spectators && page_params.is_spectator) {+ const $widget = $(this.widget_id);+ $widget.addClass("disabled-for-spectators");+ $widget.on("click", (e) => {+ e.stopPropagation();+ e.preventDefault();+ });+ }}show_empty_if_no_items($popper) {diff --git a/web/src/views_util.js b/web/src/views_util.jsindex 64b3dad6f27..fa3af6581d6 100644--- a/web/src/views_util.js+++ b/web/src/views_util.js@@ -29,6 +29,7 @@ export const COMMON_DROPDOWN_WIDGET_PARAMS = {unique_id_type: dropdown_widget.DATA_TYPES.STRING,hide_search_box: true,bold_current_selection: true,+ disable_for_spectators: true,};export function filters_dropdown_options() {diff --git a/web/styles/recent_view.css b/web/styles/recent_view.cssindex 6016a8ad0f2..db7581edf3c 100644--- a/web/styles/recent_view.css+++ b/web/styles/recent_view.css@@ -557,3 +557,8 @@outline: 2px solid var(--color-outline-focus);}}++#recent-view-filter_widget.disabled-for-spectators {+ cursor: not-allowed;+ opacity: 0.5;+}