Skip to content

Fix undefined kaui_admin_screens_allowed? on the Plugins page (KPM) - #687

Open
tungleduyxyz wants to merge 3 commits into
masterfrom
fix-admin-screens-helper-other-engines
Open

tungleduyxyz wants to merge 3 commits into
masterfrom
fix-admin-screens-helper-other-engines

Conversation

@tungleduyxyz

@tungleduyxyz tungleduyxyz commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #688

Problem

Since the Cognito token exchange (#683), the Kaui navbar and the settings sidebar call kaui_admin_screens_allowed?. It was exposed to views with helper_method in Kaui::EngineController.

The Plugins page is served by killbill-kpm-ui: KPM::PluginsController < KPM::EngineController < ApplicationController, which does not inherit from Kaui::EngineController. Its plugins/index.html.erb (and nodes_info/index.html.erb) render the kaui/layouts/kaui_setting_sidebar template, which calls the helper at line 4. Opening Plugins therefore fails with:

undefined method 'kaui_admin_screens_allowed?' for an instance of #<Class:0x...>

Seen on dev (WAR built from Kaui 35a7eb8, with killbill-kpm-ui 4.0.7). Any other non-Kaui engine controller rendering the Kaui layout would hit the same error.

Fix

  • Move the view helper to Kaui::PermissionsHelper, which Kaui::Engine loads into every controller. For non-Kaui controllers it builds a Kaui::Ability itself, because their current_ability is not a Kaui one.
  • Remove the helper_method from Kaui::EngineController. It keeps its own method for require_kaui_admin_screens!.

Testing

Added test/integration/kaui/other_engine_settings_sidebar_test.rb: a controller that does not inherit from Kaui::EngineController renders the kaui/layouts/kaui_setting_sidebar template, for a regular user, a Cognito bearer user without the *:* role (admin links hidden) and one holding it (admin links shown).

  • With this change: 3 runs, 0 failures (Ruby 3.2.2, MySQL 8.0). cognito_admin_screens_test.rb still passes.
  • Against master's engine_controller.rb and permissions_helper.rb: the 3 tests fail with undefined method 'kaui_admin_screens_allowed?' (HTTP 500).

Not checked on a deployed instance: open Settings > Plugins after rebuilding the WAR.

🤖 Generated with Claude Code

tungleduyxyz and others added 2 commits December 6, 2026 21:30
…rollers

The Kaui layout (navbar, settings sidebar) calls kaui_admin_screens_allowed?, which was
exposed with helper_method in Kaui::EngineController. The controllers of the other engines
(Kanaui, Kenui, Avatax, ...) render the same layout but do not inherit from it, so their
pages failed with "undefined method 'kaui_admin_screens_allowed?'".

Move the view helper to Kaui::PermissionsHelper, which Kaui::Engine makes available to every
controller. Kaui::EngineController keeps its own method for require_kaui_admin_screens!.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… page renders the Kaui sidebar

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@tungleduyxyz tungleduyxyz changed the title Make kaui_admin_screens_allowed? available to the other engines' controllers Fix undefined kaui_admin_screens_allowed? on the Plugins page (KPM) Dec 6, 2026
…ntroller

Covers the Plugins page failure (undefined method 'kaui_admin_screens_allowed?'): a controller
that does not inherit from Kaui::EngineController renders the kaui_setting_sidebar template,
for a regular user, a Cognito bearer user without the *:* role and one holding it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

Plugins page fails with undefined method 'kaui_admin_screens_allowed?'

1 participant