Skip to content

Commit 4be4f2f

Browse files
Merge pull request #89 from inventree/spotlight-actions
Spotlight actions
2 parents e2b9f30 + 432bdf9 commit 4be4f2f

File tree

7 files changed

+37
-3
lines changed

7 files changed

+37
-3
lines changed

.github/workflows/build.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ jobs:
5353
test -f MyCustomPlugin/frontend/README.md
5454
test -f MyCustomPlugin/frontend/vite.config.ts
5555
test -f MyCustomPlugin/frontend/src/Panel.tsx
56+
test -f MyCustomPlugin/frontend/src/Settings.tsx
57+
test -f MyCustomPlugin/frontend/src/Dashboard.tsx
58+
test -f MyCustomPlugin/frontend/src/Spotlight.tsx
5659
- name: Build and Install Plugin
5760
run: |
5861
cd output/MyCustomPlugin

plugin_creator/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# -*- coding: utf-8 -*-
22

3-
PLUGIN_CREATOR_VERSION = "1.13.4"
3+
PLUGIN_CREATOR_VERSION = "1.14.0"

plugin_creator/frontend.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def frontend_features() -> dict:
1919
"dashboard": "Custom dashboard items",
2020
"panel": "Custom panel items",
2121
"settings": "Custom settings display",
22+
"spotlight": "Custom spotlight actions",
2223
}
2324

2425

plugin_creator/template/cookiecutter.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
"features": {
3838
"dashboard": true,
3939
"panel": true,
40-
"settings": true
40+
"settings": true,
41+
"spotlight": true
4142
}
4243
}
4344
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
// Import for type checking
3+
import { type InvenTreePluginContext } from '@inventreedb/ui';
4+
5+
/**
6+
* Custom spotlight action with the provided context
7+
* Refer to the InvenTree documentation for the context interface
8+
* https://docs.inventree.org/en/stable/extend/plugins/ui/#plugin-context
9+
*/
10+
export function {{ cookiecutter.plugin_name }}SpotlightAction(context: InvenTreePluginContext) {
11+
12+
// Simply display an alert when the action is executed
13+
// Replace this with any custom action
14+
alert(`Hello, ${context.user?.username?.()}`);
15+
}

plugin_creator/template/{{ cookiecutter.plugin_name }}/{{ cookiecutter.package_name }}/core.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,20 @@ def get_ui_dashboard_items(self, request, context: dict, **kwargs):
188188
})
189189

190190
return items
191+
{% endif %}
192+
193+
{% if cookiecutter.frontend.features.spotlight -%}
194+
def get_ui_spotlight_actions(self, request, context, **kwargs):
195+
"""Return a list of custom spotlight actions to be made available."""
196+
return [
197+
{
198+
'key': 'sample-spotlight-action',
199+
'title': 'Hello Action',
200+
'description': 'Hello from {{ cookiecutter.plugin_name }}',
201+
'icon': 'ti:heart-handshake:outline',
202+
'source': self.plugin_static_file('Spotlight.js:{{ cookiecutter.plugin_name }}SpotlightAction'),
203+
}
204+
]
191205
{%- endif -%}
192206
{%- endif -%}
193207
{%- endif %}

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
66
exclude = [
77
".git",
88
"__pycache__",
9-
"plugin_creator/template/",
9+
"plugin_creator/template",
1010
"test.py",
1111
"tests",
1212
"venv",

0 commit comments

Comments
 (0)