From 4c11f8c911bdca89ecedb341a3490d940048a80e Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Sun, 29 Jun 2025 02:45:51 +0200 Subject: [PATCH] feat(frontend): reduce flickering on reload (#9897) * rename states to better fit naming conv * fix name * ensure splashscreen only loads after login check this reduces a short splash of the splashscreen even if logged in * move loader to the middle of the screen and remove fallback on a view screens --- src/frontend/lib/types/User.tsx | 3 +++ src/frontend/src/components/SplashScreen.tsx | 8 +++++-- .../src/components/barcodes/BarcodeInput.tsx | 2 +- .../src/components/barcodes/QRCode.tsx | 2 +- .../src/components/buttons/AdminButton.tsx | 2 +- .../components/buttons/PrintingActions.tsx | 2 +- .../dashboard/DashboardWidgetLibrary.tsx | 2 +- .../src/components/details/Details.tsx | 2 +- .../src/components/details/DetailsImage.tsx | 2 +- .../src/components/forms/AuthFormOptions.tsx | 2 +- .../components/forms/AuthenticationForm.tsx | 2 +- .../src/components/forms/InstanceOptions.tsx | 2 +- .../components/modals/AboutInvenTreeModal.tsx | 2 +- .../src/components/modals/ServerInfoModal.tsx | 2 +- src/frontend/src/components/nav/Alerts.tsx | 4 ++-- src/frontend/src/components/nav/Header.tsx | 4 ++-- .../src/components/nav/NavigationDrawer.tsx | 2 +- .../src/components/nav/PageDetail.tsx | 2 +- src/frontend/src/components/nav/PageTitle.tsx | 2 +- .../src/components/nav/SearchDrawer.tsx | 2 +- .../src/components/plugins/PluginContext.tsx | 2 +- .../src/components/render/StatusRenderer.tsx | 2 +- .../src/components/settings/SettingList.tsx | 2 +- src/frontend/src/contexts/LanguageContext.tsx | 2 +- src/frontend/src/defaults/formatters.tsx | 2 +- src/frontend/src/forms/BuildForms.tsx | 2 +- src/frontend/src/forms/CommonForms.tsx | 2 +- src/frontend/src/forms/PartForms.tsx | 2 +- src/frontend/src/forms/PurchaseOrderForms.tsx | 2 +- src/frontend/src/forms/ReturnOrderForms.tsx | 2 +- src/frontend/src/forms/SalesOrderForms.tsx | 2 +- src/frontend/src/forms/StockForms.tsx | 2 +- src/frontend/src/functions/auth.tsx | 6 ++++- src/frontend/src/functions/loading.tsx | 23 ++++++++++++++----- src/frontend/src/hooks/UseDashboardItems.tsx | 2 +- src/frontend/src/hooks/UseInstanceName.tsx | 2 +- src/frontend/src/hooks/UsePluginPanels.tsx | 2 +- src/frontend/src/hooks/UsePluginUIFeature.tsx | 2 +- src/frontend/src/hooks/UseStatusCodes.tsx | 2 +- src/frontend/src/pages/Auth/Layout.tsx | 2 +- src/frontend/src/pages/Auth/Login.tsx | 2 +- .../AccountSettings/SecurityContent.tsx | 2 +- .../AdminCenter/PluginManagementPanel.tsx | 2 +- .../pages/Index/Settings/SystemSettings.tsx | 2 +- src/frontend/src/pages/build/BuildDetail.tsx | 2 +- src/frontend/src/pages/build/BuildIndex.tsx | 2 +- src/frontend/src/pages/core/UserDetail.tsx | 2 +- src/frontend/src/pages/part/PartDetail.tsx | 2 +- .../src/pages/part/PartPricingPanel.tsx | 2 +- .../part/pricing/PricingOverviewPanel.tsx | 2 +- .../pages/purchasing/PurchaseOrderDetail.tsx | 2 +- .../src/pages/sales/ReturnOrderDetail.tsx | 2 +- .../src/pages/sales/SalesOrderDetail.tsx | 2 +- src/frontend/src/pages/stock/StockDetail.tsx | 2 +- src/frontend/src/router.tsx | 18 +++++++++++---- ...{StatusState.tsx => GlobalStatusState.tsx} | 0 .../{ApiState.tsx => ServerApiState.tsx} | 0 .../{SettingsState.tsx => SettingsStates.tsx} | 0 src/frontend/src/states/UserState.tsx | 5 ++++ src/frontend/src/states/states.tsx | 6 ++--- src/frontend/src/tables/ColumnRenderers.tsx | 2 +- src/frontend/src/tables/Filter.tsx | 7 ++++-- .../src/tables/build/BuildOrderTable.tsx | 2 +- .../src/tables/plugin/PluginListTable.tsx | 2 +- .../settings/BarcodeScanHistoryTable.tsx | 2 +- .../src/tables/settings/CustomStateTable.tsx | 2 +- .../src/tables/stock/StockItemTable.tsx | 2 +- .../tables/stock/StockItemTestResultTable.tsx | 2 +- src/frontend/src/views/MainView.tsx | 12 ++++++++-- 69 files changed, 127 insertions(+), 79 deletions(-) rename src/frontend/src/states/{StatusState.tsx => GlobalStatusState.tsx} (100%) rename src/frontend/src/states/{ApiState.tsx => ServerApiState.tsx} (100%) rename src/frontend/src/states/{SettingsState.tsx => SettingsStates.tsx} (100%) diff --git a/src/frontend/lib/types/User.tsx b/src/frontend/lib/types/User.tsx index 82e7c6b553..8194ecdfbc 100644 --- a/src/frontend/lib/types/User.tsx +++ b/src/frontend/lib/types/User.tsx @@ -59,4 +59,7 @@ export interface UserStateProps { isLoggedIn: () => boolean; isStaff: () => boolean; isSuperuser: () => boolean; + // login state + login_checked: boolean; + setLoginChecked: (value: boolean) => void; } diff --git a/src/frontend/src/components/SplashScreen.tsx b/src/frontend/src/components/SplashScreen.tsx index 54ef01f203..b1b6c19de7 100644 --- a/src/frontend/src/components/SplashScreen.tsx +++ b/src/frontend/src/components/SplashScreen.tsx @@ -2,7 +2,8 @@ import { BackgroundImage } from '@mantine/core'; import { useEffect } from 'react'; import { useShallow } from 'zustand/react/shallow'; import { generateUrl } from '../functions/urls'; -import { useServerApiState } from '../states/ApiState'; +import { useServerApiState } from '../states/ServerApiState'; +import { useUserState } from '../states/UserState'; /** * Render content within a "splash screen" container. @@ -15,6 +16,9 @@ export default function SplashScreen({ const [server, fetchServerApiState] = useServerApiState( useShallow((state) => [state.server, state.fetchServerApiState]) ); + const [checked_login] = useUserState( + useShallow((state) => [state.login_checked]) + ); // Fetch server data on mount if no server data is present useEffect(() => { @@ -23,7 +27,7 @@ export default function SplashScreen({ } }, [server]); - if (server.customize?.splash) { + if (server.customize?.splash && checked_login) { return ( {children} diff --git a/src/frontend/src/components/barcodes/BarcodeInput.tsx b/src/frontend/src/components/barcodes/BarcodeInput.tsx index 0c5b14aaa0..6e5d5e012b 100644 --- a/src/frontend/src/components/barcodes/BarcodeInput.tsx +++ b/src/frontend/src/components/barcodes/BarcodeInput.tsx @@ -14,7 +14,7 @@ import { IconCamera, IconScan } from '@tabler/icons-react'; import { useCallback, useMemo, useState } from 'react'; import { useLocalStorage } from '@mantine/hooks'; -import { useGlobalSettingsState } from '../../states/SettingsState'; +import { useGlobalSettingsState } from '../../states/SettingsStates'; import { Boundary } from '../Boundary'; import BarcodeCameraInput from './BarcodeCameraInput'; import BarcodeKeyboardInput from './BarcodeKeyboardInput'; diff --git a/src/frontend/src/components/barcodes/QRCode.tsx b/src/frontend/src/components/barcodes/QRCode.tsx index 2ad407de45..fd8e0a1387 100644 --- a/src/frontend/src/components/barcodes/QRCode.tsx +++ b/src/frontend/src/components/barcodes/QRCode.tsx @@ -21,7 +21,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react'; import { ApiEndpoints } from '@lib/enums/ApiEndpoints'; import { apiUrl } from '@lib/functions/Api'; import { api } from '../../App'; -import { useGlobalSettingsState } from '../../states/SettingsState'; +import { useGlobalSettingsState } from '../../states/SettingsStates'; import { CopyButton } from '../buttons/CopyButton'; import type { QrCodeType } from '../items/ActionDropdown'; diff --git a/src/frontend/src/components/buttons/AdminButton.tsx b/src/frontend/src/components/buttons/AdminButton.tsx index c5b7e4d40c..d56811d6fc 100644 --- a/src/frontend/src/components/buttons/AdminButton.tsx +++ b/src/frontend/src/components/buttons/AdminButton.tsx @@ -6,7 +6,7 @@ import { ModelInformationDict } from '@lib/enums/ModelInformation'; import type { ModelType } from '@lib/enums/ModelType'; import { eventModified } from '@lib/functions/Navigation'; import { generateUrl } from '../../functions/urls'; -import { useServerApiState } from '../../states/ApiState'; +import { useServerApiState } from '../../states/ServerApiState'; import { useUserState } from '../../states/UserState'; import { ActionButton } from './ActionButton'; diff --git a/src/frontend/src/components/buttons/PrintingActions.tsx b/src/frontend/src/components/buttons/PrintingActions.tsx index 316ee10c8c..1dede788a4 100644 --- a/src/frontend/src/components/buttons/PrintingActions.tsx +++ b/src/frontend/src/components/buttons/PrintingActions.tsx @@ -13,7 +13,7 @@ import { useCreateApiFormModal } from '../../hooks/UseForm'; import { useGlobalSettingsState, useUserSettingsState -} from '../../states/SettingsState'; +} from '../../states/SettingsStates'; import { ActionDropdown } from '../items/ActionDropdown'; export function PrintingActions({ diff --git a/src/frontend/src/components/dashboard/DashboardWidgetLibrary.tsx b/src/frontend/src/components/dashboard/DashboardWidgetLibrary.tsx index dbeab88f1d..1772d9d788 100644 --- a/src/frontend/src/components/dashboard/DashboardWidgetLibrary.tsx +++ b/src/frontend/src/components/dashboard/DashboardWidgetLibrary.tsx @@ -1,7 +1,7 @@ import { t } from '@lingui/core/macro'; import { ModelType } from '@lib/enums/ModelType'; -import { useGlobalSettingsState } from '../../states/SettingsState'; +import { useGlobalSettingsState } from '../../states/SettingsStates'; import type { DashboardWidgetProps } from './DashboardWidget'; import ColorToggleDashboardWidget from './widgets/ColorToggleWidget'; import GetStartedWidget from './widgets/GetStartedWidget'; diff --git a/src/frontend/src/components/details/Details.tsx b/src/frontend/src/components/details/Details.tsx index 4bc7062b6a..546d4b87a0 100644 --- a/src/frontend/src/components/details/Details.tsx +++ b/src/frontend/src/components/details/Details.tsx @@ -26,7 +26,7 @@ import type { InvenTreeIconType } from '@lib/types/Icons'; import { useApi } from '../../contexts/ApiContext'; import { formatDate, formatDecimal } from '../../defaults/formatters'; import { InvenTreeIcon } from '../../functions/icons'; -import { useGlobalSettingsState } from '../../states/SettingsState'; +import { useGlobalSettingsState } from '../../states/SettingsStates'; import { CopyButton } from '../buttons/CopyButton'; import { YesNoButton } from '../buttons/YesNoButton'; import { ProgressBar } from '../items/ProgressBar'; diff --git a/src/frontend/src/components/details/DetailsImage.tsx b/src/frontend/src/components/details/DetailsImage.tsx index 8963a7ba84..a1bdeabe0f 100644 --- a/src/frontend/src/components/details/DetailsImage.tsx +++ b/src/frontend/src/components/details/DetailsImage.tsx @@ -28,7 +28,7 @@ import { api } from '../../App'; import { InvenTreeIcon } from '../../functions/icons'; import { showApiErrorMessage } from '../../functions/notifications'; import { useEditApiFormModal } from '../../hooks/UseForm'; -import { useGlobalSettingsState } from '../../states/SettingsState'; +import { useGlobalSettingsState } from '../../states/SettingsStates'; import { useUserState } from '../../states/UserState'; import { PartThumbTable } from '../../tables/part/PartThumbTable'; import { vars } from '../../theme'; diff --git a/src/frontend/src/components/forms/AuthFormOptions.tsx b/src/frontend/src/components/forms/AuthFormOptions.tsx index 8c23313b90..a1a2d41211 100644 --- a/src/frontend/src/components/forms/AuthFormOptions.tsx +++ b/src/frontend/src/components/forms/AuthFormOptions.tsx @@ -2,7 +2,7 @@ import { ActionIcon, Center, Group, Text, Tooltip } from '@mantine/core'; import { IconServer } from '@tabler/icons-react'; import { useShallow } from 'zustand/react/shallow'; -import { useServerApiState } from '../../states/ApiState'; +import { useServerApiState } from '../../states/ServerApiState'; import { ColorToggle } from '../items/ColorToggle'; import { LanguageToggle } from '../items/LanguageToggle'; diff --git a/src/frontend/src/components/forms/AuthenticationForm.tsx b/src/frontend/src/components/forms/AuthenticationForm.tsx index deeea5e8ed..572a075d08 100644 --- a/src/frontend/src/components/forms/AuthenticationForm.tsx +++ b/src/frontend/src/components/forms/AuthenticationForm.tsx @@ -27,7 +27,7 @@ import { followRedirect } from '../../functions/auth'; import { showLoginNotification } from '../../functions/notifications'; -import { useServerApiState } from '../../states/ApiState'; +import { useServerApiState } from '../../states/ServerApiState'; import { useUserState } from '../../states/UserState'; import { SsoButton } from '../buttons/SSOButton'; diff --git a/src/frontend/src/components/forms/InstanceOptions.tsx b/src/frontend/src/components/forms/InstanceOptions.tsx index f38e7ec0e3..0236da2e55 100644 --- a/src/frontend/src/components/forms/InstanceOptions.tsx +++ b/src/frontend/src/components/forms/InstanceOptions.tsx @@ -23,8 +23,8 @@ import { import type { HostList } from '@lib/types/Server'; import { useShallow } from 'zustand/react/shallow'; import { Wrapper } from '../../pages/Auth/Layout'; -import { useServerApiState } from '../../states/ApiState'; import { useLocalState } from '../../states/LocalState'; +import { useServerApiState } from '../../states/ServerApiState'; import { ActionButton } from '../buttons/ActionButton'; import { HostOptionsForm } from './HostOptionsForm'; diff --git a/src/frontend/src/components/modals/AboutInvenTreeModal.tsx b/src/frontend/src/components/modals/AboutInvenTreeModal.tsx index cf916327d3..8a353a8086 100644 --- a/src/frontend/src/components/modals/AboutInvenTreeModal.tsx +++ b/src/frontend/src/components/modals/AboutInvenTreeModal.tsx @@ -19,7 +19,7 @@ import { apiUrl } from '@lib/functions/Api'; import { useShallow } from 'zustand/react/shallow'; import { api } from '../../App'; import { generateUrl } from '../../functions/urls'; -import { useServerApiState } from '../../states/ApiState'; +import { useServerApiState } from '../../states/ServerApiState'; import { useUserState } from '../../states/UserState'; import { CopyButton } from '../buttons/CopyButton'; import { StylishText } from '../items/StylishText'; diff --git a/src/frontend/src/components/modals/ServerInfoModal.tsx b/src/frontend/src/components/modals/ServerInfoModal.tsx index 6b56405826..2594bc9be6 100644 --- a/src/frontend/src/components/modals/ServerInfoModal.tsx +++ b/src/frontend/src/components/modals/ServerInfoModal.tsx @@ -3,7 +3,7 @@ import { Badge, Button, Divider, Group, Stack, Table } from '@mantine/core'; import type { ContextModalProps } from '@mantine/modals'; import { useShallow } from 'zustand/react/shallow'; -import { useServerApiState } from '../../states/ApiState'; +import { useServerApiState } from '../../states/ServerApiState'; import { OnlyStaff } from '../items/OnlyStaff'; export function ServerInfoModal({ diff --git a/src/frontend/src/components/nav/Alerts.tsx b/src/frontend/src/components/nav/Alerts.tsx index 5e82326a06..a23d8120a0 100644 --- a/src/frontend/src/components/nav/Alerts.tsx +++ b/src/frontend/src/components/nav/Alerts.tsx @@ -5,8 +5,8 @@ import { useMemo, useState } from 'react'; import { t } from '@lingui/core/macro'; import { useShallow } from 'zustand/react/shallow'; import { docLinks } from '../../defaults/links'; -import { useServerApiState } from '../../states/ApiState'; -import { useGlobalSettingsState } from '../../states/SettingsState'; +import { useServerApiState } from '../../states/ServerApiState'; +import { useGlobalSettingsState } from '../../states/SettingsStates'; import { useUserState } from '../../states/UserState'; interface AlertInfo { diff --git a/src/frontend/src/components/nav/Header.tsx b/src/frontend/src/components/nav/Header.tsx index a5b33b6d80..d843b3ffc5 100644 --- a/src/frontend/src/components/nav/Header.tsx +++ b/src/frontend/src/components/nav/Header.tsx @@ -26,12 +26,12 @@ import { getNavTabs } from '../../defaults/links'; import { generateUrl } from '../../functions/urls'; import { usePluginUIFeature } from '../../hooks/UsePluginUIFeature'; import * as classes from '../../main.css'; -import { useServerApiState } from '../../states/ApiState'; import { useLocalState } from '../../states/LocalState'; +import { useServerApiState } from '../../states/ServerApiState'; import { useGlobalSettingsState, useUserSettingsState -} from '../../states/SettingsState'; +} from '../../states/SettingsStates'; import { useUserState } from '../../states/UserState'; import { ScanButton } from '../buttons/ScanButton'; import { SpotlightButton } from '../buttons/SpotlightButton'; diff --git a/src/frontend/src/components/nav/NavigationDrawer.tsx b/src/frontend/src/components/nav/NavigationDrawer.tsx index 35ffe69521..876177fefc 100644 --- a/src/frontend/src/components/nav/NavigationDrawer.tsx +++ b/src/frontend/src/components/nav/NavigationDrawer.tsx @@ -15,7 +15,7 @@ import { UserRoles } from '@lib/enums/Roles'; import { AboutLinks, DocumentationLinks } from '../../defaults/links'; import useInstanceName from '../../hooks/UseInstanceName'; import * as classes from '../../main.css'; -import { useGlobalSettingsState } from '../../states/SettingsState'; +import { useGlobalSettingsState } from '../../states/SettingsStates'; import { useUserState } from '../../states/UserState'; import { InvenTreeLogo } from '../items/InvenTreeLogo'; import { type MenuLinkItem, MenuLinks } from '../items/MenuLinks'; diff --git a/src/frontend/src/components/nav/PageDetail.tsx b/src/frontend/src/components/nav/PageDetail.tsx index 174ecd701e..a59b2680ca 100644 --- a/src/frontend/src/components/nav/PageDetail.tsx +++ b/src/frontend/src/components/nav/PageDetail.tsx @@ -3,7 +3,7 @@ import { useHotkeys } from '@mantine/hooks'; import { Fragment, type ReactNode, useMemo } from 'react'; import { shortenString } from '../../functions/tables'; -import { useUserSettingsState } from '../../states/SettingsState'; +import { useUserSettingsState } from '../../states/SettingsStates'; import { ApiImage } from '../images/ApiImage'; import { StylishText } from '../items/StylishText'; import { type Breadcrumb, BreadcrumbList } from './BreadcrumbList'; diff --git a/src/frontend/src/components/nav/PageTitle.tsx b/src/frontend/src/components/nav/PageTitle.tsx index e20bc1b8c4..f1bb61dacc 100644 --- a/src/frontend/src/components/nav/PageTitle.tsx +++ b/src/frontend/src/components/nav/PageTitle.tsx @@ -1,5 +1,5 @@ import { useEffect, useMemo } from 'react'; -import { useGlobalSettingsState } from '../../states/SettingsState'; +import { useGlobalSettingsState } from '../../states/SettingsStates'; /** * Component to set the page title diff --git a/src/frontend/src/components/nav/SearchDrawer.tsx b/src/frontend/src/components/nav/SearchDrawer.tsx index 70de9a777f..3c4198b93e 100644 --- a/src/frontend/src/components/nav/SearchDrawer.tsx +++ b/src/frontend/src/components/nav/SearchDrawer.tsx @@ -41,7 +41,7 @@ import { cancelEvent } from '@lib/functions/Events'; import { eventModified, navigateToLink } from '@lib/functions/Navigation'; import { showNotification } from '@mantine/notifications'; import { api } from '../../App'; -import { useUserSettingsState } from '../../states/SettingsState'; +import { useUserSettingsState } from '../../states/SettingsStates'; import { useUserState } from '../../states/UserState'; import { Boundary } from '../Boundary'; import { RenderInstance } from '../render/Instance'; diff --git a/src/frontend/src/components/plugins/PluginContext.tsx b/src/frontend/src/components/plugins/PluginContext.tsx index 91bd46f402..4c570be6fe 100644 --- a/src/frontend/src/components/plugins/PluginContext.tsx +++ b/src/frontend/src/components/plugins/PluginContext.tsx @@ -7,7 +7,7 @@ import { useLocalState } from '../../states/LocalState'; import { useGlobalSettingsState, useUserSettingsState -} from '../../states/SettingsState'; +} from '../../states/SettingsStates'; import { useUserState } from '../../states/UserState'; import { ModelInformationDict } from '@lib/enums/ModelInformation'; diff --git a/src/frontend/src/components/render/StatusRenderer.tsx b/src/frontend/src/components/render/StatusRenderer.tsx index 8ae2c6bf5b..bb54da9e6e 100644 --- a/src/frontend/src/components/render/StatusRenderer.tsx +++ b/src/frontend/src/components/render/StatusRenderer.tsx @@ -3,7 +3,7 @@ import { Badge, Center, type MantineSize } from '@mantine/core'; import type { ModelType } from '@lib/enums/ModelType'; import { statusColorMap } from '../../defaults/backendMappings'; import { resolveItem } from '../../functions/conversion'; -import { useGlobalStatusState } from '../../states/StatusState'; +import { useGlobalStatusState } from '../../states/GlobalStatusState'; export interface StatusCodeInterface { key: number; diff --git a/src/frontend/src/components/settings/SettingList.tsx b/src/frontend/src/components/settings/SettingList.tsx index 3ae18402e7..22676cde46 100644 --- a/src/frontend/src/components/settings/SettingList.tsx +++ b/src/frontend/src/components/settings/SettingList.tsx @@ -16,7 +16,7 @@ import { createPluginSettingsState, useGlobalSettingsState, useUserSettingsState -} from '../../states/SettingsState'; +} from '../../states/SettingsStates'; import { SettingItem } from './SettingItem'; /** diff --git a/src/frontend/src/contexts/LanguageContext.tsx b/src/frontend/src/contexts/LanguageContext.tsx index 8332baf961..bfe65d3923 100644 --- a/src/frontend/src/contexts/LanguageContext.tsx +++ b/src/frontend/src/contexts/LanguageContext.tsx @@ -6,8 +6,8 @@ import { type JSX, useEffect, useRef, useState } from 'react'; import { useShallow } from 'zustand/react/shallow'; import { api } from '../App'; -import { useServerApiState } from '../states/ApiState'; import { useLocalState } from '../states/LocalState'; +import { useServerApiState } from '../states/ServerApiState'; import { fetchGlobalStates } from '../states/states'; export const defaultLocale = 'en'; diff --git a/src/frontend/src/defaults/formatters.tsx b/src/frontend/src/defaults/formatters.tsx index 9b5ad1dc2b..2a87657316 100644 --- a/src/frontend/src/defaults/formatters.tsx +++ b/src/frontend/src/defaults/formatters.tsx @@ -3,7 +3,7 @@ import dayjs from 'dayjs'; import { useGlobalSettingsState, useUserSettingsState -} from '../states/SettingsState'; +} from '../states/SettingsStates'; interface FormatDecmimalOptionsInterface { digits?: number; diff --git a/src/frontend/src/forms/BuildForms.tsx b/src/frontend/src/forms/BuildForms.tsx index 982fb12a1e..ba66b43409 100644 --- a/src/frontend/src/forms/BuildForms.tsx +++ b/src/frontend/src/forms/BuildForms.tsx @@ -29,7 +29,7 @@ import { useBatchCodeGenerator, useSerialNumberGenerator } from '../hooks/UseGenerator'; -import { useGlobalSettingsState } from '../states/SettingsState'; +import { useGlobalSettingsState } from '../states/SettingsStates'; import { PartColumn } from '../tables/ColumnRenderers'; /** diff --git a/src/frontend/src/forms/CommonForms.tsx b/src/frontend/src/forms/CommonForms.tsx index f611214fa5..25b8e2b81d 100644 --- a/src/frontend/src/forms/CommonForms.tsx +++ b/src/frontend/src/forms/CommonForms.tsx @@ -6,7 +6,7 @@ import type { StatusCodeInterface, StatusCodeListInterface } from '../components/render/StatusRenderer'; -import { useGlobalStatusState } from '../states/StatusState'; +import { useGlobalStatusState } from '../states/GlobalStatusState'; export function projectCodeFields(): ApiFormFieldSet { return { diff --git a/src/frontend/src/forms/PartForms.tsx b/src/frontend/src/forms/PartForms.tsx index eec80a41bf..22341e49e1 100644 --- a/src/frontend/src/forms/PartForms.tsx +++ b/src/frontend/src/forms/PartForms.tsx @@ -6,7 +6,7 @@ import { ApiEndpoints } from '@lib/enums/ApiEndpoints'; import { apiUrl } from '@lib/functions/Api'; import type { ApiFormFieldSet } from '@lib/types/Forms'; import { useApi } from '../contexts/ApiContext'; -import { useGlobalSettingsState } from '../states/SettingsState'; +import { useGlobalSettingsState } from '../states/SettingsStates'; /** * Construct a set of fields for creating / editing a Part instance diff --git a/src/frontend/src/forms/PurchaseOrderForms.tsx b/src/frontend/src/forms/PurchaseOrderForms.tsx index 575d626976..d1cbf18a9e 100644 --- a/src/frontend/src/forms/PurchaseOrderForms.tsx +++ b/src/frontend/src/forms/PurchaseOrderForms.tsx @@ -51,7 +51,7 @@ import { useBatchCodeGenerator, useSerialNumberGenerator } from '../hooks/UseGenerator'; -import { useGlobalSettingsState } from '../states/SettingsState'; +import { useGlobalSettingsState } from '../states/SettingsStates'; /* * Construct a set of fields for creating / editing a PurchaseOrderLineItem instance */ diff --git a/src/frontend/src/forms/ReturnOrderForms.tsx b/src/frontend/src/forms/ReturnOrderForms.tsx index 892b038226..d791344943 100644 --- a/src/frontend/src/forms/ReturnOrderForms.tsx +++ b/src/frontend/src/forms/ReturnOrderForms.tsx @@ -21,7 +21,7 @@ import type { import type { TableFieldRowProps } from '../components/forms/fields/TableField'; import { Thumbnail } from '../components/images/Thumbnail'; import { useCreateApiFormModal } from '../hooks/UseForm'; -import { useGlobalSettingsState } from '../states/SettingsState'; +import { useGlobalSettingsState } from '../states/SettingsStates'; import { StatusFilterOptions } from '../tables/Filter'; export function useReturnOrderFields({ diff --git a/src/frontend/src/forms/SalesOrderForms.tsx b/src/frontend/src/forms/SalesOrderForms.tsx index 96c1805707..b8b6e8bb9d 100644 --- a/src/frontend/src/forms/SalesOrderForms.tsx +++ b/src/frontend/src/forms/SalesOrderForms.tsx @@ -22,7 +22,7 @@ import type { import type { TableFieldRowProps } from '../components/forms/fields/TableField'; import { ProgressBar } from '../components/items/ProgressBar'; import { useCreateApiFormModal } from '../hooks/UseForm'; -import { useGlobalSettingsState } from '../states/SettingsState'; +import { useGlobalSettingsState } from '../states/SettingsStates'; import { PartColumn } from '../tables/ColumnRenderers'; export function useSalesOrderFields({ diff --git a/src/frontend/src/forms/StockForms.tsx b/src/frontend/src/forms/StockForms.tsx index a85709d05e..dad409597d 100644 --- a/src/frontend/src/forms/StockForms.tsx +++ b/src/frontend/src/forms/StockForms.tsx @@ -56,7 +56,7 @@ import { useBatchCodeGenerator, useSerialNumberGenerator } from '../hooks/UseGenerator'; -import { useGlobalSettingsState } from '../states/SettingsState'; +import { useGlobalSettingsState } from '../states/SettingsStates'; import { StatusFilterOptions } from '../tables/Filter'; /** diff --git a/src/frontend/src/functions/auth.tsx b/src/frontend/src/functions/auth.tsx index 49d583c123..7a2158e6f5 100644 --- a/src/frontend/src/functions/auth.tsx +++ b/src/frontend/src/functions/auth.tsx @@ -7,8 +7,8 @@ import axios from 'axios'; import type { AxiosRequestConfig } from 'axios'; import type { Location, NavigateFunction } from 'react-router-dom'; import { api, setApiDefaults } from '../App'; -import { useServerApiState } from '../states/ApiState'; import { useLocalState } from '../states/LocalState'; +import { useServerApiState } from '../states/ServerApiState'; import { useUserState } from '../states/UserState'; import { fetchGlobalStates } from '../states/states'; import { showLoginNotification } from './notifications'; @@ -354,6 +354,7 @@ export const checkLoginState = async ( redirect?: any, no_redirect?: boolean ) => { + const { setLoginChecked } = useUserState.getState(); setApiDefaults(); if (redirect == '/') { @@ -364,6 +365,7 @@ export const checkLoginState = async ( // Callback function when login is successful const loginSuccess = () => { + setLoginChecked(true); showLoginNotification({ title: t`Logged In`, message: t`Successfully logged in` @@ -388,8 +390,10 @@ export const checkLoginState = async ( if (isLoggedIn()) { loginSuccess(); } else if (!no_redirect) { + setLoginChecked(true); navigate('/login', { state: redirect }); } + setLoginChecked(true); }; function handleSuccessFullAuth( diff --git a/src/frontend/src/functions/loading.tsx b/src/frontend/src/functions/loading.tsx index 73c56d04a7..f0dbcb0894 100644 --- a/src/frontend/src/functions/loading.tsx +++ b/src/frontend/src/functions/loading.tsx @@ -4,11 +4,13 @@ import { type JSX, Suspense } from 'react'; import { colorSchema } from '../contexts/colorSchema'; import { theme } from '../theme'; -function LoadingFallback() { +function LoadingFallback({ + fullHeight = false +}: { fullHeight: boolean }): JSX.Element { return ( - -
+ +
@@ -16,12 +18,21 @@ function LoadingFallback() { ); } -export const Loadable = - (Component: any) => (props: JSX.IntrinsicAttributes) => ( - }> +export function Loadable( + Component: any, + noFallback = false, + fullHeight = false +): any { + return (props: JSX.IntrinsicAttributes) => ( + : undefined + } + > ); +} export function LoadingItem({ item }: Readonly<{ item: any }>): JSX.Element { const Itm = Loadable(item); diff --git a/src/frontend/src/hooks/UseDashboardItems.tsx b/src/frontend/src/hooks/UseDashboardItems.tsx index 52202fbfad..dae1fcb9e0 100644 --- a/src/frontend/src/hooks/UseDashboardItems.tsx +++ b/src/frontend/src/hooks/UseDashboardItems.tsx @@ -13,7 +13,7 @@ import { } from '../components/plugins/PluginUIFeature'; import RemoteComponent from '../components/plugins/RemoteComponent'; import { identifierString } from '../functions/conversion'; -import { useGlobalSettingsState } from '../states/SettingsState'; +import { useGlobalSettingsState } from '../states/SettingsStates'; import { useUserState } from '../states/UserState'; interface DashboardLibraryProps { diff --git a/src/frontend/src/hooks/UseInstanceName.tsx b/src/frontend/src/hooks/UseInstanceName.tsx index 71af926c5b..a125cbbf63 100644 --- a/src/frontend/src/hooks/UseInstanceName.tsx +++ b/src/frontend/src/hooks/UseInstanceName.tsx @@ -1,6 +1,6 @@ import { useMemo } from 'react'; -import { useGlobalSettingsState } from '../states/SettingsState'; +import { useGlobalSettingsState } from '../states/SettingsStates'; /** * Simple hook for returning the "instance name" of the Server diff --git a/src/frontend/src/hooks/UsePluginPanels.tsx b/src/frontend/src/hooks/UsePluginPanels.tsx index e7e28d50b6..6418fcd1aa 100644 --- a/src/frontend/src/hooks/UsePluginPanels.tsx +++ b/src/frontend/src/hooks/UsePluginPanels.tsx @@ -14,7 +14,7 @@ import { type PluginUIFeature, PluginUIFeatureType } from '../components/plugins/PluginUIFeature'; -import { useGlobalSettingsState } from '../states/SettingsState'; +import { useGlobalSettingsState } from '../states/SettingsStates'; /** * Type definition for a plugin panel which extends the standard PanelType diff --git a/src/frontend/src/hooks/UsePluginUIFeature.tsx b/src/frontend/src/hooks/UsePluginUIFeature.tsx index 0e8cfccebd..cb1aa8f6d6 100644 --- a/src/frontend/src/hooks/UsePluginUIFeature.tsx +++ b/src/frontend/src/hooks/UsePluginUIFeature.tsx @@ -11,7 +11,7 @@ import type { PluginUIFeatureAPIResponse, PluginUIFuncWithoutInvenTreeContextType } from '../components/plugins/PluginUIFeatureTypes'; -import { useGlobalSettingsState } from '../states/SettingsState'; +import { useGlobalSettingsState } from '../states/SettingsStates'; export function usePluginUIFeature({ enabled = true, diff --git a/src/frontend/src/hooks/UseStatusCodes.tsx b/src/frontend/src/hooks/UseStatusCodes.tsx index cad7b60178..c54ec10339 100644 --- a/src/frontend/src/hooks/UseStatusCodes.tsx +++ b/src/frontend/src/hooks/UseStatusCodes.tsx @@ -2,7 +2,7 @@ import { useMemo } from 'react'; import type { ModelType } from '@lib/enums/ModelType'; import { getStatusCodes } from '../components/render/StatusRenderer'; -import { useGlobalStatusState } from '../states/StatusState'; +import { useGlobalStatusState } from '../states/GlobalStatusState'; /** * Hook to access status codes, which are enumerated by the backend. diff --git a/src/frontend/src/pages/Auth/Layout.tsx b/src/frontend/src/pages/Auth/Layout.tsx index 7fbe6955b5..03cc7205f8 100644 --- a/src/frontend/src/pages/Auth/Layout.tsx +++ b/src/frontend/src/pages/Auth/Layout.tsx @@ -14,7 +14,7 @@ import SplashScreen from '../../components/SplashScreen'; import { StylishText } from '../../components/items/StylishText'; import { doLogout } from '../../functions/auth'; -export default function Layout() { +export default function LoginLayoutComponent() { return (
diff --git a/src/frontend/src/pages/Auth/Login.tsx b/src/frontend/src/pages/Auth/Login.tsx index a8c9e777e3..ebf8f6d41c 100644 --- a/src/frontend/src/pages/Auth/Login.tsx +++ b/src/frontend/src/pages/Auth/Login.tsx @@ -16,8 +16,8 @@ import { doBasicLogin, followRedirect } from '../../functions/auth'; -import { useServerApiState } from '../../states/ApiState'; import { useLocalState } from '../../states/LocalState'; +import { useServerApiState } from '../../states/ServerApiState'; import { Wrapper } from './Layout'; export default function Login() { diff --git a/src/frontend/src/pages/Index/Settings/AccountSettings/SecurityContent.tsx b/src/frontend/src/pages/Index/Settings/AccountSettings/SecurityContent.tsx index 0506bffd15..f08d810b47 100644 --- a/src/frontend/src/pages/Index/Settings/AccountSettings/SecurityContent.tsx +++ b/src/frontend/src/pages/Index/Settings/AccountSettings/SecurityContent.tsx @@ -35,7 +35,7 @@ import { useShallow } from 'zustand/react/shallow'; import { api } from '../../../../App'; import { StylishText } from '../../../../components/items/StylishText'; import { ProviderLogin, authApi } from '../../../../functions/auth'; -import { useServerApiState } from '../../../../states/ApiState'; +import { useServerApiState } from '../../../../states/ServerApiState'; import { ApiTokenTable } from '../../../../tables/settings/ApiTokenTable'; import { QrRegistrationForm } from './QrRegistrationForm'; import { useReauth } from './useConfirm'; diff --git a/src/frontend/src/pages/Index/Settings/AdminCenter/PluginManagementPanel.tsx b/src/frontend/src/pages/Index/Settings/AdminCenter/PluginManagementPanel.tsx index 329358276d..87660c7d2a 100644 --- a/src/frontend/src/pages/Index/Settings/AdminCenter/PluginManagementPanel.tsx +++ b/src/frontend/src/pages/Index/Settings/AdminCenter/PluginManagementPanel.tsx @@ -8,7 +8,7 @@ import { useShallow } from 'zustand/react/shallow'; import { StylishText } from '../../../../components/items/StylishText'; import { GlobalSettingList } from '../../../../components/settings/SettingList'; import { Loadable } from '../../../../functions/loading'; -import { useServerApiState } from '../../../../states/ApiState'; +import { useServerApiState } from '../../../../states/ServerApiState'; import { useUserState } from '../../../../states/UserState'; const PluginListTable = Loadable( diff --git a/src/frontend/src/pages/Index/Settings/SystemSettings.tsx b/src/frontend/src/pages/Index/Settings/SystemSettings.tsx index 4d1ed7a2bd..6fb4c85961 100644 --- a/src/frontend/src/pages/Index/Settings/SystemSettings.tsx +++ b/src/frontend/src/pages/Index/Settings/SystemSettings.tsx @@ -25,7 +25,7 @@ import { SettingsHeader } from '../../../components/nav/SettingsHeader'; import type { PanelType } from '../../../components/panels/Panel'; import { PanelGroup } from '../../../components/panels/PanelGroup'; import { GlobalSettingList } from '../../../components/settings/SettingList'; -import { useServerApiState } from '../../../states/ApiState'; +import { useServerApiState } from '../../../states/ServerApiState'; import { useUserState } from '../../../states/UserState'; /** diff --git a/src/frontend/src/pages/build/BuildDetail.tsx b/src/frontend/src/pages/build/BuildDetail.tsx index d532ec679e..3f1bf4073b 100644 --- a/src/frontend/src/pages/build/BuildDetail.tsx +++ b/src/frontend/src/pages/build/BuildDetail.tsx @@ -51,7 +51,7 @@ import { } from '../../hooks/UseForm'; import { useInstance } from '../../hooks/UseInstance'; import useStatusCodes from '../../hooks/UseStatusCodes'; -import { useGlobalSettingsState } from '../../states/SettingsState'; +import { useGlobalSettingsState } from '../../states/SettingsStates'; import { useUserState } from '../../states/UserState'; import BuildAllocatedStockTable from '../../tables/build/BuildAllocatedStockTable'; import BuildLineTable from '../../tables/build/BuildLineTable'; diff --git a/src/frontend/src/pages/build/BuildIndex.tsx b/src/frontend/src/pages/build/BuildIndex.tsx index ff09a5ca5e..bd95117a53 100644 --- a/src/frontend/src/pages/build/BuildIndex.tsx +++ b/src/frontend/src/pages/build/BuildIndex.tsx @@ -13,7 +13,7 @@ import PermissionDenied from '../../components/errors/PermissionDenied'; import { PageDetail } from '../../components/nav/PageDetail'; import type { PanelType } from '../../components/panels/Panel'; import { PanelGroup } from '../../components/panels/PanelGroup'; -import { useGlobalSettingsState } from '../../states/SettingsState'; +import { useGlobalSettingsState } from '../../states/SettingsStates'; import { useUserState } from '../../states/UserState'; import { PartCategoryFilter } from '../../tables/Filter'; import { BuildOrderTable } from '../../tables/build/BuildOrderTable'; diff --git a/src/frontend/src/pages/core/UserDetail.tsx b/src/frontend/src/pages/core/UserDetail.tsx index 6b7f592457..67681e9464 100644 --- a/src/frontend/src/pages/core/UserDetail.tsx +++ b/src/frontend/src/pages/core/UserDetail.tsx @@ -17,7 +17,7 @@ import type { PanelType } from '../../components/panels/Panel'; import { PanelGroup } from '../../components/panels/PanelGroup'; import {} from '../../hooks/UseForm'; import { useInstance } from '../../hooks/UseInstance'; -import { useGlobalSettingsState } from '../../states/SettingsState'; +import { useGlobalSettingsState } from '../../states/SettingsStates'; import { useUserState } from '../../states/UserState'; /** diff --git a/src/frontend/src/pages/part/PartDetail.tsx b/src/frontend/src/pages/part/PartDetail.tsx index 85922fd400..b575278130 100644 --- a/src/frontend/src/pages/part/PartDetail.tsx +++ b/src/frontend/src/pages/part/PartDetail.tsx @@ -86,7 +86,7 @@ import { useInstance } from '../../hooks/UseInstance'; import { useGlobalSettingsState, useUserSettingsState -} from '../../states/SettingsState'; +} from '../../states/SettingsStates'; import { useUserState } from '../../states/UserState'; import { BomTable } from '../../tables/bom/BomTable'; import { UsedInTable } from '../../tables/bom/UsedInTable'; diff --git a/src/frontend/src/pages/part/PartPricingPanel.tsx b/src/frontend/src/pages/part/PartPricingPanel.tsx index e0515943f8..8289d85662 100644 --- a/src/frontend/src/pages/part/PartPricingPanel.tsx +++ b/src/frontend/src/pages/part/PartPricingPanel.tsx @@ -5,7 +5,7 @@ import { useMemo, useState } from 'react'; import { ApiEndpoints } from '@lib/enums/ApiEndpoints'; import { UserRoles } from '@lib/enums/Roles'; import { useInstance } from '../../hooks/UseInstance'; -import { useGlobalSettingsState } from '../../states/SettingsState'; +import { useGlobalSettingsState } from '../../states/SettingsStates'; import { useUserState } from '../../states/UserState'; import BomPricingPanel from './pricing/BomPricingPanel'; import PriceBreakPanel from './pricing/PriceBreakPanel'; diff --git a/src/frontend/src/pages/part/pricing/PricingOverviewPanel.tsx b/src/frontend/src/pages/part/pricing/PricingOverviewPanel.tsx index dc8c0d96dc..d08cf0222e 100644 --- a/src/frontend/src/pages/part/pricing/PricingOverviewPanel.tsx +++ b/src/frontend/src/pages/part/pricing/PricingOverviewPanel.tsx @@ -36,7 +36,7 @@ import { import { formatCurrency, formatDate } from '../../../defaults/formatters'; import { InvenTreeIcon } from '../../../functions/icons'; import { useEditApiFormModal } from '../../../hooks/UseForm'; -import { useGlobalSettingsState } from '../../../states/SettingsState'; +import { useGlobalSettingsState } from '../../../states/SettingsStates'; import { panelOptions } from '../PartPricingPanel'; interface PricingOverviewEntry { diff --git a/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx b/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx index 014ed13b4a..578e18f158 100644 --- a/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx +++ b/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx @@ -41,7 +41,7 @@ import { } from '../../hooks/UseForm'; import { useInstance } from '../../hooks/UseInstance'; import useStatusCodes from '../../hooks/UseStatusCodes'; -import { useGlobalSettingsState } from '../../states/SettingsState'; +import { useGlobalSettingsState } from '../../states/SettingsStates'; import { useUserState } from '../../states/UserState'; import ExtraLineItemTable from '../../tables/general/ExtraLineItemTable'; import { PurchaseOrderLineItemTable } from '../../tables/purchasing/PurchaseOrderLineItemTable'; diff --git a/src/frontend/src/pages/sales/ReturnOrderDetail.tsx b/src/frontend/src/pages/sales/ReturnOrderDetail.tsx index ad23945f9f..74ca9e92a8 100644 --- a/src/frontend/src/pages/sales/ReturnOrderDetail.tsx +++ b/src/frontend/src/pages/sales/ReturnOrderDetail.tsx @@ -41,7 +41,7 @@ import { } from '../../hooks/UseForm'; import { useInstance } from '../../hooks/UseInstance'; import useStatusCodes from '../../hooks/UseStatusCodes'; -import { useGlobalSettingsState } from '../../states/SettingsState'; +import { useGlobalSettingsState } from '../../states/SettingsStates'; import { useUserState } from '../../states/UserState'; import ExtraLineItemTable from '../../tables/general/ExtraLineItemTable'; import ReturnOrderLineItemTable from '../../tables/sales/ReturnOrderLineItemTable'; diff --git a/src/frontend/src/pages/sales/SalesOrderDetail.tsx b/src/frontend/src/pages/sales/SalesOrderDetail.tsx index a9ad456cea..dca6851ff5 100644 --- a/src/frontend/src/pages/sales/SalesOrderDetail.tsx +++ b/src/frontend/src/pages/sales/SalesOrderDetail.tsx @@ -47,7 +47,7 @@ import { } from '../../hooks/UseForm'; import { useInstance } from '../../hooks/UseInstance'; import useStatusCodes from '../../hooks/UseStatusCodes'; -import { useGlobalSettingsState } from '../../states/SettingsState'; +import { useGlobalSettingsState } from '../../states/SettingsStates'; import { useUserState } from '../../states/UserState'; import { BuildOrderTable } from '../../tables/build/BuildOrderTable'; import ExtraLineItemTable from '../../tables/general/ExtraLineItemTable'; diff --git a/src/frontend/src/pages/stock/StockDetail.tsx b/src/frontend/src/pages/stock/StockDetail.tsx index e2c997cf75..49bab78ad9 100644 --- a/src/frontend/src/pages/stock/StockDetail.tsx +++ b/src/frontend/src/pages/stock/StockDetail.tsx @@ -84,7 +84,7 @@ import { useEditApiFormModal } from '../../hooks/UseForm'; import { useInstance } from '../../hooks/UseInstance'; -import { useGlobalSettingsState } from '../../states/SettingsState'; +import { useGlobalSettingsState } from '../../states/SettingsStates'; import { useUserState } from '../../states/UserState'; import BuildAllocatedStockTable from '../../tables/build/BuildAllocatedStockTable'; import SalesOrderAllocationTable from '../../tables/sales/SalesOrderAllocationTable'; diff --git a/src/frontend/src/router.tsx b/src/frontend/src/router.tsx index 8459692804..49b580fcfa 100644 --- a/src/frontend/src/router.tsx +++ b/src/frontend/src/router.tsx @@ -5,10 +5,14 @@ import { Loadable } from './functions/loading'; // Lazy loaded pages export const LayoutComponent = Loadable( - lazy(() => import('./components/nav/Layout')) + lazy(() => import('./components/nav/Layout')), + true, + true ); export const LoginLayoutComponent = Loadable( - lazy(() => import('./pages/Auth/Layout')) + lazy(() => import('./pages/Auth/Layout')), + true, + true ); export const Home = Loadable(lazy(() => import('./pages/Index/Home'))); @@ -119,7 +123,11 @@ export const NotFound = Loadable( // Auth export const Login = Loadable(lazy(() => import('./pages/Auth/Login'))); -export const LoggedIn = Loadable(lazy(() => import('./pages/Auth/LoggedIn'))); +export const LoggedIn = Loadable( + lazy(() => import('./pages/Auth/LoggedIn')), + true, + true +); export const Logout = Loadable(lazy(() => import('./pages/Auth/Logout'))); export const Register = Loadable(lazy(() => import('./pages/Auth/Register'))); export const Mfa = Loadable(lazy(() => import('./pages/Auth/MFA'))); @@ -132,7 +140,9 @@ export const ResetPassword = Loadable( lazy(() => import('./pages/Auth/ResetPassword')) ); export const VerifyEmail = Loadable( - lazy(() => import('./pages/Auth/VerifyEmail')) + lazy(() => import('./pages/Auth/VerifyEmail')), + true, + true ); // Routes diff --git a/src/frontend/src/states/StatusState.tsx b/src/frontend/src/states/GlobalStatusState.tsx similarity index 100% rename from src/frontend/src/states/StatusState.tsx rename to src/frontend/src/states/GlobalStatusState.tsx diff --git a/src/frontend/src/states/ApiState.tsx b/src/frontend/src/states/ServerApiState.tsx similarity index 100% rename from src/frontend/src/states/ApiState.tsx rename to src/frontend/src/states/ServerApiState.tsx diff --git a/src/frontend/src/states/SettingsState.tsx b/src/frontend/src/states/SettingsStates.tsx similarity index 100% rename from src/frontend/src/states/SettingsState.tsx rename to src/frontend/src/states/SettingsStates.tsx diff --git a/src/frontend/src/states/UserState.tsx b/src/frontend/src/states/UserState.tsx index 3c174f1cf9..16cfd75bde 100644 --- a/src/frontend/src/states/UserState.tsx +++ b/src/frontend/src/states/UserState.tsx @@ -198,5 +198,10 @@ export const useUserState = create((set, get) => ({ }, hasViewPermission: (model: ModelType) => { return get().checkUserPermission(model, UserPermissions.view); + }, + // login state + login_checked: false, + setLoginChecked: (value) => { + set({ login_checked: value }); } })); diff --git a/src/frontend/src/states/states.tsx b/src/frontend/src/states/states.tsx index 704a5a90ee..82e015e757 100644 --- a/src/frontend/src/states/states.tsx +++ b/src/frontend/src/states/states.tsx @@ -1,10 +1,10 @@ import type { PluginProps } from '@lib/types/Plugins'; import type { NavigateFunction } from 'react-router-dom'; import { setApiDefaults } from '../App'; -import { useServerApiState } from './ApiState'; +import { useGlobalStatusState } from './GlobalStatusState'; import { useIconState } from './IconState'; -import { useGlobalSettingsState, useUserSettingsState } from './SettingsState'; -import { useGlobalStatusState } from './StatusState'; +import { useServerApiState } from './ServerApiState'; +import { useGlobalSettingsState, useUserSettingsState } from './SettingsStates'; import { useUserState } from './UserState'; // Type interface fully defining the current server diff --git a/src/frontend/src/tables/ColumnRenderers.tsx b/src/frontend/src/tables/ColumnRenderers.tsx index 992ecac30d..6c15e21b45 100644 --- a/src/frontend/src/tables/ColumnRenderers.tsx +++ b/src/frontend/src/tables/ColumnRenderers.tsx @@ -14,7 +14,7 @@ import { TableStatusRenderer } from '../components/render/StatusRenderer'; import { RenderOwner, RenderUser } from '../components/render/User'; import { formatCurrency, formatDate } from '../defaults/formatters'; import { resolveItem } from '../functions/conversion'; -import { useGlobalSettingsState } from '../states/SettingsState'; +import { useGlobalSettingsState } from '../states/SettingsStates'; import type { TableColumn, TableColumnProps } from './Column'; import { ProjectCodeHoverCard } from './TableHoverCard'; diff --git a/src/frontend/src/tables/Filter.tsx b/src/frontend/src/tables/Filter.tsx index d4af8578f0..284a33b5f7 100644 --- a/src/frontend/src/tables/Filter.tsx +++ b/src/frontend/src/tables/Filter.tsx @@ -8,8 +8,11 @@ import type { StatusCodeInterface, StatusCodeListInterface } from '../components/render/StatusRenderer'; -import { useGlobalSettingsState } from '../states/SettingsState'; -import { type StatusLookup, useGlobalStatusState } from '../states/StatusState'; +import { + type StatusLookup, + useGlobalStatusState +} from '../states/GlobalStatusState'; +import { useGlobalSettingsState } from '../states/SettingsStates'; /** * Return list of available filter options for a given filter diff --git a/src/frontend/src/tables/build/BuildOrderTable.tsx b/src/frontend/src/tables/build/BuildOrderTable.tsx index 843d419ee6..1ca2893962 100644 --- a/src/frontend/src/tables/build/BuildOrderTable.tsx +++ b/src/frontend/src/tables/build/BuildOrderTable.tsx @@ -12,7 +12,7 @@ import { RenderUser } from '../../components/render/User'; import { useBuildOrderFields } from '../../forms/BuildForms'; import { useCreateApiFormModal } from '../../hooks/UseForm'; import { useTable } from '../../hooks/UseTable'; -import { useGlobalSettingsState } from '../../states/SettingsState'; +import { useGlobalSettingsState } from '../../states/SettingsStates'; import { useUserState } from '../../states/UserState'; import { BooleanColumn, diff --git a/src/frontend/src/tables/plugin/PluginListTable.tsx b/src/frontend/src/tables/plugin/PluginListTable.tsx index e44990a4fd..0502a2e7c1 100644 --- a/src/frontend/src/tables/plugin/PluginListTable.tsx +++ b/src/frontend/src/tables/plugin/PluginListTable.tsx @@ -26,7 +26,7 @@ import { useEditApiFormModal } from '../../hooks/UseForm'; import { useTable } from '../../hooks/UseTable'; -import { useServerApiState } from '../../states/ApiState'; +import { useServerApiState } from '../../states/ServerApiState'; import { useUserState } from '../../states/UserState'; import type { TableColumn } from '../Column'; import { BooleanColumn } from '../ColumnRenderers'; diff --git a/src/frontend/src/tables/settings/BarcodeScanHistoryTable.tsx b/src/frontend/src/tables/settings/BarcodeScanHistoryTable.tsx index a5ded3284b..499d019b4d 100644 --- a/src/frontend/src/tables/settings/BarcodeScanHistoryTable.tsx +++ b/src/frontend/src/tables/settings/BarcodeScanHistoryTable.tsx @@ -25,7 +25,7 @@ import { RenderUser } from '../../components/render/User'; import { shortenString } from '../../functions/tables'; import { useDeleteApiFormModal } from '../../hooks/UseForm'; import { useTable } from '../../hooks/UseTable'; -import { useGlobalSettingsState } from '../../states/SettingsState'; +import { useGlobalSettingsState } from '../../states/SettingsStates'; import { useUserState } from '../../states/UserState'; import type { TableColumn } from '../Column'; import { UserFilter } from '../Filter'; diff --git a/src/frontend/src/tables/settings/CustomStateTable.tsx b/src/frontend/src/tables/settings/CustomStateTable.tsx index 9d4080ee91..af6793ed55 100644 --- a/src/frontend/src/tables/settings/CustomStateTable.tsx +++ b/src/frontend/src/tables/settings/CustomStateTable.tsx @@ -19,7 +19,7 @@ import { useEditApiFormModal } from '../../hooks/UseForm'; import { useTable } from '../../hooks/UseTable'; -import { useGlobalStatusState } from '../../states/StatusState'; +import { useGlobalStatusState } from '../../states/GlobalStatusState'; import { useUserState } from '../../states/UserState'; import type { TableColumn } from '../Column'; import { InvenTreeTable } from '../InvenTreeTable'; diff --git a/src/frontend/src/tables/stock/StockItemTable.tsx b/src/frontend/src/tables/stock/StockItemTable.tsx index 1fee33ef60..301f767318 100644 --- a/src/frontend/src/tables/stock/StockItemTable.tsx +++ b/src/frontend/src/tables/stock/StockItemTable.tsx @@ -26,7 +26,7 @@ import { import { InvenTreeIcon } from '../../functions/icons'; import { useCreateApiFormModal } from '../../hooks/UseForm'; import { useTable } from '../../hooks/UseTable'; -import { useGlobalSettingsState } from '../../states/SettingsState'; +import { useGlobalSettingsState } from '../../states/SettingsStates'; import { useUserState } from '../../states/UserState'; import type { TableColumn } from '../Column'; import { diff --git a/src/frontend/src/tables/stock/StockItemTestResultTable.tsx b/src/frontend/src/tables/stock/StockItemTestResultTable.tsx index 57a1ab8f8d..2a815b42fc 100644 --- a/src/frontend/src/tables/stock/StockItemTestResultTable.tsx +++ b/src/frontend/src/tables/stock/StockItemTestResultTable.tsx @@ -28,7 +28,7 @@ import { useEditApiFormModal } from '../../hooks/UseForm'; import { useTable } from '../../hooks/UseTable'; -import { useGlobalSettingsState } from '../../states/SettingsState'; +import { useGlobalSettingsState } from '../../states/SettingsStates'; import { useUserState } from '../../states/UserState'; import type { TableColumn } from '../Column'; import { DateColumn, DescriptionColumn, NoteColumn } from '../ColumnRenderers'; diff --git a/src/frontend/src/views/MainView.tsx b/src/frontend/src/views/MainView.tsx index a79611af55..434c404280 100644 --- a/src/frontend/src/views/MainView.tsx +++ b/src/frontend/src/views/MainView.tsx @@ -13,8 +13,16 @@ function checkMobile() { return false; } -const MobileAppView = Loadable(lazy(() => import('./MobileAppView'))); -const DesktopAppView = Loadable(lazy(() => import('./DesktopAppView'))); +const MobileAppView = Loadable( + lazy(() => import('./MobileAppView')), + true, + true +); +const DesktopAppView = Loadable( + lazy(() => import('./DesktopAppView')), + true, + true +); // Main App export default function MainView() {