popover_menus_data: Hide actions user can't take for archived channels.

This commit is contained in:
sanchi-t 2024-09-27 18:03:13 +05:30 committed by Tim Abbott
parent e8bb9e2de1
commit 5dfa8ac9fe
8 changed files with 57 additions and 25 deletions

View File

@ -102,6 +102,10 @@ export function is_topic_editable(message: Message, edit_limit_seconds_buffer =
return false;
}
if (message.type === "stream" && stream_data.is_stream_archived(message.stream_id)) {
return false;
}
if (!settings_data.user_can_move_messages_to_another_topic()) {
return false;
}
@ -206,6 +210,10 @@ export function is_message_sent_by_my_bot(message: Message): boolean {
}
export function get_deletability(message: Message): boolean {
if (message.type === "stream" && stream_data.is_stream_archived(message.stream_id)) {
return false;
}
if (settings_data.user_can_delete_any_message()) {
return true;
}
@ -243,6 +251,10 @@ export function is_stream_editable(message: Message, edit_limit_seconds_buffer =
return false;
}
if (message.type === "stream" && stream_data.is_stream_archived(message.stream_id)) {
return false;
}
if (!settings_data.user_can_move_messages_between_streams()) {
return false;
}

View File

@ -206,7 +206,10 @@ export function get_actions_popover_content_context(message_id: number): ActionP
// `media_breakpoints.sm_min`, we need to include the reaction button in the
// popover if it is not displayed.
const should_display_add_reaction_option =
!message.is_me_message && !is_add_reaction_icon_visible() && not_spectator;
!message.is_me_message &&
!is_add_reaction_icon_visible() &&
not_spectator &&
!(stream_id && stream_data.is_stream_archived(stream_id));
return {
message_id: message.id,

View File

@ -6,6 +6,12 @@
margin-bottom: var(--message-box-markdown-aligned-vertical-space);
}
.message_reaction_container {
&.disabled {
cursor: not-allowed;
}
}
.message_reaction {
display: flex;
/* Set a pixel and half padding to maintain
@ -39,6 +45,10 @@
box-shadow: none;
}
&.disabled {
pointer-events: none;
}
&:hover {
background-color: var(--color-message-reaction-background-hover);
}

View File

@ -1,3 +1,4 @@
{{#unless is_archived}}
{{#if msg/sent_by_me}}
<div class="edit_content message_control_button"></div>
{{/if}}
@ -9,6 +10,7 @@
</div>
</div>
{{/unless}}
{{/unless}}
<div class="actions_hover message_control_button" data-tooltip-template-id="message-actions-tooltip-template" >
<i class="message-controls-icon message-actions-menu-button zulip-icon zulip-icon-more-vertical-spread" role="button" aria-haspopup="true" tabindex="0" aria-label="{{t 'Message actions' }}"></i>

View File

@ -10,7 +10,7 @@
{{> recipient_row use_match_properties=../use_match_properties}}
{{#each message_containers}}
{{#with this}}
{{> single_message use_match_properties=../../use_match_properties message_list_id=../../message_list_id}}
{{> single_message use_match_properties=../../use_match_properties message_list_id=../../message_list_id is_archived=../is_archived}}
{{/with}}
{{/each}}
</div>

View File

@ -1,4 +1,5 @@
<div class="{{this.class}}" aria-label="{{this.label}}" data-reaction-id="{{this.local_id}}">
<div class="message_reaction_container {{#if is_archived}}disabled{{/if}}">
<div class="{{this.class}} {{#if is_archived}}disabled{{/if}}" aria-label="{{this.label}}" data-reaction-id="{{this.local_id}}">
{{#if this.emoji_alt_code}}
<div class="emoji_alt_code">&nbsp;:{{this.emoji_name}}:</div>
{{else if this.is_realm_emoji}}
@ -8,3 +9,4 @@
{{/if}}
<div class="message_reaction_count">{{this.vote_text}}</div>
</div>
</div>

View File

@ -1,11 +1,13 @@
<div class="message_reactions">
{{#each this/msg/message_reactions}}
{{> message_reaction}}
{{> message_reaction is_archived=../is_archived}}
{{/each}}
{{#unless is_archived}}
<div class="reaction_button" role="button" aria-haspopup="true" data-tooltip-template-id="add-emoji-tooltip-template" aria-label="{{t 'Add emoji reaction' }} (:)">
<div class="emoji-message-control-button-container">
<i class="zulip-icon zulip-icon-smile" tabindex="0"></i>
<div class="message_reaction_count">+</div>
</div>
</div>
{{/unless}}
</div>

View File

@ -46,6 +46,7 @@ mock_esm("../src/hash_util", {
});
mock_esm("../src/stream_data", {
is_subscribed: () => true,
is_stream_archived: () => false,
});
mock_esm("../src/group_permission_settings", {
get_group_permission_setting_config() {