Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
oatkiller committed Aug 11, 2020
1 parent 998a664 commit 47f0cff
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions x-pack/plugins/security_solution/public/resolver/view/submenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
* you may not use this file except in compliance with the Elastic License.
*/

/* eslint-disable no-duplicate-imports */

/* eslint-disable react/display-name */

import { i18n } from '@kbn/i18n';
import React, { ReactNode, useState, useMemo, useCallback, useRef, useLayoutEffect } from 'react';
import React, { useState, useMemo, useCallback, useRef, useLayoutEffect } from 'react';
import {
EuiI18nNumber,
EuiSelectable,
Expand All @@ -17,6 +19,7 @@ import {
htmlIdGenerator,
} from '@elastic/eui';
import styled from 'styled-components';
import { EuiSelectableOption } from '@elastic/eui';
import { Matrix3 } from '../types';

/**
Expand Down Expand Up @@ -61,22 +64,19 @@ const OptionList = React.memo(
subMenuOptions: ResolverSubmenuOptionList;
isLoading: boolean;
}) => {
const [options, setOptions] = useState(() =>
const [options, setOptions] = useState<EuiSelectableOption[]>(() =>
typeof subMenuOptions !== 'object'
? []
: subMenuOptions.map((opt: ResolverSubmenuOption): {
label: string;
prepend?: ReactNode;
} => {
: subMenuOptions.map((option: ResolverSubmenuOption) => {
const dataTestSubj = 'resolver:map:node-submenu-item';
return opt.prefix
return option.prefix
? {
label: opt.optionTitle,
prepend: <span>{opt.prefix} </span>,
label: option.optionTitle,
prepend: <span>{option.prefix} </span>,
'data-test-subj': dataTestSubj,
}
: {
label: opt.optionTitle,
label: option.optionTitle,
prepend: <span />,
'data-test-subj': dataTestSubj,
};
Expand All @@ -93,11 +93,10 @@ const OptionList = React.memo(
}, {});
}, [subMenuOptions]);

type ChangeOptions = Array<{ label: string; prepend?: ReactNode; checked?: string }>;
const selectableProps = useMemo(() => {
return {
listProps: { showIcons: true, bordered: true },
onChange: (newOptions: ChangeOptions) => {
onChange: (newOptions: EuiSelectableOption[]) => {
const selectedOption = newOptions.find((opt) => opt.checked === 'on');
if (selectedOption) {
const { label } = selectedOption;
Expand Down

0 comments on commit 47f0cff

Please sign in to comment.