Skip to content

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

Closed

Conversation

Ezio-Sarthak
Copy link
Member

This PR is a follow-up PR from #852.
Visual improvements:

  • Stream and topic prefixes minimized.
  • Invalid stream handling.
  • Stream prefix color rendering.

Partially fixes #783.

@zulipbot zulipbot added the size: XL [Automatic label added by zulipbot] label Jan 3, 2021
@Ezio-Sarthak Ezio-Sarthak force-pushed the re-enhance-compose-msg-area branch 2 times, most recently from e0c8921 to 895f79b Compare January 6, 2021 15:57
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.

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

Comment on lines 340 to 352
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.")
Copy link
Collaborator

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?

@neiljp neiljp added the PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback label Jan 6, 2021
@Ezio-Sarthak Ezio-Sarthak force-pushed the re-enhance-compose-msg-area branch 4 times, most recently from 2d7d535 to 437d7aa Compare January 7, 2021 11:26
@Ezio-Sarthak
Copy link
Member Author

Ezio-Sarthak commented Jan 7, 2021

Thanks for suggesting the changes! They were really required to clean the messy code earlier 😅 .

  • I squashed the first commit because, as you said, the symbols need to be added whenever they are used in the code. So, making an explicit commit for that wasn't useful.
  • Re invalid stream marker I've improved the rendering of stream name (now by urwid.connect_signal()) which clears that issue :)
  • This PR might also improve the test coverage of WriteBox, as raised in Improve test coverage for WriteBox #739 :)

@Ezio-Sarthak Ezio-Sarthak requested a review from neiljp January 7, 2021 12:15
@Ezio-Sarthak Ezio-Sarthak force-pushed the re-enhance-compose-msg-area branch from 437d7aa to e51d62c Compare January 7, 2021 13:35
@neiljp
Copy link
Collaborator

neiljp commented Jan 7, 2021

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.

@Ezio-Sarthak Ezio-Sarthak force-pushed the re-enhance-compose-msg-area branch 4 times, most recently from cf0e4ed to 08f77e6 Compare January 7, 2021 16:36
@neiljp neiljp 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 Jan 8, 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.

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

Comment on lines 332 to 338
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
Copy link
Collaborator

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.

@@ -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())
Copy link
Collaborator

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?

Copy link
Member Author

@Ezio-Sarthak Ezio-Sarthak Jan 12, 2021

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

@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 11, 2021
@Ezio-Sarthak Ezio-Sarthak force-pushed the re-enhance-compose-msg-area branch from 08f77e6 to 79d0518 Compare January 12, 2021 10:53
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.
@Ezio-Sarthak Ezio-Sarthak force-pushed the re-enhance-compose-msg-area branch from 79d0518 to d0982ae Compare January 12, 2021 10:54
@Ezio-Sarthak
Copy link
Member Author

Thanks for the suggestions! Updated the PR :)

@neiljp
Copy link
Collaborator

neiljp commented Jan 12, 2021

@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 git range-diff.

@neiljp neiljp closed this Jan 12, 2021
@neiljp neiljp added this to the Next Release milestone Jan 12, 2021
@Ezio-Sarthak Ezio-Sarthak deleted the re-enhance-compose-msg-area branch March 26, 2021 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback size: XL [Automatic label added by zulipbot]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve styling of compose-message recipients-area
3 participants