From 3f2ab44f9485da603dc192b1b6a03102d13997d4 Mon Sep 17 00:00:00 2001 From: Prakhar Pratyush Date: Mon, 21 Aug 2023 11:40:03 +0530 Subject: [PATCH] follow_topics: Remove the 'development' guard. This commit removes the 'development' guard and makes the UI changes related to the 'Follow Topics' project visible outside the development environment. Cleans up the older UI elements related to mute and unmute topics. --- web/src/inbox_ui.js | 11 +-- web/src/message_list_view.js | 6 +- web/src/popover_menus_data.js | 3 - web/src/recent_view_ui.js | 8 +-- web/src/settings.js | 1 - web/src/settings_user_topics.js | 2 - web/templates/inbox_view/inbox_row.hbs | 42 ++++------- web/templates/recent_view_row.hbs | 36 ++++------ web/templates/recipient_row.hbs | 36 ++++------ .../settings/notification_settings.hbs | 72 +++++++++---------- web/templates/topic_sidebar_actions.hbs | 72 +++++-------------- web/templates/user_topic_ui_row.hbs | 4 +- web/tests/recent_view.test.js | 10 --- 13 files changed, 99 insertions(+), 204 deletions(-) diff --git a/web/src/inbox_ui.js b/web/src/inbox_ui.js index 6e13f6ef8e..21ee0f6b30 100644 --- a/web/src/inbox_ui.js +++ b/web/src/inbox_ui.js @@ -17,7 +17,6 @@ import {localstorage} from "./localstorage"; import * as message_store from "./message_store"; import * as modals from "./modals"; import * as overlays from "./overlays"; -import {page_params} from "./page_params"; import * as people from "./people"; import * as popovers from "./popovers"; import * as sidebar_ui from "./sidebar_ui"; @@ -313,15 +312,11 @@ function format_topic(stream_id, topic, topic_unread_count, latest_msg_id) { is_collapsed: collapsed_containers.has(STREAM_HEADER_PREFIX + stream_id), mention_in_unread: unread.topic_has_any_unread_mentions(stream_id, topic), latest_msg_id, - // The following two fields (development & all_visibility_policies) - // are not specific to this context, but this is the easiest way - // we've figured out for passing the data to the template rendering. - development: page_params.development_environment, + // The 'all_visibility_policies' field is not specific to this context, + // but this is the easiest way we've figured out for passing the data + // to the template rendering. all_visibility_policies: user_topics.all_visibility_policies, visibility_policy: user_topics.get_topic_visibility_policy(stream_id, topic), - topic_muted: Boolean(user_topics.is_topic_muted(stream_id, topic)), - topic_unmuted: Boolean(user_topics.is_topic_unmuted(stream_id, topic)), - stream_muted: sub_store.get(stream_id).is_muted, }; return context; diff --git a/web/src/message_list_view.js b/web/src/message_list_view.js index 996c2d762b..717a4f9b85 100644 --- a/web/src/message_list_view.js +++ b/web/src/message_list_view.js @@ -230,20 +230,16 @@ function populate_group_from_message_container(group, message_container) { group.stream_id = -1; } else { group.stream_id = sub.stream_id; - group.stream_muted = sub.is_muted; } group.is_subscribed = stream_data.is_subscribed(group.stream_id); group.topic_is_resolved = resolved_topic.is_resolved(group.topic); - group.topic_muted = user_topics.is_topic_muted(group.stream_id, group.topic); - group.topic_unmuted = user_topics.is_topic_unmuted(group.stream_id, group.topic); group.visibility_policy = user_topics.get_topic_visibility_policy( group.stream_id, group.topic, ); - // The following two fields are not specific to this group, but this is the + // The following field is not specific to this group, but this is the // easiest way we've figured out for passing the data to the template rendering. - group.development = page_params.development_environment; group.all_visibility_policies = user_topics.all_visibility_policies; } else if (group.is_private) { group.pm_with_url = message_container.pm_with_url; diff --git a/web/src/popover_menus_data.js b/web/src/popover_menus_data.js index 723dcae113..4cb7f149db 100644 --- a/web/src/popover_menus_data.js +++ b/web/src/popover_menus_data.js @@ -118,7 +118,6 @@ export function get_actions_popover_content_context(message_id) { export function get_topic_popover_content_context({stream_id, topic_name, url}) { const sub = sub_store.get(stream_id); - const topic_muted = user_topics.is_topic_muted(sub.stream_id, topic_name); const topic_unmuted = user_topics.is_topic_unmuted(sub.stream_id, topic_name); const has_starred_messages = starred_messages.get_count_in_topic(sub.stream_id, topic_name) > 0; const can_move_topic = settings_data.user_can_move_messages_between_streams(); @@ -130,7 +129,6 @@ export function get_topic_popover_content_context({stream_id, topic_name, url}) stream_id: sub.stream_id, stream_muted: sub.is_muted, topic_name, - topic_muted, topic_unmuted, can_move_topic, can_rename_topic, @@ -141,7 +139,6 @@ export function get_topic_popover_content_context({stream_id, topic_name, url}) url, visibility_policy, all_visibility_policies, - development: page_params.development_environment, }; } diff --git a/web/src/recent_view_ui.js b/web/src/recent_view_ui.js index 098e29f95c..1247f1bdcb 100644 --- a/web/src/recent_view_ui.js +++ b/web/src/recent_view_ui.js @@ -471,7 +471,6 @@ function format_conversation(conversation_data) { // Stream info context.stream_id = last_msg.stream_id; context.stream_name = stream_data.get_stream_name_from_id(last_msg.stream_id); - context.stream_muted = stream_info.is_muted; context.stream_color = stream_info.color; context.stream_url = hash_util.by_stream_url(context.stream_id); context.invite_only = stream_info.invite_only; @@ -484,10 +483,6 @@ function format_conversation(conversation_data) { // We only supply the data to the topic rows and let jquery // display / hide them according to filters instead of // doing complete re-render. - context.topic_muted = Boolean(user_topics.is_topic_muted(context.stream_id, context.topic)); - context.topic_unmuted = Boolean( - user_topics.is_topic_unmuted(context.stream_id, context.topic), - ); context.mention_in_unread = unread.topic_has_any_unread_mentions( context.stream_id, context.topic, @@ -497,9 +492,8 @@ function format_conversation(conversation_data) { context.stream_id, context.topic, ); - // The following two fields are not specific to this context, but this is the + // The following field is not specific to this context, but this is the // easiest way we've figured out for passing the data to the template rendering. - context.development = page_params.development_environment; context.all_visibility_policies = user_topics.all_visibility_policies; // Since the css for displaying senders in reverse order is much simpler, diff --git a/web/src/settings.js b/web/src/settings.js index adba9980c8..a9c36016d2 100644 --- a/web/src/settings.js +++ b/web/src/settings.js @@ -109,7 +109,6 @@ export function build_page() { full_name: people.my_full_name(), date_joined_text: get_parsed_date_of_joining(), page_params, - development: page_params.development_environment, enable_sound_select: user_settings.enable_sounds || user_settings.enable_stream_audible_notifications, zuliprc: "zuliprc", diff --git a/web/src/settings_user_topics.js b/web/src/settings_user_topics.js index fb5223a36d..f0d6c90ade 100644 --- a/web/src/settings_user_topics.js +++ b/web/src/settings_user_topics.js @@ -3,7 +3,6 @@ import $ from "jquery"; import render_user_topic_ui_row from "../templates/user_topic_ui_row.hbs"; import * as ListWidget from "./list_widget"; -import {page_params} from "./page_params"; import * as scroll_util from "./scroll_util"; import * as settings_config from "./settings_config"; import * as user_topics from "./user_topics"; @@ -32,7 +31,6 @@ export function populate_list() { user_topic, user_topic_visibility_policy_values: settings_config.user_topic_visibility_policy_values, - development: page_params.development_environment, }; return render_user_topic_ui_row(context); }, diff --git a/web/templates/inbox_view/inbox_row.hbs b/web/templates/inbox_view/inbox_row.hbs index 7bf96d4712..b4e8a2780d 100644 --- a/web/templates/inbox_view/inbox_row.hbs +++ b/web/templates/inbox_view/inbox_row.hbs @@ -47,33 +47,21 @@
{{#if is_topic}} - {{#if development}} - - {{#if (eq visibility_policy all_visibility_policies.FOLLOWED)}} - - {{else if (eq visibility_policy all_visibility_policies.UNMUTED)}} - - {{else if (eq visibility_policy all_visibility_policies.MUTED)}} - - {{else}} - - {{/if}} - - {{else}} - - {{#if stream_muted}} - - {{else}} - - {{/if}} - - {{/if}} + + {{#if (eq visibility_policy all_visibility_policies.FOLLOWED)}} + + {{else if (eq visibility_policy all_visibility_policies.UNMUTED)}} + + {{else if (eq visibility_policy all_visibility_policies.MUTED)}} + + {{else}} + + {{/if}} + {{/if}}
- {{#if development}} - - {{#if (eq visibility_policy all_visibility_policies.FOLLOWED)}} - - {{else if (eq visibility_policy all_visibility_policies.UNMUTED)}} - - {{else if (eq visibility_policy all_visibility_policies.MUTED)}} - - {{else}} - - {{/if}} - - {{else}} - {{#if stream_muted}} - + + {{#if (eq visibility_policy all_visibility_policies.FOLLOWED)}} + + {{else if (eq visibility_policy all_visibility_policies.UNMUTED)}} + + {{else if (eq visibility_policy all_visibility_policies.MUTED)}} + {{else}} - + {{/if}} - {{/if}} +
{{/if}} diff --git a/web/templates/recipient_row.hbs b/web/templates/recipient_row.hbs index 6e06120924..9c36935ba1 100644 --- a/web/templates/recipient_row.hbs +++ b/web/templates/recipient_row.hbs @@ -59,31 +59,21 @@ {{/if}} {{#if is_subscribed}} - {{#if development}} - - {{#if (eq visibility_policy all_visibility_policies.FOLLOWED)}} - - {{else if (eq visibility_policy all_visibility_policies.UNMUTED)}} - - {{else if (eq visibility_policy all_visibility_policies.MUTED)}} - - {{else}} - - {{/if}} - - {{else}} - {{#if stream_muted}} - + + {{#if (eq visibility_policy all_visibility_policies.FOLLOWED)}} + + {{else if (eq visibility_policy all_visibility_policies.UNMUTED)}} + + {{else if (eq visibility_policy all_visibility_policies.MUTED)}} + {{else}} - + {{/if}} - {{/if}} + {{/if}} {{{date}}} diff --git a/web/templates/settings/notification_settings.hbs b/web/templates/settings/notification_settings.hbs index 6d36bfa966..11aa37c1f2 100644 --- a/web/templates/settings/notification_settings.hbs +++ b/web/templates/settings/notification_settings.hbs @@ -28,18 +28,16 @@ {{#each general_settings}} - {{#unless (and (eq this.label "Followed topics") (not ../development))}} - - {{ this.label }} - {{#each this.notification_settings}} - {{> notification_settings_checkboxes - setting_name=this.setting_name - is_checked=this.is_checked - is_disabled=this.is_disabled - prefix=../../prefix }} - {{/each}} - - {{/unless}} + + {{ this.label }} + {{#each this.notification_settings}} + {{> notification_settings_checkboxes + setting_name=this.setting_name + is_checked=this.is_checked + is_disabled=this.is_disabled + prefix=../../prefix }} + {{/each}} + {{/each}} {{#unless for_realm_settings}} @@ -49,34 +47,32 @@
- {{#if development}} -
+
-
-

{{t "Topic notifications" }} - {{> ../help_link_widget link="/help/mute-a-topic" }} -

- {{> settings_save_discard_widget section_name="topic-notifications-settings" show_only_indicator=(not for_realm_settings) }} -

{{t "You will automatically follow topics that you have configured to both follow and unmute." }}

-
- -
- - -
- -
- - -
+
+

{{t "Topic notifications" }} + {{> ../help_link_widget link="/help/mute-a-topic" }} +

+ {{> settings_save_discard_widget section_name="topic-notifications-settings" show_only_indicator=(not for_realm_settings) }} +

{{t "You will automatically follow topics that you have configured to both follow and unmute." }}

- {{/if}} + +
+ + +
+ +
+ + +
+
diff --git a/web/templates/topic_sidebar_actions.hbs b/web/templates/topic_sidebar_actions.hbs index bdd172ea11..428aef25b7 100644 --- a/web/templates/topic_sidebar_actions.hbs +++ b/web/templates/topic_sidebar_actions.hbs @@ -8,62 +8,26 @@
- {{#if development}} -
  • -
    -
    - -
    -
    - -
    - {{#if (or stream_muted topic_unmuted)}} -
    - -
    - {{/if}} -
    - -
    +
  • +
    +
    +
    -
  • +
    + +
    + {{#if (or stream_muted topic_unmuted)}} +
    + +
    + {{/if}} +
    + +
    +
    + -
    - {{else}} - {{#if stream_muted}} - {{#unless topic_unmuted}} -
  • - - - {{t "Unmute topic"}} - -
  • - {{else}} -
  • - - - {{t "Mute topic"}} - -
  • - {{/unless}} - {{else}} - {{#unless topic_muted}} -
  • - - - {{t "Mute topic"}} - -
  • - {{else}} -
  • - - - {{t "Unmute topic"}} - -
  • - {{/unless}} - {{/if}} - {{/if}} +
    {{#if has_starred_messages}}
  • diff --git a/web/templates/user_topic_ui_row.hbs b/web/templates/user_topic_ui_row.hbs index 77ca2552fc..ae4e21749d 100644 --- a/web/templates/user_topic_ui_row.hbs +++ b/web/templates/user_topic_ui_row.hbs @@ -5,9 +5,7 @@ diff --git a/web/tests/recent_view.test.js b/web/tests/recent_view.test.js index 19b6b14be9..d320281e65 100644 --- a/web/tests/recent_view.test.js +++ b/web/tests/recent_view.test.js @@ -117,12 +117,6 @@ mock_esm("../src/user_topics", { } return false; }, - is_topic_unmuted(stream_id, topic) { - if (stream_id === stream6 && topic === topic11) { - return true; - } - return false; - }, is_topic_unmuted_or_followed(stream_id, topic) { if (stream_id === stream6 && (topic === topic11 || topic === topic12)) { return true; @@ -398,17 +392,13 @@ function generate_topic_data(topic_info_array) { stream_name: "stream_name", stream_color: "", stream_id, - stream_muted: undefined, stream_url: "https://www.example.com", topic, conversation_key: get_topic_key(stream_id, topic), topic_url: "https://www.example.com", unread_count, mention_in_unread: false, - topic_muted: visibility_policy === all_visibility_policies.MUTED, - topic_unmuted: visibility_policy === all_visibility_policies.UNMUTED, visibility_policy, - development: true, all_visibility_policies, }); }