[Logs+] Extract custom integration resources to package#165510
[Logs+] Extract custom integration resources to package#165510Kerry350 merged 18 commits intoelastic:mainfrom
Conversation
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
372c73c to
94b991d
Compare
59edf59 to
70d4ad7
Compare
799f0f7 to
c229a91
Compare
…of github.com:Kerry350/kibana into 163788-extract-custom-integration-creation-to-package
…om-integration-creation-to-package
|
Pinging @elastic/infra-monitoring-ui (Team:Infra Monitoring UI) |
They are coming in #165782 |
Thanks. I'll get that fixed. @yngrdyn 👌 Yep. These tests were more aimed at the state machines etc within this PR. |
|
@tonyghiani I was thinking about the “not installed” errors a bit more for the cleanup operation. I wonder if these specific errors should actually just be silently handled and the machine allowed to progress to the success state. Ultimately if the “previously installed” item isn’t installed anyway, then what we want has already happened. I can think of situations where it might be pertinent for the user to know that what they’ve requested to delete wasn’t found, but this is a silent cleanup 🤔 My thinking was that this option would be supplied for quicker user flows (like this wizard), but the idea is this package can fulfil all sorts of flows / implementations, so it’s entirely possible some state might be provided for something that doesn’t exist anymore. It could also just be an option. |
Agree, this is an implicit behaviour that the user shouldn't even realize is happening as a side effect.
Yep, we are not providing an interactive way to "remove the integration that was created", so the user shouldn't be directly informed about something that wasn't even aware was happening.
Yeah is an option if we need to make it more flexible, but maybe exposing an event such as |
…om-integration-creation-to-package
|
@Kerry350 thanks for extracting the xstate utils ❤️ I'm looking forward to v5 with the new "system" concept, which should make wiring up different statecharts even easier. |
packages/kbn-custom-integrations/src/hooks/use_consumer_custom_integrations.ts
Outdated
Show resolved
Hide resolved
| }, | ||
| }, | ||
| }, | ||
| untouched: {}, |
There was a problem hiding this comment.
question: does untouched represent a final state?
There was a problem hiding this comment.
it's not a final state, no. I wanted something to differentiate invalid and untouched. With untouched we still want the button to be disabled (etc), due to not being valid, but we don't want to throw lots of errors at the user in the form fields because they haven't touched anything yet. Essentially the default values don't need to pass through the initial validation flow, as they're untouched. The top level UPDATE_FIELDS event will transition from here.
…p so that the failure flow works when cleanup is successful but the creation fails
| }; | ||
| }; | ||
|
|
||
| const validateConfigsAgainstContext = (validatorsConfig: ValidatorsConfig, context: any) => { |
There was a problem hiding this comment.
suggestion: took me some time to get the logic of this validation and I noticed the cases for validatorsOrValidator being a single function or an array are handled in parallel.
We could improve its readability always converting the value into an array to have a single logical flow, wdyt?
This snippet could fit the case:
const validateConfigsAgainstContext = (validatorsConfig, context) => {
return Object.entries(validatorsConfig).reduce((errors, [field, validatorsOrValidator]) => {
const validators = Array.isArray(validatorsOrValidator)
? validatorsOrValidator
: [validatorsOrValidator];
const fieldErrors = validators.flatMap((validator) => {
const error = validator(context[field]);
return error === null ? [] : [error];
});
return fieldErrors.length > 0 ? { ...errors, [field]: fieldErrors } : errors;
}, {});
};There was a problem hiding this comment.
I agree your version is more readable, but the resulting data structure is slightly different (array item errors aren’t an object keyed by array index).
I’m going to merge this PR without this change for now (just don’t want such a big PR sitting around). But I will make this more readable as part of my PR with the state machine tests 👍
packages/kbn-custom-integrations/src/state_machines/services/integrations_client.ts
Outdated
Show resolved
Hide resolved
tonyghiani
left a comment
There was a problem hiding this comment.
Code implementation LGTM and I appreciate the technical choice of controlling the flow with state machines!
I left a couple of notes around the PR, they are not blocking anyway.
Also thanks a lot for extracting into a package the Xstate utils, we'll be able to cleanup some existing code using it ❤️
|
@elastic/apm-ui Hi folks, would it be possible to get a review on this? The bulk of changes for your team should be in |
| } | ||
| } | ||
|
|
||
| const hasNamingCollision = |
There was a problem hiding this comment.
this is so much cleaner now 👯
yngrdyn
left a comment
There was a problem hiding this comment.
LGTM, since you extracted some stuff to a plugin some of the observabilityOnboarding e2e tests are failing
…om-integration-creation-to-package
…of github.com:Kerry350/kibana into 163788-extract-custom-integration-creation-to-package
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Public APIs missing exports
Page load bundle
Unknown metric groupsAPI count
ESLint disabled in files
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @Kerry350 |
Summary
This closes #163788.
High level overview
kbn-custom-integrationspackage.kbn-xstate-utilspackage (as these utils were in 2 plugins and now 1 package).logs, and one dataset, but it can be easily extended in the future to support all types and multiple datasets. The state machine is ready, it just needs exposed in the UI.The Configure integration section should more or less work the same as before.
Testing
/app/observabilityOnboarding/customLogscan you:Screenshots
State machine diagram
(The top level management machine is super basic, so this is just the create machine)
Followups