Skip to content

Commit

Permalink
[ML] Only enable apply button in anomaly detection datafeed chart if …
Browse files Browse the repository at this point in the history
…changes have been made (elastic#174425)

Fixes elastic#174406, so that the apply
button is only enabled in the anomaly detection datafeed chart flyout if
changes have been made.

## Summary

Compares current query delay value vs edited value to determine if the
apply button should be disabled.


https://github.com/elastic/kibana/assets/264922/6c7d3889-271e-4849-9e9d-6246a8757648



### Checklist

- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

---------

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
kalabro and kibanamachine authored Jan 9, 2024
1 parent 636c65b commit abc712c
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const EditQueryDelay: FC<{
queryDelay: Datafeed['query_delay'];
isEnabled: boolean;
}> = ({ datafeedId, queryDelay, isEnabled }) => {
const [currentQueryDelay, setCurrentQueryDelay] = useState(queryDelay);
const [newQueryDelay, setNewQueryDelay] = useState<string | undefined>();
const [isEditing, setIsEditing] = useState<boolean>(false);
const { updateDatafeed } = useMlApiContext();
Expand All @@ -45,6 +46,7 @@ export const EditQueryDelay: FC<{
datafeedId,
datafeedConfig: { query_delay: newQueryDelay },
});
setCurrentQueryDelay(newQueryDelay);
displaySuccessToast(
i18n.translate(
'xpack.ml.jobsList.datafeedChart.editQueryDelay.changesSavedNotificationMessage',
Expand Down Expand Up @@ -120,7 +122,12 @@ export const EditQueryDelay: FC<{
<EuiFlexItem grow={false}>
<EuiFlexGroup gutterSize="none" direction="column">
<EuiFlexItem grow={false}>
<EuiButtonEmpty color="primary" size="xs" onClick={updateQueryDelay}>
<EuiButtonEmpty
disabled={newQueryDelay === currentQueryDelay}
color="primary"
size="xs"
onClick={updateQueryDelay}
>
<FormattedMessage
id="xpack.ml.jobsList.datafeedChart.applyQueryDelayLabel"
defaultMessage="Apply"
Expand Down

0 comments on commit abc712c

Please sign in to comment.