Admin section refactor (#6033)

* Remove plugin warning

- No longer needed as plugins are automatically reloaded

* Move ProjectCodeTable to admin interface

* Move CustomUnits table

* Transfer PartParameterTemplateTable

* Tweak user menu

* Fix unused imports
This commit is contained in:
Oliver 2023-12-05 19:03:09 +11:00 committed by GitHub
parent 03a8190195
commit 8605832693
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 63 additions and 56 deletions

View File

@ -34,15 +34,6 @@ export function MainMenu() {
</UnstyledButton> </UnstyledButton>
</Menu.Target> </Menu.Target>
<Menu.Dropdown> <Menu.Dropdown>
{userState.user?.is_staff && (
<Menu.Item
icon={<IconUserBolt />}
component={Link}
to="/settings/admin"
>
<Trans>Admin Center</Trans>
</Menu.Item>
)}
<Menu.Label> <Menu.Label>
<Trans>Settings</Trans> <Trans>Settings</Trans>
</Menu.Label> </Menu.Label>
@ -58,8 +49,17 @@ export function MainMenu() {
<Trans>System Settings</Trans> <Trans>System Settings</Trans>
</Menu.Item> </Menu.Item>
)} )}
{userState.user?.is_staff && <Menu.Divider />}
{userState.user?.is_staff && (
<Menu.Item
icon={<IconUserBolt />}
component={Link}
to="/settings/admin"
>
<Trans>Admin Center</Trans>
</Menu.Item>
)}
<Menu.Divider /> <Menu.Divider />
<Menu.Item <Menu.Item
icon={<IconLogout />} icon={<IconLogout />}
onClick={() => { onClick={() => {

View File

@ -17,7 +17,7 @@ import { TableColumn } from '../Column';
import { InvenTreeTable } from '../InvenTreeTable'; import { InvenTreeTable } from '../InvenTreeTable';
import { RowDeleteAction, RowEditAction } from '../RowActions'; import { RowDeleteAction, RowEditAction } from '../RowActions';
export function PartParameterTemplateTable() { export default function PartParameterTemplateTable() {
const table = useTable('part-parameter-templates'); const table = useTable('part-parameter-templates');
const user = useUserState(); const user = useUserState();

View File

@ -19,7 +19,7 @@ import { RowAction, RowDeleteAction, RowEditAction } from '../RowActions';
/** /**
* Table for displaying list of custom physical units * Table for displaying list of custom physical units
*/ */
export function CustomUnitsTable() { export default function CustomUnitsTable() {
const table = useTable('custom-units'); const table = useTable('custom-units');
const user = useUserState(); const user = useUserState();

View File

@ -20,7 +20,7 @@ import { RowAction, RowDeleteAction, RowEditAction } from '../RowActions';
/** /**
* Table for displaying list of project codes * Table for displaying list of project codes
*/ */
export function ProjectCodeTable() { export default function ProjectCodeTable() {
const table = useTable('project-codes'); const table = useTable('project-codes');
const user = useUserState(); const user = useUserState();

View File

@ -1,20 +1,43 @@
import { Trans, t } from '@lingui/macro'; import { Trans, t } from '@lingui/macro';
import { Paper, SimpleGrid, Stack, Text, Title } from '@mantine/core'; import { Divider, Paper, SimpleGrid, Stack, Text, Title } from '@mantine/core';
import { IconPlugConnected, IconUsersGroup } from '@tabler/icons-react'; import {
IconList,
IconListDetails,
IconPlugConnected,
IconScale,
IconUsersGroup
} from '@tabler/icons-react';
import { lazy, useMemo } from 'react'; import { lazy, useMemo } from 'react';
import { PlaceholderPill } from '../../../../components/items/Placeholder'; import { PlaceholderPill } from '../../../../components/items/Placeholder';
import { PanelGroup, PanelType } from '../../../../components/nav/PanelGroup'; import { PanelGroup, PanelType } from '../../../../components/nav/PanelGroup';
import { SettingsHeader } from '../../../../components/nav/SettingsHeader'; import { SettingsHeader } from '../../../../components/nav/SettingsHeader';
import { GlobalSettingList } from '../../../../components/settings/SettingList';
import { Loadable } from '../../../../functions/loading'; import { Loadable } from '../../../../functions/loading';
const UserManagementPanel = Loadable( const UserManagementPanel = Loadable(
lazy(() => import('./UserManagementPanel')) lazy(() => import('./UserManagementPanel'))
); );
const PluginManagementPanel = Loadable( const PluginManagementPanel = Loadable(
lazy(() => import('./PluginManagementPanel')) lazy(() => import('./PluginManagementPanel'))
); );
const ProjectCodeTable = Loadable(
lazy(() => import('../../../../components/tables/settings/ProjectCodeTable'))
);
const CustomUnitsTable = Loadable(
lazy(() => import('../../../../components/tables/settings/CustomUnitsTable'))
);
const PartParameterTemplateTable = Loadable(
lazy(
() =>
import('../../../../components/tables/part/PartParameterTemplateTable')
)
);
export default function AdminCenter() { export default function AdminCenter() {
const adminCenterPanels: PanelType[] = useMemo(() => { const adminCenterPanels: PanelType[] = useMemo(() => {
return [ return [
@ -24,6 +47,30 @@ export default function AdminCenter() {
icon: <IconUsersGroup />, icon: <IconUsersGroup />,
content: <UserManagementPanel /> content: <UserManagementPanel />
}, },
{
name: 'projectcodes',
label: t`Project Codes`,
icon: <IconListDetails />,
content: (
<Stack spacing="xs">
<GlobalSettingList keys={['PROJECT_CODES_ENABLED']} />
<Divider />
<ProjectCodeTable />
</Stack>
)
},
{
name: 'customunits',
label: t`Custom Units`,
icon: <IconScale />,
content: <CustomUnitsTable />
},
{
name: 'parameters',
label: t`Part Parameters`,
icon: <IconList />,
content: <PartParameterTemplateTable />
},
{ {
name: 'plugin', name: 'plugin',
label: t`Plugins`, label: t`Plugins`,

View File

@ -1,6 +1,6 @@
import { Trans } from '@lingui/macro'; import { Trans } from '@lingui/macro';
import { Alert, Stack, Title } from '@mantine/core'; import { Alert, Stack, Title } from '@mantine/core';
import { IconAlertTriangle, IconInfoCircle } from '@tabler/icons-react'; import { IconInfoCircle } from '@tabler/icons-react';
import { GlobalSettingList } from '../../../../components/settings/SettingList'; import { GlobalSettingList } from '../../../../components/settings/SettingList';
import { PluginErrorTable } from '../../../../components/tables/plugin/PluginErrorTable'; import { PluginErrorTable } from '../../../../components/tables/plugin/PluginErrorTable';
@ -39,16 +39,6 @@ export default function PluginManagementPanel() {
<Title order={5}> <Title order={5}>
<Trans>Plugin Settings</Trans> <Trans>Plugin Settings</Trans>
</Title> </Title>
<Alert
icon={<IconAlertTriangle />}
color="yellow"
title={<Trans>Warning</Trans>}
>
<Trans>
Changing the settings below require you to immediately restart the
server. Do not change this while under active usage.
</Trans>
</Alert>
<GlobalSettingList <GlobalSettingList
keys={[ keys={[
'ENABLE_PLUGINS_SCHEDULE', 'ENABLE_PLUGINS_SCHEDULE',

View File

@ -7,11 +7,8 @@ import {
IconCurrencyDollar, IconCurrencyDollar,
IconFileAnalytics, IconFileAnalytics,
IconFingerprint, IconFingerprint,
IconList,
IconListDetails,
IconPackages, IconPackages,
IconQrcode, IconQrcode,
IconScale,
IconServerCog, IconServerCog,
IconShoppingCart, IconShoppingCart,
IconSitemap, IconSitemap,
@ -25,10 +22,7 @@ import { StylishText } from '../../../components/items/StylishText';
import { PanelGroup, PanelType } from '../../../components/nav/PanelGroup'; import { PanelGroup, PanelType } from '../../../components/nav/PanelGroup';
import { SettingsHeader } from '../../../components/nav/SettingsHeader'; import { SettingsHeader } from '../../../components/nav/SettingsHeader';
import { GlobalSettingList } from '../../../components/settings/SettingList'; import { GlobalSettingList } from '../../../components/settings/SettingList';
import { PartParameterTemplateTable } from '../../../components/tables/part/PartParameterTemplateTable';
import { CurrencyTable } from '../../../components/tables/settings/CurrencyTable'; import { CurrencyTable } from '../../../components/tables/settings/CurrencyTable';
import { CustomUnitsTable } from '../../../components/tables/settings/CustomUnitsTable';
import { ProjectCodeTable } from '../../../components/tables/settings/ProjectCodeTable';
import { useServerApiState } from '../../../states/ApiState'; import { useServerApiState } from '../../../states/ApiState';
/** /**
@ -101,24 +95,6 @@ export default function SystemSettings() {
/> />
) )
}, },
{
name: 'projectcodes',
label: t`Project Codes`,
icon: <IconListDetails />,
content: (
<Stack spacing="xs">
<GlobalSettingList keys={['PROJECT_CODES_ENABLED']} />
<Divider />
<ProjectCodeTable />
</Stack>
)
},
{
name: 'physicalunits',
label: t`Physical Units`,
icon: <IconScale />,
content: <CustomUnitsTable />
},
{ {
name: 'notifications', name: 'notifications',
label: t`Notifications`, label: t`Notifications`,
@ -219,12 +195,6 @@ export default function SystemSettings() {
/> />
) )
}, },
{
name: 'parameters',
label: t`Part Parameters`,
icon: <IconList />,
content: <PartParameterTemplateTable />
},
{ {
name: 'stock', name: 'stock',
label: t`Stock`, label: t`Stock`,