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 role banner under user avatar #3400

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

harmitgoswami
Copy link
Collaborator

Fix #3393

This PR adds the user role as a banner under their avatar in the translate view. As per discussions in team calls, the design for the banner is to be iterated on within this PR.

To reproduce results: Head to any string within any team/project that has more than just the imported translation available (i.e. a user has submitted a translation for that string). At the bottom of their avatar, their role will be displayed within a banner.

image

@codecov-commenter
Copy link

codecov-commenter commented Oct 7, 2024

Codecov Report

Attention: Patch coverage is 96.36364% with 2 lines in your changes missing coverage. Please review.

Project coverage is 80.49%. Comparing base (b8a2030) to head (e765262).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
pontoon/base/models/user.py 93.33% 1 Missing ⚠️
...anslate/src/modules/user/components/UserAvatar.tsx 80.00% 1 Missing ⚠️
Additional details and impacted files

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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!

The spec is not exactly clear where to show the status icons. It mentions translations (suggestions) and comments and shows the status icon in the Profile. It also says "Status Icons: Show status icons universally in the user avatar".

I am not sure we should show them everywhere we show the avatar. In the Contributors dashboards and user filters, we already show the roles. I also don't think it's useful to show it in the Profile icon or in the Settings page, since that's only visible to the user.

How about we keep it just next to translations and comments (covered by this patch) and also add them to the Profile page? @flodolo Given that you were the reviewer of the spec, what's your take on this?

pontoon/base/views.py Outdated Show resolved Hide resolved
translate/public/locale/en-US/translate.ftl Outdated Show resolved Hide resolved
@flodolo
Copy link
Collaborator

flodolo commented Oct 8, 2024

The spec is not exactly clear where to show the status icons. It mentions translations (suggestions) and comments and shows the status icon in the Profile. It also says "Status Icons: Show status icons universally in the user avatar".

I am not sure we should show them everywhere we show the avatar. In the Contributors dashboards and user filters, we already show the roles. I also don't think it's useful to show it in the Profile icon or in the Settings page, since that's only visible to the user.

How about we keep it just next to translations and comments (covered by this patch) and also add them to the Profile page? @flodolo Given that you were the reviewer of the spec, what's your take on this?

Looks like I didn't actually review the final version 🤔

I agree on showing the status only in translations and comments:

  • That information is useful when reviewing (is this person new? Is the person leaving a comment/suggestion a translator for that locale?)
  • Same for comments (am I getting a comment from someone who doesn't know how Pontoon works?).

@mathjazz
Copy link
Collaborator

mathjazz commented Oct 8, 2024

OK, so let's keep it like that. On a second thought, it's indeed not necessary in the Profile page, where we already show the Translator, Manager and Admin status (as well as the date joined).

In this commit, i've expanded the status icons to also be included in comments. I've slightly adjusted the CSS rules as well, and created a new function to send status data to translations and comments.
@harmitgoswami
Copy link
Collaborator Author

As we discussed, it seems like some of the statuses do indeed overflow when displayed in the banner.

image

image

@flodolo
Copy link
Collaborator

flodolo commented Oct 8, 2024

Thoughts on using just letters to keep labels short (A/T/M + New), and rely on tooltip for explanation?

@harmitgoswami
Copy link
Collaborator Author

I think it would work for 'New', however, since a lot of users have their avatar as the default (the initials of their username), I personally feel that it might look odd to have up to three letters displayed in the avatar container.

@flodolo
Copy link
Collaborator

flodolo commented Oct 8, 2024

I think it would work for 'New', however, since a lot of users have their avatar as the default (the initials of their username), I personally feel that it might look odd to have up to three letters displayed in the avatar container.

We could make it more "badge-y".

Screenshot 2024-10-08 alle 21 37 53

pontoon/base/models/user.py Outdated Show resolved Hide resolved
pontoon/base/views.py Outdated Show resolved Hide resolved
translate/src/modules/comments/components/Comment.tsx Outdated Show resolved Hide resolved
pontoon/base/models/user.py Outdated Show resolved Hide resolved
translate/public/locale/en-US/translate.ftl Outdated Show resolved Hide resolved
@mathjazz
Copy link
Collaborator

mathjazz commented Oct 9, 2024

I like flod's idea for the status icon.

Below is a rough variant of this proposal, which uses different colors for different statuses and shortens the titles using the similar method that we use on the dashboards.

Posnetek zaslona 2024-10-09 ob 10 09 03

pontoon/base/models/user.py Outdated Show resolved Hide resolved
pontoon/base/models/user.py Outdated Show resolved Hide resolved
translate/src/modules/comments/components/Comment.tsx Outdated Show resolved Hide resolved
translate/src/modules/comments/components/Comment.tsx Outdated Show resolved Hide resolved
translate/src/modules/user/components/UserAvatar.tsx Outdated Show resolved Hide resolved
@harmitgoswami
Copy link
Collaborator Author

I've held off on creating useLocaleRole.test.js for now, in case we need to tweak the hook any further

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.

Works great! A few comments, but they are all small.

translate/src/modules/comments/components/Comment.tsx Outdated Show resolved Hide resolved
translate/src/hooks/useLocaleRole.ts Outdated Show resolved Hide resolved
pontoon/base/views.py Show resolved Hide resolved
translate/src/hooks/useLocaleRole.ts Outdated Show resolved Hide resolved
translate/src/modules/comments/components/CommentsList.tsx Outdated Show resolved Hide resolved
translate/src/modules/user/components/UserAvatar.tsx Outdated Show resolved Hide resolved
translate/src/modules/user/components/UserAvatar.tsx Outdated Show resolved Hide resolved
translate/src/modules/user/components/UserAvatar.css Outdated Show resolved Hide resolved
translate/src/modules/user/components/UserAvatar.css Outdated Show resolved Hide resolved
@@ -18,6 +18,7 @@ export function CommentsList({
user,
}: Props): React.ReactElement<'div'> {
const onAddComment = useAddCommentAndRefresh(translation);

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Please restore this change and we can ship it! :)

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.

Implement status icons in user avatars
4 participants