[Response Ops][Connectors] New xpack.actions.email.services.enabled Kibana setting#223363
[Response Ops][Connectors] New xpack.actions.email.services.enabled Kibana setting#223363jcger merged 19 commits intoelastic:mainfrom
xpack.actions.email.services.enabled Kibana setting#223363Conversation
1ac53e0 to
734e470
Compare
|
Pinging @elastic/response-ops (Team:ResponseOps) |
...atform/plugins/shared/stack_connectors/public/connector_types/email/email_connector.test.tsx
Outdated
Show resolved
Hide resolved
| const disableServiceConfig = shouldDisableEmailConfiguration(service); | ||
| const { isLoading, getEmailServiceConfig } = useEmailConfig({ http, toasts }); | ||
|
|
||
| useMount(() => { |
There was a problem hiding this comment.
This is after rendering, right? Shouldn't we fetch before rendering to prevent the UI from flashing?
There was a problem hiding this comment.
I'm not sure what you mean by "before rendering". I can only think of blocking the whole form or doing it server side. Server side isn't an option as we don't render server side, and blocking the whole form because of this seems like too much.
For more context: before my changes, we had a list of possible options, by default, it's set to empty. Once the user chooses an option, we fetch the linked data (host, port, and whether it's secure or not). But now, there is a chance that only one option is enabled and it would render as select with just one option. My changes are to set that only available service and it's linked data. useMount is just a useEffect with no dependencies in the dependency array. This way, it will only fetch once when the component is mounted in the DOM and yes, there will be a slight delay while loading the data linked to the enabled service.
| }).not.toThrowError(); | ||
| }); | ||
|
|
||
| test('error when using a service that is not enabled', async () => { |
There was a problem hiding this comment.
This part is key, so I would extend these tests to also include does not throw when config is [*] and does not throw when fetching service enabled in config
There was a problem hiding this comment.
| domain_allowlist: schema.maybe(schema.arrayOf(schema.string())), | ||
| services: schema.maybe( | ||
| schema.object({ | ||
| enabled: schema.maybe( |
There was a problem hiding this comment.
Here we set enabled: schema.maybe( but then schema.arrayOf has a default value. I think like this, the default value will never come into effect. We should probably pick one of the two.
There was a problem hiding this comment.
I did change/simplify this schema. The comment shouldn't apply anymore
| { | ||
| validator: emptyField(i18n.SERVICE_REQUIRED), | ||
| {availableEmailServices.length === 1 ? ( | ||
| <UseField |
There was a problem hiding this comment.
All tests changed in x-pack/platform/plugins/shared/stack_connectors/public/connector_types/email/email_connector.test.tsx expect the [*] scenario. We should also test when availableEmailServices.length === 1.
Maybe just checking that emailServiceInput exists.
There was a problem hiding this comment.
…l-services-kbn-cfg
…l-services-kbn-cfg
nastasha-solomon
left a comment
There was a problem hiding this comment.
Docs look good - thanks!
| * 2.0. | ||
| */ | ||
|
|
||
| export const serviceParamValueToKbnSettingMap = { |
...ck/platform/plugins/shared/stack_connectors/public/connector_types/email/email_connector.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Let's add a basic test for the new functionality (unless it has already been tested elsewhere; I haven't finished the review).
cnasikas
left a comment
There was a problem hiding this comment.
The initial bug I reported seems to not be easily reproducible and probably it is related with how the config is cached. I found another bug. If I have an already configured connector with a service, I change the config to make this service unavailable and I try to save the connector I get an error even though it shows another valid service.
Screen.Recording.2025-06-19.at.12.31.31.PM.mov
| validations: [ | ||
| { | ||
| validator: emptyField(i18n.SERVICE_REQUIRED), | ||
| {availableEmailServices.length === 1 ? ( |
There was a problem hiding this comment.
I think it is better if we do not introduce a separate field just for when the available services are. You could disable the selection (disabled: readOnly || isLoading || availableEmailServices.length <= 1,). I tested, and the result is visually the same. Nevertheless, I would say not to disable at all because users may want to change an already configured connector to the new valid service. Otherwise, they would have to delete that one and create a new one, meaning they would have to update all rules to use the new connector.
There was a problem hiding this comment.
Thanks, I didn't check that the disabled select doesn't show the "expand" icon on the right. I will show a service that is not enabled, but the current service value of the connector. This means that if the user tries to update, they'll not be able to do so because the service is not enabled, and they'll have to update it.
I should still be disabled if only one service is enabled, even if it only applies to new connectors.
| const disableServiceConfig = shouldDisableEmailConfiguration(service); | ||
| const { isLoading, getEmailServiceConfig } = useEmailConfig({ http, toasts }); | ||
|
|
||
| useMount(() => { |
There was a problem hiding this comment.
I am a bit confused why we want this extra API call. Should the useEffect achieve the same? The service is either what the user selected or what the connector is already configured. If the service is not part of the available services, and the connector is configured with such a service, we should probably not set any value or deselect the value. I think it is related to a bug I posted in my second review.
There was a problem hiding this comment.
The useEffect is triggered every time the user clicks on the select service component. I added useMount to automatically load the data linked to a service when there is only one service available. For example, if we just have amazon-ses, it will select that service and load the host, port and issecure fields automatically when rendering the form. Related to the bug you found, it shouldn't trigger if it's an already existing connector that has a service selected. Still useful for new connectors when only one service is enabled, though
There was a problem hiding this comment.
It wasn't possible, at least not in a simple manner. Instead, the dropdown will have as options the enabled services. On update, it will render the enabled services and the currently stored service. If the user just updates the name, the BE will throw until the service is updated to an enabled option. The downside is that if only one service is enabled, we'll show a dropdown with just one option and the user will have to manually select that only option.
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
History
|
cnasikas
left a comment
There was a problem hiding this comment.
LGTM! I tested and is working as expected. The bugs I mentioned are not reproducible anymore.
|
Starting backport for target branches: 8.19 |
💔 All backports failedManual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
… Kibana setting (elastic#223363) ## Summary Closes elastic#220288 ## Release note New kibana setting `xpack.actions.email.services.enabled` to enable/disable email services for email connector. (cherry picked from commit 411ab21) # Conflicts: # docs/reference/configuration-reference/alerting-settings.md # docs/settings-gen/source/kibana-alert-action-settings.yml
…nabled` Kibana setting (#223363) (#224710) # Backport This will backport the following commits from `main` to `8.19`: - [[Response Ops][Connectors] New `xpack.actions.email.services.enabled` Kibana setting (#223363)](#223363) <!--- Backport version: 10.0.1 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Julian Gernun","email":"17549662+jcger@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-06-20T14:10:43Z","message":"[Response Ops][Connectors] New `xpack.actions.email.services.enabled` Kibana setting (#223363)\n\n## Summary\n\nCloses #220288\n\n## Release note\nNew kibana setting `xpack.actions.email.services.enabled` to\nenable/disable email services for email connector.","sha":"411ab215a50c773fa535e48e1b7a8199176eefb0","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:ResponseOps","release_note:feature","backport:version","v9.1.0","v8.19.0"],"title":"[Response Ops][Connectors] New `xpack.actions.email.services.enabled` Kibana setting","number":223363,"url":"https://github.com/elastic/kibana/pull/223363","mergeCommit":{"message":"[Response Ops][Connectors] New `xpack.actions.email.services.enabled` Kibana setting (#223363)\n\n## Summary\n\nCloses #220288\n\n## Release note\nNew kibana setting `xpack.actions.email.services.enabled` to\nenable/disable email services for email connector.","sha":"411ab215a50c773fa535e48e1b7a8199176eefb0"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/223363","number":223363,"mergeCommit":{"message":"[Response Ops][Connectors] New `xpack.actions.email.services.enabled` Kibana setting (#223363)\n\n## Summary\n\nCloses #220288\n\n## Release note\nNew kibana setting `xpack.actions.email.services.enabled` to\nenable/disable email services for email connector.","sha":"411ab215a50c773fa535e48e1b7a8199176eefb0"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
… Kibana setting (elastic#223363) ## Summary Closes elastic#220288 ## Release note New kibana setting `xpack.actions.email.services.enabled` to enable/disable email services for email connector.
…c#228215) Available since 9.1 - 8.19 - elastic#223363 - elastic#221389 - elastic#221389 - elastic#222507 (cherry picked from commit 39dda35)
…c#228215) Available since 9.1 - 8.19 - elastic#223363 - elastic#221389 - elastic#221389 - elastic#222507
…c#228215) Available since 9.1 - 8.19 - elastic#223363 - elastic#221389 - elastic#221389 - elastic#222507

Summary
Closes #220288
Release note
New kibana setting
xpack.actions.email.services.enabledto enable/disable email services for email connector.