Skip to content

Commit 670c70d

Browse files
committed
views: Markup stream description using MessageBox.transform_content().
Footlinks support is added in a subsequent commit. Test amended. Fixes zulip#743.
1 parent 1e992db commit 670c70d

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

tests/ui/test_ui_tools.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -1454,9 +1454,15 @@ def mock_external_classes(self, mocker, monkeypatch):
14541454
self.controller.model.is_muted_stream.return_value = False
14551455
self.controller.model.is_pinned_stream.return_value = False
14561456
mocker.patch(VIEWS + ".urwid.SimpleFocusListWalker", return_value=[])
1457+
mocker.patch(VIEWS + '.MessageBox.transform_content',
1458+
return_value=('Hey', OrderedDict(), list()))
14571459
stream_id = 10
1458-
self.controller.model.stream_dict = {stream_id: {'name': 'books',
1459-
'description': 'hey'}}
1460+
self.controller.model.stream_dict = {
1461+
stream_id: {
1462+
'name': 'books',
1463+
'rendered_description': '<p>Hey</p>',
1464+
}
1465+
}
14601466
self.stream_info_view = StreamInfoView(self.controller, stream_id)
14611467

14621468
@pytest.mark.parametrize('key', {*keys_for_command('GO_BACK'),

zulipterminal/ui_tools/views.py

+18-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from zulipterminal.helper import (
1515
Message, asynch, edit_mode_captions, match_stream, match_user,
1616
)
17-
from zulipterminal.ui_tools.boxes import PanelSearchBox
17+
from zulipterminal.ui_tools.boxes import MessageBox, PanelSearchBox
1818
from zulipterminal.ui_tools.buttons import (
1919
HomeButton, MentionedButton, MessageLinkButton, PMButton, StarredButton,
2020
StreamButton, TopicButton, UnreadPMButton, UserButton,
@@ -1047,8 +1047,11 @@ def __init__(self, controller: Any, stream_id: int) -> None:
10471047
self.controller = controller
10481048
stream = controller.model.stream_dict[stream_id]
10491049
title = '# {}'.format(stream['name'])
1050-
desc = stream['description']
1051-
stream_info_content = [('', [desc]), ('Stream settings', [])]
1050+
rendered_desc = stream['rendered_description']
1051+
1052+
stream_info_content = (
1053+
[('Stream settings', [])]
1054+
) # type: PopUpViewTableContent
10521055
popup_width, column_widths = self.calculate_table_widths(
10531056
stream_info_content, len(title))
10541057

@@ -1064,12 +1067,23 @@ def __init__(self, controller: Any, stream_id: int) -> None:
10641067
urwid.connect_signal(pinned_setting, 'change',
10651068
self.toggle_pinned_status)
10661069

1070+
markup_desc, *_ = MessageBox.transform_content(
1071+
rendered_desc,
1072+
self.controller.model.server_url,
1073+
)
1074+
desc = urwid.Text(markup_desc)
1075+
10671076
# Manual because calculate_table_widths does not support checkboxes.
10681077
# Add 4 to checkbox label to accomodate the checkbox itself.
10691078
popup_width = max(popup_width, len(muted_setting.label) + 4,
1070-
len(pinned_setting.label) + 4)
1079+
len(pinned_setting.label) + 4, desc.pack()[0])
10711080
self.widgets = self.make_table_with_categories(stream_info_content,
10721081
column_widths)
1082+
1083+
# Stream description.
1084+
self.widgets.insert(0, desc)
1085+
self.widgets.insert(1, urwid.Text('')) # Add a newline.
1086+
10731087
self.widgets.append(muted_setting)
10741088
self.widgets.append(pinned_setting)
10751089
super().__init__(controller, self.widgets, 'STREAM_DESC', popup_width,

0 commit comments

Comments
 (0)