[ResponseOps][Slack] Simplify channel configuration #245423
[ResponseOps][Slack] Simplify channel configuration #245423cnasikas merged 19 commits intoelastic:mainfrom
Conversation
…na into slack_ui_optional_channels
| import type { SlackApiConfig } from '@kbn/connector-schemas/slack_api'; | ||
|
|
||
| export const deserializer = (data: ConnectorFormSchema): InternalConnectorForm => { | ||
| const allowedChannels = (data.config?.allowedChannels as SlackApiConfig['allowedChannels']) ?? []; |
There was a problem hiding this comment.
The casting is needed because the TS types do not support templates, as they assume the data is the same for all connectors. I opened this issue: #246390.
There was a problem hiding this comment.
I wrote everything from scratch as a lot of the functionality was removed.
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| }, [defaultMessage, useDefaultMessage]); | ||
|
|
||
| return <SlackParamsFieldsComponent {...props} key={key} />; |
There was a problem hiding this comment.
The key will reset the state (useState) of the component if it changes. This helps to reset the fields when the connector changes.
| readOnly, | ||
| configFormSchema, | ||
| secretsFormSchema, | ||
| configFormSchemaAfterSecrets = [], |
There was a problem hiding this comment.
Not used by any connector type.
|
Pinging @elastic/response-ops (Team:ResponseOps) |
js-jankisalvi
left a comment
There was a problem hiding this comment.
Verified changes locally, working as expected with new and existing connectors and rules using those connectors
Few minor things (no blocker)
- Channels dropdown is different for Old connector (from main) test tab view than in rules action form
Old rule with old connector (from main)

