-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Replace Checkboxes List with Stream Pills in Invite Users Modal #26871 #28686
Conversation
web/src/stream_pill.ts
Outdated
export function append_stream( | ||
stream: StreamSubscription, | ||
pill_widget: StreamPillWidget, | ||
display_value: (stream: StreamSubscription) => string, | ||
): void { |
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 using a parameter, show_stream_sub_size
, a better approach than passing a function?
The show_stream_sub_size
parameter approach has been employed in a similar PR, #24580.
a192317
to
ade9654
Compare
I guess this is still blocked on migrating |
@sanchi-t the pill TypeScript work finally got integrated, so it should be possible to rebase and merge this one now! |
36a62d8
to
cd5d1df
Compare
239e6bf
to
28d6746
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.
Looks good visually, thanks @sanchi-t ! I've left a few comments, it also might be worth investing some time into making the commit structure of this PR a bit better
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.
Left some comments. Moreover, the last 3 commits should be squashed since the css and test changes of a feature should be in the same commit.
web/src/pill_typeahead.ts
Outdated
display_pill = stream_pill.display_pill; | ||
} else { | ||
display_pill = opts.display_pill; | ||
} |
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 might be better framed as follows:
let display_pill: (sub: StreamSubscription) => string = stream_pill.display_pill;
if (opts.display_pill) {
display_pill = opts.display_pill;
}
This makes it easier to read that stream_pill.display_pill
is the default display_pill function
and we use the opts.display_pill
if it exists
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.
Done.
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'm not entirely sure this version is easier to read; probably the ??
operator might be clearest?
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.
So also of note is that this function being patched here is a generic function not limited to just streams, and yet we have a function called display_pill
that is only relevant for those? That doesn't make sense.
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.
Do we need a default value at all?
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.
Do we need a default value at all?
No, we use display_pill
when we call stream_pill.append
. We can change the stream_pill.append
function such that it accepts an optional parameter for getting stream pill label and it would provide the default value.
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.
So also of note is that this function being patched here is a generic function not limited to just streams, and yet we have a function called display_pill that is only relevant for those? That doesn't make sense.
We can rename the function so it indicates its stream specific like stream_display_pill
?
I think we need this function in pill_typeahead.ts
because pill_typeahead
calls stream_pill.append
and we need to mention the display value of pill there. It wouldn't been have a problem if we displayed the same format value for stream pill everywhere, but for user invite modal we just want stream name as the display value and not extra information about subscriber count.
Also you suggested to have stream_match_prefix
as a parameter which is also specific to streams so i think a function specific to streams should also be alright.
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.
Posted some comments.
Also, the invite modal is not opened if the user does not have permission to susbcribe others, so that should be fixed.
web/src/pill_typeahead.ts
Outdated
user_source?: () => User[]; | ||
exclude_bots?: boolean; | ||
update_func?: () => void; | ||
help_on_empty_strings?: boolean; |
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.
Are these changes required now since set_up_streams
function is added?
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.
Yeah, I am not sure. I thought Tim wanted that stream_match_prefix
property for opts
in set_up_combined
.
Anyway I removed that commit.
Also, I guess the previous approach that you used for translating the text inside the pills [here](#28686 (comment) was fine since variable values are not translated. You can see we use similar methods when text contains user on stream name, one is where we translate the "Already subscribed to {channel}" string in |
431a244
to
ac515ad
Compare
What do you mean? If user does not have permission to subscribe other the invite modal should not be opened and that is the current behavior. I am not getting what you mean. |
So what do you suggest? Use the previous approach? I think the current approach is better as it is easier/simpler to use |
It should open and the current behavior is that it does not open. |
I am not sure. |
Updates since last review:
|
Use `$t` to ensure the function returns a translatable string.
assert.equal(typeof config.highlighter_html, "function"); | ||
assert.equal(typeof config.matcher, "function"); | ||
assert.equal(typeof config.sorter, "function"); | ||
assert.equal(typeof config.updater, "function"); |
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'm not really a fan of the testing strategy of doing so much mocking... It's a lot of test code for pretty minimal value.
I guess I can merge this version, but maybe we should discuss in #frontend what would be a better way to unit-test this.
@@ -67,33 +77,43 @@ export function get_user_ids(pill_widget: StreamPillWidget | CombinedPillContain | |||
|
|||
export function append_stream( | |||
stream: StreamSubscription, | |||
pill_widget: CombinedPillContainer, | |||
pill_widget: StreamPillWidget | CombinedPillContainer, | |||
show_subscriber_count = true, |
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.
It would be better to do the refactors to add options like this in their own commits, for future reference, since that helps a reviewer model how much risk there is of breaking other pill typeahead components.
Introduce an input field with typeahead functionality, initially populated with the default streams for the organization. Fixes zulip#26871.
So I did a fairly extensive review, and I think this is basically good to merge. I ended up squashing the last two commits together, since that seemed more readable to me; the new final commit essentially fixed a correctness issue in the previous one. I found one bug, which I'll open as a follow-up issue that should be a high priority -- I don't intend to deploy this to production until it's fixed:
|
Fixes #26871.
The Invite Users Modal previously featured a list of checkboxes for selecting streams when inviting users. This has been replaced with an input field featuring typeahead and stream pills for streamlined stream selection.
Screenshots and screen captures:
Before:
After:
Dark mode:
Light Mode:
Self-review checklist
(variable names, code reuse, readability, etc.).
Communicate decisions, questions, and potential concerns.
Individual commits are ready for review (see commit discipline).
Completed manual review and testing of the following: