Skip to content

Commit 6dab928

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 5a026b4 commit 6dab928

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

tests/ui_tools/test_buttons.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,15 @@ def test_activate_called_once_on_keypress(
328328

329329
assert activate.call_count == 1
330330

331+
@pytest.mark.parametrize("key", keys_for_command("USER_INFO"))
332+
def test_keypress_USER_INFO(self, mocker, user_button, key, widget_size):
333+
size = widget_size(user_button)
334+
pop_up = mocker.patch("zulipterminal.core.Controller.show_user_info")
335+
336+
user_button.keypress(size, key)
337+
338+
pop_up.assert_called_once_with(user_button.user_id)
339+
331340

332341
class TestTopicButton:
333342
@pytest.mark.parametrize(

zulipterminal/ui_tools/buttons.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ def __init__(
255255
self.email = user["email"]
256256
self.user_id = user["user_id"]
257257

258+
self.controller = controller
258259
self._view = view # Used in _narrow_with_compose
259260

260261
# FIXME Is this still needed?
@@ -283,6 +284,11 @@ def _narrow_with_compose(self) -> None:
283284
emails=[self.email], recipient_user_ids=[self.user_id]
284285
)
285286

287+
def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
288+
if is_command_key("USER_INFO", key):
289+
self.controller.show_user_info(self.user_id)
290+
return super().keypress(size, key)
291+
286292

287293
class TopicButton(TopButton):
288294
def __init__(

0 commit comments

Comments
 (0)