frontend: Allow users to see the source of messages they can't edit.

Previously we showed an "Edit" item in the actions popover menu when a user
could edit the content or topic of a message, and nothing otherwise. We now
show "Edit", "Edit Topic", or "View Source" in the popover menu for every
message, depending on the editability of the message, and present an
appropriate version of message_edit_form when the menu item is clicked.

Finishes #1604 and #1761.
This commit is contained in:
Rishi Gupta
2016-10-21 17:38:56 -07:00
committed by Tim Abbott
parent 879f2a1e2e
commit 49b23ea84a
6 changed files with 48 additions and 9 deletions

View File

@@ -60,6 +60,14 @@ exports.toggle_actions_popover = function (element, id) {
var editability = message_edit.get_editability(message);
var is_editable = (editability === message_edit.editability_types.TOPIC_ONLY ||
editability === message_edit.editability_types.FULL);
var editability_menu_item;
if (editability === message_edit.editability_types.FULL) {
editability_menu_item = i18n.t("Edit");
} else if (editability === message_edit.editability_types.TOPIC_ONLY) {
editability_menu_item = i18n.t("Edit Topic");
} else {
editability_menu_item = i18n.t("View Source");
}
var can_mute_topic =
message.stream &&
message.subject &&
@@ -72,6 +80,7 @@ exports.toggle_actions_popover = function (element, id) {
var args = {
message: message,
is_editable: is_editable,
editability_menu_item: editability_menu_item,
can_mute_topic: can_mute_topic,
can_unmute_topic: can_unmute_topic,
conversation_time_uri: narrow.by_conversation_and_time_uri(message),