[Fleet] Add support for select type in integrations#152550
[Fleet] Add support for select type in integrations#152550jillguyonnet merged 14 commits intoelastic:mainfrom
Conversation
df2075e to
3c9e055
Compare
|
Pinging @elastic/fleet (Team:Fleet) |
|
Hey @elastic/fleet , not sure which kind of release note this qualifies for, any suggestion? |
|
@jillguyonnet - This can probably use |
|
This is great I am wondering if can add this to the package policy validation https://github.com/nchaulet/kibana/blob/290cb9497c34e73c498c58f2270834406cfa295c/x-pack/plugins/fleet/common/services/validate_package_policy.ts#L318-L339 and reject values that are not a select option. |
| isEditPage, | ||
| isInvalid, | ||
| fieldLabel, | ||
| options, |
There was a problem hiding this comment.
I was suspicious about memoizing an array since it would be compared by reference, but I'm not sure at all if that could be an issue in this case. I didn't see any strangeness with local testing. Does anyone know?
…-ref HEAD~1..HEAD --fix'
…-ref HEAD~1..HEAD --fix'
| } | ||
|
|
||
| if (varDef.type === 'select') { | ||
| if (!varDef.options) { |
There was a problem hiding this comment.
Should we validate that the value is one of the options instead? That service validate user provided value not the package structure.
There was a problem hiding this comment.
Hey @nchaulet - Thanks for your input! Ah right, I suppose that will be handled by the package linter. Ok, so we can check that the value is either undefined or one the options' value.
Edit: I'm not sure in what scenario the value would be something else though?
There was a problem hiding this comment.
Edit: I'm not sure in what scenario the value would be something else though?
For a package policy created via an API call user can provide any value they want
There was a problem hiding this comment.
Thanks! I amended the validation, let me know.
…-ref HEAD~1..HEAD --fix'
…-ref HEAD~1..HEAD --fix'
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
## Summary This PR adds support for the new `select` var type in integrations. Context and discussion in related issue: elastic/package-spec#453 Related package-spec PR: elastic/package-spec#486 ### Screenshots #### Before Current `Scope` advanced option in the Elasticsearch metrics settings (free text field): <img width="777" alt="Screenshot 2023-03-08 at 09 37 30" src="https://user-images.githubusercontent.com/23701614/223664474-a5cc5c2b-43c3-451f-9678-30e8c661bfcf.png"> #### After Same option with a select instead: <img width="777" alt="Screenshot 2023-03-08 at 09 36 25" src="https://user-images.githubusercontent.com/23701614/223664552-37c56bff-d6c9-4035-af4c-3a27e355beed.png"> <img width="777" alt="Screenshot 2023-03-08 at 09 36 31" src="https://user-images.githubusercontent.com/23701614/223664581-9e92abfa-6202-433e-b4de-2740fc7c96bc.png"> ### Checklist - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [ ] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [ ] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
## Summary This PR is a followup fix to #152550. As discovered in elastic/integrations#5451 (comment), there is currently an issue where the select is invalid upon first render because no default `value` exists, yet the first option appears to be selected. The fix introduced in this PR replaces the EUISelect with a more flexible EUIComboBox component, with a placeholder with text `Select an option` when no value is selected. In addition, this new component allows the selection to be cleared, which can be useful for non required variables. If the package specifies a default value, it should be selected by default. Otherwise, the placeholder will render. Note that the field will not be valid upon first render if the variable is required and no default value is provided. <img width="1728" alt="Screenshot 2023-03-29 at 17 47 28" src="https://user-images.githubusercontent.com/23701614/228596370-d6b14c03-4a09-4f68-a137-95bb7ca7e78f.png"> <img width="1728" alt="Screenshot 2023-03-29 at 17 47 35" src="https://user-images.githubusercontent.com/23701614/228596387-dc99e4b2-5d9d-4218-baf1-010bf527b028.png"> <img width="1728" alt="Screenshot 2023-03-29 at 17 47 44" src="https://user-images.githubusercontent.com/23701614/228596415-9f1f73af-a9f5-4a88-a700-999213500c4e.png"> ### Repro steps 1. Run package-registry with version 1.5.0 of Elasticsearch integration from elastic/integrations#5451: 1. In integrations repo, check out the branch in elastic/integrations#5451 2. In `packages/elasticsearch/changelog.yml`, change `version: 1.5.0-next` to `version: 1.5.0` 3. In `packages/elasticsearch/manifest.yml`, change the version to 1.5.0 4. In the shell, `cd packages/elasticsearch` if not there already and `elastic-package build -v` 5. Run the package registry: `elastic-package stack up -v -d --services package-registry` 6. Check that it is running correctly and that you can see version 1.5.0 of Elasticsearch at https://localhost:8080/search?package=elasticsearch 2. Run Kibana in dev on this branch: 1. In your `kibana.dev.yml`, add `xpack.fleet.registryUrl: https://localhost:8080` if not there (⚠️ https, not http) 2. Before running `yarn start`, run `export NODE_EXTRA_CA_CERTS=$HOME/.elastic-package/profiles/default/certs/kibana/ca-cert.pem` in the same shell. This is to set up the certificate needed to access EPR with https. 3. In Kibana, add the Elasticsearch integration (should be version 1.5.0). Check that the `Scope` setting is controlled by a select. Note: in the latest version, this integration now provides a default value, which should be set to `node`. ### Checklist - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [ ] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [ ] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [ ] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
|
Great work completing this @jillguyonnet. Can you leave a comment with testing instructions for the QA team (probably using the new version of the Elasticsearch integration)? (@amolnater-qasource @dikshachauhan-qasource) |
|
@jen-huang @amolnater-qasource @dikshachauhan-qasource |
|
Thanks for sharing the guide. Further, we have validated the changes as mentioned are currently available on Cloud 8.8 Snapshot build and found them working fine. Build details: Observations:
Further, when we are using Preview API request option to validate the changes, we observed improper validation message is displayed. cc @jen-huang Please let us know if this is expected and if we missed any other validation. Thanks |
|
Thank you for your report!
These are expected 👍
I can reproduce this as well with version 1.5.0 of Elasticsearch. We should perhaps investigate whether this issue is related to this change, I am having a look. |
|
@jillguyonnet I agree it is not related to this change. @dikshachauhan-qasource could you file a separate issue with that finding? I think the |
|
@jillguyonnet My mistake, the @dikshachauhan-qasource This is expected behavior. The Preview API content expects you to replace |
|
Hi @jen-huang Thanks for addressing above query and sharing your feedback. Further, as mentioned we have re-tried to validate above scenario using Preview API request and have following observations: Working fine:
As per our understanding, Not Working Fine:
Please let us know if we still are missing anything here. Thanks |
@dikshachauhan-qasource This one is expected since this has a default value that will be filled in automatically if it is excluded: https://github.com/elastic/integrations/blob/main/packages/elasticsearch/manifest.yml#L73
Will follow up on this in #154905. |
|
Thank you @jen-huang for feedback on above mentioned scenario. |




Summary
This PR adds support for the new
selectvar type in integrations.Context and discussion in related issue: elastic/package-spec#453
Related package-spec PR: elastic/package-spec#486
Screenshots
Before
Current

Scopeadvanced option in the Elasticsearch metrics settings (free text field):After
Same option with a select instead:


Checklist
For maintainers