mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-16 12:05:53 +00:00
Cleanup old settings (#8709)
* Use LABEL_ENABLE and REPORT_ENABLE settings in PUI * Cleanup base.html - Should reduce db hits slightly * Remove defunct homepage settings * Cleanup old settings * Adjust unit test
This commit is contained in:
@ -11,7 +11,10 @@ import { extractAvailableFields } from '../../functions/forms';
|
||||
import { generateUrl } from '../../functions/urls';
|
||||
import { useCreateApiFormModal } from '../../hooks/UseForm';
|
||||
import { apiUrl } from '../../states/ApiState';
|
||||
import { useUserSettingsState } from '../../states/SettingsState';
|
||||
import {
|
||||
useGlobalSettingsState,
|
||||
useUserSettingsState
|
||||
} from '../../states/SettingsState';
|
||||
import type { ApiFormFieldSet } from '../forms/fields/ApiFormField';
|
||||
import { ActionDropdown } from '../items/ActionDropdown';
|
||||
|
||||
@ -29,14 +32,23 @@ export function PrintingActions({
|
||||
modelType?: ModelType;
|
||||
}) {
|
||||
const userSettings = useUserSettingsState();
|
||||
const globalSettings = useGlobalSettingsState();
|
||||
|
||||
const enabled = useMemo(() => items.length > 0, [items]);
|
||||
|
||||
const [pluginKey, setPluginKey] = useState<string>('');
|
||||
|
||||
const labelPrintingEnabled = useMemo(() => {
|
||||
return enableLabels && globalSettings.isSet('LABEL_ENABLE');
|
||||
}, [enableLabels, globalSettings]);
|
||||
|
||||
const reportPrintingEnabled = useMemo(() => {
|
||||
return enableReports && globalSettings.isSet('REPORT_ENABLE');
|
||||
}, [enableReports, globalSettings]);
|
||||
|
||||
// Fetch available printing fields via OPTIONS request
|
||||
const printingFields = useQuery({
|
||||
enabled: enableLabels,
|
||||
enabled: labelPrintingEnabled,
|
||||
queryKey: ['printingFields', modelType, pluginKey],
|
||||
gcTime: 500,
|
||||
queryFn: () =>
|
||||
@ -162,7 +174,7 @@ export function PrintingActions({
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!enableLabels && !enableReports) {
|
||||
if (!labelPrintingEnabled && !reportPrintingEnabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -180,13 +192,13 @@ export function PrintingActions({
|
||||
name: t`Print Labels`,
|
||||
icon: <IconTags />,
|
||||
onClick: () => labelModal.open(),
|
||||
hidden: !enableLabels
|
||||
hidden: !labelPrintingEnabled
|
||||
},
|
||||
{
|
||||
name: t`Print Reports`,
|
||||
icon: <IconReport />,
|
||||
onClick: () => reportModal.open(),
|
||||
hidden: !enableReports
|
||||
hidden: !reportPrintingEnabled
|
||||
}
|
||||
]}
|
||||
/>
|
||||
|
@ -50,9 +50,7 @@ export default function SystemSettings() {
|
||||
'INVENTREE_DOWNLOAD_FROM_URL',
|
||||
'INVENTREE_DOWNLOAD_IMAGE_MAX_SIZE',
|
||||
'INVENTREE_DOWNLOAD_FROM_URL_USER_AGENT',
|
||||
'INVENTREE_REQUIRE_CONFIRM',
|
||||
'INVENTREE_STRICT_URLS',
|
||||
'INVENTREE_TREE_DEPTH',
|
||||
'INVENTREE_BACKUP_ENABLE',
|
||||
'INVENTREE_BACKUP_DAYS',
|
||||
'INVENTREE_DELETE_TASKS_DAYS',
|
||||
|
@ -3,7 +3,6 @@ import { Skeleton, Stack } from '@mantine/core';
|
||||
import {
|
||||
IconBellCog,
|
||||
IconDeviceDesktop,
|
||||
IconDeviceDesktopAnalytics,
|
||||
IconFileAnalytics,
|
||||
IconLock,
|
||||
IconSearch,
|
||||
@ -43,38 +42,6 @@ export default function UserSettings() {
|
||||
icon: <IconLock />,
|
||||
content: <SecurityContent />
|
||||
},
|
||||
{
|
||||
name: 'dashboard',
|
||||
label: t`Dashboard`,
|
||||
icon: <IconDeviceDesktopAnalytics />,
|
||||
content: (
|
||||
<UserSettingList
|
||||
keys={[
|
||||
// TODO: These will be replaced with "dashboard" settings,
|
||||
// once the new dashboard is implemented
|
||||
'HOMEPAGE_HIDE_INACTIVE',
|
||||
'HOMEPAGE_PART_STARRED',
|
||||
'HOMEPAGE_CATEGORY_STARRED',
|
||||
'HOMEPAGE_PART_LATEST',
|
||||
'HOMEPAGE_BOM_REQUIRES_VALIDATION',
|
||||
'HOMEPAGE_STOCK_RECENT',
|
||||
'HOMEPAGE_STOCK_LOW',
|
||||
'HOMEPAGE_SHOW_STOCK_DEPLETED',
|
||||
'HOMEPAGE_BUILD_STOCK_NEEDED',
|
||||
'HOMEPAGE_STOCK_EXPIRED',
|
||||
'HOMEPAGE_STOCK_STALE',
|
||||
'HOMEPAGE_BUILD_PENDING',
|
||||
'HOMEPAGE_BUILD_OVERDUE',
|
||||
'HOMEPAGE_PO_OUTSTANDING',
|
||||
'HOMEPAGE_PO_OVERDUE',
|
||||
'HOMEPAGE_SO_OUTSTANDING',
|
||||
'HOMEPAGE_SO_OVERDUE',
|
||||
'HOMEPAGE_SO_SHIPMENTS_PENDING',
|
||||
'HOMEPAGE_NEWS'
|
||||
]}
|
||||
/>
|
||||
)
|
||||
},
|
||||
{
|
||||
name: 'display',
|
||||
label: t`Display Options`,
|
||||
|
Reference in New Issue
Block a user