mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Framework for a sample plugin which implements custom panels
This commit is contained in:
parent
d25613ac3f
commit
587ad8d09d
@ -8,7 +8,7 @@ import logging
|
||||
logger = logging.getLogger('inventree')
|
||||
|
||||
|
||||
class UserIterfaceMixin:
|
||||
class UserInterfaceMixin:
|
||||
"""Plugin mixin class which handles injection of custom elements into the front-end interface.
|
||||
|
||||
- All content is accessed via the API, as requested by the user interface.
|
||||
|
@ -14,7 +14,7 @@ from plugin.base.integration.ReportMixin import ReportMixin
|
||||
from plugin.base.integration.ScheduleMixin import ScheduleMixin
|
||||
from plugin.base.integration.SettingsMixin import SettingsMixin
|
||||
from plugin.base.integration.UrlsMixin import UrlsMixin
|
||||
from plugin.base.integration.UserInterfaceMixin import UserIterfaceMixin
|
||||
from plugin.base.integration.UserInterfaceMixin import UserInterfaceMixin
|
||||
from plugin.base.integration.ValidationMixin import ValidationMixin
|
||||
from plugin.base.label.mixins import LabelPrintingMixin
|
||||
from plugin.base.locate.mixins import LocateMixin
|
||||
@ -32,7 +32,7 @@ __all__ = [
|
||||
'SettingsContentMixin',
|
||||
'SettingsMixin',
|
||||
'UrlsMixin',
|
||||
'UserIterfaceMixin',
|
||||
'UserInterfaceMixin',
|
||||
'PanelMixin',
|
||||
'ActionMixin',
|
||||
'BarcodeMixin',
|
||||
|
@ -0,0 +1,31 @@
|
||||
"""Sample plugin which demonstrates user interface integrations."""
|
||||
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from plugin import InvenTreePlugin
|
||||
from plugin.mixins import SettingsMixin, UserInterfaceMixin
|
||||
|
||||
|
||||
class SampleUserInterfacePlugin(SettingsMixin, UserInterfaceMixin, InvenTreePlugin):
|
||||
"""A sample plugin which demonstrates user interface integrations."""
|
||||
|
||||
NAME = 'SampleUI'
|
||||
SLUG = 'sampleui'
|
||||
TITLE = 'Sample User Interface Plugin'
|
||||
DESCRIPTION = 'A sample plugin which demonstrates user interface integrations'
|
||||
VERSION = '1.0'
|
||||
|
||||
SETTINGS = {
|
||||
'ENABLE_PART_PANELS': {
|
||||
'name': _('Enable Part Panels'),
|
||||
'description': _('Enable custom panels for Part views'),
|
||||
'default': True,
|
||||
'validator': bool,
|
||||
},
|
||||
'ENABLE_PURCHASE_ORDER_PANELS': {
|
||||
'name': _('Enable Purchase Order Panels'),
|
||||
'description': _('Enable custom panels for Purchase Order views'),
|
||||
'default': False,
|
||||
'validator': bool,
|
||||
},
|
||||
}
|
@ -1,12 +1,14 @@
|
||||
import { Trans, t } from '@lingui/macro';
|
||||
import { Accordion, Alert, Stack } from '@mantine/core';
|
||||
import { IconInfoCircle } from '@tabler/icons-react';
|
||||
import { userInfo } from 'os';
|
||||
import { lazy } from 'react';
|
||||
|
||||
import { StylishText } from '../../../../components/items/StylishText';
|
||||
import { GlobalSettingList } from '../../../../components/settings/SettingList';
|
||||
import { Loadable } from '../../../../functions/loading';
|
||||
import { useServerApiState } from '../../../../states/ApiState';
|
||||
import { useUserState } from '../../../../states/UserState';
|
||||
|
||||
const PluginListTable = Loadable(
|
||||
lazy(() => import('../../../../tables/plugin/PluginListTable'))
|
||||
@ -21,6 +23,8 @@ export default function PluginManagementPanel() {
|
||||
(state) => state.server.plugins_enabled
|
||||
);
|
||||
|
||||
const user = useUserState();
|
||||
|
||||
return (
|
||||
<Stack>
|
||||
{!pluginsEnabled && (
|
||||
@ -45,15 +49,6 @@ export default function PluginManagementPanel() {
|
||||
</Accordion.Panel>
|
||||
</Accordion.Item>
|
||||
|
||||
<Accordion.Item value="pluginerror">
|
||||
<Accordion.Control>
|
||||
<StylishText size="lg">{t`Plugin Errors`}</StylishText>
|
||||
</Accordion.Control>
|
||||
<Accordion.Panel>
|
||||
<PluginErrorTable />
|
||||
</Accordion.Panel>
|
||||
</Accordion.Item>
|
||||
|
||||
<Accordion.Item value="pluginsettings">
|
||||
<Accordion.Control>
|
||||
<StylishText size="lg">{t`Plugin Settings`}</StylishText>
|
||||
@ -73,6 +68,16 @@ export default function PluginManagementPanel() {
|
||||
/>
|
||||
</Accordion.Panel>
|
||||
</Accordion.Item>
|
||||
{user.isSuperuser() && (
|
||||
<Accordion.Item value="pluginerror">
|
||||
<Accordion.Control>
|
||||
<StylishText size="lg">{t`Plugin Errors`}</StylishText>
|
||||
</Accordion.Control>
|
||||
<Accordion.Panel>
|
||||
<PluginErrorTable />
|
||||
</Accordion.Panel>
|
||||
</Accordion.Item>
|
||||
)}
|
||||
</Accordion>
|
||||
</Stack>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user