diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/__jest__/__snapshots__/create_index_pattern_wizard.test.js.snap b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.js.snap similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/__jest__/__snapshots__/create_index_pattern_wizard.test.js.snap rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.js.snap diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/empty_state/__jest__/__snapshots__/empty_state.test.js.snap b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/empty_state/__snapshots__/empty_state.test.tsx.snap similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/empty_state/__jest__/__snapshots__/empty_state.test.js.snap rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/empty_state/__snapshots__/empty_state.test.tsx.snap diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/empty_state/__jest__/empty_state.test.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/empty_state/empty_state.test.tsx similarity index 84% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/empty_state/__jest__/empty_state.test.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/empty_state/empty_state.test.tsx index 92b54a4000e46..5b1f9f546e250 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/empty_state/__jest__/empty_state.test.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/empty_state/empty_state.test.tsx @@ -24,9 +24,7 @@ import sinon from 'sinon'; describe('EmptyState', () => { it('should render normally', () => { - const component = shallow( - {}} /> - ); + const component = shallow( {}} />); expect(component).toMatchSnapshot(); }); @@ -36,9 +34,7 @@ describe('EmptyState', () => { it('is called when refresh button is clicked', () => { const onRefreshHandler = sinon.stub(); - const component = shallow( - - ); + const component = shallow(); component.find('[data-test-subj="refreshIndicesButton"]').simulate('click'); diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/empty_state/empty_state.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/empty_state/empty_state.tsx similarity index 94% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/empty_state/empty_state.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/empty_state/empty_state.tsx index 1f81fb7361686..676f4d38f409b 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/empty_state/empty_state.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/empty_state/empty_state.tsx @@ -18,13 +18,12 @@ */ import React from 'react'; -import PropTypes from 'prop-types'; import { EuiCallOut, EuiTextColor, EuiLink, EuiButton } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -export const EmptyState = ({ onRefresh }) => ( +export const EmptyState = ({ onRefresh }: { onRefresh: () => void }) => (
(
); - -EmptyState.propTypes = { - onRefresh: PropTypes.func.isRequired, -}; diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/empty_state/index.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/empty_state/index.ts similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/empty_state/index.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/empty_state/index.ts diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/header/__jest__/__snapshots__/header.test.js.snap b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/header/__snapshots__/header.test.tsx.snap similarity index 96% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/header/__jest__/__snapshots__/header.test.js.snap rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/header/__snapshots__/header.test.tsx.snap index a4998fc975372..a6b22ebf32a43 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/header/__jest__/__snapshots__/header.test.js.snap +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/header/__snapshots__/header.test.tsx.snap @@ -64,7 +64,7 @@ exports[`Header should render normally 1`] = ` id="kbn.management.createIndexPatternHeader" values={ Object { - "indexPatternName": undefined, + "indexPatternName": "test index pattern", } } /> @@ -109,7 +109,7 @@ exports[`Header should render without including system indices 1`] = ` id="kbn.management.createIndexPatternHeader" values={ Object { - "indexPatternName": undefined, + "indexPatternName": "test index pattern", } } /> diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/header/__jest__/header.test.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/header/header.test.tsx similarity index 79% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/header/__jest__/header.test.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/header/header.test.tsx index c7cb3d4631b94..06b8b38e2d8bc 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/header/__jest__/header.test.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/header/header.test.tsx @@ -22,9 +22,14 @@ import { Header } from '../header'; import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; describe('Header', () => { + const indexPatternName = 'test index pattern'; it('should render normally', () => { const component = shallowWithI18nProvider( -
{}} /> +
{}} + /> ); expect(component).toMatchSnapshot(); @@ -32,7 +37,11 @@ describe('Header', () => { it('should render without including system indices', () => { const component = shallowWithI18nProvider( -
{}} /> +
{}} + /> ); expect(component).toMatchSnapshot(); @@ -44,7 +53,7 @@ describe('Header', () => { isIncludingSystemIndices={false} onChangeIncludingSystemIndices={() => {}} prompt={
Test prompt
} - indexPatternName="test index pattern" + indexPatternName={indexPatternName} isBeta={true} /> ); diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/header/header.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/header/header.tsx similarity index 92% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/header/header.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/header/header.tsx index 3352996368669..928c1ef2b6299 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/header/header.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/header/header.tsx @@ -36,10 +36,17 @@ import { FormattedMessage } from '@kbn/i18n/react'; export const Header = ({ prompt, indexPatternName, - showSystemIndices, + showSystemIndices = false, isIncludingSystemIndices, onChangeIncludingSystemIndices, - isBeta, + isBeta = false, +}: { + prompt?: React.ReactNode; + indexPatternName: string; + showSystemIndices?: boolean; + isIncludingSystemIndices: boolean; + onChangeIncludingSystemIndices: () => void; + isBeta?: boolean; }) => (
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/header/index.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/header/index.ts similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/header/index.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/header/index.ts diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/loading_state/__jest__/__snapshots__/loading_state.test.js.snap b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/loading_state/__snapshots__/loading_state.test.tsx.snap similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/loading_state/__jest__/__snapshots__/loading_state.test.js.snap rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/loading_state/__snapshots__/loading_state.test.tsx.snap diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/loading_state/index.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/loading_state/index.ts similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/loading_state/index.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/loading_state/index.ts diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/loading_state/__jest__/loading_state.test.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/loading_state/loading_state.test.tsx similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/loading_state/__jest__/loading_state.test.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/loading_state/loading_state.test.tsx diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/loading_state/loading_state.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/loading_state/loading_state.tsx similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/loading_state/loading_state.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/loading_state/loading_state.tsx diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/__jest__/__snapshots__/step_index_pattern.test.js.snap b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/__snapshots__/step_index_pattern.test.tsx.snap similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/__jest__/__snapshots__/step_index_pattern.test.js.snap rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/__snapshots__/step_index_pattern.test.tsx.snap diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/header/__jest__/__snapshots__/header.test.js.snap b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/header/__snapshots__/header.test.tsx.snap similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/header/__jest__/__snapshots__/header.test.js.snap rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/header/__snapshots__/header.test.tsx.snap diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/header/__jest__/header.test.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/header/header.test.tsx similarity index 96% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/header/__jest__/header.test.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/header/header.test.tsx index 534c46ab73ded..f56340d0009be 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/header/__jest__/header.test.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/header/header.test.tsx @@ -27,7 +27,7 @@ describe('Header', () => {
{}} goToNextStep={() => {}} @@ -43,7 +43,7 @@ describe('Header', () => {
{}} goToNextStep={() => {}} diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/header/header.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx similarity index 92% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/header/header.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx index 8fc039fc4b2cc..f9d86d5d9d53d 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/header/header.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx @@ -33,7 +33,17 @@ import { import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -export const Header = ({ +interface HeaderProps { + isInputInvalid: boolean; + errors: any; + characterList: string; + query: string; + onQueryChanged: (e: React.ChangeEvent) => void; + goToNextStep: (query: string) => void; + isNextStepDisabled: boolean; +} + +export const Header: React.FC = ({ isInputInvalid, errors, characterList, diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/header/index.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/header/index.ts similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/header/index.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/header/index.ts diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/__jest__/__snapshots__/indices_list.test.js.snap b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/__snapshots__/indices_list.test.tsx.snap similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/__jest__/__snapshots__/indices_list.test.js.snap rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/__snapshots__/indices_list.test.tsx.snap diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/index.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/index.ts similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/index.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/index.ts diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/__jest__/indices_list.test.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.test.tsx similarity index 95% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/__jest__/indices_list.test.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.test.tsx index 00ae40c9d513b..d8a1d1a0ab72f 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/__jest__/indices_list.test.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.test.tsx @@ -36,7 +36,7 @@ describe('IndicesList', () => { it('should change pages', () => { const component = shallow(); - const instance = component.instance(); + const instance = component.instance() as IndicesList; component.setState({ perPage: 1 }); instance.onChangePage(1); @@ -48,7 +48,7 @@ describe('IndicesList', () => { it('should change per page', () => { const component = shallow(); - const instance = component.instance(); + const instance = component.instance() as IndicesList; instance.onChangePerPage(1); component.update(); diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.tsx similarity index 87% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.tsx index 6ac086842f246..921a5692d00aa 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.tsx @@ -17,9 +17,7 @@ * under the License. */ -import React, { Component } from 'react'; -import PropTypes from 'prop-types'; -import { PER_PAGE_INCREMENTS } from '../../../../constants'; +import React from 'react'; import { EuiBadge, @@ -37,17 +35,26 @@ import { EuiPopover, } from '@elastic/eui'; -import { Pager } from '@elastic/eui/lib/services'; +import { Pager } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; +import { PER_PAGE_INCREMENTS } from '../../../../constants'; +import { MatchedIndex, Tag } from '../../../../types'; -export class IndicesList extends Component { - static propTypes = { - indices: PropTypes.array.isRequired, - query: PropTypes.string.isRequired, - }; +interface IndicesListProps { + indices: MatchedIndex[]; + query: string; +} + +interface IndicesListState { + page: number; + perPage: number; + isPerPageControlOpen: boolean; +} - constructor(props) { +export class IndicesList extends React.Component { + pager: Pager; + constructor(props: IndicesListProps) { super(props); this.state = { @@ -59,7 +66,7 @@ export class IndicesList extends Component { this.pager = new Pager(props.indices.length, this.state.perPage, this.state.page); } - UNSAFE_componentWillReceiveProps(nextProps) { + UNSAFE_componentWillReceiveProps(nextProps: IndicesListProps) { if (nextProps.indices.length !== this.props.indices.length) { this.pager.setTotalItems(nextProps.indices.length); this.resetPageTo0(); @@ -68,12 +75,12 @@ export class IndicesList extends Component { resetPageTo0 = () => this.onChangePage(0); - onChangePage = page => { + onChangePage = (page: number) => { this.pager.goToPageIndex(page); this.setState({ page }); }; - onChangePerPage = perPage => { + onChangePerPage = (perPage: number) => { this.pager.setItemsPerPage(perPage); this.setState({ perPage }); this.resetPageTo0(); @@ -147,7 +154,7 @@ export class IndicesList extends Component { ); } - highlightIndexName(indexName, query) { + highlightIndexName(indexName: string, query: string) { const queryIdx = indexName.indexOf(query); if (!query || queryIdx === -1) { return indexName; @@ -178,7 +185,7 @@ export class IndicesList extends Component { {this.highlightIndexName(index.name, queryWithoutWildcard)} - {index.tags.map(tag => { + {index.tags.map((tag: Tag) => { return ( {tag.name} diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/__jest__/__snapshots__/loading_indices.test.js.snap b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/__snapshots__/loading_indices.test.tsx.snap similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/__jest__/__snapshots__/loading_indices.test.js.snap rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/__snapshots__/loading_indices.test.tsx.snap diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/index.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/index.ts similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/index.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/index.ts diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/__jest__/loading_indices.test.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/loading_indices.test.tsx similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/__jest__/loading_indices.test.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/loading_indices.test.tsx diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/loading_indices.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/loading_indices.tsx similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/loading_indices.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/loading_indices.tsx diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__jest__/__snapshots__/status_message.test.js.snap b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__snapshots__/status_message.test.tsx.snap similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__jest__/__snapshots__/status_message.test.js.snap rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__snapshots__/status_message.test.tsx.snap diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/index.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/index.ts similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/index.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/index.ts diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__jest__/status_message.test.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.test.tsx similarity index 53% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__jest__/status_message.test.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.test.tsx index 301b230b71494..899c21d59c5bc 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__jest__/status_message.test.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.test.tsx @@ -21,15 +21,29 @@ import React from 'react'; import { StatusMessage } from '../status_message'; import { shallow } from 'enzyme'; +const tagsPartial = { + tags: [], +}; + const matchedIndices = { - allIndices: [{ name: 'kibana' }, { name: 'es' }], + allIndices: [ + { name: 'kibana', ...tagsPartial }, + { name: 'es', ...tagsPartial }, + ], exactMatchedIndices: [], - partialMatchedIndices: [{ name: 'kibana' }], + partialMatchedIndices: [{ name: 'kibana', ...tagsPartial }], }; describe('StatusMessage', () => { it('should render without a query', () => { - const component = shallow(); + const component = shallow( + + ); expect(component).toMatchSnapshot(); }); @@ -37,16 +51,30 @@ describe('StatusMessage', () => { it('should render with exact matches', () => { const localMatchedIndices = { ...matchedIndices, - exactMatchedIndices: [{ name: 'kibana' }], + exactMatchedIndices: [{ name: 'kibana', ...tagsPartial }], }; - const component = shallow(); + const component = shallow( + + ); expect(component).toMatchSnapshot(); }); it('should render with partial matches', () => { - const component = shallow(); + const component = shallow( + + ); expect(component).toMatchSnapshot(); }); @@ -57,14 +85,30 @@ describe('StatusMessage', () => { partialMatchedIndices: [], }; - const component = shallow(); + const component = shallow( + + ); expect(component).toMatchSnapshot(); }); it('should show that system indices exist', () => { const component = shallow( - + ); expect(component).toMatchSnapshot(); @@ -72,7 +116,16 @@ describe('StatusMessage', () => { it('should show that no indices exist', () => { const component = shallow( - + ); expect(component).toMatchSnapshot(); diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx similarity index 91% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx index f78bedf988cd7..ad7f58fa4e879 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx @@ -22,16 +22,28 @@ import React from 'react'; import { EuiText, EuiTextColor, EuiIcon } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; +import { MatchedIndex } from '../../../../types'; -export const StatusMessage = ({ +interface StatusMessageProps { + matchedIndices: { + allIndices: MatchedIndex[]; + exactMatchedIndices: MatchedIndex[]; + partialMatchedIndices: MatchedIndex[]; + }; + isIncludingSystemIndices: boolean; + query: string; + showSystemIndices: boolean; +} + +export const StatusMessage: React.FC = ({ matchedIndices: { allIndices = [], exactMatchedIndices = [], partialMatchedIndices = [] }, isIncludingSystemIndices, query, - showSystemIndicies, + showSystemIndices, }) => { let statusIcon; let statusMessage; - let statusColor; + let statusColor: 'default' | 'secondary' | undefined; const allIndicesLength = allIndices.length; @@ -49,7 +61,7 @@ export const StatusMessage = ({ /> ); - } else if (!isIncludingSystemIndices && showSystemIndicies) { + } else if (!isIncludingSystemIndices && showSystemIndices) { statusMessage = ( ({ - ensureMinimumTime: async promises => +import { Header } from './components/header'; +import { IndexPatternCreationConfig } from '../../../../../../../../management/public'; +import { coreMock } from '../../../../../../../../../../core/public/mocks'; +import { dataPluginMock } from '../../../../../../../../../../plugins/data/public/mocks'; +import { SavedObjectsFindResponsePublic } from '../../../../../../../../../../core/public'; + +jest.mock('../../lib/ensure_minimum_time', () => ({ + ensureMinimumTime: async (promises: Array>) => Array.isArray(promises) ? await Promise.all(promises) : await promises, })); -const mockIndexPatternCreationType = { - getIndexPatternType: () => 'default', - getIndexPatternName: () => 'name', - checkIndicesForErrors: () => false, - getShowSystemIndices: () => false, -}; -jest.mock('ui/chrome', () => ({ - getUiSettingsClient: () => ({ - get: () => '', - }), - addBasePath: () => {}, -})); +const mockIndexPatternCreationType = new IndexPatternCreationConfig({ + type: 'default', + name: 'name', +}); -jest.mock('../../../lib/get_indices', () => ({ - getIndices: (service, indexPatternCreationType, query) => { +jest.mock('../../lib/get_indices', () => ({ + getIndices: ({}, {}, query: string) => { if (query.startsWith('e')) { return [{ name: 'es' }]; } @@ -50,22 +46,30 @@ jest.mock('../../../lib/get_indices', () => ({ }, })); -const allIndices = [{ name: 'kibana' }, { name: 'es' }]; -const esService = {}; -const savedObjectsClient = { - find: () => ({ savedObjects: [] }), -}; +const allIndices = [ + { name: 'kibana', tags: [] }, + { name: 'es', tags: [] }, +]; + const goToNextStep = () => {}; -const createComponent = props => { +const savedObjectClient = coreMock.createStart().savedObjects.client; +savedObjectClient.find = () => + new Promise>(() => ({ savedObjects: [] })); + +const uiSettings = coreMock.createSetup().uiSettings; +uiSettings.get.mockReturnValue(''); + +const createComponent = (props?: Record) => { return shallowWithI18nProvider( ); @@ -93,8 +97,8 @@ describe('StepIndexPattern', () => { it('renders errors when input is invalid', async () => { const component = createComponent(); - const instance = component.instance(); - instance.onQueryChanged({ target: { value: '?' } }); + const instance = component.instance() as StepIndexPattern; + instance.onQueryChanged({ target: { value: '?' } } as React.ChangeEvent); // Ensure all promises resolve await new Promise(resolve => process.nextTick(resolve)); @@ -107,8 +111,8 @@ describe('StepIndexPattern', () => { it('renders matching indices when input is valid', async () => { const component = createComponent(); - const instance = component.instance(); - instance.onQueryChanged({ target: { value: 'k' } }); + const instance = component.instance() as StepIndexPattern; + instance.onQueryChanged({ target: { value: 'k' } } as React.ChangeEvent); // Ensure all promises resolve await new Promise(resolve => process.nextTick(resolve)); @@ -122,8 +126,8 @@ describe('StepIndexPattern', () => { it('appends a wildcard automatically to queries', async () => { const component = createComponent(); - const instance = component.instance(); - instance.onQueryChanged({ target: { value: 'k' } }); + const instance = component.instance() as StepIndexPattern; + instance.onQueryChanged({ target: { value: 'k' } } as React.ChangeEvent); expect(component.state('query')).toBe('k*'); }); @@ -135,8 +139,8 @@ describe('StepIndexPattern', () => { it('ensures the response of the latest request is persisted', async () => { const component = createComponent(); - const instance = component.instance(); - instance.onQueryChanged({ target: { value: 'e' } }); + const instance = component.instance() as StepIndexPattern; + instance.onQueryChanged({ target: { value: 'e' } } as React.ChangeEvent); instance.lastQuery = 'k'; await new Promise(resolve => process.nextTick(resolve)); @@ -149,7 +153,7 @@ describe('StepIndexPattern', () => { // Ensure it works in the other code flow too (the other early return) // Provide `es` so we do not auto append * and enter our other code flow - instance.onQueryChanged({ target: { value: 'es' } }); + instance.onQueryChanged({ target: { value: 'es' } } as React.ChangeEvent); instance.lastQuery = 'k'; await new Promise(resolve => process.nextTick(resolve)); expect(component.state('exactMatchedIndices')).toEqual([]); diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx similarity index 74% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx index e10f033ed8165..7cfc7c4dbc81c 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx @@ -18,8 +18,14 @@ */ import React, { Component } from 'react'; -import PropTypes from 'prop-types'; -import { indexPatterns } from '../../../../../../../../../../plugins/data/public'; +import { EuiPanel, EuiSpacer, EuiCallOut } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { + indexPatterns, + DataPublicPluginStart, +} from '../../../../../../../../../../plugins/data/public'; +import { SavedObjectsClient, IUiSettingsClient } from '../../../../../../../../../../core/public'; import { MAX_SEARCH_SIZE } from '../../constants'; import { getIndices, @@ -32,47 +38,53 @@ import { LoadingIndices } from './components/loading_indices'; import { StatusMessage } from './components/status_message'; import { IndicesList } from './components/indices_list'; import { Header } from './components/header'; +import { IndexPatternCreationConfig } from '../../../../../../../../management/public'; +import { MatchedIndex } from '../../types'; + +interface StepIndexPatternProps { + allIndices: MatchedIndex[]; + isIncludingSystemIndices: boolean; + esService: DataPublicPluginStart['search']['__LEGACY']['esClient']; + savedObjectsClient: SavedObjectsClient; + indexPatternCreationType: IndexPatternCreationConfig; + goToNextStep: () => void; + initialQuery?: string; + uiSettings: IUiSettingsClient; +} -import { EuiPanel, EuiSpacer, EuiCallOut } from '@elastic/eui'; - -import { i18n } from '@kbn/i18n'; -import { FormattedMessage } from '@kbn/i18n/react'; -import chrome from 'ui/chrome'; - -const uiSettings = chrome.getUiSettingsClient(); - -export class StepIndexPattern extends Component { - static propTypes = { - allIndices: PropTypes.array.isRequired, - isIncludingSystemIndices: PropTypes.bool.isRequired, - esService: PropTypes.object.isRequired, - savedObjectsClient: PropTypes.object.isRequired, - indexPatternCreationType: PropTypes.object.isRequired, - goToNextStep: PropTypes.func.isRequired, - initialQuery: PropTypes.string, - }; +interface StepIndexPatternState { + partialMatchedIndices: MatchedIndex[]; + exactMatchedIndices: MatchedIndex[]; + isLoadingIndices: boolean; + existingIndexPatterns: string[]; + indexPatternExists: boolean; + query: string; + appendedWildcard: boolean; + showingIndexPatternQueryErrors: boolean; + indexPatternName: string; +} - static defaultProps = { - initialQuery: uiSettings.get('indexPattern:placeholder'), +export class StepIndexPattern extends Component { + state = { + partialMatchedIndices: [], + exactMatchedIndices: [], + isLoadingIndices: false, + existingIndexPatterns: [], + indexPatternExists: false, + query: '', + appendedWildcard: false, + showingIndexPatternQueryErrors: false, + indexPatternName: '', }; + ILLEGAL_CHARACTERS = [...indexPatterns.ILLEGAL_CHARACTERS]; + lastQuery: string | undefined; - constructor(props) { + constructor(props: StepIndexPatternProps) { super(props); - const { indexPatternCreationType } = this.props; - this.state = { - partialMatchedIndices: [], - exactMatchedIndices: [], - isLoadingIndices: false, - existingIndexPatterns: [], - indexPatternExists: false, - query: props.initialQuery, - appendedWildcard: false, - showingIndexPatternQueryErrors: false, - indexPatternName: indexPatternCreationType.getIndexPatternName(), - }; - - this.ILLEGAL_CHARACTERS = [...indexPatterns.ILLEGAL_CHARACTERS]; - this.lastQuery = null; + const { indexPatternCreationType, initialQuery } = this.props; + + this.state.query = initialQuery || props.uiSettings.get('indexPattern:placeholder'); + this.state.indexPatternName = indexPatternCreationType.getIndexPatternName(); } async UNSAFE_componentWillMount() { @@ -89,17 +101,19 @@ export class StepIndexPattern extends Component { fields: ['title'], perPage: 10000, }); + const existingIndexPatterns = savedObjects.map(obj => obj && obj.attributes ? obj.attributes.title : '' - ); + ) as string[]; + this.setState({ existingIndexPatterns }); }; - fetchIndices = async query => { + fetchIndices = async (query: string) => { const { esService, indexPatternCreationType } = this.props; const { existingIndexPatterns } = this.state; - if (existingIndexPatterns.includes(query)) { + if ((existingIndexPatterns as string[]).includes(query)) { this.setState({ indexPatternExists: true }); return; } @@ -135,7 +149,7 @@ export class StepIndexPattern extends Component { }); }; - onQueryChanged = e => { + onQueryChanged = (e: React.ChangeEvent) => { const { appendedWildcard } = this.state; const { target } = e; @@ -166,9 +180,13 @@ export class StepIndexPattern extends Component { return ; } - renderStatusMessage(matchedIndices) { - const { indexPatternCreationType } = this.props; - const { query, isLoadingIndices, indexPatternExists, isIncludingSystemIndices } = this.state; + renderStatusMessage(matchedIndices: { + allIndices: MatchedIndex[]; + exactMatchedIndices: MatchedIndex[]; + partialMatchedIndices: MatchedIndex[]; + }) { + const { indexPatternCreationType, isIncludingSystemIndices } = this.props; + const { query, isLoadingIndices, indexPatternExists } = this.state; if (isLoadingIndices || indexPatternExists) { return null; @@ -184,7 +202,13 @@ export class StepIndexPattern extends Component { ); } - renderList({ visibleIndices, allIndices }) { + renderList({ + visibleIndices, + allIndices, + }: { + visibleIndices: MatchedIndex[]; + allIndices: MatchedIndex[]; + }) { const { query, isLoadingIndices, indexPatternExists } = this.state; if (isLoadingIndices || indexPatternExists) { @@ -192,7 +216,6 @@ export class StepIndexPattern extends Component { } const indicesToList = query.length ? visibleIndices : allIndices; - return ( {this.renderHeader(matchedIndices)} - {this.renderLoadingState(matchedIndices)} + {this.renderLoadingState()} {this.renderIndexPatternExists()} {this.renderStatusMessage(matchedIndices)} diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/__jest__/__snapshots__/step_time_field.test.js.snap b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/__snapshots__/step_time_field.test.tsx.snap similarity index 92% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/__jest__/__snapshots__/step_time_field.test.js.snap rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/__snapshots__/step_time_field.test.tsx.snap index 04a8a5070b21f..8ca307b3fc2a8 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/__jest__/__snapshots__/step_time_field.test.js.snap +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/__snapshots__/step_time_field.test.tsx.snap @@ -32,14 +32,7 @@ exports[`StepTimeField should render "Custom index pattern ID already exists" wh isLoading={false} isVisible={false} onTimeFieldChanged={[Function]} - timeFieldOptions={ - Array [ - Object { - "text": "", - "value": "", - }, - ] - } + timeFieldOptions={Array []} /> ( +export const ActionButtons = ({ + goToPreviousStep, + submittable, + createIndexPattern, +}: { + goToPreviousStep: () => void; + submittable: boolean; + createIndexPattern: () => void; +}) => ( diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/action_buttons/index.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/action_buttons/index.ts similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/action_buttons/index.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/action_buttons/index.ts diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/advanced_options/__jest__/__snapshots__/advanced_options.test.js.snap b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/advanced_options/__jest__/__snapshots__/advanced_options.test.js.snap deleted file mode 100644 index 9dbc052d143f3..0000000000000 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/advanced_options/__jest__/__snapshots__/advanced_options.test.js.snap +++ /dev/null @@ -1,37 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`AdvancedOptions should hide if not showing 1`] = ` -
- - - - -
-`; - -exports[`AdvancedOptions should render normally 1`] = ` -
- - - - -
-`; diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/advanced_options/__snapshots__/advanced_options.test.tsx.snap b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/advanced_options/__snapshots__/advanced_options.test.tsx.snap new file mode 100644 index 0000000000000..02ceed3454a00 --- /dev/null +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/advanced_options/__snapshots__/advanced_options.test.tsx.snap @@ -0,0 +1,69 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AdvancedOptions should hide if not showing 1`] = ` +
+ + + + +
+`; + +exports[`AdvancedOptions should render normally 1`] = ` +
+ + + + + + + } + label={ + + } + labelType="label" + > + + + +
+`; diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/advanced_options/__jest__/advanced_options.test.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.test.tsx similarity index 95% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/advanced_options/__jest__/advanced_options.test.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.test.tsx index 6dde1a597fc2d..ffb3779d47c89 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/advanced_options/__jest__/advanced_options.test.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.test.tsx @@ -25,7 +25,7 @@ describe('AdvancedOptions', () => { it('should render normally', () => { const component = shallowWithI18nProvider( {}} onChangeIndexPatternId={() => {}} @@ -38,7 +38,7 @@ describe('AdvancedOptions', () => { it('should hide if not showing', () => { const component = shallowWithI18nProvider( {}} onChangeIndexPatternId={() => {}} diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.tsx similarity index 90% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.tsx index 9082df6affa09..fd2c1db1eacd7 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.tsx @@ -24,7 +24,14 @@ import { EuiForm, EuiFormRow, EuiFieldText, EuiButtonEmpty, EuiSpacer } from '@e import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -export const AdvancedOptions = ({ +interface AdvancedOptionsProps { + isVisible: boolean; + indexPatternId: string; + toggleAdvancedOptions: (e: React.FormEvent) => void; + onChangeIndexPatternId: (e: React.ChangeEvent) => void; +} + +export const AdvancedOptions: React.FC = ({ isVisible, indexPatternId, toggleAdvancedOptions, diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/advanced_options/index.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/advanced_options/index.ts similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/advanced_options/index.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/advanced_options/index.ts diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/header/__jest__/__snapshots__/header.test.js.snap b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/header/__snapshots__/header.test.tsx.snap similarity index 94% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/header/__jest__/__snapshots__/header.test.js.snap rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/header/__snapshots__/header.test.tsx.snap index dabe9577596a0..5c53558286b0d 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/header/__jest__/__snapshots__/header.test.js.snap +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/header/__snapshots__/header.test.tsx.snap @@ -27,7 +27,7 @@ exports[`Header should render normally 1`] = ` "indexPattern": ki* , - "indexPatternName": undefined, + "indexPatternName": "ki*", } } /> diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/header/__jest__/header.test.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/header/header.test.tsx similarity index 92% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/header/__jest__/header.test.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/header/header.test.tsx index 29c4b849070b8..8a37eefc82ce2 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/header/__jest__/header.test.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/header/header.test.tsx @@ -23,7 +23,7 @@ import { shallow } from 'enzyme'; describe('Header', () => { it('should render normally', () => { - const component = shallow(
); + const component = shallow(
); expect(component).toMatchSnapshot(); }); diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/header/header.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/header/header.tsx similarity index 90% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/header/header.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/header/header.tsx index 63718e411f712..5c2f184e8038b 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/header/header.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/header/header.tsx @@ -23,7 +23,12 @@ import { EuiTitle, EuiSpacer, EuiText } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -export const Header = ({ indexPattern, indexPatternName }) => ( +interface HeaderProps { + indexPattern: string; + indexPatternName: string; +} + +export const Header: React.FC = ({ indexPattern, indexPatternName }) => (

diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/header/index.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/header/index.ts similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/header/index.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/header/index.ts diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/time_field/__jest__/__snapshots__/time_field.test.js.snap b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/time_field/__snapshots__/time_field.test.tsx.snap similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/time_field/__jest__/__snapshots__/time_field.test.js.snap rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/time_field/__snapshots__/time_field.test.tsx.snap diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/time_field/index.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/time_field/index.ts similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/time_field/index.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/time_field/index.ts diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/time_field/__jest__/time_field.test.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.test.tsx similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/time_field/__jest__/time_field.test.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.test.tsx diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.tsx similarity index 92% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.tsx index 595552568b461..876a3b79a8812 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.tsx @@ -35,7 +35,16 @@ import { import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -export const TimeField = ({ +interface TimeFieldProps { + isVisible: boolean; + fetchTimeFields: () => void; + timeFieldOptions: Array<{ text: string; value?: string }>; + isLoading: boolean; + selectedTimeField?: string; + onTimeFieldChanged: (e: React.ChangeEvent) => void; +} + +export const TimeField: React.FC = ({ isVisible, fetchTimeFields, timeFieldOptions, diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/index.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/index.ts similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/index.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/index.ts diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/__jest__/step_time_field.test.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/step_time_field.test.tsx similarity index 83% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/__jest__/step_time_field.test.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/step_time_field.test.tsx index 1f9d80440f6cb..f37dc088ac78e 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/__jest__/step_time_field.test.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/step_time_field.test.tsx @@ -19,34 +19,30 @@ import React from 'react'; import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; +import { IndexPatternCreationConfig } from '../../../../../../../../management/public'; +import { IFieldType } from '../../../../../../../../../../plugins/data/public'; +import { dataPluginMock } from '../../../../../../../../../../plugins/data/public/mocks'; import { StepTimeField } from '../step_time_field'; -jest.mock('../components/header', () => ({ Header: 'Header' })); -jest.mock('../components/time_field', () => ({ TimeField: 'TimeField' })); -jest.mock('../components/advanced_options', () => ({ AdvancedOptions: 'AdvancedOptions' })); -jest.mock('../components/action_buttons', () => ({ ActionButtons: 'ActionButtons' })); -jest.mock('../../../lib/extract_time_fields', () => ({ - extractTimeFields: fields => fields, +jest.mock('./components/header', () => ({ Header: 'Header' })); +jest.mock('./components/time_field', () => ({ TimeField: 'TimeField' })); +jest.mock('./components/advanced_options', () => ({ AdvancedOptions: 'AdvancedOptions' })); +jest.mock('./components/action_buttons', () => ({ ActionButtons: 'ActionButtons' })); +jest.mock('./../../lib/extract_time_fields', () => ({ + extractTimeFields: (fields: IFieldType) => fields, })); jest.mock('ui/chrome', () => ({ addBasePath: () => {}, })); -const mockIndexPatternCreationType = { - getIndexPatternType: () => 'default', - getIndexPatternName: () => 'name', - getFetchForWildcardOptions: () => {}, -}; +const mockIndexPatternCreationType = new IndexPatternCreationConfig({ + type: 'default', + name: 'name', +}); + const noop = () => {}; -const indexPatternsService = { - make: async () => ({ - fieldsFetcher: { - fetch: noop, - fetchForWildcard: noop, - }, - }), -}; +const indexPatternsService = dataPluginMock.createStartContract().indexPatterns; describe('StepTimeField', () => { it('should render normally', () => { @@ -127,12 +123,16 @@ describe('StepTimeField', () => { // If the value is undefined, that means the user selected the // `I don't want to use a Time filter` option - component.instance().onTimeFieldChanged({ target: { value: undefined } }); + (component.instance() as StepTimeField).onTimeFieldChanged(({ + target: { value: undefined }, + } as unknown) as React.ChangeEvent); expect(component.state('timeFieldSet')).toBe(true); // If the value is an empty string, that means the user selected // an invalid selection (like the empty selection or the `-----`) - component.instance().onTimeFieldChanged({ target: { value: '' } }); + (component.instance() as StepTimeField).onTimeFieldChanged(({ + target: { value: '' }, + } as unknown) as React.ChangeEvent); expect(component.state('timeFieldSet')).toBe(false); }); @@ -154,7 +154,9 @@ describe('StepTimeField', () => { ], }); - component.instance().onTimeFieldChanged({ target: { value: '' } }); + (component.instance() as StepTimeField).onTimeFieldChanged(({ + target: { value: '' }, + } as unknown) as React.ChangeEvent); component.update(); expect(component.find('ActionButtons')).toMatchSnapshot(); @@ -178,7 +180,9 @@ describe('StepTimeField', () => { ], }); - component.instance().onTimeFieldChanged({ target: { value: undefined } }); + (component.instance() as StepTimeField).onTimeFieldChanged(({ + target: { value: undefined }, + } as unknown) as React.ChangeEvent); component.update(); expect(component.find('ActionButtons')).toMatchSnapshot(); @@ -281,7 +285,7 @@ describe('StepTimeField', () => { /> ); - await component.instance().createIndexPattern(); + await (component.instance() as StepTimeField).createIndexPattern(); component.update(); expect(component.instance().state).toMatchObject({ diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/step_time_field.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx similarity index 71% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/step_time_field.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx index d69717eead231..dff2a07e460e2 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/step_time_field.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx @@ -18,14 +18,6 @@ */ import React, { Component } from 'react'; -import PropTypes from 'prop-types'; -import { ensureMinimumTime, extractTimeFields } from '../../lib'; - -import { Header } from './components/header'; -import { TimeField } from './components/time_field'; -import { AdvancedOptions } from './components/advanced_options'; -import { ActionButtons } from './components/action_buttons'; - import { EuiCallOut, EuiFlexGroup, @@ -35,33 +27,61 @@ import { EuiSpacer, EuiLoadingSpinner, } from '@elastic/eui'; - import { FormattedMessage } from '@kbn/i18n/react'; +import { ensureMinimumTime, extractTimeFields } from '../../lib'; + +import { Header } from './components/header'; +import { TimeField } from './components/time_field'; +import { AdvancedOptions } from './components/advanced_options'; +import { ActionButtons } from './components/action_buttons'; +import { IndexPatternCreationConfig } from '../../../../../../../../management/public'; +import { DataPublicPluginStart } from '../../../../../../../../../../plugins/data/public'; -export class StepTimeField extends Component { - static propTypes = { - indexPattern: PropTypes.string.isRequired, - indexPatternsService: PropTypes.object.isRequired, - goToPreviousStep: PropTypes.func.isRequired, - createIndexPattern: PropTypes.func.isRequired, - indexPatternCreationType: PropTypes.object.isRequired, +interface StepTimeFieldProps { + indexPattern: string; + indexPatternsService: DataPublicPluginStart['indexPatterns']; + goToPreviousStep: () => void; + createIndexPattern: (selectedTimeField: string, indexPatternId: string) => void; + indexPatternCreationType: IndexPatternCreationConfig; +} + +interface StepTimeFieldState { + error: string; + timeFields: TimeFieldConfig[]; + selectedTimeField?: string; + timeFieldSet: boolean; + isAdvancedOptionsVisible: boolean; + isFetchingTimeFields: boolean; + isCreating: boolean; + indexPatternId: string; + indexPatternType: string; + indexPatternName: string; +} + +interface TimeFieldConfig { + display: string; + fieldName?: string; + isDisabled?: boolean; +} + +export class StepTimeField extends Component { + state = { + error: '', + timeFields: [], + selectedTimeField: undefined, + timeFieldSet: false, + isAdvancedOptionsVisible: false, + isFetchingTimeFields: false, + isCreating: false, + indexPatternId: '', + indexPatternType: '', + indexPatternName: '', }; - constructor(props) { + constructor(props: StepTimeFieldProps) { super(props); - - this.state = { - error: '', - timeFields: [], - selectedTimeField: undefined, - timeFieldSet: false, - isAdvancedOptionsVisible: false, - isFetchingTimeFields: false, - isCreating: false, - indexPatternId: '', - indexPatternType: props.indexPatternCreationType.getIndexPatternType(), - indexPatternName: props.indexPatternCreationType.getIndexPatternName(), - }; + this.state.indexPatternType = props.indexPatternCreationType.getIndexPatternType() || ''; + this.state.indexPatternName = props.indexPatternCreationType.getIndexPatternName(); } mounted = false; @@ -91,22 +111,24 @@ export class StepTimeField extends Component { this.setState({ timeFields, isFetchingTimeFields: false }); }; - onTimeFieldChanged = e => { + onTimeFieldChanged = (e: React.ChangeEvent) => { const value = e.target.value; // Find the time field based on the selected value - const timeField = this.state.timeFields.find(timeField => timeField.fieldName === value); + const timeField = this.state.timeFields.find( + (timeFld: TimeFieldConfig) => timeFld.fieldName === value + ); // If the value is an empty string, it's not a valid selection const validSelection = value !== ''; this.setState({ - selectedTimeField: timeField ? timeField.fieldName : undefined, + selectedTimeField: timeField ? (timeField as TimeFieldConfig).fieldName : undefined, timeFieldSet: validSelection, }); }; - onChangeIndexPatternId = e => { + onChangeIndexPatternId = (e: React.ChangeEvent) => { this.setState({ indexPatternId: e.target.value }); }; @@ -121,7 +143,7 @@ export class StepTimeField extends Component { const { selectedTimeField, indexPatternId } = this.state; this.setState({ isCreating: true }); try { - await createIndexPattern(selectedTimeField, indexPatternId); + await createIndexPattern(selectedTimeField || '', indexPatternId); } catch (error) { if (!this.mounted) return; this.setState({ @@ -131,7 +153,7 @@ export class StepTimeField extends Component { } }; - formatErrorMessage(message) { + formatErrorMessage(message: string) { // `createIndexPattern` throws "Conflict" when index pattern ID already exists. return message === 'Conflict' ? ( ({ - text: timeField.display, - value: timeField.fieldName, - disabled: timeFields.isDisabled, - })), - ] - : []; + const timeFieldOptions = + timeFields.length > 0 + ? [ + { text: '', value: '' }, + ...timeFields.map((timeField: TimeFieldConfig) => ({ + text: timeField.display, + value: timeField.fieldName, + disabled: ((timeFields as unknown) as TimeFieldConfig).isDisabled, + })), + ] + : []; const showTimeField = !timeFields || timeFields.length > 1; const submittable = !showTimeField || timeFieldSet; diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/create_index_pattern_wizard.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/create_index_pattern_wizard.js index b5c6000eb2fe1..1a93188edd6cc 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/create_index_pattern_wizard.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/create_index_pattern_wizard.js @@ -224,6 +224,7 @@ export class CreateIndexPatternWizard extends Component { savedObjectsClient={services.savedObjectsClient} indexPatternCreationType={this.indexPatternCreationType} goToNextStep={this.goToTimeFieldStep} + uiSettings={services.uiSettings} /> ); } diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/__jest__/create_index_pattern_wizard.test.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/create_index_pattern_wizard.test.js similarity index 91% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/__jest__/create_index_pattern_wizard.test.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/create_index_pattern_wizard.test.js index bcf28725c91da..941f87d4d9fd2 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/__jest__/create_index_pattern_wizard.test.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/create_index_pattern_wizard.test.js @@ -20,7 +20,7 @@ import React from 'react'; import { shallow } from 'enzyme'; -import { CreateIndexPatternWizard } from '../create_index_pattern_wizard'; +import { CreateIndexPatternWizard } from './create_index_pattern_wizard'; const mockIndexPatternCreationType = { getIndexPatternType: () => 'default', getIndexPatternName: () => 'name', @@ -32,12 +32,12 @@ const mockIndexPatternCreationType = { return {}; }, }; -jest.mock('../components/step_index_pattern', () => ({ StepIndexPattern: 'StepIndexPattern' })); -jest.mock('../components/step_time_field', () => ({ StepTimeField: 'StepTimeField' })); -jest.mock('../components/header', () => ({ Header: 'Header' })); -jest.mock('../components/loading_state', () => ({ LoadingState: 'LoadingState' })); -jest.mock('../components/empty_state', () => ({ EmptyState: 'EmptyState' })); -jest.mock('../lib/get_indices', () => ({ +jest.mock('./components/step_index_pattern', () => ({ StepIndexPattern: 'StepIndexPattern' })); +jest.mock('./components/step_time_field', () => ({ StepTimeField: 'StepTimeField' })); +jest.mock('./components/header', () => ({ Header: 'Header' })); +jest.mock('./components/loading_state', () => ({ LoadingState: 'LoadingState' })); +jest.mock('./components/empty_state', () => ({ EmptyState: 'EmptyState' })); +jest.mock('./lib/get_indices', () => ({ getIndices: () => { return [{ name: 'kibana' }]; }, diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/index.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/index.js index d06bc8784de51..50c5a58d35db3 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/index.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/index.js @@ -47,6 +47,7 @@ uiRoutes.when('/management/kibana/index_pattern', { $scope.$evalAsync(() => kbnUrl.changePath(url)); }, openConfirm: npStart.core.overlays.openConfirm, + uiSettings: npStart.core.uiSettings, }; const initialQuery = $routeParams.id ? decodeURIComponent($routeParams.id) : undefined; diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/lib/get_matched_indices.test.ts b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/lib/get_matched_indices.test.ts index 7aba50a7ca12b..65840aa64046d 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/lib/get_matched_indices.test.ts +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/lib/get_matched_indices.test.ts @@ -18,12 +18,13 @@ */ import { getMatchedIndices } from './get_matched_indices'; +import { Tag } from '../types'; jest.mock('./../constants', () => ({ MAX_NUMBER_OF_MATCHING_INDICES: 6, })); -const tags: string[] = []; +const tags: Tag[] = []; const indices = [ { name: 'kibana', tags }, { name: 'es', tags }, diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/__jest__/render.test.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/render.test.js similarity index 98% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/__jest__/render.test.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/render.test.js index 375e80028f317..af580547b11ed 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/__jest__/render.test.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/render.test.js @@ -33,7 +33,7 @@ jest.mock('ui/i18n', () => ({ I18nContext: () => {}, })); -const { renderCreateIndexPatternWizard, destroyCreateIndexPatternWizard } = require('../render'); +const { renderCreateIndexPatternWizard, destroyCreateIndexPatternWizard } = require('./render'); describe('CreateIndexPatternWizardRender', () => { beforeEach(() => { diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/types.ts b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/types.ts index 93bb6920c6981..634bbd856ea86 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/types.ts +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/types.ts @@ -19,5 +19,10 @@ export interface MatchedIndex { name: string; - tags: string[]; + tags: Tag[]; +} + +export interface Tag { + name: string; + key: string; } diff --git a/src/legacy/core_plugins/management/public/np_ready/services/index_pattern_management/creation/config.ts b/src/legacy/core_plugins/management/public/np_ready/services/index_pattern_management/creation/config.ts index b68b2e40aad9e..5714fa3338962 100644 --- a/src/legacy/core_plugins/management/public/np_ready/services/index_pattern_management/creation/config.ts +++ b/src/legacy/core_plugins/management/public/np_ready/services/index_pattern_management/creation/config.ts @@ -18,6 +18,7 @@ */ import { i18n } from '@kbn/i18n'; +import { MatchedIndex } from '../../../../../../kibana/public/management/sections/index_patterns/create_index_pattern_wizard/types'; const indexPatternTypeName = i18n.translate( 'management.editIndexPattern.createIndex.defaultTypeName', @@ -106,7 +107,7 @@ export class IndexPatternCreationConfig { return []; } - public checkIndicesForErrors() { + public checkIndicesForErrors(indices: MatchedIndex[]) { return undefined; } diff --git a/src/plugins/advanced_settings/public/management_app/components/field/field.tsx b/src/plugins/advanced_settings/public/management_app/components/field/field.tsx index 5cf5ea99faa80..7158e3d5e7b3e 100644 --- a/src/plugins/advanced_settings/public/management_app/components/field/field.tsx +++ b/src/plugins/advanced_settings/public/management_app/components/field/field.tsx @@ -31,7 +31,6 @@ import { EuiCodeBlock, // @ts-ignore EuiCodeEditor, - // @ts-ignore EuiDescribedFormGroup, EuiFieldNumber, EuiFieldText, diff --git a/src/plugins/advanced_settings/public/management_app/components/search/search.test.tsx b/src/plugins/advanced_settings/public/management_app/components/search/search.test.tsx index 8e7bac5129ae9..0e3fbb3cf97fa 100644 --- a/src/plugins/advanced_settings/public/management_app/components/search/search.test.tsx +++ b/src/plugins/advanced_settings/public/management_app/components/search/search.test.tsx @@ -19,6 +19,7 @@ import React from 'react'; import { shallowWithI18nProvider, mountWithI18nProvider } from 'test_utils/enzyme_helpers'; + // @ts-ignore import { findTestSubject } from '@elastic/eui/lib/test'; diff --git a/src/plugins/data/public/index_patterns/index_patterns/index_pattern.ts b/src/plugins/data/public/index_patterns/index_patterns/index_pattern.ts index 06d4a881447dc..768029136879d 100644 --- a/src/plugins/data/public/index_patterns/index_patterns/index_pattern.ts +++ b/src/plugins/data/public/index_patterns/index_patterns/index_pattern.ts @@ -64,7 +64,7 @@ export class IndexPattern implements IIndexPattern { private getConfig: any; private sourceFilters?: []; private originalBody: { [key: string]: any } = {}; - private fieldsFetcher: any; + public fieldsFetcher: any; // probably want to factor out any direct usage and change to private private shortDotsEnable: boolean = false; private mapping: MappingObject = expandShorthand({ diff --git a/src/plugins/data/public/mocks.ts b/src/plugins/data/public/mocks.ts index c723c34cd0a22..2d5cc72597ec4 100644 --- a/src/plugins/data/public/mocks.ts +++ b/src/plugins/data/public/mocks.ts @@ -97,7 +97,13 @@ const createStartContract = (): Start => { msearch: jest.fn(), }, }, - indexPatterns: {} as IndexPatternsContract, + indexPatterns: ({ + make: () => ({ + fieldsFetcher: { + fetchForWildcard: jest.fn(), + }, + }), + } as unknown) as IndexPatternsContract, }; return startContract; }; diff --git a/src/plugins/data/public/ui/query_string_input/__snapshots__/query_string_input.test.tsx.snap b/src/plugins/data/public/ui/query_string_input/__snapshots__/query_string_input.test.tsx.snap index 990386687bade..06e56aaf3eb0a 100644 --- a/src/plugins/data/public/ui/query_string_input/__snapshots__/query_string_input.test.tsx.snap +++ b/src/plugins/data/public/ui/query_string_input/__snapshots__/query_string_input.test.tsx.snap @@ -189,7 +189,9 @@ exports[`QueryStringInput Should disable autoFocus on EuiFieldText when disableA "register": [MockFunction], }, "getSuggestions": [MockFunction], - "indexPatterns": Object {}, + "indexPatterns": Object { + "make": [Function], + }, "query": Object { "filterManager": [MockFunction], "savedQueries": [MockFunction], @@ -842,7 +844,9 @@ exports[`QueryStringInput Should disable autoFocus on EuiFieldText when disableA "register": [MockFunction], }, "getSuggestions": [MockFunction], - "indexPatterns": Object {}, + "indexPatterns": Object { + "make": [Function], + }, "query": Object { "filterManager": [MockFunction], "savedQueries": [MockFunction], @@ -1477,7 +1481,9 @@ exports[`QueryStringInput Should pass the query language to the language switche "register": [MockFunction], }, "getSuggestions": [MockFunction], - "indexPatterns": Object {}, + "indexPatterns": Object { + "make": [Function], + }, "query": Object { "filterManager": [MockFunction], "savedQueries": [MockFunction], @@ -2127,7 +2133,9 @@ exports[`QueryStringInput Should pass the query language to the language switche "register": [MockFunction], }, "getSuggestions": [MockFunction], - "indexPatterns": Object {}, + "indexPatterns": Object { + "make": [Function], + }, "query": Object { "filterManager": [MockFunction], "savedQueries": [MockFunction], @@ -2762,7 +2770,9 @@ exports[`QueryStringInput Should render the given query 1`] = ` "register": [MockFunction], }, "getSuggestions": [MockFunction], - "indexPatterns": Object {}, + "indexPatterns": Object { + "make": [Function], + }, "query": Object { "filterManager": [MockFunction], "savedQueries": [MockFunction], @@ -3412,7 +3422,9 @@ exports[`QueryStringInput Should render the given query 1`] = ` "register": [MockFunction], }, "getSuggestions": [MockFunction], - "indexPatterns": Object {}, + "indexPatterns": Object { + "make": [Function], + }, "query": Object { "filterManager": [MockFunction], "savedQueries": [MockFunction],