Skip to content

Commit

Permalink
Merge pull request #5821 from glekner/fix-1850395
Browse files Browse the repository at this point in the history
Bug 1850395: Affinity modal crashes when user tries to change Operator
  • Loading branch information
openshift-merge-robot committed Jun 25, 2020
2 parents 3b945a1 + cafcd0e commit 50c6e66
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Expand Up @@ -97,7 +97,7 @@ export const AffinityEdit: React.FC<AffinityEditProps> = ({
const isWeightInvalid = !isWeightValid(focusedAffinity);

const isAffinityInvalid =
(affinityExpressions.length === 0 && affinityFields.length === 0) ||
(affinityExpressions?.length === 0 && affinityFields?.length === 0) ||
isWeightInvalid ||
isExpressionsInvalid ||
(isNodeAffinity && isFieldsInvalid) ||
Expand Down
Expand Up @@ -20,7 +20,7 @@ export const AffinityExpressionRow = ({
onDelete,
rowID = 'affinity',
}: AffinityExpressionRowProps) => {
const { id, key, values, operator } = expression;
const { id, key, values = [], operator } = expression;
const enableValueField = operator !== 'Exists' && operator !== 'DoesNotExist';
const [isValuesExpanded, setIsValuesExpanded] = React.useState(false);

Expand Down
Expand Up @@ -6,9 +6,9 @@ export const isWeightValid = (focusedAffinity: AffinityRowData) =>
(focusedAffinity.weight > 0 && focusedAffinity.weight <= 100);

export const isTermsInvalid = (terms: AffinityLabel[]) =>
terms.some(
terms?.some(
({ key, values, operator }) =>
!key || ((operator === 'In' || operator === 'NotIn') && values.length === 0),
!key || ((operator === 'In' || operator === 'NotIn') && values?.length === 0),
);

export const getTopologyKeyValidation = ({ type, condition, topologyKey }: AffinityRowData) => {
Expand Down

0 comments on commit 50c6e66

Please sign in to comment.