From 9c906237a0164d905c576a3a4433be304261ff39 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 1 Oct 2024 14:30:55 +0000 Subject: [PATCH] Add custom settings UI elements --- frontend/src/WirevizSettings.tsx | 30 ++++++++++++++++++++++++++++++ frontend/vite.config.ts | 3 ++- inventree_wireviz/wireviz.py | 3 +++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 frontend/src/WirevizSettings.tsx diff --git a/frontend/src/WirevizSettings.tsx b/frontend/src/WirevizSettings.tsx new file mode 100644 index 0000000..edb1c0c --- /dev/null +++ b/frontend/src/WirevizSettings.tsx @@ -0,0 +1,30 @@ +import { Alert, MantineProvider, Stack, Text } from '@mantine/core'; +import { StrictMode } from 'react'; +import { createRoot } from 'react-dom/client'; + + +function WirevizSettings({context}: {context: any}) { + + console.log("settings context:", context); + + return ( + + + Check it out - custom settings code!! + + + ); +} + + +export function renderPluginSettings(target: HTMLElement | null, context: any) { + + createRoot(target!).render( + + + + + + ); +} + diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 4cc3cfc..6ca8c0d 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -10,7 +10,8 @@ export default defineConfig({ rollupOptions: { preserveEntrySignatures: "exports-only", input: [ - './src/WirevizPanel.tsx' + './src/WirevizPanel.tsx', + './src/WirevizSettings.tsx', ], output: { dir: '../inventree_wireviz/static', diff --git a/inventree_wireviz/wireviz.py b/inventree_wireviz/wireviz.py index 9bce586..03474dd 100644 --- a/inventree_wireviz/wireviz.py +++ b/inventree_wireviz/wireviz.py @@ -44,6 +44,9 @@ class WirevizPlugin(PanelMixin, ReportMixin, SettingsMixin, UrlsMixin, UserInter SLUG = "wireviz" TITLE = "Wireviz Plugin" + # Javascript file which renders custom plugin settings + ADMIN_PANEL_JS_FILE = "WirevizSettings.js" + # Filenames and key constants HARNESS_SVG_FILE = "wireviz_harness.svg"