Skip to content

Commit 9732b17

Browse files
committed
boxes/core/views: Add message links in MsgInfoView.
Tests amended.
1 parent 723421c commit 9732b17

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

tests/ui/test_ui_tools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,7 @@ def mock_external_classes(self, mocker, monkeypatch, message_fixture):
13661366
return_value=(64, 64))
13671367
mocker.patch(VIEWS + ".urwid.SimpleFocusListWalker", return_value=[])
13681368
self.msg_info_view = MsgInfoView(self.controller, message_fixture,
1369-
'Message Information')
1369+
'Message Information', OrderedDict())
13701370

13711371
def test_keypress_any_key(self):
13721372
key = "a"
@@ -1428,7 +1428,7 @@ def test_height_noreactions(self):
14281428
def test_height_reactions(self, message_fixture, to_vary_in_each_message):
14291429
varied_message = dict(message_fixture, **to_vary_in_each_message)
14301430
self.msg_info_view = MsgInfoView(self.controller, varied_message,
1431-
'Message Information')
1431+
'Message Information', OrderedDict())
14321432
# 9 = 3 labels + 1 blank line + 1 'Reactions' (category) + 4 reactions.
14331433
expected_height = 9
14341434
assert self.msg_info_view.height == expected_height

zulipterminal/core.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import signal
33
import sys
44
import time
5+
from collections import OrderedDict
56
from functools import partial
67
from platform import platform
78
from typing import Any, List, Optional, Tuple
@@ -134,9 +135,12 @@ def show_help(self) -> None:
134135
help_view = HelpView(self, "Help Menu (up/down scrolls)")
135136
self.show_pop_up(help_view)
136137

137-
def show_msg_info(self, msg: Message) -> None:
138+
def show_msg_info(self, msg: Message,
139+
message_links: 'OrderedDict[str, Tuple[str, int]]',
140+
) -> None:
138141
msg_info_view = MsgInfoView(self, msg,
139-
"Message Information (up/down scrolls)")
142+
"Message Information (up/down scrolls)",
143+
message_links)
140144
self.show_pop_up(msg_info_view)
141145

142146
def show_stream_info(self, color: str, name: str, desc: str) -> None:

zulipterminal/ui_tools/boxes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,8 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
885885
write_box.msg_write_box.set_edit_pos(len(msg))
886886
self.model.controller.view.middle_column.set_focus('footer')
887887
elif is_command_key('MSG_INFO', key):
888-
self.model.controller.show_msg_info(self.message)
888+
self.model.controller.show_msg_info(self.message,
889+
self.message_links)
889890
return key
890891

891892

zulipterminal/ui_tools/views.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import threading
22
import time
3+
from collections import OrderedDict
34
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
45

56
import urwid
@@ -973,14 +974,20 @@ def __init__(self, controller: Any, color: str,
973974

974975

975976
class MsgInfoView(PopUpView):
976-
def __init__(self, controller: Any, msg: Message, title: str) -> None:
977+
def __init__(self, controller: Any, msg: Message, title: str,
978+
message_links: 'OrderedDict[str, Tuple[str, int]]') -> None:
977979
self.msg = msg
978980

979981
msg_info = [
980982
('', [('Date & Time', time.ctime(msg['timestamp'])[:-5]),
981983
('Sender', msg['sender_full_name']),
982984
('Sender\'s Email ID', msg['sender_email'])]),
983985
]
986+
if message_links:
987+
msg_info.append(('Message Links', [
988+
urwid.Text(['{}: {}'.format(index, text), '\n', link])
989+
for link, (text, index) in message_links.items()
990+
]))
984991
if msg['reactions']:
985992
reactions = sorted(
986993
(reaction['emoji_name'], reaction['user']['full_name'])

0 commit comments

Comments
 (0)