diff --git a/packages/kbn-coloring/src/shared_components/coloring/color_ranges/color_ranges_item.tsx b/packages/kbn-coloring/src/shared_components/coloring/color_ranges/color_ranges_item.tsx index 12c58c0c8763a28..7552a0c4bc42beb 100644 --- a/packages/kbn-coloring/src/shared_components/coloring/color_ranges/color_ranges_item.tsx +++ b/packages/kbn-coloring/src/shared_components/coloring/color_ranges/color_ranges_item.tsx @@ -8,7 +8,15 @@ import { i18n } from '@kbn/i18n'; import useUpdateEffect from 'react-use/lib/useUpdateEffect'; -import React, { useState, useCallback, Dispatch, FocusEvent, useContext, useMemo } from 'react'; +import React, { + useState, + useCallback, + Dispatch, + FocusEvent, + useContext, + useMemo, + ChangeEventHandler, +} from 'react'; import { css } from '@emotion/react'; import { @@ -126,9 +134,9 @@ export function ColorRangeItem({ [colorRange.start, colorRanges, dispatch, index, popoverInFocus, dataBounds, palettes, isLast] ); - const onValueChange = useCallback( + const onValueChange = useCallback>( ({ target: { value: targetValue } }) => { - setLocalValue(targetValue); + setLocalValue(+targetValue); dispatch({ type: 'updateValue', payload: { index, value: targetValue, accessor, dataBounds, palettes }, @@ -138,7 +146,7 @@ export function ColorRangeItem({ ); const onUpdateColor = useCallback( - (color) => { + (color: string) => { dispatch({ type: 'updateColor', payload: { index, color, dataBounds, palettes } }); }, [dispatch, index, dataBounds, palettes] diff --git a/packages/kbn-content-management-utils/kibana.jsonc b/packages/kbn-content-management-utils/kibana.jsonc index 06779896a47c451..0b0fa95451cd2da 100644 --- a/packages/kbn-content-management-utils/kibana.jsonc +++ b/packages/kbn-content-management-utils/kibana.jsonc @@ -1,5 +1,5 @@ { - "type": "shared-common", + "type": "shared-server", "id": "@kbn/content-management-utils", "owner": "@elastic/kibana-data-discovery" } diff --git a/packages/kbn-dom-drag-drop/index.ts b/packages/kbn-dom-drag-drop/index.ts index f188b6c6659adc4..f9e4f3f4f5bb923 100644 --- a/packages/kbn-dom-drag-drop/index.ts +++ b/packages/kbn-dom-drag-drop/index.ts @@ -14,6 +14,7 @@ export { type DraggingIdentifier, type DragDropAction, type DropOverlayWrapperProps, + type DroppableProps, Draggable, Droppable, useDragDropContext, diff --git a/packages/kbn-grouping/src/components/accordion_panel/index.tsx b/packages/kbn-grouping/src/components/accordion_panel/index.tsx index ae13509b51a9ebe..37a531b386b47ac 100644 --- a/packages/kbn-grouping/src/components/accordion_panel/index.tsx +++ b/packages/kbn-grouping/src/components/accordion_panel/index.tsx @@ -102,7 +102,7 @@ const GroupPanelComponent = ({ ); const onToggle = useCallback( - (isOpen) => { + (isOpen: boolean) => { if (onToggleGroup) { onToggleGroup(isOpen, groupBucket); } diff --git a/packages/kbn-grouping/src/hooks/use_grouping.tsx b/packages/kbn-grouping/src/hooks/use_grouping.tsx index 284343a29d74845..f01dcc29aa7903f 100644 --- a/packages/kbn-grouping/src/hooks/use_grouping.tsx +++ b/packages/kbn-grouping/src/hooks/use_grouping.tsx @@ -56,7 +56,7 @@ export type DynamicGroupingProps = Pick< /** Interface for configuring grouping package where T is the consumer `GroupingAggregation` * @interface GroupingArgs */ -interface GroupingArgs { +export interface GroupingArgs { componentProps: StaticGroupingProps; defaultGroupingOptions: GroupOption[]; fields: FieldSpec[]; diff --git a/packages/kbn-management/settings/components/field_input/code_editor.tsx b/packages/kbn-management/settings/components/field_input/code_editor.tsx index ac1ea672d8a151e..397fd8b80492b9b 100644 --- a/packages/kbn-management/settings/components/field_input/code_editor.tsx +++ b/packages/kbn-management/settings/components/field_input/code_editor.tsx @@ -70,7 +70,7 @@ export const CodeEditor = ({ onChange, type, isReadOnly, name, ...props }: CodeE editorModel.setValue(trimmedValue); }, []); - const editorDidMount = useCallback( + const editorDidMount = useCallback>( (editor) => { setEditorCalculatedHeight(editor); diff --git a/packages/kbn-management/settings/components/field_input/input/array_input.tsx b/packages/kbn-management/settings/components/field_input/input/array_input.tsx index 0dc9b8ddc406e88..f77c66f5f15e156 100644 --- a/packages/kbn-management/settings/components/field_input/input/array_input.tsx +++ b/packages/kbn-management/settings/components/field_input/input/array_input.tsx @@ -13,6 +13,7 @@ import { getFieldInputValue } from '@kbn/management-settings-utilities'; import { useUpdate } from '@kbn/management-settings-utilities'; import { debounce } from 'lodash'; +import { OnInputChangeFn } from '@kbn/management-settings-types'; import { useServices } from '../services'; import { InputProps } from '../types'; import { TEST_SUBJ_PREFIX_FIELD } from '.'; @@ -39,7 +40,7 @@ export const ArrayInput = ({ const onUpdate = useUpdate({ onInputChange, field }); const updateValue = useCallback( - async (newValue: string, onUpdateFn) => { + async (newValue: string, onUpdateFn: OnInputChangeFn<'array'>) => { const parsedValue = newValue .replace(REGEX, ',') .split(',') diff --git a/packages/kbn-management/settings/components/field_input/input/number_input.tsx b/packages/kbn-management/settings/components/field_input/input/number_input.tsx index 8a29429eff59fce..303dfe386866442 100644 --- a/packages/kbn-management/settings/components/field_input/input/number_input.tsx +++ b/packages/kbn-management/settings/components/field_input/input/number_input.tsx @@ -12,6 +12,7 @@ import { EuiFieldNumber, EuiFieldNumberProps } from '@elastic/eui'; import { getFieldInputValue, useUpdate } from '@kbn/management-settings-utilities'; import { debounce } from 'lodash'; +import { OnInputChangeFn } from '@kbn/management-settings-types'; import { InputProps } from '../types'; import { TEST_SUBJ_PREFIX_FIELD } from '.'; import { useServices } from '../services'; @@ -36,7 +37,7 @@ export const NumberInput = ({ const onUpdate = useUpdate({ onInputChange, field }); const updateValue = useCallback( - async (newValue: number, onUpdateFn) => { + async (newValue: number, onUpdateFn: OnInputChangeFn<'number'>) => { const validationResponse = await validateChange(field.id, newValue); if (validationResponse.successfulValidation && !validationResponse.valid) { onUpdateFn({ diff --git a/packages/kbn-securitysolution-autocomplete/src/field_value_lists/index.tsx b/packages/kbn-securitysolution-autocomplete/src/field_value_lists/index.tsx index 75c7001c462d5fa..bf7f77837fee4cf 100644 --- a/packages/kbn-securitysolution-autocomplete/src/field_value_lists/index.tsx +++ b/packages/kbn-securitysolution-autocomplete/src/field_value_lists/index.tsx @@ -64,7 +64,7 @@ export const AutocompleteFieldListsComponent: React.FC name, []); + const getLabel = useCallback(({ name }: ListSchema) => name, []); const optionsMemo = useMemo( () => filterFieldToList(listData, selectedField), diff --git a/packages/kbn-securitysolution-autocomplete/src/operator/index.tsx b/packages/kbn-securitysolution-autocomplete/src/operator/index.tsx index 6d45d4d5ab37d20..722bb33f9f303d7 100644 --- a/packages/kbn-securitysolution-autocomplete/src/operator/index.tsx +++ b/packages/kbn-securitysolution-autocomplete/src/operator/index.tsx @@ -44,7 +44,7 @@ export const OperatorComponent: React.FC = ({ selectedField, 'aria-label': ariaLabel, }): JSX.Element => { - const getLabel = useCallback(({ message }): string => message, []); + const getLabel = useCallback(({ message }: OperatorOption): string => message, []); const optionsMemo = useMemo( (): OperatorOption[] => operatorOptions != null && operatorOptions.length > 0 diff --git a/packages/kbn-securitysolution-exception-list-components/src/search_bar/index.tsx b/packages/kbn-securitysolution-exception-list-components/src/search_bar/index.tsx index a40393bac8fccec..ab5c81d30eb5af9 100644 --- a/packages/kbn-securitysolution-exception-list-components/src/search_bar/index.tsx +++ b/packages/kbn-securitysolution-exception-list-components/src/search_bar/index.tsx @@ -9,7 +9,7 @@ import React, { useCallback } from 'react'; import type { FC } from 'react'; -import type { IconType, SearchFilterConfig } from '@elastic/eui'; +import type { EuiSearchBarProps, IconType, SearchFilterConfig } from '@elastic/eui'; import { EuiFlexGroup, EuiFlexItem, EuiButton, EuiSearchBar } from '@elastic/eui'; import type { ExceptionListTypeEnum } from '@kbn/securitysolution-io-ts-list-types'; import type { GetExceptionItemProps } from '../types'; @@ -73,7 +73,7 @@ const SearchBarComponent: FC = ({ onSearch, onAddExceptionClick, }) => { - const handleOnSearch = useCallback( + const handleOnSearch = useCallback>( ({ queryText }): void => { onSearch({ search: queryText }); }, diff --git a/packages/kbn-securitysolution-list-utils/src/helpers/index.test.ts b/packages/kbn-securitysolution-list-utils/src/helpers/index.test.ts index 0da36d21f405bab..76946be77fc3d00 100644 --- a/packages/kbn-securitysolution-list-utils/src/helpers/index.test.ts +++ b/packages/kbn-securitysolution-list-utils/src/helpers/index.test.ts @@ -204,6 +204,26 @@ describe('Helpers', () => { ]) ).toBeTruthy(); }); + + test('it returns true if there are entries joined with an OR that have a wildcard and the wrong operator', () => { + expect( + hasWrongOperatorWithWildcard([ + { + description: '', + name: '', + type: 'simple', + entries: [{ type: 'match', value: 'withwildcard?', field: '', operator: 'included' }], + }, + { + description: '', + name: '', + type: 'simple', + entries: [{ type: 'match', value: 'withwildcard?*', field: '', operator: 'included' }], + }, + ]) + ).toBeTruthy(); + }); + test('it returns false if there are no exception entries with a wildcard and the wrong operator', () => { expect( hasWrongOperatorWithWildcard([ @@ -219,5 +239,25 @@ describe('Helpers', () => { ]) ).toBeFalsy(); }); + + test('it returns true if there are nested entries with a wildcard and the wrong operator', () => { + expect( + hasWrongOperatorWithWildcard([ + { + description: '', + name: '', + type: 'simple', + entries: [ + { type: 'match', value: 'nowildcard', field: '', operator: 'excluded' }, + { + field: '', + type: 'nested', + entries: [{ type: 'match', value: 'wildcard?', field: '', operator: 'excluded' }], + }, + ], + }, + ]) + ).toBeTruthy(); + }); }); }); diff --git a/packages/kbn-securitysolution-list-utils/src/helpers/index.ts b/packages/kbn-securitysolution-list-utils/src/helpers/index.ts index c969ac82c8a1907..27598fb18110cd4 100644 --- a/packages/kbn-securitysolution-list-utils/src/helpers/index.ts +++ b/packages/kbn-securitysolution-list-utils/src/helpers/index.ts @@ -1032,7 +1032,16 @@ export const getMappingConflictsInfo = (field: DataViewField): FieldConflictsInf export const hasWrongOperatorWithWildcard = ( items: ExceptionsBuilderReturnExceptionItem[] ): boolean => { - const allEntries = items.flatMap((item) => item.entries); + // flattens array of multiple entries added with OR + const multipleEntries = items.flatMap((item) => item.entries); + // flattens nested entries + const allEntries = multipleEntries.flatMap((item) => { + if (item.type === 'nested') { + return item.entries; + } + return item; + }); + return allEntries.some((e) => { if (e.type !== 'list' && 'value' in e) { return validateHasWildcardWithWrongOperator({ diff --git a/packages/kbn-unified-data-table/src/components/data_table_additional_display_settings.tsx b/packages/kbn-unified-data-table/src/components/data_table_additional_display_settings.tsx index cbead22b399975e..9b6629d2c960ba5 100644 --- a/packages/kbn-unified-data-table/src/components/data_table_additional_display_settings.tsx +++ b/packages/kbn-unified-data-table/src/components/data_table_additional_display_settings.tsx @@ -7,7 +7,7 @@ */ import React, { useCallback, useEffect, useMemo, useState } from 'react'; -import { EuiFormRow, EuiHorizontalRule, EuiRange } from '@elastic/eui'; +import { EuiFormRow, EuiHorizontalRule, EuiRange, EuiRangeProps } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { debounce } from 'lodash'; import { RowHeightSettings, RowHeightSettingsProps } from './row_height_settings'; @@ -63,9 +63,9 @@ export const UnifiedDataTableAdditionalDisplaySettings: React.FC< [onChangeSampleSize] ); - const onChangeActiveSampleSize = useCallback( + const onChangeActiveSampleSize = useCallback>( (event) => { - if (!event.target.value) { + if (!('value' in event.target) || !event.target.value) { setActiveSampleSize(''); return; } diff --git a/packages/kbn-visualization-ui-components/components/color_picker.tsx b/packages/kbn-visualization-ui-components/components/color_picker.tsx index 3a2613d16d66588..442140e82c2b646 100644 --- a/packages/kbn-visualization-ui-components/components/color_picker.tsx +++ b/packages/kbn-visualization-ui-components/components/color_picker.tsx @@ -28,6 +28,17 @@ const tooltipContent = { }), }; +export interface ColorPickerProps { + overwriteColor?: string | null; + defaultColor?: string | null; + isClearable?: boolean; + setConfig: (config: { color?: string }) => void; + label?: string; + disableHelpTooltip?: boolean; + disabledMessage?: string; + showAlpha?: boolean; +} + export const ColorPicker = ({ overwriteColor, defaultColor, @@ -37,16 +48,7 @@ export const ColorPicker = ({ disableHelpTooltip, disabledMessage, showAlpha, -}: { - overwriteColor?: string | null; - defaultColor?: string | null; - isClearable?: boolean; - setConfig: (config: { color?: string }) => void; - label?: string; - disableHelpTooltip?: boolean; - disabledMessage?: string; - showAlpha?: boolean; -}) => { +}: ColorPickerProps) => { const [colorText, setColorText] = useState(overwriteColor || defaultColor); const [validatedColor, setValidatedColor] = useState(overwriteColor || defaultColor); const [currentColorAlpha, setCurrentColorAlpha] = useState(getColorAlpha(colorText)); diff --git a/packages/kbn-visualization-ui-components/components/query_input/filter_query_input.tsx b/packages/kbn-visualization-ui-components/components/query_input/filter_query_input.tsx index b954c37e3f7d123..3c031ac82da0624 100644 --- a/packages/kbn-visualization-ui-components/components/query_input/filter_query_input.tsx +++ b/packages/kbn-visualization-ui-components/components/query_input/filter_query_input.tsx @@ -33,6 +33,18 @@ export const defaultFilter: Query = { language: 'kuery', }; +export interface FilterQueryInputProps { + inputFilter: Query | undefined; + onChange: (query: Query) => void; + dataView: DataViewBase; + helpMessage?: string | null; + label?: string; + initiallyOpen?: boolean; + ['data-test-subj']?: string; + queryInputServices: QueryInputServices; + appName: string; +} + export function FilterQueryInput({ inputFilter, onChange, @@ -43,17 +55,7 @@ export function FilterQueryInput({ ['data-test-subj']: dataTestSubj, queryInputServices, appName, -}: { - inputFilter: Query | undefined; - onChange: (query: Query) => void; - dataView: DataViewBase; - helpMessage?: string | null; - label?: string; - initiallyOpen?: boolean; - ['data-test-subj']?: string; - queryInputServices: QueryInputServices; - appName: string; -}) { +}: FilterQueryInputProps) { const [filterPopoverOpen, setFilterPopoverOpen] = useState(Boolean(initiallyOpen)); const onClosePopup: EuiPopoverProps['closePopover'] = useCallback(() => { diff --git a/packages/kbn-visualization-ui-components/index.ts b/packages/kbn-visualization-ui-components/index.ts index 239849da05a506f..c6d4d7a8c545c39 100644 --- a/packages/kbn-visualization-ui-components/index.ts +++ b/packages/kbn-visualization-ui-components/index.ts @@ -40,6 +40,7 @@ export type { IconSet, AccessorConfig, QueryInputServices, + ColorPickerProps, } from './components'; export type { FormatFactory, LineStyle } from './types'; diff --git a/packages/react/kibana_mount/utils.ts b/packages/react/kibana_mount/utils.ts index d012a373f6a0991..10294c8f0f818c7 100644 --- a/packages/react/kibana_mount/utils.ts +++ b/packages/react/kibana_mount/utils.ts @@ -17,7 +17,7 @@ export const useIfMounted = () => { [] ); - const ifMounted = useCallback((func) => { + const ifMounted = useCallback((func?: () => void) => { if (isMounted.current && func) { func(); } diff --git a/src/plugins/chart_expressions/expression_gauge/public/components/gauge_component.tsx b/src/plugins/chart_expressions/expression_gauge/public/components/gauge_component.tsx index 0e1ebe988e602e8..145571da110221b 100644 --- a/src/plugins/chart_expressions/expression_gauge/public/components/gauge_component.tsx +++ b/src/plugins/chart_expressions/expression_gauge/public/components/gauge_component.tsx @@ -194,7 +194,7 @@ export const GaugeComponent: FC = ({ const getColor = useCallback( ( - value, + value: number, paletteConfig: PaletteOutput, bands: number[], percentageMode?: boolean diff --git a/src/plugins/chart_expressions/expression_tagcloud/public/components/tagcloud_component.tsx b/src/plugins/chart_expressions/expression_tagcloud/public/components/tagcloud_component.tsx index 0c7f855c66390a0..b76bc5ec611b7b8 100644 --- a/src/plugins/chart_expressions/expression_tagcloud/public/components/tagcloud_component.tsx +++ b/src/plugins/chart_expressions/expression_tagcloud/public/components/tagcloud_component.tsx @@ -18,6 +18,8 @@ import { Wordcloud, RenderChangeListener, LEGACY_LIGHT_THEME, + ElementClickListener, + WordCloudElementEvent, } from '@elastic/charts'; import { EmptyPlaceholder } from '@kbn/charts-plugin/public'; import { @@ -190,13 +192,13 @@ export const TagCloudChart = ({ [] ); - const handleWordClick = useCallback( + const handleWordClick = useCallback( (elements) => { if (!bucket) { return; } const termsBucketId = getColumnByAccessor(bucket, visData.columns)!.id; - const clickedValue = elements[0][0].text; + const clickedValue = (elements[0] as WordCloudElementEvent)[0].text; const columnIndex = visData.columns.findIndex((col) => col.id === termsBucketId); if (columnIndex < 0) { diff --git a/src/plugins/charts/public/services/active_cursor/use_active_cursor.ts b/src/plugins/charts/public/services/active_cursor/use_active_cursor.ts index e06c6096664c803..aff01a5871ad6dd 100644 --- a/src/plugins/charts/public/services/active_cursor/use_active_cursor.ts +++ b/src/plugins/charts/public/services/active_cursor/use_active_cursor.ts @@ -11,7 +11,7 @@ import { animationFrameScheduler } from 'rxjs'; import { useCallback, useEffect, RefObject } from 'react'; import { filter, debounceTime } from 'rxjs'; -import type { Chart } from '@elastic/charts'; +import type { Chart, PointerUpdateListener } from '@elastic/charts'; import { parseSyncOptions } from './active_cursor_utils'; @@ -24,9 +24,9 @@ export const useActiveCursor = ( activeCursor: ActiveCursor, chartRef: RefObject, syncOptions: ActiveCursorSyncOption -) => { +): PointerUpdateListener => { const { accessors, isDateHistogram } = parseSyncOptions(syncOptions); - const handleCursorUpdate = useCallback( + const handleCursorUpdate = useCallback( (cursor) => { activeCursor.activeCursor$?.next({ cursor, diff --git a/src/plugins/controls/public/options_list/components/options_list_popover_suggestions.tsx b/src/plugins/controls/public/options_list/components/options_list_popover_suggestions.tsx index 486978b63ec5ef3..f0398d1bf60fd16 100644 --- a/src/plugins/controls/public/options_list/components/options_list_popover_suggestions.tsx +++ b/src/plugins/controls/public/options_list/components/options_list_popover_suggestions.tsx @@ -157,7 +157,7 @@ export const OptionsListPopoverSuggestions = ({ }, [loadMoreSuggestions, totalCardinality]); const renderOption = useCallback( - (option, searchStringValue) => { + (option: EuiSelectableOption, searchStringValue: string) => { if (!allowExpensiveQueries || searchTechnique === 'exact') return option.label; return ( diff --git a/src/plugins/dashboard/common/content_management/v1/index.ts b/src/plugins/dashboard/common/content_management/v1/index.ts index 4fb96a584691e41..72271a64a3e5702 100644 --- a/src/plugins/dashboard/common/content_management/v1/index.ts +++ b/src/plugins/dashboard/common/content_management/v1/index.ts @@ -13,10 +13,3 @@ export type { DashboardAttributes, SavedDashboardPanel, } from './types'; - -export { - serviceDefinition, - dashboardSavedObjectSchema, - controlGroupInputSchema, - dashboardAttributesSchema, -} from './cm_services'; diff --git a/src/plugins/dashboard/common/content_management/v2/index.ts b/src/plugins/dashboard/common/content_management/v2/index.ts index 15105c60d5aba03..27ba4a2c2ef6116 100644 --- a/src/plugins/dashboard/common/content_management/v2/index.ts +++ b/src/plugins/dashboard/common/content_management/v2/index.ts @@ -6,11 +6,5 @@ * Side Public License, v 1. */ -export { - serviceDefinition, - dashboardSavedObjectSchema, - dashboardAttributesSchema, -} from './cm_services'; - export type { GridData, DashboardItem, SavedDashboardPanel } from '../v1/types'; // no changes made to types from v1 to v2 export type { DashboardCrudTypes, DashboardAttributes } from './types'; diff --git a/src/plugins/dashboard/common/content_management/v2/types.ts b/src/plugins/dashboard/common/content_management/v2/types.ts index dcb45f9b44c549e..3ecee5fe8f43ec1 100644 --- a/src/plugins/dashboard/common/content_management/v2/types.ts +++ b/src/plugins/dashboard/common/content_management/v2/types.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { +import type { ContentManagementCrudTypes, SavedObjectCreateOptions, SavedObjectUpdateOptions, diff --git a/src/plugins/dashboard/server/content_management/dashboard_storage.ts b/src/plugins/dashboard/server/content_management/dashboard_storage.ts index 4391aeaa90563b6..e9b5479dea90ced 100644 --- a/src/plugins/dashboard/server/content_management/dashboard_storage.ts +++ b/src/plugins/dashboard/server/content_management/dashboard_storage.ts @@ -11,7 +11,7 @@ import { SavedObjectsFindOptions } from '@kbn/core-saved-objects-api-server'; import type { Logger } from '@kbn/logging'; import { CONTENT_ID } from '../../common/content_management'; -import { cmServicesDefinition } from '../../common/content_management/cm_services'; +import { cmServicesDefinition } from './schema/cm_services'; import type { DashboardCrudTypes } from '../../common/content_management'; const searchArgsToSOFindOptions = ( diff --git a/src/plugins/dashboard/common/content_management/cm_services.ts b/src/plugins/dashboard/server/content_management/schema/cm_services.ts similarity index 100% rename from src/plugins/dashboard/common/content_management/cm_services.ts rename to src/plugins/dashboard/server/content_management/schema/cm_services.ts diff --git a/src/plugins/dashboard/common/content_management/v1/cm_services.ts b/src/plugins/dashboard/server/content_management/schema/v1/cm_services.ts similarity index 100% rename from src/plugins/dashboard/common/content_management/v1/cm_services.ts rename to src/plugins/dashboard/server/content_management/schema/v1/cm_services.ts diff --git a/src/plugins/dashboard/server/content_management/schema/v1/index.ts b/src/plugins/dashboard/server/content_management/schema/v1/index.ts new file mode 100644 index 000000000000000..3e4684ab64cfb81 --- /dev/null +++ b/src/plugins/dashboard/server/content_management/schema/v1/index.ts @@ -0,0 +1,14 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export { + serviceDefinition, + dashboardSavedObjectSchema, + controlGroupInputSchema, + dashboardAttributesSchema, +} from './cm_services'; diff --git a/src/plugins/dashboard/common/content_management/v2/cm_services.ts b/src/plugins/dashboard/server/content_management/schema/v2/cm_services.ts similarity index 100% rename from src/plugins/dashboard/common/content_management/v2/cm_services.ts rename to src/plugins/dashboard/server/content_management/schema/v2/cm_services.ts diff --git a/src/plugins/dashboard/server/content_management/schema/v2/index.ts b/src/plugins/dashboard/server/content_management/schema/v2/index.ts new file mode 100644 index 000000000000000..b20dfef42380186 --- /dev/null +++ b/src/plugins/dashboard/server/content_management/schema/v2/index.ts @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export { + serviceDefinition, + dashboardSavedObjectSchema, + dashboardAttributesSchema, +} from './cm_services'; diff --git a/src/plugins/dashboard/server/dashboard_saved_object/dashboard_saved_object.ts b/src/plugins/dashboard/server/dashboard_saved_object/dashboard_saved_object.ts index 2cf913919b91227..688dce1d0687d1a 100644 --- a/src/plugins/dashboard/server/dashboard_saved_object/dashboard_saved_object.ts +++ b/src/plugins/dashboard/server/dashboard_saved_object/dashboard_saved_object.ts @@ -9,8 +9,8 @@ import { ANALYTICS_SAVED_OBJECT_INDEX } from '@kbn/core-saved-objects-server'; import { SavedObjectsType } from '@kbn/core/server'; -import { dashboardAttributesSchema as dashboardAttributesSchemaV1 } from '../../common/content_management/v1'; -import { dashboardAttributesSchema as dashboardAttributesSchemaV2 } from '../../common/content_management/v2'; +import { dashboardAttributesSchema as dashboardAttributesSchemaV1 } from '../content_management/schema/v1'; +import { dashboardAttributesSchema as dashboardAttributesSchemaV2 } from '../content_management/schema/v2'; import { createDashboardSavedObjectTypeMigrations, DashboardSavedObjectTypeMigrationsDeps, diff --git a/src/plugins/data_view_editor/public/components/data_view_editor_flyout_content.tsx b/src/plugins/data_view_editor/public/components/data_view_editor_flyout_content.tsx index 98897ed4472de1a..22ed26e702eb490 100644 --- a/src/plugins/data_view_editor/public/components/data_view_editor_flyout_content.tsx +++ b/src/plugins/data_view_editor/public/components/data_view_editor_flyout_content.tsx @@ -196,7 +196,7 @@ const IndexPatternEditorFlyoutContentComponent = ({ const getRollupIndices = (rollupCaps: RollupIndicesCapsResponse) => Object.keys(rollupCaps); const onTypeChange = useCallback( - (newType) => { + (newType: INDEX_PATTERN_TYPE) => { form.setFieldValue('title', ''); form.setFieldValue('name', ''); form.setFieldValue('timestampField', ''); diff --git a/src/plugins/data_views/server/content_management/data_views_storage.ts b/src/plugins/data_views/server/content_management/data_views_storage.ts index bb01064d59956ad..c0f7f287a7f9270 100644 --- a/src/plugins/data_views/server/content_management/data_views_storage.ts +++ b/src/plugins/data_views/server/content_management/data_views_storage.ts @@ -11,7 +11,7 @@ import type { Logger } from '@kbn/logging'; import type { DataViewCrudTypes } from '../../common/content_management'; import { DataViewSOType } from '../../common/content_management'; -import { cmServicesDefinition } from '../../common/content_management/cm_services'; +import { cmServicesDefinition } from './schema/cm_services'; export class DataViewsStorage extends SOContentStorage { constructor({ diff --git a/src/plugins/data_views/common/content_management/cm_services.ts b/src/plugins/data_views/server/content_management/schema/cm_services.ts similarity index 100% rename from src/plugins/data_views/common/content_management/cm_services.ts rename to src/plugins/data_views/server/content_management/schema/cm_services.ts diff --git a/src/plugins/data_views/common/content_management/v1/cm_services.ts b/src/plugins/data_views/server/content_management/schema/v1/cm_services.ts similarity index 95% rename from src/plugins/data_views/common/content_management/v1/cm_services.ts rename to src/plugins/data_views/server/content_management/schema/v1/cm_services.ts index 7b70a4c103457f9..71e73135b5e59e0 100644 --- a/src/plugins/data_views/common/content_management/v1/cm_services.ts +++ b/src/plugins/data_views/server/content_management/schema/v1/cm_services.ts @@ -16,9 +16,9 @@ import { createResultSchema, searchOptionsSchemas, } from '@kbn/content-management-utils'; -import { DataViewType } from '../..'; -import { MAX_DATA_VIEW_FIELD_DESCRIPTION_LENGTH } from '../../constants'; -import { serializedFieldFormatSchema, fieldSpecSchema } from '../../schemas'; +import { DataViewType } from '../../../../common'; +import { MAX_DATA_VIEW_FIELD_DESCRIPTION_LENGTH } from '../../../../common/constants'; +import { serializedFieldFormatSchema, fieldSpecSchema } from '../../../schemas'; const dataViewAttributesSchema = schema.object( { diff --git a/src/plugins/data_views/server/rest_api_routes/public/fields/update_fields.ts b/src/plugins/data_views/server/rest_api_routes/public/fields/update_fields.ts index a8d2e7d0a524719..2ef80e8cbf68d39 100644 --- a/src/plugins/data_views/server/rest_api_routes/public/fields/update_fields.ts +++ b/src/plugins/data_views/server/rest_api_routes/public/fields/update_fields.ts @@ -12,7 +12,7 @@ import { IRouter, StartServicesAccessor } from '@kbn/core/server'; import { SerializedFieldFormat } from '@kbn/field-formats-plugin/common'; import { DataViewsService } from '../../../../common'; import { handleErrors } from '../util/handle_errors'; -import { serializedFieldFormatSchema } from '../../../../common/schemas'; +import { serializedFieldFormatSchema } from '../../../schemas'; import { MAX_DATA_VIEW_FIELD_DESCRIPTION_LENGTH } from '../../../../common/constants'; import { dataViewSpecSchema } from '../../schema'; import { DataViewSpecRestResponse } from '../../route_types'; diff --git a/src/plugins/data_views/server/rest_api_routes/public/runtime_fields/create_runtime_field.ts b/src/plugins/data_views/server/rest_api_routes/public/runtime_fields/create_runtime_field.ts index ff446f76c885aa1..49f928dd863a51e 100644 --- a/src/plugins/data_views/server/rest_api_routes/public/runtime_fields/create_runtime_field.ts +++ b/src/plugins/data_views/server/rest_api_routes/public/runtime_fields/create_runtime_field.ts @@ -12,7 +12,7 @@ import { IRouter, StartServicesAccessor } from '@kbn/core/server'; import { DataViewsService } from '../../../../common/data_views'; import { RuntimeField } from '../../../../common/types'; import { handleErrors } from '../util/handle_errors'; -import { runtimeFieldSchema } from '../../../../common/schemas'; +import { runtimeFieldSchema } from '../../../schemas'; import type { DataViewsServerPluginStart, DataViewsServerPluginStartDependencies, diff --git a/src/plugins/data_views/server/rest_api_routes/public/runtime_fields/put_runtime_field.ts b/src/plugins/data_views/server/rest_api_routes/public/runtime_fields/put_runtime_field.ts index 7105d8ea8413b7f..30076183ce6e808 100644 --- a/src/plugins/data_views/server/rest_api_routes/public/runtime_fields/put_runtime_field.ts +++ b/src/plugins/data_views/server/rest_api_routes/public/runtime_fields/put_runtime_field.ts @@ -12,7 +12,7 @@ import { IRouter, StartServicesAccessor } from '@kbn/core/server'; import { DataViewsService } from '../../../../common/data_views'; import { RuntimeField } from '../../../../common/types'; import { handleErrors } from '../util/handle_errors'; -import { runtimeFieldSchema } from '../../../../common/schemas'; +import { runtimeFieldSchema } from '../../../schemas'; import type { DataViewsServerPluginStart, DataViewsServerPluginStartDependencies, diff --git a/src/plugins/data_views/server/rest_api_routes/public/runtime_fields/update_runtime_field.ts b/src/plugins/data_views/server/rest_api_routes/public/runtime_fields/update_runtime_field.ts index 485551c866eefbc..85887582804ad03 100644 --- a/src/plugins/data_views/server/rest_api_routes/public/runtime_fields/update_runtime_field.ts +++ b/src/plugins/data_views/server/rest_api_routes/public/runtime_fields/update_runtime_field.ts @@ -13,7 +13,7 @@ import { DataViewsService } from '../../../../common/data_views'; import { RuntimeField } from '../../../../common/types'; import { ErrorIndexPatternFieldNotFound } from '../../../error'; import { handleErrors } from '../util/handle_errors'; -import { runtimeFieldSchemaUpdate } from '../../../../common/schemas'; +import { runtimeFieldSchemaUpdate } from '../../../schemas'; import type { DataViewsServerPluginStart, DataViewsServerPluginStartDependencies, diff --git a/src/plugins/data_views/server/rest_api_routes/public/scripted_fields/create_scripted_field.ts b/src/plugins/data_views/server/rest_api_routes/public/scripted_fields/create_scripted_field.ts index ed6716b1684bab5..6ed3bbf5e84d0b7 100644 --- a/src/plugins/data_views/server/rest_api_routes/public/scripted_fields/create_scripted_field.ts +++ b/src/plugins/data_views/server/rest_api_routes/public/scripted_fields/create_scripted_field.ts @@ -9,7 +9,7 @@ import { schema } from '@kbn/config-schema'; import { IRouter, StartServicesAccessor } from '@kbn/core/server'; import { handleErrors } from '../util/handle_errors'; -import { fieldSpecSchema } from '../../../../common/schemas'; +import { fieldSpecSchema } from '../../../schemas'; import type { DataViewsServerPluginStart, DataViewsServerPluginStartDependencies, diff --git a/src/plugins/data_views/server/rest_api_routes/public/scripted_fields/get_scripted_field.ts b/src/plugins/data_views/server/rest_api_routes/public/scripted_fields/get_scripted_field.ts index 7023fba31b5895f..d5083b01070ba1c 100644 --- a/src/plugins/data_views/server/rest_api_routes/public/scripted_fields/get_scripted_field.ts +++ b/src/plugins/data_views/server/rest_api_routes/public/scripted_fields/get_scripted_field.ts @@ -15,7 +15,7 @@ import type { DataViewsServerPluginStartDependencies, } from '../../../types'; import { INITIAL_REST_VERSION } from '../../../constants'; -import { fieldSpecSchemaFields } from '../../../../common/schemas'; +import { fieldSpecSchemaFields } from '../../../schemas'; import { FieldSpecRestResponse } from '../../route_types'; export const registerGetScriptedFieldRoute = ( diff --git a/src/plugins/data_views/server/rest_api_routes/public/scripted_fields/put_scripted_field.ts b/src/plugins/data_views/server/rest_api_routes/public/scripted_fields/put_scripted_field.ts index 20e828009f2a19f..00875773a80490f 100644 --- a/src/plugins/data_views/server/rest_api_routes/public/scripted_fields/put_scripted_field.ts +++ b/src/plugins/data_views/server/rest_api_routes/public/scripted_fields/put_scripted_field.ts @@ -9,7 +9,7 @@ import { schema } from '@kbn/config-schema'; import { IRouter, StartServicesAccessor } from '@kbn/core/server'; import { handleErrors } from '../util/handle_errors'; -import { fieldSpecSchema } from '../../../../common/schemas'; +import { fieldSpecSchema } from '../../../schemas'; import type { DataViewsServerPluginStart, DataViewsServerPluginStartDependencies, diff --git a/src/plugins/data_views/server/rest_api_routes/public/scripted_fields/update_scripted_field.ts b/src/plugins/data_views/server/rest_api_routes/public/scripted_fields/update_scripted_field.ts index 53e9d165814b5f1..9589c1c9e7a8d1e 100644 --- a/src/plugins/data_views/server/rest_api_routes/public/scripted_fields/update_scripted_field.ts +++ b/src/plugins/data_views/server/rest_api_routes/public/scripted_fields/update_scripted_field.ts @@ -11,7 +11,7 @@ import { IRouter, StartServicesAccessor } from '@kbn/core/server'; import { FieldSpec } from '../../../../common'; import { ErrorIndexPatternFieldNotFound } from '../../../error'; import { handleErrors } from '../util/handle_errors'; -import { fieldSpecSchemaFields } from '../../../../common/schemas'; +import { fieldSpecSchemaFields } from '../../../schemas'; import type { DataViewsServerPluginStart, DataViewsServerPluginStartDependencies, diff --git a/src/plugins/data_views/server/rest_api_routes/public/update_data_view.ts b/src/plugins/data_views/server/rest_api_routes/public/update_data_view.ts index 0c7c66a0a1fecad..ad830c7c809f271 100644 --- a/src/plugins/data_views/server/rest_api_routes/public/update_data_view.ts +++ b/src/plugins/data_views/server/rest_api_routes/public/update_data_view.ts @@ -13,11 +13,7 @@ import { DataViewSpecRestResponse } from '../route_types'; import { DataViewsService } from '../../../common/data_views'; import { DataViewSpec } from '../../../common/types'; import { handleErrors } from './util/handle_errors'; -import { - fieldSpecSchema, - runtimeFieldSchema, - serializedFieldFormatSchema, -} from '../../../common/schemas'; +import { fieldSpecSchema, runtimeFieldSchema, serializedFieldFormatSchema } from '../../schemas'; import { dataViewSpecSchema } from '../schema'; import type { DataViewsServerPluginStartDependencies, diff --git a/src/plugins/data_views/server/rest_api_routes/schema.ts b/src/plugins/data_views/server/rest_api_routes/schema.ts index c4f4a4c70b82623..f9518ca8099b295 100644 --- a/src/plugins/data_views/server/rest_api_routes/schema.ts +++ b/src/plugins/data_views/server/rest_api_routes/schema.ts @@ -14,7 +14,7 @@ import { runtimeFieldSchema, serializedFieldFormatSchema, fieldSpecSchemaFields, -} from '../../common/schemas'; +} from '../schemas'; import { MAX_DATA_VIEW_FIELD_DESCRIPTION_LENGTH } from '../../common/constants'; export const dataViewSpecSchema = schema.object({ diff --git a/src/plugins/data_views/common/schemas.ts b/src/plugins/data_views/server/schemas.ts similarity index 97% rename from src/plugins/data_views/common/schemas.ts rename to src/plugins/data_views/server/schemas.ts index b780118414044e0..1eae6d09ee7dead 100644 --- a/src/plugins/data_views/common/schemas.ts +++ b/src/plugins/data_views/server/schemas.ts @@ -7,8 +7,8 @@ */ import { schema, Type } from '@kbn/config-schema'; -import { MAX_DATA_VIEW_FIELD_DESCRIPTION_LENGTH } from './constants'; -import { RuntimeType } from '.'; +import { MAX_DATA_VIEW_FIELD_DESCRIPTION_LENGTH } from '../common/constants'; +import { RuntimeType } from '../common'; export const serializedFieldFormatSchema = schema.object({ id: schema.maybe(schema.string()), diff --git a/src/plugins/discover/public/application/context/context_app_content.tsx b/src/plugins/discover/public/application/context/context_app_content.tsx index 4d6d815fd796bf6..e0f0dbbd820cb2d 100644 --- a/src/plugins/discover/public/application/context/context_app_content.tsx +++ b/src/plugins/discover/public/application/context/context_app_content.tsx @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import React, { Fragment, useCallback, useMemo, useState, FC, PropsWithChildren } from 'react'; +import React, { Fragment, useCallback, useMemo, useState, FC } from 'react'; import { FormattedMessage } from '@kbn/i18n-react'; import { EuiSpacer, EuiText, useEuiPaddingSize } from '@elastic/eui'; import { css } from '@emotion/react'; @@ -241,7 +241,7 @@ export function ContextAppContent({ ); } -const WrapperWithPadding: FC> = ({ children }) => { +const WrapperWithPadding: FC = ({ children }) => { const padding = useEuiPaddingSize('s'); return ( diff --git a/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar_responsive.tsx b/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar_responsive.tsx index fa8128c0b95ecc5..ac71b1a437038fb 100644 --- a/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar_responsive.tsx +++ b/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar_responsive.tsx @@ -250,7 +250,7 @@ export function DiscoverSidebarResponsive(props: DiscoverSidebarResponsiveProps) // As unifiedFieldListSidebarContainerRef ref can be empty in the beginning, // we need to fetch the data once API becomes available and after documents are fetched const initializeUnifiedFieldListSidebarContainerApi = useCallback( - (api) => { + (api: UnifiedFieldListSidebarContainerApi) => { if (!api) { return; } diff --git a/src/plugins/es_ui_shared/static/forms/components/fields/select_field.tsx b/src/plugins/es_ui_shared/static/forms/components/fields/select_field.tsx index b09215146a59bba..3794f605e4e6415 100644 --- a/src/plugins/es_ui_shared/static/forms/components/fields/select_field.tsx +++ b/src/plugins/es_ui_shared/static/forms/components/fields/select_field.tsx @@ -11,7 +11,7 @@ import { EuiFormRow, EuiSelect } from '@elastic/eui'; import { FieldHook, getFieldValidityAndErrorMessage } from '../../hook_form_lib'; -interface Props { +export interface Props { field: FieldHook; euiFieldProps: { options: Array< diff --git a/src/plugins/event_annotation/common/content_management/v1/types.ts b/src/plugins/event_annotation/common/content_management/v1/types.ts index d85250e3883fa83..6e2ee48e010f954 100644 --- a/src/plugins/event_annotation/common/content_management/v1/types.ts +++ b/src/plugins/event_annotation/common/content_management/v1/types.ts @@ -18,7 +18,7 @@ import { CreateResult, UpdateResult, } from '@kbn/content-management-plugin/common'; -import { ContentManagementCrudTypes } from '@kbn/content-management-utils'; +import type { ContentManagementCrudTypes } from '@kbn/content-management-utils'; import type { DataViewSpec } from '@kbn/data-views-plugin/common'; import type { EventAnnotationConfig } from '@kbn/event-annotation-common'; diff --git a/src/plugins/event_annotation/server/content_management/event_annotation_group_storage.ts b/src/plugins/event_annotation/server/content_management/event_annotation_group_storage.ts index 49a5b516c1d24a3..ea92e9ac0fa10d4 100644 --- a/src/plugins/event_annotation/server/content_management/event_annotation_group_storage.ts +++ b/src/plugins/event_annotation/server/content_management/event_annotation_group_storage.ts @@ -9,7 +9,7 @@ import { SOContentStorage } from '@kbn/content-management-utils'; import { EVENT_ANNOTATION_GROUP_TYPE } from '@kbn/event-annotation-common'; import { Logger } from '@kbn/logging'; -import { cmServicesDefinition } from '../../common/content_management/cm_services'; +import { cmServicesDefinition } from './schema/cm_services'; import type { EventAnnotationGroupCrudTypes } from '../../common/content_management'; export class EventAnnotationGroupStorage extends SOContentStorage { diff --git a/src/plugins/event_annotation/common/content_management/cm_services.ts b/src/plugins/event_annotation/server/content_management/schema/cm_services.ts similarity index 100% rename from src/plugins/event_annotation/common/content_management/cm_services.ts rename to src/plugins/event_annotation/server/content_management/schema/cm_services.ts diff --git a/src/plugins/event_annotation/common/content_management/v1/cm_services.ts b/src/plugins/event_annotation/server/content_management/schema/v1/cm_services.ts similarity index 100% rename from src/plugins/event_annotation/common/content_management/v1/cm_services.ts rename to src/plugins/event_annotation/server/content_management/schema/v1/cm_services.ts diff --git a/src/plugins/links/common/persistable_state/references.ts b/src/plugins/links/common/persistable_state/references.ts index 3c527465a286816..93dc152949289bd 100644 --- a/src/plugins/links/common/persistable_state/references.ts +++ b/src/plugins/links/common/persistable_state/references.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { Reference } from '@kbn/content-management-utils'; +import type { Reference } from '@kbn/content-management-utils'; import { omit } from 'lodash'; import { DASHBOARD_LINK_TYPE, LinksAttributes } from '../content_management'; diff --git a/src/plugins/links/public/components/dashboard_link/dashboard_link_destination_picker.tsx b/src/plugins/links/public/components/dashboard_link/dashboard_link_destination_picker.tsx index 8868dd1a2776ac6..30bd3d3879da9f1 100644 --- a/src/plugins/links/public/components/dashboard_link/dashboard_link_destination_picker.tsx +++ b/src/plugins/links/public/components/dashboard_link/dashboard_link_destination_picker.tsx @@ -94,7 +94,7 @@ export const DashboardLinkDestinationPicker = ({ ); const renderOption = useCallback( - (option, searchValue, contentClassName) => { + (option: DashboardComboBoxOption, searchValue: string, contentClassName: string) => { const { label, key: dashboardId } = option; return ( diff --git a/src/plugins/links/public/components/editor/links_editor.tsx b/src/plugins/links/public/components/editor/links_editor.tsx index 0ee31cd8415212e..ac8879d1dd8502a 100644 --- a/src/plugins/links/public/components/editor/links_editor.tsx +++ b/src/plugins/links/public/components/editor/links_editor.tsx @@ -10,6 +10,7 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react' import useMountedState from 'react-use/lib/useMountedState'; import { + DropResult, EuiButton, EuiButtonEmpty, EuiButtonGroup, @@ -101,7 +102,7 @@ const LinksEditor = ({ }, [initialLinks]); const onDragEnd = useCallback( - ({ source, destination }) => { + ({ source, destination }: DropResult) => { if (source && destination) { const newList = euiDragDropReorder(orderedLinks, source.index, destination.index).map( (link, i) => { diff --git a/src/plugins/links/public/lib/deserialize_from_library.ts b/src/plugins/links/public/lib/deserialize_from_library.ts index 859a988954a1b94..2640540b6e49ca5 100644 --- a/src/plugins/links/public/lib/deserialize_from_library.ts +++ b/src/plugins/links/public/lib/deserialize_from_library.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { SOWithMetadata } from '@kbn/content-management-utils'; +import type { SOWithMetadata } from '@kbn/content-management-utils'; import { LinksAttributes } from '../../common/content_management'; import { injectReferences } from '../../common/persistable_state'; import { LinksByReferenceSerializedState, LinksRuntimeState, LinksSerializedState } from '../types'; diff --git a/src/plugins/links/server/content_management/links_storage.ts b/src/plugins/links/server/content_management/links_storage.ts index 21a5e4aa0de0d4e..ca403efcd099e36 100644 --- a/src/plugins/links/server/content_management/links_storage.ts +++ b/src/plugins/links/server/content_management/links_storage.ts @@ -10,7 +10,7 @@ import type { Logger } from '@kbn/logging'; import { SOContentStorage } from '@kbn/content-management-utils'; import { CONTENT_ID } from '../../common'; import type { LinksCrudTypes } from '../../common/content_management'; -import { cmServicesDefinition } from '../../common/content_management/cm_services'; +import { cmServicesDefinition } from './schema/cm_services'; export class LinksStorage extends SOContentStorage { constructor({ diff --git a/src/plugins/links/common/content_management/cm_services.ts b/src/plugins/links/server/content_management/schema/cm_services.ts similarity index 100% rename from src/plugins/links/common/content_management/cm_services.ts rename to src/plugins/links/server/content_management/schema/cm_services.ts diff --git a/src/plugins/links/common/content_management/v1/cm_services.ts b/src/plugins/links/server/content_management/schema/v1/cm_services.ts similarity index 93% rename from src/plugins/links/common/content_management/v1/cm_services.ts rename to src/plugins/links/server/content_management/schema/v1/cm_services.ts index 597fcfe0d845187..16a8b1209b22b9b 100644 --- a/src/plugins/links/common/content_management/v1/cm_services.ts +++ b/src/plugins/links/server/content_management/schema/v1/cm_services.ts @@ -15,8 +15,11 @@ import { createOptionsSchemas, objectTypeToGetResultSchema, } from '@kbn/content-management-utils'; -import { DASHBOARD_LINK_TYPE, EXTERNAL_LINK_TYPE } from '.'; -import { LINKS_HORIZONTAL_LAYOUT, LINKS_VERTICAL_LAYOUT } from './constants'; +import { DASHBOARD_LINK_TYPE, EXTERNAL_LINK_TYPE } from '../../../../common/content_management/v1'; +import { + LINKS_HORIZONTAL_LAYOUT, + LINKS_VERTICAL_LAYOUT, +} from '../../../../common/content_management/v1/constants'; const baseLinkSchema = { id: schema.string(), diff --git a/src/plugins/saved_search/server/content_management/saved_search_storage.ts b/src/plugins/saved_search/server/content_management/saved_search_storage.ts index 3982bca7cf93262..de17c9e9cf5decb 100644 --- a/src/plugins/saved_search/server/content_management/saved_search_storage.ts +++ b/src/plugins/saved_search/server/content_management/saved_search_storage.ts @@ -11,7 +11,7 @@ import type { Logger } from '@kbn/logging'; import type { SavedSearchCrudTypes } from '../../common/content_management'; import { SavedSearchType } from '../../common/content_management'; -import { cmServicesDefinition } from '../../common/content_management/cm_services'; +import { cmServicesDefinition } from './schema/cm_services'; export class SavedSearchStorage extends SOContentStorage { constructor({ diff --git a/src/plugins/saved_search/common/content_management/cm_services.ts b/src/plugins/saved_search/server/content_management/schema/cm_services.ts similarity index 100% rename from src/plugins/saved_search/common/content_management/cm_services.ts rename to src/plugins/saved_search/server/content_management/schema/cm_services.ts diff --git a/src/plugins/saved_search/common/content_management/v1/cm_services.ts b/src/plugins/saved_search/server/content_management/schema/v1/cm_services.ts similarity index 97% rename from src/plugins/saved_search/common/content_management/v1/cm_services.ts rename to src/plugins/saved_search/server/content_management/schema/v1/cm_services.ts index 7a3f8eb6d5e9d94..53df9882afd7086 100644 --- a/src/plugins/saved_search/common/content_management/v1/cm_services.ts +++ b/src/plugins/saved_search/server/content_management/schema/v1/cm_services.ts @@ -15,7 +15,10 @@ import { updateOptionsSchema, createResultSchema, } from '@kbn/content-management-utils'; -import { MIN_SAVED_SEARCH_SAMPLE_SIZE, MAX_SAVED_SEARCH_SAMPLE_SIZE } from '../../constants'; +import { + MIN_SAVED_SEARCH_SAMPLE_SIZE, + MAX_SAVED_SEARCH_SAMPLE_SIZE, +} from '../../../../common/constants'; const sortSchema = schema.arrayOf(schema.string(), { maxSize: 2 }); diff --git a/src/plugins/unified_histogram/public/chart/chart_config_panel.tsx b/src/plugins/unified_histogram/public/chart/chart_config_panel.tsx index 1c598d06a143cfd..00d1eee9bcba0a8 100644 --- a/src/plugins/unified_histogram/public/chart/chart_config_panel.tsx +++ b/src/plugins/unified_histogram/public/chart/chart_config_panel.tsx @@ -5,12 +5,13 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import React, { useCallback, useEffect, useRef, useState } from 'react'; +import React, { ComponentProps, useCallback, useEffect, useRef, useState } from 'react'; import type { Observable } from 'rxjs'; import type { AggregateQuery, Query } from '@kbn/es-query'; -import { isEqual } from 'lodash'; +import { isEqual, isObject } from 'lodash'; import type { LensEmbeddableOutput, Suggestion } from '@kbn/lens-plugin/public'; import type { Datatable } from '@kbn/expressions-plugin/common'; +import { EditLensConfigPanelComponent } from '@kbn/lens-plugin/public/plugin'; import { deriveLensSuggestionFromLensAttributes } from '../utils/external_vis_context'; import { @@ -49,13 +50,16 @@ export function ChartConfigPanel({ const previousAdapters = useRef | undefined>(undefined); const previousQuery = useRef(undefined); - const updatePanelState = useCallback( + const updatePanelState = useCallback< + ComponentProps['updatePanelState'] + >( (datasourceState, visualizationState, visualizationId) => { const updatedSuggestion: Suggestion = { - ...currentSuggestionContext?.suggestion, - visualizationId: visualizationId ?? currentSuggestionContext?.suggestion?.visualizationId, - ...(datasourceState && { datasourceState }), - ...(visualizationState && { visualizationState }), + ...currentSuggestionContext.suggestion!, + visualizationId: + visualizationId ?? currentSuggestionContext.suggestion?.visualizationId ?? '', + ...(isObject(datasourceState) && { datasourceState }), + ...(isObject(visualizationState) && { visualizationState }), }; onSuggestionContextEdit({ ...currentSuggestionContext, @@ -65,7 +69,9 @@ export function ChartConfigPanel({ [currentSuggestionContext, onSuggestionContextEdit] ); - const updateSuggestion = useCallback( + const updateSuggestion = useCallback< + NonNullable['updateSuggestion']> + >( (attributes) => { const updatedSuggestion = deriveLensSuggestionFromLensAttributes({ externalVisContext: { diff --git a/src/plugins/unified_histogram/public/chart/toolbar_selector.tsx b/src/plugins/unified_histogram/public/chart/toolbar_selector.tsx index b9115847b7b03ac..58d6b5db00234d1 100644 --- a/src/plugins/unified_histogram/public/chart/toolbar_selector.tsx +++ b/src/plugins/unified_histogram/public/chart/toolbar_selector.tsx @@ -60,9 +60,11 @@ export const ToolbarSelector: React.FC = ({ [] ); - const onSelectionChange = useCallback( + const onSelectionChange = useCallback< + NonNullable['onChange']> + >( (newOptions) => { - const chosenOption = newOptions.find(({ checked }: SelectableEntry) => checked === 'on'); + const chosenOption = newOptions.find(({ checked }) => checked === 'on'); onChange?.( chosenOption?.value && chosenOption?.value !== EMPTY_OPTION ? chosenOption : undefined @@ -139,7 +141,7 @@ export const ToolbarSelector: React.FC = ({ anchorPosition="downLeft" > {popoverTitle} - id={`${dataTestSubj}Selectable`} singleSelection aria-label={popoverTitle} diff --git a/src/plugins/unified_histogram/public/container/hooks/use_state_props.test.ts b/src/plugins/unified_histogram/public/container/hooks/use_state_props.test.ts index 44a216178f6d5a8..1491556fc37d3ee 100644 --- a/src/plugins/unified_histogram/public/container/hooks/use_state_props.test.ts +++ b/src/plugins/unified_histogram/public/container/hooks/use_state_props.test.ts @@ -7,10 +7,9 @@ */ import { DataView, DataViewField, DataViewType } from '@kbn/data-views-plugin/common'; import { RequestAdapter } from '@kbn/inspector-plugin/common'; -import { Suggestion } from '@kbn/lens-plugin/public'; import { renderHook } from '@testing-library/react-hooks'; import { act } from 'react-test-renderer'; -import { UnifiedHistogramFetchStatus } from '../../types'; +import { UnifiedHistogramFetchStatus, UnifiedHistogramSuggestionContext } from '../../types'; import { dataViewMock } from '../../__mocks__/data_view'; import { dataViewWithTimefieldMock } from '../../__mocks__/data_view_with_timefield'; import { lensAdaptersMock } from '../../__mocks__/lens_adapters'; @@ -451,10 +450,12 @@ describe('useStateProps', () => { expect(stateService.setBreakdownField).toHaveBeenLastCalledWith('field'); act(() => { - onSuggestionContextChange({ title: 'Stacked Bar' } as Suggestion); + onSuggestionContextChange({ + suggestion: { title: 'Stacked Bar' }, + } as UnifiedHistogramSuggestionContext); }); expect(stateService.setCurrentSuggestionContext).toHaveBeenLastCalledWith({ - title: 'Stacked Bar', + suggestion: { title: 'Stacked Bar' }, }); }); diff --git a/src/plugins/unified_histogram/public/container/hooks/use_state_props.ts b/src/plugins/unified_histogram/public/container/hooks/use_state_props.ts index f5c8e8e3bc025a0..58ec13fd5d1a7d3 100644 --- a/src/plugins/unified_histogram/public/container/hooks/use_state_props.ts +++ b/src/plugins/unified_histogram/public/container/hooks/use_state_props.ts @@ -10,7 +10,11 @@ import { DataView, DataViewField, DataViewType } from '@kbn/data-views-plugin/co import { AggregateQuery, isOfAggregateQueryType, Query } from '@kbn/es-query'; import type { RequestAdapter } from '@kbn/inspector-plugin/public'; import { useCallback, useEffect, useMemo } from 'react'; -import { UnifiedHistogramChartLoadEvent, UnifiedHistogramFetchStatus } from '../../types'; +import { + UnifiedHistogramChartLoadEvent, + UnifiedHistogramFetchStatus, + UnifiedHistogramSuggestionContext, +} from '../../types'; import type { UnifiedHistogramStateService } from '../services/state_service'; import { breakdownFieldSelector, @@ -150,7 +154,7 @@ export const useStateProps = ({ ); const onSuggestionContextChange = useCallback( - (suggestionContext) => { + (suggestionContext: UnifiedHistogramSuggestionContext | undefined) => { stateService?.setCurrentSuggestionContext(suggestionContext); }, [stateService] diff --git a/src/plugins/unified_search/public/dataview_picker/dataview_list.tsx b/src/plugins/unified_search/public/dataview_picker/dataview_list.tsx index 559174711af3b46..1b32952c15679bb 100644 --- a/src/plugins/unified_search/public/dataview_picker/dataview_list.tsx +++ b/src/plugins/unified_search/public/dataview_picker/dataview_list.tsx @@ -16,6 +16,7 @@ import { EuiPanel, EuiButtonGroup, toSentenceCase, + Direction, } from '@elastic/eui'; import type { DataViewListItem } from '@kbn/data-views-plugin/public'; import { i18n } from '@kbn/i18n'; @@ -107,8 +108,8 @@ export function DataViewsList({ ); const onChangeSortDirection = useCallback( - (value) => { - sortingService.setDirection(value); + (value: string) => { + sortingService.setDirection(value as Direction); setSortedDataViewsList((dataViews) => sortingService.sortData(dataViews)); }, [sortingService] diff --git a/src/plugins/unified_search/public/filters_builder/filter_item/params_editor.tsx b/src/plugins/unified_search/public/filters_builder/filter_item/params_editor.tsx index b51defaf2282ef9..4dac0d33163dd73 100644 --- a/src/plugins/unified_search/public/filters_builder/filter_item/params_editor.tsx +++ b/src/plugins/unified_search/public/filters_builder/filter_item/params_editor.tsx @@ -10,10 +10,11 @@ import React, { useCallback, useContext } from 'react'; import { DataView, DataViewField } from '@kbn/data-views-plugin/common'; import type { Filter } from '@kbn/es-query'; import { EuiToolTip, EuiFormRow } from '@elastic/eui'; +import { FilterMetaParams } from '@kbn/es-query/src/filters/build_filters'; import type { Operator } from '../../filter_bar/filter_editor'; import { getFieldValidityAndErrorMessage } from '../../filter_bar/filter_editor/lib'; import { FiltersBuilderContextType } from '../context'; -import { ParamsEditorInput } from './params_editor_input'; +import { ParamsEditorInput, ParamsEditorInputProps } from './params_editor_input'; interface ParamsEditorProps { dataView: DataView; @@ -37,15 +38,15 @@ export function ParamsEditor({ filtersForSuggestions, }: ParamsEditorProps) { const { disabled, suggestionsAbstraction } = useContext(FiltersBuilderContextType); - const onParamsChange = useCallback( + const onParamsChange = useCallback( (selectedParams) => { - onHandleParamsChange(selectedParams); + onHandleParamsChange(selectedParams as FilterMetaParams); }, [onHandleParamsChange] ); - const onParamsUpdate = useCallback( - (value) => { + const onParamsUpdate = useCallback( + (value: any) => { onHandleParamsUpdate(value); }, [onHandleParamsUpdate] diff --git a/src/plugins/unified_search/public/filters_builder/filter_item/params_editor_input.tsx b/src/plugins/unified_search/public/filters_builder/filter_item/params_editor_input.tsx index c3138f7a14e24cb..d59ffa9782e3560 100644 --- a/src/plugins/unified_search/public/filters_builder/filter_item/params_editor_input.tsx +++ b/src/plugins/unified_search/public/filters_builder/filter_item/params_editor_input.tsx @@ -34,7 +34,7 @@ export const strings = { }), }; -interface ParamsEditorInputProps { +export interface ParamsEditorInputProps { dataView: DataView; params: unknown; onParamsChange: (params: unknown) => void; diff --git a/src/plugins/unified_search/public/saved_query_form/save_query_form.tsx b/src/plugins/unified_search/public/saved_query_form/save_query_form.tsx index e9d7a548fadaa9f..09a55047d277797 100644 --- a/src/plugins/unified_search/public/saved_query_form/save_query_form.tsx +++ b/src/plugins/unified_search/public/saved_query_form/save_query_form.tsx @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import React, { useState, useCallback } from 'react'; +import React, { useState, useCallback, ChangeEventHandler } from 'react'; import { EuiButton, EuiForm, EuiFormRow, EuiFieldText, EuiSwitch } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { isEqual } from 'lodash'; @@ -117,7 +117,7 @@ export function SaveQueryForm({ shouldIncludeTimefilter, ]); - const onInputChange = useCallback((event) => { + const onInputChange = useCallback>((event) => { setFormErrors([]); setTitle(event.target.value); }, []); diff --git a/src/plugins/unified_search/public/saved_query_management/saved_query_management_list.tsx b/src/plugins/unified_search/public/saved_query_management/saved_query_management_list.tsx index d62061d7d6cf6a6..825b15884912010 100644 --- a/src/plugins/unified_search/public/saved_query_management/saved_query_management_list.tsx +++ b/src/plugins/unified_search/public/saved_query_management/saved_query_management_list.tsx @@ -24,6 +24,7 @@ import { EuiHorizontalRule, EuiProgress, PrettyDuration, + EuiSelectableProps, } from '@elastic/eui'; import { EuiContextMenuClass } from '@elastic/eui/src/components/context_menu/context_menu'; import { i18n } from '@kbn/i18n'; @@ -282,9 +283,17 @@ export const SavedQueryManagementList = ({ } }, [onLoad, selectedSavedQuery, onClose]); - const handleSelect = useCallback((savedQueryToSelect) => { - setSelectedSavedQuery(savedQueryToSelect); - }, []); + const handleSelect = useCallback['onChange']>>( + (choices) => { + const choice = choices.find(({ checked }) => checked); + if (choice) { + setSelectedSavedQuery( + currentPageQueries.find((savedQuery) => savedQuery.id === choice.value) + ); + } + }, + [currentPageQueries] + ); const handleDelete = useCallback((savedQueryToDelete: SavedQuery) => { setShowDeletionConfirmationModal(true); @@ -439,14 +448,7 @@ export const SavedQueryManagementList = ({ {noSavedQueriesDescriptionText} } - onChange={(choices) => { - const choice = choices.find(({ checked }) => checked); - if (choice) { - handleSelect( - currentPageQueries.find((savedQuery) => savedQuery.id === choice.value) - ); - } - }} + onChange={handleSelect} renderOption={renderOption} css={{ '.euiSelectableList__list': { diff --git a/src/plugins/vis_default_editor/public/components/agg_params.tsx b/src/plugins/vis_default_editor/public/components/agg_params.tsx index aa1fe36d797e41a..8e67a2624501f4c 100644 --- a/src/plugins/vis_default_editor/public/components/agg_params.tsx +++ b/src/plugins/vis_default_editor/public/components/agg_params.tsx @@ -11,7 +11,7 @@ import { EuiForm, EuiAccordion, EuiSpacer } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import useUnmount from 'react-use/lib/useUnmount'; -import { IAggConfig, AggGroupNames } from '@kbn/data-plugin/public'; +import { IAggConfig, AggGroupNames, IAggType } from '@kbn/data-plugin/public'; import type { DataView } from '@kbn/data-views-plugin/public'; import type { Schema } from '@kbn/visualizations-plugin/public'; @@ -124,7 +124,7 @@ function DefaultEditorAggParams({ !!error || isInvalidParamsTouched(agg.type, aggType, paramsState); const onAggSelect = useCallback( - (value) => { + (value: IAggType) => { if (agg.type !== value) { onAggTypeChange(agg.id, value); // reset touched and valid of params diff --git a/src/plugins/vis_default_editor/public/components/agg_select.tsx b/src/plugins/vis_default_editor/public/components/agg_select.tsx index 09aee4b217266f6..e65b56753ab1bdd 100644 --- a/src/plugins/vis_default_editor/public/components/agg_select.tsx +++ b/src/plugins/vis_default_editor/public/components/agg_select.tsx @@ -104,14 +104,14 @@ function DefaultEditorAggSelect({ }, [setValue] ); - const onSearchChange = useCallback((searchValue) => setIsDirty(Boolean(searchValue)), []); + const onSearchChange = useCallback((searchValue: string) => setIsDirty(Boolean(searchValue)), []); const setTouched = useCallback( () => onChangeAggType({ type: AGG_TYPE_ACTION_KEYS.TOUCHED, payload: true }), [onChangeAggType] ); const setValidity = useCallback( - (valid) => onChangeAggType({ type: AGG_TYPE_ACTION_KEYS.VALID, payload: valid }), + (valid: boolean) => onChangeAggType({ type: AGG_TYPE_ACTION_KEYS.VALID, payload: valid }), [onChangeAggType] ); diff --git a/src/plugins/vis_default_editor/public/components/controls/components/from_to_list.tsx b/src/plugins/vis_default_editor/public/components/controls/components/from_to_list.tsx index 89a6109c52fc765..699dbe34702730e 100644 --- a/src/plugins/vis_default_editor/public/components/controls/components/from_to_list.tsx +++ b/src/plugins/vis_default_editor/public/components/controls/components/from_to_list.tsx @@ -67,7 +67,7 @@ const defaultConfig = { }; function FromToList({ showValidation, onBlur, ...rest }: FromToListProps) { - const renderInputRow = useCallback( + const renderInputRow = useCallback( (item: FromToModel, index, onChangeValue) => ( <> diff --git a/src/plugins/vis_default_editor/public/components/controls/components/mask_list.tsx b/src/plugins/vis_default_editor/public/components/controls/components/mask_list.tsx index a63848c1d14ce09..ca42f1bd23f0212 100644 --- a/src/plugins/vis_default_editor/public/components/controls/components/mask_list.tsx +++ b/src/plugins/vis_default_editor/public/components/controls/components/mask_list.tsx @@ -63,7 +63,7 @@ const defaultConfig = { }; function MaskList({ showValidation, onBlur, ...rest }: MaskListProps) { - const renderInputRow = useCallback( + const renderInputRow = useCallback( ({ mask }: MaskModel, index, onChangeValue) => ( setIsDirty(Boolean(searchValue)), []); + const onSearchChange = useCallback((searchValue: string) => setIsDirty(Boolean(searchValue)), []); return ( setValue(ev.target.value), [setValue]); + const onChange = useCallback>( + (e) => setValue(e.target.value), + [setValue] + ); return ( setStateParamValue(PARAMS.NAME, optionId === PARAMS.ROWS), + (optionId: string) => setStateParamValue(PARAMS.NAME, optionId === PARAMS.ROWS), [setStateParamValue] ); diff --git a/src/plugins/vis_default_editor/public/components/controls/string.tsx b/src/plugins/vis_default_editor/public/components/controls/string.tsx index 254c29918066215..90b47ebf5c0d464 100644 --- a/src/plugins/vis_default_editor/public/components/controls/string.tsx +++ b/src/plugins/vis_default_editor/public/components/controls/string.tsx @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import React, { useEffect, useCallback } from 'react'; +import React, { useEffect, useCallback, ChangeEventHandler } from 'react'; import { EuiFieldText, EuiFormRow } from '@elastic/eui'; import { AggParamEditorProps } from '../agg_param_props'; @@ -26,7 +26,10 @@ function StringParamEditor({ setValidity(isValid); }, [isValid, setValidity]); - const onChange = useCallback((ev) => setValue(ev.target.value), [setValue]); + const onChange = useCallback>( + (e) => setValue(e.target.value), + [setValue] + ); return ( void; @@ -18,9 +19,9 @@ function useSubAggParamsHandlers( aggParam: AggParamType, subAgg: IAggConfig, setValue: SetValue -) { - const setAggParamValue = useCallback( - (aggId, paramName, val) => { +): Pick { + const setAggParamValue = useCallback( + (_, paramName, val) => { const parsedParams = subAgg.serialize(); const params = { ...parsedParams, @@ -35,13 +36,13 @@ function useSubAggParamsHandlers( [agg, aggParam, setValue, subAgg] ); - const onAggTypeChange = useCallback( - (aggId, aggType) => { + const onAggTypeChange = useCallback( + (_, aggType) => { const parsedAgg = subAgg.serialize(); const parsedAggParams = parsedAgg.params as SerializableRecord; // we should share between aggs only field and base params: json, label, time shift. - const params = { + const params: AggConfigSerialized = { ...parsedAgg, params: { field: parsedAggParams.field, @@ -49,6 +50,7 @@ function useSubAggParamsHandlers( customLabel: parsedAggParams.customLabel, timeShift: parsedAggParams.timeShift, }, + // @ts-ignore - Need to verify type type: aggType, }; diff --git a/src/plugins/vis_default_editor/public/components/options/color_ranges.tsx b/src/plugins/vis_default_editor/public/components/options/color_ranges.tsx index 67a6c9c6e8f400c..059518926a3e8af 100644 --- a/src/plugins/vis_default_editor/public/components/options/color_ranges.tsx +++ b/src/plugins/vis_default_editor/public/components/options/color_ranges.tsx @@ -39,8 +39,8 @@ function ColorRanges({ }, [colorsRange]); const validateRange = useCallback( - ({ from, to }, index) => { - if (!colorsRange[index]) { + ({ from, to }: RangeValues, index: number) => { + if (from === undefined || to === undefined || !colorsRange[index]) { return [false, false]; } diff --git a/src/plugins/vis_default_editor/public/components/options/index.ts b/src/plugins/vis_default_editor/public/components/options/index.ts index 09373dc64eb8558..fa2aab156861003 100644 --- a/src/plugins/vis_default_editor/public/components/options/index.ts +++ b/src/plugins/vis_default_editor/public/components/options/index.ts @@ -9,11 +9,9 @@ export { BasicOptions } from './basic_options'; export { SwitchOption } from './switch'; export { SelectOption } from './select'; -export type { SetColorRangeValue } from './color_ranges'; -export { ColorRanges } from './color_ranges'; -export type { SetColorSchemaOptionsValue } from './color_schema'; -export { ColorSchemaOptions } from './color_schema'; -export { NumberInputOption } from './number_input'; +export { ColorRanges, type SetColorRangeValue } from './color_ranges'; +export { ColorSchemaOptions, type SetColorSchemaOptionsValue } from './color_schema'; +export { NumberInputOption, type NumberInputOptionProps } from './number_input'; export { RangeOption } from './range'; export { RequiredNumberInputOption } from './required_number_input'; export { TextInputOption } from './text_input'; diff --git a/src/plugins/vis_default_editor/public/components/options/legend_size_settings.tsx b/src/plugins/vis_default_editor/public/components/options/legend_size_settings.tsx index bbe47295c99e662..43d6b6d230b5db3 100644 --- a/src/plugins/vis_default_editor/public/components/options/legend_size_settings.tsx +++ b/src/plugins/vis_default_editor/public/components/options/legend_size_settings.tsx @@ -71,7 +71,7 @@ export const LegendSizeSettings = ({ }, [isVerticalLegend, legendSize, onLegendSizeChange]); const onLegendSizeOptionChange = useCallback( - (option) => onLegendSizeChange(option === DEFAULT_LEGEND_SIZE ? undefined : option), + (size: LegendSize) => onLegendSizeChange(size === DEFAULT_LEGEND_SIZE ? undefined : size), [onLegendSizeChange] ); diff --git a/src/plugins/vis_default_editor/public/components/options/number_input.tsx b/src/plugins/vis_default_editor/public/components/options/number_input.tsx index 604a5896308ae2a..643d4ad60890e8e 100644 --- a/src/plugins/vis_default_editor/public/components/options/number_input.tsx +++ b/src/plugins/vis_default_editor/public/components/options/number_input.tsx @@ -62,4 +62,4 @@ function NumberInputOption({ ); } -export { NumberInputOption }; +export { NumberInputOption, type NumberInputOptionProps }; diff --git a/src/plugins/vis_default_editor/public/components/sidebar/controls.tsx b/src/plugins/vis_default_editor/public/components/sidebar/controls.tsx index 678a6c2edaf97a3..4b14ade5ef43107 100644 --- a/src/plugins/vis_default_editor/public/components/sidebar/controls.tsx +++ b/src/plugins/vis_default_editor/public/components/sidebar/controls.tsx @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import React, { useCallback, useState } from 'react'; +import React, { SetStateAction, useCallback, useState } from 'react'; import { EuiFlexGroup, EuiFlexItem, @@ -42,7 +42,7 @@ function DefaultEditorControls({ const { enableAutoApply } = vis.type.editorConfig; const [autoApplyEnabled, setAutoApplyEnabled] = useState(false); const toggleAutoApply = useCallback( - (nextAutoApplyEnabled) => setAutoApplyEnabled(nextAutoApplyEnabled), + (nextAutoApplyEnabled: SetStateAction) => setAutoApplyEnabled(nextAutoApplyEnabled), [] ); const onClickDiscard = useCallback(() => dispatch(discardChanges(vis)), [dispatch, vis]); diff --git a/src/plugins/vis_default_editor/public/index.ts b/src/plugins/vis_default_editor/public/index.ts index ffa5e5f88e661d3..1e251976d30a991 100644 --- a/src/plugins/vis_default_editor/public/index.ts +++ b/src/plugins/vis_default_editor/public/index.ts @@ -27,6 +27,7 @@ export { ColorRanges, BasicOptions, type SetColorRangeValue, + type NumberInputOptionProps, type SetColorSchemaOptionsValue, } from './components/options'; export type { RangeValues } from './components/controls/ranges'; diff --git a/src/plugins/vis_types/heatmap/public/editor/components/heatmap.tsx b/src/plugins/vis_types/heatmap/public/editor/components/heatmap.tsx index 14f09472df752f7..de483e34f7b1143 100644 --- a/src/plugins/vis_types/heatmap/public/editor/components/heatmap.tsx +++ b/src/plugins/vis_types/heatmap/public/editor/components/heatmap.tsx @@ -69,7 +69,10 @@ const HeatmapOptions = (props: HeatmapOptionsProps) => { } }, [stateParams]); - const handleLegendSizeChange = useCallback((size) => setValue('legendSize', size), [setValue]); + const handleLegendSizeChange = useCallback( + (size?: LegendSize) => setValue('legendSize', size), + [setValue] + ); return ( <> diff --git a/src/plugins/vis_types/heatmap/public/editor/components/labels_panel.tsx b/src/plugins/vis_types/heatmap/public/editor/components/labels_panel.tsx index 0b16e538fb48194..0134d8d056ec8e0 100644 --- a/src/plugins/vis_types/heatmap/public/editor/components/labels_panel.tsx +++ b/src/plugins/vis_types/heatmap/public/editor/components/labels_panel.tsx @@ -47,7 +47,10 @@ function LabelsPanel({ valueAxis, setValue, isNewLibrary }: LabelsPanelProps) { [setValueAxisLabels] ); - const setColor = useCallback((value) => setValueAxisLabels('color', value), [setValueAxisLabels]); + const setColor = useCallback( + (value: string) => setValueAxisLabels('color', value), + [setValueAxisLabels] + ); return ( diff --git a/src/plugins/vis_types/pie/public/editor/components/pie.tsx b/src/plugins/vis_types/pie/public/editor/components/pie.tsx index b1369e4e909299d..8b5a6bdd7c490a4 100644 --- a/src/plugins/vis_types/pie/public/editor/components/pie.tsx +++ b/src/plugins/vis_types/pie/public/editor/components/pie.tsx @@ -117,14 +117,17 @@ const PieOptions = (props: PieOptionsProps) => { }, [props.palettes]); const handleEmptySizeRatioChange = useCallback( - (sizeId) => { + (sizeId: string) => { const emptySizeRatio = emptySizeRatioOptions.find(({ id }) => id === sizeId)?.value; setValue('emptySizeRatio', emptySizeRatio); }, [setValue] ); - const handleLegendSizeChange = useCallback((size) => setValue('legendSize', size), [setValue]); + const handleLegendSizeChange = useCallback( + (size?: LegendSize) => setValue('legendSize', size), + [setValue] + ); const handleLegendDisplayChange = useCallback( (name: keyof PartitionVisParams, show: boolean) => { diff --git a/src/plugins/vis_types/timeseries/public/application/components/annotations_editor.tsx b/src/plugins/vis_types/timeseries/public/application/components/annotations_editor.tsx index b1c4adae3859bd7..9af19c8dc18f7b4 100644 --- a/src/plugins/vis_types/timeseries/public/application/components/annotations_editor.tsx +++ b/src/plugins/vis_types/timeseries/public/application/components/annotations_editor.tsx @@ -74,7 +74,7 @@ export const AnnotationsEditor = (props: AnnotationsEditorProps) => { ); const handleDelete = useCallback( - (annotation) => () => + (annotation: Annotation) => () => collectionActions.handleDelete(getCollectionActionsProps(props), annotation), [props] ); diff --git a/src/plugins/vis_types/vega/public/vega_inspector/components/inspector_data_grid.tsx b/src/plugins/vis_types/vega/public/vega_inspector/components/inspector_data_grid.tsx index 688247c5eb6d59b..e9341ec5a4a2ed4 100644 --- a/src/plugins/vis_types/vega/public/vega_inspector/components/inspector_data_grid.tsx +++ b/src/plugins/vis_types/vega/public/vega_inspector/components/inspector_data_grid.tsx @@ -19,12 +19,12 @@ interface InspectorDataGridProps extends VegaRuntimeData { export const InspectorDataGrid = ({ columns, data, dataGridAriaLabel }: InspectorDataGridProps) => { const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: DEFAULT_PAGE_SIZE }); const onChangeItemsPerPage = useCallback( - (pageSize) => setPagination((p) => ({ ...p, pageSize, pageIndex: 0 })), + (pageSize: number) => setPagination((p) => ({ ...p, pageSize, pageIndex: 0 })), [setPagination] ); const onChangePage = useCallback( - (pageIndex) => setPagination((p) => ({ ...p, pageIndex })), + (pageIndex: number) => setPagination((p) => ({ ...p, pageIndex })), [setPagination] ); diff --git a/src/plugins/vis_types/xy/public/editor/components/options/metrics_axes/chart_options.tsx b/src/plugins/vis_types/xy/public/editor/components/options/metrics_axes/chart_options.tsx index 1d609187f83c537..8611f17d585ddd1 100644 --- a/src/plugins/vis_types/xy/public/editor/components/options/metrics_axes/chart_options.tsx +++ b/src/plugins/vis_types/xy/public/editor/components/options/metrics_axes/chart_options.tsx @@ -47,7 +47,7 @@ function ChartOptions({ ); const setValueAxis = useCallback( - (paramName, value) => { + (paramName: 'valueAxis', value: string) => { changeValueAxis(index, paramName, value); }, [changeValueAxis, index] diff --git a/src/plugins/vis_types/xy/public/editor/components/options/metrics_axes/y_extents.tsx b/src/plugins/vis_types/xy/public/editor/components/options/metrics_axes/y_extents.tsx index 5b37ae97a196696..e8baea3ed4da17b 100644 --- a/src/plugins/vis_types/xy/public/editor/components/options/metrics_axes/y_extents.tsx +++ b/src/plugins/vis_types/xy/public/editor/components/options/metrics_axes/y_extents.tsx @@ -10,7 +10,7 @@ import React, { useEffect, useCallback } from 'react'; import { EuiFlexGroup, EuiFlexItem, EuiFormRow } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { NumberInputOption } from '@kbn/vis-default-editor-plugin/public'; +import { NumberInputOption, NumberInputOptionProps } from '@kbn/vis-default-editor-plugin/public'; import { Scale, ScaleType } from '../../../../types'; import { SetScale } from './value_axis_options'; @@ -54,7 +54,7 @@ function YExtents({ scale, setScale, setMultipleValidity }: YExtentsProps) { const isValid = !errors.length; - const setExtents = useCallback( + const setExtents = useCallback['setValue']>( (paramName, value) => { setScale(paramName, value === '' ? null : value); }, diff --git a/src/plugins/vis_types/xy/public/editor/components/options/point_series/point_series.tsx b/src/plugins/vis_types/xy/public/editor/components/options/point_series/point_series.tsx index f38471d2ae24e8b..fe997ead61eb50d 100644 --- a/src/plugins/vis_types/xy/public/editor/components/options/point_series/point_series.tsx +++ b/src/plugins/vis_types/xy/public/editor/components/options/point_series/point_series.tsx @@ -46,7 +46,10 @@ export function PointSeriesOptions(props: ValidationVisOptionsProps) const [hadAutoLegendSize] = useState(() => legendSize === LegendSize.AUTO); - const handleLegendSizeChange = useCallback((size) => setValue('legendSize', size), [setValue]); + const handleLegendSizeChange = useCallback( + (size?: LegendSize) => setValue('legendSize', size), + [setValue] + ); return ( <> diff --git a/src/plugins/visualizations/common/content_management/v1/types.ts b/src/plugins/visualizations/common/content_management/v1/types.ts index 80159165d97d9ce..02ab5f762051f4c 100644 --- a/src/plugins/visualizations/common/content_management/v1/types.ts +++ b/src/plugins/visualizations/common/content_management/v1/types.ts @@ -18,7 +18,7 @@ import { CreateResult, UpdateResult, } from '@kbn/content-management-plugin/common'; -import { ContentManagementCrudTypes } from '@kbn/content-management-utils'; +import type { ContentManagementCrudTypes } from '@kbn/content-management-utils'; import { VisualizationContentType } from '../types'; diff --git a/src/plugins/visualizations/public/vis_types/vis_type_alias_registry.ts b/src/plugins/visualizations/public/vis_types/vis_type_alias_registry.ts index f736455faf04678..1144f4519490cc2 100644 --- a/src/plugins/visualizations/public/vis_types/vis_type_alias_registry.ts +++ b/src/plugins/visualizations/public/vis_types/vis_type_alias_registry.ts @@ -8,7 +8,7 @@ import { SearchQuery } from '@kbn/content-management-plugin/common'; import { ContentManagementPublicStart } from '@kbn/content-management-plugin/public'; -import { +import type { ContentManagementCrudTypes, SavedObjectCreateOptions, SavedObjectUpdateOptions, diff --git a/test/plugin_functional/plugins/kbn_tp_custom_visualizations/public/self_changing_vis/self_changing_editor.tsx b/test/plugin_functional/plugins/kbn_tp_custom_visualizations/public/self_changing_vis/self_changing_editor.tsx index 2ffe694e37b5e07..7b92509ed53cfcb 100644 --- a/test/plugin_functional/plugins/kbn_tp_custom_visualizations/public/self_changing_vis/self_changing_editor.tsx +++ b/test/plugin_functional/plugins/kbn_tp_custom_visualizations/public/self_changing_vis/self_changing_editor.tsx @@ -16,7 +16,7 @@ interface CounterParams { } export class SelfChangingEditor extends React.Component> { - onCounterChange = (ev: any) => { + onCounterChange = (ev: React.ChangeEvent) => { this.props.setValue('counter', parseInt(ev.target.value, 10)); }; diff --git a/x-pack/examples/testing_embedded_lens/public/app.tsx b/x-pack/examples/testing_embedded_lens/public/app.tsx index c3d4d103a9a4ecd..9aa6a40fe20cf15 100644 --- a/x-pack/examples/testing_embedded_lens/public/app.tsx +++ b/x-pack/examples/testing_embedded_lens/public/app.tsx @@ -470,7 +470,7 @@ export const App = (props: { const currentSO = useRef(initialAttributes); const [currentValid, saveValidSO] = useState(initialAttributes); const switchChartPreset = useCallback( - (newIndex) => { + (newIndex: number) => { const newChart = charts[newIndex]; const newAttributes = JSON.stringify(newChart.attributes, null, 2); currentSO.current = newAttributes; @@ -694,7 +694,7 @@ export const App = (props: { ({ value: i, text: id }))} value={undefined} - onChange={(e) => switchChartPreset(Number(e.target.value))} + onChange={(e) => switchChartPreset(+e.target.value)} aria-label="Load from a preset" prepend={'Load preset'} /> diff --git a/x-pack/packages/kbn-elastic-assistant/impl/connectorland/models/model_selector/model_selector.tsx b/x-pack/packages/kbn-elastic-assistant/impl/connectorland/models/model_selector/model_selector.tsx index 01f4049fb67b3c4..b23f85519a08bda 100644 --- a/x-pack/packages/kbn-elastic-assistant/impl/connectorland/models/model_selector/model_selector.tsx +++ b/x-pack/packages/kbn-elastic-assistant/impl/connectorland/models/model_selector/model_selector.tsx @@ -6,7 +6,7 @@ */ import React, { useCallback, useMemo, useState } from 'react'; -import { EuiComboBox, EuiComboBoxOptionOption } from '@elastic/eui'; +import { EuiComboBox, EuiComboBoxOptionOption, EuiComboBoxProps } from '@elastic/eui'; import * as i18n from './translations'; @@ -49,7 +49,9 @@ export const ModelSelector: React.FC = React.memo( ); // Callback for when user types to create a new model - const onCreateOption = useCallback( + const onCreateOption = useCallback< + NonNullable['onCreateOption']> + >( (searchValue, flattenedOptions = []) => { if (!searchValue || !searchValue.trim().toLowerCase()) { return; @@ -58,8 +60,7 @@ export const ModelSelector: React.FC = React.memo( const normalizedSearchValue = searchValue.trim().toLowerCase(); const optionExists = flattenedOptions.findIndex( - (option: EuiComboBoxOptionOption) => - option.label.trim().toLowerCase() === normalizedSearchValue + (option) => option.label.trim().toLowerCase() === normalizedSearchValue ) !== -1; const newOption = { diff --git a/x-pack/packages/ml/inference_integration_flyout/components/flyout_layout.tsx b/x-pack/packages/ml/inference_integration_flyout/components/flyout_layout.tsx index a859b1d95103f24..22c904e63561e26 100644 --- a/x-pack/packages/ml/inference_integration_flyout/components/flyout_layout.tsx +++ b/x-pack/packages/ml/inference_integration_flyout/components/flyout_layout.tsx @@ -51,7 +51,7 @@ export const InferenceFlyout: React.FC = ({ }, [inferenceEndpointError]); const onChangingInferenceEndpoint = useCallback( - (value) => { + (value: any) => { setInferenceEndpointId(value); onInferenceEndpointChange(value); }, diff --git a/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/log_rate_analysis_results_table.tsx b/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/log_rate_analysis_results_table.tsx index 38cf611b4bdd1b6..f6f3ea0f4d9db9f 100644 --- a/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/log_rate_analysis_results_table.tsx +++ b/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/log_rate_analysis_results_table.tsx @@ -104,7 +104,7 @@ export const LogRateAnalysisResultsTable: FC = groupFilter !== undefined ); - const onChange = useCallback((tableSettings) => { + const onChange = useCallback((tableSettings: any) => { if (tableSettings.page) { const { index, size } = tableSettings.page; setPageIndex(index); diff --git a/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/log_rate_analysis_results_table_groups.tsx b/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/log_rate_analysis_results_table_groups.tsx index 905ac53b149cacf..d69a0fec7200fec 100644 --- a/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/log_rate_analysis_results_table_groups.tsx +++ b/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/log_rate_analysis_results_table_groups.tsx @@ -247,7 +247,7 @@ export const LogRateAnalysisResultsGroupsTable: FC { + const onChange = useCallback((tableSettings: any) => { if (tableSettings.page) { const { index, size } = tableSettings.page; setPageIndex(index); diff --git a/x-pack/plugins/alerting/public/pages/maintenance_windows/components/create_maintenance_windows_form.tsx b/x-pack/plugins/alerting/public/pages/maintenance_windows/components/create_maintenance_windows_form.tsx index cd69f972c675aa9..e74f3117d55f965 100644 --- a/x-pack/plugins/alerting/public/pages/maintenance_windows/components/create_maintenance_windows_form.tsx +++ b/x-pack/plugins/alerting/public/pages/maintenance_windows/components/create_maintenance_windows_form.tsx @@ -9,6 +9,7 @@ import moment from 'moment'; import { FIELD_TYPES, Form, + FormSubmitHandler, getUseField, useForm, useFormData, @@ -136,7 +137,7 @@ export const CreateMaintenanceWindowForm = React.memo>( async (formData, isValid) => { if (!isValid || scopedQueryErrors.length !== 0) { return; diff --git a/x-pack/plugins/alerting/public/pages/maintenance_windows/components/maintenance_windows_list.tsx b/x-pack/plugins/alerting/public/pages/maintenance_windows/components/maintenance_windows_list.tsx index dd396057e3724f5..7e474859981ef36 100644 --- a/x-pack/plugins/alerting/public/pages/maintenance_windows/components/maintenance_windows_list.tsx +++ b/x-pack/plugins/alerting/public/pages/maintenance_windows/components/maintenance_windows_list.tsx @@ -29,7 +29,7 @@ import { MaintenanceWindow, } from '../../../../common'; import { StatusFilter } from './status_filter'; -import { TableActionsPopover } from './table_actions_popover'; +import { TableActionsPopover, TableActionsPopoverProps } from './table_actions_popover'; import { useFinishMaintenanceWindow } from '../../../hooks/use_finish_maintenance_window'; import { useArchiveMaintenanceWindow } from '../../../hooks/use_archive_maintenance_window'; import { useFinishAndArchiveMaintenanceWindow } from '../../../hooks/use_finish_and_archive_maintenance_window'; @@ -115,13 +115,13 @@ export const MaintenanceWindowsList = React.memo( }; const { euiTheme } = useEuiTheme(); const { navigateToEditMaintenanceWindows } = useEditMaintenanceWindowsNavigation(); - const onEdit = useCallback( + const onEdit = useCallback( (id) => navigateToEditMaintenanceWindows(id), [navigateToEditMaintenanceWindows] ); const { mutate: finishMaintenanceWindow, isLoading: isLoadingFinish } = useFinishMaintenanceWindow(); - const onCancel = useCallback( + const onCancel = useCallback( (id) => finishMaintenanceWindow(id, { onSuccess: () => refreshData() }), [finishMaintenanceWindow, refreshData] ); diff --git a/x-pack/plugins/alerting/public/pages/maintenance_windows/components/table_actions_popover.tsx b/x-pack/plugins/alerting/public/pages/maintenance_windows/components/table_actions_popover.tsx index ffe0509c1fd322e..c91f518f6976f2a 100644 --- a/x-pack/plugins/alerting/public/pages/maintenance_windows/components/table_actions_popover.tsx +++ b/x-pack/plugins/alerting/public/pages/maintenance_windows/components/table_actions_popover.tsx @@ -18,7 +18,7 @@ import { import * as i18n from '../translations'; import { MaintenanceWindowStatus } from '../../../../common'; -interface TableActionsPopoverProps { +export interface TableActionsPopoverProps { id: string; status: MaintenanceWindowStatus; onEdit: (id: string) => void; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/vis_dimension.tsx b/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/vis_dimension.tsx index 89c3cf35a7c3661..488abfcc80e0aec 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/vis_dimension.tsx +++ b/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/vis_dimension.tsx @@ -6,7 +6,7 @@ */ import React, { useState, useEffect, useCallback } from 'react'; -import { EuiButton, EuiFlexGroup, EuiFlexItem, EuiSelect } from '@elastic/eui'; +import { EuiButton, EuiFlexGroup, EuiFlexItem, EuiSelect, EuiSelectProps } from '@elastic/eui'; import { DatatableColumn, ExpressionAstExpression } from '@kbn/expressions-plugin/common'; import { templateFromReactComponent } from '../../../public/lib/template_from_react_component'; import { ArgumentStrings } from '../../../i18n'; @@ -15,7 +15,7 @@ import { ResolvedArgProps, ResolvedColumns } from '../../../public/expression_ty const { VisDimension: strings } = ArgumentStrings; type VisDimensionArgInputProps = { - onValueChange: (value: ExpressionAstExpression) => void; + onValueChange: (value: ExpressionAstExpression | string) => void; argValue: ExpressionAstExpression; typeInstance: { options?: { @@ -30,14 +30,14 @@ const VisDimensionArgInput: React.FC = ({ onValueChange, resolved: { columns }, }) => { - const [value, setValue] = useState(argValue); + const [value, setValue] = useState(argValue); const confirm = typeInstance?.options?.confirm; useEffect(() => { setValue(argValue); }, [argValue]); - const onChange = useCallback( + const onChange = useCallback>( (ev) => { const onChangeFn = confirm ? setValue : onValueChange; const astObj: ExpressionAstExpression = { diff --git a/x-pack/plugins/canvas/public/components/arg_form/arg_template_form.tsx b/x-pack/plugins/canvas/public/components/arg_form/arg_template_form.tsx index 053cda9dd03f396..f2abceff1f67fb7 100644 --- a/x-pack/plugins/canvas/public/components/arg_form/arg_template_form.tsx +++ b/x-pack/plugins/canvas/public/components/arg_form/arg_template_form.tsx @@ -59,14 +59,18 @@ const ArgTemplateFormComponent: React.FunctionComponent = mountedArgumentRef.current = undefined; }); - const onMount = useCallback((ref) => { - if (!mountedArgumentRef.current && ref) { - mountedArgumentRef.current = ref; - } - }, []); + const onMount = useCallback( + (ref: UpdatePropsRef | null) => { + if (!mountedArgumentRef.current && ref) { + mountedArgumentRef.current = ref; + } + }, + [] + ); const renderTemplate = useCallback( - (domNode) => template && template(domNode, argumentProps, updatedHandlers, onMount), + (domNode: HTMLElement) => + template && template(domNode, argumentProps, updatedHandlers, onMount), [argumentProps, onMount, template, updatedHandlers] ); diff --git a/x-pack/plugins/canvas/public/components/var_config/var_value_field.tsx b/x-pack/plugins/canvas/public/components/var_config/var_value_field.tsx index 24b9a82e32e5c12..6b91497fa0f64f7 100644 --- a/x-pack/plugins/canvas/public/components/var_config/var_value_field.tsx +++ b/x-pack/plugins/canvas/public/components/var_config/var_value_field.tsx @@ -48,7 +48,7 @@ export const VarValueField: FC = ({ type, value, onChange }) => { ]; const onNumberChange = useCallback( - (e) => { + (e: React.ChangeEvent) => { const floatVal = parseFloat(e.target.value); const varValue = isNaN(floatVal) ? '' : floatVal; onChange(varValue); diff --git a/x-pack/plugins/canvas/public/components/workpad/workpad.tsx b/x-pack/plugins/canvas/public/components/workpad/workpad.tsx index 7cc077203c73723..1e604a6deb8508a 100644 --- a/x-pack/plugins/canvas/public/components/workpad/workpad.tsx +++ b/x-pack/plugins/canvas/public/components/workpad/workpad.tsx @@ -74,7 +74,7 @@ export const Workpad: FC = (props) => { ); const getAnimation = useCallback( - (pageNumber) => { + (pageNumber: number) => { if (!transition || !transition.name) { return null; } @@ -94,7 +94,7 @@ export const Workpad: FC = (props) => { const onTransitionEnd = useCallback(() => setTransition(null), [setTransition]); const setFullscreenWithEffect = useCallback( - (fullscreen) => { + (fullscreen: boolean) => { setFullscreen(fullscreen); if (fullscreen === true) { trackCanvasUiMetric( diff --git a/x-pack/plugins/canvas/public/components/workpad_color_picker/workpad_color_picker.component.tsx b/x-pack/plugins/canvas/public/components/workpad_color_picker/workpad_color_picker.component.tsx index c14e54d8e854951..64e0c259cd04829 100644 --- a/x-pack/plugins/canvas/public/components/workpad_color_picker/workpad_color_picker.component.tsx +++ b/x-pack/plugins/canvas/public/components/workpad_color_picker/workpad_color_picker.component.tsx @@ -21,8 +21,11 @@ const strings = { export const WorkpadColorPicker = (props: Props) => { const dispatch = useDispatch(); - const onAddColor = useCallback((payload) => dispatch(addColor(payload)), [dispatch]); - const onRemoveColor = useCallback((payload) => dispatch(removeColor(payload)), [dispatch]); + const onAddColor = useCallback((payload: string) => dispatch(addColor(payload)), [dispatch]); + const onRemoveColor = useCallback( + (payload: string) => dispatch(removeColor(payload)), + [dispatch] + ); const colors = useSelector(getWorkpadColors); return ( diff --git a/x-pack/plugins/canvas/public/expression_types/datasource.tsx b/x-pack/plugins/canvas/public/expression_types/datasource.tsx index a7d5cd4e7a2b479..f7bd89200cfdae3 100644 --- a/x-pack/plugins/canvas/public/expression_types/datasource.tsx +++ b/x-pack/plugins/canvas/public/expression_types/datasource.tsx @@ -61,12 +61,12 @@ const DatasourceWrapperComponent: React.FunctionComponent { + const onMount = useCallback((ref: UpdatePropsRef | null) => { datasourceRef.current = ref ?? undefined; }, []); const callRenderFn = useCallback( - (domNode) => { + (domNode: HTMLDivElement) => { const { template } = spec; if (!template) { return null; diff --git a/x-pack/plugins/cases/public/components/actions/assignees/edit_assignees_selectable.tsx b/x-pack/plugins/cases/public/components/actions/assignees/edit_assignees_selectable.tsx index d3a4d9cbb06e172..0d4bd261647d18c 100644 --- a/x-pack/plugins/cases/public/components/actions/assignees/edit_assignees_selectable.tsx +++ b/x-pack/plugins/cases/public/components/actions/assignees/edit_assignees_selectable.tsx @@ -198,7 +198,7 @@ const EditAssigneesSelectableComponent: React.FC = ({ ); const onSearchChange = useCallback( - (value) => { + (value: string) => { setSearchValue(value); onContentChange(value); }, diff --git a/x-pack/plugins/cases/public/components/actions/tags/edit_tags_selectable.tsx b/x-pack/plugins/cases/public/components/actions/tags/edit_tags_selectable.tsx index 17cf9939f8145f3..947228ce9b136df 100644 --- a/x-pack/plugins/cases/public/components/actions/tags/edit_tags_selectable.tsx +++ b/x-pack/plugins/cases/public/components/actions/tags/edit_tags_selectable.tsx @@ -120,10 +120,6 @@ const EditTagsSelectableComponent: React.FC = ({ [options, searchValue, state.items] ); - const onSearchChange = useCallback((value) => { - setSearchValue(value); - }, []); - return ( = ({ placeholder: i18n.SEARCH_PLACEHOLDER, isLoading, isClearable: !isLoading, - onChange: onSearchChange, + onChange: setSearchValue, value: searchValue, 'data-test-subj': 'cases-actions-tags-edit-selectable-search-input', }} diff --git a/x-pack/plugins/cases/public/components/add_comment/index.tsx b/x-pack/plugins/cases/public/components/add_comment/index.tsx index 009594df200f7ac..c84f799b1c899bb 100644 --- a/x-pack/plugins/cases/public/components/add_comment/index.tsx +++ b/x-pack/plugins/cases/public/components/add_comment/index.tsx @@ -26,7 +26,7 @@ import { import { AttachmentType } from '../../../common/types/domain'; import { useCreateAttachments } from '../../containers/use_create_attachments'; import type { CaseUI } from '../../containers/types'; -import type { EuiMarkdownEditorRef } from '../markdown_editor'; +import type { MarkdownEditorRef } from '../markdown_editor'; import { MarkdownEditorForm } from '../markdown_editor'; import { getMarkdownEditorStorageKey } from '../markdown_editor/utils'; import { removeItemFromSessionStorage } from '../utils'; @@ -45,7 +45,7 @@ const initialCommentValue: AddCommentFormSchema = { export interface AddCommentRefObject { addQuote: (quote: string) => void; setComment: (newComment: string) => void; - editor: EuiMarkdownEditorRef | null; + editor: MarkdownEditorRef | null; } /* eslint-disable react/no-unused-prop-types */ @@ -65,7 +65,7 @@ export const AddComment = React.memo( { id, caseId, onCommentPosted, onCommentSaving, showLoading = true, statusActionButton }, ref ) => { - const editorRef = useRef(null); + const editorRef = useRef(null); const [focusOnContext, setFocusOnContext] = useState(false); const { permissions, owner } = useCasesContext(); const { isLoading, mutate: createAttachments } = useCreateAttachments(); @@ -85,7 +85,7 @@ export const AddComment = React.memo( const { setFieldValue, reset, submit } = form; const [{ comment }] = useFormData<{ comment: string }>({ form, watch: [fieldName] }); - const addQuote = useCallback( + const addQuote = useCallback( (quote) => { const addCarrots = quote.replace(new RegExp('\r?\n', 'g'), '\n> '); const val = `> ${addCarrots} \n\n`; @@ -95,7 +95,7 @@ export const AddComment = React.memo( [comment, setFieldValue] ); - const setComment = useCallback( + const setComment = useCallback( (newComment) => { setFieldValue(fieldName, newComment); }, diff --git a/x-pack/plugins/cases/public/components/all_cases/nav_buttons.tsx b/x-pack/plugins/cases/public/components/all_cases/nav_buttons.tsx index 29b0607ec62aff4..310340f0366eb57 100644 --- a/x-pack/plugins/cases/public/components/all_cases/nav_buttons.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/nav_buttons.tsx @@ -27,7 +27,7 @@ export const NavButtons: FunctionComponent = ({ actionsErrors }) => { const { getCreateCaseUrl, navigateToCreateCase } = useCreateCaseNavigation(); const { euiTheme } = useEuiTheme(); const navigateToCreateCaseClick = useCallback( - (e) => { + (e: React.SyntheticEvent) => { e.preventDefault(); navigateToCreateCase(); }, diff --git a/x-pack/plugins/cases/public/components/all_cases/search.tsx b/x-pack/plugins/cases/public/components/all_cases/search.tsx index 265c42470cdbded..542ebf9e0c51d95 100644 --- a/x-pack/plugins/cases/public/components/all_cases/search.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/search.tsx @@ -22,7 +22,7 @@ const TableSearchComponent: React.FC = ({ const [search, setSearch] = useState(filterOptionsSearch); const onSearch = useCallback( - (newSearch) => { + (newSearch: string) => { const trimSearch = newSearch.trim(); setSearch(trimSearch); onFilterOptionsChange({ search: trimSearch }); diff --git a/x-pack/plugins/cases/public/components/all_cases/table.tsx b/x-pack/plugins/cases/public/components/all_cases/table.tsx index c2b429f4789eb0b..c95059660b3e44a 100644 --- a/x-pack/plugins/cases/public/components/all_cases/table.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/table.tsx @@ -59,7 +59,7 @@ export const CasesTable: FunctionComponent = ({ const { getCreateCaseUrl, navigateToCreateCase } = useCreateCaseNavigation(); const { euiTheme } = useEuiTheme(); const navigateToCreateCaseClick = useCallback( - (ev) => { + (ev: React.SyntheticEvent) => { ev.preventDefault(); if (goToCreateCase != null) { goToCreateCase(); diff --git a/x-pack/plugins/cases/public/components/app/routes.tsx b/x-pack/plugins/cases/public/components/app/routes.tsx index 501cd665ff24b87..ee2c82777dbf6b6 100644 --- a/x-pack/plugins/cases/public/components/app/routes.tsx +++ b/x-pack/plugins/cases/public/components/app/routes.tsx @@ -28,6 +28,7 @@ import { NoPrivilegesPage } from '../no_privileges'; import * as i18n from './translations'; import { useReadonlyHeader } from './use_readonly_header'; import type { CaseViewProps } from '../case_view/types'; +import type { CreateCaseFormProps } from '../create/form'; const CaseViewLazy: React.FC = lazy(() => import('../case_view')); @@ -45,7 +46,7 @@ const CasesRoutesComponent: React.FC = ({ const { navigateToCaseView } = useCaseViewNavigation(); useReadonlyHeader(); - const onCreateCaseSuccess = useCallback( + const onCreateCaseSuccess: CreateCaseFormProps['onSuccess'] = useCallback( async ({ id }) => navigateToCaseView({ detailName: id }), [navigateToCaseView] ); diff --git a/x-pack/plugins/cases/public/components/case_view/case_view_page.tsx b/x-pack/plugins/cases/public/components/case_view/case_view_page.tsx index adc2b41f6ce6a8d..add85202d0e551d 100644 --- a/x-pack/plugins/cases/public/components/case_view/case_view_page.tsx +++ b/x-pack/plugins/cases/public/components/case_view/case_view_page.tsx @@ -73,7 +73,7 @@ export const CaseViewPage = React.memo( }, [isLoading, refreshRef, refreshCaseViewPage]); const onSubmitTitle = useCallback( - (newTitle) => + (newTitle: string) => onUpdateField({ key: 'title', value: newTitle, diff --git a/x-pack/plugins/cases/public/components/case_view/components/case_view_activity.tsx b/x-pack/plugins/cases/public/components/case_view/components/case_view_activity.tsx index d0e5cefa458a423..6e945ef83627253 100644 --- a/x-pack/plugins/cases/public/components/case_view/components/case_view_activity.tsx +++ b/x-pack/plugins/cases/public/components/case_view/components/case_view_activity.tsx @@ -25,6 +25,7 @@ import { useGetSupportedActionConnectors } from '../../../containers/configure/u import type { CaseSeverity, CaseStatuses } from '../../../../common/types/domain'; import type { CaseUICustomField, UseFetchAlertData } from '../../../../common/ui/types'; import type { CaseUI } from '../../../../common'; +import type { EditConnectorProps } from '../../edit_connector'; import { EditConnector } from '../../edit_connector'; import type { CasesNavigation } from '../../links'; import { StatusActionButton } from '../../status/button'; @@ -115,12 +116,12 @@ export const CaseViewActivity = ({ ); const onSubmitTags = useCallback( - (newTags) => onUpdateField({ key: 'tags', value: newTags }), + (newTags: string[]) => onUpdateField({ key: 'tags', value: newTags }), [onUpdateField] ); const onSubmitCategory = useCallback( - (newCategory) => onUpdateField({ key: 'category', value: newCategory }), + (newCategory: string | null) => onUpdateField({ key: 'category', value: newCategory }), [onUpdateField] ); @@ -142,7 +143,7 @@ export const CaseViewActivity = ({ const { isLoading: isLoadingAllAvailableConnectors, data: supportedActionConnectors } = useGetSupportedActionConnectors(); - const onSubmitConnector = useCallback( + const onSubmitConnector = useCallback( (connector) => { onUpdateField({ key: 'connector', diff --git a/x-pack/plugins/cases/public/components/case_view/components/case_view_files.tsx b/x-pack/plugins/cases/public/components/case_view/components/case_view_files.tsx index 85cd4685a41fb1a..25f6929fbb81b19 100644 --- a/x-pack/plugins/cases/public/components/case_view/components/case_view_files.tsx +++ b/x-pack/plugins/cases/public/components/case_view/components/case_view_files.tsx @@ -57,7 +57,7 @@ export const CaseViewFiles = ({ caseData }: CaseViewFilesProps) => { ); const onSearchChange = useCallback( - (newSearch) => { + (newSearch: string) => { const trimSearch = newSearch.trim(); if (!isEqual(trimSearch, filteringOptions.searchTerm)) { setFilteringOptions({ diff --git a/x-pack/plugins/cases/public/components/case_view/components/custom_fields.tsx b/x-pack/plugins/cases/public/components/case_view/components/custom_fields.tsx index 32d03bac8dc8e04..c30e2b1767eede4 100644 --- a/x-pack/plugins/cases/public/components/case_view/components/custom_fields.tsx +++ b/x-pack/plugins/cases/public/components/case_view/components/custom_fields.tsx @@ -33,7 +33,7 @@ const CustomFieldsComponent: React.FC = ({ ); const onSubmitCustomField = useCallback( - (customFieldToAdd) => { + (customFieldToAdd: CaseUICustomField) => { onSubmit(customFieldToAdd); }, [onSubmit] diff --git a/x-pack/plugins/cases/public/components/case_view/components/edit_category.tsx b/x-pack/plugins/cases/public/components/case_view/components/edit_category.tsx index f4992f96d98560d..460fa364bc4d713 100644 --- a/x-pack/plugins/cases/public/components/case_view/components/edit_category.tsx +++ b/x-pack/plugins/cases/public/components/case_view/components/edit_category.tsx @@ -28,7 +28,7 @@ import { RemovableItem } from '../../removable_item/removable_item'; export interface EditCategoryProps { isLoading: boolean; - onSubmit: (category?: string | null) => void; + onSubmit: (category: string | null) => void; category?: string | null; } diff --git a/x-pack/plugins/cases/public/components/description/index.tsx b/x-pack/plugins/cases/public/components/description/index.tsx index 78440cf9b7f1e10..6599bc3ef43cb5b 100644 --- a/x-pack/plugins/cases/public/components/description/index.tsx +++ b/x-pack/plugins/cases/public/components/description/index.tsx @@ -21,7 +21,7 @@ import { getMarkdownEditorStorageKey } from '../markdown_editor/utils'; import * as i18n from '../user_actions/translations'; import { useCasesContext } from '../cases_context/use_cases_context'; import { useLensDraftComment } from '../markdown_editor/plugins/lens/use_lens_draft_comment'; -import type { EditableMarkdownRefObject, EuiMarkdownEditorRef } from '../markdown_editor'; +import type { EditableMarkdownRefObject, MarkdownEditorRef } from '../markdown_editor'; import { EditableMarkdown, ScrollableMarkdown } from '../markdown_editor'; import type { CaseUI } from '../../containers/types'; import type { OnUpdateFields } from '../case_view/types'; @@ -30,7 +30,7 @@ import { schema } from './schema'; const DESCRIPTION_ID = 'description'; export interface DescriptionMarkdownRefObject extends EditableMarkdownRefObject { - editor: EuiMarkdownEditorRef | null; + editor: MarkdownEditorRef | null; } export interface DescriptionProps { caseData: CaseUI; diff --git a/x-pack/plugins/cases/public/components/files/add_file.tsx b/x-pack/plugins/cases/public/components/files/add_file.tsx index 449e9bf26992313..7b91879834a78c7 100644 --- a/x-pack/plugins/cases/public/components/files/add_file.tsx +++ b/x-pack/plugins/cases/public/components/files/add_file.tsx @@ -31,6 +31,7 @@ import { useCasesContext } from '../cases_context/use_cases_context'; import * as i18n from './translations'; import { useRefreshCaseViewPage } from '../case_view/use_on_refresh_case_view_page'; import { deleteFileAttachments } from '../../containers/api'; +import type { ServerError } from '../../types'; interface AddFileProps { caseId: string; @@ -47,7 +48,7 @@ const AddFileComponent: React.FC = ({ caseId }) => { const showModal = () => setIsModalVisible(true); const onError = useCallback( - (error) => { + (error: Error | ServerError) => { showErrorToast(error, { title: i18n.FAILED_UPLOAD, }); diff --git a/x-pack/plugins/cases/public/components/filter_popover/index.tsx b/x-pack/plugins/cases/public/components/filter_popover/index.tsx index 60b796476149920..142a8aac8833aa2 100644 --- a/x-pack/plugins/cases/public/components/filter_popover/index.tsx +++ b/x-pack/plugins/cases/public/components/filter_popover/index.tsx @@ -62,7 +62,7 @@ export const FilterPopoverComponent = ({ const setIsPopoverOpenCb = useCallback(() => setIsPopoverOpen(!isPopoverOpen), [isPopoverOpen]); const toggleSelectedGroupCb = useCallback( - (option) => onSelectedOptionsChanged(toggleSelectedGroup(option, selectedOptions)), + (option: string) => onSelectedOptionsChanged(toggleSelectedGroup(option, selectedOptions)), [selectedOptions, onSelectedOptionsChanged] ); diff --git a/x-pack/plugins/cases/public/components/header_page/index.tsx b/x-pack/plugins/cases/public/components/header_page/index.tsx index 60aa4a9160cf8ce..1901700fe428d5f 100644 --- a/x-pack/plugins/cases/public/components/header_page/index.tsx +++ b/x-pack/plugins/cases/public/components/header_page/index.tsx @@ -56,7 +56,7 @@ const HeaderPageComponent: React.FC = ({ const xsFontSize = useEuiFontSize('xs').fontSize; const navigateToAllCasesClick = useCallback( - (e) => { + (e: React.SyntheticEvent) => { if (e) { e.preventDefault(); } diff --git a/x-pack/plugins/cases/public/components/links/index.tsx b/x-pack/plugins/cases/public/components/links/index.tsx index f09a9f852a28f55..cc6e29da8008cc1 100644 --- a/x-pack/plugins/cases/public/components/links/index.tsx +++ b/x-pack/plugins/cases/public/components/links/index.tsx @@ -44,7 +44,7 @@ const CaseDetailsLinkComponent: React.FC = ({ }) => { const { getCaseViewUrl, navigateToCaseView } = useCaseViewNavigation(); const navigateToCaseViewClick = useCallback( - (ev) => { + (ev: React.SyntheticEvent) => { ev.preventDefault(); navigateToCaseView({ detailName }); }, @@ -83,7 +83,7 @@ const ConfigureCaseButtonComponent: React.FC = ({ const { getConfigureCasesUrl, navigateToConfigureCases } = useConfigureCasesNavigation(); const navigateToConfigureCasesClick = useCallback( - (e) => { + (e: React.SyntheticEvent) => { e.preventDefault(); navigateToConfigureCases(); }, diff --git a/x-pack/plugins/cases/public/components/markdown_editor/editable_markdown_renderer.tsx b/x-pack/plugins/cases/public/components/markdown_editor/editable_markdown_renderer.tsx index bd91d219ee8776d..0353c7491d00cf1 100644 --- a/x-pack/plugins/cases/public/components/markdown_editor/editable_markdown_renderer.tsx +++ b/x-pack/plugins/cases/public/components/markdown_editor/editable_markdown_renderer.tsx @@ -50,7 +50,7 @@ const EditableMarkDownRenderer = forwardRef< const { submit, setFieldValue, isValid: isFormValid } = form; const setComment = useCallback( - (newComment) => { + (newComment: string) => { setFieldValue(fieldName, newComment); }, [setFieldValue, fieldName] diff --git a/x-pack/plugins/cases/public/components/markdown_editor/plugins/lens/use_lens_draft_comment.ts b/x-pack/plugins/cases/public/components/markdown_editor/plugins/lens/use_lens_draft_comment.ts index 95e558ca1f79f22..23c4a66fa4e5873 100644 --- a/x-pack/plugins/cases/public/components/markdown_editor/plugins/lens/use_lens_draft_comment.ts +++ b/x-pack/plugins/cases/public/components/markdown_editor/plugins/lens/use_lens_draft_comment.ts @@ -11,6 +11,7 @@ import { first } from 'rxjs'; import { useKibana } from '../../../../common/lib/kibana'; import { DRAFT_COMMENT_STORAGE_ID } from './constants'; import { VISUALIZATION } from './translations'; +import type { MarkdownEditorRef } from '../../editor'; interface DraftComment { commentId: string; @@ -51,9 +52,11 @@ export const useLensDraftComment = () => { fetchDraftComment(); }, [currentAppId$, embeddable, storage]); - const openLensModal = useCallback(({ editorRef }) => { + const openLensModal = useCallback(({ editorRef }: { editorRef: MarkdownEditorRef }) => { if (editorRef && editorRef.textarea && editorRef.toolbar) { - const lensPluginButton = editorRef.toolbar?.querySelector(`[aria-label="${VISUALIZATION}"]`); + const lensPluginButton = editorRef.toolbar?.querySelector( + `[aria-label="${VISUALIZATION}"]` + ); if (lensPluginButton) { lensPluginButton.click(); } diff --git a/x-pack/plugins/cases/public/components/recent_cases/filters/index.tsx b/x-pack/plugins/cases/public/components/recent_cases/filters/index.tsx index 5478f5b918822fc..1d7c22eccb68f37 100644 --- a/x-pack/plugins/cases/public/components/recent_cases/filters/index.tsx +++ b/x-pack/plugins/cases/public/components/recent_cases/filters/index.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import type { EuiSelectOption } from '@elastic/eui'; +import type { EuiSelectOption, EuiSelectProps } from '@elastic/eui'; import { EuiSelect } from '@elastic/eui'; import React, { useCallback } from 'react'; @@ -50,7 +50,7 @@ export const RecentCasesFilters = React.memo<{ }; }); - const onChange = useCallback( + const onChange = useCallback>( (e) => { setFilterBy(e.target.value as FilterMode); }, diff --git a/x-pack/plugins/cases/public/components/recent_cases/index.tsx b/x-pack/plugins/cases/public/components/recent_cases/index.tsx index 28c632f843d7685..55df7a6c9ac43ee 100644 --- a/x-pack/plugins/cases/public/components/recent_cases/index.tsx +++ b/x-pack/plugins/cases/public/components/recent_cases/index.tsx @@ -48,7 +48,7 @@ const RecentCasesComponent = React.memo(({ maxCasesToShow }: RecentCasesProps) = useState('recentlyCreated'); const navigateToAllCasesClick = useCallback( - (e) => { + (e: React.SyntheticEvent) => { e.preventDefault(); navigateToAllCases(); }, diff --git a/x-pack/plugins/cases/public/components/recent_cases/no_cases/index.tsx b/x-pack/plugins/cases/public/components/recent_cases/no_cases/index.tsx index d284c99af76d082..5fc24e8655eefa7 100644 --- a/x-pack/plugins/cases/public/components/recent_cases/no_cases/index.tsx +++ b/x-pack/plugins/cases/public/components/recent_cases/no_cases/index.tsx @@ -23,7 +23,7 @@ const NoCasesComponent = ({ recentCasesFilterBy }: NoCasesComp) => { const { getCreateCaseUrl, navigateToCreateCase } = useCreateCaseNavigation(); const navigateToCreateCaseClick = useCallback( - (e) => { + (e: React.SyntheticEvent) => { e.preventDefault(); navigateToCreateCase(); }, diff --git a/x-pack/plugins/cases/public/components/use_create_case_modal/index.tsx b/x-pack/plugins/cases/public/components/use_create_case_modal/index.tsx index 92a24b615e38303..a83fa98836716f9 100644 --- a/x-pack/plugins/cases/public/components/use_create_case_modal/index.tsx +++ b/x-pack/plugins/cases/public/components/use_create_case_modal/index.tsx @@ -24,7 +24,7 @@ export const useCreateCaseModal = ({ onCaseCreated }: UseCreateCaseModalProps) = const closeModal = useCallback(() => setIsModalOpen(false), []); const openModal = useCallback(() => setIsModalOpen(true), []); const onSuccess = useCallback( - async (theCase) => { + async (theCase: CaseUI) => { onCaseCreated(theCase); closeModal(); }, diff --git a/x-pack/plugins/cases/public/components/use_push_to_service/callout/callout.tsx b/x-pack/plugins/cases/public/components/use_push_to_service/callout/callout.tsx index c94fbb826df4898..a3326b3cb90f42a 100644 --- a/x-pack/plugins/cases/public/components/use_push_to_service/callout/callout.tsx +++ b/x-pack/plugins/cases/public/components/use_push_to_service/callout/callout.tsx @@ -36,7 +36,7 @@ const CallOutComponent = ({ const { permissions } = useCasesContext(); const handleCallOut = useCallback( - (e) => handleButtonClick(e, id, type), + (e: React.MouseEvent) => handleButtonClick(e, id, type), [handleButtonClick, id, type] ); diff --git a/x-pack/plugins/cases/public/components/use_push_to_service/callout/index.tsx b/x-pack/plugins/cases/public/components/use_push_to_service/callout/index.tsx index 07f4ab2768c0bb1..f311044e835a269 100644 --- a/x-pack/plugins/cases/public/components/use_push_to_service/callout/index.tsx +++ b/x-pack/plugins/cases/public/components/use_push_to_service/callout/index.tsx @@ -36,7 +36,7 @@ const CaseCallOutComponent = ({ }: CaseCallOutProps) => { const { navigateToConfigureCases } = useConfigureCasesNavigation(); const handleCallOut = useCallback( - (e) => { + (e: React.SyntheticEvent) => { e.preventDefault(); // if theres connectors open dropdown editor // if no connectors, redirect to create case page diff --git a/x-pack/plugins/cases/public/components/user_actions/comment/alert_event.tsx b/x-pack/plugins/cases/public/components/user_actions/comment/alert_event.tsx index 94f9d290e37572e..42e5e6b9d442742 100644 --- a/x-pack/plugins/cases/public/components/user_actions/comment/alert_event.tsx +++ b/x-pack/plugins/cases/public/components/user_actions/comment/alert_event.tsx @@ -29,7 +29,7 @@ interface MultipleAlertsProps extends SingleAlertProps { const RuleLink: React.FC = memo( ({ onRuleDetailsClick, getRuleDetailsHref, ruleId, ruleName, loadingAlertData, actionId }) => { const onLinkClick = useCallback( - (ev) => { + (ev: React.MouseEvent) => { ev.preventDefault(); if (onRuleDetailsClick) onRuleDetailsClick(ruleId, ev); }, diff --git a/x-pack/plugins/cases/public/components/user_actions/comment/host_isolation_event.tsx b/x-pack/plugins/cases/public/components/user_actions/comment/host_isolation_event.tsx index a638c1a69b30e0c..66e7c65f8695bb9 100644 --- a/x-pack/plugins/cases/public/components/user_actions/comment/host_isolation_event.tsx +++ b/x-pack/plugins/cases/public/components/user_actions/comment/host_isolation_event.tsx @@ -31,7 +31,7 @@ const HostIsolationCommentEventComponent: React.FC = ({ const endpointDetailsHref = href ? href(endpoints[0].endpointId) : ''; const onLinkClick = useCallback( - (ev) => { + (ev: React.MouseEvent) => { ev.preventDefault(); if (onClick) onClick(endpoints[0].endpointId, ev); }, diff --git a/x-pack/plugins/cloud_defend/public/components/control_general_view_response/index.tsx b/x-pack/plugins/cloud_defend/public/components/control_general_view_response/index.tsx index af2d7c0fd1cdf2e..1c782973dd0ed7b 100644 --- a/x-pack/plugins/cloud_defend/public/components/control_general_view_response/index.tsx +++ b/x-pack/plugins/cloud_defend/public/components/control_general_view_response/index.tsx @@ -139,7 +139,7 @@ export const ControlGeneralViewResponse = ({ }, [closePopover, onDuplicate, response]); const onChangeMatches = useCallback( - (options) => { + (options: any) => { response.match = options.map((option: EuiComboBoxOptionOption) => option.value); onResponseChange(response, index); @@ -148,7 +148,7 @@ export const ControlGeneralViewResponse = ({ ); const onChangeExcludes = useCallback( - (options) => { + (options: any) => { response.exclude = options.map((option: EuiComboBoxOptionOption) => option.value); if (response.exclude?.length === 0) { diff --git a/x-pack/plugins/cloud_defend/public/components/control_general_view_selector/index.tsx b/x-pack/plugins/cloud_defend/public/components/control_general_view_selector/index.tsx index 4511aa71f056c5e..05820541fd02c06 100644 --- a/x-pack/plugins/cloud_defend/public/components/control_general_view_selector/index.tsx +++ b/x-pack/plugins/cloud_defend/public/components/control_general_view_selector/index.tsx @@ -24,6 +24,7 @@ import { EuiFlexItem, EuiText, EuiCheckbox, + EuiCheckboxProps, } from '@elastic/eui'; import { useStyles } from './styles'; import { @@ -69,7 +70,7 @@ const BooleanCondition = ({ onRemoveCondition, }: BooleanConditionProps) => { const value = selector[prop as keyof Selector] as boolean; - const onChange = useCallback( + const onChange = useCallback( (e) => { onChangeBooleanCondition(prop, e.target.checked); }, diff --git a/x-pack/plugins/cloud_defend/public/components/control_yaml_view/index.tsx b/x-pack/plugins/cloud_defend/public/components/control_yaml_view/index.tsx index 4dc47b8b5263fc6..6d1262afa135bd3 100644 --- a/x-pack/plugins/cloud_defend/public/components/control_yaml_view/index.tsx +++ b/x-pack/plugins/cloud_defend/public/components/control_yaml_view/index.tsx @@ -43,7 +43,7 @@ export const ControlYamlView = ({ policy, onChange, show }: ViewDeps) => { const currentModel = useConfigModel(configuration); // not all validations can be done via json-schema - const validateAdditional = useCallback((value) => { + const validateAdditional = useCallback((value: any) => { const errors: string[] = []; const { selectors, responses } = getSelectorsAndResponsesFromYaml(value); @@ -125,7 +125,7 @@ export const ControlYamlView = ({ policy, onChange, show }: ViewDeps) => { ]); const onYamlChange = useCallback( - (value) => { + (value: any) => { if (show && input?.vars) { input.vars.configuration.value = value; diff --git a/x-pack/plugins/cloud_defend/public/components/policy_settings/index.tsx b/x-pack/plugins/cloud_defend/public/components/policy_settings/index.tsx index 0c74551183942ef..b842453382b6817 100644 --- a/x-pack/plugins/cloud_defend/public/components/policy_settings/index.tsx +++ b/x-pack/plugins/cloud_defend/public/components/policy_settings/index.tsx @@ -16,6 +16,7 @@ import { EuiFormRow, EuiFieldText, EuiHorizontalRule, + EuiSwitchProps, } from '@elastic/eui'; import { INPUT_CONTROL } from '../../../common/constants'; import { getInputFromPolicy } from '../../../common/utils/helpers'; @@ -27,7 +28,7 @@ export const PolicySettings = ({ policy, onChange }: SettingsDeps) => { const [policyHasErrors, setPolicyHasErrors] = useState(false); const controlInput = getInputFromPolicy(policy, INPUT_CONTROL); const controlEnabled = !!controlInput?.enabled; - const onToggleEnabled = useCallback( + const onToggleEnabled = useCallback( (e) => { if (controlInput) { controlInput.enabled = e.target.checked; diff --git a/x-pack/plugins/cloud_security_posture/public/common/hooks/use_cloud_posture_data_table/use_cloud_posture_data_table.ts b/x-pack/plugins/cloud_security_posture/public/common/hooks/use_cloud_posture_data_table/use_cloud_posture_data_table.ts index ae8ddb48488c1c8..acd63279bdccf70 100644 --- a/x-pack/plugins/cloud_security_posture/public/common/hooks/use_cloud_posture_data_table/use_cloud_posture_data_table.ts +++ b/x-pack/plugins/cloud_security_posture/public/common/hooks/use_cloud_posture_data_table/use_cloud_posture_data_table.ts @@ -59,7 +59,7 @@ export const useCloudPostureDataTable = ({ const { pageSize, setPageSize } = usePageSize(paginationLocalStorageKey); const onChangeItemsPerPage = useCallback( - (newPageSize) => { + (newPageSize: any) => { setPageSize(newPageSize); setUrlQuery({ pageIndex: 0, @@ -81,7 +81,7 @@ export const useCloudPostureDataTable = ({ }, [setUrlQuery]); const onChangePage = useCallback( - (newPageIndex) => { + (newPageIndex: any) => { setUrlQuery({ pageIndex: newPageIndex, }); @@ -90,7 +90,7 @@ export const useCloudPostureDataTable = ({ ); const onSort = useCallback( - (sort) => { + (sort: any) => { setUrlQuery({ sort, }); @@ -99,7 +99,7 @@ export const useCloudPostureDataTable = ({ ); const setTableOptions = useCallback( - ({ page, sort }) => { + ({ page, sort }: any) => { setPageSize(page.size); setUrlQuery({ sort, @@ -119,7 +119,7 @@ export const useCloudPostureDataTable = ({ }); const handleUpdateQuery = useCallback( - (query) => { + (query: any) => { setUrlQuery({ ...query, pageIndex: 0 }); }, [setUrlQuery] diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/hooks/navigation.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/hooks/navigation.tsx index c97392dce6ae124..ac0123d0845a77f 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/hooks/navigation.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/hooks/navigation.tsx @@ -35,7 +35,7 @@ export const useCancelAddPackagePolicy = (params: UseCancelParams) => { const { getHref } = useLink(); const cancelClickHandler = useCallback( - (ev) => { + (ev: React.SyntheticEvent) => { if (routeState?.onCancelNavigateTo) { ev.preventDefault(); navigateToApp(...routeState.onCancelNavigateTo); diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/single_page_layout/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/single_page_layout/index.tsx index 99ed5592ac3ab17..bfca5b75f78f50f 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/single_page_layout/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/single_page_layout/index.tsx @@ -218,7 +218,7 @@ export const CreatePackagePolicySinglePage: CreatePackagePolicyParams = ({ ); const updateSelectedPolicyTab = useCallback( - (selectedTab) => { + (selectedTab: any) => { setSelectedPolicyTab(selectedTab); setPolicyValidation(selectedTab, newAgentPolicy); }, diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/settings/components/multi_row_input/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/settings/components/multi_row_input/index.tsx index be3a52d10456b74..1cdb12d158e8a6c 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/settings/components/multi_row_input/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/settings/components/multi_row_input/index.tsx @@ -311,7 +311,7 @@ export const MultiRowInput: FunctionComponent = ({ }, [value, onChange]); const onDragEndHandler = useCallback( - ({ source, destination }) => { + ({ source, destination }: any) => { if (source && destination) { const items = euiDragDropReorder(value, source.index, destination.index); const sourceErrors = indexedErrors[source.index]; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/settings/hooks/use_confirm_modal.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/settings/hooks/use_confirm_modal.tsx index 695047288e29801..fa45e0969c6019b 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/settings/hooks/use_confirm_modal.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/settings/hooks/use_confirm_modal.tsx @@ -71,7 +71,7 @@ export const ConfirmModalProvider: React.FunctionComponent<{ children?: React.Re onConfirm: () => {}, }); - const showModal = useCallback(({ title, description, onConfirm, onCancel, options }) => { + const showModal = useCallback(({ title, description, onConfirm, onCancel, options }: any) => { setIsVisible(true); setModal({ title, diff --git a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/policies/persona.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/policies/persona.tsx index c2a7e1530cbf563..aa1bbcc3dc838e0 100644 --- a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/policies/persona.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/policies/persona.tsx @@ -17,7 +17,7 @@ const MIN_WIDTH: CSSProperties = { minWidth: 0 }; export const Persona = memo( ({ name, className, 'data-test-subj': dataTestSubj, title, ...otherAvatarProps }) => { const getTestId = useCallback( - (suffix) => { + (suffix: any) => { if (dataTestSubj) { return `${dataTestSubj}-${suffix}`; } diff --git a/x-pack/plugins/graph/common/content_management/v1/types.ts b/x-pack/plugins/graph/common/content_management/v1/types.ts index c6664cf5a162c8f..0a53afa4a4a242e 100644 --- a/x-pack/plugins/graph/common/content_management/v1/types.ts +++ b/x-pack/plugins/graph/common/content_management/v1/types.ts @@ -17,7 +17,7 @@ import { CreateResult, UpdateResult, } from '@kbn/content-management-plugin/common'; -import { ContentManagementCrudTypes } from '@kbn/content-management-utils'; +import type { ContentManagementCrudTypes } from '@kbn/content-management-utils'; import { GraphContentType } from '../types'; diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields_json_editor.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields_json_editor.tsx index 94d370082ca7eba..751f4fb546c74da 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields_json_editor.tsx +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields_json_editor.tsx @@ -18,7 +18,7 @@ export const DocumentFieldsJsonEditor = ({ defaultValue }: Props) => { const dispatch = useDispatch(); const defaultValueRef = useRef(defaultValue); const onUpdate = useCallback( - ({ data, isValid }) => + ({ data, isValid }: any) => dispatch({ type: 'fieldsJsonEditor.update', value: { json: data.format(), isValid }, diff --git a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/pipeline_processors_editor_item/pipeline_processors_editor_item.tsx b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/pipeline_processors_editor_item/pipeline_processors_editor_item.tsx index 9edef3e800a98ec..1c236ea7e78d634 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/pipeline_processors_editor_item/pipeline_processors_editor_item.tsx +++ b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/pipeline_processors_editor_item/pipeline_processors_editor_item.tsx @@ -98,7 +98,7 @@ export const PipelineProcessorsEditorItem: FunctionComponent = memo( ); const onDescriptionChange = useCallback( - (nextDescription) => { + (nextDescription: any) => { let nextOptions: Record; if (!nextDescription) { const { description: _description, ...restOptions } = processor.options; diff --git a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/field_components/drag_and_drop_text_list.tsx b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/field_components/drag_and_drop_text_list.tsx index ea9f460a5899a6a..915054b053bafe5 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/field_components/drag_and_drop_text_list.tsx +++ b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/field_components/drag_and_drop_text_list.tsx @@ -78,7 +78,7 @@ function DragAndDropTextListComponent({ const [firstItemId] = useState(() => uuidv4()); const onDragEnd = useCallback( - ({ source, destination }) => { + ({ source, destination }: any) => { if (source && destination) { onMove(source.index, destination.index); } diff --git a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/field_components/xjson_editor.tsx b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/field_components/xjson_editor.tsx index 73aff739b1eef63..5134df09ac93bff 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/field_components/xjson_editor.tsx +++ b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/field_components/xjson_editor.tsx @@ -28,7 +28,7 @@ export const XJsonEditor: FunctionComponent = ({ field, editorProps }) => const { xJson, setXJson, convertToJson } = useXJsonMode(value); const onChange = useCallback( - (s) => { + (s: any) => { setXJson(s); setValue(convertToJson(s)); }, diff --git a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/processor_form.container.tsx b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/processor_form.container.tsx index ff34c88a7179e4f..e6a47c52657ed81 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/processor_form.container.tsx +++ b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/processor_form.container.tsx @@ -74,7 +74,7 @@ export const ProcessorFormContainer: FunctionComponent = ({ }, [processor, unsavedFormState]); const formSerializer = useCallback( - (formState) => { + (formState: any) => { return { type: formState.type, fields: formState.customOptions diff --git a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processors_tree/processors_tree.tsx b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processors_tree/processors_tree.tsx index 1dd2bec15845398..9e5281ea4a85370 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processors_tree/processors_tree.tsx +++ b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processors_tree/processors_tree.tsx @@ -61,7 +61,7 @@ export const ProcessorsTree: FunctionComponent = memo((props) => { onAction({ type: 'cancelMove' }); } }; - const cancelMoveClickListener = (ev: any) => { + const cancelMoveClickListener = () => { onAction({ type: 'cancelMove' }); }; // Give the browser a chance to flush any click events including the click diff --git a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/test_pipeline/test_pipeline_tabs/tab_documents/tab_documents.tsx b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/test_pipeline/test_pipeline_tabs/tab_documents/tab_documents.tsx index fc731f6be078d12..6d5cc2b582e8db1 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/test_pipeline/test_pipeline_tabs/tab_documents/tab_documents.tsx +++ b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/test_pipeline/test_pipeline_tabs/tab_documents/tab_documents.tsx @@ -152,7 +152,7 @@ export const DocumentsTab: FunctionComponent = ({ const { getFormData, reset } = form; const onAddDocumentHandler = useCallback( - (document) => { + (document: any) => { const { documents: existingDocuments = [] } = getFormData(); reset({ defaultValue: { documents: [...existingDocuments, document] } }); diff --git a/x-pack/plugins/kubernetes_security/public/components/container_name_widget/index.tsx b/x-pack/plugins/kubernetes_security/public/components/container_name_widget/index.tsx index e907e0dc9dbefbc..57d3e3288d61342 100644 --- a/x-pack/plugins/kubernetes_security/public/components/container_name_widget/index.tsx +++ b/x-pack/plugins/kubernetes_security/public/components/container_name_widget/index.tsx @@ -86,7 +86,7 @@ export const ContainerNameWidget = ({ sortDirection ); - const onTableChange = useCallback(({ sort = {} }) => { + const onTableChange = useCallback(({ sort = {} }: any) => { // @ts-ignore const { field: sortingField, direction: sortingDirection } = sort; diff --git a/x-pack/plugins/lens/public/app_plugin/lens_top_nav.tsx b/x-pack/plugins/lens/public/app_plugin/lens_top_nav.tsx index 3f12c6f63ca9554..da99d693539b8d1 100644 --- a/x-pack/plugins/lens/public/app_plugin/lens_top_nav.tsx +++ b/x-pack/plugins/lens/public/app_plugin/lens_top_nav.tsx @@ -8,9 +8,9 @@ import { cloneDeep, isEqual } from 'lodash'; import { i18n } from '@kbn/i18n'; import React, { useCallback, useEffect, useMemo, useState, useRef } from 'react'; -import { isOfAggregateQueryType } from '@kbn/es-query'; +import { AggregateQuery, isOfAggregateQueryType, Query } from '@kbn/es-query'; import { useStore } from 'react-redux'; -import { TopNavMenuData } from '@kbn/navigation-plugin/public'; +import { TopNavMenuData, TopNavMenuProps } from '@kbn/navigation-plugin/public'; import { getEsQueryConfig } from '@kbn/data-plugin/public'; import type { DataView, DataViewSpec } from '@kbn/data-views-plugin/public'; import { useKibana } from '@kbn/kibana-react-plugin/public'; @@ -803,7 +803,9 @@ export const LensTopNavMenu = ({ startServices, ]); - const onQuerySubmitWrapped = useCallback( + const onQuerySubmitWrapped = useCallback< + Required>['onQuerySubmit'] + >( (payload) => { const { dateRange, query: newQuery } = payload; const currentRange = data.query.timefilter.timefilter.getTime(); @@ -819,7 +821,7 @@ export const LensTopNavMenu = ({ } if (newQuery) { if (!isEqual(newQuery, query)) { - dispatchSetState({ query: newQuery }); + dispatchSetState({ query: newQuery as Query }); // check if query is text-based (esql etc) and switchAndCleanDatasource if (isOfAggregateQueryType(newQuery) && !isOnTextBasedMode) { setIsOnTextBasedMode(true); @@ -846,14 +848,16 @@ export const LensTopNavMenu = ({ ] ); - const onSavedWrapped = useCallback( + const onSavedWrapped = useCallback>['onSaved']>( (newSavedQuery) => { dispatchSetState({ savedQuery: newSavedQuery }); }, [dispatchSetState] ); - const onSavedQueryUpdatedWrapped = useCallback( + const onSavedQueryUpdatedWrapped = useCallback< + Required>['onSavedQueryUpdated'] + >( (newSavedQuery) => { // If the user tries to load the same saved query that is already loaded, // we will receive the same object reference which was previously frozen diff --git a/x-pack/plugins/lens/public/app_plugin/show_underlying_data.ts b/x-pack/plugins/lens/public/app_plugin/show_underlying_data.ts index 5b6712ed2386261..fa9268c0374eb7c 100644 --- a/x-pack/plugins/lens/public/app_plugin/show_underlying_data.ts +++ b/x-pack/plugins/lens/public/app_plugin/show_underlying_data.ts @@ -15,6 +15,7 @@ import { TimeRange, EsQueryConfig, isOfQueryType, + AggregateQuery, } from '@kbn/es-query'; import { i18n } from '@kbn/i18n'; import { RecursiveReadonly } from '@kbn/utility-types'; @@ -203,7 +204,7 @@ type QueryLanguage = 'lucene' | 'kuery'; * extra filter pill. */ export function combineQueryAndFilters( - query: Query | Query[] | undefined, + query: Query | Query[] | AggregateQuery | undefined, filters: Filter[], meta: LayerMetaInfo, dataViews: DataViewBase[] | undefined, diff --git a/x-pack/plugins/lens/public/datasources/form_based/datapanel.tsx b/x-pack/plugins/lens/public/datasources/form_based/datapanel.tsx index ba047564a1f070a..c666c23d667c370 100644 --- a/x-pack/plugins/lens/public/datasources/form_based/datapanel.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/datapanel.tsx @@ -241,7 +241,7 @@ export const InnerFormBasedDataPanel = function InnerFormBasedDataPanel({ [layerFields] ); - const onOverrideFieldGroupDetails = useCallback((groupName) => { + const onOverrideFieldGroupDetails = useCallback((groupName: string) => { if (groupName === FieldsGroupNames.AvailableFields) { return { helpText: i18n.translate('xpack.lens.indexPattern.allFieldsLabelHelp', { diff --git a/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx index b551ac967eead9d..98086df2e5ba123 100644 --- a/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx @@ -48,9 +48,9 @@ import { getReferencedField, hasField } from '../pure_utils'; import { fieldIsInvalid, getSamplingValue, isSamplingValueEnabled } from '../utils'; import { BucketNestingEditor } from './bucket_nesting_editor'; import type { FormBasedLayer } from '../types'; -import { FormatSelector } from './format_selector'; +import { FormatSelector, FormatSelectorProps } from './format_selector'; import { ReferenceEditor } from './reference_editor'; -import { TimeScaling } from './time_scaling'; +import { TimeScaling, TimeScalingProps } from './time_scaling'; import { Filtering } from './filtering'; import { ReducedTimeRange } from './reduced_time_range'; import { AdvancedOptions } from './advanced_options'; @@ -144,7 +144,8 @@ export function DimensionEditor(props: DimensionEditorProps) { const { euiTheme } = useEuiTheme(); const updateLayer = useCallback( - (newLayer) => setState((prevState) => mergeLayer({ state: prevState, layerId, newLayer })), + (newLayer: Partial) => + setState((prevState) => mergeLayer({ state: prevState, layerId, newLayer })), [layerId, setState] ); @@ -843,7 +844,7 @@ export function DimensionEditor(props: DimensionEditorProps) { updateLayer({ ...layer, // clean up the incomplete column data for the referenced id - incompleteColumns: { ...layer.incompleteColumns, [referenceId]: null }, + incompleteColumns: { ...layer.incompleteColumns, [referenceId]: undefined }, }); }} onDeleteColumn={() => { @@ -993,7 +994,7 @@ export function DimensionEditor(props: DimensionEditorProps) { const ButtonGroupContent = showQuickFunctions ? quickFunctions : customParamEditor; - const onFormatChange = useCallback( + const onFormatChange = useCallback( (newFormat) => { updateLayer( updateColumnParam({ @@ -1098,7 +1099,7 @@ export function DimensionEditor(props: DimensionEditorProps) { * Advanced options can cause side effects on other columns (i.e. formulas) * so before updating the layer the full insertOrReplaceColumn needs to be performed */ - const updateAdvancedOption = useCallback( + const updateAdvancedOption = useCallback( (newLayer) => { if (selectedColumn) { setStateWrapper( diff --git a/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/filtering.tsx b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/filtering.tsx index e79ead1e5536a64..c4585a51e6b0d91 100644 --- a/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/filtering.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/filtering.tsx @@ -9,6 +9,7 @@ import { isEqual } from 'lodash'; import type { Query } from '@kbn/es-query'; import { validateQuery, FilterQueryInput } from '@kbn/visualization-ui-components'; import { useKibana } from '@kbn/kibana-react-plugin/public'; +import { FilterQueryInputProps } from '@kbn/visualization-ui-components/components/query_input/filter_query_input'; import { LENS_APP_NAME } from '../../../../common/constants'; import { GenericIndexPatternColumn, operationDefinitionMap } from '../operations'; import type { FormBasedLayer } from '../types'; @@ -44,7 +45,7 @@ export function Filtering({ helpMessage: string | null; }) { const inputFilter = selectedColumn.filter; - const onChange = useCallback( + const onChange = useCallback( (query) => { const { isValid } = validateQuery(query, indexPattern); if (isValid && !isEqual(inputFilter, query)) { diff --git a/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/format_selector.tsx b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/format_selector.tsx index 08972b236240da3..0e978e439a701d1 100644 --- a/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/format_selector.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/format_selector.tsx @@ -17,6 +17,7 @@ import { EuiFormLabel, EuiLink, useEuiTheme, + EuiComboBoxOptionOption, } from '@elastic/eui'; import { useDebouncedValue } from '@kbn/visualization-utils'; import { useKibana } from '@kbn/kibana-react-plugin/public'; @@ -227,7 +228,7 @@ export function FormatSelector(props: FormatSelectorProps) { ); const onChangeWrapped = useCallback( - (choices) => { + (choices: Array>) => { if (choices.length === 0) { return; } diff --git a/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/time_scaling.tsx b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/time_scaling.tsx index 003407649622ef2..5cf3bde50bec3ac 100644 --- a/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/time_scaling.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/time_scaling.tsx @@ -54,17 +54,14 @@ export function setTimeScaling( }; } -export function TimeScaling({ - selectedColumn, - columnId, - layer, - updateLayer, -}: { +export interface TimeScalingProps { selectedColumn: GenericIndexPatternColumn; columnId: string; layer: FormBasedLayer; updateLayer: (newLayer: FormBasedLayer) => void; -}) { +} + +export function TimeScaling({ selectedColumn, columnId, layer, updateLayer }: TimeScalingProps) { const selectedOperation = operationDefinitionMap[selectedColumn.operationType]; if (!selectedOperation.timeScalingMode || selectedOperation.timeScalingMode === 'disabled') { diff --git a/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/percentile.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/percentile.tsx index ad9a1067dcae731..7896f1f2950bc00 100644 --- a/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/percentile.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/percentile.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { EuiFieldNumber, EuiRange } from '@elastic/eui'; +import { EuiFieldNumber, EuiRange, EuiRangeProps } from '@elastic/eui'; import React, { useCallback } from 'react'; import { i18n } from '@kbn/i18n'; import { AggFunctionsMapping } from '@kbn/data-plugin/public'; @@ -344,7 +344,7 @@ export const percentileOperation: OperationDefinition< const step = isInline ? 1 : 0.0001; const upperBound = isInline ? 99 : 99.9999; const onChange = useCallback( - (value) => { + (value?: string) => { if ( !isValidNumber(value, isInline, upperBound, step, ALLOWED_DECIMAL_DIGITS) || Number(value) === currentColumn.params.percentile @@ -384,7 +384,12 @@ export const percentileOperation: OperationDefinition< ALLOWED_DECIMAL_DIGITS ); - const handleInputChange = useCallback( + const handleInputChange = useCallback>( + (e) => handleInputChangeWithoutValidation(String(e.currentTarget.value)), + [handleInputChangeWithoutValidation] + ); + + const handleRangeChange = useCallback>( (e) => handleInputChangeWithoutValidation(String(e.currentTarget.value)), [handleInputChangeWithoutValidation] ); @@ -420,7 +425,7 @@ export const percentileOperation: OperationDefinition< min={step} max={upperBound} step={step} - onChange={handleInputChange} + onChange={handleRangeChange} showInput aria-label={percentileLabel} /> diff --git a/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/percentile_ranks.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/percentile_ranks.tsx index 575bcc2ec0ed0bd..a7d8896ea050b03 100644 --- a/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/percentile_ranks.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/percentile_ranks.tsx @@ -185,7 +185,7 @@ export const percentileRanksOperation: OperationDefinition< defaultMessage: 'Percentile ranks value', }); const onChange = useCallback( - (value) => { + (value?: string) => { if (!isValidNumber(value, isInline) || Number(value) === currentColumn.params.value) { return; } diff --git a/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/static_value.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/static_value.tsx index 715889b896ced49..6b2b2166c02ba9c 100644 --- a/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/static_value.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/static_value.tsx @@ -167,7 +167,7 @@ export const staticValueOperation: OperationDefinition< paramEditorCustomProps, }) { const onChange = useCallback( - (newValue) => { + (newValue?: string) => { // even if debounced it's triggering for empty string with the previous valid value if ( currentColumn.params.value === newValue || diff --git a/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/terms/field_inputs.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/terms/field_inputs.tsx index 2a88a72029648f9..960aeea67b23784 100644 --- a/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/terms/field_inputs.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/terms/field_inputs.tsx @@ -16,7 +16,7 @@ import { } from '@kbn/visualization-ui-components'; import { useDebouncedValue } from '@kbn/visualization-utils'; import { IndexPattern } from '../../../../../types'; -import { FieldSelect } from '../../../dimension_panel/field_select'; +import { FieldChoiceWithOperationType, FieldSelect } from '../../../dimension_panel/field_select'; import type { TermsIndexPatternColumn } from './types'; import type { OperationSupportMatrix } from '../../../dimension_panel'; import { supportedTypes } from './constants'; @@ -72,7 +72,7 @@ export function FieldInputs({ }); const onFieldSelectChange = useCallback( - (choice, index = 0) => { + (choice: FieldChoiceWithOperationType, index = 0) => { const fields = [...localValues]; if (indexPattern.getFieldByName(choice.field)) { diff --git a/x-pack/plugins/lens/public/datasources/form_based/types.ts b/x-pack/plugins/lens/public/datasources/form_based/types.ts index 5abec15c31d61fc..1241429cf785c57 100644 --- a/x-pack/plugins/lens/public/datasources/form_based/types.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/types.ts @@ -53,7 +53,7 @@ export interface FormBasedLayer { indexPatternId: string; linkToLayers?: string[]; // Partial columns represent the temporary invalid states - incompleteColumns?: Record; + incompleteColumns?: Record; sampling?: number; ignoreGlobalFilters?: boolean; } diff --git a/x-pack/plugins/lens/public/datasources/text_based/components/datapanel.tsx b/x-pack/plugins/lens/public/datasources/text_based/components/datapanel.tsx index bda5df0e34882dc..fd61c0d06345293 100644 --- a/x-pack/plugins/lens/public/datasources/text_based/components/datapanel.tsx +++ b/x-pack/plugins/lens/public/datasources/text_based/components/datapanel.tsx @@ -24,6 +24,7 @@ import { GetCustomFieldType, useGroupedFields, } from '@kbn/unified-field-list'; +import { OverrideFieldGroupDetails } from '@kbn/unified-field-list/src/types'; import type { DatasourceDataPanelProps } from '../../../types'; import type { TextBasedPrivateState } from '../types'; import { getStateFromAggregateQuery } from '../utils'; @@ -83,7 +84,7 @@ export function TextBasedDataPanel({ [layerFields] ); - const onOverrideFieldGroupDetails = useCallback((groupName) => { + const onOverrideFieldGroupDetails = useCallback((groupName) => { if (groupName === FieldsGroupNames.AvailableFields) { return { helpText: i18n.translate('xpack.lens.indexPattern.allFieldsForTextBasedLabelHelp', { diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/buttons/draggable_dimension_button.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/buttons/draggable_dimension_button.tsx index aa3315972b71978..4218eb6426d20de 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/buttons/draggable_dimension_button.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/buttons/draggable_dimension_button.tsx @@ -13,6 +13,7 @@ import { DropTargetSwapDuplicateCombine, Draggable, Droppable, + DroppableProps, } from '@kbn/dom-drag-drop'; import { isDraggedField } from '../../../../utils'; import { @@ -125,11 +126,11 @@ export function DraggableDimensionButton({ ); const registerNewButtonRefMemoized = useCallback( - (el) => registerNewButtonRef(target.columnId, el), + (el: HTMLDivElement | null) => registerNewButtonRef(target.columnId, el), [registerNewButtonRef, target.columnId] ); - const handleOnDrop = useCallback( + const handleOnDrop = useCallback>( (source, selectedDropType) => onDrop(source, value, selectedDropType), [value, onDrop] ); diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/buttons/empty_dimension_button.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/buttons/empty_dimension_button.tsx index f8562a161c2a791..836365effc3dca1 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/buttons/empty_dimension_button.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/buttons/empty_dimension_button.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import React, { useMemo, useState, useEffect } from 'react'; +import React, { useCallback, useMemo, useState, useEffect } from 'react'; import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; import { @@ -14,6 +14,7 @@ import { DropType, DropTargetSwapDuplicateCombine, Droppable, + DroppableProps, } from '@kbn/dom-drag-drop'; import { EmptyDimensionButton as EmptyDimensionButtonInner } from '@kbn/visualization-ui-components'; import { css } from '@emotion/react'; @@ -167,7 +168,7 @@ export function EmptyDimensionButton({ [newColumnId, target, nextLabel, canDuplicate] ); - const handleOnDrop = React.useCallback( + const handleOnDrop = useCallback>( (source, selectedDropType) => onDrop(source, value, selectedDropType), [value, onDrop] ); diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.tsx index 5f66bd2e838c037..e83323a36fadfe9 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.tsx @@ -23,7 +23,7 @@ import { import { AddLayerFunction, DragDropOperation, Visualization } from '../../../types'; import { LayerPanel } from './layer_panel'; import { generateId } from '../../../id_generator'; -import { ConfigPanelWrapperProps } from './types'; +import { ConfigPanelWrapperProps, LayerPanelProps } from './types'; import { useFocusUpdate } from './use_focus_update'; import { setLayerDefaultDimension, @@ -245,10 +245,9 @@ export function LayerPanels( setNextFocusedLayerId(layerId); }; - const registerLibraryAnnotationGroupFunction = useCallback( - (groupInfo) => dispatchLens(registerLibraryAnnotationGroup(groupInfo)), - [dispatchLens] - ); + const registerLibraryAnnotationGroupFunction = useCallback< + LayerPanelProps['registerLibraryAnnotationGroup'] + >((groupInfo) => dispatchLens(registerLibraryAnnotationGroup(groupInfo)), [dispatchLens]); const hideAddLayerButton = query && isOfAggregateQueryType(query); diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx index cad1dd351c3ca43..2847af1ca43758a 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx @@ -91,7 +91,7 @@ export function LayerPanel(props: LayerPanelProps) { const settingsPanelRef = useRef(null); const registerLayerRef = useCallback( - (el) => registerNewLayerRef(layerId, el), + (el: HTMLDivElement | null) => registerNewLayerRef(layerId, el), [layerId, registerNewLayerRef] ); diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/use_focus_update.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/use_focus_update.tsx index 7065c37c1daf2b1..4a6234a7cf6b18b 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/use_focus_update.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/use_focus_update.tsx @@ -35,7 +35,7 @@ export function useFocusUpdate(ids: string[]) { } }, [ids, refsById, nextFocusedId]); - const registerNewRef = useCallback((id, el) => { + const registerNewRef = useCallback((id: string, el: HTMLElement | null) => { if (el) { setRefsById((refs) => { return new Map(refs.set(id, el)); @@ -44,7 +44,7 @@ export function useFocusUpdate(ids: string[]) { }, []); const removeRef = useCallback( - (id) => { + (id: string) => { if (ids.length <= 1) { return setNextFocusedId(id); } diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/editor_frame.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/editor_frame.tsx index e0736b149fcbb3a..d5173998dc462b4 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/editor_frame.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/editor_frame.tsx @@ -97,7 +97,7 @@ export function EditorFrame(props: EditorFrameProps) { ); const dropOntoWorkspace = useCallback( - (field) => { + (field: DragDropIdentifier) => { const suggestion = getSuggestionForField.current!(field); if (suggestion) { trackUiCounterEvents('drop_onto_workspace'); diff --git a/x-pack/plugins/lens/public/embeddable/embeddable.tsx b/x-pack/plugins/lens/public/embeddable/embeddable.tsx index faa617f081d8fe7..7baf35c4eb140d3 100644 --- a/x-pack/plugins/lens/public/embeddable/embeddable.tsx +++ b/x-pack/plugins/lens/public/embeddable/embeddable.tsx @@ -162,7 +162,7 @@ interface PreventableEvent { export type Simplify = { [KeyType in keyof T]: T[KeyType] } & {}; -interface LensBaseEmbeddableInput extends EmbeddableInput { +export interface LensBaseEmbeddableInput extends EmbeddableInput { filters?: Filter[]; query?: Query; timeRange?: TimeRange; diff --git a/x-pack/plugins/lens/public/shared_components/axis/ticks/axis_ticks_settings.tsx b/x-pack/plugins/lens/public/shared_components/axis/ticks/axis_ticks_settings.tsx index 1ac1c84f7063305..8f47307d19d36c9 100644 --- a/x-pack/plugins/lens/public/shared_components/axis/ticks/axis_ticks_settings.tsx +++ b/x-pack/plugins/lens/public/shared_components/axis/ticks/axis_ticks_settings.tsx @@ -33,7 +33,7 @@ export const AxisTicksSettings: React.FunctionComponent updateTicksVisibilityState, }) => { const onTicksStatusChange = useCallback( - (visible) => updateTicksVisibilityState(visible, axis), + (visible: boolean) => updateTicksVisibilityState(visible, axis), [axis, updateTicksVisibilityState] ); diff --git a/x-pack/plugins/lens/public/visualizations/datatable/components/table_basic.tsx b/x-pack/plugins/lens/public/visualizations/datatable/components/table_basic.tsx index 9c3823c434a2183..83249f86ffa794e 100644 --- a/x-pack/plugins/lens/public/visualizations/datatable/components/table_basic.tsx +++ b/x-pack/plugins/lens/public/visualizations/datatable/components/table_basic.tsx @@ -183,13 +183,13 @@ export const DatatableComponent = (props: DatatableRenderProps) => { ); const onChangeItemsPerPage = useCallback( - (pageSize) => onEditAction({ action: 'pagesize', size: pageSize }), + (pageSize: number) => onEditAction({ action: 'pagesize', size: pageSize }), [onEditAction] ); // active page isn't persisted, so we manage this state locally const onChangePage = useCallback( - (pageIndex) => { + (pageIndex: number) => { setPagination((_pagination) => { if (_pagination) { return { pageSize: _pagination?.pageSize, pageIndex }; diff --git a/x-pack/plugins/lens/public/visualizations/datatable/components/toolbar.tsx b/x-pack/plugins/lens/public/visualizations/datatable/components/toolbar.tsx index b27dc0305c68437..be5a81ef33dc093 100644 --- a/x-pack/plugins/lens/public/visualizations/datatable/components/toolbar.tsx +++ b/x-pack/plugins/lens/public/visualizations/datatable/components/toolbar.tsx @@ -24,9 +24,9 @@ export function DataTableToolbar(props: VisualizationToolbarProps { const rowHeightLines = @@ -45,7 +45,7 @@ export function DataTableToolbar(props: VisualizationToolbarProps { + (newRowHeightLines: number, heightLinesProperty: string) => { setState({ ...state, [heightLinesProperty]: newRowHeightLines, diff --git a/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/axis_settings_popover.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/axis_settings_popover.tsx index 47178886dc53130..1bf00cb0afb6f25 100644 --- a/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/axis_settings_popover.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/axis_settings_popover.tsx @@ -245,7 +245,7 @@ export const AxisSettingsPopover: React.FunctionComponent { + (newExtent: AxisExtentConfig | undefined) => { if (setExtent && newExtent && !isEqual(newExtent, extent)) { const { errorMsg } = validateExtent(hasBarOrAreaOnAxis, newExtent, scale); if (axis === 'x' || newExtent.mode !== 'custom' || !errorMsg) { diff --git a/x-pack/plugins/maps/server/content_management/maps_storage.ts b/x-pack/plugins/maps/server/content_management/maps_storage.ts index 66d72646385e9b1..6a4df61a8c485db 100644 --- a/x-pack/plugins/maps/server/content_management/maps_storage.ts +++ b/x-pack/plugins/maps/server/content_management/maps_storage.ts @@ -9,7 +9,7 @@ import { SOContentStorage, tagsToFindOptions } from '@kbn/content-management-uti import { SavedObjectsFindOptions } from '@kbn/core-saved-objects-api-server'; import type { Logger } from '@kbn/logging'; import { CONTENT_ID } from '../../common/content_management'; -import { cmServicesDefinition } from '../../common/content_management/cm_services'; +import { cmServicesDefinition } from './schema/cm_services'; import type { MapCrudTypes } from '../../common/content_management'; const searchArgsToSOFindOptions = (args: MapCrudTypes['SearchIn']): SavedObjectsFindOptions => { diff --git a/x-pack/plugins/maps/common/content_management/cm_services.ts b/x-pack/plugins/maps/server/content_management/schema/cm_services.ts similarity index 100% rename from x-pack/plugins/maps/common/content_management/cm_services.ts rename to x-pack/plugins/maps/server/content_management/schema/cm_services.ts diff --git a/x-pack/plugins/maps/common/content_management/v1/cm_services.ts b/x-pack/plugins/maps/server/content_management/schema/v1/cm_services.ts similarity index 100% rename from x-pack/plugins/maps/common/content_management/v1/cm_services.ts rename to x-pack/plugins/maps/server/content_management/schema/v1/cm_services.ts diff --git a/x-pack/plugins/ml/public/alerting/anomaly_detection_rule/ml_anomaly_alert_trigger.tsx b/x-pack/plugins/ml/public/alerting/anomaly_detection_rule/ml_anomaly_alert_trigger.tsx index 2f36f3f687caf04..7404646db719530 100644 --- a/x-pack/plugins/ml/public/alerting/anomaly_detection_rule/ml_anomaly_alert_trigger.tsx +++ b/x-pack/plugins/ml/public/alerting/anomaly_detection_rule/ml_anomaly_alert_trigger.tsx @@ -199,7 +199,6 @@ const MlAnomalyAlertTrigger: FC = ({ errors={Array.isArray(errors.jobSelection) ? errors.jobSelection : []} shouldUseDropdownJobCreate /> - = ({ alertParams={resultParams} maxNumberOfBuckets={maxNumberOfBuckets} /> - = ({ onChange={useCallback(onAlertParamChange('includeInterim'), [])} /> - { + onChange={useCallback((update: any) => { Object.keys(update).forEach((k) => { setRuleParams(k, update[k as keyof MlAnomalyDetectionAlertAdvancedSettings]); }); // eslint-disable-next-line react-hooks/exhaustive-deps }, [])} /> - - - ); diff --git a/x-pack/plugins/ml/public/alerting/jobs_health_rule/anomaly_detection_jobs_health_rule_trigger.tsx b/x-pack/plugins/ml/public/alerting/jobs_health_rule/anomaly_detection_jobs_health_rule_trigger.tsx index 4e8d88f8b33ef7a..54d25e9fcb30b11 100644 --- a/x-pack/plugins/ml/public/alerting/jobs_health_rule/anomaly_detection_jobs_health_rule_trigger.tsx +++ b/x-pack/plugins/ml/public/alerting/jobs_health_rule/anomaly_detection_jobs_health_rule_trigger.tsx @@ -125,13 +125,11 @@ const AnomalyDetectionJobsHealthRuleTrigger: FC = ({ } shouldUseDropdownJobCreate /> - - { + onChange={useCallback((update: any) => { const callback = onAlertParamChange('excludeJobs'); if (isPopulatedObject(update)) { callback(update); @@ -151,9 +149,7 @@ const AnomalyDetectionJobsHealthRuleTrigger: FC = ({ options={excludeJobsOptions} shouldUseDropdownJobCreate /> - - { const useUserTimeSettings = useUiSettings().get(ANOMALY_DETECTION_ENABLE_TIME_RANGE); const userTimeSettings = useUiSettings().get(ANOMALY_DETECTION_DEFAULT_TIME_RANGE); const createLinkWithUserDefaults = useCallback( - (location, jobList) => { + (location: any, jobList: any) => { const resultsUrl = mlJobService.createResultsUrlForJobs( jobList, location, diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/exploration_results_table/use_exploration_data_grid.ts b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/exploration_results_table/use_exploration_data_grid.ts index 8ed2b2fd3b2a2bc..5a8d29422a9d507 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/exploration_results_table/use_exploration_data_grid.ts +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/exploration_results_table/use_exploration_data_grid.ts @@ -36,20 +36,20 @@ export const useExplorationDataGrid = ( }), [pageUrlState.pageSize, pageUrlState.pageIndex] ); - dataGrid.setPagination = useCallback( + dataGrid.setPagination = useCallback( (u) => { setPageUrlState({ ...u }); }, [setPageUrlState] ); dataGrid.onChangePage = useCallback( - (pageIndex) => { + (pageIndex: number) => { setPageUrlState({ pageIndex }); }, [setPageUrlState] ); dataGrid.onChangeItemsPerPage = useCallback( - (pageSize) => { + (pageSize: number) => { setPageUrlState({ pageSize }); }, [setPageUrlState] diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/feature_importance/decision_path_chart.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/feature_importance/decision_path_chart.tsx index 954b85ce2793e03..2805563eeb7fd0d 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/feature_importance/decision_path_chart.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/feature_importance/decision_path_chart.tsx @@ -122,7 +122,7 @@ export const DecisionPathChart = ({ ); // if regression, guarantee up to num_precision significant digits without having it in scientific notation // if classification, hide the numeric values since we only want to show the path - const tickFormatter = useCallback((d) => formatSingleValue(d, '').toString(), []); + const tickFormatter = useCallback((d: any) => formatSingleValue(d, '').toString(), []); return (
diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/total_feature_importance_summary/feature_importance_summary.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/total_feature_importance_summary/feature_importance_summary.tsx index e4c1b92433b88e6..9e7371580b12d0f 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/total_feature_importance_summary/feature_importance_summary.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/total_feature_importance_summary/feature_importance_summary.tsx @@ -200,7 +200,7 @@ export const FeatureImportanceSummaryPanel: FC Number(d.toPrecision(3)).toString(), []); + const tickFormatter = useCallback((d: any) => Number(d.toPrecision(3)).toString(), []); // do not expand by default if no feature importance data const noDataCallOut = useMemo(() => { diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/analytics_list.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/analytics_list.tsx index 19d4d3a55f732ea..9cf36366044508b 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/analytics_list.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/analytics_list.tsx @@ -100,7 +100,7 @@ export const DataFrameAnalyticsList: FC = ({ const searchQueryText = pageState.queryText ?? ''; const setSearchQueryText = useCallback( - (value) => { + (value: any) => { updatePageState({ queryText: value }); }, [updatePageState] diff --git a/x-pack/plugins/ml/public/application/explorer/actions/load_explorer_data.ts b/x-pack/plugins/ml/public/application/explorer/actions/load_explorer_data.ts index 8d710e0a83b6cf6..faa2b009c131d53 100644 --- a/x-pack/plugins/ml/public/application/explorer/actions/load_explorer_data.ts +++ b/x-pack/plugins/ml/public/application/explorer/actions/load_explorer_data.ts @@ -224,7 +224,7 @@ export const useExplorerData = (): [Partial | undefined, (d: any) const explorerData$ = useMemo(() => loadExplorerData$.pipe(switchMap(loadExplorerData)), []); const explorerData = useObservable(explorerData$); - const update = useCallback((c) => { + const update = useCallback((c: any) => { loadExplorerData$.next(c); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); diff --git a/x-pack/plugins/ml/public/application/explorer/anomaly_timeline.tsx b/x-pack/plugins/ml/public/application/explorer/anomaly_timeline.tsx index 2b164985f022a4e..ae12b8b1fa4ac7e 100644 --- a/x-pack/plugins/ml/public/application/explorer/anomaly_timeline.tsx +++ b/x-pack/plugins/ml/public/application/explorer/anomaly_timeline.tsx @@ -465,7 +465,7 @@ export const AnomalyTimeline: FC = React.memo( { + onChange={useCallback((update: any) => { setSeverityUpdate(update); }, [])} /> diff --git a/x-pack/plugins/ml/public/application/explorer/explorer.tsx b/x-pack/plugins/ml/public/application/explorer/explorer.tsx index 23a4cbed76bbc2e..65b862bc548e631 100644 --- a/x-pack/plugins/ml/public/application/explorer/explorer.tsx +++ b/x-pack/plugins/ml/public/application/explorer/explorer.tsx @@ -232,7 +232,7 @@ export const Explorer: FC = ({ ); const onPanelWidthChange = useCallback( - (newSizes) => { + (newSizes: any) => { setAnomalyExplorerPanelState({ mainPage: { size: newSizes.mainPage, diff --git a/x-pack/plugins/monitoring/public/application/hooks/use_table.ts b/x-pack/plugins/monitoring/public/application/hooks/use_table.ts index af1a71f95aa28fc..11f76bb577b1110 100644 --- a/x-pack/plugins/monitoring/public/application/hooks/use_table.ts +++ b/x-pack/plugins/monitoring/public/application/hooks/use_table.ts @@ -72,7 +72,7 @@ export function useTable(storageKey: string) { ); const updateTotalItemCount = useCallback( - (num) => { + (num: any) => { // only update pagination state if different if (num === pagination.totalItemCount) return; setPagination({ diff --git a/x-pack/plugins/monitoring/public/application/pages/logstash/pipeline.tsx b/x-pack/plugins/monitoring/public/application/pages/logstash/pipeline.tsx index 206b43cad4578d6..b89bb112e56f5fb 100644 --- a/x-pack/plugins/monitoring/public/application/pages/logstash/pipeline.tsx +++ b/x-pack/plugins/monitoring/public/application/pages/logstash/pipeline.tsx @@ -145,7 +145,7 @@ export const LogStashPipelinePage: React.FC = ({ clusters }) => }, [detailVertexId, getPageData]); const onChangePipelineHash = useCallback( - (hash) => { + (hash: any) => { window.location.hash = getSafeForExternalLink(`#/logstash/pipelines/${pipelineId}/${hash}`); }, [pipelineId] diff --git a/x-pack/plugins/observability_solution/apm/public/components/app/alerts_overview/index.tsx b/x-pack/plugins/observability_solution/apm/public/components/app/alerts_overview/index.tsx index e606c5c2e163289..a5d0df3b05538e1 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/app/alerts_overview/index.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/app/alerts_overview/index.tsx @@ -71,7 +71,7 @@ export function AlertsOverview() { }, [serviceName, environment]); const onKueryChange = useCallback( - (value) => push(history, { query: { kuery: value } }), + (value: any) => push(history, { query: { kuery: value } }), [history] ); diff --git a/x-pack/plugins/observability_solution/apm/public/components/app/correlations/correlations_table.tsx b/x-pack/plugins/observability_solution/apm/public/components/app/correlations/correlations_table.tsx index 670521bb6086c83..ea79b1ef198bc0e 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/app/correlations/correlations_table.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/app/correlations/correlations_table.tsx @@ -69,7 +69,7 @@ export function CorrelationsTable({ }, [pageIndex, pageSize, significantTerms]); const onChange = useCallback( - (tableSettings) => { + (tableSettings: any) => { const { index, size } = tableSettings.page; setPageIndex(index); diff --git a/x-pack/plugins/observability_solution/apm/public/components/app/correlations/failed_transactions_correlations.tsx b/x-pack/plugins/observability_solution/apm/public/components/app/correlations/failed_transactions_correlations.tsx index 9149be49e298617..d02eed810acd086 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/app/correlations/failed_transactions_correlations.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/app/correlations/failed_transactions_correlations.tsx @@ -331,7 +331,7 @@ export function FailedTransactionsCorrelations({ onFilter }: { onFilter: () => v useState('normalizedScore'); const [sortDirection, setSortDirection] = useState('desc'); - const onTableChange = useCallback(({ sort }) => { + const onTableChange = useCallback(({ sort }: any) => { const { field: currentSortField, direction: currentSortDirection } = sort; setSortField(currentSortField); diff --git a/x-pack/plugins/observability_solution/apm/public/components/app/correlations/latency_correlations.tsx b/x-pack/plugins/observability_solution/apm/public/components/app/correlations/latency_correlations.tsx index 1183338b0f4bd5a..8144dbd5484100d 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/app/correlations/latency_correlations.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/app/correlations/latency_correlations.tsx @@ -249,7 +249,7 @@ export function LatencyCorrelations({ onFilter }: { onFilter: () => void }) { const [sortField, setSortField] = useState('correlation'); const [sortDirection, setSortDirection] = useState('desc'); - const onTableChange = useCallback(({ sort }) => { + const onTableChange = useCallback(({ sort }: any) => { const { field: currentSortField, direction: currentSortDirection } = sort; setSortField(currentSortField); diff --git a/x-pack/plugins/observability_solution/apm/public/components/app/mobile/service_overview/stats/location_stats.tsx b/x-pack/plugins/observability_solution/apm/public/components/app/mobile/service_overview/stats/location_stats.tsx index b59246cf27e1f67..47451fac265c931 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/app/mobile/service_overview/stats/location_stats.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/app/mobile/service_overview/stats/location_stats.tsx @@ -88,7 +88,7 @@ export function MobileLocationStats({ const previousPeriod = locationStatsData?.previousPeriod; const getComparisonValueFormatter = useCallback( - ({ currentPeriodValue, previousPeriodValue }) => { + ({ currentPeriodValue, previousPeriodValue }: any) => { const comparisonDiffValue = calculateDiffPercentageAndFormat( currentPeriodValue, previousPeriodValue diff --git a/x-pack/plugins/observability_solution/apm/public/components/app/mobile/service_overview/stats/stats.tsx b/x-pack/plugins/observability_solution/apm/public/components/app/mobile/service_overview/stats/stats.tsx index f71da0cf8abd22b..59f6020d61c33c0 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/app/mobile/service_overview/stats/stats.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/app/mobile/service_overview/stats/stats.tsx @@ -49,7 +49,7 @@ export function MobileStats({ start, end, kuery }: { start: string; end: string; ); const getComparisonValueFormatter = useCallback( - (value) => { + (value: any) => { return ( {value && comparisonEnabled diff --git a/x-pack/plugins/observability_solution/apm/public/components/app/service_dashboards/index.tsx b/x-pack/plugins/observability_solution/apm/public/components/app/service_dashboards/index.tsx index db8a2c1bac8cca3..458a2e647cc2b2b 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/app/service_dashboards/index.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/app/service_dashboards/index.tsx @@ -124,7 +124,7 @@ export function ServiceDashboards({ checkForEntities = false }: { checkForEntiti }, [dataView, serviceName, environment, kuery, dashboard, rangeFrom, rangeTo, currentDashboard]); const getLocatorParams = useCallback( - (params) => { + (params: any) => { return { serviceName, dashboardId: params.dashboardId, diff --git a/x-pack/plugins/observability_solution/exploratory_view/public/components/shared/exploratory_view/header/add_to_case_action.tsx b/x-pack/plugins/observability_solution/exploratory_view/public/components/shared/exploratory_view/header/add_to_case_action.tsx index 8f91ee3c87cd6c9..4a3693de8265e4a 100644 --- a/x-pack/plugins/observability_solution/exploratory_view/public/components/shared/exploratory_view/header/add_to_case_action.tsx +++ b/x-pack/plugins/observability_solution/exploratory_view/public/components/shared/exploratory_view/header/add_to_case_action.tsx @@ -45,7 +45,7 @@ export function AddToCaseAction({ } = kServices; const getToastText = useCallback( - (theCase) => + (theCase: any) => toMountPoint( { + (isLoading: any) => { const timeLoaded = Date.now(); setChartTimeRangeContext?.({ diff --git a/x-pack/plugins/observability_solution/exploratory_view/public/context/date_picker_context.tsx b/x-pack/plugins/observability_solution/exploratory_view/public/context/date_picker_context.tsx index 33d57611d1399d4..598cb9f956f1b86 100644 --- a/x-pack/plugins/observability_solution/exploratory_view/public/context/date_picker_context.tsx +++ b/x-pack/plugins/observability_solution/exploratory_view/public/context/date_picker_context.tsx @@ -108,7 +108,7 @@ export function DatePickerContextProvider({ children }: { children: React.ReactE ); const updateRefreshInterval = useCallback( - ({ interval, isPaused }) => { + ({ interval, isPaused }: any) => { updateUrl({ refreshInterval: interval, refreshPaused: isPaused }); data.query.timefilter.timefilter.setRefreshInterval({ value: interval, pause: isPaused }); setLastUpdated(Date.now()); diff --git a/x-pack/plugins/observability_solution/infra/public/alerting/inventory/components/expression.tsx b/x-pack/plugins/observability_solution/infra/public/alerting/inventory/components/expression.tsx index f89cd7e77876315..89579ac74a3261e 100644 --- a/x-pack/plugins/observability_solution/infra/public/alerting/inventory/components/expression.tsx +++ b/x-pack/plugins/observability_solution/infra/public/alerting/inventory/components/expression.tsx @@ -128,7 +128,7 @@ export const Expressions: React.FC = (props) => { const { metricsView } = useMetricsDataViewContext(); const updateParams = useCallback( - (id, e: InventoryMetricConditions) => { + (id: any, e: InventoryMetricConditions) => { const exp = ruleParams.criteria ? ruleParams.criteria.slice() : []; exp[id] = e; setRuleParams('criteria', exp); @@ -492,7 +492,7 @@ export const ExpressionRow: FC> = (props) ); const updateThreshold = useCallback( - (t) => { + (t: any) => { if (t.join() !== expression.threshold.join()) { setRuleParams(expressionId, { ...expression, threshold: t }); } @@ -501,7 +501,7 @@ export const ExpressionRow: FC> = (props) ); const updateWarningThreshold = useCallback( - (t) => { + (t: any) => { if (t.join() !== expression.warningThreshold?.join()) { setRuleParams(expressionId, { ...expression, warningThreshold: t }); } diff --git a/x-pack/plugins/observability_solution/infra/public/alerting/log_threshold/components/expression_editor/criteria.tsx b/x-pack/plugins/observability_solution/infra/public/alerting/log_threshold/components/expression_editor/criteria.tsx index 33f63fe6a49c3a1..f821d7510b3bf9c 100644 --- a/x-pack/plugins/observability_solution/infra/public/alerting/log_threshold/components/expression_editor/criteria.tsx +++ b/x-pack/plugins/observability_solution/infra/public/alerting/log_threshold/components/expression_editor/criteria.tsx @@ -218,7 +218,7 @@ const useCriteriaState = ( onUpdateCriteria: (criteria: PartialCountCriteriaType) => void ) => { const updateCriterion = useCallback( - (idx, criterionParams) => { + (idx: any, criterionParams: any) => { const nextCriteria = criteria.map((criterion, index) => { return idx === index ? { ...criterion, ...criterionParams } : criterion; }); @@ -233,7 +233,7 @@ const useCriteriaState = ( }, [criteria, defaultCriterion, onUpdateCriteria]); const removeCriterion = useCallback( - (idx) => { + (idx: any) => { const nextCriteria = criteria.filter((_criterion, index) => { return index !== idx; }); diff --git a/x-pack/plugins/observability_solution/infra/public/alerting/log_threshold/components/expression_editor/editor.tsx b/x-pack/plugins/observability_solution/infra/public/alerting/log_threshold/components/expression_editor/editor.tsx index a38eed49ee82b57..85935143da39918 100644 --- a/x-pack/plugins/observability_solution/infra/public/alerting/log_threshold/components/expression_editor/editor.tsx +++ b/x-pack/plugins/observability_solution/infra/public/alerting/log_threshold/components/expression_editor/editor.tsx @@ -193,7 +193,7 @@ export const Editor: React.FC { + (thresholdParams: any) => { const nextThresholdParams = { ...ruleParams.count, ...thresholdParams }; setRuleParams('count', nextThresholdParams); }, diff --git a/x-pack/plugins/observability_solution/infra/public/alerting/metric_threshold/components/expression.tsx b/x-pack/plugins/observability_solution/infra/public/alerting/metric_threshold/components/expression.tsx index 4855d71274e96de..42eb0daa7806dc7 100644 --- a/x-pack/plugins/observability_solution/infra/public/alerting/metric_threshold/components/expression.tsx +++ b/x-pack/plugins/observability_solution/infra/public/alerting/metric_threshold/components/expression.tsx @@ -81,7 +81,7 @@ export const Expressions: React.FC = (props) => { }, [metadata]); const updateParams = useCallback( - (id, e: MetricExpression) => { + (id: any, e: MetricExpression) => { const exp = ruleParams.criteria ? ruleParams.criteria.slice() : []; exp[id] = e; setRuleParams('criteria', exp); diff --git a/x-pack/plugins/observability_solution/infra/public/alerting/metric_threshold/components/expression_row.tsx b/x-pack/plugins/observability_solution/infra/public/alerting/metric_threshold/components/expression_row.tsx index cca94d10e9539e2..48371bebb2569f0 100644 --- a/x-pack/plugins/observability_solution/infra/public/alerting/metric_threshold/components/expression_row.tsx +++ b/x-pack/plugins/observability_solution/infra/public/alerting/metric_threshold/components/expression_row.tsx @@ -118,13 +118,13 @@ export const ExpressionRow = ({ ); const convertThreshold = useCallback( - (enteredThreshold) => + (enteredThreshold: any) => isMetricPct ? enteredThreshold.map((v: number) => pctToDecimal(v)) : enteredThreshold, [isMetricPct] ); const updateThreshold = useCallback( - (enteredThreshold) => { + (enteredThreshold: any) => { const t = convertThreshold(enteredThreshold); if (t.join() !== expression.threshold.join()) { setRuleParams(expressionId, { ...expression, threshold: t }); @@ -134,7 +134,7 @@ export const ExpressionRow = ({ ); const updateWarningThreshold = useCallback( - (enteredThreshold) => { + (enteredThreshold: any) => { const t = convertThreshold(enteredThreshold); if (t.join() !== expression.warningThreshold?.join()) { setRuleParams(expressionId, { ...expression, warningThreshold: t }); @@ -165,7 +165,7 @@ export const ExpressionRow = ({ ]); const handleCustomMetricChange = useCallback( - (exp) => { + (exp: any) => { setRuleParams(expressionId, exp); }, [expressionId, setRuleParams] diff --git a/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/dashboards/actions/save_dashboard_modal.tsx b/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/dashboards/actions/save_dashboard_modal.tsx index cda931e81a3fa01..87ff45ef2173c5e 100644 --- a/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/dashboards/actions/save_dashboard_modal.tsx +++ b/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/dashboards/actions/save_dashboard_modal.tsx @@ -91,7 +91,7 @@ export function SaveDashboardModal({ () => setAssetNameFiltersEnabled(!assetNameEnabled), [assetNameEnabled] ); - const onSelect = useCallback((newSelection) => setSelectedDashboard(newSelection), []); + const onSelect = useCallback((newSelection: any) => setSelectedDashboard(newSelection), []); const onClickSave = useCallback( async function () { diff --git a/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/dashboards/dashboards.tsx b/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/dashboards/dashboards.tsx index 2c7aaeafa6878c1..0178d478a85b310 100644 --- a/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/dashboards/dashboards.tsx +++ b/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/dashboards/dashboards.tsx @@ -165,7 +165,7 @@ export function Dashboards() { ]); const getLocatorParams = useCallback( - (params, isFlyoutView) => { + (params: any, isFlyoutView: any) => { const searchParams = new URLSearchParams(location.search); const tableProperties = searchParams.get('tableProperties'); const flyoutParams = diff --git a/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/metadata/table.tsx b/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/metadata/table.tsx index 4d4d2e4c0558895..fedf54a2d10a03d 100644 --- a/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/metadata/table.tsx +++ b/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/metadata/table.tsx @@ -126,7 +126,7 @@ export const Table = ({ loading, rows, onSearchChange, search, showActionsColumn ); const searchBarOnChange = useCallback( - ({ queryText, error }) => { + ({ queryText, error }: any) => { if (error) { setSearchError(error); } else { diff --git a/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/processes/processes.tsx b/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/processes/processes.tsx index d11aab9307ab545..e7666a7f4191ef8 100644 --- a/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/processes/processes.tsx +++ b/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/processes/processes.tsx @@ -110,7 +110,7 @@ export const Processes = () => { }, []); const searchBarOnChange = useCallback( - ({ query, queryText, error: queryError }) => { + ({ query, queryText, error: queryError }: any) => { if (queryError) { setSearchQueryError(queryError); } else { diff --git a/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/processes/processes_table.tsx b/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/processes/processes_table.tsx index 87d4d7d9b5aa730..6d432910c20b34a 100644 --- a/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/processes/processes_table.tsx +++ b/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/processes/processes_table.tsx @@ -66,7 +66,7 @@ function useSortableProperties( return { updateSortableProperties: useCallback( - (property) => { + (property: any) => { sortableProperties.sortOn(property); callback(omit(sortableProperties.getSortedProperty(), 'getValue')); }, diff --git a/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/profiling/profiling.tsx b/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/profiling/profiling.tsx index c31c79f02463506..709d249616f29fb 100644 --- a/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/profiling/profiling.tsx +++ b/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/profiling/profiling.tsx @@ -49,7 +49,7 @@ export function Profiling() { ); const onSearchSubmit = useCallback( - ({ dateRange: range, query }) => { + ({ dateRange: range, query }: any) => { setDateRange(range); setCustomKuery(query); }, diff --git a/x-pack/plugins/observability_solution/infra/public/components/logging/log_analysis_results/analyze_in_ml_button.tsx b/x-pack/plugins/observability_solution/infra/public/components/logging/log_analysis_results/analyze_in_ml_button.tsx index 7550f81112c023c..0751ad3b897fb0c 100644 --- a/x-pack/plugins/observability_solution/infra/public/components/logging/log_analysis_results/analyze_in_ml_button.tsx +++ b/x-pack/plugins/observability_solution/infra/public/components/logging/log_analysis_results/analyze_in_ml_button.tsx @@ -19,7 +19,7 @@ export const AnalyzeInMlButton: React.FunctionComponent<{ } = useKibanaContextForPlugin(); const handleClick = useCallback( - (e) => { + (e: React.MouseEvent) => { if (!href || !shouldHandleLinkEvent(e)) return; application.navigateToUrl(href); }, diff --git a/x-pack/plugins/observability_solution/infra/public/components/logging/log_datepicker.tsx b/x-pack/plugins/observability_solution/infra/public/components/logging/log_datepicker.tsx index db2f90fc52dfc14..097f2fbf755d710 100644 --- a/x-pack/plugins/observability_solution/infra/public/components/logging/log_datepicker.tsx +++ b/x-pack/plugins/observability_solution/infra/public/components/logging/log_datepicker.tsx @@ -6,7 +6,13 @@ */ import React, { useCallback } from 'react'; -import { EuiFlexGroup, EuiFlexItem, EuiSuperDatePicker, EuiButton } from '@elastic/eui'; +import { + EuiFlexGroup, + EuiFlexItem, + EuiSuperDatePicker, + EuiButton, + OnTimeChangeProps, +} from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; interface LogDatepickerProps { @@ -27,7 +33,7 @@ export const LogDatepicker: React.FC = ({ onStopStreaming, }) => { const handleTimeChange = useCallback( - ({ start, end, isInvalid }) => { + ({ start, end, isInvalid }: OnTimeChangeProps) => { if (onUpdateDateRange && !isInvalid) { onUpdateDateRange({ startDateExpression: start, endDateExpression: end }); } diff --git a/x-pack/plugins/observability_solution/infra/public/components/ml/anomaly_detection/anomalies_table/anomalies_table.tsx b/x-pack/plugins/observability_solution/infra/public/components/ml/anomaly_detection/anomalies_table/anomalies_table.tsx index 4e344808c04ef78..fca61d349ce35d2 100644 --- a/x-pack/plugins/observability_solution/infra/public/components/ml/anomaly_detection/anomalies_table/anomalies_table.tsx +++ b/x-pack/plugins/observability_solution/infra/public/components/ml/anomaly_detection/anomalies_table/anomalies_table.tsx @@ -357,7 +357,7 @@ export const AnomaliesTable = ({ setSearch(e.target.value); }, []); - const changeJobType = useCallback((selectedOptions) => { + const changeJobType = useCallback((selectedOptions: any) => { setSelectedJobType(selectedOptions); setJobType(selectedOptions[0].id); }, []); diff --git a/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_categories/sections/top_categories/analyze_dataset_in_ml_action.tsx b/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_categories/sections/top_categories/analyze_dataset_in_ml_action.tsx index a0ee944e5efb570..088f54a14997463 100644 --- a/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_categories/sections/top_categories/analyze_dataset_in_ml_action.tsx +++ b/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_categories/sections/top_categories/analyze_dataset_in_ml_action.tsx @@ -47,7 +47,7 @@ export const AnalyzeCategoryDatasetInMlAction: React.FunctionComponent<{ ); const handleClick = useCallback( - (e) => { + (e: React.MouseEvent) => { if (!viewAnomalyInMachineLearningLink || !shouldHandleLinkEvent(e)) return; application.navigateToUrl(viewAnomalyInMachineLearningLink); }, diff --git a/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_categories/sections/top_categories/top_categories_table.tsx b/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_categories/sections/top_categories/top_categories_table.tsx index f119a08cbd10a2d..78486723913158c 100644 --- a/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_categories/sections/top_categories/top_categories_table.tsx +++ b/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_categories/sections/top_categories/top_categories_table.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { EuiBasicTable, EuiBasicTableColumn } from '@elastic/eui'; +import { Criteria, EuiBasicTable, EuiBasicTableColumn } from '@elastic/eui'; import numeral from '@elastic/numeral'; import { i18n } from '@kbn/i18n'; import React, { useMemo, useCallback } from 'react'; @@ -14,6 +14,7 @@ import useSet from 'react-use/lib/useSet'; import { euiStyled } from '@kbn/kibana-react-plugin/common'; import { PersistedLogViewReference } from '@kbn/logs-shared-plugin/common'; import { + categoriesSortRT, LogEntryCategory, LogEntryCategoryDataset, LogEntryCategoryHistogram, @@ -51,8 +52,10 @@ export const TopCategoriesTable = euiStyled( }, [sortOptions]); const handleTableChange = useCallback( - ({ sort = {} }) => { - changeSortOptions(sort); + ({ sort }: Criteria) => { + if (categoriesSortRT.is(sort)) { + changeSortOptions(sort); + } }, [changeSortOptions] ); diff --git a/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_rate/sections/anomalies/log_entry_example.tsx b/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_rate/sections/anomalies/log_entry_example.tsx index ad5601846f339ce..6c545beb4b9cd4a 100644 --- a/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_rate/sections/anomalies/log_entry_example.tsx +++ b/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_rate/sections/anomalies/log_entry_example.tsx @@ -139,7 +139,7 @@ export const LogEntryExampleMessage: React.FunctionComponent = ({ }); const handleMlLinkClick = useCallback( - (e) => { + (e: React.MouseEvent) => { if (!viewAnomalyInMachineLearningLink || !shouldHandleLinkEvent(e)) return; application.navigateToUrl(viewAnomalyInMachineLearningLink); }, diff --git a/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_rate/sections/anomalies/table.tsx b/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_rate/sections/anomalies/table.tsx index e3f7767662a097e..a0c8eb762e9f1c0 100644 --- a/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_rate/sections/anomalies/table.tsx +++ b/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_rate/sections/anomalies/table.tsx @@ -6,42 +6,44 @@ */ import { + Criteria, EuiBasicTable, EuiBasicTableColumn, - EuiIcon, + EuiButtonIcon, EuiFlexGroup, EuiFlexItem, - EuiButtonIcon, + EuiIcon, EuiSpacer, RIGHT_ALIGNMENT, } from '@elastic/eui'; -import moment from 'moment'; import { i18n } from '@kbn/i18n'; +import moment from 'moment'; import React, { useCallback, useMemo } from 'react'; import useSet from 'react-use/lib/useSet'; -import { TimeRange } from '../../../../../../common/time/time_range'; import { + anomaliesSortRT, AnomalyType, - getFriendlyNameForPartitionId, formatOneDecimalPlace, + getFriendlyNameForPartitionId, isCategoryAnomaly, } from '../../../../../../common/log_analysis'; +import { TimeRange } from '../../../../../../common/time/time_range'; import { RowExpansionButton } from '../../../../../components/basic_table'; -import { AnomaliesTableExpandedRow } from './expanded_row'; +import { LoadingOverlayWrapper } from '../../../../../components/loading_overlay_wrapper'; import { AnomalySeverityIndicator } from '../../../../../components/logging/log_analysis_results/anomaly_severity_indicator'; import { RegularExpressionRepresentation } from '../../../../../components/logging/log_analysis_results/category_expression'; import { useKibanaUiSetting } from '../../../../../hooks/use_kibana_ui_setting'; import { - Page, + ChangePaginationOptions, + ChangeSortOptions, FetchNextPage, FetchPreviousPage, - ChangeSortOptions, - ChangePaginationOptions, - SortOptions, - PaginationOptions, LogEntryAnomalies, + Page, + PaginationOptions, + SortOptions, } from '../../use_log_entry_anomalies_results'; -import { LoadingOverlayWrapper } from '../../../../../components/loading_overlay_wrapper'; +import { AnomaliesTableExpandedRow } from './expanded_row'; interface TableItem { id: string; @@ -146,8 +148,10 @@ export const AnomaliesTable: React.FunctionComponent<{ ); const handleTableChange = useCallback( - ({ sort = {} }) => { - changeSortOptions(sort); + ({ sort }: Criteria) => { + if (anomaliesSortRT.is(sort)) { + changeSortOptions(sort); + } }, [changeSortOptions] ); diff --git a/x-pack/plugins/observability_solution/infra/public/pages/logs/settings/log_columns_configuration_panel.tsx b/x-pack/plugins/observability_solution/infra/public/pages/logs/settings/log_columns_configuration_panel.tsx index 97fd485fac24c54..931219dc0bce400 100644 --- a/x-pack/plugins/observability_solution/infra/public/pages/logs/settings/log_columns_configuration_panel.tsx +++ b/x-pack/plugins/observability_solution/infra/public/pages/logs/settings/log_columns_configuration_panel.tsx @@ -57,7 +57,7 @@ export const LogColumnsConfigurationPanel = React.memo<{ ); const moveLogColumn = useCallback( - (sourceIndex, destinationIndex) => { + (sourceIndex: number, destinationIndex: number) => { logColumnsFormElement.updateValue((logColumns) => { if (destinationIndex >= 0 && sourceIndex <= logColumnsFormElement.value.length - 1) { const newLogColumns = [...logColumnsFormElement.value]; @@ -189,6 +189,8 @@ const TimestampLogColumnConfigurationPanel: React.FunctionComponent< id="xpack.infra.sourceConfiguration.timestampLogColumnDescription" defaultMessage="This system field shows the log entry's time as determined by the {timestampSetting} field setting." values={{ + // this is a settings key and should not be translated + // eslint-disable-next-line @kbn/i18n/strings_should_be_translated_with_i18n timestampSetting: timestamp, }} /> diff --git a/x-pack/plugins/observability_solution/infra/public/pages/logs/stream/page_logs_content.tsx b/x-pack/plugins/observability_solution/infra/public/pages/logs/stream/page_logs_content.tsx index 7184b0c9ecf37d5..d40014ed4468b04 100644 --- a/x-pack/plugins/observability_solution/infra/public/pages/logs/stream/page_logs_content.tsx +++ b/x-pack/plugins/observability_solution/infra/public/pages/logs/stream/page_logs_content.tsx @@ -13,10 +13,12 @@ import { LogEntryFlyout, LogEntryStreamItem, ScrollableLogTextStreamView, + UpdatedDateRange, useLogHighlightsStateContext, useLogPositionStateContext, useLogStreamContext, useLogViewContext, + VisibleInterval, WithSummary, WithSummaryProps, } from '@kbn/logs-shared-plugin/public'; @@ -173,11 +175,11 @@ export const StreamPageLogsContent = React.memo<{ const [, { setContextEntry }] = useViewLogInProviderContext(); const handleDateRangeExtension = useCallback( - (newDateRange) => { + (newDateRange: UpdatedDateRange) => { updateDateRange(newDateRange); if ( - 'startDateExpression' in newDateRange && + newDateRange.startDateExpression != null && isValidDatemath(newDateRange.startDateExpression) ) { fetchPreviousEntries({ @@ -185,7 +187,10 @@ export const StreamPageLogsContent = React.memo<{ extendTo: datemathToEpochMillis(newDateRange.startDateExpression)!, }); } - if ('endDateExpression' in newDateRange && isValidDatemath(newDateRange.endDateExpression)) { + if ( + newDateRange.endDateExpression != null && + isValidDatemath(newDateRange.endDateExpression) + ) { fetchNextEntries({ force: true, extendTo: datemathToEpochMillis(newDateRange.endDateExpression)!, @@ -196,7 +201,7 @@ export const StreamPageLogsContent = React.memo<{ ); const handlePagination = useCallback( - (params) => { + (params: VisibleInterval) => { reportVisiblePositions(params); if (!params.fromScroll) { return; diff --git a/x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/components/waffle/legend_controls.tsx b/x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/components/waffle/legend_controls.tsx index 92c57e94599163d..7b81056b32b8f1d 100644 --- a/x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/components/waffle/legend_controls.tsx +++ b/x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/components/waffle/legend_controls.tsx @@ -27,6 +27,7 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { euiStyled } from '@kbn/kibana-react-plugin/common'; import React, { SyntheticEvent, useState, useCallback, useEffect } from 'react'; import { first, last } from 'lodash'; +import { EuiRangeProps, EuiSelectProps } from '@elastic/eui'; import type { WaffleLegendOptions } from '../../hooks/use_waffle_options'; import { type InfraWaffleMapBounds, @@ -148,17 +149,17 @@ export const LegendControls = ({ setPopoverState(false); }, [autoBounds, boundsOverride, options]); - const handleStepsChange = useCallback( + const handleStepsChange = useCallback>( (e) => { - const steps = parseInt(e.target.value, 10); + const steps = parseInt((e.target as HTMLInputElement).value, 10); setLegendOptions((previous) => ({ ...previous, steps })); }, [setLegendOptions] ); - const handlePaletteChange = useCallback( + const handlePaletteChange = useCallback>( (e) => { - const palette = e.target.value; + const palette = e.target.value as WaffleLegendOptions['palette']; setLegendOptions((previous) => ({ ...previous, palette })); }, [setLegendOptions] diff --git a/x-pack/plugins/observability_solution/infra/public/pages/metrics/metrics_explorer/components/aggregation.tsx b/x-pack/plugins/observability_solution/infra/public/pages/metrics/metrics_explorer/components/aggregation.tsx index 582c52a969ac3e8..9a24e0b0cd0e662 100644 --- a/x-pack/plugins/observability_solution/infra/public/pages/metrics/metrics_explorer/components/aggregation.tsx +++ b/x-pack/plugins/observability_solution/infra/public/pages/metrics/metrics_explorer/components/aggregation.tsx @@ -10,6 +10,7 @@ import { i18n } from '@kbn/i18n'; import React, { useCallback } from 'react'; import { xor } from 'lodash'; +import { EuiSelectProps } from '@elastic/eui'; import { MetricsExplorerAggregation } from '../../../../../common/http_api/metrics_explorer'; import { MetricsExplorerOptions } from '../hooks/use_metrics_explorer_options'; import { @@ -56,7 +57,7 @@ export const MetricsExplorerAggregationPicker = ({ options, onChange }: Props) = }), }; - const handleChange = useCallback( + const handleChange = useCallback>( (e) => { const aggregation = (metricsExplorerAggregationRT.is(e.target.value) && e.target.value) || 'avg'; diff --git a/x-pack/plugins/observability_solution/infra/public/pages/metrics/metrics_explorer/components/chart_options.tsx b/x-pack/plugins/observability_solution/infra/public/pages/metrics/metrics_explorer/components/chart_options.tsx index abd82b4e74a9042..01471fab526aeb8 100644 --- a/x-pack/plugins/observability_solution/infra/public/pages/metrics/metrics_explorer/components/chart_options.tsx +++ b/x-pack/plugins/observability_solution/infra/public/pages/metrics/metrics_explorer/components/chart_options.tsx @@ -15,6 +15,7 @@ import { EuiForm, EuiFormRow, EuiSwitch, + EuiSwitchProps, } from '@elastic/eui'; import { MetricsExplorerChartOptions as ChartOptions, @@ -111,7 +112,7 @@ export const MetricsExplorerChartOptions = ({ chartOptions, onChange }: Props) = [chartOptions, onChange] ); - const handleStackChange = useCallback( + const handleStackChange = useCallback( (e) => { onChange({ ...chartOptions, diff --git a/x-pack/plugins/observability_solution/infra/public/pages/metrics/metrics_explorer/components/metrics.tsx b/x-pack/plugins/observability_solution/infra/public/pages/metrics/metrics_explorer/components/metrics.tsx index 4e2764d9222e093..c493d2922359b75 100644 --- a/x-pack/plugins/observability_solution/infra/public/pages/metrics/metrics_explorer/components/metrics.tsx +++ b/x-pack/plugins/observability_solution/infra/public/pages/metrics/metrics_explorer/components/metrics.tsx @@ -60,7 +60,7 @@ export const MetricsExplorerMetrics = ({ options, onChange, autoFocus = false }: ); const handleChange = useCallback( - (selectedOptions) => { + (selectedOptions: any) => { onChange( selectedOptions.map((opt: SelectedOption, index: number) => ({ aggregation: options.aggregation, diff --git a/x-pack/plugins/observability_solution/logs_shared/public/components/logging/log_entry_flyout/log_entry_flyout.tsx b/x-pack/plugins/observability_solution/logs_shared/public/components/logging/log_entry_flyout/log_entry_flyout.tsx index ffb1881122540b6..952ee959e4a727a 100644 --- a/x-pack/plugins/observability_solution/logs_shared/public/components/logging/log_entry_flyout/log_entry_flyout.tsx +++ b/x-pack/plugins/observability_solution/logs_shared/public/components/logging/log_entry_flyout/log_entry_flyout.tsx @@ -51,7 +51,7 @@ export const useLogEntryFlyout = (logViewReference: LogViewReference) => { }, []); const openLogEntryFlyout = useCallback( - (logEntryId) => { + (logEntryId: string | null | undefined) => { const { Provider: KibanaReactContextProvider } = createKibanaReactContext({ http, data, diff --git a/x-pack/plugins/observability_solution/logs_shared/public/components/logging/log_text_stream/index.ts b/x-pack/plugins/observability_solution/logs_shared/public/components/logging/log_text_stream/index.ts index c4507a2b4ebc549..6468ea3d94d2289 100644 --- a/x-pack/plugins/observability_solution/logs_shared/public/components/logging/log_text_stream/index.ts +++ b/x-pack/plugins/observability_solution/logs_shared/public/components/logging/log_text_stream/index.ts @@ -17,3 +17,4 @@ export { LogEntryMessageColumn } from './log_entry_message_column'; export { LogEntryRowWrapper } from './log_entry_row_wrapper'; export { LogEntryTimestampColumn } from './log_entry_timestamp_column'; export { ScrollableLogTextStreamView } from './scrollable_log_text_stream_view'; +export type { UpdatedDateRange, VisibleInterval } from './scrollable_log_text_stream_view'; diff --git a/x-pack/plugins/observability_solution/logs_shared/public/components/logging/log_text_stream/scrollable_log_text_stream_view.tsx b/x-pack/plugins/observability_solution/logs_shared/public/components/logging/log_text_stream/scrollable_log_text_stream_view.tsx index fdb0d6a88f8a5d7..6fe7260e8c7e247 100644 --- a/x-pack/plugins/observability_solution/logs_shared/public/components/logging/log_text_stream/scrollable_log_text_stream_view.tsx +++ b/x-pack/plugins/observability_solution/logs_shared/public/components/logging/log_text_stream/scrollable_log_text_stream_view.tsx @@ -28,6 +28,20 @@ import { LogDateRow } from './log_date_row'; import { LogEntry } from '../../../../common/log_entry'; import { LogColumnRenderConfiguration } from '../../../utils/log_column_render_configuration'; +export interface VisibleInterval { + pagesBeforeStart: number; + pagesAfterEnd: number; + startKey: TimeKey | null; + middleKey: TimeKey | null; + endKey: TimeKey | null; + fromScroll: boolean; +} + +export interface UpdatedDateRange { + startDateExpression?: string; + endDateExpression?: string; +} + export interface ScrollableLogTextStreamViewProps { columnConfigurations: LogColumnRenderConfiguration[]; items: StreamItem[]; @@ -41,14 +55,7 @@ export interface ScrollableLogTextStreamViewProps { lastLoadedTime?: Date; target: TimeKey | null; jumpToTarget: (target: TimeKey) => any; - reportVisibleInterval: (params: { - pagesBeforeStart: number; - pagesAfterEnd: number; - startKey: TimeKey | null; - middleKey: TimeKey | null; - endKey: TimeKey | null; - fromScroll: boolean; - }) => any; + reportVisibleInterval: (params: VisibleInterval) => any; reloadItems: () => void; onOpenLogEntryFlyout?: (logEntryId?: string) => void; setContextEntry?: (entry: LogEntry) => void; @@ -56,7 +63,7 @@ export interface ScrollableLogTextStreamViewProps { currentHighlightKey: UniqueTimeKey | null; startDateExpression: string; endDateExpression: string; - updateDateRange: (range: { startDateExpression?: string; endDateExpression?: string }) => void; + updateDateRange: (range: UpdatedDateRange) => void; startLiveStreaming: () => void; hideScrollbar?: boolean; } diff --git a/x-pack/plugins/observability_solution/logs_shared/public/index.ts b/x-pack/plugins/observability_solution/logs_shared/public/index.ts index 80b8dd3638924f4..7a0f731b4a93b62 100644 --- a/x-pack/plugins/observability_solution/logs_shared/public/index.ts +++ b/x-pack/plugins/observability_solution/logs_shared/public/index.ts @@ -46,6 +46,10 @@ export { } from './components/logging/log_text_stream/log_entry_column'; export type { LogAIAssistantProps } from './components/log_ai_assistant/log_ai_assistant'; export type { LogStreamProps } from './components/log_stream/log_stream'; +export type { + UpdatedDateRange, + VisibleInterval, +} from './components/logging/log_text_stream/scrollable_log_text_stream_view'; export const WithSummary = dynamic(() => import('./containers/logs/log_summary/with_summary')); export const LogEntryFlyout = dynamic( diff --git a/x-pack/plugins/observability_solution/observability/public/components/custom_threshold/components/expression_row.tsx b/x-pack/plugins/observability_solution/observability/public/components/custom_threshold/components/expression_row.tsx index ffeaf3aef61cbd9..d98b0a69d984f64 100644 --- a/x-pack/plugins/observability_solution/observability/public/components/custom_threshold/components/expression_row.tsx +++ b/x-pack/plugins/observability_solution/observability/public/components/custom_threshold/components/expression_row.tsx @@ -73,13 +73,13 @@ export const ExpressionRow: React.FC = (props) => { ); const convertThreshold = useCallback( - (enteredThreshold) => + (enteredThreshold: any) => isMetricPct ? enteredThreshold.map((v: number) => pctToDecimal(v)) : enteredThreshold, [isMetricPct] ); const updateThreshold = useCallback( - (enteredThreshold) => { + (enteredThreshold: any) => { const t = convertThreshold(enteredThreshold); if (t.join() !== expression.threshold.join()) { setRuleParams(expressionId, { ...expression, threshold: t }); @@ -89,7 +89,7 @@ export const ExpressionRow: React.FC = (props) => { ); const handleCustomMetricChange = useCallback( - (exp) => { + (exp: any) => { setRuleParams(expressionId, exp); }, [expressionId, setRuleParams] diff --git a/x-pack/plugins/observability_solution/observability/public/components/custom_threshold/custom_threshold_rule_expression.tsx b/x-pack/plugins/observability_solution/observability/public/components/custom_threshold/custom_threshold_rule_expression.tsx index bbbcb5905782479..747abedfc0f3553 100644 --- a/x-pack/plugins/observability_solution/observability/public/components/custom_threshold/custom_threshold_rule_expression.tsx +++ b/x-pack/plugins/observability_solution/observability/public/components/custom_threshold/custom_threshold_rule_expression.tsx @@ -219,7 +219,7 @@ export default function Expressions(props: Props) { ); const updateParams = useCallback( - (id, e: MetricExpression) => { + (id: any, e: MetricExpression) => { const ruleCriteria = ruleParams.criteria ? ruleParams.criteria.slice() : []; ruleCriteria[id] = e; setRuleParams('criteria', ruleCriteria); diff --git a/x-pack/plugins/observability_solution/observability/public/context/date_picker_context/date_picker_context.tsx b/x-pack/plugins/observability_solution/observability/public/context/date_picker_context/date_picker_context.tsx index b31b48456a564b0..3a7b3ed89b21244 100644 --- a/x-pack/plugins/observability_solution/observability/public/context/date_picker_context/date_picker_context.tsx +++ b/x-pack/plugins/observability_solution/observability/public/context/date_picker_context/date_picker_context.tsx @@ -108,7 +108,7 @@ export function DatePickerContextProvider({ children }: { children: React.ReactE ); const updateRefreshInterval = useCallback( - ({ interval, isPaused }) => { + ({ interval, isPaused }: any) => { updateUrl({ refreshInterval: interval, refreshPaused: isPaused }); data.query.timefilter.timefilter.setRefreshInterval({ value: interval, pause: isPaused }); setLastUpdated(Date.now()); diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitor_add_edit/fields/request_body_field.test.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitor_add_edit/fields/request_body_field.test.tsx index 2882104dbcb93ed..7740a346ca9971d 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitor_add_edit/fields/request_body_field.test.tsx +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitor_add_edit/fields/request_body_field.test.tsx @@ -34,7 +34,7 @@ describe('', () => { type: config.type, }} onChange={useCallback( - (code) => setConfig({ type: code.type as CodeEditorMode, value: code.value }), + (code: any) => setConfig({ type: code.type as CodeEditorMode, value: code.value }), [setConfig] )} readOnly={readOnly} diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitor_details/monitor_history/monitor_history.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitor_details/monitor_history/monitor_history.tsx index 8420df9b15f8199..fc151db70d1ee71 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitor_details/monitor_history/monitor_history.tsx +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitor_details/monitor_history/monitor_history.tsx @@ -35,7 +35,7 @@ export const MonitorHistory = () => { const statsColumns = statsWidth && statsWidth < STATS_WIDTH_SINGLE_COLUMN_THRESHOLD ? 1 : 2; const handleStatusChartBrushed = useCallback( - ({ fromUtc, toUtc }) => { + ({ fromUtc, toUtc }: any) => { updateUrlParams({ dateRangeStart: fromUtc, dateRangeEnd: toUtc }); }, [updateUrlParams] diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/monitor_detail_flyout.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/monitor_detail_flyout.tsx index 78ac9dd2f663f42..cf2f6cb97d82e80 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/monitor_detail_flyout.tsx +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/monitor_detail_flyout.tsx @@ -187,7 +187,7 @@ function DetailedFlyoutHeader({ configId={configId} selectedLocation={selectedLocation} onChange={useCallback( - (id, label) => { + (id: any, label: any) => { if (currentLocation !== label) setCurrentLocation(label, id); }, [currentLocation, setCurrentLocation] diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/step_details_page/step_waterfall_chart/waterfall/waterfall_chart_wrapper.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/step_details_page/step_waterfall_chart/waterfall/waterfall_chart_wrapper.tsx index ed5a6b73d411ef7..4f155d56db833df 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/step_details_page/step_waterfall_chart/waterfall/waterfall_chart_wrapper.tsx +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/step_details_page/step_waterfall_chart/waterfall/waterfall_chart_wrapper.tsx @@ -127,14 +127,14 @@ export const WaterfallChartWrapper: React.FC = ({ setShowCustomMarks={setShowCustomMarks} query={query} setQuery={setQuery} - renderTooltipItem={useCallback((tooltipProps) => { + renderTooltipItem={useCallback((tooltipProps: any) => { return {tooltipProps?.value}; }, [])} > `${Number(d).toFixed(0)} ms`, [])} domain={domain} - barStyleAccessor={useCallback(({ datum }) => { + barStyleAccessor={useCallback(({ datum }: any) => { if (!datum.config?.isHighlighted) { return { rect: { diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/step_details_page/step_waterfall_chart/waterfall/waterfall_sidebar_item.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/step_details_page/step_waterfall_chart/waterfall/waterfall_sidebar_item.tsx index 60898420c84b2da..a5d26e33a9b5ab2 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/step_details_page/step_waterfall_chart/waterfall/waterfall_sidebar_item.tsx +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/step_details_page/step_waterfall_chart/waterfall/waterfall_sidebar_item.tsx @@ -35,7 +35,7 @@ export const WaterfallSidebarItem = React.memo(function WaterfallSidebarItem({ } }, [buttonRef, index, onClick]); - const setRef = useCallback((ref) => setButtonRef(ref), [setButtonRef]); + const setRef = useCallback((ref: any) => setButtonRef(ref), [setButtonRef]); const isErrorStatusCode = (statusCode: number) => { const is400 = statusCode >= 400 && statusCode <= 499; diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/test_now_mode/test_now_mode_flyout_container.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/test_now_mode/test_now_mode_flyout_container.tsx index b550cdbd2745e68..b710da8cfcba75d 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/test_now_mode/test_now_mode_flyout_container.tsx +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/test_now_mode/test_now_mode_flyout_container.tsx @@ -26,7 +26,7 @@ export function TestNowModeFlyoutContainer() { const flyoutOpenTestRun = useTestFlyoutOpen(); const onDone = useCallback( - (testRunId) => { + (testRunId: any) => { dispatch( manualTestRunUpdateAction({ testRunId, @@ -39,7 +39,7 @@ export function TestNowModeFlyoutContainer() { ); const handleFlyoutClose = useCallback( - (testRunId) => { + (testRunId: any) => { dispatch( manualTestRunUpdateAction({ testRunId, diff --git a/x-pack/plugins/observability_solution/synthetics/public/hooks/use_form_wrapped.tsx b/x-pack/plugins/observability_solution/synthetics/public/hooks/use_form_wrapped.tsx index 97a5d7433714488..354f3f6e21c2eb3 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/hooks/use_form_wrapped.tsx +++ b/x-pack/plugins/observability_solution/synthetics/public/hooks/use_form_wrapped.tsx @@ -41,7 +41,7 @@ export function useFormWrapped { + (name: any, ...registerArgs: any) => { const { ref, onChange, ...restOfRegister } = register(name, ...registerArgs); return { diff --git a/x-pack/plugins/observability_solution/uptime/public/legacy_uptime/components/monitor/synthetics/step_detail/waterfall/waterfall_chart_wrapper.tsx b/x-pack/plugins/observability_solution/uptime/public/legacy_uptime/components/monitor/synthetics/step_detail/waterfall/waterfall_chart_wrapper.tsx index 669d615dd647978..2cde284fd7afa59 100644 --- a/x-pack/plugins/observability_solution/uptime/public/legacy_uptime/components/monitor/synthetics/step_detail/waterfall/waterfall_chart_wrapper.tsx +++ b/x-pack/plugins/observability_solution/uptime/public/legacy_uptime/components/monitor/synthetics/step_detail/waterfall/waterfall_chart_wrapper.tsx @@ -129,14 +129,14 @@ export const WaterfallChartWrapper: React.FC = ({ sidebarItems={sidebarItems} legendItems={legendItems} metadata={metadata} - renderTooltipItem={useCallback((tooltipProps) => { + renderTooltipItem={useCallback((tooltipProps: any) => { return {tooltipProps?.value}; }, [])} > `${Number(d).toFixed(0)} ms`, [])} domain={domain} - barStyleAccessor={useCallback(({ datum }) => { + barStyleAccessor={useCallback(({ datum }: any) => { if (!datum.config?.isHighlighted) { return { rect: { diff --git a/x-pack/plugins/observability_solution/uptime/public/legacy_uptime/components/monitor/synthetics/step_detail/waterfall/waterfall_sidebar_item.tsx b/x-pack/plugins/observability_solution/uptime/public/legacy_uptime/components/monitor/synthetics/step_detail/waterfall/waterfall_sidebar_item.tsx index 193fe3312163656..249edeaa8f3a13b 100644 --- a/x-pack/plugins/observability_solution/uptime/public/legacy_uptime/components/monitor/synthetics/step_detail/waterfall/waterfall_sidebar_item.tsx +++ b/x-pack/plugins/observability_solution/uptime/public/legacy_uptime/components/monitor/synthetics/step_detail/waterfall/waterfall_sidebar_item.tsx @@ -35,7 +35,7 @@ export const WaterfallSidebarItem = ({ } }, [buttonRef, index, onClick]); - const setRef = useCallback((ref) => setButtonRef(ref), [setButtonRef]); + const setRef = useCallback((ref: any) => setButtonRef(ref), [setButtonRef]); const isErrorStatusCode = (statusCode: number) => { const is400 = statusCode >= 400 && statusCode <= 499; diff --git a/x-pack/plugins/observability_solution/ux/public/components/app/rum_dashboard/charts/visitor_breakdown_chart.tsx b/x-pack/plugins/observability_solution/ux/public/components/app/rum_dashboard/charts/visitor_breakdown_chart.tsx index 2c32df316efc730..71738fbe246f985 100644 --- a/x-pack/plugins/observability_solution/ux/public/components/app/rum_dashboard/charts/visitor_breakdown_chart.tsx +++ b/x-pack/plugins/observability_solution/ux/public/components/app/rum_dashboard/charts/visitor_breakdown_chart.tsx @@ -70,7 +70,7 @@ export function VisitorBreakdownChart({ ); const filterHandler = useCallback( - (event) => { + (event: any) => { onFilter(metric, event); }, [onFilter, metric] diff --git a/x-pack/plugins/osquery/public/action_results/action_results_summary.tsx b/x-pack/plugins/osquery/public/action_results/action_results_summary.tsx index 6b9581249a07541..3a53b3c2d9f1fca 100644 --- a/x-pack/plugins/osquery/public/action_results/action_results_summary.tsx +++ b/x-pack/plugins/osquery/public/action_results/action_results_summary.tsx @@ -78,10 +78,13 @@ const ActionResultsSummaryComponent: React.FC = ({ } }, [edges, error, expired]); - const renderAgentIdColumn = useCallback((agentId) => , []); - const renderRowsColumn = useCallback((rowsCount) => rowsCount ?? '-', []); + const renderAgentIdColumn = useCallback( + (agentId: any) => , + [] + ); + const renderRowsColumn = useCallback((rowsCount: any) => rowsCount ?? '-', []); const renderStatusColumn = useCallback( - (_, item) => { + (_: any, item: any) => { if (item.fields['error.skipped']) { return i18n.translate('xpack.osquery.liveQueryActionResults.table.skippedStatusText', { defaultMessage: 'skipped', diff --git a/x-pack/plugins/osquery/public/actions/actions_table.tsx b/x-pack/plugins/osquery/public/actions/actions_table.tsx index a6c66855f12cc67..a2b654b310c1e21 100644 --- a/x-pack/plugins/osquery/public/actions/actions_table.tsx +++ b/x-pack/plugins/osquery/public/actions/actions_table.tsx @@ -66,14 +66,14 @@ const ActionsTableComponent = () => { kuery: 'user_id: *', }); - const onTableChange = useCallback(({ page = {} }) => { + const onTableChange = useCallback(({ page = {} }: any) => { const { index, size } = page; setPageIndex(index); setPageSize(size); }, []); - const renderQueryColumn = useCallback((_, item) => { + const renderQueryColumn = useCallback((_: any, item: any) => { if (item._source.pack_name) { return ( @@ -96,22 +96,28 @@ const ActionsTableComponent = () => { ); }, []); - const renderAgentsColumn = useCallback((_, item) => <>{item.fields.agents?.length ?? 0}, []); + const renderAgentsColumn = useCallback( + (_: any, item: any) => <>{item.fields.agents?.length ?? 0}, + [] + ); - const renderCreatedByColumn = useCallback((userId) => (isArray(userId) ? userId[0] : '-'), []); + const renderCreatedByColumn = useCallback( + (userId: any) => (isArray(userId) ? userId[0] : '-'), + [] + ); const renderTimestampColumn = useCallback( - (_, item) => <>{formatDate(item.fields['@timestamp'][0])}, + (_: any, item: any) => <>{formatDate(item.fields['@timestamp'][0])}, [] ); const renderActionsColumn = useCallback( - (item) => , + (item: any) => , [] ); const handlePlayClick = useCallback( - (item) => () => { + (item: any) => () => { const packId = item._source.pack_id; if (packId) { @@ -152,7 +158,7 @@ const ActionsTableComponent = () => { [push] ); const renderPlayButton = useCallback( - (item, enabled) => { + (item: any, enabled: any) => { const playText = i18n.translate('xpack.osquery.liveQueryActions.table.runActionAriaLabel', { defaultMessage: 'Run query', }); @@ -174,7 +180,7 @@ const ActionsTableComponent = () => { const existingPackIds = useMemo(() => map(packsData?.data ?? [], 'id'), [packsData]); const isPlayButtonAvailable = useCallback( - (item) => { + (item: any) => { if (item.fields.pack_id?.length) { return ( existingPackIds.includes(item.fields.pack_id[0]) && @@ -260,7 +266,7 @@ const ActionsTableComponent = () => { ); const rowProps = useCallback( - (data) => ({ + (data: any) => ({ 'data-test-subj': `row-${data._source.action_id}`, }), [] diff --git a/x-pack/plugins/osquery/public/agent_policies/agents_policy_link.tsx b/x-pack/plugins/osquery/public/agent_policies/agents_policy_link.tsx index c471d9ffcd1bc61..722a0ee2073b7d5 100644 --- a/x-pack/plugins/osquery/public/agent_policies/agents_policy_link.tsx +++ b/x-pack/plugins/osquery/public/agent_policies/agents_policy_link.tsx @@ -38,7 +38,7 @@ const AgentsPolicyLinkComponent: React.FC = ({ policyId } ); const handleClick = useCallback( - (event) => { + (event: any) => { if (!isModifiedEvent(event) && isLeftClickEvent(event)) { event.preventDefault(); diff --git a/x-pack/plugins/osquery/public/agents/agents_table.tsx b/x-pack/plugins/osquery/public/agents/agents_table.tsx index ff9b89f73543b9e..913876e7019ef92 100644 --- a/x-pack/plugins/osquery/public/agents/agents_table.tsx +++ b/x-pack/plugins/osquery/public/agents/agents_table.tsx @@ -173,7 +173,7 @@ const AgentsTableComponent: React.FC = ({ agentSelection, onCh } }, [agentList?.agents, agentList?.groups, agentList?.total, agentsFetched, searchValue]); - const renderOption = useCallback((option, searchVal, contentClassName) => { + const renderOption = useCallback((option: any, searchVal: any, contentClassName: any) => { const { label, value } = option; return value?.groupType === AGENT_GROUP_KEY.Agent ? ( diff --git a/x-pack/plugins/osquery/public/components/empty_state.tsx b/x-pack/plugins/osquery/public/components/empty_state.tsx index 18f5afe8eaf5fdc..9a25443d4aaf227 100644 --- a/x-pack/plugins/osquery/public/components/empty_state.tsx +++ b/x-pack/plugins/osquery/public/components/empty_state.tsx @@ -35,7 +35,7 @@ const OsqueryAppEmptyStateComponent = () => { ); const integrationClick = useCallback( - (event) => { + (event: any) => { if (!isModifiedEvent(event) && isLeftClickEvent(event)) { event.preventDefault(); diff --git a/x-pack/plugins/osquery/public/components/manage_integration_link.tsx b/x-pack/plugins/osquery/public/components/manage_integration_link.tsx index 44ae6421a6c25b2..5c8141d5b8bb93e 100644 --- a/x-pack/plugins/osquery/public/components/manage_integration_link.tsx +++ b/x-pack/plugins/osquery/public/components/manage_integration_link.tsx @@ -30,7 +30,7 @@ const ManageIntegrationLinkComponent = () => { ); const integrationClick = useCallback( - (event) => { + (event: any) => { if (!isModifiedEvent(event) && isLeftClickEvent(event)) { event.preventDefault(); diff --git a/x-pack/plugins/osquery/public/fleet_integration/config_uploader.tsx b/x-pack/plugins/osquery/public/fleet_integration/config_uploader.tsx index 3d5b042769d8d1f..67370b42fe01872 100644 --- a/x-pack/plugins/osquery/public/fleet_integration/config_uploader.tsx +++ b/x-pack/plugins/osquery/public/fleet_integration/config_uploader.tsx @@ -75,7 +75,7 @@ const ConfigUploaderComponent: React.FC = ({ onChange }) => }; const handleInputChange = useCallback( - (inputFiles) => { + (inputFiles: any) => { if (!inputFiles.length) { return; } diff --git a/x-pack/plugins/osquery/public/fleet_integration/navigation_buttons.tsx b/x-pack/plugins/osquery/public/fleet_integration/navigation_buttons.tsx index 4da470270de76bd..cab1ca3beece1ff 100644 --- a/x-pack/plugins/osquery/public/fleet_integration/navigation_buttons.tsx +++ b/x-pack/plugins/osquery/public/fleet_integration/navigation_buttons.tsx @@ -36,7 +36,7 @@ const NavigationButtonsComponent: React.FC = ({ ); const liveQueryClick = useCallback( - (event) => { + (event: any) => { if (!isModifiedEvent(event) && isLeftClickEvent(event)) { event.preventDefault(); navigateToApp(PLUGIN_ID, { @@ -54,7 +54,7 @@ const NavigationButtonsComponent: React.FC = ({ }); const packsClick = useCallback( - (event) => { + (event: any) => { if (!isModifiedEvent(event) && isLeftClickEvent(event)) { event.preventDefault(); navigateToApp(PLUGIN_ID, { diff --git a/x-pack/plugins/osquery/public/fleet_integration/osquery_managed_policy_create_import_extension.tsx b/x-pack/plugins/osquery/public/fleet_integration/osquery_managed_policy_create_import_extension.tsx index 8c41771b6f194b8..732c47fcdcfa7c8 100644 --- a/x-pack/plugins/osquery/public/fleet_integration/osquery_managed_policy_create_import_extension.tsx +++ b/x-pack/plugins/osquery/public/fleet_integration/osquery_managed_policy_create_import_extension.tsx @@ -194,7 +194,7 @@ export const OsqueryManagedPolicyCreateImportExtension = React.memo< }, [getUrlForApp, policy?.policy_id]); const handleConfigUpload = useCallback( - (newConfig) => { + (newConfig: any) => { let currentPacks = {}; try { currentPacks = JSON.parse(config)?.packs; diff --git a/x-pack/plugins/osquery/public/form/results_type_field.tsx b/x-pack/plugins/osquery/public/form/results_type_field.tsx index 37fe9d9ceee385a..43eb9b88ca82393 100644 --- a/x-pack/plugins/osquery/public/form/results_type_field.tsx +++ b/x-pack/plugins/osquery/public/form/results_type_field.tsx @@ -74,7 +74,7 @@ const ResultsTypeFieldComponent: React.FC = ({ euiFieldPr }); const handleChange = useCallback( - (newValue) => { + (newValue: any) => { if (newValue === SNAPSHOT_OPTION.value) { onSnapshotChange(true); onRemovedChange(false); diff --git a/x-pack/plugins/osquery/public/lens/view_results_in_lens.tsx b/x-pack/plugins/osquery/public/lens/view_results_in_lens.tsx index 53281c794e3a3cc..240cd6d24de09af 100644 --- a/x-pack/plugins/osquery/public/lens/view_results_in_lens.tsx +++ b/x-pack/plugins/osquery/public/lens/view_results_in_lens.tsx @@ -41,7 +41,7 @@ const ViewResultsInLensActionComponent: React.FC = const { data: logsDataView } = useLogsDataView({ skip: !actionId, checkOnly: true }); const handleClick = useCallback( - (event) => { + (event: any) => { event.preventDefault(); if (logsDataView) { diff --git a/x-pack/plugins/osquery/public/live_queries/form/live_query_query_field.tsx b/x-pack/plugins/osquery/public/live_queries/form/live_query_query_field.tsx index 23ef0524dbb15dd..462d3aa94d7f7be 100644 --- a/x-pack/plugins/osquery/public/live_queries/form/live_query_query_field.tsx +++ b/x-pack/plugins/osquery/public/live_queries/form/live_query_query_field.tsx @@ -82,7 +82,7 @@ const LiveQueryQueryFieldComponent: React.FC = ({ [resetField] ); - const handleToggle = useCallback((isOpen) => { + const handleToggle = useCallback((isOpen: any) => { const newState = isOpen ? 'open' : 'closed'; setAdvancedContentState(newState); }, []); diff --git a/x-pack/plugins/osquery/public/live_queries/form/pack_queries_status_table.tsx b/x-pack/plugins/osquery/public/live_queries/form/pack_queries_status_table.tsx index 73d66481d94fcc5..4fe0993306c9397 100644 --- a/x-pack/plugins/osquery/public/live_queries/form/pack_queries_status_table.tsx +++ b/x-pack/plugins/osquery/public/live_queries/form/pack_queries_status_table.tsx @@ -157,7 +157,7 @@ const PackQueriesStatusTableComponent: React.FC = ( } | null>(null); const handleQueryFlyoutOpen = useCallback( - (item) => () => { + (item: any) => () => { setQueryDetailsFlyoutOpen(item); }, [] @@ -179,7 +179,7 @@ const PackQueriesStatusTableComponent: React.FC = ( ); const renderQueryColumn = useCallback( - (query: string, item) => { + (query: string, item: any) => { const singleLine = removeMultilines(query); const content = singleLine.length > 55 ? `${singleLine.substring(0, 55)}...` : singleLine; @@ -201,7 +201,7 @@ const PackQueriesStatusTableComponent: React.FC = ( return ; }, []); - const renderAgentsColumn = useCallback((item) => { + const renderAgentsColumn = useCallback((item: any) => { if (!item.action_id) return; return ( @@ -214,14 +214,17 @@ const PackQueriesStatusTableComponent: React.FC = ( }, []); const renderDiscoverResultsAction = useCallback( - (item) => , + (item: any) => , [] ); - const renderLensResultsAction = useCallback((item) => , []); + const renderLensResultsAction = useCallback( + (item: any) => , + [] + ); const getHandleErrorsToggle = useCallback( - (item) => () => { + (item: any) => () => { setItemIdToExpandedRowMap((prevValue) => { const itemIdToExpandedRowMapValues = { ...prevValue }; if (itemIdToExpandedRowMapValues[item.id]) { @@ -252,7 +255,7 @@ const PackQueriesStatusTableComponent: React.FC = ( ); const renderToggleResultsAction = useCallback( - (item) => + (item: any) => item?.action_id && data?.length && data.length > 1 ? ( ([]); const handlePackChange = useCallback( - (newSelectedOptions) => { + (newSelectedOptions: any) => { if (!newSelectedOptions.length) { setSelectedOptions(newSelectedOptions); onChange([]); @@ -86,7 +86,7 @@ export const PacksComboBoxField = ({ ); const renderOption = useCallback( - ({ value: option }) => ( + ({ value: option }: any) => ( { + (type: any) => { setQueryType(type); }, [setQueryType] diff --git a/x-pack/plugins/osquery/public/packs/form/index.tsx b/x-pack/plugins/osquery/public/packs/form/index.tsx index fd9c114a07944be..5b0bb73fd16652c 100644 --- a/x-pack/plugins/osquery/public/packs/form/index.tsx +++ b/x-pack/plugins/osquery/public/packs/form/index.tsx @@ -60,7 +60,7 @@ const PackFormComponent: React.FC = ({ }) => { const [shardsToggleState, setShardsToggleState] = useState('closed'); - const handleToggle = useCallback((isOpen) => { + const handleToggle = useCallback((isOpen: any) => { const newState = isOpen ? 'open' : 'closed'; setShardsToggleState(newState); }, []); diff --git a/x-pack/plugins/osquery/public/packs/form/pack_uploader.tsx b/x-pack/plugins/osquery/public/packs/form/pack_uploader.tsx index b9f9c914ed24bdb..7ab3218a00b9f06 100644 --- a/x-pack/plugins/osquery/public/packs/form/pack_uploader.tsx +++ b/x-pack/plugins/osquery/public/packs/form/pack_uploader.tsx @@ -83,7 +83,7 @@ const OsqueryPackUploaderComponent: React.FC = ({ onCh }; const handleInputChange = useCallback( - (inputFiles) => { + (inputFiles: any) => { if (!inputFiles.length) { packName.current = ''; diff --git a/x-pack/plugins/osquery/public/packs/form/queries_field.tsx b/x-pack/plugins/osquery/public/packs/form/queries_field.tsx index 3e62a5639e1f7c4..f4f2f07297137d9 100644 --- a/x-pack/plugins/osquery/public/packs/form/queries_field.tsx +++ b/x-pack/plugins/osquery/public/packs/form/queries_field.tsx @@ -56,7 +56,7 @@ const QueriesFieldComponent: React.FC = ({ euiFieldProps }) = const handleHideEditFlyout = useCallback(() => setShowEditQueryFlyout(-1), []); const handleDeleteClick = useCallback( - (query) => { + (query: any) => { const streamIndex = findIndex(fieldValue, ['id', query.id]); if (streamIndex > -1) { @@ -67,7 +67,7 @@ const QueriesFieldComponent: React.FC = ({ euiFieldProps }) = ); const handleEditClick = useCallback( - (query) => { + (query: any) => { const streamIndex = findIndex(fieldValue, ['id', query.id]); setShowEditQueryFlyout(streamIndex); @@ -76,7 +76,7 @@ const QueriesFieldComponent: React.FC = ({ euiFieldProps }) = ); const handleEditQuery = useCallback( - (updatedQuery) => + (updatedQuery: any) => new Promise((resolve) => { if (showEditQueryFlyout >= 0) { update( @@ -114,7 +114,7 @@ const QueriesFieldComponent: React.FC = ({ euiFieldProps }) = ); const handleAddQuery = useCallback( - (newQuery) => + (newQuery: any) => new Promise((resolve) => { append(newQuery); handleHideAddFlyout(); @@ -132,7 +132,7 @@ const QueriesFieldComponent: React.FC = ({ euiFieldProps }) = }, [fieldValue, remove, tableSelectedItems]); const handlePackUpload = useCallback( - (parsedContent, uploadedPackName) => { + (parsedContent: any, uploadedPackName: any) => { replace( map(parsedContent.queries, (newQuery, newQueryId) => pickBy( diff --git a/x-pack/plugins/osquery/public/packs/form/shards/pack_type_selectable.tsx b/x-pack/plugins/osquery/public/packs/form/shards/pack_type_selectable.tsx index a64dc02cb02838f..ce64d990a5dc759 100644 --- a/x-pack/plugins/osquery/public/packs/form/shards/pack_type_selectable.tsx +++ b/x-pack/plugins/osquery/public/packs/form/shards/pack_type_selectable.tsx @@ -50,7 +50,7 @@ const PackTypeSelectableComponent = ({ resetFormFields, }: PackTypeSelectableProps) => { const handleChange = useCallback( - (type) => { + (type: any) => { setPackType(type); if (resetFormFields) { resetFormFields(); diff --git a/x-pack/plugins/osquery/public/packs/form/shards/shards_form.tsx b/x-pack/plugins/osquery/public/packs/form/shards/shards_form.tsx index 8fbf05e3d7e7734..c353512b66f6fc1 100644 --- a/x-pack/plugins/osquery/public/packs/form/shards/shards_form.tsx +++ b/x-pack/plugins/osquery/public/packs/form/shards/shards_form.tsx @@ -39,7 +39,7 @@ const ShardsFormComponent = ({ }, [index, onDelete]); const buttonWrapperCss = useCallback( - ({ euiTheme }) => (index === 0 ? { marginTop: euiTheme.size.base } : {}), + ({ euiTheme }: any) => (index === 0 ? { marginTop: euiTheme.size.base } : {}), [index] ); diff --git a/x-pack/plugins/osquery/public/packs/pack_queries_status_table.tsx b/x-pack/plugins/osquery/public/packs/pack_queries_status_table.tsx index f4f941a1254eb5f..48f3024d499c373 100644 --- a/x-pack/plugins/osquery/public/packs/pack_queries_status_table.tsx +++ b/x-pack/plugins/osquery/public/packs/pack_queries_status_table.tsx @@ -187,7 +187,7 @@ const ViewResultsInLensActionComponent: React.FC { + (event: any) => { event.preventDefault(); if (logsDataView?.id) { @@ -584,7 +584,7 @@ const PackQueriesStatusTableComponent: React.FC = ( Record> >({}); - const renderQueryColumn = useCallback((query: string, item) => { + const renderQueryColumn = useCallback((query: string, item: any) => { const singleLine = removeMultilines(query); const content = singleLine.length > 55 ? `${singleLine.substring(0, 55)}...` : singleLine; @@ -618,7 +618,7 @@ const PackQueriesStatusTableComponent: React.FC = ( ); const renderLastResultsColumn = useCallback( - (item) => ( + (item: any) => ( = ( [packName] ); const renderDocsColumn = useCallback( - (item) => ( + (item: any) => ( ), [packName] ); const renderAgentsColumn = useCallback( - (item) => ( + (item: any) => ( ), [packName] ); const renderErrorsColumn = useCallback( - (item) => ( + (item: any) => ( = ( ); const renderDiscoverResultsAction = useCallback( - (item) => , + (item: any) => , [packName] ); const renderLensResultsAction = useCallback( - (item) => , + (item: any) => , [packName] ); diff --git a/x-pack/plugins/osquery/public/packs/packs_table.tsx b/x-pack/plugins/osquery/public/packs/packs_table.tsx index 3574d45891755e9..aa0d6d205a624d3 100644 --- a/x-pack/plugins/osquery/public/packs/packs_table.tsx +++ b/x-pack/plugins/osquery/public/packs/packs_table.tsx @@ -86,18 +86,18 @@ const PacksTableComponent = () => { const { data, isLoading } = usePacks({}); const renderAgentPolicy = useCallback( - (agentPolicyIds) => , + (agentPolicyIds: any) => , [] ); const renderQueries = useCallback( - (queries) => <>{(queries && Object.keys(queries).length) ?? 0}, + (queries: any) => <>{(queries && Object.keys(queries).length) ?? 0}, [] ); - const renderActive = useCallback((_, item) => , []); + const renderActive = useCallback((_: any, item: any) => , []); - const renderUpdatedAt = useCallback((updatedAt, item) => { + const renderUpdatedAt = useCallback((updatedAt: any, item: any) => { if (!updatedAt) return '-'; const updatedBy = item.updated_by !== item.created_by ? ` @ ${item.updated_by}` : ''; @@ -122,7 +122,7 @@ const PacksTableComponent = () => { ); const renderPlayAction = useCallback( - (item, enabled) => { + (item: any, enabled: any) => { const playText = i18n.translate('xpack.osquery.packs.table.runActionAriaLabel', { defaultMessage: 'Run {packName}', values: { diff --git a/x-pack/plugins/osquery/public/packs/queries/ecs_mapping_editor_field.tsx b/x-pack/plugins/osquery/public/packs/queries/ecs_mapping_editor_field.tsx index d1ca70f14b08120..5cd39930333787a 100644 --- a/x-pack/plugins/osquery/public/packs/queries/ecs_mapping_editor_field.tsx +++ b/x-pack/plugins/osquery/public/packs/queries/ecs_mapping_editor_field.tsx @@ -139,7 +139,7 @@ const ECSComboboxFieldComponent: React.FC = ({ const describedByIds = useMemo(() => (idAria ? [idAria] : []), [idAria]); const { ecsMappingArray: watchedEcsMapping } = watch(); const handleChange = useCallback( - (newSelectedOptions) => { + (newSelectedOptions: any) => { setSelected(newSelectedOptions); ECSField.onChange(newSelectedOptions[0]?.label ?? ''); }, @@ -148,7 +148,7 @@ const ECSComboboxFieldComponent: React.FC = ({ // TODO: Create own component for this. const renderOption = useCallback( - (option, searchValue, contentClassName) => ( + (option: any, searchValue: any, contentClassName: any) => ( = ({ const describedByIds = useMemo(() => (idAria ? [idAria] : []), [idAria]); const renderOsqueryOption = useCallback( - (option, searchValue, contentClassName) => ( + (option: any, searchValue: any, contentClassName: any) => ( = ({ ); const handleKeyChange = useCallback( - (newSelectedOptions) => { + (newSelectedOptions: any) => { setSelected(newSelectedOptions); resultField.onChange( isArray(newSelectedOptions) @@ -438,7 +438,7 @@ const OsqueryColumnFieldComponent: React.FC = ({ }, [ecsMappingArray, index, isLastItem, resultTypeField.value]); const onTypeChange = useCallback( - (newType) => { + (newType: any) => { if (newType !== resultTypeField.value) { resultTypeField.onChange(newType); resultField.onChange(newType === 'value' && isSingleSelection === false ? [] : ''); diff --git a/x-pack/plugins/osquery/public/packs/queries/query_flyout.tsx b/x-pack/plugins/osquery/public/packs/queries/query_flyout.tsx index 751f53f91ece21a..1afe75f463d023c 100644 --- a/x-pack/plugins/osquery/public/packs/queries/query_flyout.tsx +++ b/x-pack/plugins/osquery/public/packs/queries/query_flyout.tsx @@ -76,7 +76,7 @@ const QueryFlyoutComponent: React.FC = ({ }; const handleSetQueryValue = useCallback( - (savedQuery) => { + (savedQuery: any) => { if (savedQuery) { resetField('id', { defaultValue: savedQuery.id }); resetField('query', { defaultValue: savedQuery.query }); diff --git a/x-pack/plugins/osquery/public/packs/scheduled_query_errors_table.tsx b/x-pack/plugins/osquery/public/packs/scheduled_query_errors_table.tsx index 99b614a2c53f992..7c7f1bee0fc555e 100644 --- a/x-pack/plugins/osquery/public/packs/scheduled_query_errors_table.tsx +++ b/x-pack/plugins/osquery/public/packs/scheduled_query_errors_table.tsx @@ -37,7 +37,7 @@ const ViewErrorsInLogsActionComponent: React.FC = ( const navigateToApp = useKibana().services.application.navigateToApp; const handleClick = useCallback( - (event) => { + (event: any) => { const openInNewTab = !(!isModifiedEvent(event) && isLeftClickEvent(event)); event.preventDefault(); @@ -90,10 +90,13 @@ const ScheduledQueryErrorsTableComponent: React.FC , []); + const renderAgentIdColumn = useCallback( + (agentId: any) => , + [] + ); const renderLogsErrorsAction = useCallback( - (item) => ( + (item: any) => ( = ({ } = useKibana().services; const getFleetAppUrl = useCallback( - (agentId) => + (agentId: any) => getUrlForApp('fleet', { path: pagePathGetters.agent_details({ agentId })[1], }), @@ -118,7 +118,7 @@ const ResultsTableComponent: React.FC = ({ const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 50 }); const onChangeItemsPerPage = useCallback( - (pageSize) => + (pageSize: any) => setPagination((currentPagination) => ({ ...currentPagination, pageSize, @@ -127,7 +127,7 @@ const ResultsTableComponent: React.FC = ({ [setPagination] ); const onChangePage = useCallback( - (pageIndex) => setPagination((currentPagination) => ({ ...currentPagination, pageIndex })), + (pageIndex: any) => setPagination((currentPagination) => ({ ...currentPagination, pageIndex })), [setPagination] ); diff --git a/x-pack/plugins/osquery/public/routes/saved_queries/edit/index.tsx b/x-pack/plugins/osquery/public/routes/saved_queries/edit/index.tsx index d1c78cf89de8b1f..ce7cda4f71fed01 100644 --- a/x-pack/plugins/osquery/public/routes/saved_queries/edit/index.tsx +++ b/x-pack/plugins/osquery/public/routes/saved_queries/edit/index.tsx @@ -126,7 +126,7 @@ const EditSavedQueryPageComponent = () => { ); const handleSubmit = useCallback( - async (payload) => { + async (payload: any) => { await updateSavedQueryMutation.mutateAsync(payload); }, [updateSavedQueryMutation] diff --git a/x-pack/plugins/osquery/public/routes/saved_queries/list/index.tsx b/x-pack/plugins/osquery/public/routes/saved_queries/list/index.tsx index e9fa1d34df207fa..8d6d180f46bd0ee 100644 --- a/x-pack/plugins/osquery/public/routes/saved_queries/list/index.tsx +++ b/x-pack/plugins/osquery/public/routes/saved_queries/list/index.tsx @@ -157,7 +157,7 @@ const SavedQueriesPageComponent = () => { [permissions.runSavedQueries, permissions.writeLiveQueries] ); - const renderUpdatedAt = useCallback((updatedAt, item) => { + const renderUpdatedAt = useCallback((updatedAt: any, item: any) => { if (!updatedAt) return '-'; const updatedBy = item.updated_by !== item.created_by ? ` @ ${item.updated_by}` : ''; @@ -223,7 +223,7 @@ const SavedQueriesPageComponent = () => { [renderDescriptionColumn, renderEditAction, renderPlayAction, renderUpdatedAt] ); - const onTableChange = useCallback(({ page = {}, sort = {} }) => { + const onTableChange = useCallback(({ page = {}, sort = {} }: any) => { setPageIndex(page.index); setPageSize(page.size); setSortField(sort.field); diff --git a/x-pack/plugins/osquery/public/routes/saved_queries/new/index.tsx b/x-pack/plugins/osquery/public/routes/saved_queries/new/index.tsx index 4c8d2fa5d3a9c71..b06c27aeaf0bdd3 100644 --- a/x-pack/plugins/osquery/public/routes/saved_queries/new/index.tsx +++ b/x-pack/plugins/osquery/public/routes/saved_queries/new/index.tsx @@ -48,7 +48,7 @@ const NewSavedQueryPageComponent = () => { ); const handleSubmit = useCallback( - async (payload) => { + async (payload: any) => { await mutateAsync(payload); }, [mutateAsync] diff --git a/x-pack/plugins/osquery/public/saved_queries/saved_queries_dropdown.tsx b/x-pack/plugins/osquery/public/saved_queries/saved_queries_dropdown.tsx index 690341fd2221fe2..5a5e052362ee47b 100644 --- a/x-pack/plugins/osquery/public/saved_queries/saved_queries_dropdown.tsx +++ b/x-pack/plugins/osquery/public/saved_queries/saved_queries_dropdown.tsx @@ -67,7 +67,7 @@ const SavedQueriesDropdownComponent: React.FC = ({ ); const handleSavedQueryChange = useCallback( - (newSelectedOptions) => { + (newSelectedOptions: any) => { if (!newSelectedOptions.length) { onChange(null); setSelectedOptions(newSelectedOptions); @@ -87,7 +87,7 @@ const SavedQueriesDropdownComponent: React.FC = ({ ); const renderOption = useCallback( - ({ value }) => ( + ({ value }: any) => ( <> {value.id}
diff --git a/x-pack/plugins/osquery/public/timelines/add_to_timeline_button.tsx b/x-pack/plugins/osquery/public/timelines/add_to_timeline_button.tsx index 6a03317c486d77d..f59ccfee00abbdf 100644 --- a/x-pack/plugins/osquery/public/timelines/add_to_timeline_button.tsx +++ b/x-pack/plugins/osquery/public/timelines/add_to_timeline_button.tsx @@ -28,7 +28,7 @@ export const AddToTimelineButton = (props: AddToTimelineButtonProps) => { const queryIds = isArray(value) ? value : [value]; const TimelineIconComponent = useCallback( - (timelineComponentProps) => ( + (timelineComponentProps: any) => ( ), [iconProps] diff --git a/x-pack/plugins/saved_objects_tagging/public/components/edition_modal/utils.ts b/x-pack/plugins/saved_objects_tagging/public/components/edition_modal/utils.ts index e5b98b35a18ae19..773e8a40fab21e3 100644 --- a/x-pack/plugins/saved_objects_tagging/public/components/edition_modal/utils.ts +++ b/x-pack/plugins/saved_objects_tagging/public/components/edition_modal/utils.ts @@ -66,7 +66,7 @@ export const useIfMounted = () => { [] ); - const ifMounted = useCallback((func) => { + const ifMounted = useCallback((func?: () => void) => { if (isMounted.current && func) { func(); } diff --git a/x-pack/plugins/searchprofiler/public/application/app.tsx b/x-pack/plugins/searchprofiler/public/application/app.tsx index 321b2a167a38ca8..08dd4b1db6470b6 100644 --- a/x-pack/plugins/searchprofiler/public/application/app.tsx +++ b/x-pack/plugins/searchprofiler/public/application/app.tsx @@ -46,7 +46,7 @@ export const App = () => { ); const onHighlight = useCallback( - (value) => dispatch({ type: 'setHighlightDetails', value }), + (value: any) => dispatch({ type: 'setHighlightDetails', value }), [dispatch] ); diff --git a/x-pack/plugins/searchprofiler/public/application/components/profile_query_editor/profile_query_editor.tsx b/x-pack/plugins/searchprofiler/public/application/components/profile_query_editor/profile_query_editor.tsx index 574f8c7e18b6031..577c3e530e8cc9b 100644 --- a/x-pack/plugins/searchprofiler/public/application/components/profile_query_editor/profile_query_editor.tsx +++ b/x-pack/plugins/searchprofiler/public/application/components/profile_query_editor/profile_query_editor.tsx @@ -77,7 +77,10 @@ export const ProfileQueryEditor = memo(() => { } }; - const onEditorReady = useCallback((editorInstance) => (editorRef.current = editorInstance), []); + const onEditorReady = useCallback( + (editorInstance: any) => (editorRef.current = editorInstance), + [] + ); const licenseEnabled = getLicenseStatus().valid; return ( diff --git a/x-pack/plugins/security_solution/public/assistant/use_assistant_telemetry/index.tsx b/x-pack/plugins/security_solution/public/assistant/use_assistant_telemetry/index.tsx index 3de834c08829a9a..084f8ca94215302 100644 --- a/x-pack/plugins/security_solution/public/assistant/use_assistant_telemetry/index.tsx +++ b/x-pack/plugins/security_solution/public/assistant/use_assistant_telemetry/index.tsx @@ -17,7 +17,7 @@ export const useAssistantTelemetry = (): AssistantTelemetry => { const baseConversations = useBaseConversations(); const getAnonymizedConversationTitle = useCallback( - async (title) => { + async (title: string) => { // With persistent storage for conversation replacing id to title, because id is UUID now // and doesn't make any value for telemetry tracking return baseConversations[title] ? title : 'Custom'; diff --git a/x-pack/plugins/security_solution/public/cases/pages/index.tsx b/x-pack/plugins/security_solution/public/cases/pages/index.tsx index 1ba63b8c43662c6..c873e48e4975f40 100644 --- a/x-pack/plugins/security_solution/public/cases/pages/index.tsx +++ b/x-pack/plugins/security_solution/public/cases/pages/index.tsx @@ -44,7 +44,8 @@ const CaseContainerComponent: React.FC = () => { const { openFlyout } = useExpandableFlyoutApi(); const getDetectionsRuleDetailsHref = useCallback( - (ruleId) => detectionsFormatUrl(getRuleDetailsUrl(ruleId ?? '', detectionsUrlSearch)), + (ruleId: string | null | undefined) => + detectionsFormatUrl(getRuleDetailsUrl(ruleId ?? '', detectionsUrlSearch)), [detectionsFormatUrl, detectionsUrlSearch] ); diff --git a/x-pack/plugins/security_solution/public/common/components/control_columns/row_action/index.tsx b/x-pack/plugins/security_solution/public/common/components/control_columns/row_action/index.tsx index 5c61900876aaebb..931c519ae9b5747 100644 --- a/x-pack/plugins/security_solution/public/common/components/control_columns/row_action/index.tsx +++ b/x-pack/plugins/security_solution/public/common/components/control_columns/row_action/index.tsx @@ -26,7 +26,7 @@ import { useIsExperimentalFeatureEnabled } from '../../../hooks/use_experimental import { useTourContext } from '../../guided_onboarding_tour'; import { AlertsCasesTourSteps, SecurityStepId } from '../../guided_onboarding_tour/tour_config'; -type Props = EuiDataGridCellValueElementProps & { +export type RowActionProps = EuiDataGridCellValueElementProps & { columnHeaders: ColumnHeaderOptions[]; controlColumn: ControlColumnProps; data: TimelineItem; @@ -67,7 +67,7 @@ const RowActionComponent = ({ setEventsDeleted, width, refetch, -}: Props) => { +}: RowActionProps) => { const { data: timelineNonEcsData, ecs: ecsData, _id: eventId, _index: indexName } = data ?? {}; const { telemetry } = useKibana().services; const { openFlyout } = useExpandableFlyoutApi(); diff --git a/x-pack/plugins/security_solution/public/common/components/drag_and_drop/draggable_wrapper.tsx b/x-pack/plugins/security_solution/public/common/components/drag_and_drop/draggable_wrapper.tsx index 9a8762cee2c079f..eca4c61f9cea253 100644 --- a/x-pack/plugins/security_solution/public/common/components/drag_and_drop/draggable_wrapper.tsx +++ b/x-pack/plugins/security_solution/public/common/components/drag_and_drop/draggable_wrapper.tsx @@ -95,7 +95,7 @@ type RenderFunctionProp = ( state: DraggableStateSnapshot ) => React.ReactNode; -interface Props { +export interface DraggableWrapperProps { dataProvider: DataProvider; fieldType?: string; isAggregatable?: boolean; @@ -128,7 +128,7 @@ export const getStyle = ( }; }; -const DraggableOnWrapper: React.FC = React.memo( +const DraggableOnWrapper: React.FC = React.memo( ({ dataProvider, render, scopeId, truncate, hideTopN }) => { const [providerRegistered, setProviderRegistered] = useState(false); const isDisabled = dataProvider.id.includes(`-${ROW_RENDERER_BROWSER_EXAMPLE_TIMELINE_ID}-`); @@ -265,7 +265,7 @@ const DraggableOnWrapper: React.FC = React.memo( ); DraggableOnWrapper.displayName = 'DraggableOnWrapper'; -export const DraggableWrapper: React.FC = React.memo( +export const DraggableWrapper: React.FC = React.memo( ({ dataProvider, isDraggable = false, render, scopeId, truncate, hideTopN }) => { const content = useMemo( () => ( diff --git a/x-pack/plugins/security_solution/public/common/components/drag_and_drop/droppable_wrapper.tsx b/x-pack/plugins/security_solution/public/common/components/drag_and_drop/droppable_wrapper.tsx index d0b1ce4eca2110b..586165893408ccf 100644 --- a/x-pack/plugins/security_solution/public/common/components/drag_and_drop/droppable_wrapper.tsx +++ b/x-pack/plugins/security_solution/public/common/components/drag_and_drop/droppable_wrapper.tsx @@ -7,7 +7,7 @@ import { rgba } from 'polished'; import React, { useCallback } from 'react'; -import type { DraggableChildrenFn } from '@hello-pangea/dnd'; +import type { DraggableChildrenFn, DroppableProps } from '@hello-pangea/dnd'; import { Droppable } from '@hello-pangea/dnd'; import styled from 'styled-components'; @@ -99,7 +99,7 @@ export const DroppableWrapper = React.memo( render = null, renderClone, }) => { - const DroppableContent = useCallback( + const DroppableContent = useCallback( (provided, snapshot) => ( ( [field, id, name, queryValue, value] ); - const renderCallback = useCallback( + const renderCallback = useCallback( (dataProvider, _, snapshot) => snapshot.isDragging ? ( diff --git a/x-pack/plugins/security_solution/public/common/components/events_viewer/index.tsx b/x-pack/plugins/security_solution/public/common/components/events_viewer/index.tsx index ea81a232cff52d9..e251370c7e4d30d 100644 --- a/x-pack/plugins/security_solution/public/common/components/events_viewer/index.tsx +++ b/x-pack/plugins/security_solution/public/common/components/events_viewer/index.tsx @@ -24,6 +24,7 @@ import { connect, useDispatch, useSelector } from 'react-redux'; import { ThemeContext } from 'styled-components'; import type { Filter } from '@kbn/es-query'; import type { + ColumnHeaderOptions, DeprecatedCellValueElementProps, DeprecatedRowRenderer, Direction, @@ -249,11 +250,12 @@ const StatefulEventsViewerComponent: React.FC dispatch(dataTableActions.upsertColumn({ column, id: tableId, index })), + (column: ColumnHeaderOptions, index: number) => + dispatch(dataTableActions.upsertColumn({ column, id: tableId, index })), [dispatch, tableId] ), removeColumn: useCallback( - (columnId) => dispatch(dataTableActions.removeColumn({ columnId, id: tableId })), + (columnId: string) => dispatch(dataTableActions.removeColumn({ columnId, id: tableId })), [dispatch, tableId] ), }); @@ -328,7 +330,8 @@ const StatefulEventsViewerComponent: React.FC dispatch(inputsActions.deleteOneQuery({ inputId: InputsModelId.global, id })), + ({ id }: { id: string }) => + dispatch(inputsActions.deleteOneQuery({ inputId: InputsModelId.global, id })), [dispatch] ); @@ -375,7 +378,7 @@ const StatefulEventsViewerComponent: React.FC { + (itemsChangedPerPage: number) => { dispatch( dataTableActions.updateItemsPerPage({ id: tableId, itemsPerPage: itemsChangedPerPage }) ); @@ -384,7 +387,7 @@ const StatefulEventsViewerComponent: React.FC { + (page: number) => { loadPage(page); }, [loadPage] diff --git a/x-pack/plugins/security_solution/public/common/components/events_viewer/summary_view_select/index.tsx b/x-pack/plugins/security_solution/public/common/components/events_viewer/summary_view_select/index.tsx index 88a2638976cf892..40d0d4e1a7c08c2 100644 --- a/x-pack/plugins/security_solution/public/common/components/events_viewer/summary_view_select/index.tsx +++ b/x-pack/plugins/security_solution/public/common/components/events_viewer/summary_view_select/index.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import type { EuiSelectableOption } from '@elastic/eui'; +import type { EuiSelectableOption, EuiSelectableProps } from '@elastic/eui'; import { EuiButtonEmpty, EuiPopover, EuiSelectable, EuiTitle, EuiTextColor } from '@elastic/eui'; import { Storage } from '@kbn/kibana-utils-plugin/public'; import { i18n } from '@kbn/i18n'; @@ -116,7 +116,9 @@ const SummaryViewSelectorComponent = ({ viewSelected, onViewChange }: SummaryVie [viewSelected] ); - const renderOption = useCallback((option) => { + const renderOption = useCallback< + NonNullable }>['renderOption']> + >((option) => { return ( <> diff --git a/x-pack/plugins/security_solution/public/common/components/hover_popover/hover_popover.tsx b/x-pack/plugins/security_solution/public/common/components/hover_popover/hover_popover.tsx index 827290565f28741..28a72a1bb87c703 100644 --- a/x-pack/plugins/security_solution/public/common/components/hover_popover/hover_popover.tsx +++ b/x-pack/plugins/security_solution/public/common/components/hover_popover/hover_popover.tsx @@ -16,7 +16,7 @@ import React, { useCallback, useEffect, useRef, useState } from 'react'; */ const HOVER_INTENT_DELAY = 100; // ms -interface Props { +export interface HoverPopoverProps { hoverContent: React.ReactNode; anchorPosition?: PopoverAnchorPosition; } @@ -37,7 +37,7 @@ interface Props { * otherwise it will be difficult for keyboard-only and screen * reader users to navigate to and from your popover. */ -export const HoverPopover = React.memo>( +export const HoverPopover = React.memo>( ({ hoverContent, anchorPosition = 'downCenter', children }) => { const [isOpen, setIsOpen] = useState(hoverContent != null); const [showHoverContent, setShowHoverContent] = useState(false); diff --git a/x-pack/plugins/security_solution/public/common/components/landing_page/onboarding/card_step/index.tsx b/x-pack/plugins/security_solution/public/common/components/landing_page/onboarding/card_step/index.tsx index 2e6886af03afa5c..07a73681ec8742d 100644 --- a/x-pack/plugins/security_solution/public/common/components/landing_page/onboarding/card_step/index.tsx +++ b/x-pack/plugins/security_solution/public/common/components/landing_page/onboarding/card_step/index.tsx @@ -71,7 +71,7 @@ const CardStepComponent: React.FC<{ const isDone = finishedSteps.has(stepId); const toggleStep = useCallback( - (e) => { + (e: React.SyntheticEvent) => { e.preventDefault(); const newStatus = !isExpandedStep; diff --git a/x-pack/plugins/security_solution/public/common/components/links/helpers.tsx b/x-pack/plugins/security_solution/public/common/components/links/helpers.tsx index 9dd3accd15e3294..5aed35ccb4b4caa 100644 --- a/x-pack/plugins/security_solution/public/common/components/links/helpers.tsx +++ b/x-pack/plugins/security_solution/public/common/components/links/helpers.tsx @@ -82,7 +82,7 @@ export const PortContainer = styled.div` } `; -interface ReputationLinkOverflowProps { +export interface ReputationLinkOverflowProps { rowItems: ReputationLinkSetting[]; render?: (item: ReputationLinkSetting) => React.ReactNode; overflowIndexStart?: number; diff --git a/x-pack/plugins/security_solution/public/common/components/links/index.tsx b/x-pack/plugins/security_solution/public/common/components/links/index.tsx index 4f07d53023e9e79..9d615d80be63f53 100644 --- a/x-pack/plugins/security_solution/public/common/components/links/index.tsx +++ b/x-pack/plugins/security_solution/public/common/components/links/index.tsx @@ -31,7 +31,7 @@ import { isUrlInvalid } from '../../utils/validators'; import * as i18n from './translations'; import { SecurityPageName } from '../../../app/types'; import { getTabsOnUsersDetailsUrl, getUsersDetailsUrl } from '../link_to/redirect_to_users'; -import type { ReputationLinkSetting } from './helpers'; +import type { ReputationLinkSetting, ReputationLinkOverflowProps } from './helpers'; import { LinkAnchor, GenericLinkButton, @@ -72,7 +72,7 @@ const UserDetailsLinkComponent: React.FC<{ telemetry, } = useKibana().services; const goToUsersDetails = useCallback( - (ev) => { + (ev: SyntheticEvent) => { ev.preventDefault(); navigateToApp(APP_UI_ID, { deepLinkId: SecurityPageName.users, @@ -122,7 +122,7 @@ const UserDetailsLinkComponent: React.FC<{ export const UserDetailsLink = React.memo(UserDetailsLinkComponent); -const HostDetailsLinkComponent: React.FC<{ +export interface HostDetailsLinkProps { children?: React.ReactNode; /** `Component` is only used with `EuiDataGrid`; the grid keeps a reference to `Component` for show / hide functionality */ Component?: typeof EuiButtonEmpty | typeof EuiButtonIcon; @@ -131,7 +131,16 @@ const HostDetailsLinkComponent: React.FC<{ onClick?: (e: SyntheticEvent) => void; hostTab?: HostsTableType; title?: string; -}> = ({ children, Component, hostName, isButton, onClick: onClickParam, title, hostTab }) => { +} +const HostDetailsLinkComponent: React.FC = ({ + children, + Component, + hostName, + isButton, + onClick: onClickParam, + title, + hostTab, +}) => { const { formatUrl, search } = useFormatUrl(SecurityPageName.hosts); const { application: { navigateToApp }, @@ -141,7 +150,7 @@ const HostDetailsLinkComponent: React.FC<{ const encodedHostName = encodeURIComponent(hostName); const goToHostDetails = useCallback( - (ev) => { + (ev: SyntheticEvent) => { ev.preventDefault(); navigateToApp(APP_UI_ID, { deepLinkId: SecurityPageName.hosts, @@ -226,7 +235,7 @@ export const ExternalLink = React.memo<{ ExternalLink.displayName = 'ExternalLink'; -const NetworkDetailsLinkComponent: React.FC<{ +export interface NetworkDetailsLinkProps { children?: React.ReactNode; /** `Component` is only used with `EuiDataGrid`; the grid keeps a reference to `Component` for show / hide functionality */ Component?: typeof EuiButtonEmpty | typeof EuiButtonIcon; @@ -235,7 +244,17 @@ const NetworkDetailsLinkComponent: React.FC<{ isButton?: boolean; onClick?: (e: SyntheticEvent) => void | undefined; title?: string; -}> = ({ Component, children, ip, flowTarget = FlowTarget.source, isButton, onClick, title }) => { +} + +const NetworkDetailsLinkComponent: React.FC = ({ + Component, + children, + ip, + flowTarget = FlowTarget.source, + isButton, + onClick, + title, +}) => { const getSecuritySolutionLinkProps = useGetSecuritySolutionLinkProps(); const getLink = useCallback( @@ -310,7 +329,7 @@ const CaseDetailsLinkComponent: React.FC = ({ ); const goToCaseDetails = useCallback( - async (ev?) => { + async (ev?: SyntheticEvent) => { if (ev) ev.preventDefault(); return navigateToApp(APP_UI_ID, { deepLinkId: SecurityPageName.case, @@ -350,7 +369,7 @@ export const CreateCaseLink = React.memo<{ children: React.ReactNode }>(({ child const { formatUrl, search } = useFormatUrl(SecurityPageName.case); const { navigateToApp } = useKibana().services.application; const goToCreateCase = useCallback( - async (ev) => { + async (ev: SyntheticEvent) => { ev.preventDefault(); return navigateToApp(APP_UI_ID, { deepLinkId: SecurityPageName.case, @@ -508,7 +527,7 @@ const ReputationLinkComponent: React.FC<{ [ipReputationLinksSetting, domain, defaultNameMapping, allItemsLimit] ); - const renderCallback = useCallback( + const renderCallback: NonNullable = useCallback( (rowItem) => isReputationLink(rowItem) && ( { - const [markdownErrorMessages, setMarkdownErrorMessages] = useState([]); - const onParse = useCallback( + const [markdownErrorMessages, setMarkdownErrorMessages] = useState([]); + const onParse = useCallback>( (err, { messages }) => { setMarkdownErrorMessages(err ? [err] : messages); setIsMarkdownInvalid(err ? true : false); diff --git a/x-pack/plugins/security_solution/public/common/components/markdown_editor/plugins/insight/index.tsx b/x-pack/plugins/security_solution/public/common/components/markdown_editor/plugins/insight/index.tsx index 791bace753ff834..f38a20ddd7ad0c6 100644 --- a/x-pack/plugins/security_solution/public/common/components/markdown_editor/plugins/insight/index.tsx +++ b/x-pack/plugins/security_solution/public/common/components/markdown_editor/plugins/insight/index.tsx @@ -9,7 +9,7 @@ import { pickBy, isEmpty } from 'lodash'; import type { Plugin } from 'unified'; import moment from 'moment'; import React, { useContext, useMemo, useCallback, useState } from 'react'; -import type { RemarkTokenizer } from '@elastic/eui'; +import type { RemarkTokenizer, EuiSelectProps } from '@elastic/eui'; import { EuiLoadingSpinner, EuiIcon, @@ -382,7 +382,7 @@ const InsightEditorComponent = ({ const onChange = useCallback((filters: Filter[]) => { setProviders(filtersToInsightProviders(filters)); }, []); - const selectOnChange = useCallback( + const selectOnChange = useCallback>( (event) => { relativeTimerangeController.field.onChange(event.target.value); }, diff --git a/x-pack/plugins/security_solution/public/common/components/markdown_editor/plugins/osquery/plugin.tsx b/x-pack/plugins/security_solution/public/common/components/markdown_editor/plugins/osquery/plugin.tsx index 6cc54184db60c79..6a37280f9ef230d 100644 --- a/x-pack/plugins/security_solution/public/common/components/markdown_editor/plugins/osquery/plugin.tsx +++ b/x-pack/plugins/security_solution/public/common/components/markdown_editor/plugins/osquery/plugin.tsx @@ -25,6 +25,12 @@ import { LabelField } from './label_field'; import { OsqueryNotAvailablePrompt } from './not_available_prompt'; import { useKibana } from '../../../../lib/kibana'; +interface FormData { + label: string; + query: string; + ecs_mapping: Record; +} + const OsqueryEditorComponent = ({ node, onSave, @@ -43,11 +49,7 @@ const OsqueryEditorComponent = ({ capabilities: { osquery: osqueryPermissions }, }, } = useKibana().services; - const formMethods = useForm<{ - label: string; - query: string; - ecs_mapping: Record; - }>({ + const formMethods = useForm({ defaultValues: { label: node?.configuration?.label, query: node?.configuration?.query, @@ -56,7 +58,7 @@ const OsqueryEditorComponent = ({ }); const onSubmit = useCallback( - (data) => { + (data: FormData) => { onSave( `!{osquery${JSON.stringify( pickBy( diff --git a/x-pack/plugins/security_solution/public/common/components/ml/tables/select_interval.tsx b/x-pack/plugins/security_solution/public/common/components/ml/tables/select_interval.tsx index 717c0d0a484092d..e273487d31173fd 100644 --- a/x-pack/plugins/security_solution/public/common/components/ml/tables/select_interval.tsx +++ b/x-pack/plugins/security_solution/public/common/components/ml/tables/select_interval.tsx @@ -5,6 +5,7 @@ * 2.0. */ import React, { useCallback } from 'react'; +import type { EuiSelectProps } from '@elastic/eui'; import { EuiSelect, EuiIcon, EuiToolTip } from '@elastic/eui'; import * as i18n from './translations'; @@ -31,7 +32,7 @@ export const SelectInterval: React.FC<{ interval: string; onChange: (interval: string) => void; }> = ({ interval, onChange }) => { - const onChangeCb = useCallback( + const onChangeCb = useCallback>( (e) => { onChange(e.target.value); }, diff --git a/x-pack/plugins/security_solution/public/common/components/ml_popover/hooks/use_security_jobs.ts b/x-pack/plugins/security_solution/public/common/components/ml_popover/hooks/use_security_jobs.ts index e7a7571c6e51615..b1064431f4266e2 100644 --- a/x-pack/plugins/security_solution/public/common/components/ml_popover/hooks/use_security_jobs.ts +++ b/x-pack/plugins/security_solution/public/common/components/ml_popover/hooks/use_security_jobs.ts @@ -47,7 +47,7 @@ export const useSecurityJobs = (): UseSecurityJobsReturn => { const isMlEnabled = isMlAdmin && isLicensed; const onError = useCallback( - (error) => { + (error: unknown) => { addError(error, { title: i18n.SIEM_JOB_FETCH_FAILURE }); }, [addError] diff --git a/x-pack/plugins/security_solution/public/common/components/ml_popover/jobs_table/job_switch.tsx b/x-pack/plugins/security_solution/public/common/components/ml_popover/jobs_table/job_switch.tsx index 45fb359c0e121bb..46fbd4c5f70e631 100644 --- a/x-pack/plugins/security_solution/public/common/components/ml_popover/jobs_table/job_switch.tsx +++ b/x-pack/plugins/security_solution/public/common/components/ml_popover/jobs_table/job_switch.tsx @@ -7,6 +7,7 @@ import styled from 'styled-components'; import React, { useState, useCallback } from 'react'; +import type { EuiSwitchProps } from '@elastic/eui'; import { EuiFlexGroup, EuiFlexItem, EuiLoadingSpinner, EuiSwitch } from '@elastic/eui'; import { isJobLoading, @@ -36,7 +37,7 @@ export const JobSwitchComponent = ({ onJobStateChange, }: JobSwitchProps) => { const [isLoading, setIsLoading] = useState(false); - const handleChange = useCallback( + const handleChange: EuiSwitchProps['onChange'] = useCallback( async (e) => { setIsLoading(true); await onJobStateChange(job, job.latestTimestampMs || 0, e.target.checked); diff --git a/x-pack/plugins/security_solution/public/common/components/navigation/tab_navigation/tab_navigation.tsx b/x-pack/plugins/security_solution/public/common/components/navigation/tab_navigation/tab_navigation.tsx index 0f38ff32cfefa41..c37fed0c0281855 100644 --- a/x-pack/plugins/security_solution/public/common/components/navigation/tab_navigation/tab_navigation.tsx +++ b/x-pack/plugins/security_solution/public/common/components/navigation/tab_navigation/tab_navigation.tsx @@ -29,7 +29,7 @@ const TabNavigationItemComponent = ({ const { getAppUrl, navigateTo } = useNavigation(); const handleClick = useCallback( - (ev) => { + (ev: React.SyntheticEvent) => { ev.preventDefault(); navigateTo({ path: hrefWithSearch, restoreScroll: true }); track(METRIC_TYPE.CLICK, `${TELEMETRY_EVENT.TAB_CLICKED}${id}`); diff --git a/x-pack/plugins/security_solution/public/common/components/rule_name/index.tsx b/x-pack/plugins/security_solution/public/common/components/rule_name/index.tsx index 07592457de41c20..ebd0e0842dd1282 100644 --- a/x-pack/plugins/security_solution/public/common/components/rule_name/index.tsx +++ b/x-pack/plugins/security_solution/public/common/components/rule_name/index.tsx @@ -32,7 +32,7 @@ const RuleNameComponents = ({ name, id, appId }: RuleNameProps) => { [getUrlForApp, id, appId] ); const goToRuleDetails = useCallback( - (ev) => { + (ev: React.SyntheticEvent) => { ev.preventDefault(); navigateToApp(appId, { deepLinkId: 'rules', diff --git a/x-pack/plugins/security_solution/public/common/components/search_bar/index.tsx b/x-pack/plugins/security_solution/public/common/components/search_bar/index.tsx index af4c0aa7b0c19cb..792074b39cfeb73 100644 --- a/x-pack/plugins/security_solution/public/common/components/search_bar/index.tsx +++ b/x-pack/plugins/security_solution/public/common/components/search_bar/index.tsx @@ -305,7 +305,7 @@ export const SearchBarComponent = memo( }, [sourcererDataView, fieldFormats]); const onTimeRangeChange = useCallback( - ({ query, dateRange }) => { + ({ dateRange }: { dateRange: TimeRange }) => { const isQuickSelection = dateRange.from.includes('now') || dateRange.to.includes('now'); updateSearch({ end: dateRange.to, @@ -313,7 +313,6 @@ export const SearchBarComponent = memo( id, isInvalid: false, isQuickSelection, - query, setTablesActivePageToZero, start: dateRange.from, updateTime: true, diff --git a/x-pack/plugins/security_solution/public/common/components/toolbar/bulk_actions/alert_bulk_assignees.tsx b/x-pack/plugins/security_solution/public/common/components/toolbar/bulk_actions/alert_bulk_assignees.tsx index e152a5f96d61e84..f4838a414b1c88c 100644 --- a/x-pack/plugins/security_solution/public/common/components/toolbar/bulk_actions/alert_bulk_assignees.tsx +++ b/x-pack/plugins/security_solution/public/common/components/toolbar/bulk_actions/alert_bulk_assignees.tsx @@ -12,9 +12,10 @@ import type { TimelineItem } from '@kbn/timelines-plugin/common'; import { ALERT_WORKFLOW_ASSIGNEE_IDS } from '@kbn/rule-data-utils'; import type { SetAlertAssigneesFunc } from './use_set_alert_assignees'; +import type { AssigneesApplyPanelProps } from '../../assignees/assignees_apply_panel'; import { AssigneesApplyPanel } from '../../assignees/assignees_apply_panel'; -interface BulkAlertAssigneesPanelComponentProps { +export interface BulkAlertAssigneesPanelComponentProps { alertItems: TimelineItem[]; setIsLoading: (isLoading: boolean) => void; refresh?: () => void; @@ -47,7 +48,7 @@ const BulkAlertAssigneesPanelComponent: React.FC( async (assignees) => { closePopoverMenu(); if (onSubmit) { diff --git a/x-pack/plugins/security_solution/public/common/components/toolbar/bulk_actions/alert_bulk_tags.tsx b/x-pack/plugins/security_solution/public/common/components/toolbar/bulk_actions/alert_bulk_tags.tsx index 67ba6562abc23cb..8c3b48d64b63ed2 100644 --- a/x-pack/plugins/security_solution/public/common/components/toolbar/bulk_actions/alert_bulk_tags.tsx +++ b/x-pack/plugins/security_solution/public/common/components/toolbar/bulk_actions/alert_bulk_tags.tsx @@ -18,7 +18,7 @@ import { createInitialTagsState } from './helpers'; import { createAlertTagsReducer, initialState } from './reducer'; import type { SetAlertTagsFunc } from './use_set_alert_tags'; -interface BulkAlertTagsPanelComponentProps { +export interface BulkAlertTagsPanelComponentProps { alertItems: TimelineItem[]; refetchQuery?: () => void; setIsLoading: (isLoading: boolean) => void; diff --git a/x-pack/plugins/security_solution/public/common/components/toolbar/bulk_actions/use_bulk_alert_assignees_items.tsx b/x-pack/plugins/security_solution/public/common/components/toolbar/bulk_actions/use_bulk_alert_assignees_items.tsx index 4c25665afa5ca14..a91fc5ad8aede2a 100644 --- a/x-pack/plugins/security_solution/public/common/components/toolbar/bulk_actions/use_bulk_alert_assignees_items.tsx +++ b/x-pack/plugins/security_solution/public/common/components/toolbar/bulk_actions/use_bulk_alert_assignees_items.tsx @@ -19,6 +19,7 @@ import { isEmpty } from 'lodash/fp'; import { useLicense } from '../../../hooks/use_license'; import { useAlertsPrivileges } from '../../../../detections/containers/detection_engine/alerts/use_alerts_privileges'; import { ASSIGNEES_PANEL_WIDTH } from '../../assignees/constants'; +import type { BulkAlertAssigneesPanelComponentProps } from './alert_bulk_assignees'; import { BulkAlertAssigneesPanel } from './alert_bulk_assignees'; import * as i18n from './translations'; import { useSetAlertAssignees } from './use_set_alert_assignees'; @@ -45,7 +46,9 @@ export const useBulkAlertAssigneesItems = ({ const { hasIndexWrite } = useAlertsPrivileges(); const setAlertAssignees = useSetAlertAssignees(); - const handleOnAlertAssigneesSubmit = useCallback( + const handleOnAlertAssigneesSubmit = useCallback< + BulkAlertAssigneesPanelComponentProps['onSubmit'] + >( async (assignees, ids, onSuccess, setIsLoading) => { if (setAlertAssignees) { await setAlertAssignees(assignees, ids, onSuccess, setIsLoading); diff --git a/x-pack/plugins/security_solution/public/common/components/toolbar/bulk_actions/use_bulk_alert_tags_items.tsx b/x-pack/plugins/security_solution/public/common/components/toolbar/bulk_actions/use_bulk_alert_tags_items.tsx index c155d39e2a3a513..d83d2c7dad0ddf2 100644 --- a/x-pack/plugins/security_solution/public/common/components/toolbar/bulk_actions/use_bulk_alert_tags_items.tsx +++ b/x-pack/plugins/security_solution/public/common/components/toolbar/bulk_actions/use_bulk_alert_tags_items.tsx @@ -9,6 +9,7 @@ import { EuiFlexGroup, EuiIconTip, EuiFlexItem } from '@elastic/eui'; import type { RenderContentPanelProps } from '@kbn/triggers-actions-ui-plugin/public/types'; import React, { useCallback, useMemo } from 'react'; import { useAlertsPrivileges } from '../../../../detections/containers/detection_engine/alerts/use_alerts_privileges'; +import type { BulkAlertTagsPanelComponentProps } from './alert_bulk_tags'; import { BulkAlertTagsPanel } from './alert_bulk_tags'; import * as i18n from './translations'; import { useSetAlertTags } from './use_set_alert_tags'; @@ -27,7 +28,7 @@ export interface UseBulkAlertTagsPanel { export const useBulkAlertTagsItems = ({ refetch }: UseBulkAlertTagsItemsProps) => { const { hasIndexWrite } = useAlertsPrivileges(); const setAlertTags = useSetAlertTags(); - const handleOnAlertTagsSubmit = useCallback( + const handleOnAlertTagsSubmit = useCallback( async (tags, ids, onSuccess, setIsLoading) => { if (setAlertTags) { await setAlertTags(tags, ids, onSuccess, setIsLoading); diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_embeddable.tsx b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_embeddable.tsx index debeca81783d6c5..a72675d3814045b 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_embeddable.tsx +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_embeddable.tsx @@ -19,6 +19,7 @@ import type { TypedLensByValueInput, XYState, } from '@kbn/lens-plugin/public'; +import type { LensBaseEmbeddableInput } from '@kbn/lens-plugin/public/embeddable'; import { setAbsoluteRangeDatePicker } from '../../store/inputs/actions'; import { useKibana } from '../../lib/kibana'; import { useLensAttributes } from './use_lens_attributes'; @@ -159,7 +160,7 @@ const LensEmbeddableComponent: React.FC = ({ }); const updateDateRange = useCallback( - ({ range }) => { + ({ range }: { range: Array }) => { const [min, max] = range; dispatch( setAbsoluteRangeDatePicker({ @@ -172,7 +173,7 @@ const LensEmbeddableComponent: React.FC = ({ [dispatch, inputsModelId] ); - const onFilterCallback = useCallback( + const onFilterCallback = useCallback['onFilter']>( (event) => { if (disableOnClickFilter) { event.preventDefault(); diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/types.ts b/x-pack/plugins/security_solution/public/common/components/visualization_actions/types.ts index 6d285e0407292ee..f6a90ebfd479bd6 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/types.ts +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/types.ts @@ -11,6 +11,7 @@ import type { FormBasedPersistedState, TypedLensByValueInput, } from '@kbn/lens-plugin/public'; +import type { IKibanaSearchResponse } from '@kbn/search-types'; import type { DataViewSpec } from '@kbn/data-views-plugin/common'; import type { Action } from '@kbn/ui-actions-plugin/public'; import type { Filter, Query } from '@kbn/es-query'; @@ -145,7 +146,7 @@ export interface RequestStatistic { } export interface Response { - json?: { rawResponse?: object }; + json?: IKibanaSearchResponse; time?: number; } diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/use_embeddable_inspect.tsx b/x-pack/plugins/security_solution/public/common/components/visualization_actions/use_embeddable_inspect.tsx index ca80999a81062b9..ee577d4a310d971 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/use_embeddable_inspect.tsx +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/use_embeddable_inspect.tsx @@ -5,18 +5,19 @@ * 2.0. */ +import type { LensBaseEmbeddableInput } from '@kbn/lens-plugin/public/embeddable'; import { useCallback } from 'react'; -import type { OnEmbeddableLoaded } from './types'; +import type { OnEmbeddableLoaded, Request } from './types'; import { getRequestsAndResponses } from './utils'; export const useEmbeddableInspect = (onEmbeddableLoad?: OnEmbeddableLoaded) => { - const setInspectData = useCallback( + const setInspectData = useCallback>( (isLoading, adapters) => { if (!adapters) { return; } - const data = getRequestsAndResponses(adapters?.requests?.getRequests()); + const data = getRequestsAndResponses(adapters?.requests?.getRequests() as Request[]); onEmbeddableLoad?.({ requests: data.requests, diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/use_redirect_to_dashboard_from_lens.ts b/x-pack/plugins/security_solution/public/common/components/visualization_actions/use_redirect_to_dashboard_from_lens.ts index 1aebf72217c5bd5..3aee19bf6edd2e7 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/use_redirect_to_dashboard_from_lens.ts +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/use_redirect_to_dashboard_from_lens.ts @@ -5,6 +5,7 @@ * 2.0. */ +import type { RedirectToProps } from '@kbn/dashboard-plugin/public/dashboard_container/types'; import { useMemo, useCallback } from 'react'; import { SecurityPageName } from '../../../../common'; import { useNavigateTo } from '../../lib/kibana'; @@ -39,11 +40,11 @@ export const useRedirectToDashboardFromLens = ({ ); const redirectTo = useCallback( - (props) => { - if (props.destination === 'listing') { + (props?: RedirectToProps) => { + if (props?.destination === 'listing') { navigateTo({ url: dashboardListingUrl }); } - if (props.destination === 'dashboard') { + if (props?.destination === 'dashboard') { navigateTo({ url: getEditOrCreateDashboardUrl(props.id) }); } }, diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/use_save_to_library.tsx b/x-pack/plugins/security_solution/public/common/components/visualization_actions/use_save_to_library.tsx index 8940853444d1b65..c7a44842fc51378 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/use_save_to_library.tsx +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/use_save_to_library.tsx @@ -38,6 +38,8 @@ export const useSaveToLibrary = ({ getOriginatingPath={(dashboardId) => `${SecurityPageName.dashboards}/${getEditOrCreateDashboardPath(dashboardId)}` } + // Type 'string' is not assignable to type 'RedirectToProps | undefined'. + // @ts-expect-error redirectTo={redirectTo} />, startServices diff --git a/x-pack/plugins/security_solution/public/common/containers/source/index.tsx b/x-pack/plugins/security_solution/public/common/containers/source/index.tsx index f305088ef3d32d2..a121919b412e53d 100644 --- a/x-pack/plugins/security_solution/public/common/containers/source/index.tsx +++ b/x-pack/plugins/security_solution/public/common/containers/source/index.tsx @@ -105,14 +105,17 @@ export const useFetchIndex = ( const { addError } = useAppToasts(); const indexFieldsSearch = useCallback( - (iNames) => { + (iNames: string[]) => { const asyncSearch = async () => { try { setState({ ...state, loading: true }); abortCtrl.current = new AbortController(); const dv = await data.dataViews.create({ title: iNames.join(','), allowNoIndex: true }); const dataView = dv.toSpec(); - const { browserFields } = getDataViewStateFromIndexFields(iNames, dataView.fields); + const { browserFields } = getDataViewStateFromIndexFields( + iNames.join(','), + dataView.fields + ); previousIndexesName.current = dv.getIndexPattern().split(','); diff --git a/x-pack/plugins/security_solution/public/common/hooks/endpoint/use_navigate_by_router_event_handler.ts b/x-pack/plugins/security_solution/public/common/hooks/endpoint/use_navigate_by_router_event_handler.ts index b140252e13a68c1..2c0988e29ed85f3 100644 --- a/x-pack/plugins/security_solution/public/common/hooks/endpoint/use_navigate_by_router_event_handler.ts +++ b/x-pack/plugins/security_solution/public/common/hooks/endpoint/use_navigate_by_router_event_handler.ts @@ -27,7 +27,7 @@ export const useNavigateByRouterEventHandler = ( ): EventHandlerCallback => { const history = useHistory(); return useCallback( - (ev) => { + (ev: React.MouseEvent) => { try { if (onClick) { onClick(ev); diff --git a/x-pack/plugins/security_solution/public/common/hooks/endpoint/use_navigate_to_app_event_handler.ts b/x-pack/plugins/security_solution/public/common/hooks/endpoint/use_navigate_to_app_event_handler.ts index a4b998d3bca9823..1d284d21e91442a 100644 --- a/x-pack/plugins/security_solution/public/common/hooks/endpoint/use_navigate_to_app_event_handler.ts +++ b/x-pack/plugins/security_solution/public/common/hooks/endpoint/use_navigate_to_app_event_handler.ts @@ -41,7 +41,7 @@ export const useNavigateToAppEventHandler = ( const { path, state, onClick, deepLinkId, openInNewTab } = options || {}; return useCallback( - (ev) => { + (ev: React.MouseEvent) => { try { if (onClick) { onClick(ev); diff --git a/x-pack/plugins/security_solution/public/common/hooks/use_add_integrations_url.ts b/x-pack/plugins/security_solution/public/common/hooks/use_add_integrations_url.ts index 07a63013b0687e4..e80c1e871d49a38 100644 --- a/x-pack/plugins/security_solution/public/common/hooks/use_add_integrations_url.ts +++ b/x-pack/plugins/security_solution/public/common/hooks/use_add_integrations_url.ts @@ -27,7 +27,7 @@ export const useAddIntegrationsUrl = () => { const href = useMemo(() => prepend(integrationsUrl), [prepend, integrationsUrl]); const onClick = useCallback( - (e) => { + (e: React.SyntheticEvent) => { e.preventDefault(); navigateTo({ url: href }); }, diff --git a/x-pack/plugins/security_solution/public/common/utils/use_set_field_value_cb.ts b/x-pack/plugins/security_solution/public/common/utils/use_set_field_value_cb.ts index 8f57dd78d8a538c..c067e1747b4ff26 100644 --- a/x-pack/plugins/security_solution/public/common/utils/use_set_field_value_cb.ts +++ b/x-pack/plugins/security_solution/public/common/utils/use_set_field_value_cb.ts @@ -18,7 +18,7 @@ export const useSetFieldValueWithCallback = ({ setFieldValue: FormHook['setFieldValue']; }) => { const isWaitingRef = useRef(false); - const valueRef = useRef(); + const valueRef = useRef(); const [callback, setCallback] = useState<() => void>(() => null); useEffect(() => { @@ -30,7 +30,7 @@ export const useSetFieldValueWithCallback = ({ }, [value, callback]); return useCallback( - (v, cb) => { + (v: unknown, cb: () => void) => { setFieldValue(field, v); setCallback(() => cb); diff --git a/x-pack/plugins/security_solution/public/dashboards/components/dashboard_renderer.tsx b/x-pack/plugins/security_solution/public/dashboards/components/dashboard_renderer.tsx index 9fc53f1a4175be1..83f48d76246e52f 100644 --- a/x-pack/plugins/security_solution/public/dashboards/components/dashboard_renderer.tsx +++ b/x-pack/plugins/security_solution/public/dashboards/components/dashboard_renderer.tsx @@ -8,13 +8,18 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'; import type { DashboardContainerInput } from '@kbn/dashboard-plugin/common'; -import type { DashboardAPI, DashboardCreationOptions } from '@kbn/dashboard-plugin/public'; +import type { + DashboardAPI, + DashboardCreationOptions, + DashboardLocatorParams, +} from '@kbn/dashboard-plugin/public'; import { DashboardRenderer as DashboardContainerRenderer } from '@kbn/dashboard-plugin/public'; import { ViewMode } from '@kbn/embeddable-plugin/public'; import type { Filter, Query } from '@kbn/es-query'; import { useDispatch } from 'react-redux'; import { BehaviorSubject } from 'rxjs'; +import type { DashboardRendererProps } from '@kbn/dashboard-plugin/public/dashboard_container/external_api/dashboard_renderer'; import { APP_UI_ID } from '../../../common'; import { DASHBOARDS_PATH, SecurityPageName } from '../../../common/constants'; import { useGetSecuritySolutionUrl } from '../../common/components/link_to'; @@ -64,7 +69,7 @@ const DashboardRendererComponent = ({ const isCreateDashboard = !savedObjectId; const getSecuritySolutionDashboardUrl = useCallback( - ({ dashboardId }) => { + ({ dashboardId }: DashboardLocatorParams) => { return getSecuritySolutionUrl({ deepLinkId: SecurityPageName.dashboards, path: dashboardId, @@ -73,7 +78,7 @@ const DashboardRendererComponent = ({ [getSecuritySolutionUrl] ); - const goToDashboard = useCallback( + const goToDashboard = useCallback['navigate']>( /** * Note: Due to the query bar being separate from the portable dashboard, the "Use filters and query from origin * dashboard" and "Use date range from origin dashboard" Link embeddable settings do not make sense in this context. diff --git a/x-pack/plugins/security_solution/public/dashboards/components/dashboard_tool_bar.tsx b/x-pack/plugins/security_solution/public/dashboards/components/dashboard_tool_bar.tsx index eb74f7c563500b3..3a5e3d43eae6305 100644 --- a/x-pack/plugins/security_solution/public/dashboards/components/dashboard_tool_bar.tsx +++ b/x-pack/plugins/security_solution/public/dashboards/components/dashboard_tool_bar.tsx @@ -12,6 +12,7 @@ import { ViewMode } from '@kbn/embeddable-plugin/public'; import type { ChromeBreadcrumb } from '@kbn/core/public'; import type { DashboardCapabilities } from '@kbn/dashboard-plugin/common'; +import type { RedirectToProps } from '@kbn/dashboard-plugin/public/dashboard_container/types'; import { SecurityPageName } from '../../../common'; import { useCapabilities, useKibana, useNavigation } from '../../common/lib/kibana'; import { APP_NAME } from '../../../common/constants'; @@ -30,7 +31,7 @@ const DashboardToolBarComponent = ({ const { navigateTo, getAppUrl } = useNavigation(); const redirectTo = useCallback( - ({ destination, id }) => { + ({ destination, id }: RedirectToProps & { id?: string }) => { if (destination === 'listing') { navigateTo({ deepLinkId: SecurityPageName.dashboards }); } diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_creation/components/ml_jobs_description/admin/ml_admin_job_description.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_creation/components/ml_jobs_description/admin/ml_admin_job_description.tsx index 7f1236aef08cd78..af30519a337774c 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_creation/components/ml_jobs_description/admin/ml_admin_job_description.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_creation/components/ml_jobs_description/admin/ml_admin_job_description.tsx @@ -10,6 +10,7 @@ import React, { useCallback, useMemo, memo } from 'react'; import { useEnableDataFeed } from '../../../../../common/components/ml_popover/hooks/use_enable_data_feed'; import type { SecurityJob } from '../../../../../common/components/ml_popover/types'; +import type { JobSwitchProps } from '../../../../../common/components/ml_popover/jobs_table/job_switch'; import { JobSwitch } from '../../../../../common/components/ml_popover/jobs_table/job_switch'; import { MlJobItem } from '../ml_job_item'; @@ -31,8 +32,8 @@ const MlAdminJobDescriptionComponent: FC = ({ isLoading: isLoadingEnableDataFeed, } = useEnableDataFeed(); - const handleJobStateChange = useCallback( - async (_, latestTimestampMs: number, enable: boolean) => { + const handleJobStateChange = useCallback( + async (_, latestTimestampMs, enable) => { if (enable) { await enableDatafeed(job, latestTimestampMs); } else { diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_creation/components/schedule_item_form/index.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_creation/components/schedule_item_form/index.tsx index 4dbbf1f3a9206a7..997930926f26f91 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_creation/components/schedule_item_form/index.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_creation/components/schedule_item_form/index.tsx @@ -5,6 +5,7 @@ * 2.0. */ +import type { EuiSelectProps, EuiFieldNumberProps } from '@elastic/eui'; import { EuiFlexGroup, EuiFlexItem, @@ -106,7 +107,7 @@ export const ScheduleItem = ({ const { isInvalid, errorMessage } = getFieldValidityAndErrorMessage(field); const { value, setValue } = field; - const onChangeTimeType = useCallback( + const onChangeTimeType = useCallback>( (e) => { setTimeType(e.target.value); setValue(`${timeVal}${e.target.value}`); @@ -114,7 +115,7 @@ export const ScheduleItem = ({ [setValue, timeVal] ); - const onChangeTimeVal = useCallback( + const onChangeTimeVal = useCallback>( (e) => { const sanitizedValue = getNumberFromUserInput(e.target.value, minimumValue); setTimeVal(sanitizedValue); diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/components/eql_query_bar/footer.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/components/eql_query_bar/footer.tsx index 7f7a6ab21a3856b..fd2bc98a048b060 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/components/eql_query_bar/footer.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/components/eql_query_bar/footer.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import type { EuiComboBoxOptionOption } from '@elastic/eui'; +import type { EuiComboBoxOptionOption, EuiFieldNumberProps } from '@elastic/eui'; import { EuiButtonIcon, EuiComboBox, @@ -78,7 +78,7 @@ export const EqlQueryBarFooter: FC = ({ onOptionsChange, }) => { const [openEqlSettings, setIsOpenEqlSettings] = useState(false); - const [localSize, setLocalSize] = useState(optionsSelected?.size ?? 100); + const [localSize, setLocalSize] = useState(optionsSelected?.size ?? 100); const debounceSize = useRef(); const openEqlSettingsHandler = useCallback(() => { @@ -124,10 +124,10 @@ export const EqlQueryBarFooter: FC = ({ }, [onOptionsChange] ); - const handleSizeField = useCallback( + const handleSizeField = useCallback>( (evt) => { if (onOptionsChange) { - setLocalSize(evt?.target?.value); + setLocalSize(evt?.target?.valueAsNumber); if (debounceSize.current?.cancel) { debounceSize.current?.cancel(); } diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/components/step_define_rule/index.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/components/step_define_rule/index.tsx index 1ef86c1cab1ed8d..cc4d968d1b52552 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/components/step_define_rule/index.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/components/step_define_rule/index.tsx @@ -33,6 +33,7 @@ import type { SavedQuery } from '@kbn/data-plugin/public'; import type { DataViewBase } from '@kbn/es-query'; import { FormattedMessage } from '@kbn/i18n-react'; import { useSetFieldValueWithCallback } from '../../../../common/utils/use_set_field_value_cb'; +import type { SetRuleQuery } from '../../../../detections/containers/detection_engine/rules/use_rule_from_timeline'; import { useRuleFromTimeline } from '../../../../detections/containers/detection_engine/rules/use_rule_from_timeline'; import { isMlRule } from '../../../../../common/machine_learning/helpers'; import type { EqlOptionsSelected, FieldsEqlOptions } from '../../../../../common/search_strategy'; @@ -65,7 +66,7 @@ import { useFormData, UseMultiFields, } from '../../../../shared_imports'; -import type { FormHook } from '../../../../shared_imports'; +import type { FormHook, FieldHook } from '../../../../shared_imports'; import { schema } from './schema'; import { getTermsAggregationFields } from './utils'; import { useExperimentalFeatureFieldsTransform } from './use_experimental_feature_fields_transform'; @@ -161,6 +162,14 @@ const IntendedRuleTypeEuiFormRow = styled(RuleTypeEuiFormRow)` ${({ theme }) => `padding-left: ${theme.eui.euiSizeXL};`} `; +/* eslint-disable react/no-unused-prop-types */ +interface GroupByChildrenProps { + groupByRadioSelection: FieldHook; + groupByDurationUnit: FieldHook; + groupByDurationValue: FieldHook; +} +/* eslint-enable react/no-unused-prop-types */ + // eslint-disable-next-line complexity const StepDefineRuleComponent: FC = ({ dataSourceType, @@ -225,7 +234,7 @@ const StepDefineRuleComponent: FC = ({ setFieldValue, }); - const handleSetRuleFromTimeline = useCallback( + const handleSetRuleFromTimeline = useCallback( ({ index: timelineIndex, queryBar: timelineQueryBar, eqlOptions }) => { const setQuery = () => { setFieldValue('index', timelineIndex); @@ -426,7 +435,12 @@ const StepDefineRuleComponent: FC = ({ }, []); const ThresholdInputChildren = useCallback( - ({ thresholdField, thresholdValue, thresholdCardinalityField, thresholdCardinalityValue }) => ( + ({ + thresholdField, + thresholdValue, + thresholdCardinalityField, + thresholdCardinalityValue, + }: Record) => ( = ({ ); const ThreatMatchInputChildren = useCallback( - ({ threatMapping }) => ( + ({ threatMapping }: Record) => ( = ({ const isMissingFieldsDisabled = areSuppressionFieldsDisabled || !areSuppressionFieldsSelected; const GroupByChildren = useCallback( - ({ groupByRadioSelection, groupByDurationUnit, groupByDurationValue }) => ( + ({ + groupByRadioSelection, + groupByDurationUnit, + groupByDurationValue, + }: GroupByChildrenProps) => ( = ({ ); const AlertSuppressionMissingFields = useCallback( - ({ suppressionMissingFields }) => ( + ({ suppressionMissingFields }: Record>) => ( { const { setValue } = props.field; const onChange = useCallback( - (e) => { + (e: React.ChangeEvent) => { const throttle = e.target.value; setValue(throttle); }, diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/pages/rule_editing/index.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/pages/rule_editing/index.tsx index 5e6ed40d4d282f7..deb58fbed49a322 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/pages/rule_editing/index.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/pages/rule_editing/index.tsx @@ -455,7 +455,7 @@ const EditRulePageComponent: FC<{ rule: RuleResponse }> = ({ rule }) => { }; const goToDetailsRule = useCallback( - (ev) => { + (ev: React.SyntheticEvent) => { ev.preventDefault(); navigateToApp(APP_UI_ID, { deepLinkId: SecurityPageName.rules, diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/all_exception_items_table/search_bar.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/all_exception_items_table/search_bar.tsx index 36dac931265c234..5bcfc5b0784d02e 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/all_exception_items_table/search_bar.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/all_exception_items_table/search_bar.tsx @@ -6,6 +6,7 @@ */ import React, { useCallback, useMemo } from 'react'; +import type { EuiSearchBarProps } from '@elastic/eui'; import { EuiFlexGroup, EuiFlexItem, EuiButton, EuiSearchBar } from '@elastic/eui'; import * as i18n from './translations'; @@ -61,8 +62,8 @@ const ExceptionsViewerSearchBarComponent = ({ onSearch, onAddExceptionClick, }: ExceptionsViewerSearchBarProps): JSX.Element => { - const handleOnSearch = useCallback( - ({ queryText }): void => { + const handleOnSearch = useCallback>( + ({ queryText }) => { onSearch({ search: queryText }); }, [onSearch] diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/flyout_components/add_to_lists_table/link_list_switch/index.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/flyout_components/add_to_lists_table/link_list_switch/index.tsx index 486f0c7a5bf4cc3..cb87fea8cd25314 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/flyout_components/add_to_lists_table/link_list_switch/index.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/flyout_components/add_to_lists_table/link_list_switch/index.tsx @@ -5,6 +5,7 @@ * 2.0. */ import React, { memo, useCallback, useMemo } from 'react'; +import type { EuiSwitchProps } from '@elastic/eui'; import { EuiFlexItem, EuiSwitch } from '@elastic/eui'; import type { ExceptionListRuleReferencesSchema } from '../../../../../../../common/api/detection_engine/rule_exceptions'; @@ -26,7 +27,7 @@ export const LinkListSwitch = memo( () => Boolean(linkedList.find((l) => l.id === list.id)), [linkedList, list.id] ); - const onLinkOrUnlinkList = useCallback( + const onLinkOrUnlinkList = useCallback( ({ target: { checked } }) => { const newLinkedLists = !checked ? linkedList?.filter((item) => item.id !== list.id) diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/flyout_components/add_to_rules_table/link_rule_switch/index.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/flyout_components/add_to_rules_table/link_rule_switch/index.tsx index 080a59a8082f90b..25fcf6f942c67af 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/flyout_components/add_to_rules_table/link_rule_switch/index.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/flyout_components/add_to_rules_table/link_rule_switch/index.tsx @@ -5,6 +5,7 @@ * 2.0. */ import React, { memo, useCallback, useMemo } from 'react'; +import type { EuiSwitchProps } from '@elastic/eui'; import { EuiFlexItem, EuiSwitch } from '@elastic/eui'; import type { RuleResponse } from '../../../../../../../common/api/detection_engine'; @@ -22,7 +23,7 @@ export const LinkRuleSwitch = memo( () => Boolean(linkedRules.find((r) => r.id === rule.id)), [linkedRules, rule.id] ); - const onLinkOrUnlinkRule = useCallback( + const onLinkOrUnlinkRule = useCallback( ({ target: { checked } }) => { const newLinkedRules = !checked ? linkedRules?.filter((item) => item.id !== rule.id) diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/add_prebuilt_rules_table/add_prebuilt_rules_table_filters.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/add_prebuilt_rules_table/add_prebuilt_rules_table_filters.tsx index 913dbd5a0fbc1a7..5640f64cd7a0b9e 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/add_prebuilt_rules_table/add_prebuilt_rules_table_filters.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/add_prebuilt_rules_table/add_prebuilt_rules_table_filters.tsx @@ -31,7 +31,7 @@ const AddPrebuiltRulesTableFiltersComponent = () => { const { tags: selectedTags } = filterOptions; const handleOnSearch = useCallback( - (filterString) => { + (filterString: string) => { setFilterOptions((filters) => ({ ...filters, filter: filterString.trim(), diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/bulk_duplicate_exceptions_confirmation.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/bulk_duplicate_exceptions_confirmation.tsx index 74575c327fbc8dc..fe01accf5e10447 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/bulk_duplicate_exceptions_confirmation.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/bulk_duplicate_exceptions_confirmation.tsx @@ -27,8 +27,8 @@ const BulkActionDuplicateExceptionsConfirmationComponent = ({ ); const handleRadioChange = useCallback( - (optionId) => { - setSelectedDuplicateOption(optionId); + (optionId: string) => { + setSelectedDuplicateOption(optionId as DuplicateOptions); }, [setSelectedDuplicateOption] ); diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/rules_table_filters/rules_table_filters.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/rules_table_filters/rules_table_filters.tsx index e7e81b8dd334275..e900c20eae9a42d 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/rules_table_filters/rules_table_filters.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/rules_table_filters/rules_table_filters.tsx @@ -47,7 +47,7 @@ const RulesTableFiltersComponent = () => { } = filterOptions; const handleOnSearch = useCallback( - (filterString) => { + (filterString: string) => { startTransaction({ name: RULES_TABLE_ACTIONS.FILTER }); setFilterOptions({ filter: filterString.trim() }); }, diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/upgrade_prebuilt_rules_table/upgrade_prebuilt_rules_table_filters.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/upgrade_prebuilt_rules_table/upgrade_prebuilt_rules_table_filters.tsx index fc8fecab1e07c6b..215a810bf3aa21b 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/upgrade_prebuilt_rules_table/upgrade_prebuilt_rules_table_filters.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/upgrade_prebuilt_rules_table/upgrade_prebuilt_rules_table_filters.tsx @@ -31,7 +31,7 @@ const UpgradePrebuiltRulesTableFiltersComponent = () => { const { tags: selectedTags } = filterOptions; const handleOnSearch = useCallback( - (filterString) => { + (filterString: string) => { setFilterOptions((filters) => ({ ...filters, filter: filterString.trim(), diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/pages/coverage_overview/helpers.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/pages/coverage_overview/helpers.ts index ecd67546e762721..4e6d42e4dc60933 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/pages/coverage_overview/helpers.ts +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/pages/coverage_overview/helpers.ts @@ -28,10 +28,12 @@ export const extractSelected = < return options.filter((option) => option.checked === 'on').map((option) => option.label); }; -export const populateSelected = ( - allOptions: EuiSelectableOption[], +export const populateSelected = < + T extends CoverageOverviewRuleSource | CoverageOverviewRuleActivity +>( + allOptions: Array>, selected: string[] -): EuiSelectableOption[] => +): Array> => allOptions.map((option) => selected.includes(option.label) ? { ...option, checked: 'on' } : option ); diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/pages/coverage_overview/rule_activity_filter.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/pages/coverage_overview/rule_activity_filter.tsx index 43159822deab357..ae7b6445a70c46e 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/pages/coverage_overview/rule_activity_filter.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/pages/coverage_overview/rule_activity_filter.tsx @@ -51,7 +51,7 @@ const RuleActivityFilterComponent = ({ const options = populateSelected(ruleActivityFilterDefaultOptions, selected); const handleSelectableOnChange = useCallback( - (newOptions) => { + (newOptions: Array>) => { const formattedOptions = extractSelected(newOptions); onChange(formattedOptions); }, @@ -95,7 +95,7 @@ const RuleActivityFilterComponent = ({ panelPaddingSize="none" > {i18n.CoverageOverviewFilterPopoverTitle} - data-test-subj="coverageOverviewFilterList" options={options} onChange={handleSelectableOnChange} diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/pages/coverage_overview/rule_source_filter.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/pages/coverage_overview/rule_source_filter.tsx index e55450f0a069ab7..08bc8c334743b41 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/pages/coverage_overview/rule_source_filter.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/pages/coverage_overview/rule_source_filter.tsx @@ -48,7 +48,10 @@ const RuleSourceFilterComponent = ({ const numActiveFilters = useMemo(() => selected.length, [selected]); - const options = populateSelected(ruleSourceFilterDefaultOptions, selected); + const options = populateSelected( + ruleSourceFilterDefaultOptions, + selected + ) as EuiSelectableOption[]; const handleSelectableOnChange = useCallback( (newOptions) => { diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_response_actions/osquery/osquery_response_action_form_field.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_response_actions/osquery/osquery_response_action_form_field.tsx index 7898dfef3ea90cb..d355187b1d0bc53 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_response_actions/osquery/osquery_response_action_form_field.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_response_actions/osquery/osquery_response_action_form_field.tsx @@ -5,7 +5,10 @@ * 2.0. */ -import type { FieldHook } from '@kbn/es-ui-shared-plugin/static/forms/hook_form_lib'; +import type { + FieldHook, + ValidationError, +} from '@kbn/es-ui-shared-plugin/static/forms/hook_form_lib'; import React, { useCallback, useMemo } from 'react'; import { isEmpty, map } from 'lodash'; import { useFormContext } from '@kbn/es-ui-shared-plugin/static/forms/hook_form_lib'; @@ -22,7 +25,7 @@ export const ResponseActionFormField = React.memo(({ field }: { field: FieldHook ); const handleError = useCallback( - (newErrors) => { + (newErrors: ValidationError) => { if (isEmpty(newErrors)) { clearErrors(); } else { diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_response_actions/response_action_add_button.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_response_actions/response_action_add_button.tsx index a8fcccee30effa2..4dc903bbd1c0ec4 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_response_actions/response_action_add_button.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_response_actions/response_action_add_button.tsx @@ -46,7 +46,7 @@ export const ResponseActionAddButton = ({ const isPlatinumPlus = useLicense().isPlatinumPlus(); const handleAddActionType = useCallback( - (item) => { + (item: ResponseActionType) => { setAddResponseActionButtonShown(false); addActionType(); diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_response_actions/response_actions_wrapper.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_response_actions/response_actions_wrapper.tsx index 39f036a1b332225..7e2fb59cea848d0 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_response_actions/response_actions_wrapper.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_response_actions/response_actions_wrapper.tsx @@ -23,7 +23,7 @@ interface ResponseActionsWrapperProps { export const ResponseActionsWrapper = React.memo( ({ items, removeItem, supportedResponseActionTypes, addItem }) => { const actionTypeIdRef = useRef(null); - const updateActionTypeId = useCallback((id) => { + const updateActionTypeId = useCallback((id: string) => { actionTypeIdRef.current = id; }, []); diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/alerts_histogram_panel/index.tsx b/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/alerts_histogram_panel/index.tsx index c2f25b4b5c80cd7..0c1c33da81e5018 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/alerts_histogram_panel/index.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/alerts_histogram_panel/index.tsx @@ -8,6 +8,7 @@ import type { Action } from '@kbn/ui-actions-plugin/public'; import type { EuiComboBox, EuiTitleSize } from '@elastic/eui'; import { EuiFlexGroup, EuiFlexItem, EuiSpacer, EuiToolTip } from '@elastic/eui'; +import type { SyntheticEvent } from 'react'; import React, { memo, useCallback, useMemo, useState, useEffect } from 'react'; import styled from 'styled-components'; import { isEmpty, noop } from 'lodash/fp'; @@ -160,7 +161,7 @@ export const AlertsHistogramPanel = memo( }); const goToDetectionEngine = useCallback( - (ev) => { + (ev: SyntheticEvent) => { ev.preventDefault(); navigateToApp(APP_UI_ID, { deepLinkId: SecurityPageName.alerts, diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/common/components.tsx b/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/common/components.tsx index bf050c2eedab9be..3a0dccc492475c4 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/common/components.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/common/components.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import type { EuiComboBoxOptionOption } from '@elastic/eui'; +import type { EuiComboBoxOptionOption, EuiComboBoxProps } from '@elastic/eui'; import { EuiPanel, EuiComboBox } from '@elastic/eui'; import styled from 'styled-components'; import type { LegacyRef } from 'react'; @@ -53,7 +53,7 @@ export const KpiPanel = styled(EuiPanel)<{ interface StackedBySelectProps { 'aria-label'?: string; 'data-test-subj'?: string; - dropDownoptions?: Array>; + dropDownoptions?: Array>; inputRef?: (inputRef: HTMLInputElement | null) => void; isDisabled?: boolean; onSelect: (selected: string) => void; @@ -84,9 +84,9 @@ export const StackByComboBox = React.forwardRef( }: StackedBySelectProps, ref ) => { - const onChange = useCallback( + const onChange = useCallback['onChange']>>( (options) => { - if (options && options.length > 0) { + if (options && options.length && options[0].value) { onSelect(options[0].value); } else { onSelect(''); @@ -117,7 +117,7 @@ export const StackByComboBox = React.forwardRef( isDisabled={isDisabled} placeholder={i18n.STACK_BY_PLACEHOLDER} prepend={prepend} - ref={ref as LegacyRef> | undefined} + ref={ref as LegacyRef> | undefined} singleSelection={singleSelection} isClearable={false} sortMatchesBy="startsWith" diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/common/hooks.ts b/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/common/hooks.ts index 75d86873c52bcbf..a666d25b1df1014 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/common/hooks.ts +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/common/hooks.ts @@ -76,7 +76,7 @@ export interface GetAggregatableFields { export function getAggregatableFields( fields: GetAggregatableFields, useLensCompatibleFields?: boolean -): EuiComboBoxOptionOption[] { +): Array> { const result = []; for (const [key, field] of Object.entries(fields)) { if (useLensCompatibleFields) { diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_table/alerts_grouping.tsx b/x-pack/plugins/security_solution/public/detections/components/alerts_table/alerts_grouping.tsx index fd7ca232ca8eaae..8b02530fec07ab5 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_table/alerts_grouping.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_table/alerts_grouping.tsx @@ -12,6 +12,7 @@ import { isNoneGroup, useGrouping } from '@kbn/grouping'; import { isEmpty, isEqual } from 'lodash/fp'; import type { Storage } from '@kbn/kibana-utils-plugin/public'; import type { TableIdLiteral } from '@kbn/securitysolution-data-table'; +import type { GroupingArgs } from '@kbn/grouping/src'; import { groupIdSelector } from '../../../common/store/grouping/selectors'; import { getDefaultGroupingOptions } from '../../../common/utils/alerts'; import { useDeepEqualSelector } from '../../../common/hooks/use_selector'; @@ -89,7 +90,7 @@ const GroupedAlertsTableComponent: React.FC = (props) [telemetry] ); - const onOptionsChange = useCallback( + const onOptionsChange = useCallback['onOptionsChange']>>( (options) => { dispatch( updateGroups({ diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/use_add_bulk_to_timeline.tsx b/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/use_add_bulk_to_timeline.tsx index e0e11ad0251b51f..044fb10a6ac12f0 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/use_add_bulk_to_timeline.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/use_add_bulk_to_timeline.tsx @@ -143,7 +143,8 @@ export const useAddBulkToTimelineAction = ({ }); const updateTimelineIsLoading = useCallback( - (payload) => dispatch(timelineActions.updateIsLoading(payload)), + (payload: Parameters[0]) => + dispatch(timelineActions.updateIsLoading(payload)), [dispatch] ); diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/use_add_exception_flyout.tsx b/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/use_add_exception_flyout.tsx index 40c855341a1e9a5..dba19fda539cbb9 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/use_add_exception_flyout.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/use_add_exception_flyout.tsx @@ -55,7 +55,7 @@ export const useExceptionFlyout = ({ }, [setAllTourStepsHidden]); const onAddExceptionConfirm = useCallback( - (didRuleChange: boolean, didCloseAlert: boolean, didBulkCloseAlert) => { + (didRuleChange: boolean, didCloseAlert: boolean, didBulkCloseAlert: boolean) => { if (refetch && (isActiveTimelines === false || didBulkCloseAlert)) { refetch(); } diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/use_investigate_in_timeline.tsx b/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/use_investigate_in_timeline.tsx index 211bfd0db2dc12b..a68d773468e7587 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/use_investigate_in_timeline.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/use_investigate_in_timeline.tsx @@ -136,7 +136,8 @@ export const useInvestigateInTimeline = ({ ); const updateTimelineIsLoading = useCallback( - (payload) => dispatch(timelineActions.updateIsLoading(payload)), + (payload: Parameters[0]) => + dispatch(timelineActions.updateIsLoading(payload)), [dispatch] ); diff --git a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/use_rule_from_timeline.tsx b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/use_rule_from_timeline.tsx index 29cec20f12d79b9..a8eec62f2d58ad3 100644 --- a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/use_rule_from_timeline.tsx +++ b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/use_rule_from_timeline.tsx @@ -31,7 +31,7 @@ export interface RuleFromTimeline { onOpenTimeline: (timeline: TimelineModel) => void; } -type SetRuleQuery = ({ +export type SetRuleQuery = ({ index, queryBar, eqlOptions, diff --git a/x-pack/plugins/security_solution/public/detections/hooks/trigger_actions_alert_table/use_actions_column.tsx b/x-pack/plugins/security_solution/public/detections/hooks/trigger_actions_alert_table/use_actions_column.tsx index 4f2c995b163d5de..59e3cf9f07f9ce9 100644 --- a/x-pack/plugins/security_solution/public/detections/hooks/trigger_actions_alert_table/use_actions_column.tsx +++ b/x-pack/plugins/security_solution/public/detections/hooks/trigger_actions_alert_table/use_actions_column.tsx @@ -8,7 +8,10 @@ import type { EcsSecurityExtension as Ecs } from '@kbn/securitysolution-ecs'; import React, { useCallback, useContext, useMemo } from 'react'; import { useSelector } from 'react-redux'; -import type { AlertsTableConfigurationRegistry } from '@kbn/triggers-actions-ui-plugin/public/types'; +import type { + AlertsTableConfigurationRegistry, + RenderCustomActionsRowArgs, +} from '@kbn/triggers-actions-ui-plugin/public/types'; import { TableId } from '@kbn/securitysolution-data-table'; import { useIsExperimentalFeatureEnabled } from '../../../common/hooks/use_experimental_features'; import { StatefulEventContext } from '../../../common/components/events_viewer/stateful_event_context'; @@ -61,7 +64,7 @@ export const getUseActionColumnHook = clearSelection, ecsAlert: alert, nonEcsData, - }) => { + }: RenderCustomActionsRowArgs) => { const timelineItem: TimelineItem = { _id: (alert as Ecs)._id, _index: (alert as Ecs)._index, diff --git a/x-pack/plugins/security_solution/public/detections/hooks/trigger_actions_alert_table/use_trigger_actions_browser_fields_options.tsx b/x-pack/plugins/security_solution/public/detections/hooks/trigger_actions_alert_table/use_trigger_actions_browser_fields_options.tsx index e2876e962fd20f8..a627131ff05c0f1 100644 --- a/x-pack/plugins/security_solution/public/detections/hooks/trigger_actions_alert_table/use_trigger_actions_browser_fields_options.tsx +++ b/x-pack/plugins/security_solution/public/detections/hooks/trigger_actions_alert_table/use_trigger_actions_browser_fields_options.tsx @@ -6,6 +6,7 @@ */ import { useCallback, useMemo } from 'react'; import type { AlertsTableConfigurationRegistry } from '@kbn/triggers-actions-ui-plugin/public/types'; +import type { EuiDataGridColumn } from '@elastic/eui'; import { useFieldBrowserOptions } from '../../../timelines/components/fields_browser'; import type { SourcererScopeName } from '../../../sourcerer/store/model'; @@ -13,7 +14,7 @@ export const getUseTriggersActionsFieldBrowserOptions = (scopeId: SourcererScope const useTriggersActionsFieldBrowserOptions: AlertsTableConfigurationRegistry['useFieldBrowserOptions'] = ({ onToggleColumn }) => { const upsertColumn = useCallback( - (column) => { + (column: EuiDataGridColumn) => { onToggleColumn(column.id); }, [onToggleColumn] diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/detection_engine.tsx b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/detection_engine.tsx index 31116f7c5ecd936..7784fbb5760c326 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/detection_engine.tsx +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/detection_engine.tsx @@ -223,7 +223,7 @@ const DetectionEnginePageComponent: React.FC = () ); const goToRules = useCallback( - (ev) => { + (ev: React.MouseEvent) => { ev.preventDefault(); navigateToUrl(formatUrl(getRulesUrl())); }, diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/details/components/edit_rule_settings_button_link.tsx b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/details/components/edit_rule_settings_button_link.tsx index 6ef7ebb0cae4cf9..f1572b326a90a30 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/details/components/edit_rule_settings_button_link.tsx +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/details/components/edit_rule_settings_button_link.tsx @@ -29,7 +29,7 @@ export function EditRuleSettingButtonLink({ application: { navigateToApp }, } = useKibana().services; const goToEditRule = useCallback( - (ev) => { + (ev: React.SyntheticEvent) => { ev.preventDefault(); navigateToApp(APP_UI_ID, { deepLinkId: SecurityPageName.rules, diff --git a/x-pack/plugins/security_solution/public/entity_analytics/components/asset_criticality_file_uploader/asset_criticality_file_uploader.tsx b/x-pack/plugins/security_solution/public/entity_analytics/components/asset_criticality_file_uploader/asset_criticality_file_uploader.tsx index ddffe01955b29d8..0acd1f831ca7104 100644 --- a/x-pack/plugins/security_solution/public/entity_analytics/components/asset_criticality_file_uploader/asset_criticality_file_uploader.tsx +++ b/x-pack/plugins/security_solution/public/entity_analytics/components/asset_criticality_file_uploader/asset_criticality_file_uploader.tsx @@ -61,7 +61,7 @@ export const AssetCriticalityFileUploader: React.FC = () => { }, [telemetry] ); - const onValidationError = useCallback((message) => { + const onValidationError = useCallback((message: string) => { dispatch({ type: 'fileError', payload: { message } }); }, []); diff --git a/x-pack/plugins/security_solution/public/entity_analytics/components/host_risk_score_table/index.tsx b/x-pack/plugins/security_solution/public/entity_analytics/components/host_risk_score_table/index.tsx index 5dca054f013cd92..a451c5030212d1b 100644 --- a/x-pack/plugins/security_solution/public/entity_analytics/components/host_risk_score_table/index.tsx +++ b/x-pack/plugins/security_solution/public/entity_analytics/components/host_risk_score_table/index.tsx @@ -9,7 +9,12 @@ import React, { useMemo, useCallback } from 'react'; import { useDispatch } from 'react-redux'; import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; -import type { Columns, Criteria, ItemsPerRow } from '../../../explore/components/paginated_table'; +import type { + Columns, + Criteria, + ItemsPerRow, + SiemTables, +} from '../../../explore/components/paginated_table'; import { PaginatedTable } from '../../../explore/components/paginated_table'; import { useDeepEqualSelector } from '../../../common/hooks/use_selector'; import { hostsActions, hostsModel, hostsSelectors } from '../../../explore/hosts/store'; @@ -81,7 +86,7 @@ const HostRiskScoreTableComponent: React.FC = ({ const { activePage, limit, sort } = useDeepEqualSelector((state: State) => getHostRiskScoreSelector(state, hostsModel.HostsType.page) ); - const updateLimitPagination = useCallback( + const updateLimitPagination = useCallback( (newLimit) => dispatch( hostsActions.updateTableLimit({ @@ -93,7 +98,7 @@ const HostRiskScoreTableComponent: React.FC = ({ [type, dispatch] ); - const updateActivePage = useCallback( + const updateActivePage = useCallback( (newPage) => dispatch( hostsActions.updateTableActivePage({ diff --git a/x-pack/plugins/security_solution/public/entity_analytics/components/risk_summary_flyout/risk_summary.tsx b/x-pack/plugins/security_solution/public/entity_analytics/components/risk_summary_flyout/risk_summary.tsx index 21ea627d3f65d14..b0d988eaeac1acd 100644 --- a/x-pack/plugins/security_solution/public/entity_analytics/components/risk_summary_flyout/risk_summary.tsx +++ b/x-pack/plugins/security_solution/public/entity_analytics/components/risk_summary_flyout/risk_summary.tsx @@ -95,7 +95,7 @@ const FlyoutRiskSummaryComponent = ({ ); const onToggle = useCallback( - (isOpen) => { + (isOpen: boolean) => { const entity = isUserRiskData(riskData) ? 'user' : 'host'; telemetry.reportToggleRiskSummaryClicked({ diff --git a/x-pack/plugins/security_solution/public/entity_analytics/components/severity/severity_filter_group.tsx b/x-pack/plugins/security_solution/public/entity_analytics/components/severity/severity_filter_group.tsx index 9ecb9d9cd6cdb49..df99f39091a9297 100644 --- a/x-pack/plugins/security_solution/public/entity_analytics/components/severity/severity_filter_group.tsx +++ b/x-pack/plugins/security_solution/public/entity_analytics/components/severity/severity_filter_group.tsx @@ -6,7 +6,7 @@ */ import React, { useCallback, useMemo, useState } from 'react'; -import type { FilterChecked } from '@elastic/eui'; +import type { FilterChecked, EuiSelectableProps } from '@elastic/eui'; import { EuiFilterButton, EuiFilterGroup, @@ -67,8 +67,10 @@ export const SeverityFilterGroup: React.FC<{ })); }, [severityCount, selectedSeverities]); - const updateSeverityFilter = useCallback( - (newSelection: SeverityItems[], _, changedSeverity: SeverityItems) => { + const updateSeverityFilter = useCallback< + NonNullable['onChange']> + >( + (newSelection, _, changedSeverity) => { if (changedSeverity.checked === 'on') { telemetry.reportEntityRiskFiltered({ entity: riskEntity, diff --git a/x-pack/plugins/security_solution/public/entity_analytics/components/user_risk_score_table/index.tsx b/x-pack/plugins/security_solution/public/entity_analytics/components/user_risk_score_table/index.tsx index 6a99e64d04b2799..0e2c64f84d6102a 100644 --- a/x-pack/plugins/security_solution/public/entity_analytics/components/user_risk_score_table/index.tsx +++ b/x-pack/plugins/security_solution/public/entity_analytics/components/user_risk_score_table/index.tsx @@ -9,7 +9,12 @@ import React, { useMemo, useCallback } from 'react'; import { useDispatch } from 'react-redux'; import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; -import type { Columns, Criteria, ItemsPerRow } from '../../../explore/components/paginated_table'; +import type { + Columns, + Criteria, + ItemsPerRow, + SiemTables, +} from '../../../explore/components/paginated_table'; import { PaginatedTable } from '../../../explore/components/paginated_table'; import { getUserRiskScoreColumns } from './columns'; @@ -82,7 +87,7 @@ const UserRiskScoreTableComponent: React.FC = ({ const { activePage, limit, sort } = useDeepEqualSelector((state: State) => getUserRiskScoreSelector(state) ); - const updateLimitPagination = useCallback( + const updateLimitPagination = useCallback( (newLimit) => { dispatch( usersActions.updateTableLimit({ @@ -95,7 +100,7 @@ const UserRiskScoreTableComponent: React.FC = ({ [type, dispatch] ); - const updateActivePage = useCallback( + const updateActivePage = useCallback( (newPage) => { dispatch( usersActions.updateTableActivePage({ diff --git a/x-pack/plugins/security_solution/public/exceptions/components/create_shared_exception_list/index.tsx b/x-pack/plugins/security_solution/public/exceptions/components/create_shared_exception_list/index.tsx index 9c465b202b8ca05..bf345daa1aea10e 100644 --- a/x-pack/plugins/security_solution/public/exceptions/components/create_shared_exception_list/index.tsx +++ b/x-pack/plugins/security_solution/public/exceptions/components/create_shared_exception_list/index.tsx @@ -23,7 +23,7 @@ import { EuiFlexItem, useGeneratedHtmlId, } from '@elastic/eui'; -import type { HttpSetup } from '@kbn/core-http-browser'; +import type { HttpSetup, IHttpFetchError, ResponseErrorBody } from '@kbn/core-http-browser'; import type { ErrorToastOptions, Toast, ToastInput } from '@kbn/core-notifications-browser'; import { i18n as translate } from '@kbn/i18n'; import type { ListDetails } from '@kbn/securitysolution-exception-list-components'; @@ -109,22 +109,22 @@ export const CreateSharedListFlyout = memo( http, ]); - const handleCreateSuccess = useCallback( - (response) => { - addSuccess({ - text: getSuccessText(newListDetails.name), - title: SUCCESS_TITLE, - }); - handleRefresh(); + const handleCreateSuccess = useCallback(() => { + addSuccess({ + text: getSuccessText(newListDetails.name), + title: SUCCESS_TITLE, + }); + handleRefresh(); - handleCloseFlyout(); - }, - [addSuccess, handleCloseFlyout, handleRefresh, newListDetails] - ); + handleCloseFlyout(); + }, [addSuccess, handleCloseFlyout, handleRefresh, newListDetails]); const handleCreateError = useCallback( - (error) => { - if (!error.message.includes('AbortError') && !error?.body?.message.includes('AbortError')) { + (error: IHttpFetchError | undefined) => { + if ( + !error?.message?.includes('AbortError') && + !error?.body?.message.includes('AbortError') + ) { addError(error, { title: translate.translate( 'xpack.securitySolution.exceptions.createSharedExceptionListErrorTitle', @@ -141,9 +141,11 @@ export const CreateSharedListFlyout = memo( useEffect(() => { if (!createSharedExceptionListState.loading) { if (createSharedExceptionListState?.result) { - handleCreateSuccess(createSharedExceptionListState.result); + handleCreateSuccess(); } else if (createSharedExceptionListState?.error) { - handleCreateError(createSharedExceptionListState?.error); + handleCreateError( + createSharedExceptionListState?.error as IHttpFetchError + ); } } }, [ diff --git a/x-pack/plugins/security_solution/public/exceptions/hooks/use_list_detail_view/index.ts b/x-pack/plugins/security_solution/public/exceptions/hooks/use_list_detail_view/index.ts index 99f3288379537d0..afee35da444cb17 100644 --- a/x-pack/plugins/security_solution/public/exceptions/hooks/use_list_detail_view/index.ts +++ b/x-pack/plugins/security_solution/public/exceptions/hooks/use_list_detail_view/index.ts @@ -102,10 +102,15 @@ export const useListDetailsView = (exceptionListId: string) => { [toasts] ); - const initializeListRules = useCallback(async (result) => { - const listRules = await getListRules(result.list_id); - setLinkedRules(listRules); - }, []); + const initializeListRules = useCallback( + async (result: Awaited>) => { + if (result) { + const listRules = await getListRules(result.list_id); + setLinkedRules(listRules); + } + }, + [] + ); const initializeList = useCallback(async () => { try { @@ -329,7 +334,7 @@ export const useListDetailsView = (exceptionListId: string) => { return linkedRules.filter((rule) => !newLinkedRules.includes(rule)); }, [linkedRules, newLinkedRules]); - const onRuleSelectionChange = useCallback((value) => { + const onRuleSelectionChange = useCallback((value: UIRule[]) => { setNewLinkedRules(value); setDisableManageButton(false); }, []); diff --git a/x-pack/plugins/security_solution/public/exceptions/hooks/use_list_exception_items/index.ts b/x-pack/plugins/security_solution/public/exceptions/hooks/use_list_exception_items/index.ts index 9c466859334fe58..bacd0377982a58b 100644 --- a/x-pack/plugins/security_solution/public/exceptions/hooks/use_list_exception_items/index.ts +++ b/x-pack/plugins/security_solution/public/exceptions/hooks/use_list_exception_items/index.ts @@ -7,7 +7,10 @@ import { useCallback, useState } from 'react'; import type { Pagination } from '@elastic/eui'; import { ViewerStatus } from '@kbn/securitysolution-exception-list-components'; -import type { RuleReferences } from '@kbn/securitysolution-exception-list-components'; +import type { + RuleReferences, + GetExceptionItemProps, +} from '@kbn/securitysolution-exception-list-components'; import type { ExceptionListItemSchema, ExceptionListSchema, @@ -19,6 +22,7 @@ import { getExceptionItemsReferences, prepareFetchExceptionItemsParams, } from '../../api'; +import type { DeleteExceptionItem } from '../../api/types'; export interface UseListExceptionItemsProps { list: ExceptionListSchema; @@ -73,19 +77,26 @@ export const useListExceptionItems = ({ } }, [handleErrorStatus, list, setExceptionListReferences]); - const updateViewer = useCallback((paginationResult, dataLength, viewStatus) => { - setPagination(paginationResult); - setLastUpdated(Date.now()); - setTimeout(() => { - if (viewStatus === ViewerStatus.EMPTY_SEARCH) - return setViewerStatus(!dataLength ? viewStatus : ''); + const updateViewer = useCallback( + ( + paginationResult: Awaited>['pagination'], + dataLength: number, + viewStatus?: ViewerStatus + ) => { + setPagination(paginationResult); + setLastUpdated(Date.now()); + setTimeout(() => { + if (viewStatus === ViewerStatus.EMPTY_SEARCH) + return setViewerStatus(!dataLength ? viewStatus : ''); - setViewerStatus(!dataLength ? ViewerStatus.EMPTY : ''); - }, 200); - }, []); + setViewerStatus(!dataLength ? ViewerStatus.EMPTY : ''); + }, 200); + }, + [] + ); const fetchItems = useCallback( - async (options?, viewStatus?) => { + async (options?: GetExceptionItemProps | null, viewStatus?: ViewerStatus) => { try { setViewerStatus(ViewerStatus.LOADING); const { data, pagination: paginationResult } = await fetchListExceptionItems({ @@ -104,7 +115,15 @@ export const useListExceptionItems = ({ ); const onDeleteException = useCallback( - async ({ id, name, namespaceType }) => { + async ({ + id, + name, + namespaceType, + }: { + id: DeleteExceptionItem['id']; + name: string; + namespaceType: DeleteExceptionItem['namespaceType']; + }) => { try { setViewerStatus(ViewerStatus.LOADING); await deleteException({ id, http, namespaceType }); @@ -123,7 +142,7 @@ export const useListExceptionItems = ({ if (typeof onEditListExceptionItem === 'function') onEditListExceptionItem(exception); }; const onPaginationChange = useCallback( - async (options) => { + async (options?: GetExceptionItemProps | null) => { fetchItems(options); }, [fetchItems] diff --git a/x-pack/plugins/security_solution/public/explore/components/authentication/authentications_host_table.tsx b/x-pack/plugins/security_solution/public/explore/components/authentication/authentications_host_table.tsx index 732e4f242aa437e..4f8aa2f96e87bef 100644 --- a/x-pack/plugins/security_solution/public/explore/components/authentication/authentications_host_table.tsx +++ b/x-pack/plugins/security_solution/public/explore/components/authentication/authentications_host_table.tsx @@ -9,6 +9,7 @@ import React, { useCallback, useEffect, useState } from 'react'; import { getOr } from 'lodash/fp'; import { useDispatch } from 'react-redux'; +import type { SiemTables } from '../paginated_table'; import { PaginatedTable } from '../paginated_table'; import * as i18n from './translations'; @@ -70,7 +71,7 @@ const AuthenticationsHostTableComponent: React.FC = ( ? getHostDetailsAuthenticationColumns() : getHostsPageAuthenticationColumns(); - const updateLimitPagination = useCallback( + const updateLimitPagination = useCallback( (newLimit) => dispatch( hostsActions.updateTableLimit({ @@ -82,7 +83,7 @@ const AuthenticationsHostTableComponent: React.FC = ( [type, dispatch] ); - const updateActivePage = useCallback( + const updateActivePage = useCallback( (newPage) => dispatch( hostsActions.updateTableActivePage({ diff --git a/x-pack/plugins/security_solution/public/explore/components/authentication/authentications_user_table.tsx b/x-pack/plugins/security_solution/public/explore/components/authentication/authentications_user_table.tsx index f6c5fc86e761c0c..28855562cf1019d 100644 --- a/x-pack/plugins/security_solution/public/explore/components/authentication/authentications_user_table.tsx +++ b/x-pack/plugins/security_solution/public/explore/components/authentication/authentications_user_table.tsx @@ -10,6 +10,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { getOr } from 'lodash/fp'; import { useDispatch } from 'react-redux'; import { AuthStackByField } from '../../../../common/search_strategy/security_solution/users/authentications'; +import type { SiemTables } from '../paginated_table'; import { PaginatedTable } from '../paginated_table'; import * as i18n from './translations'; @@ -67,7 +68,7 @@ const AuthenticationsUserTableComponent: React.FC [userName] ); - const updateLimitPagination = useCallback( + const updateLimitPagination = useCallback( (newLimit) => dispatch( usersActions.updateTableLimit({ @@ -79,7 +80,7 @@ const AuthenticationsUserTableComponent: React.FC [type, dispatch] ); - const updateActivePage = useCallback( + const updateActivePage = useCallback( (newPage) => dispatch( usersActions.updateTableActivePage({ diff --git a/x-pack/plugins/security_solution/public/explore/components/paginated_table/index.tsx b/x-pack/plugins/security_solution/public/explore/components/paginated_table/index.tsx index c7825d56aedd458..3aa025b30eb1b4d 100644 --- a/x-pack/plugins/security_solution/public/explore/components/paginated_table/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/components/paginated_table/index.tsx @@ -96,7 +96,7 @@ declare type BasicTableColumns = | UsersColumns | UsersTableColumns; -declare type SiemTables = BasicTableProps; +export declare type SiemTables = BasicTableProps; // Using telescoping templates to remove 'any' that was polluting downstream column type checks export interface BasicTableProps { diff --git a/x-pack/plugins/security_solution/public/explore/hosts/components/hosts_table/index.tsx b/x-pack/plugins/security_solution/public/explore/hosts/components/hosts_table/index.tsx index ef9a368dac3700f..20299d564d587e6 100644 --- a/x-pack/plugins/security_solution/public/explore/hosts/components/hosts_table/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/hosts/components/hosts_table/index.tsx @@ -16,6 +16,7 @@ import type { Columns, Criteria, ItemsPerRow, + SiemTables, SortingBasicTable, } from '../../../components/paginated_table'; import { PaginatedTable } from '../../../components/paginated_table'; @@ -96,7 +97,7 @@ const HostsTableComponent: React.FC = ({ getHostsSelector(state, type) ); - const updateLimitPagination = useCallback( + const updateLimitPagination = useCallback( (newLimit) => dispatch( hostsActions.updateTableLimit({ @@ -108,7 +109,7 @@ const HostsTableComponent: React.FC = ({ [type, dispatch] ); - const updateActivePage = useCallback( + const updateActivePage = useCallback( (newPage) => dispatch( hostsActions.updateTableActivePage({ diff --git a/x-pack/plugins/security_solution/public/explore/hosts/pages/details/index.tsx b/x-pack/plugins/security_solution/public/explore/hosts/pages/details/index.tsx index f60866be1e3eade..6e5b69f40826300 100644 --- a/x-pack/plugins/security_solution/public/explore/hosts/pages/details/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/hosts/pages/details/index.tsx @@ -20,6 +20,7 @@ import type { Filter } from '@kbn/es-query'; import { buildEsQuery } from '@kbn/es-query'; import { getEsQueryConfig } from '@kbn/data-plugin/common'; import { dataTableSelectors, tableDefaults, TableId } from '@kbn/securitysolution-data-table'; +import type { NarrowDateRange } from '../../../../common/components/ml/types'; import { useCalculateEntityRiskScore } from '../../../../entity_analytics/api/hooks/use_calculate_entity_risk_score'; import { useAssetCriticalityData, @@ -113,7 +114,7 @@ const HostDetailsComponent: React.FC = ({ detailName, hostDeta const isEnterprisePlus = useLicense().isEnterprise(); - const narrowDateRange = useCallback( + const narrowDateRange = useCallback( (score, interval) => { const fromTo = scoreIntervalToDateTime(score, interval); dispatch( diff --git a/x-pack/plugins/security_solution/public/explore/network/components/network_dns_table/index.tsx b/x-pack/plugins/security_solution/public/explore/network/components/network_dns_table/index.tsx index be0558b00f67015..3af67736d6837dd 100644 --- a/x-pack/plugins/security_solution/public/explore/network/components/network_dns_table/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/components/network_dns_table/index.tsx @@ -16,7 +16,7 @@ import type { NetworkDnsEdges, NetworkDnsFields, } from '../../../../../common/search_strategy'; -import type { Criteria, ItemsPerRow } from '../../../components/paginated_table'; +import type { Criteria, ItemsPerRow, SiemTables } from '../../../components/paginated_table'; import { PaginatedTable } from '../../../components/paginated_table'; import { useDeepEqualSelector } from '../../../../common/hooks/use_selector'; @@ -66,7 +66,7 @@ const NetworkDnsTableComponent: React.FC = ({ const getNetworkDnsSelector = useMemo(() => networkSelectors.dnsSelector(), []); const { activePage, isPtrIncluded, limit, sort } = useDeepEqualSelector(getNetworkDnsSelector); - const updateLimitPagination = useCallback( + const updateLimitPagination = useCallback( (newLimit) => dispatch( networkActions.updateNetworkTable({ @@ -78,7 +78,7 @@ const NetworkDnsTableComponent: React.FC = ({ [type, dispatch] ); - const updateActivePage = useCallback( + const updateActivePage = useCallback( (newPage) => dispatch( networkActions.updateNetworkTable({ diff --git a/x-pack/plugins/security_solution/public/explore/network/components/network_http_table/index.tsx b/x-pack/plugins/security_solution/public/explore/network/components/network_http_table/index.tsx index 4d6cd8773d06c76..642fb1a13604f8a 100644 --- a/x-pack/plugins/security_solution/public/explore/network/components/network_http_table/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/components/network_http_table/index.tsx @@ -12,7 +12,7 @@ import { networkActions, networkModel, networkSelectors } from '../../store'; import type { NetworkHttpEdges } from '../../../../../common/search_strategy'; import { NetworkHttpFields } from '../../../../../common/search_strategy'; import { useDeepEqualSelector } from '../../../../common/hooks/use_selector'; -import type { Criteria, ItemsPerRow } from '../../../components/paginated_table'; +import type { Criteria, ItemsPerRow, SiemTables } from '../../../components/paginated_table'; import { PaginatedTable } from '../../../components/paginated_table'; import { getNetworkHttpColumns } from './columns'; @@ -64,7 +64,7 @@ const NetworkHttpTableComponent: React.FC = ({ ? networkModel.NetworkTableType.http : networkModel.NetworkDetailsTableType.http; - const updateLimitPagination = useCallback( + const updateLimitPagination = useCallback( (newLimit) => dispatch( networkActions.updateNetworkTable({ @@ -76,7 +76,7 @@ const NetworkHttpTableComponent: React.FC = ({ [dispatch, type, tableType] ); - const updateActivePage = useCallback( + const updateActivePage = useCallback( (newPage) => dispatch( networkActions.updateNetworkTable({ diff --git a/x-pack/plugins/security_solution/public/explore/network/components/network_top_countries_table/index.tsx b/x-pack/plugins/security_solution/public/explore/network/components/network_top_countries_table/index.tsx index d149e1bb474efa5..3f34d79775f6fdf 100644 --- a/x-pack/plugins/security_solution/public/explore/network/components/network_top_countries_table/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/components/network_top_countries_table/index.tsx @@ -20,7 +20,7 @@ import { } from '../../../../../common/search_strategy'; import { useDeepEqualSelector } from '../../../../common/hooks/use_selector'; -import type { Criteria, ItemsPerRow } from '../../../components/paginated_table'; +import type { Criteria, ItemsPerRow, SiemTables } from '../../../components/paginated_table'; import { PaginatedTable } from '../../../components/paginated_table'; import { getCountriesColumnsCurated } from './columns'; @@ -100,7 +100,7 @@ const NetworkTopCountriesTableComponent: React.FC ? `node.network.${sort.field}` : `node.${flowTargeted}.${sort.field}`; - const updateLimitPagination = useCallback( + const updateLimitPagination = useCallback( (newLimit) => dispatch( networkActions.updateNetworkTable({ @@ -112,7 +112,7 @@ const NetworkTopCountriesTableComponent: React.FC [dispatch, type, tableType] ); - const updateActivePage = useCallback( + const updateActivePage = useCallback( (newPage) => dispatch( networkActions.updateNetworkTable({ diff --git a/x-pack/plugins/security_solution/public/explore/network/components/network_top_n_flow_table/index.tsx b/x-pack/plugins/security_solution/public/explore/network/components/network_top_n_flow_table/index.tsx index f620d5fc17df57f..4359520ea8f2175 100644 --- a/x-pack/plugins/security_solution/public/explore/network/components/network_top_n_flow_table/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/components/network_top_n_flow_table/index.tsx @@ -17,7 +17,7 @@ import { NetworkTopTablesFields, } from '../../../../../common/search_strategy'; import { useDeepEqualSelector } from '../../../../common/hooks/use_selector'; -import type { Criteria, ItemsPerRow } from '../../../components/paginated_table'; +import type { Criteria, ItemsPerRow, SiemTables } from '../../../components/paginated_table'; import { PaginatedTable } from '../../../components/paginated_table'; import { networkActions, networkModel, networkSelectors } from '../../store'; import { getNFlowColumnsCurated } from './columns'; @@ -125,7 +125,7 @@ const NetworkTopNFlowTableComponent: React.FC = ({ [flowTargeted, sort] ); - const updateActivePage = useCallback( + const updateActivePage = useCallback( (newPage) => dispatch( networkActions.updateNetworkTable({ @@ -137,7 +137,7 @@ const NetworkTopNFlowTableComponent: React.FC = ({ [dispatch, type, tableType] ); - const updateLimitPagination = useCallback( + const updateLimitPagination = useCallback( (newLimit) => dispatch( networkActions.updateNetworkTable({ diff --git a/x-pack/plugins/security_solution/public/explore/network/components/tls_table/index.tsx b/x-pack/plugins/security_solution/public/explore/network/components/tls_table/index.tsx index b981dba31c2b684..be7318daf2839fa 100644 --- a/x-pack/plugins/security_solution/public/explore/network/components/tls_table/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/components/tls_table/index.tsx @@ -13,7 +13,12 @@ import { networkActions, networkModel, networkSelectors } from '../../store'; import type { Direction, NetworkTlsEdges, SortField } from '../../../../../common/search_strategy'; import { NetworkTlsFields } from '../../../../../common/search_strategy'; import { useDeepEqualSelector } from '../../../../common/hooks/use_selector'; -import type { Criteria, ItemsPerRow, SortingBasicTable } from '../../../components/paginated_table'; +import type { + Criteria, + ItemsPerRow, + SiemTables, + SortingBasicTable, +} from '../../../components/paginated_table'; import { PaginatedTable } from '../../../components/paginated_table'; import { getTlsColumns } from './columns'; import * as i18n from './translations'; @@ -64,7 +69,7 @@ const TlsTableComponent: React.FC = ({ ? networkModel.NetworkTableType.tls : networkModel.NetworkDetailsTableType.tls; - const updateLimitPagination = useCallback( + const updateLimitPagination = useCallback( (newLimit) => dispatch( networkActions.updateNetworkTable({ @@ -76,7 +81,7 @@ const TlsTableComponent: React.FC = ({ [dispatch, type, tableType] ); - const updateActivePage = useCallback( + const updateActivePage = useCallback( (newPage) => dispatch( networkActions.updateNetworkTable({ diff --git a/x-pack/plugins/security_solution/public/explore/network/components/users_table/index.tsx b/x-pack/plugins/security_solution/public/explore/network/components/users_table/index.tsx index 909f4fa77d94d88..c88d90dc2756780 100644 --- a/x-pack/plugins/security_solution/public/explore/network/components/users_table/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/components/users_table/index.tsx @@ -19,7 +19,12 @@ import type { SortField, } from '../../../../../common/search_strategy'; import { NetworkUsersFields } from '../../../../../common/search_strategy'; -import type { Criteria, ItemsPerRow, SortingBasicTable } from '../../../components/paginated_table'; +import type { + Criteria, + ItemsPerRow, + SiemTables, + SortingBasicTable, +} from '../../../components/paginated_table'; import { PaginatedTable } from '../../../components/paginated_table'; import { getUsersColumns } from './columns'; @@ -70,7 +75,7 @@ const UsersTableComponent: React.FC = ({ const getUsersSelector = useMemo(() => networkSelectors.usersSelector(), []); const { activePage, sort, limit } = useDeepEqualSelector(getUsersSelector); - const updateLimitPagination = useCallback( + const updateLimitPagination = useCallback( (newLimit) => dispatch( networkActions.updateNetworkTable({ @@ -82,7 +87,7 @@ const UsersTableComponent: React.FC = ({ [dispatch, type] ); - const updateActivePage = useCallback( + const updateActivePage = useCallback( (newPage) => dispatch( networkActions.updateNetworkTable({ diff --git a/x-pack/plugins/security_solution/public/explore/network/pages/details/index.tsx b/x-pack/plugins/security_solution/public/explore/network/pages/details/index.tsx index c2f034038271460..adcf8a21ba47cb5 100644 --- a/x-pack/plugins/security_solution/public/explore/network/pages/details/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/pages/details/index.tsx @@ -28,6 +28,7 @@ import { networkToCriteria } from '../../../../common/components/ml/criteria/net import { scoreIntervalToDateTime } from '../../../../common/components/ml/score/score_interval_to_datetime'; import { manageQuery } from '../../../../common/components/page/manage_query'; import { FlowTargetSelectConnected } from '../../components/flow_target_select_connected'; +import type { IpOverviewProps } from '../../components/details'; import { IpOverview } from '../../components/details'; import { SiemSearchBar } from '../../../../common/components/search_bar'; import { SecuritySolutionPageWrapper } from '../../../../common/components/page_wrapper'; @@ -82,7 +83,7 @@ const NetworkDetailsComponent: React.FC = () => { const globalFilters = useDeepEqualSelector(getGlobalFiltersQuerySelector); const type = networkModel.NetworkType.details; - const narrowDateRange = useCallback( + const narrowDateRange = useCallback( (score, interval) => { const fromTo = scoreIntervalToDateTime(score, interval); dispatch( diff --git a/x-pack/plugins/security_solution/public/explore/users/components/all_users/index.tsx b/x-pack/plugins/security_solution/public/explore/users/components/all_users/index.tsx index d05c9551a251815..92303187f231a4f 100644 --- a/x-pack/plugins/security_solution/public/explore/users/components/all_users/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/users/components/all_users/index.tsx @@ -19,7 +19,12 @@ import { getOrEmptyTagFromValue, } from '../../../../common/components/empty_value'; -import type { Columns, Criteria, ItemsPerRow } from '../../../components/paginated_table'; +import type { + Columns, + Criteria, + ItemsPerRow, + SiemTables, +} from '../../../components/paginated_table'; import { PaginatedTable } from '../../../components/paginated_table'; import { getRowItemsWithActions } from '../../../../common/components/tables/helpers'; @@ -183,7 +188,7 @@ const UsersTableComponent: React.FC = ({ const isPlatinumOrTrialLicense = useMlCapabilities().isPlatinumOrTrialLicense; const { navigateTo } = useNavigateTo(); - const updateLimitPagination = useCallback( + const updateLimitPagination = useCallback( (newLimit) => { dispatch( usersActions.updateTableLimit({ @@ -196,7 +201,7 @@ const UsersTableComponent: React.FC = ({ [type, dispatch] ); - const updateActivePage = useCallback( + const updateActivePage = useCallback( (newPage) => { dispatch( usersActions.updateTableActivePage({ diff --git a/x-pack/plugins/security_solution/public/explore/users/pages/details/index.tsx b/x-pack/plugins/security_solution/public/explore/users/pages/details/index.tsx index 0ff279762161595..a53eaf43269bfaa 100644 --- a/x-pack/plugins/security_solution/public/explore/users/pages/details/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/users/pages/details/index.tsx @@ -64,6 +64,7 @@ import { LastEventTime } from '../../../../common/components/last_event_time'; import { LastEventIndexKey, RiskScoreEntity } from '../../../../../common/search_strategy'; import { AnomalyTableProvider } from '../../../../common/components/ml/anomaly/anomaly_table_provider'; +import type { UserSummaryProps } from '../../../../overview/components/user_overview'; import { UserOverview, USER_OVERVIEW_RISK_SCORE_QUERY_ID, @@ -159,7 +160,7 @@ const UsersDetailsComponent: React.FC = ({ useQueryInspector({ setQuery, deleteQuery, refetch, inspect, loading, queryId: QUERY_ID }); - const narrowDateRange = useCallback( + const narrowDateRange = useCallback( (score, interval) => { const fromTo = scoreIntervalToDateTime(score, interval); dispatch( diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/assignees.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/assignees.tsx index 5e9905107c877ca..fc9a09d4e37da28 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/assignees.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/assignees.tsx @@ -23,6 +23,7 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { useSetAlertAssignees } from '../../../../common/components/toolbar/bulk_actions/use_set_alert_assignees'; import { getEmptyTagValue } from '../../../../common/components/empty_value'; import { ASSIGNEES_PANEL_WIDTH } from '../../../../common/components/assignees/constants'; +import type { AssigneesApplyPanelProps } from '../../../../common/components/assignees/assignees_apply_panel'; import { AssigneesApplyPanel } from '../../../../common/components/assignees/assignees_apply_panel'; import { useUpsellingMessage } from '../../../../common/hooks/use_upselling'; import { useLicense } from '../../../../common/hooks/use_license'; @@ -98,7 +99,7 @@ export const Assignees: FC = memo( setIsPopoverOpen((value) => !value); }, []); - const handleApplyAssignees = useCallback( + const handleApplyAssignees = useCallback( async (assignees) => { setIsPopoverOpen(false); if (setAlertAssignees) { diff --git a/x-pack/plugins/security_solution/public/flyout/entity_details/shared/components/anomalies_field.tsx b/x-pack/plugins/security_solution/public/flyout/entity_details/shared/components/anomalies_field.tsx index ea5e7b17202f096..b050e2a55ed520b 100644 --- a/x-pack/plugins/security_solution/public/flyout/entity_details/shared/components/anomalies_field.tsx +++ b/x-pack/plugins/security_solution/public/flyout/entity_details/shared/components/anomalies_field.tsx @@ -7,6 +7,7 @@ import React, { useCallback } from 'react'; import { useDispatch } from 'react-redux'; +import type { NarrowDateRange } from '../../../../common/components/ml/types'; import type { EntityAnomalies } from './observed_entity/types'; import { AnomalyScores } from '../../../../common/components/ml/score/anomaly_scores'; import { useGlobalTime } from '../../../../common/containers/use_global_time'; @@ -18,7 +19,7 @@ export const AnomaliesField = ({ anomalies }: { anomalies: EntityAnomalies }) => const { to, from } = useGlobalTime(); const dispatch = useDispatch(); - const narrowDateRange = useCallback( + const narrowDateRange = useCallback( (score, interval) => { const fromTo = scoreIntervalToDateTime(score, interval); dispatch( diff --git a/x-pack/plugins/security_solution/public/management/components/artifact_list_page/hooks/use_set_url_params.ts b/x-pack/plugins/security_solution/public/management/components/artifact_list_page/hooks/use_set_url_params.ts index f6199f1c6c17108..cf3cce3dc9f03d6 100644 --- a/x-pack/plugins/security_solution/public/management/components/artifact_list_page/hooks/use_set_url_params.ts +++ b/x-pack/plugins/security_solution/public/management/components/artifact_list_page/hooks/use_set_url_params.ts @@ -10,17 +10,19 @@ import { useCallback } from 'react'; import { pickBy } from 'lodash'; import { useUrlParams } from '../../../hooks/use_url_params'; -// FIXME:PT Refactor into a more generic hooks for managing url params -export const useSetUrlParams = (): (( +type UseSetUrlParams = ( /** Any param whose value is `undefined` will be removed from the URl when in append mode */ params: Record, replace?: boolean -) => void) => { +) => void; + +// FIXME:PT Refactor into a more generic hooks for managing url params +export const useSetUrlParams = (): UseSetUrlParams => { const location = useLocation(); const history = useHistory(); const { toUrlParams, urlParams: currentUrlParams } = useUrlParams(); - return useCallback( + return useCallback( (params, replace = false) => { history.push({ ...location, diff --git a/x-pack/plugins/security_solution/public/management/components/console/components/command_input/components/command_input_history.tsx b/x-pack/plugins/security_solution/public/management/components/console/components/command_input/components/command_input_history.tsx index 4e192a80d5b8428..6879043eb1fc054 100644 --- a/x-pack/plugins/security_solution/public/management/components/console/components/command_input/components/command_input_history.tsx +++ b/x-pack/plugins/security_solution/public/management/components/console/components/command_input/components/command_input_history.tsx @@ -122,9 +122,12 @@ export const CommandInputHistory = memo(() => { [dispatch] ); - const handleRenderOption = useCallback((option) => { - return ; - }, []); + const handleRenderOption = useCallback>( + (option) => { + return ; + }, + [] + ); // When first loaded, clear out the current text entered, and when this component // unloads, if no option from the history was selected, then set the prior text diff --git a/x-pack/plugins/security_solution/public/management/components/console/components/command_list.tsx b/x-pack/plugins/security_solution/public/management/components/console/components/command_list.tsx index e6323fccb847ea0..d7644b60a7f7c1b 100644 --- a/x-pack/plugins/security_solution/public/management/components/console/components/command_list.tsx +++ b/x-pack/plugins/security_solution/public/management/components/console/components/command_list.tsx @@ -125,7 +125,7 @@ export const CommandList = memo(({ commands, display = 'defaul }, []); const updateInputText = useCallback( - (text) => () => { + (text: string) => () => { dispatch({ type: 'updateInputTextEnteredState', payload: () => { @@ -218,7 +218,7 @@ export const CommandList = memo(({ commands, display = 'defaul ); const getTableColumns = useCallback( - (commandsByGroup) => { + (commandsByGroup: CommandDefinition[]) => { const groupLabel = commandsByGroup[0]?.helpGroupLabel ?? otherCommandsGroupLabel; const groupTestIdSuffix = convertToTestId(groupLabel); @@ -294,7 +294,7 @@ export const CommandList = memo(({ commands, display = 'defaul ); const getFilteredCommands = useCallback( - (commandsByGroup): CommandDefinition[] => + (commandsByGroup: CommandDefinition[]): CommandDefinition[] => commandsByGroup.filter( (current: CommandDefinition) => current.name !== 'help' && current.name !== 'clear' ), diff --git a/x-pack/plugins/security_solution/public/management/components/effected_policy_select/effected_policy_select.tsx b/x-pack/plugins/security_solution/public/management/components/effected_policy_select/effected_policy_select.tsx index 079ea01492dccfa..fbfc76c77ac7deb 100644 --- a/x-pack/plugins/security_solution/public/management/components/effected_policy_select/effected_policy_select.tsx +++ b/x-pack/plugins/security_solution/public/management/components/effected_policy_select/effected_policy_select.tsx @@ -190,7 +190,7 @@ export const EffectedPolicySelect = memo( ); const handleGlobalButtonChange = useCallback( - (selectedId) => { + (selectedId: string) => { onChange({ isGlobal: selectedId === 'globalPolicy', selected, diff --git a/x-pack/plugins/security_solution/public/management/components/endpoint_response_actions_list/components/hooks.tsx b/x-pack/plugins/security_solution/public/management/components/endpoint_response_actions_list/components/hooks.tsx index a91c87223e44c64..fb2caac789451b4 100644 --- a/x-pack/plugins/security_solution/public/management/components/endpoint_response_actions_list/components/hooks.tsx +++ b/x-pack/plugins/security_solution/public/management/components/endpoint_response_actions_list/components/hooks.tsx @@ -55,7 +55,7 @@ export const useDateRangePicker = (isFlyout: boolean) => { }); const updateActionListDateRanges = useCallback( - ({ start, end }) => { + ({ start, end }: DurationRange) => { setDateRangePickerState((prevState) => ({ ...prevState, startDate: start, @@ -66,7 +66,7 @@ export const useDateRangePicker = (isFlyout: boolean) => { ); const updateActionListRecentlyUsedDateRanges = useCallback( - (recentlyUsedDateRanges) => { + (recentlyUsedDateRanges: DateRangePickerValues['recentlyUsedDateRanges']) => { setDateRangePickerState((prevState) => ({ ...prevState, recentlyUsedDateRanges, diff --git a/x-pack/plugins/security_solution/public/management/components/search_exceptions/search_exceptions.tsx b/x-pack/plugins/security_solution/public/management/components/search_exceptions/search_exceptions.tsx index dbcdb011d28f341..51ff76158f3b87f 100644 --- a/x-pack/plugins/security_solution/public/management/components/search_exceptions/search_exceptions.tsx +++ b/x-pack/plugins/security_solution/public/management/components/search_exceptions/search_exceptions.tsx @@ -6,6 +6,7 @@ */ import React, { memo, useCallback, useState } from 'react'; +import type { EuiFieldSearchProps } from '@elastic/eui'; import { EuiFlexGroup, EuiFlexItem, EuiFieldSearch, EuiButton } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import type { PolicySelectionItem } from '../policies_selector'; @@ -67,7 +68,7 @@ export const SearchExceptions = memo( [onSearch, query, includedPolicies] ); - const handleOnSearchQuery = useCallback( + const handleOnSearchQuery = useCallback>( (value) => { onSearch(value, includedPolicies, false); }, diff --git a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.tsx b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.tsx index 3c0d08821f6e78e..c93cb6228ac6a16 100644 --- a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.tsx @@ -7,7 +7,7 @@ import React, { useCallback, useMemo } from 'react'; import styled from 'styled-components'; -import type { CriteriaWithPagination } from '@elastic/eui'; +import type { CriteriaWithPagination, EuiSuperDatePickerProps } from '@elastic/eui'; import { EuiBasicTable, type EuiBasicTableColumn, @@ -452,7 +452,7 @@ export const EndpointList = () => { }); }, [dispatch]); - const onRefreshChange = useCallback( + const onRefreshChange = useCallback>( (evt) => { dispatch({ type: 'userUpdatedEndpointListRefreshOptions', diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/view/artifacts/flyout/policy_artifacts_flyout.tsx b/x-pack/plugins/security_solution/public/management/pages/policy/view/artifacts/flyout/policy_artifacts_flyout.tsx index 9805c72a75ca6cc..9b3afa038fb60d6 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/view/artifacts/flyout/policy_artifacts_flyout.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/policy/view/artifacts/flyout/policy_artifacts_flyout.tsx @@ -88,7 +88,7 @@ export const PolicyArtifactsFlyout = React.memo( searchableFields ); - const handleOnSearch = useCallback((query) => { + const handleOnSearch = useCallback((query: string) => { setSelectedArtifactIds([]); setCurrentFilter(query); }, []); diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/view/artifacts/layout/policy_artifacts_layout.tsx b/x-pack/plugins/security_solution/public/management/pages/policy/view/artifacts/layout/policy_artifacts_layout.tsx index 75927ece7dfdec8..15c347438f5a10a 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/view/artifacts/layout/policy_artifacts_layout.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/policy/view/artifacts/layout/policy_artifacts_layout.tsx @@ -28,6 +28,7 @@ import { usePolicyDetailsArtifactsNavigateCallback } from '../../policy_hooks'; import type { ExceptionsListApiClient } from '../../../../../services/exceptions_list/exceptions_list_api_client'; import { useListArtifact } from '../../../../../hooks/artifacts'; import { PolicyArtifactsEmptyUnassigned, PolicyArtifactsEmptyUnexisting } from '../empty'; +import type { PolicyArtifactsListProps } from '../list'; import { PolicyArtifactsList } from '../list'; import { PolicyArtifactsFlyout } from '../flyout'; import type { PolicyArtifactsPageLabels } from '../translations'; @@ -106,7 +107,9 @@ export const PolicyArtifactsLayout = React.memo( setExceptionItemToDelete(undefined); }, [setExceptionItemToDelete]); - const handleOnDeleteActionCallback = useCallback( + const handleOnDeleteActionCallback = useCallback< + PolicyArtifactsListProps['onDeleteActionCallback'] + >( (item) => { setExceptionItemToDelete(item); }, diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/view/artifacts/list/index.ts b/x-pack/plugins/security_solution/public/management/pages/policy/view/artifacts/list/index.ts index 260b580de74971f..68361a01d0d1f42 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/view/artifacts/list/index.ts +++ b/x-pack/plugins/security_solution/public/management/pages/policy/view/artifacts/list/index.ts @@ -6,4 +6,5 @@ */ export { PolicyArtifactsList } from './policy_artifacts_list'; +export type { PolicyArtifactsListProps } from './policy_artifacts_list'; export { POLICY_ARTIFACT_LIST_LABELS } from './translations'; diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/view/artifacts/list/policy_artifacts_list.tsx b/x-pack/plugins/security_solution/public/management/pages/policy/view/artifacts/list/policy_artifacts_list.tsx index 082012295b02345..696e29f770645b6 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/view/artifacts/list/policy_artifacts_list.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/policy/view/artifacts/list/policy_artifacts_list.tsx @@ -12,6 +12,7 @@ import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-t import type { ArtifactEntryCardDecoratorProps } from '../../../../../components/artifact_entry_card'; import { useAppUrl } from '../../../../../../common/lib/kibana'; import { APP_UI_ID } from '../../../../../../../common/constants'; +import type { SearchExceptionsProps } from '../../../../../components/search_exceptions'; import { SearchExceptions } from '../../../../../components/search_exceptions'; import { useEndpointPoliciesToArtifactPolicies } from '../../../../../components/artifact_entry_card/hooks/use_endpoint_policies_to_artifact_policies'; import { useUrlParams } from '../../../../../hooks/use_url_params'; @@ -30,7 +31,7 @@ import { useListArtifact } from '../../../../../hooks/artifacts'; import type { POLICY_ARTIFACT_LIST_LABELS } from './translations'; import type { ArtifactListPageUrlParams } from '../../../../../components/artifact_list_page'; -interface PolicyArtifactsListProps { +export interface PolicyArtifactsListProps { policy: ImmutableObject; apiClient: ExceptionsListApiClient; searchableFields: string[]; @@ -91,7 +92,7 @@ export const PolicyArtifactsList = React.memo( [artifacts?.total, pageSizeOptions, urlPagination.page, urlPagination.pageSize] ); - const handleOnSearch = useCallback( + const handleOnSearch = useCallback( (filter) => { navigateCallback({ filter }); }, @@ -123,7 +124,7 @@ export const PolicyArtifactsList = React.memo( }, [artifacts?.data.length, labels]); const artifactCardPolicies = useEndpointPoliciesToArtifactPolicies(policiesRequest.data?.items); - const provideCardProps = useCallback( + const provideCardProps = useCallback>( (artifact) => { const viewUrlPath = getArtifactPath({ filter: (artifact as ExceptionListItemSchema).item_id, diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/advanced_section.tsx b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/advanced_section.tsx index 063c3b830b7a138..2720126987117e9 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/advanced_section.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/advanced_section.tsx @@ -7,6 +7,7 @@ import React, { memo, useCallback, useState } from 'react'; import { FormattedMessage } from '@kbn/i18n-react'; +import type { EuiFieldTextProps } from '@elastic/eui'; import { EuiCallOut, EuiFieldText, @@ -120,7 +121,7 @@ export const AdvancedSection = memo( setShowAdvancedPolicy((prevState) => !prevState); }, []); - const handleAdvancedSettingUpdate = useCallback( + const handleAdvancedSettingUpdate = useCallback>( (event) => { const updatedPolicy = cloneDeep(policy); diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/cards/attack_surface_reduction_card.tsx b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/cards/attack_surface_reduction_card.tsx index ecb73adfa334112..052ceffc6575479 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/cards/attack_surface_reduction_card.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/cards/attack_surface_reduction_card.tsx @@ -7,6 +7,7 @@ import React, { memo, useCallback } from 'react'; import { OperatingSystem } from '@kbn/securitysolution-utils'; +import type { EuiSwitchProps } from '@elastic/eui'; import { EuiSwitch } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { cloneDeep } from 'lodash'; @@ -50,7 +51,7 @@ export const AttackSurfaceReductionCard = memo( const isChecked = policy.windows.attack_surface_reduction.credential_hardening.enabled; const isEditMode = mode === 'edit'; - const handleSwitchChange = useCallback( + const handleSwitchChange = useCallback( (event) => { const updatedPolicy = cloneDeep(policy); diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/cards/malware_protections_card.tsx b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/cards/malware_protections_card.tsx index f1eda1ac0915ede..634c24a1c1f5125 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/cards/malware_protections_card.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/cards/malware_protections_card.tsx @@ -7,6 +7,7 @@ import React, { memo, useCallback } from 'react'; import { i18n } from '@kbn/i18n'; +import type { EuiSwitchProps } from '@elastic/eui'; import { EuiSpacer, EuiSwitch, EuiFlexGroup, EuiFlexItem, EuiIconTip } from '@elastic/eui'; import { OperatingSystem } from '@kbn/securitysolution-utils'; import { cloneDeep } from 'lodash'; @@ -223,7 +224,7 @@ const SubfeatureSwitch = memo( const isEditMode = mode === 'edit'; const isDisabled = policy.windows.malware.mode === 'off' || !isEditMode; - const handleBlocklistSwitchChange = useCallback( + const handleBlocklistSwitchChange = useCallback( (event) => { const value = event.target.checked; const newPayload = cloneDeep(policy); diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/cards/protection_seetings_card/components/reputation_service.tsx b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/cards/protection_seetings_card/components/reputation_service.tsx index 2de776069f5e55d..7ff4ad6b3681be1 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/cards/protection_seetings_card/components/reputation_service.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/cards/protection_seetings_card/components/reputation_service.tsx @@ -6,6 +6,7 @@ */ import React, { useCallback } from 'react'; +import type { EuiCheckboxProps } from '@elastic/eui'; import { EuiCheckbox, EuiFlexGroup, @@ -48,7 +49,7 @@ export const ReputationService = React.memo( const checkboxChecked = policy.windows.behavior_protection.reputation_service && protectionTurnedOn; - const handleChange = useCallback( + const handleChange = useCallback( (event) => { const newPayload = cloneDeep(policy); newPayload.windows.behavior_protection.reputation_service = event.target.checked; diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/event_collection_card.tsx b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/event_collection_card.tsx index c74496c7512b83e..a1fee2d77b01dbd 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/event_collection_card.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/event_collection_card.tsx @@ -20,7 +20,7 @@ import { EuiText, } from '@elastic/eui'; import { cloneDeep, get, set } from 'lodash'; -import type { EuiCheckboxProps } from '@elastic/eui/src/components/form/checkbox/checkbox'; +import type { EuiCheckboxProps } from '@elastic/eui'; import { getEmptyValue } from '../../../../../../common/components/empty_value'; import { useTestIdGenerator } from '../../../../../hooks/use_test_id_generator'; import type { PolicyFormComponentCommonProps } from '../types'; @@ -253,7 +253,7 @@ const EventCheckbox = memo( ({ policy, onChange, label, keyPath, disabled, 'data-test-subj': dataTestSubj }) => { const isChecked: boolean = get(policy, keyPath); - const checkboxOnChangeHandler = useCallback( + const checkboxOnChangeHandler = useCallback>( (ev) => { const updatedPolicy = cloneDeep(policy); set(updatedPolicy, keyPath, ev.target.checked); diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/notify_user_option.tsx b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/notify_user_option.tsx index 2c05b267bb32939..9181e643f393a3c 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/notify_user_option.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/notify_user_option.tsx @@ -9,6 +9,7 @@ import React, { useCallback, useMemo } from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import { cloneDeep } from 'lodash'; +import type { EuiTextAreaProps, EuiCheckboxProps } from '@elastic/eui'; import { EuiSpacer, EuiFlexItem, @@ -76,7 +77,7 @@ export const NotifyUserOption = React.memo( const userNotificationSelected = policy.windows.popup[protection].enabled; const userNotificationMessage = policy.windows.popup[protection].message; - const handleUserNotificationCheckbox = useCallback( + const handleUserNotificationCheckbox = useCallback( (event) => { const newPayload = cloneDeep(policy); @@ -96,7 +97,7 @@ export const NotifyUserOption = React.memo( [policy, onChange, osList, protection] ); - const handleCustomUserNotification = useCallback( + const handleCustomUserNotification = useCallback>( (event) => { const newPayload = cloneDeep(policy); for (const os of osList) { diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/protection_setting_card_switch.tsx b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/protection_setting_card_switch.tsx index d4561be6e5313d8..f1dfcac00921170 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/protection_setting_card_switch.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_form/components/protection_setting_card_switch.tsx @@ -6,6 +6,7 @@ */ import React, { useCallback } from 'react'; +import type { EuiSwitchProps } from '@elastic/eui'; import { EuiSwitch } from '@elastic/eui'; import { cloneDeep } from 'lodash'; import { useTestIdGenerator } from '../../../../../hooks/use_test_id_generator'; @@ -51,7 +52,7 @@ export const ProtectionSettingCardSwitch = React.memo( const isPlatinumPlus = useLicense().isPlatinumPlus(); const isEditMode = mode === 'edit'; - const handleSwitchChange = useCallback( + const handleSwitchChange = useCallback( (event) => { const newPayload = cloneDeep(policy); diff --git a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/components/condition_entry_input/index.tsx b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/components/condition_entry_input/index.tsx index 21e183834ea7973..3ce26c70d318680 100644 --- a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/components/condition_entry_input/index.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/components/condition_entry_input/index.tsx @@ -9,8 +9,9 @@ import type { ChangeEventHandler } from 'react'; import React, { memo, useCallback, useMemo, useState } from 'react'; import styled from 'styled-components'; import { i18n } from '@kbn/i18n'; -import type { EuiSuperSelectOption } from '@elastic/eui'; +import type { EuiSuperSelectOption, EuiSuperSelectProps } from '@elastic/eui'; import { EuiButtonIcon, EuiFieldText, EuiFormRow, EuiSuperSelect, EuiText } from '@elastic/eui'; +import type { TrustedAppEntryTypes } from '@kbn/securitysolution-utils'; import { ConditionEntryField, OperatingSystem } from '@kbn/securitysolution-utils'; import type { TrustedAppConditionEntry } from '../../../../../../../common/endpoint/types'; import { OperatorFieldIds } from '../../../../../../../common/endpoint/types'; @@ -73,11 +74,13 @@ const InputItem = styled.div<{ gridArea: string }>` vertical-align: baseline; `; -const operatorOptions = (Object.keys(OperatorFieldIds) as OperatorFieldIds[]).map((value) => ({ - dropdownDisplay: OPERATOR_TITLES[value], - inputDisplay: OPERATOR_TITLES[value], - value: value === 'matches' ? 'wildcard' : 'match', -})); +const operatorOptions = (Object.keys(OperatorFieldIds) as OperatorFieldIds[]).map( + (value): EuiSuperSelectOption => ({ + dropdownDisplay: OPERATOR_TITLES[value], + inputDisplay: OPERATOR_TITLES[value], + value: value === 'matches' ? 'wildcard' : 'match', + }) +); export const ConditionEntryInput = memo( ({ @@ -101,7 +104,7 @@ export const ConditionEntryInput = memo( } }, [entry, isVisited, onVisited]); - const fieldOptions = useMemo>>(() => { + const fieldOptions = useMemo>>(() => { const getDropdownDisplay = (field: ConditionEntryField) => ( <> {CONDITION_FIELD_TITLE[field]} @@ -148,7 +151,9 @@ export const ConditionEntryInput = memo( [entry, onChange] ); - const handleFieldUpdate = useCallback( + const handleFieldUpdate = useCallback< + NonNullable['onChange']> + >( (newField) => { onChange({ ...entry, field: newField }, entry); @@ -159,10 +164,9 @@ export const ConditionEntryInput = memo( [handleVisited, entry, onChange] ); - const handleOperatorUpdate = useCallback( - (newOperator) => onChange({ ...entry, type: newOperator }, entry), - [entry, onChange] - ); + const handleOperatorUpdate = useCallback< + NonNullable['onChange']> + >((newOperator) => onChange({ ...entry, type: newOperator }, entry), [entry, onChange]); const handleRemoveClick = useCallback(() => onRemove(entry), [entry, onRemove]); diff --git a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/components/form.tsx b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/components/form.tsx index ce168c5c0646777..893956af34f7a4c 100644 --- a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/components/form.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/components/form.tsx @@ -7,7 +7,7 @@ import type { ChangeEventHandler } from 'react'; import React, { memo, useCallback, useEffect, useMemo, useState } from 'react'; -import type { EuiSuperSelectOption } from '@elastic/eui'; +import type { EuiFieldTextProps, EuiSuperSelectOption } from '@elastic/eui'; import { EuiFieldText, EuiForm, @@ -332,7 +332,7 @@ export const TrustedAppsForm = memo( [item, processChanged] ); - const handleOnNameBlur = useCallback( + const handleOnNameBlur = useCallback>( ({ target: { name } }) => { processChanged(item); setVisited((prevVisited) => ({ ...prevVisited, [name]: true })); diff --git a/x-pack/plugins/security_solution/public/overview/components/detection_response/cases_by_status/cases_by_status.tsx b/x-pack/plugins/security_solution/public/overview/components/detection_response/cases_by_status/cases_by_status.tsx index 89782fa56707f4a..e702454d45ec567 100644 --- a/x-pack/plugins/security_solution/public/overview/components/detection_response/cases_by_status/cases_by_status.tsx +++ b/x-pack/plugins/security_solution/public/overview/components/detection_response/cases_by_status/cases_by_status.tsx @@ -103,7 +103,7 @@ const CasesByStatusComponent: React.FC = () => { const caseUrl = getAppUrl({ deepLinkId: SecurityPageName.case, path: appendSearch(search) }); const goToCases = useCallback( - (ev) => { + (ev: React.SyntheticEvent) => { ev.preventDefault(); navigateTo({ url: caseUrl }); }, diff --git a/x-pack/plugins/security_solution/public/overview/components/events_by_dataset/index.tsx b/x-pack/plugins/security_solution/public/overview/components/events_by_dataset/index.tsx index 4cad19444c5e79f..37051c2b5c82299 100644 --- a/x-pack/plugins/security_solution/public/overview/components/events_by_dataset/index.tsx +++ b/x-pack/plugins/security_solution/public/overview/components/events_by_dataset/index.tsx @@ -105,7 +105,7 @@ const EventsByDatasetComponent: React.FC = ({ const [defaultNumberFormat] = useUiSetting$(DEFAULT_NUMBER_FORMAT); const goToHostEvents = useCallback( - (ev) => { + (ev: React.SyntheticEvent) => { ev.preventDefault(); navigateToApp(APP_UI_ID, { deepLinkId: SecurityPageName.hosts, diff --git a/x-pack/plugins/security_solution/public/overview/components/overview_network/index.tsx b/x-pack/plugins/security_solution/public/overview/components/overview_network/index.tsx index c7616c3c6d2997e..f9d4319ca25128d 100644 --- a/x-pack/plugins/security_solution/public/overview/components/overview_network/index.tsx +++ b/x-pack/plugins/security_solution/public/overview/components/overview_network/index.tsx @@ -72,7 +72,7 @@ const OverviewNetworkComponent: React.FC = ({ }); const goToNetwork = useCallback( - (ev) => { + (ev: React.SyntheticEvent) => { ev.preventDefault(); navigateToApp(APP_UI_ID, { deepLinkId: SecurityPageName.network, diff --git a/x-pack/plugins/security_solution/public/overview/components/recent_timelines/index.tsx b/x-pack/plugins/security_solution/public/overview/components/recent_timelines/index.tsx index 8e6ccb158bfa7b7..a167791a7b06cd2 100644 --- a/x-pack/plugins/security_solution/public/overview/components/recent_timelines/index.tsx +++ b/x-pack/plugins/security_solution/public/overview/components/recent_timelines/index.tsx @@ -54,7 +54,7 @@ const StatefulRecentTimelinesComponent: React.FC = ({ filterBy }) => { ); const goToTimelines = useCallback( - (ev) => { + (ev: React.SyntheticEvent) => { ev.preventDefault(); navigateToApp(APP_UI_ID, { deepLinkId: SecurityPageName.timelines, diff --git a/x-pack/plugins/security_solution/public/resolver/view/controls/date_picker.tsx b/x-pack/plugins/security_solution/public/resolver/view/controls/date_picker.tsx index aa0c0f6031952a4..62d86cb37aed00c 100644 --- a/x-pack/plugins/security_solution/public/resolver/view/controls/date_picker.tsx +++ b/x-pack/plugins/security_solution/public/resolver/view/controls/date_picker.tsx @@ -8,7 +8,7 @@ import React, { useCallback, memo } from 'react'; import { useSelector, useDispatch } from 'react-redux'; import { i18n } from '@kbn/i18n'; import { EuiPopover, EuiPopoverTitle, EuiSuperDatePicker } from '@elastic/eui'; -import type { ShortDate } from '@elastic/eui'; +import type { ShortDate, EuiSuperDatePickerProps } from '@elastic/eui'; import { formatDate } from '../../../common/components/super_date_picker'; import { StyledEuiButtonIcon } from './styles'; import { useColors } from '../use_colors'; @@ -61,7 +61,7 @@ export const DateSelectionButton = memo( return selectors.currentAppliedTimeRange(state.analyzer[id]); }); - const onTimeChange = useCallback( + const onTimeChange = useCallback( ({ start, end, isInvalid }) => { if (!isInvalid) { const isQuickSelection = start.includes('now') || end.includes('now'); diff --git a/x-pack/plugins/security_solution/public/resolver/view/controls/index.tsx b/x-pack/plugins/security_solution/public/resolver/view/controls/index.tsx index 6829f9ece1fe03e..a12ae2d90a7dc21 100644 --- a/x-pack/plugins/security_solution/public/resolver/view/controls/index.tsx +++ b/x-pack/plugins/security_solution/public/resolver/view/controls/index.tsx @@ -29,6 +29,8 @@ import { StyledGraphControls, StyledGraphControlsColumn, StyledEuiRange } from ' import { NodeLegend } from './legend'; import { SchemaInformation } from './schema'; +type PopoverType = null | 'schemaInfo' | 'nodeLegend' | 'sourcererSelection' | 'datePicker'; + export const GraphControls = React.memo( ({ id, @@ -51,13 +53,11 @@ export const GraphControls = React.memo( const isDatePickerAndSourcererDisabled = useIsExperimentalFeatureEnabled( 'analyzerDatePickersAndSourcererDisabled' ); - const [activePopover, setPopover] = useState< - null | 'schemaInfo' | 'nodeLegend' | 'sourcererSelection' | 'datePicker' - >(null); + const [activePopover, setPopover] = useState(null); const colorMap = useColors(); const setActivePopover = useCallback( - (value) => { + (value: PopoverType) => { if (value === activePopover) { setPopover(null); } else { diff --git a/x-pack/plugins/security_solution/public/resolver/view/process_event_dot.tsx b/x-pack/plugins/security_solution/public/resolver/view/process_event_dot.tsx index 0465f16d55b70d1..3846e1d7b19d1e8 100644 --- a/x-pack/plugins/security_solution/public/resolver/view/process_event_dot.tsx +++ b/x-pack/plugins/security_solution/public/resolver/view/process_event_dot.tsx @@ -317,7 +317,7 @@ const UnstyledProcessEventDot = React.memo( }, [dispatch, nodeID, timestamp, id]); const handleClick = useCallback( - (clickEvent) => { + (clickEvent: React.MouseEvent) => { if (animationTarget.current?.beginElement) { animationTarget.current.beginElement(); } diff --git a/x-pack/plugins/security_solution/public/resolver/view/use_link_props.ts b/x-pack/plugins/security_solution/public/resolver/view/use_link_props.ts index f61d768a341411b..494ed521c73e060 100644 --- a/x-pack/plugins/security_solution/public/resolver/view/use_link_props.ts +++ b/x-pack/plugins/security_solution/public/resolver/view/use_link_props.ts @@ -13,8 +13,6 @@ import * as selectors from '../store/selectors'; import type { PanelViewAndParameters } from '../types'; import type { State } from '../../common/store/types'; -type EventHandlerCallback = MouseEventHandler; - /** * Get an `onClick` function and an `href` string. Use these as props for `` elements. * `onClick` will use navigate to the `panelViewAndParameters` using `history.push`. @@ -26,7 +24,7 @@ export function useLinkProps( panelViewAndParameters: PanelViewAndParameters ): { href: string; - onClick: EventHandlerCallback; + onClick: MouseEventHandler; } { const search = useSelector((state: State) => selectors.relativeHref(state.analyzer[id])(panelViewAndParameters) diff --git a/x-pack/plugins/security_solution/public/resolver/view/use_navigate_or_replace.ts b/x-pack/plugins/security_solution/public/resolver/view/use_navigate_or_replace.ts index 447bedb6735236c..ede554b305d3082 100644 --- a/x-pack/plugins/security_solution/public/resolver/view/use_navigate_or_replace.ts +++ b/x-pack/plugins/security_solution/public/resolver/view/use_navigate_or_replace.ts @@ -10,15 +10,13 @@ import { useCallback } from 'react'; import { useHistory } from 'react-router-dom'; import type { LocationDescriptorObject } from 'history'; -type EventHandlerCallback = MouseEventHandler; - export function useNavigateOrReplace( to: LocationDescriptorObject, /** Additional onClick callback */ - additionalOnClick?: EventHandlerCallback -): { href: string; onClick: EventHandlerCallback } { + additionalOnClick?: MouseEventHandler +): { href: string; onClick: MouseEventHandler } { const history = useHistory(); - const onClick = useCallback( + const onClick = useCallback( (event) => { try { if (additionalOnClick) { diff --git a/x-pack/plugins/security_solution/public/sourcerer/components/index.tsx b/x-pack/plugins/security_solution/public/sourcerer/components/index.tsx index 0f946bd8c247c94..8b45d9666979306 100644 --- a/x-pack/plugins/security_solution/public/sourcerer/components/index.tsx +++ b/x-pack/plugins/security_solution/public/sourcerer/components/index.tsx @@ -255,7 +255,7 @@ export const Sourcerer = React.memo(({ scope: scopeId } ); const onChangeDataView = useCallback( - (newSelectedOption) => { + (newSelectedOption: string) => { setDataViewId(newSelectedOption); setIndexPatternsByDataView(newSelectedOption); }, diff --git a/x-pack/plugins/security_solution/public/sourcerer/components/use_pick_index_patterns.tsx b/x-pack/plugins/security_solution/public/sourcerer/components/use_pick_index_patterns.tsx index 397732ed4ec9fd2..8798a84409d13d9 100644 --- a/x-pack/plugins/security_solution/public/sourcerer/components/use_pick_index_patterns.tsx +++ b/x-pack/plugins/security_solution/public/sourcerer/components/use_pick_index_patterns.tsx @@ -179,11 +179,11 @@ export const usePickIndexPatterns = ({ // eslint-disable-next-line react-hooks/exhaustive-deps }, [isOnlyDetectionAlerts, selectedDataViewId, missingPatterns, scopeId, selectedPatterns]); - const onChangeCombo = useCallback((newSelectedOptions) => { + const onChangeCombo = useCallback((newSelectedOptions) => { setSelectedOptions(newSelectedOptions); }, []); - const renderOption = useCallback( + const renderOption = useCallback( ({ value }) => {value}, [] ); diff --git a/x-pack/plugins/security_solution/public/threat_intelligence/use_investigate_in_timeline.ts b/x-pack/plugins/security_solution/public/threat_intelligence/use_investigate_in_timeline.ts index 64e616d0a1ea91e..85ced6d6e153dee 100644 --- a/x-pack/plugins/security_solution/public/threat_intelligence/use_investigate_in_timeline.ts +++ b/x-pack/plugins/security_solution/public/threat_intelligence/use_investigate_in_timeline.ts @@ -50,7 +50,8 @@ export const useInvestigateInTimeline = ({ const { startTransaction } = useStartTransaction(); const updateTimelineIsLoading = useCallback( - (payload) => dispatch(timelineActions.updateIsLoading(payload)), + (payload: Parameters[0]) => + dispatch(timelineActions.updateIsLoading(payload)), [dispatch] ); diff --git a/x-pack/plugins/security_solution/public/timelines/components/modal/actions/save_timeline_modal.tsx b/x-pack/plugins/security_solution/public/timelines/components/modal/actions/save_timeline_modal.tsx index 67409a91c854253..7ce0be75def6149 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/modal/actions/save_timeline_modal.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/modal/actions/save_timeline_modal.tsx @@ -88,7 +88,7 @@ export const SaveTimelineModal = React.memo( }); const handleSubmit = useCallback( - (titleAndDescription, isValid) => { + (titleAndDescription: { title: string; description: string }, isValid: boolean) => { if (isValid) { dispatch( timelineActions.updateTitleAndDescription({ diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/export_timeline/export_timeline.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/export_timeline/export_timeline.tsx index 3ca9f88422a24c5..04493dfd9a4b8ec 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/export_timeline/export_timeline.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/export_timeline/export_timeline.tsx @@ -23,7 +23,7 @@ const ExportTimeline: React.FC<{ const { addSuccess } = useAppToasts(); const onExportSuccess = useCallback( - (exportCount) => { + (exportCount: number) => { if (onComplete != null) { onComplete(); } diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/types.ts b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/types.ts index 1fb75887d6a755b..1a47c22d0fb61c5 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/types.ts +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/types.ts @@ -240,7 +240,7 @@ export interface TimelineTab { href: string; id: TimelineType; name: string; - onClick: (ev: { preventDefault: () => void }) => void; + onClick: (ev: React.SyntheticEvent) => void; } export interface TemplateTimelineFilter { diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/use_timeline_status.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/use_timeline_status.tsx index 9e39bbf8ece3448..f51334d03293bba 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/use_timeline_status.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/use_timeline_status.tsx @@ -79,7 +79,7 @@ export const useTimelineStatus = ({ ); const onFilterClicked = useCallback( - (tabId) => { + (tabId: TemplateTimelineType) => { if (selectedTab === tabId) { setSelectedTab(null); } else { diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/use_timeline_types.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/use_timeline_types.tsx index 8002798291cc186..e08eccaf093e0ca 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/use_timeline_types.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/use_timeline_types.tsx @@ -158,7 +158,7 @@ export const useTimelineTypes = ({ data-test-subj={`open-timeline-modal-body-${TimelineTabsStyle.filter}-${tab.id}`} isSelected={tab.id === timelineType} key={`timeline-${TimelineTabsStyle.filter}-${tab.id}`} - onClick={(ev: { preventDefault: () => void }) => { + onClick={(ev: React.SyntheticEvent) => { tab.onClick(ev); onFilterClicked(tab.id, TimelineTabsStyle.filter); }} diff --git a/x-pack/plugins/security_solution/public/timelines/components/row_renderers_browser/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/row_renderers_browser/index.tsx index 776d1279ae715bc..4bef910848fc0dd 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/row_renderers_browser/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/row_renderers_browser/index.tsx @@ -24,6 +24,7 @@ import styled from 'styled-components'; import type { State } from '../../../common/store'; import { RowRendererValues } from '../../../../common/api/timeline'; +import type { RowRendererId } from '../../../../common/api/timeline'; import { useDeepEqualSelector } from '../../../common/hooks/use_selector'; import { setExcludedRowRendererIds as dispatchSetExcludedRowRendererIds } from '../../store/actions'; import { timelineSelectors } from '../../store'; @@ -79,7 +80,7 @@ const StatefulRowRenderersBrowserComponent: React.FC + (payload: RowRendererId[]) => dispatch( dispatchSetExcludedRowRendererIds({ id: timelineId, diff --git a/x-pack/plugins/security_solution/public/timelines/components/row_renderers_browser/row_renderers_browser.tsx b/x-pack/plugins/security_solution/public/timelines/components/row_renderers_browser/row_renderers_browser.tsx index 45f709013952816..4656bfb0da59fa6 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/row_renderers_browser/row_renderers_browser.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/row_renderers_browser/row_renderers_browser.tsx @@ -96,7 +96,7 @@ const RowRenderersBrowserComponent = ({ ); const nameColumnRenderCallback = useCallback( - (value, item) => ( + (value: string, item: RowRendererOption) => ( {value} @@ -105,7 +105,7 @@ const RowRenderersBrowserComponent = ({ ); const idColumnRenderCallback = useCallback( - (_, item) => ( + (_: unknown, item: RowRendererOption) => ( = ({ [header, onFilterChange, sort, timelineId] ); - const DraggableContent = useCallback( + const DraggableContent = useCallback( (dragProvided) => ( = ({ ); }, [dispatch, header, sort, timelineId]); - const onColumnRemoved = useCallback( + const onColumnRemoved = useCallback( (columnId) => dispatch(timelineActions.removeColumn({ id: timelineId, columnId })), [dispatch, timelineId] ); diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/column_headers/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/column_headers/index.tsx index d2b9a0aa7c66772..f343b9af8ed97b6 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/column_headers/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/column_headers/index.tsx @@ -6,7 +6,7 @@ */ import React, { useState, useEffect, useCallback, useMemo, useRef } from 'react'; -import type { DraggableChildrenFn } from '@hello-pangea/dnd'; +import type { DraggableChildrenFn, DroppableProps } from '@hello-pangea/dnd'; import { Droppable } from '@hello-pangea/dnd'; import { useDispatch } from 'react-redux'; @@ -162,7 +162,7 @@ export const ColumnHeadersComponent = ({ [columnHeaders, timelineId, draggingIndex, sort, tabType] ); - const DroppableContent = useCallback( + const DroppableContent = useCallback( (dropProvided, snapshot) => ( <> = ({ const { navigateToApp, getUrlForApp } = useKibana().services.application; const goToRuleDetails = useCallback( - (ev) => { + (ev: React.SyntheticEvent) => { ev.preventDefault(); navigateToApp(APP_UI_ID, { deepLinkId: SecurityPageName.rules, diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/suricata/suricata_signature.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/suricata/suricata_signature.tsx index 55950f9a9aac67d..fdb1f818f754e65 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/suricata/suricata_signature.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/suricata/suricata_signature.tsx @@ -9,6 +9,7 @@ import { EuiBadge, EuiFlexGroup, EuiFlexItem, EuiToolTip } from '@elastic/eui'; import React, { useCallback, useMemo } from 'react'; import styled from 'styled-components'; +import type { DraggableWrapperProps } from '../../../../../../common/components/drag_and_drop/draggable_wrapper'; import { DragEffects, DraggableWrapper, @@ -80,7 +81,7 @@ export const DraggableSignatureId = React.memo<{ [id, signatureId] ); - const render = useCallback( + const render: DraggableWrapperProps['render'] = useCallback( (dataProvider, _, snapshot) => snapshot.isDragging ? ( diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/user_name.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/user_name.tsx index 48ce6255725d36e..1f070d52a8de909 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/user_name.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/user_name.tsx @@ -49,7 +49,7 @@ const UserNameComponent: React.FC = ({ const { openRightPanel } = useExpandableFlyoutApi(); const openUserDetailsSidePanel = useCallback( - (e) => { + (e: React.SyntheticEvent) => { e.preventDefault(); if (onClick) { diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/zeek/zeek_signature.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/zeek/zeek_signature.tsx index 6e4b8793620308c..493d6d054a9944c 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/zeek/zeek_signature.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/zeek/zeek_signature.tsx @@ -11,6 +11,7 @@ import React, { useCallback, useMemo } from 'react'; import styled from 'styled-components'; import type { EcsSecurityExtension as Ecs } from '@kbn/securitysolution-ecs'; +import type { DraggableWrapperProps } from '../../../../../../common/components/drag_and_drop/draggable_wrapper'; import { DragEffects, DraggableWrapper, @@ -89,7 +90,7 @@ export const DraggableZeekElement = React.memo<{ [field, id, value] ); - const render = useCallback( + const render: DraggableWrapperProps['render'] = useCallback( (dataProvider, _, snapshot) => snapshot.isDragging ? ( diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/add_data_provider_popover.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/add_data_provider_popover.tsx index d09444edd6c9969..09aef63266d2a46 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/add_data_provider_popover.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/add_data_provider_popover.tsx @@ -27,6 +27,7 @@ import { StatefulEditDataProvider } from '../../edit_data_provider'; import { addContentToTimeline, getDisplayValue } from './helpers'; import { timelineSelectors } from '../../../store'; import { ADD_FIELD_LABEL, ADD_TEMPLATE_FIELD_LABEL } from './translations'; +import type { OnDataProviderEdited } from '../events'; interface AddDataProviderPopoverProps { browserFields: BrowserFields; @@ -58,7 +59,7 @@ const AddDataProviderPopoverComponent: React.FC = ( [setIsAddFilterPopoverOpen] ); - const handleDataProviderEdited = useCallback( + const handleDataProviderEdited = useCallback( ({ andProviderId, excluded, field, id, operator, providerId, value, type }) => { addContentToTimeline({ dataProviders, diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/providers.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/providers.tsx index 11c13f16275f885..debb46a1f992242 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/providers.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/providers.tsx @@ -5,10 +5,11 @@ * 2.0. */ +import type { DroppableProps } from '@elastic/eui'; import { EuiFlexGroup, EuiFlexItem, EuiFormHelpText, EuiSpacer } from '@elastic/eui'; import { rgba } from 'polished'; import React, { useCallback, useMemo, useRef, useState } from 'react'; -import type { DraggingStyle, NotDraggingStyle } from '@hello-pangea/dnd'; +import type { DraggableChildrenFn, DraggingStyle, NotDraggingStyle } from '@hello-pangea/dnd'; import { Draggable, Droppable } from '@hello-pangea/dnd'; import styled from 'styled-components'; import { useDispatch } from 'react-redux'; @@ -34,6 +35,7 @@ import { EMPTY_GROUP, flattenIntoAndGroups } from './helpers'; import { ProviderItemBadge } from './provider_item_badge'; import * as i18n from './translations'; +import type { OnDataProviderEdited } from '../events'; export const EMPTY_PROVIDERS_GROUP_CLASS_NAME = 'empty-providers-group'; @@ -222,7 +224,7 @@ export const DataProvidersGroupItem = React.memo( dispatch(timelineActions.updateDataProviderType(payload)); }, [dataProvider.id, dataProvider.type, dispatch, group, index, timelineId]); - const handleDataProviderEdited = useCallback( + const handleDataProviderEdited = useCallback( ({ andProviderId, excluded, field, operator, providerId, value }) => dispatch( timelineActions.dataProviderEdited({ @@ -267,7 +269,7 @@ export const DataProvidersGroupItem = React.memo( dataProvider.queryMatch.displayValue ?? dataProvider.queryMatch.value ); - const DraggableContent = useCallback( + const DraggableContent = useCallback( (provided, snapshot) => (
( [browserFields, group, groupIndex, timelineId] ); - const DroppableContent = useCallback( + const DroppableContent = useCallback( (droppableProvided) => ( setIsPopoverOpen(false), [setIsPopoverOpen]); const onChangeItemsPerPage = useCallback( - (itemsChangedPerPage) => + (itemsChangedPerPage: number) => dispatch(timelineActions.updateItemsPerPage({ id, itemsPerPage: itemsChangedPerPage })), [dispatch, id] ); diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/query_bar/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/query_bar/index.tsx index 659073b3fc83269..3ac5ba0cb5ac892 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/query_bar/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/query_bar/index.tsx @@ -121,7 +121,7 @@ export const QueryBarTimeline = memo( const savedQueryServices = useSavedQueryServices(); const applyKqlFilterQuery = useCallback( - (expression: string, kind) => + (expression: string, kind: KueryFilterQueryKind) => dispatch( timelineActions.applyKqlFilterQuery({ id: timelineId, diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/search_super_select/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/search_super_select/index.tsx index 33bbfe53bda652d..1a4906b6c530a58 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/search_super_select/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/search_super_select/index.tsx @@ -10,6 +10,7 @@ import { EuiInputPopover, EuiFieldText, htmlIdGenerator, keys } from '@elastic/e import React, { memo, useCallback, useMemo, useState } from 'react'; import type { OpenTimelineResult } from '../../open_timeline/types'; +import type { SelectableTimelineProps } from '../selectable_timeline'; import { SelectableTimeline } from '../selectable_timeline'; import * as i18n from '../translations'; import { type TimelineType, TimelineTypeEnum } from '../../../../../common/api/timeline'; @@ -89,7 +90,7 @@ const SearchTimelineSuperSelectComponent: React.FC( ({ timelines, onlyFavorites, searchTimelineValue }) => [ ...(!onlyFavorites && searchTimelineValue === '' ? getBasicSelectableOptions(timelineId == null ? '-1' : timelineId) diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/selectable_timeline/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/selectable_timeline/index.tsx index 71c5b273d9dc1d1..b1672e1a7f6f4cb 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/selectable_timeline/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/selectable_timeline/index.tsx @@ -25,7 +25,7 @@ import { type TimelineType, SortFieldTimelineEnum } from '../../../../../common/ import { useGetAllTimeline } from '../../../containers/all'; import { isUntitled } from '../../open_timeline/helpers'; import * as i18nTimeline from '../../open_timeline/translations'; -import type { OpenTimelineResult } from '../../open_timeline/types'; +import type { FavoriteTimelineResult, OpenTimelineResult } from '../../open_timeline/types'; import { getEmptyTagValue } from '../../../../common/components/empty_value'; import * as i18n from '../translations'; import { Direction } from '../../../../../common/search_strategy'; @@ -50,8 +50,16 @@ const TIMELINE_ITEM_HEIGHT = 50; * @param {EuiSelectableOption[]} options * @returns {EuiSelectableOption[]} modified options */ -const replaceTitleInOptions = (options: EuiSelectableOption[]): EuiSelectableOption[] => - options.map(({ title, ...props }) => ({ ...props, title: undefined, timelineTitle: title })); +const replaceTitleInOptions = ( + options: EuiSelectableOption[] +): Array< + EuiSelectableOption<{ timelineTitle: string; description?: string; graphEveId?: string }> +> => + options.map(({ title, ...props }) => ({ + ...props, + title: undefined, + timelineTitle: title ?? '', + })); export interface GetSelectableOptions { timelines: OpenTimelineResult[]; @@ -97,7 +105,7 @@ const SelectableTimelineComponent: React.FC = ({ const debouncedSetSearchTimelineValue = useMemo(() => debounce(500, setSearchTimelineValue), []); const onSearchTimeline = useCallback( - (val) => { + (val: string) => { debouncedSetSearchTimelineValue(val); }, [debouncedSetSearchTimelineValue] @@ -130,7 +138,16 @@ const SelectableTimelineComponent: React.FC = ({ [heightTrigger, pageSize] ); - const renderTimelineOption = useCallback((option, searchValue) => { + const renderTimelineOption = useCallback< + NonNullable< + EuiSelectableProps<{ + timelineTitle: string; + description?: string; + graphEventId?: string; + favorite?: FavoriteTimelineResult[]; + }>['renderOption'] + > + >((option, searchValue) => { const title: string = isUntitled({ ...option, title: option.timelineTitle }) ? i18nTimeline.UNTITLED_TIMELINE : option.timelineTitle; @@ -176,17 +193,25 @@ const SelectableTimelineComponent: React.FC = ({ ); }, []); - const handleTimelineChange = useCallback( + const handleTimelineChange = useCallback< + NonNullable< + EuiSelectableProps<{ + timelineTitle: string; + description?: string; + graphEventId?: string; + }>['onChange'] + > + >( (options) => { - const selectedTimeline = options.filter( - (option: { checked: string }) => option.checked === 'on' - ); + const selectedTimeline = options.filter((option) => option.checked === 'on'); if (selectedTimeline != null && selectedTimeline.length > 0) { onTimelineChange( isEmpty(selectedTimeline[0].timelineTitle) ? i18nTimeline.UNTITLED_TIMELINE : selectedTimeline[0].timelineTitle, - selectedTimeline[0].id === '-1' ? null : selectedTimeline[0].id, + selectedTimeline[0].id === '-1' + ? null + : (selectedTimeline[0].id as unknown as string | null), selectedTimeline[0].graphEventId ?? '' ); } @@ -195,7 +220,7 @@ const SelectableTimelineComponent: React.FC = ({ [onClosePopover, onTimelineChange] ); - const EuiSelectableContent = useCallback( + const EuiSelectableContent = useCallback>( (list, search) => ( <> {search} @@ -260,7 +285,12 @@ const SelectableTimelineComponent: React.FC = ({ }, [fetchAllTimeline, onlyFavorites, pageSize, searchTimelineValue, timelineType]); return ( - data-test-subj="selectable-input" height={POPOVER_HEIGHT} isLoading={loading && timelines == null} diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/session/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/session/index.tsx index eceb9c8dbd284f4..42fffc7763712ac 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/session/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/session/index.tsx @@ -29,7 +29,7 @@ interface Props { const SessionTabContent: React.FC = ({ timelineId }) => { const [height, setHeight] = useState(0); - const measuredRef = useCallback((node) => { + const measuredRef = useCallback((node: HTMLDivElement | HTMLSpanElement | null) => { if (node !== null) { setHeight(node.getBoundingClientRect().height); } diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/unified_components/data_table/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/unified_components/data_table/index.tsx index 42b23945ac7b8e9..0b629788b7691a6 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/unified_components/data_table/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/unified_components/data_table/index.tsx @@ -208,7 +208,9 @@ export const TimelineDataTableComponent: React.FC = memo( [onColumnResize] ); - const onChangeItemsPerPage = useCallback( + const onChangeItemsPerPage = useCallback< + NonNullable + >( (itemsChangedPerPage) => { dispatch( timelineActions.updateItemsPerPage({ id: timelineId, itemsPerPage: itemsChangedPerPage }) diff --git a/x-pack/plugins/security_solution/public/timelines/hooks/use_create_timeline.tsx b/x-pack/plugins/security_solution/public/timelines/hooks/use_create_timeline.tsx index c7b5252e0897b4f..e0783522f5dd1fd 100644 --- a/x-pack/plugins/security_solution/public/timelines/hooks/use_create_timeline.tsx +++ b/x-pack/plugins/security_solution/public/timelines/hooks/use_create_timeline.tsx @@ -63,7 +63,15 @@ export const useCreateTimeline = ({ const { resetDiscoverAppState } = useDiscoverInTimelineContext(); const createTimeline = useCallback( - ({ id, show, timeRange: timeRangeParam }) => { + ({ + id, + show, + timeRange: timeRangeParam, + }: { + id: string; + show: boolean; + timeRange?: TimeRange; + }) => { const timerange = timeRangeParam ?? globalTimeRange; if (id === TimelineId.active && timelineFullScreen) { @@ -131,11 +139,11 @@ export const useCreateTimeline = ({ return useCallback( async (options?: { timeRange?: TimeRange }) => { await resetDiscoverAppState(); - createTimeline({ id: timelineId, show: true, timelineType, timeRange: options?.timeRange }); + createTimeline({ id: timelineId, show: true, timeRange: options?.timeRange }); if (typeof onClick === 'function') { onClick(); } }, - [createTimeline, timelineId, timelineType, onClick, resetDiscoverAppState] + [createTimeline, timelineId, onClick, resetDiscoverAppState] ); }; diff --git a/x-pack/plugins/security_solution/public/timelines/store/actions.ts b/x-pack/plugins/security_solution/public/timelines/store/actions.ts index fbf061529c495f2..e65b7273b5de7f7 100644 --- a/x-pack/plugins/security_solution/public/timelines/store/actions.ts +++ b/x-pack/plugins/security_solution/public/timelines/store/actions.ts @@ -30,6 +30,7 @@ import type { } from '../../../common/types/timeline'; import type { DataProviderType, RowRendererId } from '../../../common/api/timeline'; import type { ResolveTimelineConfig } from '../components/open_timeline/types'; +import type { PrimitiveOrArrayOfPrimitives } from '../../common/lib/kuery'; const actionCreator = actionCreatorFactory('x-pack/security_solution/local/timeline'); @@ -115,7 +116,7 @@ export const dataProviderEdited = actionCreator<{ id: string; operator: QueryOperator; providerId: string; - value: string | number | Array; + value: PrimitiveOrArrayOfPrimitives; }>('DATA_PROVIDER_EDITED'); export const updateDataProviderType = actionCreator<{ diff --git a/x-pack/plugins/security_solution/public/timelines/store/helpers.ts b/x-pack/plugins/security_solution/public/timelines/store/helpers.ts index 0342c28f28aa922..b876465449740bc 100644 --- a/x-pack/plugins/security_solution/public/timelines/store/helpers.ts +++ b/x-pack/plugins/security_solution/public/timelines/store/helpers.ts @@ -44,6 +44,7 @@ import { import { activeTimeline } from '../containers/active_timeline_context'; import type { ResolveTimelineConfig } from '../components/open_timeline/types'; import { getDisplayValue } from '../components/timeline/data_providers/helpers'; +import type { PrimitiveOrArrayOfPrimitives } from '../../common/lib/kuery'; interface AddTimelineNoteParams { id: string; @@ -841,7 +842,7 @@ const updateProviderProperties = ({ operator: QueryOperator; providerId: string; timeline: TimelineModel; - value: string | number | Array; + value: PrimitiveOrArrayOfPrimitives; }) => timeline.dataProviders.map((provider) => provider.id === providerId @@ -875,7 +876,7 @@ const updateAndProviderProperties = ({ operator: QueryOperator; providerId: string; timeline: TimelineModel; - value: string | number | Array; + value: PrimitiveOrArrayOfPrimitives; }) => timeline.dataProviders.map((provider) => provider.id === providerId @@ -909,7 +910,7 @@ interface UpdateTimelineProviderEditPropertiesParams { operator: QueryOperator; providerId: string; timelineById: TimelineById; - value: string | number | Array; + value: PrimitiveOrArrayOfPrimitives; } export const updateTimelineProviderProperties = ({ diff --git a/x-pack/plugins/security_solution/public/value_list/components/inline_edit_list_item_value.tsx b/x-pack/plugins/security_solution/public/value_list/components/inline_edit_list_item_value.tsx index d8777a8d83d00b4..7fe449e6cbbfcfb 100644 --- a/x-pack/plugins/security_solution/public/value_list/components/inline_edit_list_item_value.tsx +++ b/x-pack/plugins/security_solution/public/value_list/components/inline_edit_list_item_value.tsx @@ -33,7 +33,7 @@ export const InlineEditListItemValue = ({ listItem }: { listItem: ListItemSchema }); }, }); - const onChange = useCallback((e) => { + const onChange = useCallback>((e) => { setValue(e.target.value); }, []); const onCancel = useCallback(() => { @@ -41,7 +41,7 @@ export const InlineEditListItemValue = ({ listItem }: { listItem: ListItemSchema }, [listItem]); const onSave = useCallback( - async (newValue) => { + async (newValue: string) => { track(METRIC_TYPE.COUNT, TELEMETRY_EVENT.EDIT_VALUE_LIST_ITEM); await patchListItemMutation.mutateAsync({ id: listItem.id, diff --git a/x-pack/plugins/security_solution/public/value_list/components/value_list_modal.tsx b/x-pack/plugins/security_solution/public/value_list/components/value_list_modal.tsx index 6aa6b1b7d9b6057..f2741d80bd35ad0 100644 --- a/x-pack/plugins/security_solution/public/value_list/components/value_list_modal.tsx +++ b/x-pack/plugins/security_solution/public/value_list/components/value_list_modal.tsx @@ -6,6 +6,7 @@ */ import React, { useState, useCallback } from 'react'; import { css } from '@emotion/css'; +import type { EuiSearchBarProps } from '@elastic/eui'; import { EuiModal, EuiModalHeader, @@ -100,7 +101,7 @@ export const ValueListModal = ({ listId, onCloseModal, canWriteIndex }: ValueLis pageSizeOptions: [5, 10, 25], }; - const onQueryChange = useCallback((params) => { + const onQueryChange: NonNullable = useCallback((params) => { setFilter(params.queryText); }, []); diff --git a/x-pack/plugins/session_view/public/components/process_tree_alerts/index.tsx b/x-pack/plugins/session_view/public/components/process_tree_alerts/index.tsx index 6cadb836d1661be..cf688abdece57bd 100644 --- a/x-pack/plugins/session_view/public/components/process_tree_alerts/index.tsx +++ b/x-pack/plugins/session_view/public/components/process_tree_alerts/index.tsx @@ -80,7 +80,7 @@ export function ProcessTreeAlerts({ [onAlertSelected] ); - const handleProcessEventAlertCategorySelected = useCallback((eventCategory) => { + const handleProcessEventAlertCategorySelected = useCallback((eventCategory: any) => { setSelectedProcessEventAlertCategory(eventCategory); }, []); diff --git a/x-pack/plugins/session_view/public/components/process_tree_alerts_filter/index.tsx b/x-pack/plugins/session_view/public/components/process_tree_alerts_filter/index.tsx index a52fcc09cc4eadf..6f4b2b5570b4d1f 100644 --- a/x-pack/plugins/session_view/public/components/process_tree_alerts_filter/index.tsx +++ b/x-pack/plugins/session_view/public/components/process_tree_alerts_filter/index.tsx @@ -51,7 +51,7 @@ export const ProcessTreeAlertsFilter = ({ }; const onSelectedProcessEventAlertCategory = useCallback( - (event) => { + (event: any) => { const [_, selectedAlertEvent] = event.target.textContent.split(' '); setSelectedProcessEventAlertCategory(selectedAlertEvent); onAlertEventCategorySelected(selectedAlertEvent); diff --git a/x-pack/plugins/session_view/public/components/process_tree_node/index.tsx b/x-pack/plugins/session_view/public/components/process_tree_node/index.tsx index 3bd72837e01ed52..a6201ea2ed50472 100644 --- a/x-pack/plugins/session_view/public/components/process_tree_node/index.tsx +++ b/x-pack/plugins/session_view/public/components/process_tree_node/index.tsx @@ -128,7 +128,7 @@ export function ProcessTreeNode({ const nodeRef = useVisible({ viewPortEl: scrollerRef.current, visibleCallback: useCallback( - (isVisible, isAbove) => { + (isVisible: any, isAbove: any) => { onChangeJumpToEventVisibility(isVisible, isAbove); }, [onChangeJumpToEventVisibility] diff --git a/x-pack/plugins/session_view/public/components/tty_player/hooks.ts b/x-pack/plugins/session_view/public/components/tty_player/hooks.ts index 73f85b9da37839b..a1f039f9caad0fc 100644 --- a/x-pack/plugins/session_view/public/components/tty_player/hooks.ts +++ b/x-pack/plugins/session_view/public/components/tty_player/hooks.ts @@ -335,7 +335,7 @@ export const useXtermPlayer = ({ }, [lines, currentLine, isPlaying, playSpeed, render, hasNextPage, fetchNextPage, setIsPlaying]); const seekToLine = useCallback( - (index) => { + (index: any) => { setCurrentLine(index); render(index, true); diff --git a/x-pack/plugins/session_view/public/components/tty_search_bar/index.tsx b/x-pack/plugins/session_view/public/components/tty_search_bar/index.tsx index 9ba7958cb53b69d..71225b4cda93900 100644 --- a/x-pack/plugins/session_view/public/components/tty_search_bar/index.tsx +++ b/x-pack/plugins/session_view/public/components/tty_search_bar/index.tsx @@ -37,7 +37,7 @@ export const TTYSearchBar = ({ const [currentMatch, setCurrentMatch] = useState(null); const jumpToMatch = useCallback( - (match) => { + (match: any) => { if (match) { setIsPlaying(false); const goToLine = lines.indexOf(match.line); @@ -103,7 +103,7 @@ export const TTYSearchBar = ({ }, [searchQuery, lines, jumpToMatch, xTermSearchFn]); const onSearch = useCallback( - (query) => { + (query: any) => { setIsPlaying(false); setSearchQuery(query); setCurrentMatch(null); @@ -112,7 +112,7 @@ export const TTYSearchBar = ({ ); const onSetCurrentMatch = useCallback( - (index) => { + (index: any) => { const match = searchResults[index]; if (match && currentMatch !== match) { diff --git a/x-pack/plugins/stack_alerts/public/rule_types/es_query/expression/search_source_expression_form.tsx b/x-pack/plugins/stack_alerts/public/rule_types/es_query/expression/search_source_expression_form.tsx index 2797ceaad71fe84..be4ebbbc132162f 100644 --- a/x-pack/plugins/stack_alerts/public/rule_types/es_query/expression/search_source_expression_form.tsx +++ b/x-pack/plugins/stack_alerts/public/rule_types/es_query/expression/search_source_expression_form.tsx @@ -12,7 +12,7 @@ import type { Filter, Query } from '@kbn/es-query'; import { FormattedMessage } from '@kbn/i18n-react'; import { EuiFormRow, EuiSpacer, EuiTitle } from '@elastic/eui'; import { IErrorObject } from '@kbn/triggers-actions-ui-plugin/public'; -import type { SearchBarProps } from '@kbn/unified-search-plugin/public'; +import type { SearchBarProps, StatefulSearchBarProps } from '@kbn/unified-search-plugin/public'; import type { DataView } from '@kbn/data-views-plugin/public'; import { mapAndFlattenFilters, getTime } from '@kbn/data-plugin/public'; import type { SavedQuery, ISearchSource } from '@kbn/data-plugin/public'; @@ -139,9 +139,12 @@ export const SearchSourceExpressionForm = (props: SearchSourceExpressionFormProp setEsFields(convertFieldSpecToFieldOption(newDataView.fields.map((field) => field.toSpec()))); }, []); - const onUpdateFilters = useCallback((newFilters) => { - dispatch({ type: 'filter', payload: mapAndFlattenFilters(newFilters) }); - }, []); + const onUpdateFilters = useCallback>( + (newFilters) => { + dispatch({ type: 'filter', payload: mapAndFlattenFilters(newFilters) }); + }, + [] + ); const onChangeQuery = useCallback( ({ query: newQuery }: { query?: Query }) => { diff --git a/x-pack/plugins/stack_connectors/common/openai/constants.ts b/x-pack/plugins/stack_connectors/common/openai/constants.ts index 1b1bd09618ebc12..c57720d9847af40 100644 --- a/x-pack/plugins/stack_connectors/common/openai/constants.ts +++ b/x-pack/plugins/stack_connectors/common/openai/constants.ts @@ -36,8 +36,8 @@ export const DEFAULT_OPENAI_MODEL = 'gpt-4o'; export const OPENAI_CHAT_URL = 'https://api.openai.com/v1/chat/completions' as const; export const OPENAI_LEGACY_COMPLETION_URL = 'https://api.openai.com/v1/completions' as const; export const AZURE_OPENAI_CHAT_URL = - 'https://{your-resource-name}.openai.azure.com/openai/deployments/{deployment-id}/chat/completions?api-version={api-version}' as const; + '/openai/deployments/{deployment-id}/chat/completions?api-version={api-version}' as const; export const AZURE_OPENAI_COMPLETIONS_URL = - 'https://{your-resource-name}.openai.azure.com/openai/deployments/{deployment-id}/completions?api-version={api-version}' as const; + '/openai/deployments/{deployment-id}/completions?api-version={api-version}' as const; export const AZURE_OPENAI_COMPLETIONS_EXTENSIONS_URL = - 'https://{your-resource-name}.openai.azure.com/openai/deployments/{deployment-id}/extensions/chat/completions?api-version={api-version}' as const; + '/openai/deployments/{deployment-id}/extensions/chat/completions?api-version={api-version}' as const; diff --git a/x-pack/plugins/stack_connectors/public/connector_types/bedrock/dashboard_link.tsx b/x-pack/plugins/stack_connectors/public/connector_types/bedrock/dashboard_link.tsx index e9541c3f6759cc0..9074f2ae2b6180e 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/bedrock/dashboard_link.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/bedrock/dashboard_link.tsx @@ -29,7 +29,7 @@ export const DashboardLink: React.FC = ({ }, } = useKibana(); const onClick = useCallback( - (e) => { + (e: React.SyntheticEvent) => { e.preventDefault(); if (dashboardUrl) { navigateToUrl(dashboardUrl); diff --git a/x-pack/plugins/stack_connectors/public/connector_types/cases_webhook/webhook_params.tsx b/x-pack/plugins/stack_connectors/public/connector_types/cases_webhook/webhook_params.tsx index 8e6a7c587e9cc6c..0e2491304bd9ec1 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/cases_webhook/webhook_params.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/cases_webhook/webhook_params.tsx @@ -73,7 +73,7 @@ const WebhookParamsFields: React.FunctionComponent { + (key: string, value: string) => { return editAction( 'subActionParams', { diff --git a/x-pack/plugins/stack_connectors/public/connector_types/jira/jira_params.tsx b/x-pack/plugins/stack_connectors/public/connector_types/jira/jira_params.tsx index 7ae1efbe13f381d..b5c029282b9ca11 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/jira/jira_params.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/jira/jira_params.tsx @@ -97,7 +97,7 @@ const JiraParamsFields: React.FunctionComponent { + (key: string, value: string) => { editSubActionProperty(key, [{ commentId: '1', comment: value }]); }, [editSubActionProperty] diff --git a/x-pack/plugins/stack_connectors/public/connector_types/jira/search_issues.tsx b/x-pack/plugins/stack_connectors/public/connector_types/jira/search_issues.tsx index f12a848de9a5481..35af5e6a8a0fd3d 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/jira/search_issues.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/jira/search_issues.tsx @@ -69,9 +69,11 @@ const SearchIssuesComponent: React.FC = ({ }, []); const onChangeComboBox = useCallback( - (changedOptions) => { + (changedOptions: Array>) => { setSelectedOptions(changedOptions); - onChange(changedOptions[0].value); + if (changedOptions[0].value) { + onChange(changedOptions[0].value); + } }, [onChange] ); diff --git a/x-pack/plugins/stack_connectors/public/connector_types/lib/servicenow/use_get_app_info.tsx b/x-pack/plugins/stack_connectors/public/connector_types/lib/servicenow/use_get_app_info.tsx index b0b295c9b72690b..5a619dd557fc6ca 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/lib/servicenow/use_get_app_info.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/lib/servicenow/use_get_app_info.tsx @@ -30,7 +30,7 @@ export const useGetAppInfo = ({ actionTypeId, http }: UseGetAppInfoProps): UseGe const abortCtrl = useRef(new AbortController()); const fetchAppInfo = useCallback( - async (connector) => { + async (connector: ServiceNowActionConnector) => { try { if (!actionTypeId || isEmpty(actionTypeId)) { return; diff --git a/x-pack/plugins/stack_connectors/public/connector_types/openai/dashboard_link.tsx b/x-pack/plugins/stack_connectors/public/connector_types/openai/dashboard_link.tsx index 85c1a9a1955b61c..86b5298172a843f 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/openai/dashboard_link.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/openai/dashboard_link.tsx @@ -29,7 +29,7 @@ export const DashboardLink: React.FC = ({ }, } = useKibana(); const onClick = useCallback( - (e) => { + (e: React.SyntheticEvent) => { e.preventDefault(); if (dashboardUrl) { navigateToUrl(dashboardUrl); diff --git a/x-pack/plugins/stack_connectors/public/connector_types/opsgenie/create_alert/index.tsx b/x-pack/plugins/stack_connectors/public/connector_types/opsgenie/create_alert/index.tsx index ff67e51cad8058a..5e4cb6787e391ab 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/opsgenie/create_alert/index.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/opsgenie/create_alert/index.tsx @@ -19,6 +19,7 @@ import { EuiFormRow, EuiSpacer, EuiSwitch, + EuiSwitchEvent, EuiText, } from '@elastic/eui'; import type { @@ -143,7 +144,7 @@ const CreateAlertComponent: React.FC = ({ const [showJsonEditor, setShowJsonEditor] = useState(false); const toggleShowJsonEditor = useCallback( - (event) => { + (event: EuiSwitchEvent) => { if (!event.target.checked) { // when the user switches back remove the json editor error if there was one // must mark as undefined to remove the field so it is not sent to the server side diff --git a/x-pack/plugins/stack_connectors/public/connector_types/opsgenie/params.tsx b/x-pack/plugins/stack_connectors/public/connector_types/opsgenie/params.tsx index 3ae86b1e7f9ad65..e4e288623f206e3 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/opsgenie/params.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/opsgenie/params.tsx @@ -22,6 +22,7 @@ import type { OpsgenieActionParams, OpsgenieCreateAlertSubActionParams, } from '../../../server/connector_types'; +import { EditActionCallback } from './types'; const actionOptions = [ { @@ -55,7 +56,7 @@ const OpsgenieParamFields: React.FC> = ( [editAction, index] ); - const editOptionalSubAction = useCallback( + const editOptionalSubAction: EditActionCallback = useCallback( (key, value) => { if (isEmpty(value)) { const paramsCopy = cloneDeep(subActionParams); @@ -69,7 +70,7 @@ const OpsgenieParamFields: React.FC> = ( [editAction, index, subActionParams] ); - const editSubAction = useCallback( + const editSubAction: EditActionCallback = useCallback( (key, value) => { editAction('subActionParams', { ...subActionParams, [key]: value }, index); }, diff --git a/x-pack/plugins/stack_connectors/public/connector_types/resilient/resilient_params.tsx b/x-pack/plugins/stack_connectors/public/connector_types/resilient/resilient_params.tsx index 7cba015493d3062..a1c202c36ef8acc 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/resilient/resilient_params.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/resilient/resilient_params.tsx @@ -109,7 +109,7 @@ const ResilientParamsFields: React.FunctionComponent { + (key: string, value: string) => { editSubActionProperty(key, [{ commentId: '1', comment: value }]); }, [editSubActionProperty] diff --git a/x-pack/plugins/stack_connectors/public/connector_types/servicenow_itsm/servicenow_itsm_params.tsx b/x-pack/plugins/stack_connectors/public/connector_types/servicenow_itsm/servicenow_itsm_params.tsx index 51cbd8f46fc9276..67de15909ded538 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/servicenow_itsm/servicenow_itsm_params.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/servicenow_itsm/servicenow_itsm_params.tsx @@ -167,7 +167,7 @@ const ServiceNowParamsFields: React.FunctionComponent< ); const editComment = useCallback( - (key, value) => { + (key: string, value: string) => { editSubActionProperty(key, [{ commentId: '1', comment: value }]); }, [editSubActionProperty] diff --git a/x-pack/plugins/stack_connectors/public/connector_types/servicenow_sir/servicenow_sir_params.tsx b/x-pack/plugins/stack_connectors/public/connector_types/servicenow_sir/servicenow_sir_params.tsx index 19cc8407632fcc0..c6b207c70b3c3d1 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/servicenow_sir/servicenow_sir_params.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/servicenow_sir/servicenow_sir_params.tsx @@ -77,7 +77,7 @@ const ServiceNowSIRParamsFields: React.FunctionComponent< ); const editComment = useCallback( - (key, value) => { + (key: string, value: string) => { editSubActionProperty(key, [{ commentId: '1', comment: value }]); }, [editSubActionProperty] diff --git a/x-pack/plugins/stack_connectors/public/connector_types/slack_api/slack_params.tsx b/x-pack/plugins/stack_connectors/public/connector_types/slack_api/slack_params.tsx index a41b6a6b73e01e7..5264863d6ab4e97 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/slack_api/slack_params.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/slack_api/slack_params.tsx @@ -225,7 +225,7 @@ const SlackParamsFields: React.FunctionComponent< }, [editAction, index, tempChannelId, text]); const onChangeTextField = useCallback( - (evt) => { + (evt: React.ChangeEvent) => { editAction('subActionParams', { channels: undefined, channelIds: [], text }, index); setTempChannelId(evt.target.value); }, @@ -323,7 +323,7 @@ const SlackParamsFields: React.FunctionComponent< {messageType === 'text' ? ( { + editAction={(_: string, value: string) => { setTextValue(value); editAction('subActionParams', { channels, channelIds, text: value }, index); }} diff --git a/x-pack/plugins/stack_connectors/public/connector_types/swimlane/swimlane_params.tsx b/x-pack/plugins/stack_connectors/public/connector_types/swimlane/swimlane_params.tsx index 1faa8c8bbabf48b..1f60422adbcae86 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/swimlane/swimlane_params.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/swimlane/swimlane_params.tsx @@ -78,7 +78,7 @@ const SwimlaneParamsFields: React.FunctionComponent { + (key: string, value: string) => { editSubActionProperty(key, [{ commentId: '1', comment: value }]); }, [editSubActionProperty] diff --git a/x-pack/plugins/stack_connectors/server/connector_types/openai/lib/azure_openai_utils.test.ts b/x-pack/plugins/stack_connectors/server/connector_types/openai/lib/azure_openai_utils.test.ts index e9ad87a35ab7c58..6023d7715f4ed33 100644 --- a/x-pack/plugins/stack_connectors/server/connector_types/openai/lib/azure_openai_utils.test.ts +++ b/x-pack/plugins/stack_connectors/server/connector_types/openai/lib/azure_openai_utils.test.ts @@ -146,18 +146,14 @@ describe('Azure Open AI Utils', () => { const regex = transformApiUrlToRegex(AZURE_OPENAI_CHAT_URL); const match = chatUrl.match(regex); expect(match).not.toBeNull(); - expect(match![0]).toEqual( - 'https://My-test-resource-123.openai.azure.com/openai/deployments/NEW-DEPLOYMENT-321/chat/completions' - ); + expect(match![0]).toEqual('/openai/deployments/NEW-DEPLOYMENT-321/chat/completions'); }); it('should match valid completion url', () => { const regex = transformApiUrlToRegex(AZURE_OPENAI_COMPLETIONS_URL); const match = completionUrl.match(regex); expect(match).not.toBeNull(); - expect(match![0]).toEqual( - 'https://My-test-resource-123.openai.azure.com/openai/deployments/NEW-DEPLOYMENT-321/completions' - ); + expect(match![0]).toEqual('/openai/deployments/NEW-DEPLOYMENT-321/completions'); }); it('should match valid completion extensions url', () => { @@ -165,19 +161,14 @@ describe('Azure Open AI Utils', () => { const match = completionExtensionsUrl.match(regex); expect(match).not.toBeNull(); expect(match![0]).toEqual( - 'https://My-test-resource-123.openai.azure.com/openai/deployments/NEW-DEPLOYMENT-321/extensions/chat/completions' + '/openai/deployments/NEW-DEPLOYMENT-321/extensions/chat/completions' ); }); it('should not match invalid chat url', () => { const regex = transformApiUrlToRegex(AZURE_OPENAI_CHAT_URL); [ - 'https://openai.azure.com/openai/deployments/NEW-DEPLOYMENT-321/chat/completions?api-version=2023-05-15', - 'https://My-test-resource-123.openaiazure.com/openai/deployments/NEW-DEPLOYMENT-321/chat/completions?api-version=2023-05-15', - 'https://My-test-resource-123.openaiaazure.com/openai/deployments/NEW-DEPLOYMENT-321/chat/completions?api-version=2023-05-15', - 'https://My-test-resource-123openai.azure.com/openai/deployments/NEW-DEPLOYMENT-321/chat/completions?api-version=2023-05-15', - 'https://My-test-resource-123.openai.azure.com//openai/deployments/NEW-DEPLOYMENT-321/chat/completions?api-version=2023-05-15', - 'https:///My-test-resource-123.openai.azure.com/openai/deployments/NEW-DEPLOYMENT-321/chat/completions?api-version=2023-05-15', + 'https://openai.azure.com/openai/deployments/NEW-DEPLOYMENT-321/chat/not-completions?api-version=2023-05-15', ].forEach((url) => { const match = url.match(regex); expect(match).toBeNull(); @@ -187,12 +178,7 @@ describe('Azure Open AI Utils', () => { it('should not match invalid completion url', () => { const regex = transformApiUrlToRegex(AZURE_OPENAI_COMPLETIONS_URL); [ - 'https://fooai.com/completions?api-version=2023-05-15', - 'https://My-test-resource-123.openaiazure.com/openai/deployments/NEW-DEPLOYMENT-321/completions?api-version=2023-05-15', - 'https://My-test-resource-123.openaiaazure.com/openai/deployments/NEW-DEPLOYMENT-321/completions?api-version=2023-05-15', - 'https://My-test-resource-123openai.azure.com/openai/deployments/NEW-DEPLOYMENT-321/completions?api-version=2023-05-15', - 'https://My-test-resource-123.openai.azure.com//openai/deployments/NEW-DEPLOYMENT-321/completions?api-version=2023-05-15', - 'https:///My-test-resource-123.openai.azure.com/openai/deployments/NEW-DEPLOYMENT-321/completions?api-version=2023-05-15', + 'https://My-test-resource-123.openaiazure.com/openai/deployments/NEW-DEPLOYMENT-321/not-completions?api-version=2023-05-15', ].forEach((url) => { const match = url.match(regex); expect(match).toBeNull(); @@ -202,12 +188,7 @@ describe('Azure Open AI Utils', () => { it('should not match invalid completion extensions url', () => { const regex = transformApiUrlToRegex(AZURE_OPENAI_COMPLETIONS_EXTENSIONS_URL); [ - 'https://My-test-resource-123.openai.azure.com/openai/deployments/extensions/chat/completions?api-version=2023-05-15', - 'https://My-test-resource-123.openaiazure.com/openai/deployments/NEW-DEPLOYMENT-321/extensions/chat/completions?api-version=2023-05-15', - 'https://My-test-resource-123.openaiaazure.com/openai/deployments/NEW-DEPLOYMENT-321/extensions/chat/completions?api-version=2023-05-15', - 'https://My-test-resource-123openai.azure.com/openai/deployments/NEW-DEPLOYMENT-321/extensions/chat/completions?api-version=2023-05-15', - 'https:///My-test-resource-123.openai.azure.com/openai/deployments/NEW-DEPLOYMENT-321/extensions/chat/completions?api-version=2023-05-15', - 'https://My-test-resource-123.openai.azure.com/openai//deployments/NEW-DEPLOYMENT-321/extensions/chat/completions?api-version=2023-05-15', + 'https://My-test-resource-123.openai.azure.com/openai/deployments/extensions/chat/not-completions?api-version=2023-05-15', ].forEach((url) => { const match = url.match(regex); expect(match).toBeNull(); diff --git a/x-pack/plugins/threat_intelligence/public/modules/indicators/hooks/use_indicators.ts b/x-pack/plugins/threat_intelligence/public/modules/indicators/hooks/use_indicators.ts index dd8c83fd4f249b7..d9285fac81c8105 100644 --- a/x-pack/plugins/threat_intelligence/public/modules/indicators/hooks/use_indicators.ts +++ b/x-pack/plugins/threat_intelligence/public/modules/indicators/hooks/use_indicators.ts @@ -68,7 +68,7 @@ export const useIndicators = ({ const { inspectorAdapters } = useInspector(); const onChangeItemsPerPage = useCallback( - (pageSize) => + (pageSize: any) => setPagination((currentPagination) => ({ ...currentPagination, pageSize, @@ -78,7 +78,7 @@ export const useIndicators = ({ ); const onChangePage = useCallback( - (pageIndex) => setPagination((currentPagination) => ({ ...currentPagination, pageIndex })), + (pageIndex: any) => setPagination((currentPagination) => ({ ...currentPagination, pageIndex })), [] ); diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/filter_agg/components/filter_range_form.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/filter_agg/components/filter_range_form.tsx index 1c0cb4d35030a27..ec4520ef87fd7cc 100644 --- a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/filter_agg/components/filter_range_form.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/filter_agg/components/filter_range_form.tsx @@ -31,7 +31,7 @@ export const FilterRangeForm: FilterAggConfigRange['aggTypeConfig']['FilterAggFo const includeTo = config?.includeTo ?? false; const updateConfig = useCallback( - (update) => { + (update: any) => { onChange({ config: { ...config, diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/filter_agg/components/filter_term_form.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/filter_agg/components/filter_term_form.tsx index 46ecd77961617fc..2e52eb67ac49a95 100644 --- a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/filter_agg/components/filter_term_form.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/filter_agg/components/filter_term_form.tsx @@ -51,7 +51,7 @@ export const FilterTermForm: FilterAggConfigTerm['aggTypeConfig']['FilterAggForm }, []); const updateConfig = useCallback( - (update) => { + (update: any) => { onChange({ config: { ...config, diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/hooks/use_latest_function_config.ts b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/hooks/use_latest_function_config.ts index a56191f660f42f7..72a858231c7b387 100644 --- a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/hooks/use_latest_function_config.ts +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/hooks/use_latest_function_config.ts @@ -161,7 +161,7 @@ export function useLatestFunctionConfig( }, [dataView, data.search.aggs, runtimeMappings]); const updateLatestFunctionConfig = useCallback( - (update) => + (update: any) => setLatestFunctionConfig({ ...config, ...update, diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/text_area_with_autocomplete/index.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/text_area_with_autocomplete/index.tsx index 53f0d7d500eedd2..da3b08fda8e1862 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/text_area_with_autocomplete/index.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/text_area_with_autocomplete/index.tsx @@ -172,7 +172,7 @@ export const TextAreaWithAutocomplete: React.FunctionComponent { + (event: React.KeyboardEvent) => { if (selectableRef.current && isListOpen) { if (!selectableHasFocus && (event.code === 'ArrowUp' || event.code === 'ArrowDown')) { event.preventDefault(); @@ -219,7 +219,7 @@ export const TextAreaWithAutocomplete: React.FunctionComponent { + (event: any) => { const box = document .querySelector('.euiSelectableMsgAutoComplete') ?.getBoundingClientRect() || { @@ -292,7 +292,7 @@ export const TextAreaWithAutocomplete: React.FunctionComponent closeList(), [closeList]); const onScroll = useCallback( - (evt) => { + (evt: any) => { // FUTURE ENGINEER -> we need to make sure to not close the autocomplete option list if (selectableRef?.current?.listId !== evt.target?.firstElementChild?.id) { closeList(true); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_alerts_filter_query.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_alerts_filter_query.tsx index bbaf737101910e8..683bf2943266874 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_alerts_filter_query.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_alerts_filter_query.tsx @@ -12,7 +12,7 @@ import { i18n } from '@kbn/i18n'; import { EuiSwitch, EuiSpacer } from '@elastic/eui'; import { AlertsFilter } from '@kbn/alerting-plugin/common'; import deepEqual from 'fast-deep-equal'; -import { AlertsSearchBar } from '../alerts_search_bar'; +import { AlertsSearchBar, AlertsSearchBarProps } from '../alerts_search_bar'; interface ActionAlertsFilterQueryProps { state?: AlertsFilter['query']; @@ -52,7 +52,7 @@ export const ActionAlertsFilterQuery: React.FC = ( [query, setQuery] ); - const onQueryChange = useCallback( + const onQueryChange: AlertsSearchBarProps['onQueryChange'] = useCallback( ({ query: newQuery }) => updateQuery({ kql: newQuery }), [updateQuery] ); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_form.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_form.tsx index 7d34fb42409d005..1a55e2990fbf74e 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_form.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_form.tsx @@ -376,7 +376,7 @@ export const ActionTypeForm = ({ throttleUnit={actionThrottleUnit} hasAlertsMappings={hasAlertsMappings} onNotifyWhenChange={useCallback( - (notifyWhen) => { + (notifyWhen: RuleNotifyWhenType) => { setActionFrequencyProperty('notifyWhen', notifyWhen, index); }, [setActionFrequencyProperty, index] diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_event_log_list_table.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_event_log_list_table.tsx index 9cd6305b81e796e..ce977ea349cbe62 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_event_log_list_table.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_event_log_list_table.tsx @@ -262,7 +262,7 @@ export const ConnectorEventLogListTable = { + (e: React.ChangeEvent) => { if (e.target.value === '') { setSearchText(''); } @@ -272,7 +272,7 @@ export const ConnectorEventLogListTable = { + (e: React.KeyboardEvent) => { if (e.key === 'Enter') { setSearchText(search); } diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_pagination.ts b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_pagination.ts index bc0c14772b5759f..61fda55c4eb3ae5 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_pagination.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_pagination.ts @@ -32,7 +32,7 @@ export function usePagination({ onPageChange, pageIndex, pageSize }: PaginationP }); const [flyoutAlertIndex, setFlyoutAlertIndex] = useState(-1); const onChangePageSize = useCallback( - (_pageSize) => { + (_pageSize: number) => { setPagination((state) => ({ ...state, pageSize: _pageSize, @@ -44,7 +44,7 @@ export function usePagination({ onPageChange, pageIndex, pageSize }: PaginationP [updateBulkActionsState, onPageChange] ); const onChangePageIndex = useCallback( - (_pageIndex) => { + (_pageIndex: number) => { setPagination((state) => ({ ...state, pageIndex: _pageIndex })); updateBulkActionsState({ action: BulkActionsVerbs.clear }); onPageChange({ pageIndex: _pageIndex, pageSize: pagination.pageSize }); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/execution_duration_chart.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/execution_duration_chart.tsx index 4999496f669c306..c8afbb76f591091 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/execution_duration_chart.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/execution_duration_chart.tsx @@ -65,7 +65,7 @@ export const ExecutionDurationChart: React.FunctionComponent = ({ numberOfExecutions ); - const onChange = useCallback( + const onChange: React.ChangeEventHandler = useCallback( ({ target }) => onChangeDuration(Number(target.value)), [onChangeDuration] ); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/field_browser/components/field_table/field_table.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/field_browser/components/field_table/field_table.tsx index c5bf6647763010b..7647e8c62576176 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/field_browser/components/field_table/field_table.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/field_browser/components/field_table/field_table.tsx @@ -5,18 +5,24 @@ * 2.0. */ import React, { useCallback, useEffect, useMemo, useState } from 'react'; -import { EuiInMemoryTable, Pagination, Direction, useEuiTheme } from '@elastic/eui'; +import { + EuiInMemoryTable, + Pagination, + Direction, + useEuiTheme, + CriteriaWithPagination, +} from '@elastic/eui'; import { BrowserFields } from '@kbn/rule-registry-plugin/common'; import { getFieldColumns, getFieldItemsData } from '../field_items'; import { CATEGORY_TABLE_CLASS_NAME, TABLE_HEIGHT } from '../../helpers'; -import type { FieldBrowserProps, GetFieldTableColumns } from '../../types'; +import type { BrowserFieldItem, FieldBrowserProps, GetFieldTableColumns } from '../../types'; import { FieldTableHeader } from './field_table_header'; import { styles } from './field_table.styles'; -const DEFAULT_SORTING: { field: string; direction: Direction } = { - field: '', +const DEFAULT_SORTING: { field: keyof BrowserFieldItem; direction: Direction } = { + field: 'name', direction: 'asc', -} as const; +}; export interface FieldTableProps extends Pick { /** @@ -104,16 +110,19 @@ const FieldTableComponent: React.FC = ({ [sortDirection, sortField] ); - const onTableChange = useCallback(({ page, sort = DEFAULT_SORTING }) => { - const { index, size } = page; - const { field, direction } = sort; + const onTableChange = useCallback( + ({ page, sort = DEFAULT_SORTING }: CriteriaWithPagination) => { + const { index, size } = page; + const { field, direction } = sort; - setPageIndex(index); - setPageSize(size); + setPageIndex(index); + setPageSize(size); - setSortField(field); - setSortDirection(direction); - }, []); + setSortField(field); + setSortDirection(direction); + }, + [] + ); /** * Process columns diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_error_log.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_error_log.tsx index 2d33a205e6e36ce..34993d085425e8f 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_error_log.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_error_log.tsx @@ -171,7 +171,7 @@ export const RuleErrorLog = (props: RuleErrorLogProps) => { ); const onSearchChange = useCallback( - (e) => { + (e: React.ChangeEvent) => { if (e.target.value === '') { setSearchText(''); } @@ -181,7 +181,7 @@ export const RuleErrorLog = (props: RuleErrorLogProps) => { ); const onKeyUp = useCallback( - (e) => { + (e: React.KeyboardEvent) => { if (e.key === 'Enter') { setSearchText(search); } diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_event_log_list_table.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_event_log_list_table.tsx index 0aacada7e810ca2..bcaba9f511c6e0a 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_event_log_list_table.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_event_log_list_table.tsx @@ -46,7 +46,10 @@ import { RulesListDocLink } from '../../rules_list/components/rules_list_doc_lin import { LoadExecutionLogAggregationsProps } from '../../../lib/rule_api'; import { RuleEventLogListKPIWithApi as RuleEventLogListKPI } from './rule_event_log_list_kpi'; import { useMultipleSpaces } from '../../../hooks/use_multiple_spaces'; -import { useLoadRuleEventLogs } from '../../../hooks/use_load_rule_event_logs'; +import { + useLoadRuleEventLogs, + UseLoadRuleEventLogsProps, +} from '../../../hooks/use_load_rule_event_logs'; import { RulesSettingsLink } from '../../../components/rules_setting/rules_settings_link'; import { RefreshToken } from './types'; @@ -196,7 +199,7 @@ export const RuleEventLogListTable = ( // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - const onError = useCallback( + const onError = useCallback>( (e) => { if (e.body.statusCode === 413) { return; @@ -309,7 +312,7 @@ export const RuleEventLogListTable = ( }, []); const onSearchChange = useCallback( - (e) => { + (e: React.ChangeEvent) => { if (e.target.value === '') { setSearchText(''); } @@ -319,7 +322,7 @@ export const RuleEventLogListTable = ( ); const onKeyUp = useCallback( - (e) => { + (e: React.KeyboardEvent) => { if (e.key === 'Enter') { setSearchText(search); } diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_status_panel.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_status_panel.tsx index 2419993f1267019..0e07b73b56c4ed1 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_status_panel.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_status_panel.tsx @@ -20,6 +20,7 @@ import { EuiTitle, EuiHorizontalRule, } from '@elastic/eui'; +import { SnoozeSchedule } from '../../../../types'; import { RuleStatusDropdown } from '../..'; import { ComponentOpts as RuleApis, @@ -60,11 +61,11 @@ export const RuleStatusPanel: React.FC = ({ const isInitialized = useRef(false); const onSnoozeRule = useCallback( - (snoozeSchedule) => snoozeRule(rule, snoozeSchedule), + (snoozeSchedule: SnoozeSchedule) => snoozeRule(rule, snoozeSchedule), [rule, snoozeRule] ); const onUnsnoozeRule = useCallback( - (scheduleIds) => unsnoozeRule(rule, scheduleIds), + (scheduleIds?: string[]) => unsnoozeRule(rule, scheduleIds), [rule, unsnoozeRule] ); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_add.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_add.tsx index e3d564afaeda827..8657248a29df39a 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_add.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_add.tsx @@ -78,7 +78,7 @@ const RuleAdd = < }: RuleAddProps) => { const onSaveHandler = onSave ?? reloadRules; const [metadata, setMetadata] = useState(initialMetadata); - const onChangeMetaData = useCallback((newMetadata) => setMetadata(newMetadata), []); + const onChangeMetaData = useCallback((newMetadata: any) => setMetadata(newMetadata), []); const initialRule: InitialRule = useMemo(() => { return { diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_edit.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_edit.tsx index 9c0abae3eb2a3b8..72eab243ad0c83f 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_edit.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_edit.tsx @@ -137,7 +137,7 @@ export const RuleEdit = < const [config, setConfig] = useState({ isUsingSecurity: false }); const [metadata, setMetadata] = useState(initialMetadata); - const onChangeMetaData = useCallback((newMetadata) => setMetadata(newMetadata), []); + const onChangeMetaData = useCallback((newMetadata: any) => setMetadata(newMetadata), []); const { http, diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_snooze/helpers/number_field.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_snooze/helpers/number_field.tsx index 2483f6fc4a43c84..3f4be5cde90c8d5 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_snooze/helpers/number_field.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_snooze/helpers/number_field.tsx @@ -18,9 +18,12 @@ export const NumberField: React.FC< const max = typeof props.max !== 'undefined' ? props.max : Infinity; const onChange = useCallback( - (e) => { + (e: React.ChangeEvent) => { const { value } = e.target; - const isValid = !isNaN(Number(value)) && value >= min && value <= max; + const valueAsNumber = Number(value); + + const isValid = !isNaN(valueAsNumber) && valueAsNumber >= min && valueAsNumber <= max; + if (isValid || value === '') { setDisplayValue(value); } @@ -32,7 +35,7 @@ export const NumberField: React.FC< ); const onBlur = useCallback( - (e) => { + (e: React.FocusEvent) => { if (isNaN(Number(displayValue)) || displayValue === '') { setDisplayValue(props.value); } diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_snooze/panel/base_snooze_panel.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_snooze/panel/base_snooze_panel.tsx index 40d705e87816548..3d6523a144e99eb 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_snooze/panel/base_snooze_panel.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_snooze/panel/base_snooze_panel.tsx @@ -77,11 +77,18 @@ export const BaseSnoozePanel: React.FunctionComponent = ({ const { euiTheme } = useEuiTheme(); - const onChangeValue = useCallback( - ({ target }) => setIntervalValue(target.value), + const onChangeValue: React.ChangeEventHandler = useCallback( + ({ target }) => { + const value = Number(target.value); + + if (!isNaN(value)) { + setIntervalValue(value); + } + }, [setIntervalValue] ); - const onChangeUnit = useCallback( + + const onChangeUnit: React.ChangeEventHandler = useCallback( ({ target }) => setIntervalUnit(target.value), [setIntervalUnit] ); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_snooze/scheduler.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_snooze/scheduler.tsx index 97c8065c18f2183..4e17bca05e4e036 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_snooze/scheduler.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_snooze/scheduler.tsx @@ -196,7 +196,7 @@ const RuleSnoozeSchedulerPanel: React.FunctionComponent = ({ }, [setSelectingEndDate]); const selectStartDT = useCallback( - (date, clearEndDT) => { + (date: Moment, clearEndDT: boolean) => { setStartDT(moment.max(date, minDate)); if (clearEndDT) { setEndDT(null); @@ -207,7 +207,7 @@ const RuleSnoozeSchedulerPanel: React.FunctionComponent = ({ [setStartDT, setSelectingEndDate, minDate] ); const selectEndDT = useCallback( - (date) => { + (date: Moment) => { setEndDT(date.add(1, 'minutes')); setSelectingEndTime(true); setSelectingEndDate(false); @@ -216,7 +216,7 @@ const RuleSnoozeSchedulerPanel: React.FunctionComponent = ({ ); const onSelectFromInline = useCallback( - (date) => { + (date: Moment) => { const dateAsMoment = moment(date); const newDateAfterStart = !startDT || dateAsMoment.isSameOrAfter(startDT); const isEndDateTimeChange = @@ -228,6 +228,7 @@ const RuleSnoozeSchedulerPanel: React.FunctionComponent = ({ const applyToEndDate = !isStartDateTimeChange && (selectingEndDate || (isEndDateTimeChange && selectingEndTime)); + if (applyToEndDate && newDateAfterStart) { selectEndDT(date); } else selectStartDT(date, !isStartDateTimeChange); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_status_dropdown.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_status_dropdown.tsx index ddd836a4f0993fa..6ad7d525c350718 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_status_dropdown.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_status_dropdown.tsx @@ -147,7 +147,7 @@ export const RuleStatusDropdown: React.FunctionComponent = ({ ); const onSnoozeRule = useCallback( - async (snoozeSchedule) => { + async (snoozeSchedule: SnoozeSchedule) => { try { await snoozeRule(snoozeSchedule); onRuleChanged(); @@ -159,7 +159,7 @@ export const RuleStatusDropdown: React.FunctionComponent = ({ ); const onUnsnoozeRule = useCallback( - async (scheduleIds) => { + async (scheduleIds?: string[]) => { try { await unsnoozeRule(scheduleIds); onRuleChanged(); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list_auto_refresh.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list_auto_refresh.tsx index 42c59667e0e393a..3b5dff705255920 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list_auto_refresh.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list_auto_refresh.tsx @@ -9,6 +9,7 @@ import { i18n } from '@kbn/i18n'; import React, { useCallback, useEffect, useState, useRef } from 'react'; import moment from 'moment'; import { EuiFlexGroup, EuiFlexItem, EuiText, EuiAutoRefreshButton } from '@elastic/eui'; +import { OnRefreshChangeProps } from '@elastic/eui/src/components/date_picker/types'; interface RulesListAutoRefreshProps { lastUpdate: string; @@ -95,7 +96,7 @@ export const RulesListAutoRefresh = (props: RulesListAutoRefreshProps) => { }, [isPaused, refreshInterval]); const onRefreshChange = useCallback( - ({ isPaused: newIsPaused, refreshInterval: newRefreshInterval }) => { + ({ isPaused: newIsPaused, refreshInterval: newRefreshInterval }: OnRefreshChangeProps) => { setIsPaused(newIsPaused); setRefreshInterval(newRefreshInterval); }, diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/es_deprecations_table.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/es_deprecations_table.tsx index 4a617ba61097e34..7d527c27d830367 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/es_deprecations_table.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/es_deprecations_table.tsx @@ -205,7 +205,7 @@ export const EsDeprecationsTable: React.FunctionComponent = ({ [sortConfig] ); - const handleSearch = useCallback(({ query, error }) => { + const handleSearch = useCallback(({ query, error }: any) => { if (error) { setSearchError(error); } else { diff --git a/x-pack/test/security_solution_cypress/cypress/tasks/fields_browser.ts b/x-pack/test/security_solution_cypress/cypress/tasks/fields_browser.ts index f9e83fb449b773f..c05bfbc6d281bfe 100644 --- a/x-pack/test/security_solution_cypress/cypress/tasks/fields_browser.ts +++ b/x-pack/test/security_solution_cypress/cypress/tasks/fields_browser.ts @@ -75,6 +75,8 @@ export const toggleCategory = (category: string) => { }; export const removesMessageField = () => { + cy.get(FIELDS_BROWSER_FILTER_INPUT).clear(); + cy.get(FIELDS_BROWSER_FILTER_INPUT).type('message'); cy.get(FIELDS_BROWSER_MESSAGE_CHECKBOX).uncheck(); }; diff --git a/x-pack/test/security_solution_cypress/cypress/tasks/rule_snoozing.ts b/x-pack/test/security_solution_cypress/cypress/tasks/rule_snoozing.ts index 33ade4482951aa5..9c1f5d45fe07265 100644 --- a/x-pack/test/security_solution_cypress/cypress/tasks/rule_snoozing.ts +++ b/x-pack/test/security_solution_cypress/cypress/tasks/rule_snoozing.ts @@ -119,8 +119,7 @@ function snoozeRuleInOpenPopover(duration: SnoozeDuration): void { cy.log(`Snooze a rule for ${value} ${units}`); - cy.get(SNOOZE_POPOVER_INTERVAL_VALUE_INPUT).clear(); - cy.get(SNOOZE_POPOVER_INTERVAL_VALUE_INPUT).type(value.toString()); + cy.get(SNOOZE_POPOVER_INTERVAL_VALUE_INPUT).type(`{selectAll}${value.toString()}`); cy.get(SNOOZE_POPOVER_INTERVAL_UNIT_INPUT).select(units); cy.get(SNOOZE_POPOVER_APPLY_BUTTON).click(); }