-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Session log modal transition handling (#2943)
Resolves #2944 **Changes:** - Refactored session log modal opening mechanism to use React transitions for smoother loading states - Added proper cleanup of selected kernel when container log modal closes - Improved modal state management by moving logic to a dedicated component **Rationale:** The changes improve the user experience when opening session logs by: - Preventing UI jank during loading with transition states - Ensuring cleaner state management between modal opens/closes **Effects:** Users will experience: - Smoother transitions when opening session logs - More consistent behavior when closing and reopening logs - Better handling of loading states with visual feedback
- Loading branch information
Showing
4 changed files
with
93 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
react/src/components/SessionDetailAndContainerLogOpenerLegacy.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import ContainerLogModalWithLazyQueryLoader from './ComputeSessionNodeItems/ContainerLogModalWithLazyQueryLoader'; | ||
import SessionDetailDrawer from './SessionDetailDrawer'; | ||
import { useState, useEffect, useTransition } from 'react'; | ||
import { useQueryParam, StringParam } from 'use-query-params'; | ||
|
||
const SessionDetailAndContainerLogOpenerLegacy = () => { | ||
const [sessionId, setSessionId] = useQueryParam('sessionDetail', StringParam); | ||
const [containerLogModalSessionId, setContainerLogModalSessionId] = | ||
useState<string>(); | ||
const [isPendingLogModalOpen, startLogModalOpenTransition] = useTransition(); | ||
|
||
useEffect(() => { | ||
const handler = (e: any) => { | ||
startLogModalOpenTransition(() => { | ||
setContainerLogModalSessionId(e.detail); | ||
}); | ||
}; | ||
document.addEventListener('bai-open-session-log', handler); | ||
return () => { | ||
document.removeEventListener('bai-open-session-log', handler); | ||
}; | ||
}, [startLogModalOpenTransition, setContainerLogModalSessionId]); | ||
|
||
return ( | ||
<> | ||
<SessionDetailDrawer | ||
open={!sessionId} | ||
sessionId={sessionId || undefined} | ||
onClose={() => { | ||
setSessionId(null, 'replaceIn'); | ||
}} | ||
/> | ||
<ContainerLogModalWithLazyQueryLoader | ||
open={!!containerLogModalSessionId || isPendingLogModalOpen} | ||
loading={isPendingLogModalOpen} | ||
sessionId={containerLogModalSessionId} | ||
onRequestClose={() => { | ||
setContainerLogModalSessionId(undefined); | ||
}} | ||
/> | ||
</> | ||
); | ||
}; | ||
export default SessionDetailAndContainerLogOpenerLegacy; |