From 367d3209e750af7012bdb096fac9c2ce62d8c743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georgiana-Andreea=20Onolea=C8=9B=C4=83?= Date: Wed, 6 Nov 2024 16:43:48 +0200 Subject: [PATCH] [ResponseOps][Connectors]Preconfigured connectors of disabled types show as disabled, but are actually enabled (#198792) Closes https://github.com/elastic/kibana/issues/190420 ## Summary - the preconfigured connectors should be displayed as enabled and not have the tooltip icon even if the xpack.actions.enabledActionTypes: [] setting is present in the kibana.yml (to disable all the connector types) ![Screenshot 2024-11-04 at 14 38 10](https://github.com/user-attachments/assets/ee817087-a079-481b-bf82-b7247f3ea923) --------- Co-authored-by: Antonio (cherry picked from commit 56b0ac2eda55b0fe1a3dc0cd445d704320b69981) --- .../utils/check_action_type_enabled.test.ts | 20 +++++++++++++++++++ .../utils/check_action_type_enabled.ts | 5 +++-- .../actions_connectors_list.test.tsx | 15 +++++++++++++- .../components/actions_connectors_list.tsx | 7 ++++--- 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/utils/check_action_type_enabled.test.ts b/packages/kbn-alerts-ui-shared/src/rule_form/utils/check_action_type_enabled.test.ts index 987d95ef3d070..7794f83825c76 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/utils/check_action_type_enabled.test.ts +++ b/packages/kbn-alerts-ui-shared/src/rule_form/utils/check_action_type_enabled.test.ts @@ -99,6 +99,26 @@ describe('checkActionTypeEnabled', () => { } `); }); + test('checkActionTypeEnabled returns true when actionType is disabled by config', async () => { + const actionType: ActionType = { + id: '1', + minimumLicenseRequired: 'basic', + supportedFeatureIds: ['alerting'], + name: 'my action', + enabled: false, + enabledInConfig: false, + enabledInLicense: true, + isSystemActionType: false, + }; + + const isPreconfiguredConnector = true; + + expect(checkActionTypeEnabled(actionType, isPreconfiguredConnector)).toMatchInlineSnapshot(` + Object { + "isEnabled": true, + } + `); + }); }); describe('checkActionFormActionTypeEnabled', () => { diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/utils/check_action_type_enabled.ts b/packages/kbn-alerts-ui-shared/src/rule_form/utils/check_action_type_enabled.ts index 891012f0eeb23..79c26b7052e86 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/utils/check_action_type_enabled.ts +++ b/packages/kbn-alerts-ui-shared/src/rule_form/utils/check_action_type_enabled.ts @@ -22,13 +22,14 @@ export interface IsDisabledResult { } export const checkActionTypeEnabled = ( - actionType?: ActionType + actionType?: ActionType, + isPreconfiguredConnector: boolean = false ): IsEnabledResult | IsDisabledResult => { if (actionType?.enabledInLicense === false) { return getLicenseCheckResult(actionType); } - if (actionType?.enabledInConfig === false) { + if (actionType?.enabledInConfig === false && isPreconfiguredConnector === false) { return configurationCheckResult; } diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.test.tsx index a938aa6b7e6e5..1c191bf213852 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.test.tsx @@ -750,6 +750,12 @@ describe('actions_connectors_list', () => { referencedByCount: 1, config: {}, }, + { + id: '3', + actionTypeId: 'test3', + isPreconfigured: true, + isDeprecated: false, + }, ] as ActionConnector[] } setActions={() => {}} @@ -766,7 +772,7 @@ describe('actions_connectors_list', () => { it('renders table of connectors', async () => { await setup(); expect(wrapper.find('EuiInMemoryTable')).toHaveLength(1); - expect(wrapper.find('EuiTableRow')).toHaveLength(2); + expect(wrapper.find('EuiTableRow')).toHaveLength(3); expect(wrapper.find('EuiTableRow').at(0).prop('className')).toEqual( 'actConnectorsList__tableRowDisabled' ); @@ -774,6 +780,13 @@ describe('actions_connectors_list', () => { 'actConnectorsList__tableRowDisabled' ); }); + + it('renders preconfigured connectors as enabled', async () => { + await setup(); + expect(wrapper.find('EuiTableRow').at(2).prop('className')).not.toEqual( + 'actConnectorsList__tableRowDisabled' + ); + }); }); describe('component with deprecated connectors', () => { diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.tsx index e00b08d9c8512..17e6531a65c20 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.tsx @@ -199,9 +199,9 @@ const ActionsConnectorsList = ({ truncateText: true, render: (value: string, item: ActionConnectorTableItem) => { const checkEnabledResult = checkActionTypeEnabled( - actionTypesIndex && actionTypesIndex[item.actionTypeId] + actionTypesIndex && actionTypesIndex[item.actionTypeId], + item.isPreconfigured ); - /** * TODO: Remove when connectors can provide their own UX message. * Issue: https://github.com/elastic/kibana/issues/114507 @@ -363,7 +363,8 @@ const ActionsConnectorsList = ({ columns={actionsTableColumns} rowProps={(item: ActionConnectorTableItem) => ({ className: - !actionTypesIndex || !actionTypesIndex[item.actionTypeId]?.enabled + !item.isPreconfigured && + (!actionTypesIndex || !actionTypesIndex[item.actionTypeId]?.enabled) ? 'actConnectorsList__tableRowDisabled' : '', 'data-test-subj': 'connectors-row',