mirror of
https://github.com/ansible/awx.git
synced 2026-05-09 18:37:36 -02:30
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.
This commit is contained in:
@@ -95,7 +95,7 @@ function AppContainer({ i18n, navRouteConfig = [], children }) {
|
|||||||
const sessionIntervalId = useRef();
|
const sessionIntervalId = useRef();
|
||||||
const [sessionTimeout, setSessionTimeout] = useStorage(SESSION_TIMEOUT_KEY);
|
const [sessionTimeout, setSessionTimeout] = useStorage(SESSION_TIMEOUT_KEY);
|
||||||
const [timeoutWarning, setTimeoutWarning] = useState(false);
|
const [timeoutWarning, setTimeoutWarning] = useState(false);
|
||||||
const [timeRemaining, setTimeRemaining] = useState(Infinity);
|
const [timeRemaining, setTimeRemaining] = useState(null);
|
||||||
|
|
||||||
const handleAboutModalOpen = () => setIsAboutModalOpen(true);
|
const handleAboutModalOpen = () => setIsAboutModalOpen(true);
|
||||||
const handleAboutModalClose = () => setIsAboutModalOpen(false);
|
const handleAboutModalClose = () => setIsAboutModalOpen(false);
|
||||||
@@ -132,7 +132,7 @@ function AppContainer({ i18n, navRouteConfig = [], children }) {
|
|||||||
}, [history, sessionTimeout]);
|
}, [history, sessionTimeout]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (timeRemaining <= 1) {
|
if (timeRemaining !== null && timeRemaining <= 1) {
|
||||||
handleLogout();
|
handleLogout();
|
||||||
}
|
}
|
||||||
}, [handleLogout, timeRemaining]);
|
}, [handleLogout, timeRemaining]);
|
||||||
@@ -220,7 +220,7 @@ function AppContainer({ i18n, navRouteConfig = [], children }) {
|
|||||||
</AlertModal>
|
</AlertModal>
|
||||||
<AlertModal
|
<AlertModal
|
||||||
title={i18n._(t`Your session is about to expire`)}
|
title={i18n._(t`Your session is about to expire`)}
|
||||||
isOpen={timeoutWarning && sessionTimeout > 0 && timeRemaining > 0}
|
isOpen={timeoutWarning && sessionTimeout > 0 && timeRemaining !== null}
|
||||||
onClose={handleLogout}
|
onClose={handleLogout}
|
||||||
showClose={false}
|
showClose={false}
|
||||||
variant="warning"
|
variant="warning"
|
||||||
@@ -239,7 +239,7 @@ function AppContainer({ i18n, navRouteConfig = [], children }) {
|
|||||||
>
|
>
|
||||||
{i18n._(
|
{i18n._(
|
||||||
t`You will be logged out in ${Number(
|
t`You will be logged out in ${Number(
|
||||||
Math.floor(timeRemaining / 1000)
|
Math.max(Math.floor(timeRemaining / 1000), 0)
|
||||||
)} seconds due to inactivity.`
|
)} seconds due to inactivity.`
|
||||||
)}
|
)}
|
||||||
</AlertModal>
|
</AlertModal>
|
||||||
|
|||||||
Reference in New Issue
Block a user