From 2f55e68d020a3c6d55c7db6e1fec4036fa35aee7 Mon Sep 17 00:00:00 2001 From: Christos Nasikas Date: Mon, 1 Nov 2021 10:36:53 +0200 Subject: [PATCH] [Cases] Do not show deprecated callout on deleted connectors (#116615) Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- x-pack/plugins/cases/public/components/utils.test.ts | 8 +++++++- x-pack/plugins/cases/public/components/utils.ts | 2 +- .../builtin_action_types/servicenow/helpers.test.ts | 8 +++++++- .../components/builtin_action_types/servicenow/helpers.ts | 4 ++-- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/cases/public/components/utils.test.ts b/x-pack/plugins/cases/public/components/utils.test.ts index 496dc8d8c806..86d37d2e5e59 100644 --- a/x-pack/plugins/cases/public/components/utils.test.ts +++ b/x-pack/plugins/cases/public/components/utils.test.ts @@ -7,7 +7,7 @@ import { actionTypeRegistryMock } from '../../../triggers_actions_ui/public/application/action_type_registry.mock'; import { triggersActionsUiMock } from '../../../triggers_actions_ui/public/mocks'; -import { getConnectorIcon } from './utils'; +import { getConnectorIcon, isDeprecatedConnector } from './utils'; describe('Utils', () => { describe('getConnectorIcon', () => { @@ -37,4 +37,10 @@ describe('Utils', () => { expect(getConnectorIcon(mockTriggersActionsUiService, '.not-registered')).toBe(''); }); }); + + describe('isDeprecatedConnector', () => { + it('returns false if the connector is not defined', () => { + expect(isDeprecatedConnector()).toBe(false); + }); + }); }); diff --git a/x-pack/plugins/cases/public/components/utils.ts b/x-pack/plugins/cases/public/components/utils.ts index 74137789958a..3ac48135edae 100644 --- a/x-pack/plugins/cases/public/components/utils.ts +++ b/x-pack/plugins/cases/public/components/utils.ts @@ -80,7 +80,7 @@ export const getConnectorIcon = ( // TODO: Remove when the applications are certified export const isDeprecatedConnector = (connector?: CaseActionConnector): boolean => { if (connector == null) { - return true; + return false; } if (!ENABLE_NEW_SN_ITSM_CONNECTOR && connector.actionTypeId === '.servicenow') { diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/helpers.test.ts b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/helpers.test.ts index e40db85bcb12..525430ea7fc6 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/helpers.test.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/helpers.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { isRESTApiError, isFieldInvalid } from './helpers'; +import { isRESTApiError, isFieldInvalid, isDeprecatedConnector } from './helpers'; describe('helpers', () => { describe('isRESTApiError', () => { @@ -48,4 +48,10 @@ describe('helpers', () => { expect(isFieldInvalid('description', [])).toBeFalsy(); }); }); + + describe('isDeprecatedConnector', () => { + it('returns false if the connector is not defined', () => { + expect(isDeprecatedConnector()).toBe(false); + }); + }); }); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/helpers.ts b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/helpers.ts index 755923acc25c..7274c5952741 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/helpers.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/helpers.ts @@ -28,9 +28,9 @@ export const isFieldInvalid = ( ): boolean => error !== undefined && error.length > 0 && field != null; // TODO: Remove when the applications are certified -export const isDeprecatedConnector = (connector: ServiceNowActionConnector): boolean => { +export const isDeprecatedConnector = (connector?: ServiceNowActionConnector): boolean => { if (connector == null) { - return true; + return false; } if (!ENABLE_NEW_SN_ITSM_CONNECTOR && connector.actionTypeId === '.servicenow') {