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

fix: error toast message while configuring trigger while creating a monitor #1178

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

vikhy-aws
Copy link

Description

This PR fixes the issue of an unnecessary error popup appearing while creation of a monitor. The error popup is raised because the config index is not been before a monitor is created, but is created automatically when the monitor is created. So, the error popup is redundant when creating a monitor.

image

Check List

  • Bug fix tested locally.
  • Added new unit test cases.
  • All tests passed.
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

vikhy-aws and others added 2 commits December 19, 2024 13:31
…onitor

Signed-off-by: vikhy-aws <191836418+vikhy-aws@users.noreply.github.com>
Signed-off-by: vikhy-aws <191836418+vikhy-aws@users.noreply.github.com>
package.json Outdated
@@ -34,7 +34,7 @@
"@babel/plugin-transform-modules-commonjs": "^7.22.9",
"@elastic/elastic-eslint-config-kibana": "link:../../packages/opensearch-eslint-config-opensearch-dashboards",
"@elastic/eslint-import-resolver-kibana": "link:../../packages/osd-eslint-import-resolver-opensearch-dashboards",
"cypress": "9.5.4",
"cypress": "12.17.4",
Copy link
Collaborator

Choose a reason for hiding this comment

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

why are we changing this? Have other plugins updated it as well?

Copy link
Author

Choose a reason for hiding this comment

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

So, the version of cypress in OpenSearch-Dashboards and the version of cypress in all the plugins should match for the frontend to run. So, set them to the same value.

Copy link
Author

Choose a reason for hiding this comment

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

LMK if this needs to be updated or not?

Copy link
Author

Choose a reason for hiding this comment

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

Reverted back

@@ -183,7 +183,10 @@ class ConfigureActions extends React.Component {
description: '',
}));
} else {
backendErrorNotification(notifications, 'load', 'destinations', response.err);
// If the config index is not created, don't show the notification
if (response.totalMonitors !== 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Club the else if?

Copy link
Author

Choose a reason for hiding this comment

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

Done

Comment on lines +183 to +185
totalMonitors: 0,
monitors: [],
message: "Config index will be created automatically when the monitor is created"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would rather keep the schema same and return a known error message which we can check for in the frontend instead of introducing a new field totalMonitors

Copy link
Author

Choose a reason for hiding this comment

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

totalMonitors is not a new field, it's been already used in some places. I'm just reusing the same to handle exceptions.

Used here:
https://github.com/opensearch-project/alerting-dashboards-plugin/blob/aec20bd457866e2eb2d0d949a32f1bbd0c7425bd/server/services/MonitorService.js#L483C7-L489C8


beforeEach(() => {
mockClient = jest.fn();

Copy link
Collaborator

Choose a reason for hiding this comment

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

Generally we don't add empty lines between initializations

Signed-off-by: vikhy-aws <191836418+vikhy-aws@users.noreply.github.com>
@vikhy-aws vikhy-aws requested a review from amsiglan December 21, 2024 00:25
amsiglan
amsiglan previously approved these changes Dec 21, 2024
Signed-off-by: vikhy-aws <191836418+vikhy-aws@users.noreply.github.com>
@@ -182,8 +182,9 @@ class ConfigureActions extends React.Component {
type: toChannelType(destination.type),
description: '',
}));
} else {
backendErrorNotification(notifications, 'load', 'destinations', response.err);
} else if (response.totalMonitors !== 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Am hazy on my JS but are you intending to check response.totalMonitor > 0

if yes, why are we checking for >0 and then code comment says config index not created?

Copy link
Author

Choose a reason for hiding this comment

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

So, the config index will be created automatically when the monitor is created. So, when the totalMonitors is 0 it is expected that the config index has not been created, and we don't want to show that error popup to the user.

@vikhy-aws vikhy-aws requested review from amsiglan and eirsep December 23, 2024 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants