|
7 | 7 | import urwid
|
8 | 8 | from typing_extensions import Literal
|
9 | 9 |
|
10 |
| -from zulipterminal.api_types import EditPropagateMode |
| 10 | +from zulipterminal.api_types import RESOLVED_TOPIC_PREFIX, EditPropagateMode |
11 | 11 | from zulipterminal.config.keys import (
|
12 | 12 | HELP_CATEGORIES,
|
13 | 13 | KEY_BINDINGS,
|
|
20 | 20 | CHECK_MARK,
|
21 | 21 | COLUMN_TITLE_BAR_LINE,
|
22 | 22 | PINNED_STREAMS_DIVIDER,
|
| 23 | + STREAM_TOPIC_SEPARATOR, |
23 | 24 | )
|
24 | 25 | from zulipterminal.config.ui_mappings import (
|
25 | 26 | BOT_TYPE_BY_ID,
|
@@ -1492,6 +1493,50 @@ def keypress(self, size: urwid_Size, key: str) -> str:
|
1492 | 1493 | return super().keypress(size, key)
|
1493 | 1494 |
|
1494 | 1495 |
|
| 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 | + |
1495 | 1540 | class StreamMembersView(PopUpView):
|
1496 | 1541 | def __init__(self, controller: Any, stream_id: int) -> None:
|
1497 | 1542 | self.stream_id = stream_id
|
|
0 commit comments