Skip to content
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

Add notifications when a badge is awarded #3442

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

harmitgoswami
Copy link
Collaborator

Fix #3412

This PR adds notifications to signal to a user that they received a new badge/badge level. Notifications will appear in both the "Notifications Menu" in the header (first image), and as a notification banner across the top of the page. Notification banners for new badge levels will trigger a confetti animation, imported from https://github.com/catdad/canvas-confetti.

The initial commit for this PR has a noticeable bug, in that demotions and promotions will both count towards the Community Builder Badge. This issue stems from how assign_users_to_groups will always update translators then managers, in that order. Thus, there is no way to distinguish if an action is promoting a user from Contributor -> Translator or if an action is demoting a user from Manager -> Translator, especially since multiple users can be demoted/promoted in the same action.

image image

Harmit Goswami added 2 commits November 15, 2024 11:13
In this state, there is still an issue with differentiating between demotions and promotions for the Community Builder Badge, and awarding badges accordingly
@harmitgoswami harmitgoswami marked this pull request as draft November 15, 2024 19:41
@codecov-commenter
Copy link

codecov-commenter commented Nov 15, 2024

Codecov Report

Attention: Patch coverage is 60.00000% with 24 lines in your changes missing coverage. Please review.

Project coverage is 80.36%. Comparing base (9bd457f) to head (24a3519).
Report is 5 commits behind head on main.

Additional details and impacted files
---- 🚨 Try these New Features:

Copy link
Collaborator

@mathjazz mathjazz left a comment

Choose a reason for hiding this comment

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

Nice work!

As mentioned inline, I'd use a popup when the badge is awarded.

Looking into the Permission promotions bug.

pontoon/settings/base.py Outdated Show resolved Hide resolved
if (badgeLevel) {
Pontoon.endLoader(
`Community Builder Badge level gained: ${badgeLevel}`,
);
Copy link
Collaborator

@mathjazz mathjazz Nov 18, 2024

Choose a reason for hiding this comment

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

Rather than "notification banners", I would use a popup similar to the new contributor popup that persists and needs to be manually hidden.

I would also show the actual badge in the popup.

@mathjazz
Copy link
Collaborator

The initial commit for this PR has a noticeable bug, in that demotions and promotions will both count towards the Community Builder Badge. This issue stems from how assign_users_to_groups will always update translators then managers, in that order. Thus, there is no way to distinguish if an action is promoting a user from Contributor -> Translator or if an action is demoting a user from Manager -> Translator, especially since multiple users can be demoted/promoted in the same action.

Is this not working as expected then?

# Check if user was demoted from Manager to Translator
# In this case, it doesn't count as a promotion
if group_name == "managers":
removal = PermissionChangelog.objects.filter(
performed_by=self.user,
action_type=PermissionChangelog.ActionType.REMOVED,
created_at__gte=now,
)
if removal:
for item in removal:
if "managers" in item.group.name:
after_count -= 1

Changed the confetti file to be the unminified version instead. This commit also has a broken implementation of the permissions count bug, where I attempted to self-correct permissions counts inside of user.py
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.

Send notification upon user receiving new badge
3 participants