Skip to content

Commit bbedcbd

Browse files
committed
views: Add TopicInfoView to show pop up menu to change topic settings.
1 parent d9534da commit bbedcbd

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

zulipterminal/ui_tools/views.py

+46-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import urwid
88
from typing_extensions import Literal
99

10-
from zulipterminal.api_types import EditPropagateMode
10+
from zulipterminal.api_types import RESOLVED_TOPIC_PREFIX, EditPropagateMode
1111
from zulipterminal.config.keys import (
1212
HELP_CATEGORIES,
1313
KEY_BINDINGS,
@@ -20,6 +20,7 @@
2020
CHECK_MARK,
2121
COLUMN_TITLE_BAR_LINE,
2222
PINNED_STREAMS_DIVIDER,
23+
STREAM_TOPIC_SEPARATOR,
2324
)
2425
from zulipterminal.config.ui_mappings import (
2526
BOT_TYPE_BY_ID,
@@ -1492,6 +1493,50 @@ def keypress(self, size: urwid_Size, key: str) -> str:
14921493
return super().keypress(size, key)
14931494

14941495

1496+
class TopicInfoView(PopUpView):
1497+
def __init__(self, controller: Any, stream_id: int, topic: str) -> None:
1498+
self.stream_id = stream_id
1499+
self.controller = controller
1500+
stream = controller.model.stream_dict[stream_id]
1501+
self.topic_name = topic
1502+
stream_name = stream["name"]
1503+
1504+
title = f"{stream_name} {STREAM_TOPIC_SEPARATOR} {self.topic_name}"
1505+
1506+
topic_info_content = [
1507+
("Topic settings", []),
1508+
] # type: PopUpViewTableContent
1509+
1510+
popup_width, column_widths = self.calculate_table_widths(
1511+
topic_info_content, len(title)
1512+
)
1513+
1514+
resolve_topic_setting = urwid.CheckBox(
1515+
label="Topic Resolved",
1516+
state=self.topic_name.startswith(RESOLVED_TOPIC_PREFIX),
1517+
checked_symbol=CHECK_MARK,
1518+
)
1519+
urwid.connect_signal(
1520+
resolve_topic_setting, "change", self.toggle_resolve_status
1521+
)
1522+
popup_width = max(
1523+
popup_width,
1524+
len(resolve_topic_setting.label) + 4,
1525+
)
1526+
1527+
self.widgets = self.make_table_with_categories(
1528+
topic_info_content, column_widths
1529+
)
1530+
1531+
self.widgets.append(resolve_topic_setting)
1532+
super().__init__(controller, self.widgets, "TOPIC_DESC", popup_width, title)
1533+
1534+
def toggle_resolve_status(self, button: Any, new_state: bool) -> None:
1535+
self.controller.model.toggle_topic_resolved_status(
1536+
stream_id = self.stream_id, topic_name = self.topic_name
1537+
)
1538+
1539+
14951540
class StreamMembersView(PopUpView):
14961541
def __init__(self, controller: Any, stream_id: int) -> None:
14971542
self.stream_id = stream_id

0 commit comments

Comments
 (0)