Skip to content

Commit

Permalink
buttons: Add USER_INFO keypress events to trigger user info popup.
Browse files Browse the repository at this point in the history
This commit wraps up the user-info feature by defining keypress
events to toggle user info view.

Tests added.
Fixes #511.
  • Loading branch information
Ezio-Sarthak authored and neiljp committed Jul 10, 2021
1 parent bcc2ee2 commit 92dbb8c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/ui_tools/test_buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,15 @@ def test_activate_called_once_on_keypress(

assert activate.call_count == 1

@pytest.mark.parametrize("key", keys_for_command("USER_INFO"))
def test_keypress_USER_INFO(self, mocker, user_button, key, widget_size):
size = widget_size(user_button)
pop_up = mocker.patch("zulipterminal.core.Controller.show_user_info")

user_button.keypress(size, key)

pop_up.assert_called_once_with(user_button.user_id)


class TestTopicButton:
@pytest.mark.parametrize(
Expand Down
6 changes: 6 additions & 0 deletions zulipterminal/ui_tools/buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ def __init__(
self.email = user["email"]
self.user_id = user["user_id"]

self.controller = controller
self._view = view # Used in _narrow_with_compose

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

def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
if is_command_key("USER_INFO", key):
self.controller.show_user_info(self.user_id)
return super().keypress(size, key)


class TopicButton(TopButton):
def __init__(
Expand Down

0 comments on commit 92dbb8c

Please sign in to comment.