-
As discussed offline, Help text with example for allowedChannels field could be helpful.
-
Also known bug - security solution rule form doesn't show channel on selecting/changing the connector
| return channel.name; | ||
| } | ||
|
|
||
| return `#${channel.name}`; |
There was a problem hiding this comment.
how can this happen? Did we miss a schema validation to check that channel.name starts with # ?
There was a problem hiding this comment.
The old code always put names without #. We can do the same but I thought users are more used to the # on front of channels and it will make it easier to distinguish channel names for channel IDs.
| const DEFAULT_PARAMS = { subAction: 'postMessage' as const, subActionParams: { text: undefined } }; | ||
|
|
||
| const getChannelErrors = (channels?: string[], channelIds?: string[], channelNames?: string[]) => { | ||
| const isUndefinedOrEmptyArray = (arr?: string[]) => { |
There was a problem hiding this comment.
nit: could be moved outside this function to avoid creating it each time
| await userEvent.paste('some token'); | ||
|
|
||
| await userEvent.click(screen.getByTestId('comboBoxSearchInput')); | ||
| await userEvent.type(screen.getByTestId('comboBoxSearchInput'), '#general{enter}'); |
There was a problem hiding this comment.
why not paste like the token? (just curious)
There was a problem hiding this comment.
Paste does not work with the combobox or at least I cannot make it work 🙂
| return; | ||
| } | ||
|
|
||
| const areAllValid = valueAsArray.every((value) => value.startsWith('#')); |
There was a problem hiding this comment.
does this not accept channel ids anymore? What's the point in forcing # as prefix in the UI then?
There was a problem hiding this comment.
No, not any more. For new usage, we will go with channel names, and the backend will throw an error if the # is not prefixed on the channel name.
There was a problem hiding this comment.
It's no breaking change because it will still be working, it's just that the UI on edit connector will show something broken or nothing in the "Allowed channels" list?
Isn't it weird that a user can set allowed channel ids via API but then the UI will be broken/users can't update via UI this list using the same id they use via API? I would think we keep feature parity between API and UI (meaning both work)
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Async chunks
Page load bundle
Unknown metric groupsESLint disabled line counts
References to deprecated APIs
Total ESLint disabled count
History
cc @cnasikas |
…donly * commit 'bb1f55fa520b30ceb923af069ef403b24dcb1606': (52 commits) [CPS][Maps] Support CPS Picker in Maps (elastic#246382) [APM] Migrate the Transaction Overview tests to Scout/Playwright/Component/API tests (elastic#245972) [Cases] Change nested field search to be case insensitive (elastic#246643) [ES|QL] PromQL parser initial implementation (elastic#246552) [Agent Builder] Adds keyboard shortcut and toggle behavior to AI Agent button (elastic#246659) Retry on "all shards failed" from ES (elastic#246533) [Streams] Test enable wired streams flow (elastic#246113) [Agent Builder] Fast-follow bugfixes for MCP Tool type (elastic#246665) [Entity Store][API] Fix snake case on CRUD API List response (elastic#246003) [ResponseOps][Slack] Simplify channel configuration (elastic#245423) Add Canonical Name Badge to Documentation (elastic#246647) [Streams] Add simulation filtering by conditions (elastic#245400) [o11y AI] Add `get_hosts` tool (elastic#246541) [agent builder] create_visualization: support heatmap and regionmap (elastic#246671) [AI Infra] Chat experience: Selection modal title change (elastic#246683) [Background search] Change polling behavior (elastic#244760) [ES|QL ] Common Lookup Join Fields Are Not Listed First (elastic#246582) Add missing `dynamic: false` (elastic#246685) [Metrics in Discover] Unskip metrics api test (elastic#246593) [ES|QL] Show next actions after simple field assignment in RERANK ON Clause (elastic#246676) ...
## Summary Fixes: elastic#230979 ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] 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/src/platform/packages/shared/kbn-i18n/README.md) - [x] [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
…g Slack connector (#247098) ## Summary PR #245423 simplified a lot the logic of the Slack connector regarding channels. This PR fixes a small bug introduced in the PR where it would remove the ID of the channel from the payload for existing connector. ### Testing 1. Create a connector using the following payload: ``` { "name": "Slack - test allowedChannels", "config": { "allowedChannels": [ { "id": "C096LSBJZBQ", // should have an ID "name": "test" } ] }, "secrets": { "token": "foo" }, "connector_type_id": ".slack_api" } ``` 2. Edit the connector by adding an extra channel 3. Verify that the payload sent to the API preserves the channel ID. The new channel should only have a name. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] [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
…g Slack connector (elastic#247098) ## Summary PR elastic#245423 simplified a lot the logic of the Slack connector regarding channels. This PR fixes a small bug introduced in the PR where it would remove the ID of the channel from the payload for existing connector. ### Testing 1. Create a connector using the following payload: ``` { "name": "Slack - test allowedChannels", "config": { "allowedChannels": [ { "id": "C096LSBJZBQ", // should have an ID "name": "test" } ] }, "secrets": { "token": "foo" }, "connector_type_id": ".slack_api" } ``` 2. Edit the connector by adding an extra channel 3. Verify that the payload sent to the API preserves the channel ID. The new channel should only have a name. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] [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 (cherry picked from commit 2dce199)
…g Slack connector (elastic#247098) ## Summary PR elastic#245423 simplified a lot the logic of the Slack connector regarding channels. This PR fixes a small bug introduced in the PR where it would remove the ID of the channel from the payload for existing connector. ### Testing 1. Create a connector using the following payload: ``` { "name": "Slack - test allowedChannels", "config": { "allowedChannels": [ { "id": "C096LSBJZBQ", // should have an ID "name": "test" } ] }, "secrets": { "token": "foo" }, "connector_type_id": ".slack_api" } ``` 2. Edit the connector by adding an extra channel 3. Verify that the payload sent to the API preserves the channel ID. The new channel should only have a name. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] [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
…xisting Slack connector (#247098) (#247159) # Backport This will backport the following commits from `main` to `9.3`: - [[ResponseOps][Connectors] Keep the channel ID when editing an existing Slack connector (#247098)](#247098) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Christos Nasikas","email":"christos.nasikas@elastic.co"},"sourceCommit":{"committedDate":"2025-12-19T17:52:58Z","message":"[ResponseOps][Connectors] Keep the channel ID when editing an existing Slack connector (#247098)\n\n## Summary\n\nPR #245423 simplified a lot the\nlogic of the Slack connector regarding channels. This PR fixes a small\nbug introduced in the PR where it would remove the ID of the channel\nfrom the payload for existing connector.\n\n### Testing\n\n1. Create a connector using the following payload:\n\n```\n{\n \"name\": \"Slack - test allowedChannels\",\n \"config\": {\n \"allowedChannels\": [\n {\n \"id\": \"C096LSBJZBQ\", // should have an ID\n \"name\": \"test\"\n }\n ]\n },\n \"secrets\": {\n \"token\": \"foo\"\n },\n \"connector_type_id\": \".slack_api\"\n}\n```\n\n2. Edit the connector by adding an extra channel\n3. Verify that the payload sent to the API preserves the channel ID. The\nnew channel should only have a name.\n\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios","sha":"2dce199c0d7c2c38f1c6f92789ee5f7469dec4b5","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","Team:ResponseOps","backport:version","v9.3.0","v9.4.0"],"title":"[ResponseOps][Connectors] Keep the channel ID when editing an existing Slack connector","number":247098,"url":"https://github.com/elastic/kibana/pull/247098","mergeCommit":{"message":"[ResponseOps][Connectors] Keep the channel ID when editing an existing Slack connector (#247098)\n\n## Summary\n\nPR #245423 simplified a lot the\nlogic of the Slack connector regarding channels. This PR fixes a small\nbug introduced in the PR where it would remove the ID of the channel\nfrom the payload for existing connector.\n\n### Testing\n\n1. Create a connector using the following payload:\n\n```\n{\n \"name\": \"Slack - test allowedChannels\",\n \"config\": {\n \"allowedChannels\": [\n {\n \"id\": \"C096LSBJZBQ\", // should have an ID\n \"name\": \"test\"\n }\n ]\n },\n \"secrets\": {\n \"token\": \"foo\"\n },\n \"connector_type_id\": \".slack_api\"\n}\n```\n\n2. Edit the connector by adding an extra channel\n3. Verify that the payload sent to the API preserves the channel ID. The\nnew channel should only have a name.\n\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios","sha":"2dce199c0d7c2c38f1c6f92789ee5f7469dec4b5"}},"sourceBranch":"main","suggestedTargetBranches":["9.3"],"targetPullRequestStates":[{"branch":"9.3","label":"v9.3.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/247098","number":247098,"mergeCommit":{"message":"[ResponseOps][Connectors] Keep the channel ID when editing an existing Slack connector (#247098)\n\n## Summary\n\nPR #245423 simplified a lot the\nlogic of the Slack connector regarding channels. This PR fixes a small\nbug introduced in the PR where it would remove the ID of the channel\nfrom the payload for existing connector.\n\n### Testing\n\n1. Create a connector using the following payload:\n\n```\n{\n \"name\": \"Slack - test allowedChannels\",\n \"config\": {\n \"allowedChannels\": [\n {\n \"id\": \"C096LSBJZBQ\", // should have an ID\n \"name\": \"test\"\n }\n ]\n },\n \"secrets\": {\n \"token\": \"foo\"\n },\n \"connector_type_id\": \".slack_api\"\n}\n```\n\n2. Edit the connector by adding an extra channel\n3. Verify that the payload sent to the API preserves the channel ID. The\nnew channel should only have a name.\n\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios","sha":"2dce199c0d7c2c38f1c6f92789ee5f7469dec4b5"}}]}] BACKPORT--> Co-authored-by: Christos Nasikas <christos.nasikas@elastic.co> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
…g Slack connector (elastic#247098) ## Summary PR elastic#245423 simplified a lot the logic of the Slack connector regarding channels. This PR fixes a small bug introduced in the PR where it would remove the ID of the channel from the payload for existing connector. ### Testing 1. Create a connector using the following payload: ``` { "name": "Slack - test allowedChannels", "config": { "allowedChannels": [ { "id": "C096LSBJZBQ", // should have an ID "name": "test" } ] }, "secrets": { "token": "foo" }, "connector_type_id": ".slack_api" } ``` 2. Edit the connector by adding an extra channel 3. Verify that the payload sent to the API preserves the channel ID. The new channel should only have a name. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] [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
…g Slack connector (elastic#247098) ## Summary PR elastic#245423 simplified a lot the logic of the Slack connector regarding channels. This PR fixes a small bug introduced in the PR where it would remove the ID of the channel from the payload for existing connector. ### Testing 1. Create a connector using the following payload: ``` { "name": "Slack - test allowedChannels", "config": { "allowedChannels": [ { "id": "C096LSBJZBQ", // should have an ID "name": "test" } ] }, "secrets": { "token": "foo" }, "connector_type_id": ".slack_api" } ``` 2. Edit the connector by adding an extra channel 3. Verify that the payload sent to the API preserves the channel ID. The new channel should only have a name. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] [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

Summary
Fixes: #230979
Checklist
Check the PR satisfies following conditions.
Reviewers should verify this PR satisfies this list as well.
Release notes
Slack connector can be configured to send messages to any channel using channel names.