Skip to content

Commit

Permalink
views: Place message actions in new group in message information popup.
Browse files Browse the repository at this point in the history
With all actions grouped, the text can be simplified, with the hotkeys
labelled as elsewhere in the application via eg. [V].

Fixes #1339.
  • Loading branch information
axrav authored and neiljp committed Mar 25, 2023
1 parent b89def6 commit 181fe94
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 25 deletions.
8 changes: 5 additions & 3 deletions tests/ui_tools/test_popups.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,8 +1027,10 @@ def test_keypress_view_in_browser(
assert self.controller.open_in_browser.called

def test_height_noreactions(self) -> None:
expected_height = 6
expected_height = 8
# 6 = 1 (date & time) +1 (sender's name) +1 (sender's email)
# +1 (display group header)
# +1 (whitespace column)
# +1 (view message in browser)
# +1 (full rendered message)
# +1 (full raw message)
Expand Down Expand Up @@ -1099,9 +1101,9 @@ def test_height_reactions(
OrderedDict(),
list(),
)
# 12 = 6 labels + 1 blank line + 1 'Reactions' (category)
# 12 = 7 labels + 2 blank lines + 1 'Reactions' (category)
# + 4 reactions (excluding 'Message Links').
expected_height = 12
expected_height = 14
assert self.msg_info_view.height == expected_height

@pytest.mark.parametrize(
Expand Down
49 changes: 27 additions & 22 deletions zulipterminal/ui_tools/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1520,13 +1520,15 @@ def __init__(
date_and_time = controller.model.formatted_local_time(
msg["timestamp"], show_seconds=True, show_year=True
)
view_in_browser_keys = ", ".join(map(repr, keys_for_command("VIEW_IN_BROWSER")))
view_in_browser_keys = "[{}]".format(
", ".join(map(str, keys_for_command("VIEW_IN_BROWSER")))
)

full_rendered_message_keys = ", ".join(
map(repr, keys_for_command("FULL_RENDERED_MESSAGE"))
full_rendered_message_keys = "[{}]".format(
", ".join(map(str, keys_for_command("FULL_RENDERED_MESSAGE")))
)
full_raw_message_keys = ", ".join(
map(repr, keys_for_command("FULL_RAW_MESSAGE"))
full_raw_message_keys = "[{}]".format(
", ".join(map(str, keys_for_command("FULL_RAW_MESSAGE")))
)
msg_info = [
(
Expand All @@ -1535,31 +1537,31 @@ def __init__(
("Date & Time", date_and_time),
("Sender", msg["sender_full_name"]),
("Sender's Email ID", msg["sender_email"]),
(
"View message in browser",
f"Press {view_in_browser_keys} to view message in browser",
),
(
"Full rendered message",
f"Press {full_rendered_message_keys} to view",
),
(
"Full raw message",
f"Press {full_raw_message_keys} to view",
),
],
),
)
]

# actions for message info popup
viewing_actions = (
"Viewing Actions",
[
("Open in web browser", view_in_browser_keys),
("Full rendered message", full_rendered_message_keys),
("Full raw message", full_raw_message_keys),
],
)
msg_info.append(viewing_actions)
# Only show the 'Edit History' label for edited messages.

self.show_edit_history_label = (
self.msg["id"] in controller.model.index["edited_messages"]
and controller.model.initial_data["realm_allow_edit_history"]
)
if self.show_edit_history_label:
msg_info[0][1][0] = ("Date & Time (Original)", date_and_time)

keys = ", ".join(map(repr, keys_for_command("EDIT_HISTORY")))
msg_info[0][1].append(("Edit History", f"Press {keys} to view"))
keys = "[{}]".format(", ".join(map(str, keys_for_command("EDIT_HISTORY"))))
msg_info[1][1].append(("Edit History", keys))
# Render the category using the existing table methods if links exist.
if message_links:
msg_info.append(("Message Links", []))
Expand Down Expand Up @@ -1594,7 +1596,9 @@ def __init__(

# slice_index = Number of labels before message links + 1 newline
# + 1 'Message Links' category label.
slice_index = len(msg_info[0][1]) + 2
# + 2 for Viewing Actions category label and its newline
slice_index = len(msg_info[0][1]) + len(msg_info[1][1]) + 2 + 2

slice_index += sum([len(w) + 2 for w in self.button_widgets])
self.button_widgets.append(message_links)

Expand All @@ -1610,7 +1614,8 @@ def __init__(

# slice_index = Number of labels before topic links + 1 newline
# + 1 'Topic Links' category label.
slice_index = len(msg_info[0][1]) + 2
# + 2 for Viewing Actions category label and its newline
slice_index = len(msg_info[0][1]) + len(msg_info[1][1]) + 2 + 2
slice_index += sum([len(w) + 2 for w in self.button_widgets])
self.button_widgets.append(topic_links)

Expand Down

0 comments on commit 181fe94

Please sign in to comment.