"Fossies" - the Fresh Open Source Software Archive 
Member "selenium-selenium-4.8.1/javascript/grid-ui/src/screens/Sessions/Sessions.tsx" (17 Feb 2023, 2585 Bytes) of package /linux/www/selenium-selenium-4.8.1.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TSX (TypeScript with React) source code syntax highlighting (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
1 // Licensed to the Software Freedom Conservancy (SFC) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The SFC licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License. You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing,
12 // software distributed under the License is distributed on an
13 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, either express or implied. See the License for the
15 // specific language governing permissions and limitations
16 // under the License.
17
18 import React from 'react'
19 import RunningSessions from '../../components/RunningSessions/RunningSessions'
20 import { useQuery } from '@apollo/client'
21 import { loader } from 'graphql.macro'
22 import Grid from '@mui/material/Grid'
23 import QueuedSessions from '../../components/QueuedSessions/QueuedSessions'
24 import NoData from '../../components/NoData/NoData'
25 import Loading from '../../components/Loading/Loading'
26 import Error from '../../components/Error/Error'
27 import { GridConfig } from '../../config'
28
29 const GRID_SESSIONS_QUERY = loader('../../graphql/sessions.gql')
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
37 if (error !== undefined) {
38 const message = 'There has been an error while loading running and ' +
39 'queued Sessions from the Grid.'
40 const errorMessage = error?.networkError?.message
41 return (
42 <Grid container>
43 <Error message={message} errorMessage={errorMessage} />
44 </Grid>
45 )
46 }
47
48 if (loading) {
49 return (
50 <Grid container>
51 <Loading />
52 </Grid>
53 )
54 }
55
56 if (data.sessionsInfo.sessionQueueRequests.length === 0 &&
57 data.sessionsInfo.sessions.length === 0) {
58 const shortMessage = 'No running or queued sessions at the moment.'
59 return (
60 <Grid container>
61 <NoData message={shortMessage} />
62 </Grid>
63 )
64 }
65
66 return (
67 <Grid container>
68 <RunningSessions
69 sessions={data.sessionsInfo.sessions}
70 origin={window.location.origin}
71 />
72 <QueuedSessions
73 sessionQueueRequests={data.sessionsInfo.sessionQueueRequests}
74 />
75 </Grid>
76 )
77 }
78
79 export default Sessions