Skip to content
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

Merged
merged 2 commits into from
Aug 14, 2021
Merged

Feature: Improve Stream Info Popup #880

merged 2 commits into from
Aug 14, 2021

Conversation

zee-bit
Copy link
Member

@zee-bit zee-bit commented Jan 19, 2021

  • 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]

@zulipbot zulipbot added the size: S [Automatic label added by zulipbot] label Jan 19, 2021
@neiljp
Copy link
Collaborator

neiljp commented Jan 19, 2021

@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 StreamData rather than the underlying data from the server.

@zulipbot zulipbot added size: XL [Automatic label added by zulipbot] and removed size: S [Automatic label added by zulipbot] labels Jan 20, 2021
@zee-bit zee-bit force-pushed the StreamInfo branch 5 times, most recently from 53ba780 to 0331f3d Compare January 22, 2021 20:37
@zee-bit zee-bit changed the title [WIP] Feature: Add extra fields in Stream Info popup Feature: Improve Stream Info Popup Jan 23, 2021
@zee-bit
Copy link
Member Author

zee-bit commented Jan 23, 2021

@zulipbot add "PR needs review"

@zulipbot zulipbot added the PR needs review PR requires feedback to proceed label Jan 23, 2021
Copy link
Collaborator

@neiljp neiljp left a 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.

@@ -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', [
Copy link
Collaborator

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?

Copy link
Member Author

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?

Copy link
Member Author

@zee-bit zee-bit Mar 27, 2021

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. :)

Comment on lines 1101 to 1126
weekly_msg_count = ('N/A' if stream['stream_weekly_traffic'] is None
else str(stream['stream_weekly_traffic']))
Copy link
Collaborator

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.

Copy link
Member Author

@zee-bit zee-bit Jan 27, 2021

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 neiljp added PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback and removed PR needs review PR requires feedback to proceed labels Jan 26, 2021
@neiljp neiljp added this to the Release after next milestone Jan 28, 2021
Base automatically changed from master to main January 30, 2021 20:31
@zee-bit
Copy link
Member Author

zee-bit commented Feb 21, 2021

@neiljp PR has been updated.
Using Overlay for pyperclip error was looking ugly(and, not in place with our current UI), so I have decided to use the already implemented NoticeView, prompting those specific users to install the required utility package for pyperclip. Other previous reviews have been addressed as well(except maybe class parameterization, since I wasn't sure if you wanted me to remove those?).

@zee-bit
Copy link
Member Author

zee-bit commented Feb 21, 2021

@zulipbot add "PR needs review"
@zulipbot remove "PR needs update"

@zulipbot zulipbot added PR needs review PR requires feedback to proceed and removed PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback labels Feb 21, 2021
@zee-bit zee-bit force-pushed the StreamInfo branch 2 times, most recently from 560bf38 to 08c60a8 Compare February 26, 2021 21:27
@zee-bit
Copy link
Member Author

zee-bit commented Feb 26, 2021

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 stream_info's popup height.

Copy link
Collaborator

@neiljp neiljp left a 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.

clipboard_text = pyperclip.paste()
assert clipboard_text == stream_email
self.view.set_footer_text("Stream E-mail copied successfully!", 3)
except Exception:
Copy link
Collaborator

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.

{"date_created": 1472047124},
{
"date_created": 1472047124,
"message_retention_days": "72 [Organization default]",
Copy link
Collaborator

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.

Comment on lines 1165 to 1174
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",
Copy link
Collaborator

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?

@neiljp neiljp added area: UI General user interface update missing feature: user A missing feature for all users, present in another Zulip client PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback and removed PR needs review PR requires feedback to proceed labels Aug 3, 2021
@zee-bit zee-bit added PR needs review PR requires feedback to proceed and removed PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback labels Aug 7, 2021
Copy link
Member

@preetmishra preetmishra left a 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.

@neiljp
Copy link
Collaborator

neiljp commented Aug 12, 2021

@zee-bit For the record, I just merged the first 7 commits as 0e3d91e and those prior 🎉

This should allow focus on the last commit by itself 👍

Copy link
Collaborator

@neiljp neiljp left a 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.

Comment on lines +231 to +236
case(
{1: {}},
None,
10,
{1: "Indefinite [Organization default]"},
id="ZFL=None_no_stream_retention_realm_retention=None",
Copy link
Collaborator

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?

Copy link
Member Author

@zee-bit zee-bit Aug 13, 2021

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)

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

@neiljp neiljp added PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback and removed PR needs review PR requires feedback to proceed labels Aug 12, 2021
@zee-bit zee-bit added PR needs review PR requires feedback to proceed and removed PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback labels Aug 13, 2021
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.
@neiljp
Copy link
Collaborator

neiljp commented Aug 14, 2021

@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?

@neiljp neiljp merged commit 17d32a1 into zulip:main Aug 14, 2021
@neiljp neiljp removed the PR needs review PR requires feedback to proceed label Aug 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: UI General user interface update missing feature: user A missing feature for all users, present in another Zulip client size: XL [Automatic label added by zulipbot]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants