Skip to content

Commit

Permalink
Fix validation
Browse files Browse the repository at this point in the history
  • Loading branch information
nkhristinin committed Jul 20, 2022
1 parent f73fa29 commit b785fc9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,12 @@ const StepDefineRuleComponent: FC<StepDefineRuleProps> = ({
const onChangeDataSource = useCallback(
(optionId: string) => {
form.setFieldValue('dataSourceType', optionId);
form.getFields().index.reset({
resetValue: false,
});
form.getFields().dataViewId.reset({
resetValue: false,
});
},
[form]
);
Expand Down Expand Up @@ -651,7 +657,7 @@ const StepDefineRuleComponent: FC<StepDefineRuleProps> = ({
let dataForDescription: Partial<DefineStepRule> = initialState;

if (dataSourceType === DataSourceType.IndexPatterns) {
dataForDescription = omit(initialState, ['dataSourceType', 'dataViewID']);
dataForDescription = omit(initialState, ['dataSourceType', 'dataViewId']);
} else if (dataSourceType === DataSourceType.DataView) {
dataForDescription = omit(initialState, ['dataSourceType', 'index']);
}
Expand All @@ -672,14 +678,6 @@ const StepDefineRuleComponent: FC<StepDefineRuleProps> = ({
<StyledVisibleContainer isVisible={false}>
<UseField
path="dataSourceType"
config={{
...(schema.dataSourceType as {
defaultValue: string;
fieldsToValidateOnChange: string[];
type: string;
validations: [];
}),
}}
componentProps={{
euiFieldProps: {
fullWidth: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,4 @@ export const schema: FormSchema<DefineStepRule> = {
},
],
},
dataSourceType: {
defaultValue: DataSourceType.IndexPatterns,
fieldsToValidateOnChange: ['dataSourceType', 'index', 'dataViewId'],
type: FIELD_TYPES.TEXT,
validations: [],
},
};

0 comments on commit b785fc9

Please sign in to comment.