2.2 KiB
2.2 KiB
name, description
| name | description |
|---|---|
| sonarqube-frontend-extension | Use when implementing or changing a SonarQube 25.9 page extension, its JavaScript bundle, navigation placement, API calls, or browser permissions. |
SonarQube frontend extension
- Register a global page with
PageDefinition; its key isbifrost/import. - Put the matching unbundled JavaScript at
src/main/resources/static/import.js; callwindow.registerExtension("bifrost/import", start). - Use only
options.elas the page mount point; return a cleanup callback. - Do not assume global libraries except React. Plain browser JavaScript avoids an unnecessary build step.
- Use same-origin
fetchforapi/bifrost/*; rely on the active SonarQube session and never send the Gitea token to the browser. For non-GET requests, copy the readableXSRF-TOKENcookie into theX-XSRF-TOKENheader; SonarQube 25.9 rejects cookie-authenticated POSTs without it. - Render API errors as accessible text; use labels for controls, semantic table headers, keyboard-accessible controls, and text status in addition to color.
- Validate repository links as HTTP or HTTPS before assigning them to an anchor.
- Grey out imported rows and disable their checkboxes. Keep selection in page state across organization changes.
- Page visibility is not authorization. The server must enforce Create Projects permission on every endpoint.
- Do not embed inline scripts or use
eval.
Checklist
PageDefinitionkey matches JS registration key and resource filename.- Bundle packaged under
/static/bifrost/import.js. - Accessible labels, feedback and keyboard controls.
- No token in browser or authorization based only on menu visibility.
Sources
- Adding pages to the webapp: https://docs.sonarsource.com/sonarqube-community-build/extension-guide/developing-a-plugin/adding-pages-to-the-webapp (consulted 2026-10-28)
- SonarQube Web API: https://docs.sonarsource.com/sonarqube-community-build/extension-guide/web-api (consulted 2026-10-28)
Not verified
- Live page routing, bundle loading, accessible controls, selection retention, and POST CSRF behavior were verified on Community Build 25.9.0.112764. Conditional menu hiding based on Create Projects permission is not supported by the selected public page API.