From 86c420573f725684c0492682e5d0a0ee4da68689 Mon Sep 17 00:00:00 2001 From: Mike Cote Date: Thu, 29 Oct 2020 09:40:29 -0400 Subject: [PATCH] Remove usage of any on registries --- .../triggers_actions_ui/public/application/app.tsx | 7 +++---- .../context/actions_connectors_context.tsx | 5 ++--- .../public/application/context/alerts_context.tsx | 7 +++---- .../action_connector_form.test.tsx | 2 +- .../action_connector_form/action_connector_form.tsx | 5 ++--- .../action_connector_form/action_form.test.tsx | 2 +- .../sections/action_connector_form/action_form.tsx | 4 ++-- .../action_connector_form/action_type_menu.test.tsx | 2 +- .../connector_add_flyout.test.tsx | 2 +- .../connector_add_modal.test.tsx | 2 +- .../action_connector_form/connector_add_modal.tsx | 10 +++++++--- .../connector_edit_flyout.test.tsx | 2 +- .../components/actions_connectors_list.test.tsx | 2 +- .../sections/alert_form/alert_add.test.tsx | 4 ++-- .../sections/alert_form/alert_edit.test.tsx | 4 ++-- .../sections/alert_form/alert_form.test.tsx | 12 ++++++------ .../alerts_list/components/alerts_list.test.tsx | 12 ++++++------ .../public/application/test_utils/index.ts | 4 ++-- 18 files changed, 44 insertions(+), 44 deletions(-) diff --git a/x-pack/plugins/triggers_actions_ui/public/application/app.tsx b/x-pack/plugins/triggers_actions_ui/public/application/app.tsx index c53dc0c105084..bb9fe65d6bbb8 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/app.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/app.tsx @@ -18,8 +18,7 @@ import { } from 'kibana/public'; import { Section, routeToAlertDetails } from './constants'; import { AppContextProvider } from './app_context'; -import { ActionTypeModel, AlertTypeModel } from '../types'; -import { TypeRegistry } from './type_registry'; +import { ActionTypeRegistryContract, AlertTypeRegistryContract } from '../types'; import { ChartsPluginStart } from '../../../../../src/plugins/charts/public'; import { DataPublicPluginStart } from '../../../../../src/plugins/data/public'; import { PluginStartContract as AlertingStart } from '../../../alerts/public'; @@ -42,8 +41,8 @@ export interface AppDeps { uiSettings: IUiSettingsClient; setBreadcrumbs: (crumbs: ChromeBreadcrumb[]) => void; capabilities: ApplicationStart['capabilities']; - actionTypeRegistry: TypeRegistry; - alertTypeRegistry: TypeRegistry; + actionTypeRegistry: ActionTypeRegistryContract; + alertTypeRegistry: AlertTypeRegistryContract; history: ScopedHistory; } diff --git a/x-pack/plugins/triggers_actions_ui/public/application/context/actions_connectors_context.tsx b/x-pack/plugins/triggers_actions_ui/public/application/context/actions_connectors_context.tsx index 786fc12380f90..bb0606db2a9b3 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/context/actions_connectors_context.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/context/actions_connectors_context.tsx @@ -6,12 +6,11 @@ import React, { createContext, useContext } from 'react'; import { HttpSetup, ApplicationStart, DocLinksStart, ToastsSetup } from 'kibana/public'; -import { ActionTypeModel, ActionConnector } from '../../types'; -import { TypeRegistry } from '../type_registry'; +import { ActionTypeRegistryContract, ActionConnector } from '../../types'; export interface ActionsConnectorsContextValue { http: HttpSetup; - actionTypeRegistry: TypeRegistry; + actionTypeRegistry: ActionTypeRegistryContract; toastNotifications: ToastsSetup; capabilities: ApplicationStart['capabilities']; reloadConnectors?: () => Promise; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/context/alerts_context.tsx b/x-pack/plugins/triggers_actions_ui/public/application/context/alerts_context.tsx index b4cf13538d64d..a4293f94268ba 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/context/alerts_context.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/context/alerts_context.tsx @@ -18,14 +18,13 @@ import { DataPublicPluginStartUi, IndexPatternsContract, } from 'src/plugins/data/public'; -import { TypeRegistry } from '../type_registry'; -import { AlertTypeModel, ActionTypeModel } from '../../types'; +import { AlertTypeRegistryContract, ActionTypeRegistryContract } from '../../types'; export interface AlertsContextValue> { reloadAlerts?: () => Promise; http: HttpSetup; - alertTypeRegistry: TypeRegistry; - actionTypeRegistry: TypeRegistry; + alertTypeRegistry: AlertTypeRegistryContract; + actionTypeRegistry: ActionTypeRegistryContract; toastNotifications: ToastsStart; uiSettings?: IUiSettingsClient; charts?: ChartsPluginSetup; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_connector_form.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_connector_form.test.tsx index 60ec8004983a3..cf83062b5781e 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_connector_form.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_connector_form.test.tsx @@ -22,7 +22,7 @@ describe('action_connector_form', () => { ] = await mocks.getStartServices(); deps = { http: mocks.http, - actionTypeRegistry: actionTypeRegistry as any, + actionTypeRegistry, docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' }, capabilities, }; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_connector_form.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_connector_form.tsx index f91bd7382b61c..3a1f9872a96a8 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_connector_form.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_connector_form.tsx @@ -24,10 +24,9 @@ import { ReducerAction } from './connector_reducer'; import { ActionConnector, IErrorObject, - ActionTypeModel, + ActionTypeRegistryContract, UserConfiguredActionConnector, } from '../../../types'; -import { TypeRegistry } from '../../type_registry'; import { hasSaveActionsCapability } from '../../lib/capabilities'; export function validateBaseProperties(actionObject: ActionConnector) { @@ -61,7 +60,7 @@ interface ActionConnectorProps< }; errors: IErrorObject; http: HttpSetup; - actionTypeRegistry: TypeRegistry; + actionTypeRegistry: ActionTypeRegistryContract; docLinks: DocLinksStart; capabilities: ApplicationStart['capabilities']; consumer?: string; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.test.tsx index 3e229c6a2333d..7c718e8248e41 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.test.tsx @@ -178,7 +178,7 @@ describe('action_form', () => { }, }, setHasActionsWithBrokenConnector: jest.fn(), - actionTypeRegistry: actionTypeRegistry as any, + actionTypeRegistry, docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' }, }; actionTypeRegistry.list.mockReturnValue([ diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.tsx index 61cf3f2d37925..51d3b0074ca54 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.tsx @@ -34,6 +34,7 @@ import { loadActionTypes, loadAllActions as loadConnectors } from '../../lib/act import { IErrorObject, ActionTypeModel, + ActionTypeRegistryContract, AlertAction, ActionTypeIndex, ActionConnector, @@ -42,7 +43,6 @@ import { } from '../../../types'; import { SectionLoading } from '../../components/section_loading'; import { ConnectorAddModal } from './connector_add_modal'; -import { TypeRegistry } from '../../type_registry'; import { actionTypeCompare } from '../../lib/action_type_compare'; import { checkActionFormActionTypeEnabled } from '../../lib/check_action_type_enabled'; import { VIEW_LICENSE_OPTIONS_LINK } from '../../../common/constants'; @@ -55,7 +55,7 @@ interface ActionAccordionFormProps { setAlertProperty: (actions: AlertAction[]) => void; setActionParamsProperty: (key: string, value: any, index: number) => void; http: HttpSetup; - actionTypeRegistry: TypeRegistry; + actionTypeRegistry: ActionTypeRegistryContract; toastNotifications: ToastsSetup; docLinks: DocLinksStart; actionTypes?: ActionType[]; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_menu.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_menu.test.tsx index a5e9cdc65cfa6..2fe068536f4a1 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_menu.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_menu.test.tsx @@ -33,7 +33,7 @@ describe('connector_add_flyout', () => { show: true, }, }, - actionTypeRegistry: actionTypeRegistry as any, + actionTypeRegistry, docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' }, }; }); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_flyout.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_flyout.test.tsx index 0863465833c0b..b32a8ed4161d6 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_flyout.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_flyout.test.tsx @@ -34,7 +34,7 @@ describe('connector_add_flyout', () => { show: true, }, }, - actionTypeRegistry: actionTypeRegistry as any, + actionTypeRegistry, docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' }, }; }); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_modal.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_modal.test.tsx index 3d621367fc40a..cba9eea3cf3f7 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_modal.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_modal.test.tsx @@ -32,7 +32,7 @@ describe('connector_add_modal', () => { delete: true, }, }, - actionTypeRegistry: actionTypeRegistry as any, + actionTypeRegistry, docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' }, }; }); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_modal.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_modal.tsx index d7ca91218d4dd..13ec8395aa557 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_modal.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_modal.tsx @@ -19,12 +19,16 @@ import { EuiOverlayMask } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { HttpSetup, ToastsApi, ApplicationStart, DocLinksStart } from 'kibana/public'; import { ActionConnectorForm, validateBaseProperties } from './action_connector_form'; -import { ActionType, ActionConnector, IErrorObject, ActionTypeModel } from '../../../types'; import { connectorReducer } from './connector_reducer'; import { createActionConnector } from '../../lib/action_connector_api'; -import { TypeRegistry } from '../../type_registry'; import './connector_add_modal.scss'; import { hasSaveActionsCapability } from '../../lib/capabilities'; +import { + ActionType, + ActionConnector, + IErrorObject, + ActionTypeRegistryContract, +} from '../../../types'; interface ConnectorAddModalProps { actionType: ActionType; @@ -32,7 +36,7 @@ interface ConnectorAddModalProps { setAddModalVisibility: React.Dispatch>; postSaveEventHandler?: (savedAction: ActionConnector) => void; http: HttpSetup; - actionTypeRegistry: TypeRegistry; + actionTypeRegistry: ActionTypeRegistryContract; toastNotifications: Pick< ToastsApi, 'get$' | 'add' | 'remove' | 'addSuccess' | 'addWarning' | 'addDanger' | 'addError' diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_edit_flyout.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_edit_flyout.test.tsx index 0c2f4df0ca52b..ac379e279f7f2 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_edit_flyout.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_edit_flyout.test.tsx @@ -35,7 +35,7 @@ describe('connector_edit_flyout', () => { show: true, }, }, - actionTypeRegistry: actionTypeRegistry as any, + actionTypeRegistry, alertTypeRegistry: {} as any, docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' }, }; 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 c96e62df71ce4..33b839dc70b31 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 @@ -69,7 +69,7 @@ describe('actions_connectors_list component empty', () => { }, history: scopedHistoryMock.create(), setBreadcrumbs: jest.fn(), - actionTypeRegistry: actionTypeRegistry as any, + actionTypeRegistry, alertTypeRegistry: {} as any, }; actionTypeRegistry.has.mockReturnValue(true); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_add.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_add.test.tsx index 8ac80c4ad2880..0ac20626e1044 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_add.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_add.test.tsx @@ -84,8 +84,8 @@ describe('alert_add', () => { uiSettings: mocks.uiSettings, dataPlugin: dataPluginMock.createStartContract(), charts: chartPluginMock.createStartContract(), - actionTypeRegistry: actionTypeRegistry as any, - alertTypeRegistry: alertTypeRegistry as any, + actionTypeRegistry, + alertTypeRegistry, docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' }, }; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_edit.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_edit.test.tsx index 24eb7aabb9549..fe86e5da98765 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_edit.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_edit.test.tsx @@ -36,8 +36,8 @@ describe('alert_edit', () => { toastNotifications: mockedCoreSetup.notifications.toasts, http: mockedCoreSetup.http, uiSettings: mockedCoreSetup.uiSettings, - actionTypeRegistry: actionTypeRegistry as any, - alertTypeRegistry: alertTypeRegistry as any, + actionTypeRegistry, + alertTypeRegistry, docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' }, capabilities, }; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_form.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_form.test.tsx index 6091519f5851e..cda791489d7f7 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_form.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_form.test.tsx @@ -98,8 +98,8 @@ describe('alert_form', () => { toastNotifications: mocks.notifications.toasts, http: mocks.http, uiSettings: mocks.uiSettings, - actionTypeRegistry: actionTypeRegistry as any, - alertTypeRegistry: alertTypeRegistry as any, + actionTypeRegistry, + alertTypeRegistry, docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' }, capabilities, }; @@ -231,8 +231,8 @@ describe('alert_form', () => { toastNotifications: mocks.notifications.toasts, http: mocks.http, uiSettings: mocks.uiSettings, - actionTypeRegistry: actionTypeRegistry as any, - alertTypeRegistry: alertTypeRegistry as any, + actionTypeRegistry, + alertTypeRegistry, docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' }, capabilities, }; @@ -332,8 +332,8 @@ describe('alert_form', () => { toastNotifications: mockes.notifications.toasts, http: mockes.http, uiSettings: mockes.uiSettings, - actionTypeRegistry: actionTypeRegistry as any, - alertTypeRegistry: alertTypeRegistry as any, + actionTypeRegistry, + alertTypeRegistry, }; alertTypeRegistry.list.mockReturnValue([alertType]); alertTypeRegistry.get.mockReturnValue(alertType); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.test.tsx index 86b9afd9565f8..e6e44d4d21bdf 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.test.tsx @@ -109,8 +109,8 @@ describe('alerts_list component empty', () => { capabilities, history: scopedHistoryMock.create(), setBreadcrumbs: jest.fn(), - actionTypeRegistry: actionTypeRegistry as any, - alertTypeRegistry: alertTypeRegistry as any, + actionTypeRegistry, + alertTypeRegistry, }; wrapper = mountWithIntl( @@ -278,8 +278,8 @@ describe('alerts_list component with items', () => { capabilities, history: scopedHistoryMock.create(), setBreadcrumbs: jest.fn(), - actionTypeRegistry: actionTypeRegistry as any, - alertTypeRegistry: alertTypeRegistry as any, + actionTypeRegistry, + alertTypeRegistry, }; alertTypeRegistry.has.mockReturnValue(true); @@ -478,8 +478,8 @@ describe('alerts_list with show only capability', () => { capabilities, history: scopedHistoryMock.create(), setBreadcrumbs: jest.fn(), - actionTypeRegistry: actionTypeRegistry as any, - alertTypeRegistry: alertTypeRegistry as any, + actionTypeRegistry, + alertTypeRegistry, }; alertTypeRegistry.has.mockReturnValue(false); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/test_utils/index.ts b/x-pack/plugins/triggers_actions_ui/public/application/test_utils/index.ts index 7102d2db1dc09..7b3872246ca50 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/test_utils/index.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/test_utils/index.ts @@ -35,7 +35,7 @@ export async function getMockedAppDependencies() { capabilities, history: scopedHistoryMock.create(), setBreadcrumbs: jest.fn(), - actionTypeRegistry: actionTypeRegistry as any, - alertTypeRegistry: alertTypeRegistry as any, + actionTypeRegistry, + alertTypeRegistry, }; }