-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Add request flyouts to JSON watch form and Threshold Watch edit form. #43232
Add request flyouts to JSON watch form and Threshold Watch edit form. #43232
Conversation
Pinging @elastic/es-ui |
💔 Build Failed |
💔 Build Failed |
Retest |
💚 Build Succeeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cjcenizal tested locally and LGTM. Thanks for adding this!
One thing to note, the name
field in the UI is actually added to the metadata
field on the server side (https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-put-watch.html#_request_body_7).
This is more of a UI thing, so not sure if we need to surface it in the request flyout, but just wanted to point it out.
…hresholdWatch function. - Refactor build helpers to accept specific arguments instead of the entire watch object, to make dependencies more obvious.
- Move action models into common directory. - Remove boom error reporting from action models because this is an unnecessary level of defensiveness since we control the UI that consumes this API. - Make changes to action model valiation which may or may not break the UX. - Add serializeJsonWatch function and consume it within the JSON Watch edit form.
eaff848
to
215cd03
Compare
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
bc2b99b
to
86d274a
Compare
- Convert tests from Mocha to Jest. - Remove mocks and fix assertions that depended upon mocked dependencies. These assertions were low-value because they tested implementation details. - Remove other assertions based upon implementation details.
86d274a
to
cc91b97
Compare
💚 Build Succeeded |
@elastic/apm I believe APM consumes the Kibana Watcher API. Could you please verify that I haven't broken anything you depend upon in this PR? |
💔 Build Failed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I haven't tested locally. I guess that all the tests you removed is because the UI has changed so it is probably better for @alisonelizabeth to make sure those are not needed anymore.
I really wish Watcher could be refactored at some point, the concept fromUpStream
fromDownstream
makes this always dificult to go back to this app 😊
@@ -35,43 +31,13 @@ describe('action', () => { | |||
}; | |||
}); | |||
|
|||
it(`throws an error if no 'id' property in json`, () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not the last one that changed the code so I am guessing that if your removed all these tests is because we don't need those validations anymore in the UI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original implementation threw boom
errors when these properties were missing in fromUpstreamJson
, which I believe means it was making assertions against the response from Elasticsearch when retrieving a watch with actions. I removed this logic because it both seems like an extreme corner case and the user also wouldn't have a clear way of fixing the problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Sounds more like an api integration tests indeed. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 I was thinking the same thing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to break the APM integration with watcher. We do a
PUT /api/watcher/watch/{watcher_id}
which returns a 404. If you changed the endpoint can you perhaps update it accordingly in:
https://github.com/elastic/kibana/blob/master/x-pack/legacy/plugins/apm/public/services/rest/watcher.js
Thanks :)
EDIT: above might not be correct. But I can't verify whether watcher works because I get the following error when going to the watcher ui:
Uncaught TypeError: Cannot read property 'space' of null
at new NavControlPopover (nav_control_popover.tsx:109)
at constructClassInstance (react-dom.development.js:11312)
at updateClassComponent (react-dom.development.js:14481)
at beginWork (react-dom.development.js:15438)
at performUnitOfWork (react-dom.development.js:19106)
at workLoop (react-dom.development.js:19146)
at HTMLUnknownElement.callCallback (react-dom.development.js:149)
at Object.invokeGuardedCallbackDev (react-dom.development.js:199)
at invokeGuardedCallback (react-dom.development.js:256)
at replayUnitOfWork (react-dom.development.js:18372)
Looks like Watcher expects Spaces
to be enabled, and fails if it isn't.
💚 Build Succeeded |
💚 Build Succeeded |
…ing conflict resolution in last merge.
@sqren Could you take another look? The problem was that the code was overwriting provided metadata. I've updated the logic to add onto it instead of overwrite it. |
💚 Build Succeeded |
💚 Build Succeeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metadata works again 🎉
Thanks for fixing this 👍
…elastic#43232) * Refactor watch serialization logic into common serialization functions. - Refactor build helpers to accept specific arguments instead of the entire watch object, to make dependencies more obvious. - Move action models into common directory. * Remove boom error reporting from action models because this is an unnecessary level of defensiveness since we control the UI that consumes this API. * Convert tests from Mocha to Jest. - Remove mocks and fix assertions that depended upon mocked dependencies. These assertions were low-value because they tested implementation details. - Remove other assertions based upon implementation details. * Remove serializeMonitoringWatch logic, since Monitoring doesn't use the create endpoint.
…#43232) (#46634) * Refactor watch serialization logic into common serialization functions. - Refactor build helpers to accept specific arguments instead of the entire watch object, to make dependencies more obvious. - Move action models into common directory. * Remove boom error reporting from action models because this is an unnecessary level of defensiveness since we control the UI that consumes this API. * Convert tests from Mocha to Jest. - Remove mocks and fix assertions that depended upon mocked dependencies. These assertions were low-value because they tested implementation details. - Remove other assertions based upon implementation details. * Remove serializeMonitoringWatch logic, since Monitoring doesn't use the create endpoint.
💔 Build Failed |
@sebelga I'd love to get rid of the upstream and downstream stuff too. The good news is this PR is a big step in that direction. Now that we have serialization functions, it should be a straightforward process of migrating over the last few consumers of At that point we would need to write the complementary deserialization functions, and migrate over the various consumers of That would take care of this stuff on the server, but there are still client-side models with Because all of this work is time-consuming and prone to introducing errors if not done carefully, I'd like to defer it until a feature or bugfix necessitates it. |
@cjcenizal Yeah I understand the risk/time-consuming part. It will be very important to type well the contract before starting the refactor. This means making sure there aren't any instances of |
Fixes #42796
This shows the request for JSON and Threshold watches. The logic for generating a request from the threshold watch form was distributed throughout the client and server and required significant refactoring for me to use it on the client.
Reviewers
I recommend reviewing the commit history first to get a feel of the intention behind each commit, and then reviewing each commit individually to follow my workflow. This way you'll be reviewing one cohesive group of changes at a time, which should be easier to follow and review.
Notable changes
I'm concerned about some specific changes to the code. I'll add comments on the relevant lines.
To-do
register_execute_route
andregister_visualize_route
depend uponWatch.fromDownstreamJson
, which is what theserialization
functions replace. I need to verify I haven't broken these routes. DONE: these routes look like they are functioning correctly, though there is still plenty of room for improvement and refactoring. Though that work is outside the scope of this PR.Release note
This is a minor enhancement to display the underlying Elasticsearch endpoint in Watcher's create and edit forms. Users can copy and paste this endpoint and payload to execute the request manually or use it within a script or other automated system.