Skip to content

Commit

Permalink
Added capability to mention users by username (#3253)
Browse files Browse the repository at this point in the history
  • Loading branch information
harmitgoswami committed Jun 7, 2024
1 parent 17965f2 commit 5bb0877
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions pontoon/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,8 @@ def get_users(request):
.exclude(profile__system_user=True)
# Exclude deleted users
.exclude(email__regex=r"^deleted-user-(\w+)@example.com$")
# Prefetch profile for retrieving username
.prefetch_related("profile")
)
payload = []

Expand All @@ -685,6 +687,7 @@ def get_users(request):
"gravatar": u.gravatar_url(44),
"name": u.name_or_email,
"url": u.profile_url,
"username": u.profile.username,
}
)

Expand Down
1 change: 1 addition & 0 deletions translate/src/api/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export type MentionUser = {
gravatar: string;
name: string;
url: string;
username: string | null;
};

/** Dismiss Add-On Promotion. */
Expand Down
6 changes: 4 additions & 2 deletions translate/src/modules/comments/components/AddComment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,10 @@ export function AddComment({
}, [initFocus]);

const suggestedUsers = mentionUsers
.filter((user) =>
user.name.toLowerCase().includes(mentionSearch.toLowerCase()),
.filter(
(user) =>
user.username?.toLowerCase().includes(mentionSearch.toLowerCase()) ||
user.name.toLowerCase().includes(mentionSearch.toLowerCase()),
)
.slice(0, 5);

Expand Down

0 comments on commit 5bb0877

Please sign in to comment.