2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 11:36:44 +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:
Oliver 2024-12-19 07:31:59 +11:00 committed by GitHub
parent 1c9f56011c
commit e37e72357a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 18 additions and 177 deletions

View File

@ -31,9 +31,7 @@ Configuration of basic server settings:
{{ globalsetting("INVENTREE_DOWNLOAD_FROM_URL") }} {{ globalsetting("INVENTREE_DOWNLOAD_FROM_URL") }}
{{ globalsetting("INVENTREE_DOWNLOAD_IMAGE_MAX_SIZE") }} {{ globalsetting("INVENTREE_DOWNLOAD_IMAGE_MAX_SIZE") }}
{{ globalsetting("INVENTREE_DOWNLOAD_FROM_URL_USER_AGENT") }} {{ globalsetting("INVENTREE_DOWNLOAD_FROM_URL_USER_AGENT") }}
{{ globalsetting("INVENTREE_REQUIRE_CONFIRM") }}
{{ globalsetting("INVENTREE_STRICT_URLS") }} {{ globalsetting("INVENTREE_STRICT_URLS") }}
{{ globalsetting("INVENTREE_TREE_DEPTH") }}
{{ globalsetting("INVENTREE_BACKUP_ENABLE") }} {{ globalsetting("INVENTREE_BACKUP_ENABLE") }}
{{ globalsetting("INVENTREE_BACKUP_DAYS") }} {{ globalsetting("INVENTREE_BACKUP_DAYS") }}
{{ globalsetting("INVENTREE_DELETE_TASKS_DAYS") }} {{ globalsetting("INVENTREE_DELETE_TASKS_DAYS") }}

View File

