-
-
Notifications
You must be signed in to change notification settings - Fork 278
Compose box colored and further styled #865
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
Compose box colored and further styled #865
Conversation
e0c8921
to
895f79b
Compare
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.
@Ezio-Sarthak This looks to work fairly well, and certainly with small adjustment we could grab the first few commits fairly cleanly. I left some commits in-line.
I think we may want to refine the stream-validation aspect:
- this triggers fine via an invalid stream on tab (CYCLE_COMPOSE_FOCUS)
- if autocompleting to a valid value, then returning to the original text always appears to show as invalid? This is noticeable not just if we have eg. a -> announce -> a, but also with mobile -> mobile -> mobile-team -> mobile.
- the previous case is also a little strange with eg. clearing the box, where the stream character remains as before, but then changes if cycling as above
We can discuss the above points in-stream.
tests/ui_tools/test_boxes.py
Outdated
def is_valid_stream(stream_name: str) -> bool: | ||
for stream in stream_dict.values(): | ||
if stream['name'] == stream_name: | ||
return True | ||
return False | ||
|
||
def stream_id_from_name(stream_name: str) -> int: | ||
for stream_id, stream in stream_dict.items(): | ||
if stream['name'] == stream_name: | ||
return stream_id | ||
raise RuntimeError("Invalid stream name.") |
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 duplication of the model code seems overly complex. Can we just mock the behavior we expect for these cases, or parametrize the tests appropriately?
2d7d535
to
437d7aa
Compare
Thanks for suggesting the changes! They were really required to clean the messy code earlier 😅 .
|
437d7aa
to
e51d62c
Compare
Re the previous first commit, we already use P/# in one place for the stream list, so that's what I meant you could extract; let me know in the stream if this isn't clear. |
cf0e4ed
to
08f77e6
Compare
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.
@Ezio-Sarthak This include the refactoring I expected, and the live validation of the stream works really well 👍
Most changes below are fairly small, though if we could use a method rather than directly accessing the stream_dict that would likely improve the tests, which might be easier once we have the general refactoring I've mentioned elsewhere too.
tests/ui_tools/test_boxes.py
Outdated
write_box.model.stream_dict = stream_dict | ||
write_box.stream_id = stream_id | ||
write_box.model.is_valid_stream.return_value = is_valid_stream | ||
write_box.model.stream_id_from_name.return_value = stream_id |
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.
Needing to set the first and last of these comes from how we're directly accessing the model. Improving the stream encapsulation seems upcoming with @Abhirup-99 's work on the subscription events and other interest in that direction.
tests/ui_tools/test_boxes.py
Outdated
@@ -337,6 +341,7 @@ def test__set_stream_write_box_style_markers(self, write_box, stream_id, | |||
write_box._set_stream_write_box_style(write_box, stream_name) | |||
|
|||
assert write_box.header_write_box[0].text == expected_marker | |||
assert expected_color in str(write_box.header_write_box[0].get_text()) |
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 there a reason to use in
rather than direct equality?
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.
Yep. Actually the .get_text()
attribute gives a tuple object ('#', [('color', 1)])
, so I thought it would be clean to stringify it and search for the expected color. We could also use the .attrib
to get display attributes in form [('color', 1)]
.
An alternative to this could be to directly use equality as follows:
assert expected_color == write_box.header_write_box[0].attrib[0][0]
which I tried earlier, but thought it would look messy. (but seems fine now :))
08f77e6
to
79d0518
Compare
With this commit, the stream prefixes in stream list and stream info are refactored.
* Stream and topic box prefixes replaced with equivalent symbols. * Symbols now packed in the header column elements. * Focus values of header and message box elements updated. * Focus values of stream and topic prefixes added. Tests added (header contents).
* The function added currently handles only stream prefix markups. * Invalid stream name results in a standard wrong marker. Tests updated (the ones linked with stream autocomplete). Tests added (for the new styling function).
Style improvements: * Stream prefixes' color rendered. * The topic prefix is not rendered to make equivalence with the webapp. Tests updated and added (marker/color rendering). Partially fixes zulip#783.
79d0518
to
d0982ae
Compare
Thanks for the suggestions! Updated the PR :) |
@Ezio-Sarthak I've merged this with a few adjustments as the commit ending at e2a62a2 🎉 The adjustments were mainly small reformatting or text adjustments - including commit text which you'd not fully adjusted after the split of commits, perhaps? I also moved the two extra constants we discussed between commits ie. to where they were first used. The biggest change I noticed latterly was a bugfix - the stream marker was not set on setup, only on changes, so I added that (with test changes) and added myself as a co-author to avoid needing to start over. As before, I'd recommend reading the final commits to understand the differences in style/text/code and using |
This PR is a follow-up PR from #852.
Visual improvements:
Partially fixes #783.