Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/javascript/grid-ui/src/components/Node/NodeDetailsDialog.tsx
3987 views
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 {
19
Box,
20
Button,
21
Chip,
22
Dialog,
23
DialogActions,
24
DialogContent,
25
DialogTitle,
26
IconButton,
27
Typography
28
} from '@mui/material'
29
import React, { useState } from 'react'
30
import {Info as InfoIcon } from '@mui/icons-material'
31
import OsLogo from '../common/OsLogo'
32
import NodeInfo from '../../models/node-info'
33
34
function NodeDetailsDialog (props) {
35
const [open, setOpen] = useState(false)
36
const { node } = props
37
const nodeInfo: NodeInfo = node
38
39
const getStatusColor = (status: string) => {
40
if (status === 'DOWN') return 'error'
41
if (status === 'DRAINING') return 'warning'
42
return 'success'
43
}
44
45
return (
46
<Box component='span'>
47
<IconButton
48
sx={{ bm: 1 }}
49
onClick={() => setOpen(true)}
50
data-testid={`node-info-${nodeInfo.id}`}
51
size='large'
52
>
53
<InfoIcon />
54
</IconButton>
55
<Dialog
56
onClose={() => setOpen(false)}
57
aria-labelledby='node-info-dialog' open={open}
58
>
59
<DialogTitle id='node-info-dialog'>
60
<Box display='flex' alignItems='center' gap={1} flexWrap='wrap'>
61
<OsLogo osName={nodeInfo.osInfo.name} />
62
<Box fontWeight='fontWeightBold' display='inline'>
63
URI:
64
</Box>
65
<Box display='inline'>{nodeInfo.uri}</Box>
66
<Chip
67
label={nodeInfo.status}
68
color={getStatusColor(nodeInfo.status)}
69
size='small'
70
sx={{ ml: 'auto' }}
71
/>
72
</Box>
73
</DialogTitle>
74
<DialogContent dividers>
75
<Typography gutterBottom>
76
Node Id: {nodeInfo.id}
77
</Typography>
78
<Typography gutterBottom>
79
Status: {nodeInfo.status}
80
</Typography>
81
<Typography gutterBottom>
82
OS Arch: {nodeInfo.osInfo.arch}
83
</Typography>
84
<Typography gutterBottom>
85
OS Name: {nodeInfo.osInfo.name}
86
</Typography>
87
<Typography gutterBottom>
88
OS Version: {nodeInfo.osInfo.version}
89
</Typography>
90
<Typography gutterBottom>
91
Total slots: {nodeInfo.slotCount}
92
</Typography>
93
<Typography gutterBottom>
94
Grid version: {nodeInfo.version}
95
</Typography>
96
</DialogContent>
97
<DialogActions>
98
<Button
99
onClick={() => setOpen(false)}
100
color='primary'
101
variant='contained'
102
>
103
Close
104
</Button>
105
</DialogActions>
106
</Dialog>
107
</Box>
108
)
109
}
110
111
export default NodeDetailsDialog
112
113