Skip to content

autocomplete: Exclude deactivated users from @-mention autocomplete popup #582

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

Conversation

Khader-1
Copy link
Collaborator

@Khader-1 Khader-1 commented Mar 24, 2024

Logic Implemented

autocomplete: Exclude deactivated users from @-mention autocomplete popup

Deactivated users can not be mentioned, so this ensures that deactivated users are excluded from the list that gets rendered in autocomplete popup.

compose test: Check ID still included if same-name users deactivated

While autocomplete does not include deactivated users, there still is a possibility that same-name users with one or more of them deactivated gets mentioned, which will make the mentioned user ambiguous without the id, this is explained in #451.

Fixes #451

@sm-sayedi
Copy link
Collaborator

Better than before, but still needs some improvements.

It should pass tests (so test updates needed by a change should be in the same commit as the original change, not a separate “fix the tests that were broken by the last commit” commit).

As stated in the Zulip Commit Discipline page, the tests for a change should be in the same commit.

Also, instead of closing a PR and then opening a new one just for the sake of some changes, there is an easy way of doing it explained in this page.

@Khader-1 Khader-1 force-pushed the exclude-deactivated-users-from-mention-autocomplete-popup branch from 8de38cd to 3a98165 Compare March 24, 2024 08:51
@Khader-1
Copy link
Collaborator Author

It should pass tests (so test updates needed by a change should be in the same commit as the original change, not a separate “fix the tests that were broken by the last commit” commit).

@sm-sayedi You're right although the tests in the second commit do not test the same change that the first one introduces. they depend on some of the changes.

Regarding the rebase.. I learned it hard way!

Thanks for you helpful guidance☺️

@Khader-1 Khader-1 force-pushed the exclude-deactivated-users-from-mention-autocomplete-popup branch from 3a98165 to 0d6a28d Compare March 25, 2024 01:19
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Khader-1 for the contribution, and @sm-sayedi for the initial reviews! Comments below on this version.

@Khader-1 Khader-1 changed the title Exclude deactivated users from @-mention autocomplete popup autocomplete: Exclude deactivated users from @-mention autocomplete popup Mar 25, 2024
@Khader-1 Khader-1 force-pushed the exclude-deactivated-users-from-mention-autocomplete-popup branch 3 times, most recently from 13dc818 to 261bfef Compare March 25, 2024 15:55
Copy link
Collaborator Author

@Khader-1 Khader-1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has gone through many iterations! hopefully each iteration is a step in the right direction.
I think it is ready to be reviewed now

@Khader-1 Khader-1 requested a review from gnprice March 25, 2024 16:00
@Khader-1 Khader-1 force-pushed the exclude-deactivated-users-from-mention-autocomplete-popup branch 2 times, most recently from fbaf56a to 6dfd58e Compare March 26, 2024 02:23
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Khader-1! This is quite close to merge.

A few small comments below. The one other area that needs a bit of revision before we merge this is the formatting of the commit messages.

To see example commit messages in general, here's a slightly broader version of that last pair of commands:

$ git log --stat --author '(greg|cbobbe)@zulip' -P

});

test('user is always excluded when not active regardless of other criteria', () {
doCheck('Full Name', eg.user(fullName: 'Full Name', isActive: false), false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make this test case fully self-contained, let's give it a second line that looks exactly the same except the user is active, and does match.

That line will be identical to one of the lines in the existing test case, so in a sense it's redundant. But it makes a useful baseline for the reader to compare this other check to. It means that the reader can look at this test case and be confident that it really is testing what it's meant to test — that there isn't some accident where the user stopped matching because something changed about the name matching, or whatever — without having to look around at other tests, or to look back at the implementation that's being tested.

@Khader-1 Khader-1 force-pushed the exclude-deactivated-users-from-mention-autocomplete-popup branch from 6dfd58e to 854a18c Compare March 28, 2024 09:48
Copy link
Collaborator Author

@Khader-1 Khader-1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not tagged as [nfc] because it does actually add functionality or at least it tests it's existence. Besides the new test case is mentioned as a part of the issue.

@Khader-1 Khader-1 requested a review from gnprice March 28, 2024 10:02
@gnprice
Copy link
Member

gnprice commented Mar 29, 2024

This is not tagged as [nfc] because it does actually add functionality or at least it tests it's existence. Besides the new test case is mentioned as a part of the issue.

Sounds good, yeah.

(I assume you're referring to the second commit in the series:
62015a2 compose test [nfc]: Make trailing whitespace explicit in test cases
9672a0a compose test: Check ID still included if same-name users deactivated
a88222a autocomplete [nfc]: factor out _testName filtering helper
f9f476f autocomplete test [nfc]: Use test group to handle testUser cases
854a18c autocomplete: Exclude user from autocomplete popup if deactivated

because that's the one that was marked NFC in the previous revision, and isn't in this one.)

The test case 'whitespace around info string' includes a line that
ends with a white space, while this is important for the test case
it can cause two issues:
* It could accidentally get reformatted by code editor
* It is not explicit for developers reading the code

This commit is making the trailing white space be more explicit.
While autocomplete does not include deactivated users, there still
is a possibility that same-name users with one or more deactivated
gets mentioned, which will make the mentioned user ambiguous without
the id, this is explained in zulip#451.

This adds a test case that asserts same-name users are disambiguated
while composing the message regardless of them being active.

Fixes part of zulip#451
As we start adding more features 'MentionAutocompleteQuery.testUser'
would get confusing, This commit factors out _testName helper which
is then used inside testUser.
'testUser' is a filter function that is expected to get complicated
as we add features. For example it will be responsible for filtering
users based on email, name, stream activity, etc. More on this: zulip#236
so it is useful to have the test cases for 'testUser' grouped.
Deactivated users can not be mentioned, so this commit ensures that
deactivated users are excluded from the list that gets rendered in
autocomplete popup.

Fixes: zulip#451
@gnprice
Copy link
Member

gnprice commented Mar 29, 2024

Thanks @Khader-1 for the revision! This all looks good except two small nits in commit messages. I'll fix those up and merge.

autocomplete [nfc]: factor out _testName filtering helper

The summary line should be in sentence case after the prefix: so "Factor out …".

autocomplete: Exclude user from autocomplete popup if deactivated

Deactivated users can not be mentioned, so this commit ensures that
deactivated users are excluded from the list that gets rendered in
autocomplete popup.

Fixes #451

The "fixes" line should have a colon: https://github.com/zulip/zulip-mobile/blob/main/docs/style.md#fixes-format

@gnprice gnprice force-pushed the exclude-deactivated-users-from-mention-autocomplete-popup branch from 854a18c to 81feda5 Compare March 29, 2024 00:27
@gnprice gnprice merged commit 81feda5 into zulip:main Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

autocomplete: Exclude deactivated users from @-mention autocomplete popup, like in web
3 participants