mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-03 05:48:47 +00:00
[PUI] Mobile ignore warning in dev (#7009)
* enable overwrite of mobileView warning * only show exception on dev
This commit is contained in:
parent
f4d748ebed
commit
3467af361c
@ -33,6 +33,8 @@ interface LocalStateProps {
|
|||||||
addDetailDrawer: (value: number | false) => void;
|
addDetailDrawer: (value: number | false) => void;
|
||||||
navigationOpen: boolean;
|
navigationOpen: boolean;
|
||||||
setNavigationOpen: (value: boolean) => void;
|
setNavigationOpen: (value: boolean) => void;
|
||||||
|
allowMobile: boolean;
|
||||||
|
setAllowMobile: (value: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useLocalState = create<LocalStateProps>()(
|
export const useLocalState = create<LocalStateProps>()(
|
||||||
@ -94,6 +96,10 @@ export const useLocalState = create<LocalStateProps>()(
|
|||||||
navigationOpen: false,
|
navigationOpen: false,
|
||||||
setNavigationOpen: (value) => {
|
setNavigationOpen: (value) => {
|
||||||
set({ navigationOpen: value });
|
set({ navigationOpen: value });
|
||||||
|
},
|
||||||
|
allowMobile: false,
|
||||||
|
setAllowMobile: (value) => {
|
||||||
|
set({ allowMobile: value });
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,7 @@ import { lazy, useEffect } from 'react';
|
|||||||
|
|
||||||
import { setApiDefaults } from '../App';
|
import { setApiDefaults } from '../App';
|
||||||
import { Loadable } from '../functions/loading';
|
import { Loadable } from '../functions/loading';
|
||||||
|
import { useLocalState } from '../states/LocalState';
|
||||||
|
|
||||||
function checkMobile() {
|
function checkMobile() {
|
||||||
const { height, width } = useViewportSize();
|
const { height, width } = useViewportSize();
|
||||||
@ -15,6 +16,7 @@ const DesktopAppView = Loadable(lazy(() => import('./DesktopAppView')));
|
|||||||
|
|
||||||
// Main App
|
// Main App
|
||||||
export default function MainView() {
|
export default function MainView() {
|
||||||
|
const [allowMobile] = useLocalState((state) => [state.allowMobile]);
|
||||||
// Set initial login status
|
// Set initial login status
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Local state initialization
|
// Local state initialization
|
||||||
@ -22,7 +24,7 @@ export default function MainView() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// Check if mobile
|
// Check if mobile
|
||||||
if (checkMobile()) {
|
if (!allowMobile && checkMobile()) {
|
||||||
return <MobileAppView />;
|
return <MobileAppView />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,8 +3,16 @@ import { Anchor, Center, Container, Stack, Text, Title } from '@mantine/core';
|
|||||||
|
|
||||||
import { BaseContext } from '../contexts/BaseContext';
|
import { BaseContext } from '../contexts/BaseContext';
|
||||||
import { docLinks } from '../defaults/links';
|
import { docLinks } from '../defaults/links';
|
||||||
|
import { IS_DEV } from '../main';
|
||||||
|
import { useLocalState } from '../states/LocalState';
|
||||||
|
|
||||||
export default function MobileAppView() {
|
export default function MobileAppView() {
|
||||||
|
const [setAllowMobile] = useLocalState((state) => [state.setAllowMobile]);
|
||||||
|
|
||||||
|
function ignore() {
|
||||||
|
setAllowMobile(true);
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<BaseContext>
|
<BaseContext>
|
||||||
<Center h="100vh">
|
<Center h="100vh">
|
||||||
@ -22,6 +30,11 @@ export default function MobileAppView() {
|
|||||||
<Anchor href={docLinks.app}>
|
<Anchor href={docLinks.app}>
|
||||||
<Trans>Read the docs</Trans>
|
<Trans>Read the docs</Trans>
|
||||||
</Anchor>
|
</Anchor>
|
||||||
|
{IS_DEV && (
|
||||||
|
<Text onClick={ignore}>
|
||||||
|
<Trans>Ignore and continue to Desktop view</Trans>
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
</Container>
|
</Container>
|
||||||
</Center>
|
</Center>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user