83 lines
2.4 KiB
JavaScript
83 lines
2.4 KiB
JavaScript
import React from "react";
|
|
import PropTypes from "prop-types";
|
|
import { TableCell, TableRow, IconButton, Collapse } from "@material-ui/core";
|
|
import { KeyboardArrowDown, KeyboardArrowUp } from "@material-ui/icons";
|
|
import { makeStyles } from "@material-ui/core/styles";
|
|
import MachineLog from "./common/MachineLog";
|
|
import { useSensitiveInfo } from "../../../hooks";
|
|
import ActionsGroup from "./common/ActionsGroup";
|
|
|
|
const useRowStyles = makeStyles({
|
|
root: {
|
|
"& > *": {
|
|
borderBottom: "unset"
|
|
}
|
|
}
|
|
});
|
|
|
|
const MachineTableRow = ({
|
|
machine,
|
|
actions,
|
|
logs,
|
|
addLog,
|
|
secondaryActionsMenuProps
|
|
}) => {
|
|
const [open, setOpen] = React.useState(false);
|
|
const classes = useRowStyles();
|
|
const { mask } = useSensitiveInfo();
|
|
|
|
return (
|
|
<React.Fragment>
|
|
<TableRow className={classes.root}>
|
|
<TableCell>
|
|
<IconButton
|
|
aria-label="expand row"
|
|
size="small"
|
|
onClick={() => setOpen(!open)}
|
|
>
|
|
{open ? <KeyboardArrowUp /> : <KeyboardArrowDown />}
|
|
</IconButton>
|
|
</TableCell>
|
|
<TableCell component="th" scope="row">
|
|
{mask(machine.fullMachineName)}
|
|
</TableCell>
|
|
<TableCell>{mask(machine.machineName)}</TableCell>
|
|
<TableCell>{mask(machine.iPv4Address)}</TableCell>
|
|
<TableCell>{mask(machine.macAddress)}</TableCell>
|
|
<TableCell align="right">
|
|
<ActionsGroup
|
|
machine={machine}
|
|
actions={actions}
|
|
addLog={addLog}
|
|
secondaryActionsMenuProps={secondaryActionsMenuProps}
|
|
/>
|
|
</TableCell>
|
|
</TableRow>
|
|
<TableRow>
|
|
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={6}>
|
|
<Collapse in={open} timeout="auto" unmountOnExit>
|
|
<MachineLog logs={logs} />
|
|
</Collapse>
|
|
</TableCell>
|
|
</TableRow>
|
|
</React.Fragment>
|
|
);
|
|
};
|
|
|
|
MachineTableRow.propTypes = {
|
|
machine: PropTypes.shape({
|
|
machineId: PropTypes.number.isRequired,
|
|
machineName: PropTypes.string.isRequired,
|
|
fullMachineName: PropTypes.string.isRequired,
|
|
macAddress: PropTypes.string.isRequired,
|
|
iPv4Address: PropTypes.string,
|
|
description: PropTypes.string
|
|
}).isRequired,
|
|
actions: PropTypes.array.isRequired,
|
|
logs: PropTypes.array.isRequired,
|
|
addLog: PropTypes.func.isRequired,
|
|
secondaryActionsMenuProps: PropTypes.object.isRequired
|
|
};
|
|
|
|
export default MachineTableRow;
|