Skip to content

Commit 46dd6af

Browse files
committed
buttons/views: Add keypress events to trigger full message popup view.
This commit adds event to trigger full message view on pressing binded key 'f' in message info view. Visual change: * Hotkey help for full msg view appended in message info popup. Tests amended. Tests added (for added keypress events).
1 parent 2e54331 commit 46dd6af

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

tests/ui_tools/test_popups.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,21 @@ def test_keypress_edit_history(self, message_fixture, key, widget_size,
586586
else:
587587
self.controller.show_edit_history.assert_not_called()
588588

589+
@pytest.mark.parametrize('key', keys_for_command('FULL_MSG_VIEW'))
590+
def test_keypress_full_msg(self, message_fixture, key, widget_size):
591+
msg_info_view = MsgInfoView(self.controller, message_fixture,
592+
title='Message Information',
593+
message_links=OrderedDict(),
594+
time_mentions=list())
595+
size = widget_size(msg_info_view)
596+
msg_info_view.keypress(size, key)
597+
598+
self.controller.show_full_msg.assert_called_once_with(
599+
message=message_fixture,
600+
message_links=OrderedDict(),
601+
time_mentions=list(),
602+
)
603+
589604
@pytest.mark.parametrize('key', {*keys_for_command('GO_BACK'),
590605
*keys_for_command('MSG_INFO')})
591606
def test_keypress_exit_popup(self, key, widget_size):
@@ -594,7 +609,7 @@ def test_keypress_exit_popup(self, key, widget_size):
594609
assert self.controller.exit_popup.called
595610

596611
def test_height_noreactions(self):
597-
expected_height = 3
612+
expected_height = 4 # +1 due to full msg view key
598613
assert self.msg_info_view.height == expected_height
599614

600615
# FIXME This is the same parametrize as MessageBox:test_reactions_view
@@ -642,8 +657,9 @@ def test_height_reactions(self, message_fixture, to_vary_in_each_message):
642657
self.msg_info_view = MsgInfoView(self.controller, varied_message,
643658
'Message Information', OrderedDict(),
644659
list())
645-
# 9 = 3 labels + 1 blank line + 1 'Reactions' (category) + 4 reactions.
646-
expected_height = 9
660+
# 10 = 4 labels + 1 blank line + 1 'Reactions' (category)
661+
# + 4 reactions.
662+
expected_height = 10
647663
assert self.msg_info_view.height == expected_height
648664

649665
def test_keypress_navigation(self, mocker, widget_size,

zulipterminal/ui_tools/views.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1219,10 +1219,13 @@ def __init__(self, controller: Any, msg: Message, title: str,
12191219
msg['timestamp'], show_seconds=True, show_year=True
12201220
)
12211221

1222+
full_msg_keys = ', '.join(map(repr, keys_for_command('FULL_MSG_VIEW')))
12221223
msg_info = [
12231224
('', [('Date & Time', date_and_time),
12241225
('Sender', msg['sender_full_name']),
1225-
('Sender\'s Email ID', msg['sender_email'])]),
1226+
('Sender\'s Email ID', msg['sender_email']),
1227+
('Full message view', 'Press {} to view'
1228+
.format(full_msg_keys))]),
12261229
]
12271230
# Only show the 'Edit History' label for edited messages.
12281231
self.show_edit_history_label = (
@@ -1293,6 +1296,13 @@ def keypress(self, size: urwid_Size, key: str) -> str:
12931296
message_links=self.message_links,
12941297
time_mentions=self.time_mentions,
12951298
)
1299+
elif (is_command_key('FULL_MSG_VIEW', key)):
1300+
self.controller.show_full_msg(
1301+
message=self.msg,
1302+
message_links=self.message_links,
1303+
time_mentions=self.time_mentions,
1304+
)
1305+
return key
12961306
return super().keypress(size, key)
12971307

12981308

0 commit comments

Comments
 (0)