-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use NEO session log modal in session list (#2804)
**Changes:** With this PR, user can open a NEO session log modal in session list The new implementation uses a lazy-loaded query to fetch session logs and displays them in a modern container log modal. **Key Updates:** - Introduces `ContainerLogModalWithLazyQueryLoader` component for handling session logs - Adds event listener for `bai-open-session-log` to bridge legacy and React components - Implements suspense boundary with skeleton loading state - Replaces direct API calls with GraphQL queries for log fetching **Review Requirements:** - Open the log modal by clicking session's log button in session list.
- Loading branch information
Showing
4 changed files
with
145 additions
and
39 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
50 changes: 50 additions & 0 deletions
50
react/src/components/ComputeSessionNodeItems/ContainerLogModalWithLazyQueryLoader.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,50 @@ | ||
import { useCurrentProjectValue } from '../../hooks/useCurrentProject'; | ||
import ContainerLogModal from './ContainerLogModal'; | ||
import { ContainerLogModalWithLazyQueryLoaderQuery } from './__generated__/ContainerLogModalWithLazyQueryLoaderQuery.graphql'; | ||
import graphql from 'babel-plugin-relay/macro'; | ||
import { useState } from 'react'; | ||
import { useLazyLoadQuery } from 'react-relay'; | ||
|
||
const ContainerLogModalWithLazyQueryLoader: React.FC<{ | ||
sessionId: string; | ||
afterClose?: () => void; | ||
}> = ({ sessionId, afterClose }) => { | ||
const currentProject = useCurrentProjectValue(); | ||
const [open, setOpen] = useState(true); | ||
const { compute_session_node } = | ||
useLazyLoadQuery<ContainerLogModalWithLazyQueryLoaderQuery>( | ||
graphql` | ||
query ContainerLogModalWithLazyQueryLoaderQuery( | ||
$sessionId: GlobalIDField! | ||
$project_id: UUID! | ||
) { | ||
compute_session_node(id: $sessionId, project_id: $project_id) { | ||
...ContainerLogModalFragment | ||
} | ||
} | ||
`, | ||
{ | ||
sessionId, | ||
project_id: currentProject.id, | ||
}, | ||
); | ||
|
||
return ( | ||
compute_session_node && ( | ||
<ContainerLogModal | ||
maskTransitionName={open ? '' : undefined} | ||
transitionName={open ? '' : undefined} | ||
sessionFrgmt={compute_session_node} | ||
open={open} | ||
onCancel={() => { | ||
setOpen(false); | ||
}} | ||
afterClose={() => { | ||
afterClose?.(); | ||
}} | ||
/> | ||
) | ||
); | ||
}; | ||
|
||
export default ContainerLogModalWithLazyQueryLoader; |
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