Skip to content

Commit

Permalink
Use UNSET_VALUE as default for SeverityValuesGroup RelationSelector
Browse files Browse the repository at this point in the history
  • Loading branch information
swaterkamp committed Jul 2, 2021
1 parent f48e62c commit 264c975
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
26 changes: 15 additions & 11 deletions gsa/src/web/components/powerfilter/relationselector.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,22 @@ import _ from 'gmp/locale';

import Select from 'web/components/form/select';
import PropTypes from 'web/utils/proptypes.js';
import {UNSET_LABEL, UNSET_VALUE} from 'web/utils/render';

const RelationSelector = ({relation, onChange}) => (
<Select
value={relation}
onChange={onChange}
items={[
{label: _('is equal to'), value: '='},
{label: _('is greater than'), value: '>'},
{label: _('is less than'), value: '<'},
]}
/>
);
const RelationSelector = ({relation, onChange}) => {
return (
<Select
value={relation}
onChange={onChange}
items={[
{label: UNSET_LABEL, value: UNSET_VALUE},
{label: _('is equal to'), value: '='},
{label: _('is greater than'), value: '>'},
{label: _('is less than'), value: '<'},
]}
/>
);
};

RelationSelector.propTypes = {
relation: PropTypes.string,
Expand Down
4 changes: 3 additions & 1 deletion gsa/src/web/components/powerfilter/severityvaluesgroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import RelationSelector from 'web/components/powerfilter/relationselector';
import NumberField from 'web/components/form/numberfield';
import Divider from 'web/components/layout/divider';

import {UNSET_VALUE} from 'web/utils/render';

const SeverityValuesGroup = ({filter, name, title, onChange}) => {
/* useState is analogous to setState in class components.
* the first argument is the state variable.
Expand All @@ -39,7 +41,7 @@ const SeverityValuesGroup = ({filter, name, title, onChange}) => {
const term = filter.getTerm(name);
const severity = isDefined(term) ? parseSeverity(term.value) : 0;

const [rel, setRel] = useState(isDefined(term) ? term.relation : '='); // here rel is set to '='
const [rel, setRel] = useState(isDefined(term) ? term.relation : UNSET_VALUE);
const keyword = name;

return (
Expand Down

0 comments on commit 264c975

Please sign in to comment.