()
| 29 | import { useNavigate, useParams } from 'react-router-dom' |
| 30 | |
| 31 | function Sessions (): JSX.Element { |
| 32 | const { loading, error, data } = useQuery(GRID_SESSIONS_QUERY, { |
| 33 | pollInterval: GridConfig.status.xhrPollingIntervalMillis, |
| 34 | fetchPolicy: 'network-only' |
| 35 | }) |
| 36 | const navigate = useNavigate() |
| 37 | |
| 38 | const { sessionId } = useParams<{ sessionId: string }>() |
| 39 | |
| 40 | useEffect(() => { |
| 41 | if (data === undefined || data.sessionsInfo === undefined || data.sessionsInfo.sessions === undefined) { |
| 42 | return |
| 43 | } |
| 44 | if (sessionId && data.sessionsInfo.sessions.length === 0) { |
| 45 | navigate("/sessions") |
| 46 | } |
| 47 | }, [data, sessionId]) |
| 48 | |
| 49 | if (error !== undefined) { |
| 50 | const message = 'There has been an error while loading running and ' + |
| 51 | 'queued Sessions from the Grid.' |
| 52 | const errorMessage = error?.networkError?.message |
| 53 | return ( |
| 54 | <Grid container> |
| 55 | <Error message={message} errorMessage={errorMessage} /> |
| 56 | </Grid> |
| 57 | ) |
| 58 | } |
| 59 | |
| 60 | if (loading) { |
| 61 | return ( |
| 62 | <Grid container> |
| 63 | <Loading /> |
| 64 | </Grid> |
| 65 | ) |
| 66 | } |
| 67 | |
| 68 | if (data.sessionsInfo.sessionQueueRequests.length === 0 && |
| 69 | data.sessionsInfo.sessions.length === 0) { |
| 70 | const shortMessage = 'No running or queued sessions at the moment.' |
| 71 | return ( |
| 72 | <Grid container> |
| 73 | <NoData message={shortMessage} /> |
| 74 | </Grid> |
| 75 | ) |
| 76 | } |
| 77 | |
| 78 | return ( |
| 79 | <Grid container> |
| 80 | <RunningSessions |
| 81 | sessions={data.sessionsInfo.sessions} |
| 82 | origin={window.location.origin} |
| 83 | sessionId={sessionId} |
| 84 | /> |
| 85 | <QueuedSessions |
| 86 | sessionQueueRequests={data.sessionsInfo.sessionQueueRequests} |
| 87 | /> |
| 88 | </Grid> |
nothing calls this directly
no outgoing calls
no test coverage detected