MCPcopy Index your code
hub / github.com/SeleniumHQ/selenium / Overview

Function Overview

javascript/grid-ui/src/screens/Overview/Overview.tsx:46–241  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

44import { GRID_SESSIONS_QUERY } from '../../graphql/sessions'
45
46function Overview (): JSX.Element {
47 const { loading, error, data } = useQuery(NODES_QUERY, {
48 pollInterval: GridConfig.status.xhrPollingIntervalMillis,
49 fetchPolicy: 'network-only'
50 })
51
52 const { data: sessionsData } = useQuery(GRID_SESSIONS_QUERY, {
53 pollInterval: GridConfig.status.xhrPollingIntervalMillis,
54 fetchPolicy: 'network-only'
55 })
56
57 function compareSlotStereotypes(a: NodeInfo, b: NodeInfo, attribute: string): number {
58 const joinA = a.slotStereotypes.length === 1
59 ? a.slotStereotypes[0][attribute]
60 : a.slotStereotypes.slice().map(st => st[attribute]).reverse().join(',')
61 const joinB = b.slotStereotypes.length === 1
62 ? b.slotStereotypes[0][attribute]
63 : b.slotStereotypes.slice().map(st => st[attribute]).reverse().join(',')
64 return joinA.localeCompare(joinB)
65 }
66
67 const sortProperties = {
68 'platformName': (a, b) => compareSlotStereotypes(a, b, 'platformName'),
69 'status': (a, b) => (a.status ?? '').localeCompare(b.status ?? ''),
70 'uri': (a, b) => (a.uri ?? '').localeCompare(b.uri ?? ''),
71 'browserName': (a, b) => compareSlotStereotypes(a, b, 'browserName'),
72 'browserVersion': (a, b) => compareSlotStereotypes(a, b, 'browserVersion'),
73 'slotCount': (a, b) => {
74 const valueA = a.slotStereotypes.reduce((sum, st) => sum + st.slotCount, 0)
75 const valueB = b.slotStereotypes.reduce((sum, st) => sum + st.slotCount, 0)
76 return valueA < valueB ? -1 : 1
77 },
78 'id': (a, b) => (a.id < b.id ? -1 : 1)
79 }
80
81 const sortPropertiesLabel = {
82 'platformName': 'Platform Name',
83 'status': 'Status',
84 'uri': 'URI',
85 'browserName': 'Browser Name',
86 'browserVersion': 'Browser Version',
87 'slotCount': 'Slot Count',
88 'id': 'ID'
89 }
90
91 const [sortOption, setSortOption] = useState(Object.keys(sortProperties)[0])
92 const [sortOrder, setSortOrder] = useState(1)
93 const [sortedNodes, setSortedNodes] = useState<NodeInfo[]>([])
94 const [isDescending, setIsDescending] = useState(false)
95
96 const handleSortChange = (event: React.ChangeEvent<{ value: unknown }>) => {
97 setSortOption(event.target.value as string)
98 }
99
100 const handleOrderChange = (event: React.ChangeEvent<HTMLInputElement>) => {
101 setIsDescending(event.target.checked)
102 setSortOrder(event.target.checked ? -1 : 1)
103 }

Callers

nothing calls this directly

Calls 6

compareSlotStereotypesFunction · 0.85
browserVersionFunction · 0.85
filterMethod · 0.80
keysMethod · 0.45
mapMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected