From 487bf50544c0581bee73e1a10521a60a976aee5e Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Wed, 30 Sep 2020 10:03:30 -0400 Subject: [PATCH] Don't display a negative time If the remaining session time dips below 0 imediately before auto- logout, ceil the display value to 0 to avoid showing negative seconds left. --- awx/ui_next/src/components/AppContainer/AppContainer.jsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/awx/ui_next/src/components/AppContainer/AppContainer.jsx b/awx/ui_next/src/components/AppContainer/AppContainer.jsx index 4fa8ab1ee7..0abd198c07 100644 --- a/awx/ui_next/src/components/AppContainer/AppContainer.jsx +++ b/awx/ui_next/src/components/AppContainer/AppContainer.jsx @@ -95,7 +95,7 @@ function AppContainer({ i18n, navRouteConfig = [], children }) { const sessionIntervalId = useRef(); const [sessionTimeout, setSessionTimeout] = useStorage(SESSION_TIMEOUT_KEY); const [timeoutWarning, setTimeoutWarning] = useState(false); - const [timeRemaining, setTimeRemaining] = useState(Infinity); + const [timeRemaining, setTimeRemaining] = useState(null); const handleAboutModalOpen = () => setIsAboutModalOpen(true); const handleAboutModalClose = () => setIsAboutModalOpen(false); @@ -132,7 +132,7 @@ function AppContainer({ i18n, navRouteConfig = [], children }) { }, [history, sessionTimeout]); useEffect(() => { - if (timeRemaining <= 1) { + if (timeRemaining !== null && timeRemaining <= 1) { handleLogout(); } }, [handleLogout, timeRemaining]); @@ -220,7 +220,7 @@ function AppContainer({ i18n, navRouteConfig = [], children }) { 0 && timeRemaining > 0} + isOpen={timeoutWarning && sessionTimeout > 0 && timeRemaining !== null} onClose={handleLogout} showClose={false} variant="warning" @@ -239,7 +239,7 @@ function AppContainer({ i18n, navRouteConfig = [], children }) { > {i18n._( t`You will be logged out in ${Number( - Math.floor(timeRemaining / 1000) + Math.max(Math.floor(timeRemaining / 1000), 0) )} seconds due to inactivity.` )}