Skip to content

Rosetta Roles: Refactor roles JS and storage handling. - #1040

Open
timse201 wants to merge 105 commits into
WordPress:trunkfrom
timse201:patch-4
Open

timse201 wants to merge 105 commits into
WordPress:trunkfrom
timse201:patch-4

Conversation

@timse201

@timse201 timse201 commented Oct 12, 2026 •

Copy link
Copy Markdown

Refactors the Rosetta project role assignment script to modern ES6+ standards, eliminating the internal jQuery dependency in favor of native DOM APIs.

Key changes:

  • Replace localStorage with IndexedDB for caching project data.
  • Replace $window jQuery events with an internal Backbone event dispatcher (projects.events).
  • Introduce SelectableModel base model to consolidate shared selection and synchronization logic between Project and SubProject.
  • Encapsulate the #project-all toggle into a dedicated projects.view.AllProjects Backbone view.
  • Optimize sub-project search by replacing dynamic regular expressions with token-based string matching and cached search haystacks.
  • Improve accessibility by handling indeterminate checkbox states with aria-checked="mixed" and proper ARIA labels.
  • Improve rendering performance via DocumentFragment and debounced field synchronization.

Assisted by Gemini 3.8 Flash

Summary by CodeRabbit

  • Improvements
    • Project, sub-project, and “all projects” selections stay synchronized, including selections hidden by search.
    • Search matches multiple terms, prioritizes relevant results, and displays up to 100 sub-projects.
    • Project data loads from valid cached information when available, or from the server otherwise.
    • Search and checkbox controls support keyboard interaction, and search displays a message when there are no matching results.
  • Bug Fixes
    • A message appears if projects cannot be loaded.
    • Existing translators are asked to confirm when their project access list is emptied.
    • “All projects” is shown as active only when selected.

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

Core Committers: Use this line as a base for the props when committing in SVN:

Props timse201.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • ✅ Review completed - (🔄 Check again to review again)

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 15e47803-afb3-451a-8920-c8766350d37b
📥 Commits

Reviewing files that changed from the base of the PR and between dccc87d and aa92f49.

📒 Files selected for processing: 1
  • global.wordpress.org/public_html/wp-content/mu-plugins/roles/js/rosetta-roles.js

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

📝 Walkthrough

The roles interface updates project and sub-project selection, search, and rendering. Project data now uses timestamped gzip storage in IndexedDB, with remote retrieval when local data is unavailable. Initialization and submission normalize access lists and handle loading errors and translator-status removal.

Changes: Roles interface

Layer / File(s) Summary
Project selection and search
global.wordpress.org/public_html/wp-content/mu-plugins/roles/js/rosetta-roles.js, global.wordpress.org/public_html/wp-content/mu-plugins/roles/rosetta-roles.php, global.wordpress.org/public_html/wp-content/mu-plugins/roles/css/rosetta-roles.css, global.wordpress.org/public_html/wp-content/mu-plugins/roles/css/rosetta-roles-rtl.css
Shared model state synchronizes project and sub-project selection. Search matches all query tokens and ranks results when scoring is available. Views synchronize checkbox and ARIA states, support debounced keyboard search, and render up to 100 sub-projects. The project template always renders a checkbox. List styling includes hover and no-results states.
IndexedDB project-data caching
global.wordpress.org/public_html/wp-content/mu-plugins/roles/js/rosetta-roles.js
Project loading checks IndexedDB and compression support. It reads timestamped gzip data and uses remote data when local retrieval fails or the cache is stale. Database recovery and transaction handling are included.
Form initialization and access-list wiring
global.wordpress.org/public_html/wp-content/mu-plugins/roles/js/rosetta-roles.js, global.wordpress.org/public_html/wp-content/mu-plugins/roles/rosetta-roles.php, global.wordpress.org/public_html/wp-content/mu-plugins/roles/cross-locale-pte.php, global.wordpress.org/public_html/wp-content/mu-plugins/roles/views/edit-translation-editor.php
Initialization normalizes access IDs and treats “all” as the sole selection. Submission updates the selection and confirms removal of initially present translator status when the field is empty. PHP settings normalize localized values, and the editor view marks the all-project item active only when all is selected.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant ProjectLoader
  participant IndexedDB
  participant RemoteProjectRequest
  ProjectLoader->>IndexedDB: Read cached gzip data and timestamp
  IndexedDB-->>ProjectLoader: Return cached data or retrieval failure
  ProjectLoader->>RemoteProjectRequest: Request projects after cache retrieval fails
  RemoteProjectRequest-->>ProjectLoader: Return project data
  ProjectLoader->>IndexedDB: Store compressed data and timestamp
Loading
Merge Risk: ⚪ Minimal · up to aa92f

The reviewed selection, access-list, and project-loading paths have no established merge-blocking defect.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title accurately summarizes the main changes: refactoring the Rosetta Roles JavaScript and replacing the storage handling. It is concise and specific.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 4 files.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@timse201 timse201 moved this to 👀 In review (PRs only) in WordPress.org Oct 12, 2026
@timse201 timse201 added [Type] Enhancement New feature or request [Type] Bug Something isn't working [Site] Rosetta and removed [Type] Enhancement New feature or request labels Oct 12, 2026
@timse201 timse201 moved this from 👀 In review (PRs only) to 🚀 Ready for deploy (PRs only) in WordPress.org Oct 12, 2026
coderabbitai[bot]

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as outdated.

@timse201 timse201 moved this from 🏗 In progress to 🚀 Ready for deploy (PRs only) in WordPress.org Oct 13, 2026
@timse201 timse201 moved this from 🚀 Ready for deploy (PRs only) to 👀 In review (PRs only) in WordPress.org Oct 13, 2026
coderabbitai[bot]

This comment was marked as resolved.

@WordPress WordPress deleted a comment from coderabbitai Bot Oct 22, 2026
@WordPress WordPress deleted a comment from coderabbitai Bot Oct 22, 2026
@timse201 timse201 moved this from 🏗 In progress to 👀 In review (PRs only) in WordPress.org Oct 22, 2026
coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@timse201 timse201 moved this from 👀 In review (PRs only) to 🚀 Ready for deploy (PRs only) in WordPress.org Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Site] Rosetta [Type] Bug Something isn't working

Projects

Status: 🚀 Ready for deploy (PRs only)

Development

Successfully merging this pull request may close these issues.

1 participant