diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/discover_index_pattern.tsx b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/discover_index_pattern.tsx index bc028d7999915c..ef59e8a74f8d31 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/discover_index_pattern.tsx +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/discover_index_pattern.tsx @@ -37,17 +37,6 @@ export interface DiscoverIndexPatternProps { setIndexPattern: (id: string) => void; } -/** - * At initial rendering the angular directive the selectedIndexPattern prop is undefined - * this wrapper component should be removed once all is deangularized - */ -export function DiscoverIndexPatternWrapper(props: DiscoverIndexPatternProps) { - if (!props.selectedIndexPattern || !Array.isArray(props.indexPatternList)) { - return null; - } - return ; -} - /** * Component allows you to select an index pattern in discovers side bar */ @@ -60,12 +49,15 @@ export function DiscoverIndexPattern({ id: entity.id, title: entity.attributes!.title, })); - const { id: selectedId, attributes } = selectedIndexPattern; + const { id: selectedId, attributes } = selectedIndexPattern || {}; const [selected, setSelected] = useState({ id: selectedId, title: attributes ? attributes.title : '', }); + if (!selectedId) { + return null; + } return (
diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/discover_index_pattern_directive.ts b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/discover_index_pattern_directive.tsx similarity index 69% rename from src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/discover_index_pattern_directive.ts rename to src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/discover_index_pattern_directive.tsx index e22f4973ac8dd6..d6527b0d7beedf 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/discover_index_pattern_directive.ts +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/discover_index_pattern_directive.tsx @@ -16,8 +16,20 @@ * specific language governing permissions and limitations * under the License. */ +import React from 'react'; import { wrapInI18nContext } from '../../../kibana_services'; -import { DiscoverIndexPatternWrapper } from './discover_index_pattern'; +import { DiscoverIndexPattern, DiscoverIndexPatternProps } from './discover_index_pattern'; + +/** + * At initial rendering the angular directive the selectedIndexPattern prop is undefined + * This wrapper catches this, had to be introduced to satisfy eslint + */ +export function DiscoverIndexPatternWrapper(props: DiscoverIndexPatternProps) { + if (!props.selectedIndexPattern || !Array.isArray(props.indexPatternList)) { + return null; + } + return ; +} export function createIndexPatternSelectDirective(reactDirective: any) { return reactDirective(wrapInI18nContext(DiscoverIndexPatternWrapper), [