@ -253,20 +253,6 @@ SYSTEM_SETTINGS: dict[str, InvenTreeSettingsKeyType] = {
'validator': bool, 'validator': bool,
'default': True, 'default': True,
}, },
'INVENTREE_REQUIRE_CONFIRM': {
'name': _('Require confirm'),
'description': _('Require explicit user confirmation for certain action.'),
'validator': bool,
'default': True,
},
'INVENTREE_TREE_DEPTH': {
'name': _('Tree Depth'),
'description': _(
'Default tree depth for treeview. Deeper levels can be lazy loaded as they are needed.'
),
'default': 1,
'validator': [int, MinValueValidator(0)],
},
'INVENTREE_UPDATE_CHECK_INTERVAL': { 'INVENTREE_UPDATE_CHECK_INTERVAL': {
'name': _('Update Check Interval'), 'name': _('Update Check Interval'),
'description': _('How often to check for updates (set to zero to disable)'), 'description': _('How often to check for updates (set to zero to disable)'),

View File

@ -19,120 +19,6 @@ def label_printer_options():
USER_SETTINGS: dict[str, InvenTreeSettingsKeyType] = { USER_SETTINGS: dict[str, InvenTreeSettingsKeyType] = {
'HOMEPAGE_HIDE_INACTIVE': {
'name': _('Hide inactive parts'),
'description': _('Hide inactive parts in results displayed on the homepage'),
'default': True,
'validator': bool,
},
'HOMEPAGE_PART_STARRED': {
'name': _('Show subscribed parts'),
'description': _('Show subscribed parts on the homepage'),
'default': True,
'validator': bool,
},
'HOMEPAGE_CATEGORY_STARRED': {
'name': _('Show subscribed categories'),
'description': _('Show subscribed part categories on the homepage'),
'default': True,
'validator': bool,
},
'HOMEPAGE_PART_LATEST': {
'name': _('Show latest parts'),
'description': _('Show latest parts on the homepage'),
'default': True,
'validator': bool,
},
'HOMEPAGE_BOM_REQUIRES_VALIDATION': {
'name': _('Show invalid BOMs'),
'description': _('Show BOMs that await validation on the homepage'),
'default': False,
'validator': bool,
},
'HOMEPAGE_STOCK_RECENT': {
'name': _('Show recent stock changes'),
'description': _('Show recently changed stock items on the homepage'),
'default': True,
'validator': bool,
},
'HOMEPAGE_STOCK_LOW': {
'name': _('Show low stock'),
'description': _('Show low stock items on the homepage'),
'default': True,
'validator': bool,
},
'HOMEPAGE_SHOW_STOCK_DEPLETED': {
'name': _('Show depleted stock'),
'description': _('Show depleted stock items on the homepage'),
'default': False,
'validator': bool,
},
'HOMEPAGE_BUILD_STOCK_NEEDED': {
'name': _('Show needed stock'),
'description': _('Show stock items needed for builds on the homepage'),
'default': False,
'validator': bool,
},
'HOMEPAGE_STOCK_EXPIRED': {
'name': _('Show expired stock'),
'description': _('Show expired stock items on the homepage'),
'default': True,
'validator': bool,
},
'HOMEPAGE_STOCK_STALE': {
'name': _('Show stale stock'),
'description': _('Show stale stock items on the homepage'),
'default': True,
'validator': bool,
},
'HOMEPAGE_BUILD_PENDING': {
'name': _('Show pending builds'),
'description': _('Show pending builds on the homepage'),
'default': True,
'validator': bool,
},
'HOMEPAGE_BUILD_OVERDUE': {
'name': _('Show overdue builds'),
'description': _('Show overdue builds on the homepage'),
'default': True,
'validator': bool,
},
'HOMEPAGE_PO_OUTSTANDING': {
'name': _('Show outstanding POs'),
'description': _('Show outstanding POs on the homepage'),
'default': True,
'validator': bool,
},
'HOMEPAGE_PO_OVERDUE': {
'name': _('Show overdue POs'),
'description': _('Show overdue POs on the homepage'),
'default': True,
'validator': bool,
},
'HOMEPAGE_SO_OUTSTANDING': {
'name': _('Show outstanding SOs'),
'description': _('Show outstanding SOs on the homepage'),
'default': True,
'validator': bool,
},
'HOMEPAGE_SO_OVERDUE': {
'name': _('Show overdue SOs'),
'description': _('Show overdue SOs on the homepage'),
'default': True,
'validator': bool,
},
'HOMEPAGE_SO_SHIPMENTS_PENDING': {
'name': _('Show pending SO shipments'),
'description': _('Show pending SO shipments on the homepage'),
'default': True,
'validator': bool,
},
'HOMEPAGE_NEWS': {
'name': _('Show News'),
'description': _('Show news on the homepage'),
'default': False,
'validator': bool,
},
'LABEL_INLINE': { 'LABEL_INLINE': {
'name': _('Inline label display'), 'name': _('Inline label display'),
'description': _( 'description': _(

View File

@ -628,7 +628,7 @@ class UserSettingsApiTest(InvenTreeAPITestCase):
def test_user_setting_init(self): def test_user_setting_init(self):
"""Test we can retrieve a setting which has not yet been initialized.""" """Test we can retrieve a setting which has not yet been initialized."""
key = 'HOMEPAGE_PART_LATEST' key = 'LABEL_INLINE'
# Ensure it does not actually exist in the database # Ensure it does not actually exist in the database
self.assertFalse(InvenTreeUserSetting.objects.filter(key=key).exists()) self.assertFalse(InvenTreeUserSetting.objects.filter(key=key).exists())

View File

@ -2,14 +2,8 @@
{% load i18n %} {% load i18n %}
{% load inventree_extras %} {% load inventree_extras %}
{% plugins_enabled as plugins_enabled %}
{% settings_value 'BARCODE_ENABLE' as barcodes %}
{% settings_value 'RETURNORDER_ENABLED' as return_order_enabled %}
{% settings_value "REPORT_ENABLE" as report_enabled %}
{% settings_value "SERVER_RESTART_REQUIRED" as server_restart_required %} {% settings_value "SERVER_RESTART_REQUIRED" as server_restart_required %}
{% settings_value "_PENDING_MIGRATIONS" as pending_migrations %} {% settings_value "_PENDING_MIGRATIONS" as pending_migrations %}
{% settings_value "LABEL_ENABLE" as labels_enabled %}
{% inventree_show_about user as show_about %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">

View File

@ -11,7 +11,10 @@ import { extractAvailableFields } from '../../functions/forms';
import { generateUrl } from '../../functions/urls'; import { generateUrl } from '../../functions/urls';
import { useCreateApiFormModal } from '../../hooks/UseForm'; import { useCreateApiFormModal } from '../../hooks/UseForm';
import { apiUrl } from '../../states/ApiState'; import { apiUrl } from '../../states/ApiState';
import { useUserSettingsState } from '../../states/SettingsState'; import {
useGlobalSettingsState,
useUserSettingsState
} from '../../states/SettingsState';
import type { ApiFormFieldSet } from '../forms/fields/ApiFormField'; import type { ApiFormFieldSet } from '../forms/fields/ApiFormField';
import { ActionDropdown } from '../items/ActionDropdown'; import { ActionDropdown } from '../items/ActionDropdown';
@ -29,14 +32,23 @@ export function PrintingActions({
modelType?: ModelType; modelType?: ModelType;
}) { }) {
const userSettings = useUserSettingsState(); const userSettings = useUserSettingsState();
const globalSettings = useGlobalSettingsState();
const enabled = useMemo(() => items.length > 0, [items]); const enabled = useMemo(() => items.length > 0, [items]);
const [pluginKey, setPluginKey] = useState<string>(''); 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 // Fetch available printing fields via OPTIONS request
const printingFields = useQuery({ const printingFields = useQuery({
enabled: enableLabels, enabled: labelPrintingEnabled,
queryKey: ['printingFields', modelType, pluginKey], queryKey: ['printingFields', modelType, pluginKey],
gcTime: 500, gcTime: 500,
queryFn: () => queryFn: () =>
@ -162,7 +174,7 @@ export function PrintingActions({
return null; return null;
} }
if (!enableLabels && !enableReports) { if (!labelPrintingEnabled && !reportPrintingEnabled) {
return null; return null;
} }
@ -180,13 +192,13 @@ export function PrintingActions({
name: t`Print Labels`, name: t`Print Labels`,
icon: <IconTags />, icon: <IconTags />,
onClick: () => labelModal.open(), onClick: () => labelModal.open(),
hidden: !enableLabels hidden: !labelPrintingEnabled
}, },
{ {
name: t`Print Reports`, name: t`Print Reports`,
icon: <IconReport />, icon: <IconReport />,
onClick: () => reportModal.open(), onClick: () => reportModal.open(),
hidden: !enableReports hidden: !reportPrintingEnabled
} }
]} ]}
/> />

View File

@ -50,9 +50,7 @@ export default function SystemSettings() {
'INVENTREE_DOWNLOAD_FROM_URL', 'INVENTREE_DOWNLOAD_FROM_URL',
'INVENTREE_DOWNLOAD_IMAGE_MAX_SIZE', 'INVENTREE_DOWNLOAD_IMAGE_MAX_SIZE',
'INVENTREE_DOWNLOAD_FROM_URL_USER_AGENT', 'INVENTREE_DOWNLOAD_FROM_URL_USER_AGENT',
'INVENTREE_REQUIRE_CONFIRM',
'INVENTREE_STRICT_URLS', 'INVENTREE_STRICT_URLS',
'INVENTREE_TREE_DEPTH',
'INVENTREE_BACKUP_ENABLE', 'INVENTREE_BACKUP_ENABLE',
'INVENTREE_BACKUP_DAYS', 'INVENTREE_BACKUP_DAYS',
'INVENTREE_DELETE_TASKS_DAYS', 'INVENTREE_DELETE_TASKS_DAYS',

View File

@ -3,7 +3,6 @@ import { Skeleton, Stack } from '@mantine/core';
import { import {
IconBellCog, IconBellCog,
IconDeviceDesktop, IconDeviceDesktop,
IconDeviceDesktopAnalytics,
IconFileAnalytics, IconFileAnalytics,
IconLock, IconLock,
IconSearch, IconSearch,
@ -43,38 +42,6 @@ export default function UserSettings() {
icon: <IconLock />, icon: <IconLock />,
content: <SecurityContent /> 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', name: 'display',
label: t`Display Options`, label: t`Display Options`,