feat(frontend): Add option for plugins to add header actions (#9570)

* [FR] PUI - Add option for plugins to add header actions
Fixes #8593

* fix parsing

* fix merge

* reduce diff

* fix sample implementation

* add support for icons and colors in primary actions

* add changelog entry

* add docs

* add more detailed sample text

* pass location into context

* fix test

---------

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
Matthias Mair
2026-05-22 08:20:07 +10:00
committed by GitHub
co-authored by Oliver
parent 65d15a5945
commit f27b9b5443
10 changed files with 122 additions and 10 deletions
@@ -226,6 +226,17 @@ class SampleUserInterfacePlugin(SettingsMixin, UserInterfaceMixin, InvenTreePlug
}
]
def get_ui_primary_actions(self, request, context, **kwargs):
"""Return a list of custom primary action buttons."""
return [
{
'key': 'sample-primary-action',
'title': 'Sample Primary Action',
'icon': 'ti:plus:outline',
'options': {'url': '/core/sample-primary-action/', 'color': 'orange'},
}
]
def get_admin_context(self) -> dict:
"""Return custom context data which can be rendered in the admin panel."""
return {'apple': 'banana', 'foo': 'bar', 'hello': 'world'}