Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Index management] Fix errors with validation #56072

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ export class EditSettingsJson extends React.PureComponent {
const editor = (this.editor = createAceEditor(this.aceDiv, prettyJson, false, settingsKeys));
const session = editor.getSession();
session.on('changeAnnotation', () => {
this.setState({ valid: session.getAnnotations().length === 0 });
const isEmptyString = session.getValue() === '';
this.setState({ valid: !isEmptyString && session.getAnnotations().length === 0 });
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
EuiButton,
EuiCallOut,
EuiContextMenu,
EuiFieldText,
EuiFieldNumber,
EuiForm,
EuiFormRow,
EuiPopover,
Expand Down Expand Up @@ -368,7 +368,7 @@ export class IndexActionsContextMenu extends Component {
<EuiSpacer size="m" />

<EuiForm
isInvalid={this.forcemergeSegmentsError()}
isInvalid={!!this.forcemergeSegmentsError()}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it still possible for this error condition to come about given the EuiFieldNumber change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could type a negative number so I think the validation is still necessary.

error={this.forcemergeSegmentsError()}
>
<EuiFormRow
Expand All @@ -380,10 +380,11 @@ export class IndexActionsContextMenu extends Component {
)}
helpText={helpText}
>
<EuiFieldText
<EuiFieldNumber
onChange={event => {
this.setState({ forcemergeSegments: event.target.value });
}}
min={1}
name="maxNumberSegments"
/>
</EuiFormRow>
Expand Down