Skip to content

Commit

Permalink
Add custom settings UI elements
Browse files Browse the repository at this point in the history
  • Loading branch information
SchrodingersGat committed Oct 1, 2024
1 parent ff5734a commit 9c90623
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
30 changes: 30 additions & 0 deletions frontend/src/WirevizSettings.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<Stack gap="xs">
<Alert color="green" title="Hello World">
<Text>Check it out - custom settings code!!</Text>
</Alert>
</Stack>
);
}


export function renderPluginSettings(target: HTMLElement | null, context: any) {

createRoot(target!).render(
<StrictMode>
<MantineProvider>
<WirevizSettings context={context} />
</MantineProvider>
</StrictMode>
);
}

3 changes: 2 additions & 1 deletion frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 3 additions & 0 deletions inventree_wireviz/wireviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit 9c90623

Please sign in to comment.