popovers: Show "Move message" menu always when moving message is allowed.

Previously "Move message" option was not shown when content editing
was also allowed and also when only moving messaages between streams
was allowed but not topic edits.

Now we show "Move message" option when editing topics or moving
messages between streams is allowed irrespective of whether content
editing is allowed or not.
This commit is contained in:
Sahil Batra 2022-09-29 14:57:53 +05:30 committed by Tim Abbott
parent 67d7efefdc
commit 1dd89b8f9b
5 changed files with 41 additions and 27 deletions

View File

@ -467,19 +467,24 @@ export function toggle_actions_popover(element, id) {
!message_container.is_hidden &&
not_spectator;
const editability = message_edit.get_editability(message);
let use_edit_icon;
const is_stream_editable =
message.is_stream && settings_data.user_can_move_messages_between_streams();
let editability_menu_item;
let move_message_menu_item;
let view_source_menu_item;
if (editability === message_edit.editability_types.FULL) {
use_edit_icon = true;
editability_menu_item = $t({defaultMessage: "Edit message"});
} else if (editability === message_edit.editability_types.TOPIC_ONLY) {
use_edit_icon = false;
editability_menu_item = $t({defaultMessage: "Move message"});
if (message.is_stream) {
move_message_menu_item = $t({defaultMessage: "Move message"});
}
} else if (
editability === message_edit.editability_types.TOPIC_ONLY ||
is_stream_editable
) {
move_message_menu_item = $t({defaultMessage: "Move message"});
view_source_menu_item = $t({defaultMessage: "View message source"});
} else {
use_edit_icon = false;
view_source_menu_item = $t({defaultMessage: "View message source"});
}
@ -516,9 +521,6 @@ export function toggle_actions_popover(element, id) {
const should_display_uncollapse =
!message.locally_echoed && !message.is_me_message && message.collapsed;
const should_display_edit_and_move_message =
editability === message_edit.editability_types.FULL ||
editability === message_edit.editability_types.TOPIC_ONLY;
const should_display_view_source = editability !== message_edit.editability_types.FULL;
const should_display_quote_and_reply =
@ -535,8 +537,8 @@ export function toggle_actions_popover(element, id) {
message_id: message.id,
historical: message.historical,
stream_id: message.stream_id,
use_edit_icon,
editability_menu_item,
move_message_menu_item,
should_display_mark_as_unread,
view_source_menu_item,
should_display_collapse,
@ -549,7 +551,6 @@ export function toggle_actions_popover(element, id) {
should_display_delete_option,
should_display_read_receipts_option,
should_display_reminder_option: feature_flags.reminders_in_message_action_menu,
should_display_edit_and_move_message,
should_display_view_source,
should_display_quote_and_reply,
};
@ -1236,14 +1237,18 @@ export function register_click_handlers() {
e.stopPropagation();
e.preventDefault();
});
$("body").on("click", ".popover_edit_message, .popover_view_source", (e) => {
const message_id = $(e.currentTarget).data("message-id");
const $row = message_lists.current.get_row(message_id);
hide_actions_popover();
message_edit.start($row);
e.stopPropagation();
e.preventDefault();
});
$("body").on(
"click",
".popover_edit_message, .popover_move_message, .popover_view_source",
(e) => {
const message_id = $(e.currentTarget).data("message-id");
const $row = message_lists.current.get_row(message_id);
hide_actions_popover();
message_edit.start($row);
e.stopPropagation();
e.preventDefault();
},
);
$("body").on("click", ".rehide_muted_user_message", (e) => {
const message_id = $(e.currentTarget).data("message-id");
const $row = message_lists.current.get_row(message_id);

View File

@ -9,10 +9,19 @@
</li>
{{/if}}
{{#if should_display_edit_and_move_message}}
{{#if editability_menu_item}}
<li>
<a class="popover_edit_message" data-message-id="{{message_id}}" tabindex="0">
<i class="{{#if use_edit_icon}}fa fa-pencil{{else}}fa fa-arrows{{/if}}" aria-hidden="true"></i> {{editability_menu_item}}
<i class="fa fa-pencil" aria-hidden="true"></i> {{editability_menu_item}}
<span class="hotkey-hint">(e)</span>
</a>
</li>
{{/if}}
{{#if move_message_menu_item}}
<li>
<a class="popover_move_message" data-message-id="{{message_id}}" tabindex="0">
<i class="fa fa-arrows" aria-hidden="true"></i> {{move_message_menu_item}}
<span class="hotkey-hint">(e)</span>
</a>
</li>

View File

@ -47,8 +47,8 @@ destination streams.
{!message-actions-menu.md!}
1. Select **Move message** or **Edit message** (only one of these options will be shown). If you do
not see either option, you do not have permission to move this message.
1. Select **Move message**. If you do not see this option, you do not have permission
to move this message.
1. Select the destination stream for the message from the streams dropdown list.

View File

@ -22,8 +22,8 @@ for the details on when topic editing is allowed.
{!message-actions-menu.md!}
1. Select **Move message** or **Edit message** (only one of these options will be shown). If you do
not see either option, you do not have permission to move this message.
1. Select **Move message**. If you do not see this option, you do not have permission
to move this message.
1. Set the destination topic.

View File

@ -36,8 +36,8 @@ for the details on when topic editing is allowed.
{!message-actions-menu.md!}
1. Select **Move message** or **Edit message** (only one of these options will be shown). If you do
not see either option, you do not have permission to edit the topic of this message.
1. Select **Move message**. If you do not see this option, you do not have permission
to edit the topic of this message.
1. Edit the topic.