Skip to content

fix(plugins): settings button for any plugin with a settings page (Mobile API gate unreachable)#191

Closed
fabiodalez-dev wants to merge 4 commits into
mainfrom
fix/plugin-generic-settings-button
Closed

fix(plugins): settings button for any plugin with a settings page (Mobile API gate unreachable)#191
fabiodalez-dev wants to merge 4 commits into
mainfrom
fix/plugin-generic-settings-button

Conversation

@fabiodalez-dev

@fabiodalez-dev fabiodalez-dev commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Problem

After activating the Mobile API plugin, the app still gets "l'accesso da app mobile è disattivato su questa biblioteca". The cause: the gate that enables app access (mobile_api.enabled, the "Abilita accesso app mobile" toggle) lives on the plugin's settings page — but the Admin → Plugins list only renders a settings button for a few hardcoded plugins (open-library, api-book-scraper, goodlib, discogs). Mobile API (and any other plugin with a settings page) had no button, so the page /admin/plugins/{id}/settings was unreachable and the gate could never be turned on.

Confirmed live with Playwright: the Mobile API card showed only Disattiva, no settings entry, despite hasSettingsPage()=true and a fully working settings page.

Fix

  • PluginController::index flags which active plugins expose a settings page (hasSettingsPage() + getSettingsViewPath()).
  • The list renders a generic "Impostazioni" link to /admin/plugins/{id}/settings for any such plugin not already handled by a custom modal.
  • open-library / api-book-scraper / goodlib keep their custom buttons; discogs now flows through the generic path (same link it already used). No new i18n key (Impostazioni exists).

Verified

  • Live: the Mobile API card now shows ⚙ Impostazioni → its settings page with the app-access toggle; Music Scraper/Discogs and GoodLib unaffected.
  • PHPStan L5 clean.

Summary by CodeRabbit

  • New Features

    • Aggiunto il pulsante Impostazioni nella lista dei plugin solo quando è disponibile una pagina di configurazione.
    • La disponibilità delle impostazioni viene ora rilevata in modo più affidabile per i plugin attivi.
  • Bug Fixes

    • Migliorata la gestione dei casi in cui un plugin non risponde correttamente durante il controllo delle impostazioni.
    • Ridotti i casi in cui venivano mostrati controlli non coerenti nelle azioni dei plugin.

The admin Plugins list only rendered a settings button for a few hardcoded
plugins (open-library, api-book-scraper, goodlib, discogs). Any other plugin
with a working settings page — notably Mobile API, whose 'Abilita accesso app
mobile' gate (mobile_api.enabled) lives there — was unreachable from the UI, so
the gate could never be turned on and the app got 'mobile access disabled'.

PluginController::index now flags which active plugins expose a settings page
(hasSettingsPage + getSettingsViewPath), and the list shows a generic
'Impostazioni' link to /admin/plugins/{id}/settings for them. The custom modals
of open-library / api-book-scraper / goodlib are preserved; discogs now flows
through the generic path (same link it already used). No new i18n key.

Verified live: the Mobile API card now shows 'Impostazioni' linking to its
settings page with the app-access toggle; existing plugins unaffected.
PHPStan L5 clean.
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@fabiodalez-dev, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 15 minutes and 2 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: f0dac151-f594-49f7-8fad-c343bc782bc9

📥 Commits

Reviewing files that changed from the base of the PR and between 917c64e and f94a76d.

📒 Files selected for processing (1)
  • app/Controllers/PluginController.php
📝 Walkthrough

Walkthrough

Il controller calcola per ogni plugin attivo se esiste una pagina impostazioni, verificando istanza e metodi disponibili. La vista admin usa questa mappa per mostrare il pulsante Impostazioni solo quando disponibile e non per i plugin con pulsanti custom.

Changes

Impostazioni plugin

Layer / File(s) Summary
Mappa capability nel controller
app/Controllers/PluginController.php
PluginController::index costruisce pluginHasSettings per i plugin attivi dopo aver verificato hasSettingsPage() e getSettingsViewPath(), con fallback a false in caso di eccezione.
Pulsante Impostazioni nella vista
app/Views/admin/plugins.php
La vista legge pluginHasSettings con fallback vuoto e mostra il pulsante Impostazioni solo per i plugin attivi senza pulsanti custom e con capability rilevata.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Titolo chiaro e pertinente: descrive il nuovo link Impostazioni per i plugin con pagina settings e cita il caso Mobile API.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 60.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/plugin-generic-settings-button

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/Controllers/PluginController.php`:
- Around line 56-62: The settings-page detection in
PluginController::hasSettingsPage is too permissive and does not match the guard
used by settingsPage(). Update the check so it not only verifies
hasSettingsPage() and getSettingsViewPath() are callable, but also confirms the
returned path is a string and points to an existing file, mirroring the logic in
settingsPage() to avoid showing an “Impostazioni” button for invalid views.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: bfd71d1b-04d7-423a-9936-3a289eb0c489

📥 Commits

Reviewing files that changed from the base of the PR and between 966f125 and 917c64e.

📒 Files selected for processing (2)
  • app/Controllers/PluginController.php
  • app/Views/admin/plugins.php

Comment thread app/Controllers/PluginController.php Outdated
…e API toggle)

The POST /admin/plugins/{id}/settings route always called updateSettings(),
whose hardcoded if/elseif chain bailed with 'plugin non supporta impostazioni'
for mobile-api — so the 'Abilita accesso app mobile' toggle (and push config)
could never be saved from the UI, and the app kept seeing app_access_enabled=false.

The Mobile API settings page is a normal (non-AJAX) form that handles its own
POST inside the view (CSRF + plugin->saveSettings() + success message). The
legacy AJAX handlers require a nested 'settings' payload; when it's absent the
request is such a self-rendering form, so delegate to settingsPage() and let the
view's own POST logic run. Generic — fixes mobile-api and any future
self-rendering settings page; AJAX plugins (which always send 'settings') are
unaffected.

Verified end-to-end: toggling 'Abilita accesso app mobile' now flips
system_settings mobile_api.enabled 0->1. PHPStan L5 clean.
…xists

Align the settings-page detection with settingsPage()'s guard (is_string +
is_file on getSettingsViewPath), so a plugin declaring a settings page with a
missing view file doesn't surface an 'Impostazioni' button that 404s on click.
Addresses CodeRabbit review on #191.
@fabiodalez-dev

Copy link
Copy Markdown
Owner Author

Superseded by #194 (consolidated mobile-API contract coherence). Changes included there.

@fabiodalez-dev fabiodalez-dev deleted the fix/plugin-generic-settings-button branch June 25, 2026 06:03
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.

1 participant