From dba0e865a4bd1c1426142a725bdb9390bf134d2b Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 25 Feb 2026 10:36:56 +0000 Subject: [PATCH 1/4] Generate spotlight code --- plugin_creator/frontend.py | 1 + plugin_creator/template/cookiecutter.json | 3 ++- .../frontend/src/Spotlight.tsx | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 plugin_creator/template/{{ cookiecutter.plugin_name }}/frontend/src/Spotlight.tsx diff --git a/plugin_creator/frontend.py b/plugin_creator/frontend.py index b449369..5921351 100644 --- a/plugin_creator/frontend.py +++ b/plugin_creator/frontend.py @@ -19,6 +19,7 @@ def frontend_features() -> dict: "dashboard": "Custom dashboard items", "panel": "Custom panel items", "settings": "Custom settings display", + "spotlight": "Custom spotlight actions", } diff --git a/plugin_creator/template/cookiecutter.json b/plugin_creator/template/cookiecutter.json index 3e29fac..e004e1d 100644 --- a/plugin_creator/template/cookiecutter.json +++ b/plugin_creator/template/cookiecutter.json @@ -37,7 +37,8 @@ "features": { "dashboard": true, "panel": true, - "settings": true + "settings": true, + "spotlight": true } } } \ No newline at end of file diff --git a/plugin_creator/template/{{ cookiecutter.plugin_name }}/frontend/src/Spotlight.tsx b/plugin_creator/template/{{ cookiecutter.plugin_name }}/frontend/src/Spotlight.tsx new file mode 100644 index 0000000..d9f20ae --- /dev/null +++ b/plugin_creator/template/{{ cookiecutter.plugin_name }}/frontend/src/Spotlight.tsx @@ -0,0 +1,19 @@ + +// Import for type checking +import { type InvenTreePluginContext } from '@inventreedb/ui'; + +/** + * Custom spotlight action with the provided context + * Refer to the InvenTree documentation for the context interface + * https://docs.inventree.org/en/stable/extend/plugins/ui/#plugin-context + */ +export function {{ cookiecutter.plugin_name }}SpotlightAction({ + context +}: { + context: InvenTreePluginContext; +}) { + + // Simply display an alert when the action is executed + // Replace this with any custom action + alert(`Hello, ${context.user?.username?.()}`); +} From 1ce660eff1c2c09c16d06cb47eeb0ad8f3af684c Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 25 Feb 2026 10:53:14 +0000 Subject: [PATCH 2/4] Implement back-end code --- .../frontend/src/Spotlight.tsx | 6 +----- .../{{ cookiecutter.package_name }}/core.py | 14 ++++++++++++++ pyproject.toml | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/plugin_creator/template/{{ cookiecutter.plugin_name }}/frontend/src/Spotlight.tsx b/plugin_creator/template/{{ cookiecutter.plugin_name }}/frontend/src/Spotlight.tsx index d9f20ae..64c8928 100644 --- a/plugin_creator/template/{{ cookiecutter.plugin_name }}/frontend/src/Spotlight.tsx +++ b/plugin_creator/template/{{ cookiecutter.plugin_name }}/frontend/src/Spotlight.tsx @@ -7,11 +7,7 @@ import { type InvenTreePluginContext } from '@inventreedb/ui'; * Refer to the InvenTree documentation for the context interface * https://docs.inventree.org/en/stable/extend/plugins/ui/#plugin-context */ -export function {{ cookiecutter.plugin_name }}SpotlightAction({ - context -}: { - context: InvenTreePluginContext; -}) { +export function {{ cookiecutter.plugin_name }}SpotlightAction(context: InvenTreePluginContext) { // Simply display an alert when the action is executed // Replace this with any custom action diff --git a/plugin_creator/template/{{ cookiecutter.plugin_name }}/{{ cookiecutter.package_name }}/core.py b/plugin_creator/template/{{ cookiecutter.plugin_name }}/{{ cookiecutter.package_name }}/core.py index 785b450..a9491f4 100644 --- a/plugin_creator/template/{{ cookiecutter.plugin_name }}/{{ cookiecutter.package_name }}/core.py +++ b/plugin_creator/template/{{ cookiecutter.plugin_name }}/{{ cookiecutter.package_name }}/core.py @@ -188,6 +188,20 @@ def get_ui_dashboard_items(self, request, context: dict, **kwargs): }) return items + {% endif %} + + {% if cookiecutter.frontend.features.spotlight -%} + def get_ui_spotlight_actions(self, request, context, **kwargs): + """Return a list of custom spotlight actions to be made available.""" + return [ + { + 'key': 'sample-spotlight-action', + 'title': 'Hello Action', + 'description': 'Hello from {{ cookiecutter.plugin_name }}', + 'icon': 'ti:heart-handshake:outline', + 'source': self.plugin_static_file('Spotlight.js:{{ cookiecutter.plugin_name }}SpotlightAction'), + } + ] {%- endif -%} {%- endif -%} {%- endif %} diff --git a/pyproject.toml b/pyproject.toml index d8c8ab3..a43006a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta" exclude = [ ".git", "__pycache__", - "plugin_creator/template/", + "plugin_creator/template", "test.py", "tests", "venv", From b2a3c35ac6f12dde5e2700a6fcef666370b6570e Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 25 Feb 2026 10:53:33 +0000 Subject: [PATCH 3/4] Bump creator version --- plugin_creator/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin_creator/__init__.py b/plugin_creator/__init__.py index 3dd9760..5177392 100644 --- a/plugin_creator/__init__.py +++ b/plugin_creator/__init__.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- -PLUGIN_CREATOR_VERSION = "1.13.4" +PLUGIN_CREATOR_VERSION = "1.14.0" From 432bdf99f77b32dbebd798617e7ba0123decd285 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 25 Feb 2026 10:55:09 +0000 Subject: [PATCH 4/4] Extra file checks --- .github/workflows/build.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b1a60bb..fa2d87f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -53,6 +53,9 @@ jobs: test -f MyCustomPlugin/frontend/README.md test -f MyCustomPlugin/frontend/vite.config.ts test -f MyCustomPlugin/frontend/src/Panel.tsx + test -f MyCustomPlugin/frontend/src/Settings.tsx + test -f MyCustomPlugin/frontend/src/Dashboard.tsx + test -f MyCustomPlugin/frontend/src/Spotlight.tsx - name: Build and Install Plugin run: | cd output/MyCustomPlugin