mirror of
https://github.com/inventree/InvenTree.git
synced 2026-09-27 14:16:02 +00:00
UI plugins custom features (#8137)
* initial implementation to let plugins provide custom ui features
* provide exportable types
* refactor ref into renderContext to make it more generic and support template preview area ui plugins
* rename 'renderContext' -> 'featureContext' as not all features may render something
* allow to specify the function name via the source file string divided by a colon
* Bump api version
* add tests
* add docs
* add docs
* debug: workflow
* debug: workflow
* fix tests
* fix tests hopefully
* apply suggestions from codereview
* trigger: ci
* Prove that coverage does not work
* Revert "Prove that coverage does not work"
This reverts commit 920c58ea6f.
* potentially fix test???
This commit is contained in:
@@ -122,3 +122,36 @@ class SampleUserInterfacePlugin(SettingsMixin, UserInterfaceMixin, InvenTreePlug
|
||||
})
|
||||
|
||||
return panels
|
||||
|
||||
def get_ui_features(self, feature_type, context, request):
|
||||
"""Return a list of custom features to be injected into the UI."""
|
||||
if (
|
||||
feature_type == 'template_editor'
|
||||
and context.get('template_type') == 'labeltemplate'
|
||||
):
|
||||
return [
|
||||
{
|
||||
'feature_type': 'template_editor',
|
||||
'options': {
|
||||
'key': 'sample-template-editor',
|
||||
'title': 'Sample Template Editor',
|
||||
'icon': 'keywords',
|
||||
},
|
||||
'source': '/static/plugin/sample_template.js:getTemplateEditor',
|
||||
}
|
||||
]
|
||||
|
||||
if feature_type == 'template_preview':
|
||||
return [
|
||||
{
|
||||
'feature_type': 'template_preview',
|
||||
'options': {
|
||||
'key': 'sample-template-preview',
|
||||
'title': 'Sample Template Preview',
|
||||
'icon': 'category',
|
||||
},
|
||||
'source': '/static/plugin/sample_template.js:getTemplatePreview',
|
||||
}
|
||||
]
|
||||
|
||||
return []
|
||||
|
||||
Reference in New Issue
Block a user