ui: add warning message to PBA/Exploiters InfoPane

This commit is contained in:
Mike Salvatore 2021-01-28 10:12:28 -05:00
parent 5ed102bd09
commit 7ec8f0394c
3 changed files with 43 additions and 4 deletions

View File

@ -113,7 +113,16 @@ class AdvancedMultiSelect extends React.Component {
setPaneInfo = (itemKey) => { setPaneInfo = (itemKey) => {
let definitionObj = getFullDefinitionByKey(this.infoPaneRefString, this.registry, itemKey); let definitionObj = getFullDefinitionByKey(this.infoPaneRefString, this.registry, itemKey);
this.setState({infoPaneParams: {title: definitionObj.title, content: definitionObj.info, link: definitionObj.link}}); this.setState(
{
infoPaneParams: {
title: definitionObj.title,
content: definitionObj.info,
link: definitionObj.link,
showWarning: !(this.isSafe(itemKey))
}
}
);
} }
setPaneInfoToDefault() { setPaneInfoToDefault() {
@ -151,7 +160,8 @@ class AdvancedMultiSelect extends React.Component {
<InfoPane title={this.state.infoPaneParams.title} <InfoPane title={this.state.infoPaneParams.title}
body={this.state.infoPaneParams.content} body={this.state.infoPaneParams.content}
link={this.state.infoPaneParams.link}/> link={this.state.infoPaneParams.link}
showWarning={this.state.infoPaneParams.showWarning}/>
</div> </div>
); );
} }

View File

@ -4,10 +4,16 @@ import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import {faQuestionCircle} from '@fortawesome/free-solid-svg-icons'; import {faQuestionCircle} from '@fortawesome/free-solid-svg-icons';
import {getObjectFromRegistryByRef} from './JsonSchemaHelpers'; import {getObjectFromRegistryByRef} from './JsonSchemaHelpers';
import WarningIcon from './WarningIcon';
function getDefaultPaneParams(refString, registry) { function getDefaultPaneParams(refString, registry) {
let configSection = getObjectFromRegistryByRef(refString, registry); let configSection = getObjectFromRegistryByRef(refString, registry);
return ({title: configSection.title, content: configSection.description}); return (
{
title: configSection.title,
content: configSection.description,
showWarning: false
});
} }
function InfoPane(props) { function InfoPane(props) {
@ -48,11 +54,27 @@ function getSubtitle(props) {
} }
function getBody(props) { function getBody(props) {
let body = [<span key={'body'}>{props.body}</span>];
if (props.showWarning) {
body.push(getWarning());
}
return ( return (
<Card.Body className={'pane-body'}> <Card.Body className={'pane-body'}>
{props.body} {body}
</Card.Body> </Card.Body>
) )
} }
function getWarning() {
return (
<div className={'info-pane-warning'} key={'warning'}>
<WarningIcon/>This option may cause a system to become unstable or
change the system's state in undesirable ways. Therefore, this option
is not recommended for use in production or other sensitive environments.
</div>
);
}
export {getDefaultPaneParams, InfoPane} export {getDefaultPaneParams, InfoPane}

View File

@ -27,3 +27,10 @@
margin: 10px 15px; margin: 10px 15px;
padding: 0; padding: 0;
} }
.info-pane-warning {
margin-top: 1em;
}
.info-pane-warning .unsafe-indicator {
margin-left: 0em;
}