-
-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Improve Stream Info Popup #880
Conversation
zee-bit
commented
Jan 19, 2021
•
edited
Loading
edited
- Add Stream Members hotkey in README. [merged commit 8ce2edb]
- Add Stream creation date in Stream Info popup [New in Server v4.0, ZFL 30]
- Add Stream email
- bugfix: Fix case when Weekly message count is None
- Add Message retention days [New in server v3.0, ZFL 17]
- Notification settings [issue Add notification checkboxes in Stream Info view. #887]
@zee-bit We should have included the README in the previous iteration, so it's good to see it here 👍 For the stream creation date, it's good to see the check vs server feature level here, but note the type of this property, and we'll want to test against a range of values. Also note that we may want to adjust the model data of the subscriptions to be uniform across different levels (abbreviated to ZFL in places), and then have the UI just use the data that's guaranteed to be present - ie. place the conditional(s) in the model. Ultimately this could be part of a move to store/expose only |
53ba780
to
0331f3d
Compare
@zulipbot add "PR needs review" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zee-bit This generally looks good 👍 Comments inline.
tests/ui_tools/test_popups.py
Outdated
@@ -550,24 +550,62 @@ def test_keypress_navigation(self, mocker, widget_size, | |||
super_keypress.assert_called_once_with(size, expected_key) | |||
|
|||
|
|||
@pytest.mark.parametrize('stream, stream_id, server_feature_level', [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This parametrizes all tests in this class, right? Is that the intent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I thought it will increase our scope of testing, and potentially detect/eliminate any bug that may get unnoticed, if we tried to localize the parameters inside the class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed the class parameterization earlier and moved the fixtures to another test function(test_popup_height
), since the popup height will change depending on the server version running - which corresponds to the numbers of fields supported in that version. :)
zulipterminal/ui_tools/views.py
Outdated
weekly_msg_count = ('N/A' if stream['stream_weekly_traffic'] is None | ||
else str(stream['stream_weekly_traffic'])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're referring to a commit, not a PR, in this commit text.
If None
is always due to it being just-created, it would be useful to indicate that, and expand N/A to something clearer in any case.
I'd be happy merging this commit sooner, but the tests in the first commit are dependencies of all the others.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll edit the commit title accordingly. Thanks for pointing it out. :)
I can add a comment explaining this behavior, and replace 'N/A' with something like, New stream. Data unavailable
? for reference, webapp displays Stream created recently
.
Adding this commit in the same PR has led to this. I asked in #zulip-terminal about adding this fix in this PR or another PR, and we decided to go with the former. If you want, I can add this to the PR I mentioned few comments above. This should segregate this fix from the class parameters I declared in the prior commit?
@neiljp PR has been updated. |
560bf38
to
08c60a8
Compare
On second look, I dont think we use Class parameterization anywhere else in our codebase. So, I have removed it, and moved the parameters to another function that tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zee-bit This addresses a lot of my structural points, probably most left are the details 👍
The use of the fixture looks good to me, certainly for now. We may want to follow-up with private variations and similar later, but we can build on this.
zulipterminal/core.py
Outdated
clipboard_text = pyperclip.paste() | ||
assert clipboard_text == stream_email | ||
self.view.set_footer_text("Stream E-mail copied successfully!", 3) | ||
except Exception: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right; should this only be a pyperclip-specific exception, that we can use? The (online) docs for it don't include that, but the source possibly does - and you have that in the test? The package doesn't seem particularly active, otherwise I'd suggest proposing updating the documentation or opening an issue.
tests/ui_tools/test_popups.py
Outdated
{"date_created": 1472047124}, | ||
{ | ||
"date_created": 1472047124, | ||
"message_retention_days": "72 [Organization default]", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be clearer if this text wasn't overwritten, as per my other comment.
tests/ui_tools/test_popups.py
Outdated
id="ZFL=None__no_date_created_no_retention_days", | ||
), | ||
case( | ||
{"date_created": None}, | ||
{ | ||
"date_created": None, | ||
"message_retention_days": "Indefinite [Organization default]", | ||
}, | ||
29, | ||
11, | ||
id="ZFL<30__no_date_created", | ||
12, | ||
id="ZFL<30__no_date_created_default_indefinite_retention_days", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it meaningful here to include a 17-30 case, given that one feature is introduced at 30 and another by 17?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zee-bit Thanks for the updates! 👍 This continues to work well. I've left some in-line comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zee-bit This last commit is mainly minor points since we've discussed a lot, but the early Zulip version behavior still seems unclear. Other than the existing commit being quite large, having the text extraction in a separate commit will help with focusing anyone else on how we're handling it, without having display code in the way.
case( | ||
{1: {}}, | ||
None, | ||
10, | ||
{1: "Indefinite [Organization default]"}, | ||
id="ZFL=None_no_stream_retention_realm_retention=None", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this is the None
case that I queried elsewhere, where the organization value slips through to the stream level.
Was None
a realm value, though? I assume it followed the original rule, ie. -1 for indefinite and +n for days, so I'm not sure about None?
The #api-design topic doesn't seem to have clarified this exactly, so perhaps Mateusz could answer in a follow-up or you could refer him here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, this is why we were handling the days == None
case earlier.
To clarify, None
was a realm value earlier (between server v2-3, as per my testing on the dev server) and it had the same meaning as the current -1
for indefinite which was changed by @mateuszmandera's commit afterwards. So to summarize, I believe this is how the server's representation for message retention changed over time:
- Server version 2-3: realm value could have
None
for indefinite and +n for days. No stream value - Server version 3.0: added stream message retention days, with
None
for org default,-1
for indefinite and +n for days. - Server version 3+: realm's
None
value was changed to-1
by Mateusz's above commit for consistency with the stream value
(I hope Mateusz should get notification from the above mention, still, I'll refer him here from the stream to confirm my hypothesis)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that was an interesting dive through old commits 😀 This overview sounds correct to me based on that. To be a bit more precise, message_retention_days
was a thing for streams before 3.0 but only in the sense of the backend logic - but it indeed wasn't exposed via the API in any way (the value had to be set manually via manage.py shell
or db query). I presume that zulip-terminal
only cares about the API history here though, where indeed this is only a thing since 3.0 - zulip/zulip@c488a35
This commit normalizes the stream message_retention_days field and caches a message retention text that can be later used to update the UI. This response was added in Server v3, feature level 17. For older versions, the "realm_message_retention_days" field from /register is stored. The current logic dictates: * If this field is absent in subscription (i.e. ZFL<17) then add this field explicitly with value None, and then cache a retention text with the organization default i.e. realm_message_retention_days response. * If the field is absent and realm_message_retention_days is None (for server v<3.0) or -1 (server v3+), then the messages would be stored indefinitely. * If the field is already present with value None, then the default organization-level setting for this field is inherited. * If the field is already present with value -1, then the messages in this stream is stored indefinitely. Reference: https://zulip.com/api/get-subscriptions#response Tests amended.
This commit adds Message retention day field in StreamInfo popup. It uses the model.cached_retention_text to retrieve and display the message retention response in a user-friendly format. Tests amended.
@zee-bit Thanks for getting this final commit work done 👍 This now passes CI after the pytz fixup. I'm going to merge this now 🎉 (we can follow-up with other features in separate PRs - could you file issues for what we discussed?) @mateuszmandera Thanks for confirmation of the findings - do we want to improve the API docs for this? |