Bug 40095 - It would be beneficial to send the page when calling intranet_js plugin hooks
Summary: It would be beneficial to send the page when calling intranet_js plugin hooks
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Plugin architecture (show other bugs)
Version: unspecified
Hardware: PC Linux
: P1 - high enhancement
Assignee: Martin Renvoize (ashimema)
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-06-09 10:42 UTC by Martin Renvoize (ashimema)
Modified: 2025-06-21 19:33 UTC (History)
2 users (show)

See Also:
GIT URL: https://github.com/openfifth/koha/tree/bug_40095
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 40095: Add context to intranet_js plugin hook (4.12 KB, patch)
2025-06-19 13:00 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 40095: Add context to intranet_js plugin hook (4.17 KB, patch)
2025-06-21 19:33 UTC, Roman Dolny
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Renvoize (ashimema) 2025-06-09 10:42:40 UTC
We have the intranet_js plugin hook to allow adding javascript to all intranet pages.. it would be great to have the specific page the hook is called from get passed so we can optionally run code to generate and return the JS instead of returning it for all pages.
Comment 1 Martin Renvoize (ashimema) 2025-06-19 13:00:39 UTC
Created attachment 183380 [details] [review]
Bug 40095: Add context to intranet_js plugin hook

The get_plugins_intranet_js method now passes the current script name
(controller) to plugins via a 'page' parameter, allowing plugins to
determine which page/controller is being displayed.

This will allow plugin authors to only return JS that's relevant to the
current page when they wish to do so.

Test plan:
1. Create a plugin with an intranet_js method that logs the received parameters
2. Navigate to different pages in the staff interface
3. Verify that the plugin receives the page parameter containing the script name
4. Confirm that the script name reflects the actual controller (e.g.,
   '/cgi-bin/koha/admin/admin-home.pl' when on the admin home page)
5. Run the test: prove t/db_dependent/Koha/Template/Plugin/KohaPlugins.t
6. Verify that the new test passes, confirming plugins receive the page parameter
Comment 2 Roman Dolny 2025-06-21 19:33:48 UTC
Created attachment 183411 [details] [review]
Bug 40095: Add context to intranet_js plugin hook

The get_plugins_intranet_js method now passes the current script name
(controller) to plugins via a 'page' parameter, allowing plugins to
determine which page/controller is being displayed.

This will allow plugin authors to only return JS that's relevant to the
current page when they wish to do so.

Test plan:
1. Create a plugin with an intranet_js method that logs the received parameters
2. Navigate to different pages in the staff interface
3. Verify that the plugin receives the page parameter containing the script name
4. Confirm that the script name reflects the actual controller (e.g.,
   '/cgi-bin/koha/admin/admin-home.pl' when on the admin home page)
5. Run the test: prove t/db_dependent/Koha/Template/Plugin/KohaPlugins.t
6. Verify that the new test passes, confirming plugins receive the page parameter

Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>