Skip to content

Check translator rights per string in All Projects - #4412

Merged
flodolo merged 2 commits into
mozilla:mainfrom
mathjazz:4395-all-projects-approve
Aug 18, 2026
Merged

Check translator rights per string in All Projects#4412
flodolo merged 2 commits into
mozilla:mainfrom
mathjazz:4395-all-projects-approve

Conversation

@mathjazz

@mathjazz mathjazz commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Fix #4395.

useTranslator() builds its key from the URL:

const localeProject = `${code}-${slug}`;
if (Object.hasOwnProperty.call(translatorForProjects, localeProject)) {  }

In the All Projects view slug is "all-projects", and e.g. "uk-all-projects" is never a key in translatorForProjects, so it falls through to the locale-wide check, which is false for a per-project translator. Hence "Suggest".

The fix is to take the project from the entity instead.

Note that even today the submit approves, because the server already checks permissions against the entity's own project.

useTranslator() builds its key from the URL's project:

const localeProject = `${code}-${slug}`;
if (Object.hasOwnProperty.call(translatorForProjects, localeProject)) { … }

In the All Projects view slug is "all-projects", and "uk-all-projects"
is never a key in `translatorForProjects`, so it falls through to the
locale-wide check, which is false for a per-project translator. Hence "Suggest".

The fix is to take the project from the entity instead.

Note that even today the submit approves, because the server already checks
permissions against the entity's own project.
@mathjazz
mathjazz requested a review from eemeli August 14, 2026 15:09
Comment thread translate/src/hooks/useTranslator.ts Outdated
Comment thread translate/src/hooks/useTranslator.ts Outdated
Co-authored-by: Eemeli Aro <eemeli@gmail.com>
@flodolo
flodolo requested a review from eemeli August 18, 2026 13:06

@flodolo flodolo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving per conversation with Eemeli

@flodolo
flodolo removed the request for review from eemeli August 18, 2026 13:13
@flodolo
flodolo merged commit f90222c into mozilla:main Aug 18, 2026
10 checks passed
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.

Suggest button is displayed instead of the Approve button in the All Projects view

3 participants