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 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" 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..64c8928 --- /dev/null +++ b/plugin_creator/template/{{ cookiecutter.plugin_name }}/frontend/src/Spotlight.tsx @@ -0,0 +1,15 @@ + +// 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: InvenTreePluginContext) { + + // Simply display an alert when the action is executed + // Replace this with any custom action + alert(`Hello, ${context.user?.username?.()}`); +} 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",