Skip to content

Commit

Permalink
fix bug where rule form was blowing up because of a missing index fie…
Browse files Browse the repository at this point in the history
…ld on the form
  • Loading branch information
dhurley14 committed Jun 14, 2022
1 parent 6ef4f2a commit 6637e05
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,13 @@ const StepDefineRuleComponent: FC<StepDefineRuleProps> = ({
</EuiFlexItem>

<EuiFlexItem>
{dataSourceRadioIdSelected === DATA_VIEW_SELECT_ID ? (
DataViewSelectorMemo
) : (
<RuleTypeEuiFormRow $isVisible={dataSourceRadioIdSelected === DATA_VIEW_SELECT_ID}>
{DataViewSelectorMemo}
</RuleTypeEuiFormRow>
<RuleTypeEuiFormRow
$isVisible={dataSourceRadioIdSelected === INDEX_PATTERN_SELECT_ID}
fullWidth
>
<CommonUseField
path="index"
config={{
Expand All @@ -552,7 +556,7 @@ const StepDefineRuleComponent: FC<StepDefineRuleProps> = ({
},
}}
/>
)}
</RuleTypeEuiFormRow>
</EuiFlexItem>
</EuiFlexGroup>
</RuleTypeEuiFormRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,13 @@ export const schema: FormSchema<DefineStepRule> = {
const [{ path, formData }] = args;
// the dropdown defaults the dataViewId to an empty string somehow on render..
// need to figure this out.
const notEmptyDataViewId = formData.dataViewId != null && formData.dataViewId !== '';
const dataViewIdExists = formData.dataViewId != null && formData.dataViewId !== '';

const skipValidation =
isMlRule(formData.ruleType) ||
((formData.index != null || notEmptyDataViewId) &&
!(formData.index != null && notEmptyDataViewId));
dataViewIdExists ||
formData.index != null ||
formData.index.length > 0;

if (skipValidation) {
return;
Expand Down

0 comments on commit 6637e05

Please sign in to comment.