forked from p15670423/monkey
Refactored scoutsuite rule count badge readability.
This commit is contained in:
parent
b90f6587c1
commit
87dafeb440
|
@ -27,18 +27,27 @@ export default class ScoutSuiteRuleButton extends Component {
|
||||||
hideCallback={this.toggleModal} />
|
hideCallback={this.toggleModal} />
|
||||||
<div className="text-center" style={{'display': 'grid'}}>
|
<div className="text-center" style={{'display': 'grid'}}>
|
||||||
<Button variant={'monkey-info'} size={'lg'} onClick={this.toggleModal}>
|
<Button variant={'monkey-info'} size={'lg'} onClick={this.toggleModal}>
|
||||||
<FontAwesomeIcon icon={faList}/> ScoutSuite rules {this.createRuleCountBadge()}
|
<FontAwesomeIcon icon={faList}/> ScoutSuite rules
|
||||||
|
<RuleCountBadge count={this.props.scoutsuite_rules.length}/>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</>);
|
</>);
|
||||||
}
|
}
|
||||||
|
|
||||||
createRuleCountBadge() {
|
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 = {
|
ScoutSuiteRuleButton.propTypes = {
|
||||||
scoutsuite_rules: PropTypes.array,
|
scoutsuite_rules: PropTypes.array,
|
||||||
scoutsuite_data: PropTypes.object
|
scoutsuite_data: PropTypes.object
|
||||||
|
|
Loading…
Reference in New Issue