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 banner for project managers, give priority to roles within locale #3422

Merged
merged 16 commits into from
Nov 5, 2024

Conversation

flodolo
Copy link
Collaborator

@flodolo flodolo commented Oct 21, 2024

This adds a banner for users defined as "Project Manager" within a project. To reduce the space for confusion, I changed the tooltip of MNGR from "Manager" to "Team Manager".

This also makes the priority of roles consistent between front-end and back-end:

  • If a user as a role within the locale (translator, manager), we use that for the banner.
  • If a user is set as PM, we use that even if the user is an Admin.

Finally, this adds CSS variables for users, instead of reusing the ones for translation status.

Fixes #3418
Fixes #3425

TODO:

  • Update spec

@flodolo flodolo changed the title Add banner for project managers, given priority to role within locale Add banner for project managers, give priority to roles within locale Oct 21, 2024
@flodolo flodolo requested a review from mathjazz October 21, 2024 15:19
@flodolo
Copy link
Collaborator Author

flodolo commented Oct 21, 2024

Deleted the previous comment because I realize I was testing the same code 🤦🏼

Follow-up on conversation, I tested with with debug_sql():, if I did it correctly:

  • 1 translation comment: new code 6 db calls, previous 5.
  • 1 source comment: 10 db calls, previous 6.

@flodolo
Copy link
Collaborator Author

flodolo commented Oct 25, 2024

The second commit fixes #3425

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!

Added a few suggestions for minor improvements, and suggested a couple of ways forward for the PM status.

pontoon/base/models/user.py Outdated Show resolved Hide resolved
pontoon/base/views.py Outdated Show resolved Hide resolved
translate/src/hooks/useUserStatus.ts Outdated Show resolved Hide resolved
pontoon/base/models/comment.py Outdated Show resolved Hide resolved
@flodolo
Copy link
Collaborator Author

flodolo commented Oct 25, 2024

My previous version of the code was running without issues, with the last commit (review comments) I see a weird error when I load the first time?

EDIT: (solved) The suggest code returns a ProjectQuerySet that can't be serialized as JSON

f'Object of type {o.__class__.__name__} '
[server] TypeError: Object of type ProjectQuerySet is not JSON serializable
[server] [ERROR:django.server] 2024-10-25 13:34:52,066 "GET /user-data/ HTTP/1.1" 500 22414

I also tried to move project to the caller code, but that seems to be more complicated than I expected? Does that require a migration?

EDIT: removed the diff, because after putting some logging, I realize I was completely off.

pontoon/base/views.py Outdated Show resolved Hide resolved
pontoon/base/views.py Outdated Show resolved Hide resolved
pontoon/base/models/user.py Outdated Show resolved Hide resolved
pontoon/base/views.py Outdated Show resolved Hide resolved
pontoon/base/models/comment.py Outdated Show resolved Hide resolved
flodolo and others added 6 commits November 4, 2024 20:48
This adds a banner for users defined as "Project Manager" within a project.
To reduce the space for confusion, I changed the tooltip of MNGR from "Manager" to "Team Manager".

This also makes the priority of roles consistent between front-end and back-end:
- If a user as a role within the locale (translator, manager), we use that for the banner.
- If a user is set as PM, we use that even if the user is an Admin.

Finally, this adds CSS variables for users, instead of reusing the ones for translation status.
@mathjazz
Copy link
Collaborator

mathjazz commented Nov 4, 2024

@flodolo Could you please take it for a spin on stage?

In addition to addressing the review comments, I've also fix the color for the MNGR status, which was broken and simplified the logic behind it.

Copy link
Collaborator Author

@flodolo flodolo left a comment

Choose a reason for hiding this comment

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

I think we have a problem with admins in the front-end: they always show up as "MNGR" when writing a comment, because apparently managerForLocales is the full list of Pontoon locales (same for translatorForLocales).

Is that needed to enable/disable editing?

@flodolo
Copy link
Collaborator Author

flodolo commented Nov 5, 2024

(I'm testing locally because it's easier to mess with projects and users)

Another inconsistency: new user that is not set up as PM for the project, but it's part of project_managers. When commenting (front-end) it shows up as ADMIN, after commenting it shows up as NEW.

@mathjazz
Copy link
Collaborator

mathjazz commented Nov 5, 2024

Yeah, we have inconsistent definitions of user statuses between:

def user_data(request):
(used when adding a comment)

def user_status(self, locale, project_contact):
(used everywhere else)

@mathjazz
Copy link
Collaborator

mathjazz commented Nov 5, 2024

Stage updated with the new code.

@flodolo
Copy link
Collaborator Author

flodolo commented Nov 5, 2024

This works great for me locally. Thanks for taking over, so much larger than I expected

@mathjazz
Copy link
Collaborator

mathjazz commented Nov 5, 2024

Could you please also take a look at the code? I can't flag you for a review, since you're the author of the PR.

@flodolo
Copy link
Collaborator Author

flodolo commented Nov 5, 2024

Could you please also take a look at the code? I can't flag you for a review, since you're the author of the PR.

I should have called out that I did review the various commits 👍🏼

@mathjazz mathjazz merged commit 4b23a5d into mozilla:main Nov 5, 2024
7 checks passed
@mathjazz mathjazz mentioned this pull request Nov 5, 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
2 participants