diff --git a/web/src/popover_menus_data.ts b/web/src/popover_menus_data.ts index bef05ece07..f71043b883 100644 --- a/web/src/popover_menus_data.ts +++ b/web/src/popover_menus_data.ts @@ -11,6 +11,7 @@ import * as hash_util from "./hash_util.ts"; import {$t} from "./i18n.ts"; import * as message_edit from "./message_edit.ts"; import * as message_lists from "./message_lists.ts"; +import * as message_util from "./message_util.ts"; import * as muted_users from "./muted_users.ts"; import {page_params} from "./page_params.ts"; import * as people from "./people.ts"; @@ -52,6 +53,7 @@ type TopicPopoverContext = { topic_name: string; topic_unmuted: boolean; is_spectator: boolean; + is_topic_empty: boolean; can_move_topic: boolean; can_rename_topic: boolean; is_realm_admin: boolean; @@ -248,6 +250,7 @@ export function get_topic_popover_content_context({ const visibility_policy = user_topics.get_topic_visibility_policy(sub.stream_id, topic_name); const all_visibility_policies = user_topics.all_visibility_policies; const is_spectator = page_params.is_spectator; + const is_topic_empty = message_util.get_messages_in_topic(stream_id, topic_name).length === 0; return { stream_name: sub.name, stream_id: sub.stream_id, @@ -255,6 +258,7 @@ export function get_topic_popover_content_context({ topic_name, topic_unmuted, is_spectator, + is_topic_empty, can_move_topic, can_rename_topic, is_realm_admin: current_user.is_admin, diff --git a/web/src/topic_popover.js b/web/src/topic_popover.js index 805d6135e9..46cfbbeafc 100644 --- a/web/src/topic_popover.js +++ b/web/src/topic_popover.js @@ -63,6 +63,10 @@ export function initialize() { return; } + if (instance.context.is_topic_empty) { + return; + } + $popper.on("change", "input[name='sidebar-topic-visibility-select']", (e) => { const start_time = Date.now(); const visibility_policy = Number.parseInt( diff --git a/web/templates/popovers/left_sidebar/left_sidebar_topic_actions_popover.hbs b/web/templates/popovers/left_sidebar/left_sidebar_topic_actions_popover.hbs index 300d169afa..0e915cd810 100644 --- a/web/templates/popovers/left_sidebar/left_sidebar_topic_actions_popover.hbs +++ b/web/templates/popovers/left_sidebar/left_sidebar_topic_actions_popover.hbs @@ -3,103 +3,110 @@
  • {{topic_name}}
  • - {{!-- Group 1 --}} - {{#unless is_spectator}} - -
  • -
    - - - - - {{#if (or stream_muted topic_unmuted)}} - - - {{/if}} - - - -
    -
  • - {{/unless}} - {{!-- Group 2 --}} - - {{#if has_starred_messages}} - - {{/if}} - {{#if has_unread_messages}} - + {{#if is_topic_empty}} + +
  • + {{t "There are no messages in this topic." }} +
  • {{else}} - - {{/if}} - - {{!-- Group 3 --}} - {{#if (or can_move_topic can_rename_topic is_realm_admin)}} - - {{/if}} - {{#if can_move_topic}} - - {{else if can_rename_topic}} - - {{/if}} - {{#if can_rename_topic}} - - {{/if}} - {{#if is_realm_admin}} - + {{!-- Group 1 --}} + {{#unless is_spectator}} + +
  • +
    + + + + + {{#if (or stream_muted topic_unmuted)}} + + + {{/if}} + + + +
    +
  • + {{/unless}} + {{!-- Group 2 --}} + + {{#if has_starred_messages}} + + {{/if}} + {{#if has_unread_messages}} + + {{else}} + + {{/if}} + + {{!-- Group 3 --}} + {{#if (or can_move_topic can_rename_topic is_realm_admin)}} + + {{/if}} + {{#if can_move_topic}} + + {{else if can_rename_topic}} + + {{/if}} + {{#if can_rename_topic}} + + {{/if}} + {{#if is_realm_admin}} + + {{/if}} {{/if}}