Skip to content

Commit

Permalink
Backport optional validation results changes from #125068 (#137204)
Browse files Browse the repository at this point in the history
  • Loading branch information
kpollich authored Jul 26, 2022
1 parent cb8fd9f commit 1b87800
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const PackagePolicyInputPanel: React.FunctionComponent<{
);

// Errors state
const errorCount = countValidationErrors(inputValidationResults);
const errorCount = inputValidationResults ? countValidationErrors(inputValidationResults) : 0;
const hasErrors = forceShowErrors && errorCount;

const hasInputStreams = useMemo(
Expand Down Expand Up @@ -193,7 +193,7 @@ export const PackagePolicyInputPanel: React.FunctionComponent<{
packageInputVars={packageInput.vars}
packagePolicyInput={packagePolicyInput}
updatePackagePolicyInput={updatePackagePolicyInput}
inputVarsValidationResults={{ vars: inputValidationResults.vars }}
inputVarsValidationResults={{ vars: inputValidationResults?.vars }}
forceShowErrors={forceShowErrors}
/>
{hasInputStreams ? <ShortenedHorizontalRule margin="m" /> : <EuiSpacer size="l" />}
Expand Down Expand Up @@ -238,7 +238,7 @@ export const PackagePolicyInputPanel: React.FunctionComponent<{
updatePackagePolicyInput(updatedInput);
}}
inputStreamValidationResults={
inputValidationResults.streams![packagePolicyInputStream!.data_stream!.dataset]
inputValidationResults?.streams![packagePolicyInputStream!.data_stream!.dataset]
}
forceShowErrors={forceShowErrors}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ export const PackagePolicyInputStreamConfig: React.FunctionComponent<{
const advancedVarsWithErrorsCount: number = useMemo(
() =>
advancedVars.filter(
({ name: varName }) => inputStreamValidationResults.vars?.[varName]?.length
({ name: varName }) => inputStreamValidationResults?.vars?.[varName]?.length
).length,
[advancedVars, inputStreamValidationResults.vars]
[advancedVars, inputStreamValidationResults?.vars]
);

return (
Expand Down Expand Up @@ -128,7 +128,7 @@ export const PackagePolicyInputStreamConfig: React.FunctionComponent<{
},
});
}}
errors={inputStreamValidationResults.vars![varName]}
errors={inputStreamValidationResults?.vars![varName]}
forceShowErrors={forceShowErrors}
/>
</EuiFlexItem>
Expand Down Expand Up @@ -185,7 +185,7 @@ export const PackagePolicyInputStreamConfig: React.FunctionComponent<{
},
});
}}
errors={inputStreamValidationResults.vars![varName]}
errors={inputStreamValidationResults?.vars![varName]}
forceShowErrors={forceShowErrors}
/>
</EuiFlexItem>
Expand Down

0 comments on commit 1b87800

Please sign in to comment.