Skip to content

Commit

Permalink
Remove usage of any on registries
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecote committed Oct 29, 2020
1 parent c8880a6 commit 86c4205
Show file tree
Hide file tree
Showing 18 changed files with 44 additions and 44 deletions.
7 changes: 3 additions & 4 deletions x-pack/plugins/triggers_actions_ui/public/application/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -42,8 +41,8 @@ export interface AppDeps {
uiSettings: IUiSettingsClient;
setBreadcrumbs: (crumbs: ChromeBreadcrumb[]) => void;
capabilities: ApplicationStart['capabilities'];
actionTypeRegistry: TypeRegistry<ActionTypeModel>;
alertTypeRegistry: TypeRegistry<AlertTypeModel>;
actionTypeRegistry: ActionTypeRegistryContract;
alertTypeRegistry: AlertTypeRegistryContract;
history: ScopedHistory;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ActionTypeModel>;
actionTypeRegistry: ActionTypeRegistryContract;
toastNotifications: ToastsSetup;
capabilities: ApplicationStart['capabilities'];
reloadConnectors?: () => Promise<ActionConnector[] | void>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<MetaData = Record<string, any>> {
reloadAlerts?: () => Promise<void>;
http: HttpSetup;
alertTypeRegistry: TypeRegistry<AlertTypeModel>;
actionTypeRegistry: TypeRegistry<ActionTypeModel>;
alertTypeRegistry: AlertTypeRegistryContract;
actionTypeRegistry: ActionTypeRegistryContract;
toastNotifications: ToastsStart;
uiSettings?: IUiSettingsClient;
charts?: ChartsPluginSetup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -61,7 +60,7 @@ interface ActionConnectorProps<
};
errors: IErrorObject;
http: HttpSetup;
actionTypeRegistry: TypeRegistry<ActionTypeModel>;
actionTypeRegistry: ActionTypeRegistryContract;
docLinks: DocLinksStart;
capabilities: ApplicationStart['capabilities'];
consumer?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { loadActionTypes, loadAllActions as loadConnectors } from '../../lib/act
import {
IErrorObject,
ActionTypeModel,
ActionTypeRegistryContract,
AlertAction,
ActionTypeIndex,
ActionConnector,
Expand All @@ -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';
Expand All @@ -55,7 +55,7 @@ interface ActionAccordionFormProps {
setAlertProperty: (actions: AlertAction[]) => void;
setActionParamsProperty: (key: string, value: any, index: number) => void;
http: HttpSetup;
actionTypeRegistry: TypeRegistry<ActionTypeModel>;
actionTypeRegistry: ActionTypeRegistryContract;
toastNotifications: ToastsSetup;
docLinks: DocLinksStart;
actionTypes?: ActionType[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('connector_add_flyout', () => {
show: true,
},
},
actionTypeRegistry: actionTypeRegistry as any,
actionTypeRegistry,
docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' },
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('connector_add_flyout', () => {
show: true,
},
},
actionTypeRegistry: actionTypeRegistry as any,
actionTypeRegistry,
docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' },
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('connector_add_modal', () => {
delete: true,
},
},
actionTypeRegistry: actionTypeRegistry as any,
actionTypeRegistry,
docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' },
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,24 @@ 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;
addModalVisible: boolean;
setAddModalVisibility: React.Dispatch<React.SetStateAction<boolean>>;
postSaveEventHandler?: (savedAction: ActionConnector) => void;
http: HttpSetup;
actionTypeRegistry: TypeRegistry<ActionTypeModel>;
actionTypeRegistry: ActionTypeRegistryContract;
toastNotifications: Pick<
ToastsApi,
'get$' | 'add' | 'remove' | 'addSuccess' | 'addWarning' | 'addDanger' | 'addError'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: '' },
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: '' },
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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,
};
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}

0 comments on commit 86c4205

Please sign in to comment.