Skip to content

Commit e0ee338

Browse files
committed
buttons: Add keypress events to trigger user info popup.
This commit wraps up the feature PR by defining keypress events to toggle user info view. Tests added. Fixes #511.
1 parent b105efd commit e0ee338

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

tests/ui_tools/test_buttons.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,17 @@ def test_activate_called_once_on_keypress(
253253

254254
assert activate.call_count == 1
255255

256+
@pytest.mark.parametrize('key', keys_for_command('USER_INFO'))
257+
def test_keypress_USER_INFO(self, mocker, user_button, key,
258+
widget_size):
259+
size = widget_size(user_button)
260+
pop_up = mocker.patch(
261+
'zulipterminal.core.Controller.show_user_info')
262+
263+
user_button.keypress(size, key)
264+
265+
pop_up.assert_called_once_with(user_button.user_id)
266+
256267

257268
class TestTopicButton:
258269
@pytest.mark.parametrize('width, count, stream_id, title, stream_name', [

zulipterminal/ui_tools/buttons.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ def __init__(self, user: Dict[str, Any], controller: Any,
239239
self.email = user['email']
240240
self.user_id = user['user_id']
241241

242+
self.controller = controller
242243
self._view = view # Used in _narrow_with_compose
243244

244245
# FIXME Is this still needed?
@@ -268,6 +269,11 @@ def _narrow_with_compose(self) -> None:
268269
recipient_user_ids=[self.user_id]
269270
)
270271

272+
def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
273+
if is_command_key('USER_INFO', key):
274+
self.controller.show_user_info(self.user_id)
275+
return super().keypress(size, key)
276+
271277

272278
class TopicButton(TopButton):
273279
def __init__(self, stream_id: int, topic: str,

0 commit comments

Comments
 (0)