diff options
| author | Ernst Widerberg <ernst@sunet.se> | 2022-04-25 10:13:59 +0200 |
|---|---|---|
| committer | Ernst Widerberg <ernst@sunet.se> | 2022-04-25 10:13:59 +0200 |
| commit | b0a5f0a52c4bdf6ad6af0de2c8d273898a03e0e5 (patch) | |
| tree | 674af99e983dea8c07a824aa6b3113fec74ed746 /src/components | |
| parent | 5d075558c6a47c53c3790847babf95a7ce9f958c (diff) | |
Refactor out utility function
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/ListItem.js | 12 | ||||
| -rw-r--r-- | src/components/ScanDetail.js | 15 |
2 files changed, 6 insertions, 21 deletions
diff --git a/src/components/ListItem.js b/src/components/ListItem.js index 2951c48..dcafe24 100644 --- a/src/components/ListItem.js +++ b/src/components/ListItem.js @@ -3,6 +3,8 @@ import React from "react"; import Button from "@mui/material/Button"; import Card from "@mui/material/Card"; +import { resultClassName } from "../util"; + class ListItem extends React.Component { render() { return ( @@ -26,15 +28,7 @@ class ListItem extends React.Component { <td>{this.props.system_name}</td> <td style={{ paddingRight: 0 }}> <Card - className={ - "result" + - (() => { - if (this.props.vulnerable) return " vulnerable"; - else if (this.props.investigation_needed) - return " investigation_needed"; - else return ""; - })() - } + className={resultClassName(this.props)} variant="outlined" > {this.props.display_name} diff --git a/src/components/ScanDetail.js b/src/components/ScanDetail.js index 34e7a12..9cf4740 100644 --- a/src/components/ScanDetail.js +++ b/src/components/ScanDetail.js @@ -7,6 +7,8 @@ import Tooltip from "@mui/material/Tooltip"; import InfoOutlinedIcon from "@mui/icons-material/InfoOutlined"; +import { resultClassName } from "../util"; + class ScanDetail extends React.Component { render() { return ( @@ -126,18 +128,7 @@ function CustomElement(props) { function Result(props) { return ( <div className="resultContainer"> - <Card - className={ - "result" + - (() => { - if (props.vulnerable) return " vulnerable"; - else if (props.investigation_needed) - return " investigation_needed"; - else return ""; - })() - } - variant="outlined" - > + <Card className={resultClassName(props)} variant="outlined"> {props.display_name} {props.description && ( <Tooltip title={props.description}> |
