Refactored scoutsuite rule count badge readability.

This commit is contained in:
VakarisZ 2021-01-13 17:57:54 +02:00
parent b90f6587c1
commit 87dafeb440
1 changed files with 12 additions and 3 deletions

View File

@ -27,18 +27,27 @@ export default class ScoutSuiteRuleButton extends Component {
hideCallback={this.toggleModal} />
<div className="text-center" style={{'display': 'grid'}}>
<Button variant={'monkey-info'} size={'lg'} onClick={this.toggleModal}>
<FontAwesomeIcon icon={faList}/> ScoutSuite rules {this.createRuleCountBadge()}
<FontAwesomeIcon icon={faList}/> ScoutSuite rules
&nbsp;<RuleCountBadge count={this.props.scoutsuite_rules.length}/>
</Button>
</div>
</>);
}
createRuleCountBadge() {
const ruleCount = this.props.scoutsuite_rules.length > 9 ? '9+' : this.props.scoutsuite_rules.length;
return <Badge variant={'monkey-info-light'}>{ruleCount}</Badge>;
}
}
function RuleCountBadge(props) {
const maxRuleCountToShow = 9;
const textForMoreThanMaxRuleCount = maxRuleCountToShow + '+';
const ruleCountText = props.count > maxRuleCountToShow ?
textForMoreThanMaxRuleCount : props.count;
return <Badge variant={'monkey-info-light'}>{ruleCountText}</Badge>;
}
ScoutSuiteRuleButton.propTypes = {
scoutsuite_rules: PropTypes.array,
scoutsuite_data: PropTypes.object