From 057412f2c0539a1856683bf535b088f556e5bd11 Mon Sep 17 00:00:00 2001 From: cchaos Date: Mon, 8 Jun 2020 15:16:49 -0400 Subject: [PATCH 01/76] Remove old help flyout --- .sass-lint.yml | 1 + .../public/doc_links/doc_links_service.ts | 2 + .../create_index_pattern_prompt/index.tsx | 108 ------------------ .../index_pattern_table.tsx | 44 +++---- test/functional/page_objects/settings_page.ts | 9 -- 5 files changed, 19 insertions(+), 145 deletions(-) delete mode 100644 src/plugins/index_pattern_management/public/components/create_index_pattern_prompt/index.tsx diff --git a/.sass-lint.yml b/.sass-lint.yml index eb43af293c670e..0264373a8d0262 100644 --- a/.sass-lint.yml +++ b/.sass-lint.yml @@ -2,6 +2,7 @@ files: include: - 'src/legacy/core_plugins/metrics/**/*.s+(a|c)ss' - 'src/legacy/core_plugins/timelion/**/*.s+(a|c)ss' + - 'src/plugins/index_pattern_management/**/*.s+(a|c)ss' - 'src/plugins/vis_type_vislib/**/*.s+(a|c)ss' - 'src/plugins/vis_type_xy/**/*.s+(a|c)ss' - 'x-pack/plugins/canvas/**/*.s+(a|c)ss' diff --git a/src/core/public/doc_links/doc_links_service.ts b/src/core/public/doc_links/doc_links_service.ts index aeeb8c3342e462..8de664f7081391 100644 --- a/src/core/public/doc_links/doc_links_service.ts +++ b/src/core/public/doc_links/doc_links_service.ts @@ -107,6 +107,7 @@ export class DocLinksService { loadingData: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/tutorial-load-dataset.html`, introduction: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/index-patterns.html`, }, + addData: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/connect-to-elasticsearch.html`, kibana: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/index.html`, siem: { guide: `${ELASTIC_WEBSITE_URL}guide/en/siem/guide/${DOC_LINK_VERSION}/index.html`, @@ -214,6 +215,7 @@ export interface DocLinksSetup { readonly loadingData: string; readonly introduction: string; }; + readonly addData: string; readonly kibana: string; readonly siem: { readonly guide: string; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_prompt/index.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_prompt/index.tsx deleted file mode 100644 index ab3b90177bcfda..00000000000000 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_prompt/index.tsx +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { - EuiDescriptionList, - EuiDescriptionListDescription, - EuiDescriptionListTitle, - EuiFlyout, - EuiFlyoutBody, - EuiFlyoutHeader, - EuiHorizontalRule, - EuiSpacer, - EuiText, -} from '@elastic/eui'; -import { FormattedMessage } from '@kbn/i18n/react'; -import React from 'react'; - -export const CreateIndexPatternPrompt = ({ onClose }: { onClose: () => void }) => ( - - - -

- -

-
-
- - -

- -

-
- - -

- -

-
- - - - - - - - - - - - - - - - - - - - - -
-
-); diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx index 947882b8df495b..c098e623a07b7e 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx @@ -20,14 +20,14 @@ import { EuiBadge, EuiButtonEmpty, - EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiInMemoryTable, - EuiPanel, EuiSpacer, EuiText, EuiBadgeGroup, + EuiPageContent, + EuiTitle, } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { withRouter, RouteComponentProps } from 'react-router-dom'; @@ -36,7 +36,6 @@ import { i18n } from '@kbn/i18n'; import { reactRouterNavigate, useKibana } from '../../../../../plugins/kibana_react/public'; import { IndexPatternManagmentContext } from '../../types'; import { CreateButton } from '../create_button'; -import { CreateIndexPatternPrompt } from '../create_index_pattern_prompt'; import { IndexPatternTableItem, IndexPatternCreationOption } from '../types'; import { getIndexPatterns } from '../utils'; import { getListBreadcrumbs } from '../breadcrumbs'; @@ -82,7 +81,6 @@ export const IndexPatternTable = ({ canSave, history }: Props) => { indexPatternManagementStart, chrome, } = useKibana().services; - const [showFlyout, setShowFlyout] = useState(false); const [indexPatterns, setIndexPatterns] = useState([]); const [creationOptions, setCreationOptions] = useState([]); @@ -100,7 +98,6 @@ export const IndexPatternTable = ({ canSave, history }: Props) => { ); setCreationOptions(options); setIndexPatterns(gettedIndexPatterns); - setShowFlyout(gettedIndexPatterns.length === 0); })(); }, [ history.push, @@ -157,30 +154,21 @@ export const IndexPatternTable = ({ canSave, history }: Props) => { ); return ( - - {showFlyout && setShowFlyout(false)} />} + - - - - -

{title}

-
-
- - setShowFlyout(true)} - aria-label="Help" + + +

{title}

+
+ + +

+ - - +

+
{createButton}
@@ -195,7 +183,7 @@ export const IndexPatternTable = ({ canSave, history }: Props) => { sorting={sorting} search={search} /> -
+ ); }; diff --git a/test/functional/page_objects/settings_page.ts b/test/functional/page_objects/settings_page.ts index f5b4eb7ad5de83..2a79db1425038b 100644 --- a/test/functional/page_objects/settings_page.ts +++ b/test/functional/page_objects/settings_page.ts @@ -55,15 +55,6 @@ export function SettingsPageProvider({ getService, getPageObjects }: FtrProvider await testSubjects.click('indexPatterns'); await PageObjects.header.waitUntilLoadingHasFinished(); - - // check for the index pattern info flyout that covers the - // create index pattern button on smaller screens - // @ts-ignore - await retry.waitFor('index pattern info flyout', async () => { - if (await testSubjects.exists('CreateIndexPatternPrompt')) { - await testSubjects.click('CreateIndexPatternPrompt > euiFlyoutCloseButton'); - } else return true; - }); } async getAdvancedSettings(propertyName: string) { From 83506f28d569625389eee35a391c86626cbf2163 Mon Sep 17 00:00:00 2001 From: cchaos Date: Tue, 9 Jun 2020 11:17:09 -0400 Subject: [PATCH 02/76] Update the No ES Data screen --- .../empty_state/empty_state.test.tsx | 7 +- .../components/empty_state/empty_state.tsx | 212 +++++++++++++----- .../create_index_pattern_wizard.tsx | 53 +++-- 3 files changed, 190 insertions(+), 82 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.test.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.test.tsx index 7fa39363e3ef72..20608b66641315 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.test.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.test.tsx @@ -21,6 +21,9 @@ import React from 'react'; import { EmptyState } from '../empty_state'; import { shallow } from 'enzyme'; import sinon from 'sinon'; +// @ts-ignore +import { findTestSubject } from '@elastic/eui/lib/test'; +import { mountWithIntl } from 'test_utils/enzyme_helpers'; describe('EmptyState', () => { it('should render normally', () => { @@ -34,11 +37,11 @@ describe('EmptyState', () => { it('is called when refresh button is clicked', () => { const onRefreshHandler = sinon.stub(); - const component = shallow( + const component = mountWithIntl( x} /> ); - component.find('[data-test-subj="refreshIndicesButton"]').simulate('click'); + findTestSubject(component, 'refreshIndicesButton').simulate('click'); sinon.assert.calledOnce(onRefreshHandler); }); diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.tsx index 43c3bf79026feb..b3f41e1d1ee896 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.tsx @@ -18,12 +18,26 @@ */ import React from 'react'; - -import { EuiCallOut, EuiTextColor, EuiLink, EuiButton } from '@elastic/eui'; - +import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; +// import { getDocLink } from '../../../../../ legacy/ui/public/documentation_links'; import { IBasePath } from 'kibana/public'; +import { + EuiPageContentHeader, + EuiPageContentHeaderSection, + EuiTitle, + EuiPageContentBody, + EuiPageContent, + EuiIcon, + EuiSpacer, + EuiFlexItem, + EuiDescriptionList, + EuiFlexGrid, + EuiCard, + EuiLink, +} from '@elastic/eui'; + export const EmptyState = ({ onRefresh, prependBasePath, @@ -31,60 +45,140 @@ export const EmptyState = ({ onRefresh: () => void; prependBasePath: IBasePath['prepend']; }) => ( -
- - } - > -

- - - - ), - learnHowLink: ( - - - - ), - getStartedLink: ( - - - - ), - }} - /> -

- - - - -
-
+ + + + +

+ +

+
+
+
+ + + + + } + title={ + + } + description={ + + } + /> + + + } + title={ + + } + description={ + + } + /> + + + } + title={ + + } + description={ + + } + /> + + + +
+ + + + ), + description: ( + + {/* href={getDocLink('addData')} */} + Read documentation + + ), + }, + ]} + /> + + + + ), + description: ( + + {' '} + + + ), + }, + ]} + /> + + +
+
+
); diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx index 111be41cfc53a9..3a7c3321942c1a 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx @@ -19,7 +19,12 @@ import React, { ReactElement, Component } from 'react'; -import { EuiGlobalToastList, EuiGlobalToastListToast, EuiPanel } from '@elastic/eui'; +import { + EuiGlobalToastList, + EuiGlobalToastListToast, + EuiPageContent, + EuiHorizontalRule, +} from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; import { withRouter, RouteComponentProps } from 'react-router-dom'; @@ -254,29 +259,39 @@ export class CreateIndexPatternWizard extends Component< ); } + const header = this.renderHeader(); + if (step === 1) { const { location } = this.props; const initialQuery = new URLSearchParams(location.search).get('id') || undefined; return ( - + + {header} + + + ); } if (step === 2) { return ( - + + {header} + + + ); } @@ -290,15 +305,11 @@ export class CreateIndexPatternWizard extends Component< }; render() { - const header = this.renderHeader(); const content = this.renderContent(); return ( - -
- {header} - {content} -
+ <> + {content} { @@ -306,7 +317,7 @@ export class CreateIndexPatternWizard extends Component< }} toastLifeTimeMs={6000} /> -
+ ); } } From 7d5823006d7b4a471e1dde5aee2f9d2a43123a50 Mon Sep 17 00:00:00 2001 From: cchaos Date: Tue, 9 Jun 2020 11:49:29 -0400 Subject: [PATCH 03/76] Added `EmptyIndexPatternPrompt` at `/empty` --- .../empty_index_pattern_prompt.test.tsx.snap | 96 +++ .../assets/index_pattern_illustration.js | 556 ++++++++++++++++++ .../assets/index_pattern_illustration.scss | 11 + .../empty_index_pattern_prompt.scss | 26 + .../empty_index_pattern_prompt.test.tsx | 32 + .../empty_index_pattern_prompt.tsx | 123 ++++ .../empty_index_pattern_prompt/index.tsx | 23 + .../public/components/index.ts | 4 + .../mount_management_section.tsx | 4 + 9 files changed, 875 insertions(+) create mode 100644 src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/__snapshots__/empty_index_pattern_prompt.test.tsx.snap create mode 100644 src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/assets/index_pattern_illustration.js create mode 100644 src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/assets/index_pattern_illustration.scss create mode 100644 src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.scss create mode 100644 src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx create mode 100644 src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx create mode 100644 src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/index.tsx diff --git a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/__snapshots__/empty_index_pattern_prompt.test.tsx.snap b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/__snapshots__/empty_index_pattern_prompt.test.tsx.snap new file mode 100644 index 00000000000000..6519b9d479bb4d --- /dev/null +++ b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/__snapshots__/empty_index_pattern_prompt.test.tsx.snap @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`EmptyIndexPatternPrompt should render normally 1`] = ` + + + + + + + +

+ +
+ +

+

+ +

+ + + +
+
+
+ + + + + + + + + + + +
+`; diff --git a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/assets/index_pattern_illustration.js b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/assets/index_pattern_illustration.js new file mode 100644 index 00000000000000..a77419aaccce89 --- /dev/null +++ b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/assets/index_pattern_illustration.js @@ -0,0 +1,556 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import './index_pattern_illustration.scss'; +import React from 'react'; + +const IndexPatternIllustration = () => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +); + +export const Illustration = IndexPatternIllustration; diff --git a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/assets/index_pattern_illustration.scss b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/assets/index_pattern_illustration.scss new file mode 100644 index 00000000000000..ad81bd67421121 --- /dev/null +++ b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/assets/index_pattern_illustration.scss @@ -0,0 +1,11 @@ +$lightShadow: #ECF0F6; + +.indexPatternIllustration { + &__verticalStripes { + fill: lightOrDarkTheme($euiColorEmptyShade, $euiColorFullShade); + } + + &__dots { + fill: lightOrDarkTheme($lightShadow, $euiShadowColor); + } +} diff --git a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.scss b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.scss new file mode 100644 index 00000000000000..bba72ac96a9047 --- /dev/null +++ b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.scss @@ -0,0 +1,26 @@ +// .inpEmptyIndexPatternPrompt { +// // override EUI specificity +// max-width: $inpEmptyStateMaxWidth !important; // sass-lint:disable-line no-important +// } + +// .inpEmptyIndexPatternPrompt__footer { +// @extend %inp-empty-state-footer; +// } + +// .inpEmptyIndexPatternPrompt__title { +// // override EUI specificity +// width: auto !important; // sass-lint:disable-line no-important +// } + +// @include euiBreakpoint('xs', 's') { +// .inpEmptyIndexPatternPrompt__illustration > svg { +// width: $euiSize * 12; +// height: auto; +// margin: 0 auto; +// } + +// .inpEmptyIndexPatternPrompt__text { +// text-align: center; +// align-items: center; +// } +// } diff --git a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx new file mode 100644 index 00000000000000..db0edaa628cf71 --- /dev/null +++ b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx @@ -0,0 +1,32 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React from 'react'; +import { EmptyIndexPatternPrompt } from '../empty_index_pattern_prompt'; +import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; + +describe('EmptyIndexPatternPrompt', () => { + it('should render normally', () => { + const component = shallowWithI18nProvider( + + ); + + expect(component).toMatchSnapshot(); + }); +}); diff --git a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx new file mode 100644 index 00000000000000..95dae067109634 --- /dev/null +++ b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx @@ -0,0 +1,123 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import './empty_index_pattern_prompt.scss'; + +import React, { useState, useEffect } from 'react'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { withRouter, RouteComponentProps } from 'react-router-dom'; + +import { EuiPageContent, EuiSpacer, EuiText, EuiFlexItem, EuiFlexGroup } from '@elastic/eui'; +import { EuiDescriptionListTitle } from '@elastic/eui'; +import { EuiDescriptionListDescription, EuiDescriptionList } from '@elastic/eui'; +import { EuiLink } from '@elastic/eui'; +import { getListBreadcrumbs } from '../breadcrumbs'; +import { IndexPatternManagmentContext } from '../../types'; +import { useKibana } from '../../../../../plugins/kibana_react/public'; +// import { getDocLink } from 'ui/documentation_links'; +import { IndexPatternCreationOption } from '../types'; +import { CreateButton } from '../create_button'; +// @ts-ignore +import { Illustration } from './assets/index_pattern_illustration'; + +interface Props extends RouteComponentProps { + canSave: boolean; +} + +export const EmptyIndexPatternPrompt = ({ canSave, history }: Props) => { + const { indexPatternManagementStart, setBreadcrumbs } = useKibana< + IndexPatternManagmentContext + >().services; + const [creationOptions, setCreationOptions] = useState([]); + setBreadcrumbs(getListBreadcrumbs()); + + useEffect(() => { + (async function () { + const options = await indexPatternManagementStart.creation.getIndexPatternCreationOptions( + history.push + ); + setCreationOptions(options); + })(); + }, [history.push, indexPatternManagementStart]); + + return ( + + + + + + + +

+ +
+ +

+

+ +

+ {canSave && ( + + + + )} +
+
+
+ + + + + + + + {/* href={getDocLink('indexPatterns.introduction')} */} + + + + +
+ ); +}; + +export const EmptyIndexPatternPromptWithRouter = withRouter(EmptyIndexPatternPrompt); diff --git a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/index.tsx b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/index.tsx new file mode 100644 index 00000000000000..ddf1c83725ca01 --- /dev/null +++ b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/index.tsx @@ -0,0 +1,23 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { + EmptyIndexPatternPrompt, + EmptyIndexPatternPromptWithRouter, +} from './empty_index_pattern_prompt'; diff --git a/src/plugins/index_pattern_management/public/components/index.ts b/src/plugins/index_pattern_management/public/components/index.ts index e0acb9d05bc848..fede54dcfc5096 100644 --- a/src/plugins/index_pattern_management/public/components/index.ts +++ b/src/plugins/index_pattern_management/public/components/index.ts @@ -25,3 +25,7 @@ export { CreateEditFieldContainer, } from './edit_index_pattern'; export { CreateIndexPatternWizardWithRouter } from './create_index_pattern_wizard'; +export { + EmptyIndexPatternPrompt, + EmptyIndexPatternPromptWithRouter, +} from './empty_index_pattern_prompt'; diff --git a/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx b/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx index bcabd55c879750..6ae11a3bd15b57 100644 --- a/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx +++ b/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx @@ -32,6 +32,7 @@ import { EditIndexPatternContainer, CreateEditFieldContainer, CreateIndexPatternWizardWithRouter, + EmptyIndexPatternPromptWithRouter, } from '../components'; import { IndexPatternManagementStartDependencies, IndexPatternManagementStart } from '../plugin'; import { IndexPatternManagmentContext } from '../types'; @@ -89,6 +90,9 @@ export async function mountManagementSection( + + + From ce7d96d547a80ca2a4c8e7055ab686a57c10c635 Mon Sep 17 00:00:00 2001 From: cchaos Date: Tue, 9 Jun 2020 16:55:26 -0400 Subject: [PATCH 04/76] Added docLinks --- .../components/empty_state/empty_state.tsx | 7 ++++--- .../create_index_pattern_wizard.tsx | 8 +++++++- .../empty_index_pattern_prompt.tsx | 6 ++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.tsx index b3f41e1d1ee896..3b862c8de23406 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.tsx @@ -21,7 +21,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; // import { getDocLink } from '../../../../../ legacy/ui/public/documentation_links'; -import { IBasePath } from 'kibana/public'; +import { IBasePath, DocLinksSetup } from 'kibana/public'; import { EuiPageContentHeader, @@ -41,9 +41,11 @@ import { export const EmptyState = ({ onRefresh, prependBasePath, + docLinks, }: { onRefresh: () => void; prependBasePath: IBasePath['prepend']; + docLinks: DocLinksSetup; }) => ( @@ -145,8 +147,7 @@ export const EmptyState = ({ /> ), description: ( - - {/* href={getDocLink('addData')} */} + Read documentation ), diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx index 3a7c3321942c1a..f0a5fab4ef82f2 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx @@ -28,6 +28,7 @@ import { import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; import { withRouter, RouteComponentProps } from 'react-router-dom'; +import { DocLinksStart } from 'src/core/public'; import { StepIndexPattern } from './components/step_index_pattern'; import { StepTimeField } from './components/step_time_field'; import { Header } from './components/header'; @@ -51,6 +52,7 @@ interface CreateIndexPatternWizardState { isIncludingSystemIndices: boolean; toasts: EuiGlobalToastListToast[]; indexPatternCreationType: IndexPatternCreationConfig; + docLinks: DocLinksStart; } export class CreateIndexPatternWizard extends Component< @@ -77,6 +79,7 @@ export class CreateIndexPatternWizard extends Component< isIncludingSystemIndices: false, toasts: [], indexPatternCreationType: context.services.indexPatternManagementStart.creation.getType(type), + docLinks: context.services.docLinks, }; } @@ -221,7 +224,7 @@ export class CreateIndexPatternWizard extends Component< }; renderHeader() { - const { isIncludingSystemIndices } = this.state; + const { isIncludingSystemIndices, docLinks } = this.state; return (
); } @@ -243,6 +247,7 @@ export class CreateIndexPatternWizard extends Component< step, indexPattern, remoteClustersExist, + docLinks, } = this.state; if (isInitiallyLoadingIndices) { @@ -255,6 +260,7 @@ export class CreateIndexPatternWizard extends Component< ); } diff --git a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx index 95dae067109634..e31901579088b6 100644 --- a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx +++ b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx @@ -29,7 +29,6 @@ import { EuiLink } from '@elastic/eui'; import { getListBreadcrumbs } from '../breadcrumbs'; import { IndexPatternManagmentContext } from '../../types'; import { useKibana } from '../../../../../plugins/kibana_react/public'; -// import { getDocLink } from 'ui/documentation_links'; import { IndexPatternCreationOption } from '../types'; import { CreateButton } from '../create_button'; // @ts-ignore @@ -40,7 +39,7 @@ interface Props extends RouteComponentProps { } export const EmptyIndexPatternPrompt = ({ canSave, history }: Props) => { - const { indexPatternManagementStart, setBreadcrumbs } = useKibana< + const { indexPatternManagementStart, setBreadcrumbs, docLinks } = useKibana< IndexPatternManagmentContext >().services; const [creationOptions, setCreationOptions] = useState([]); @@ -107,8 +106,7 @@ export const EmptyIndexPatternPrompt = ({ canSave, history }: Props) => { /> - - {/* href={getDocLink('indexPatterns.introduction')} */} + Date: Tue, 9 Jun 2020 17:42:58 -0400 Subject: [PATCH 05/76] Added styles to the new empty prompts --- .../kibana/public/management/index.scss | 2 - .../sections/index_patterns/index.scss | 25 -- .../public/_templates.scss | 11 + .../public/_variables.scss | 1 + .../components/empty_state/empty_state.scss | 24 ++ .../components/empty_state/empty_state.tsx | 261 +++++++++--------- .../empty_index_pattern_prompt.scss | 47 ++-- .../index_pattern_table.tsx | 5 +- 8 files changed, 199 insertions(+), 177 deletions(-) delete mode 100644 src/legacy/core_plugins/kibana/public/management/sections/index_patterns/index.scss create mode 100644 src/plugins/index_pattern_management/public/_templates.scss create mode 100644 src/plugins/index_pattern_management/public/_variables.scss create mode 100644 src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.scss diff --git a/src/legacy/core_plugins/kibana/public/management/index.scss b/src/legacy/core_plugins/kibana/public/management/index.scss index fb267b714f1c96..685ff3fc8f5901 100644 --- a/src/legacy/core_plugins/kibana/public/management/index.scss +++ b/src/legacy/core_plugins/kibana/public/management/index.scss @@ -9,5 +9,3 @@ // Core @import '../../../../../plugins/advanced_settings/public/index'; - -@import 'sections/index_patterns/index'; diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/index.scss b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/index.scss deleted file mode 100644 index c5cf844ebdc342..00000000000000 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/index.scss +++ /dev/null @@ -1,25 +0,0 @@ -#indexPatternListReact { - display: flex; - - .indexPatternList__headerWrapper { - padding-bottom: $euiSizeS; - } - - .euiButtonEmpty__content { - justify-content: left; - padding: 0; - - span { - text-overflow: ellipsis; - overflow: hidden; - } - } - - .indexPatternListPrompt__descList { - text-align: left; - } -} - -.indexPatternList__badge { - margin-left: $euiSizeS; -} diff --git a/src/plugins/index_pattern_management/public/_templates.scss b/src/plugins/index_pattern_management/public/_templates.scss new file mode 100644 index 00000000000000..5303537bddabcb --- /dev/null +++ b/src/plugins/index_pattern_management/public/_templates.scss @@ -0,0 +1,11 @@ +%inp-empty-state-footer { + background: $euiColorLightestShade; + margin: 0 (-$euiSizeL) (-$euiSizeL); + padding: $euiSizeL; + border-radius: 0 0 $euiBorderRadius $euiBorderRadius; + + // sass-lint:disable-block mixins-before-declarations + @include euiBreakpoint('xs', 's') { + text-align: center; + } +} diff --git a/src/plugins/index_pattern_management/public/_variables.scss b/src/plugins/index_pattern_management/public/_variables.scss new file mode 100644 index 00000000000000..5da25a91bd77c5 --- /dev/null +++ b/src/plugins/index_pattern_management/public/_variables.scss @@ -0,0 +1 @@ +$inpEmptyStateMaxWidth: $euiSizeXXL * 19; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.scss b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.scss new file mode 100644 index 00000000000000..269d6ae99ff3b6 --- /dev/null +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.scss @@ -0,0 +1,24 @@ +@import '../../../../variables'; +@import '../../../../templates'; + +.inpEmptyState { + // override EUI specificity + max-width: $inpEmptyStateMaxWidth !important; // sass-lint:disable-line no-important +} + +.inpEmptyState__cardGrid { + justify-content: center; +} + +.inpEmptyState__card { + min-height: $euiSizeXL * 6; + min-width: $euiSizeXL * 6; +} + +.inpEmptyState__footer { + @extend %inp-empty-state-footer; +} + +.inpEmptyState__footerFlexItem { + min-width: $euiSizeXL * 7; +} diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.tsx index 3b862c8de23406..6d429b6e3feb79 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.tsx @@ -17,6 +17,7 @@ * under the License. */ +import './empty_state.scss'; import React from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; @@ -36,6 +37,7 @@ import { EuiFlexGrid, EuiCard, EuiLink, + EuiText, } from '@elastic/eui'; export const EmptyState = ({ @@ -47,139 +49,148 @@ export const EmptyState = ({ prependBasePath: IBasePath['prepend']; docLinks: DocLinksSetup; }) => ( - - - - -

- -

-
-
-
- - - - - } - title={ - - } - description={ + <> + + + + +

- } - /> - - - + + + + + + + + } + title={ + } - )} - betaBadgeTooltipContent={i18n.translate( - 'indexPatternManagement.createIndexPattern.emptyState.basicLicenseDescription', - { - defaultMessage: 'This feature requires a Basic license.', + description={ + } - )} - isDisabled - icon={} - title={ - - } - description={ - - } - /> - - - } - title={ - - } - description={ - - } - /> - - - -
- - - - ), - description: ( - - Read documentation - - ), - }, - ]} /> - - + - ), - description: ( - - {' '} - - - ), - }, - ]} + defaultMessage: 'Basic', + } + )} + betaBadgeTooltipContent={i18n.translate( + 'indexPatternManagement.createIndexPattern.emptyState.basicLicenseDescription', + { + defaultMessage: 'This feature requires a Basic license.', + } + )} + isDisabled + icon={} + title={ + + } + description={ + + } + /> + + + } + title={ + + } + description={ + + } /> -
-
- + +
+ + + + ), + description: ( + + Read documentation + + ), + }, + ]} + /> + + + + ), + description: ( + + {' '} + + + ), + }, + ]} + /> + + +
+ + + + + {/* TODO: Hook up link below */} +

+ Some indices may be hidden. Try to create an index pattern anyway. +

+
+ ); diff --git a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.scss b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.scss index bba72ac96a9047..d8c3f7327ef950 100644 --- a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.scss +++ b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.scss @@ -1,26 +1,29 @@ -// .inpEmptyIndexPatternPrompt { -// // override EUI specificity -// max-width: $inpEmptyStateMaxWidth !important; // sass-lint:disable-line no-important -// } +@import '../../variables'; +@import '../../templates'; -// .inpEmptyIndexPatternPrompt__footer { -// @extend %inp-empty-state-footer; -// } +.inpEmptyIndexPatternPrompt { + // override EUI specificity + max-width: $inpEmptyStateMaxWidth !important; // sass-lint:disable-line no-important +} -// .inpEmptyIndexPatternPrompt__title { -// // override EUI specificity -// width: auto !important; // sass-lint:disable-line no-important -// } +.inpEmptyIndexPatternPrompt__footer { + @extend %inp-empty-state-footer; +} -// @include euiBreakpoint('xs', 's') { -// .inpEmptyIndexPatternPrompt__illustration > svg { -// width: $euiSize * 12; -// height: auto; -// margin: 0 auto; -// } +.inpEmptyIndexPatternPrompt__title { + // override EUI specificity + width: auto !important; // sass-lint:disable-line no-important +} -// .inpEmptyIndexPatternPrompt__text { -// text-align: center; -// align-items: center; -// } -// } +@include euiBreakpoint('xs', 's') { + .inpEmptyIndexPatternPrompt__illustration > svg { + width: $euiSize * 12; + height: auto; + margin: 0 auto; + } + + .inpEmptyIndexPatternPrompt__text { + text-align: center; + align-items: center; + } +} diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx index c098e623a07b7e..e539839e46baeb 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx @@ -127,12 +127,11 @@ export const IndexPatternTable = ({ canSave, history }: Props) => { {name} +   {index.tags && index.tags.map(({ key: tagKey, name: tagName }) => ( - - {tagName} - + {tagName} ))} From 57d433aed9717876f0a03619b5e44381d22b2380 Mon Sep 17 00:00:00 2001 From: cchaos Date: Tue, 9 Jun 2020 18:14:12 -0400 Subject: [PATCH 06/76] Fixed up the wizard steps --- docs/setup/connect-to-elasticsearch.asciidoc | 2 +- .../components/header/header.tsx | 86 ++++++------ .../components/header/header.tsx | 64 ++++----- .../components/indices_list/indices_list.tsx | 2 +- .../loading_indices/loading_indices.tsx | 34 ++--- .../status_message/status_message.tsx | 49 +++---- .../step_index_pattern/step_index_pattern.tsx | 18 ++- .../advanced_options/advanced_options.tsx | 14 +- .../components/header/header.tsx | 4 +- .../components/time_field/time_field.scss | 7 - .../components/time_field/time_field.tsx | 128 ++++++++---------- .../step_time_field/step_time_field.tsx | 30 ++-- .../lib/extract_time_fields.test.ts | 2 +- .../lib/extract_time_fields.ts | 2 +- 14 files changed, 219 insertions(+), 223 deletions(-) delete mode 100644 src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.scss diff --git a/docs/setup/connect-to-elasticsearch.asciidoc b/docs/setup/connect-to-elasticsearch.asciidoc index 6137e028db3fd3..7e982ca6722f7f 100644 --- a/docs/setup/connect-to-elasticsearch.asciidoc +++ b/docs/setup/connect-to-elasticsearch.asciidoc @@ -91,7 +91,7 @@ Using a wildcard is the more popular approach. comparisons. + Kibana reads the index mapping and lists all fields that contain a timestamp. If your -index doesn't have time-based data, choose *I don't want to use the Time Filter*. +index doesn't have time-based data, choose *I don't want to use the time filter*. + You must select a time field to use global time filters on your dashboards. diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx index 35c6e67d0ea0e7..10584f0f792f12 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx @@ -17,21 +17,21 @@ * under the License. */ -import React, { Fragment } from 'react'; +import React from 'react'; import { EuiBetaBadge, EuiSpacer, EuiTitle, - EuiFlexGroup, - EuiFlexItem, EuiText, - EuiTextColor, EuiSwitch, + EuiLink, + EuiCode, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; +import { DocLinksSetup } from 'kibana/public'; import { useKibana } from '../../../../../../../plugins/kibana_react/public'; import { IndexPatternManagmentContext } from '../../../../types'; @@ -42,6 +42,7 @@ export const Header = ({ isIncludingSystemIndices, onChangeIncludingSystemIndices, isBeta = false, + docLinks, }: { prompt?: React.ReactNode; indexPatternName: string; @@ -49,6 +50,7 @@ export const Header = ({ isIncludingSystemIndices: boolean; onChangeIncludingSystemIndices: () => void; isBeta?: boolean; + docLinks: DocLinksSetup; }) => { const changeTitle = useKibana().services.chrome.docTitle.change; const createIndexPatternHeader = i18n.translate( @@ -67,53 +69,61 @@ export const Header = ({

{createIndexPatternHeader} {isBeta ? ( - + <> {' '} - + ) : null}

- - - -

- - - -

-
-
- {showSystemIndices ? ( - - - } - id="checkboxShowSystemIndices" - checked={isIncludingSystemIndices} - onChange={onChangeIncludingSystemIndices} + + +

+ multiple, + single: filebeat-4-3-22, + star: filebeat-*, + }} + /> +
+ + - - ) : null} - + +

+
+ {showSystemIndices ? ( + <> + + + } + id="checkboxShowSystemIndices" + checked={isIncludingSystemIndices} + onChange={onChangeIncludingSystemIndices} + /> + + ) : null} + {prompt ? ( - - + <> + {prompt} - + ) : null} - ); }; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx index 9ce72aeeea6e37..db6a04e1eecc1d 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx @@ -58,40 +58,37 @@ export const Header: React.FC = ({

- - + + } + fullWidth isInvalid={isInputInvalid} error={errors} helpText={ -
-

- * }} - /> -

-

- {characterList} }} - /> -

-
+ <> + * }} + />{' '} + {characterList} }} + /> + } > = ({ defaultMessage: 'index-name-*', } )} + fullWidth value={query} isInvalid={isInputInvalid} onChange={onQueryChanged} @@ -111,17 +109,21 @@ export const Header: React.FC = ({
- goToNextStep(query)} - isDisabled={isNextStepDisabled} - data-test-subj="createIndexPatternGoToStep2Button" - > - - + + goToNextStep(query)} + isDisabled={isNextStepDisabled} + data-test-subj="createIndexPatternGoToStep2Button" + > + + +
diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.tsx index c590d2a7ddfe2d..1ece749a8813bb 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.tsx @@ -199,7 +199,7 @@ export class IndicesList extends React.Component - + {rows} diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/loading_indices.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/loading_indices.tsx index 16e8d1a9f3e986..82603fd5985961 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/loading_indices.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/loading_indices.tsx @@ -19,34 +19,30 @@ import React from 'react'; -import { EuiFlexGroup, EuiFlexItem, EuiText, EuiTextColor, EuiLoadingSpinner } from '@elastic/eui'; +import { EuiFlexGroup, EuiFlexItem, EuiTitle, EuiLoadingSpinner } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; export const LoadingIndices = ({ ...rest }) => ( - + - - - - - - + +

- - - - - - - - +

+
+
+ +
); diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx index ccdd1833ea9bfb..e444e12ce19c61 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx @@ -19,7 +19,8 @@ import React from 'react'; -import { EuiText, EuiTextColor, EuiIcon } from '@elastic/eui'; +import { EuiCallOut } from '@elastic/eui'; +import { EuiIconType } from '@elastic/eui/src/components/icon/icon'; import { FormattedMessage } from '@kbn/i18n/react'; import { MatchedIndex } from '../../../../types'; @@ -41,17 +42,17 @@ export const StatusMessage: React.FC = ({ query, showSystemIndices, }) => { - let statusIcon; + let statusIcon: EuiIconType | undefined; let statusMessage; - let statusColor: 'default' | 'secondary' | undefined; + let statusColor: 'primary' | 'success' | undefined; const allIndicesLength = allIndices.length; if (query.length === 0) { - statusIcon = null; - statusColor = 'default'; + statusIcon = undefined; + statusColor = 'primary'; - if (allIndicesLength > 1) { + if (allIndicesLength >= 1) { statusMessage = ( = ({ ); @@ -83,22 +83,14 @@ export const StatusMessage: React.FC = ({ } } else if (exactMatchedIndices.length) { statusIcon = 'check'; - statusColor = 'secondary'; + statusColor = 'success'; statusMessage = (   - - - ), strongIndices: ( = ({ ); } else if (partialMatchedIndices.length) { - statusIcon = null; - statusColor = 'default'; + statusIcon = undefined; + statusColor = 'primary'; statusMessage = ( = ({ ); } else if (allIndicesLength) { - statusIcon = null; - statusColor = 'default'; + statusIcon = undefined; + statusColor = 'primary'; statusMessage = ( = ({ } return ( - - - {statusIcon ? : null} - {statusMessage} - - + ); }; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx index b6205a8731dfa9..658159fbe1e0af 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx @@ -18,7 +18,7 @@ */ import React, { Component } from 'react'; -import { EuiPanel, EuiSpacer, EuiCallOut } from '@elastic/eui'; +import { EuiSpacer, EuiCallOut } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { @@ -198,7 +198,13 @@ export class StepIndexPattern extends Component; + return ( + <> + + + + + ); } renderStatusMessage(matchedIndices: { @@ -334,15 +340,15 @@ export class StepIndexPattern extends Component + <> {this.renderHeader(matchedIndices)} - + {this.renderLoadingState()} {this.renderIndexPatternExists()} {this.renderStatusMessage(matchedIndices)} - + {this.renderList(matchedIndices)} - + ); } } diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.tsx index b8f34095743ba0..ea1fd4cce5fc71 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.tsx @@ -19,7 +19,14 @@ import React from 'react'; -import { EuiForm, EuiFormRow, EuiFieldText, EuiButtonEmpty, EuiSpacer } from '@elastic/eui'; +import { + EuiForm, + EuiFormRow, + EuiFieldText, + EuiButtonEmpty, + EuiSpacer, + EuiHorizontalRule, +} from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; @@ -38,6 +45,7 @@ export const AdvancedOptions: React.FC = ({ onChangeIndexPatternId, }) => (
+ = ({ {isVisible ? ( ) : ( )} diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/header/header.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/header/header.tsx index 22e245f7ac1370..530d0688b61ca6 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/header/header.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/header/header.tsx @@ -39,10 +39,10 @@ export const Header: React.FC = ({ indexPattern, indexPatternName }

- + {indexPattern}, indexPatternName, diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.scss b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.scss deleted file mode 100644 index 5bd60e8b76afc4..00000000000000 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.scss +++ /dev/null @@ -1,7 +0,0 @@ -/** - * 1. Bring the line-height down or else this link expands its container when it becomes visible. - */ - -.timeFieldRefreshButton { - line-height: 1 !important; /* 1 */ -} diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.tsx index b4ed37118966ba..1eae1055ac5efa 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.tsx @@ -17,15 +17,12 @@ * under the License. */ -import './time_field.scss'; - import React from 'react'; import { EuiForm, EuiFormRow, - EuiFlexGroup, - EuiFlexItem, + EuiSpacer, EuiLink, EuiSelect, EuiText, @@ -54,77 +51,68 @@ export const TimeField: React.FC = ({ }) => ( {isVisible ? ( - - - - - - - - {isLoading ? ( - - ) : ( - + <> + +

+ +

+
+ + + } + labelAppend={ + isLoading ? ( + + ) : ( + + - )} -
- - } - helpText={ -
-

- -

-

- -

-
- } - > - {isLoading ? ( - - ) : ( - - )} -
+ + ) + } + > + {isLoading ? ( + + ) : ( + + )} + + ) : (

diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx index 98ce22cd14227c..4511fd23f5294f 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx @@ -22,8 +22,7 @@ import { EuiCallOut, EuiFlexGroup, EuiFlexItem, - EuiPanel, - EuiText, + EuiTitle, EuiSpacer, EuiLoadingSpinner, } from '@elastic/eui'; @@ -183,21 +182,22 @@ export class StepTimeField extends Component - - - - - - + + + +

- - - - +

+ +
+ + + + + ); } @@ -236,7 +236,7 @@ export class StepTimeField extends Component + <>
- + ); } } diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/extract_time_fields.test.ts b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/extract_time_fields.test.ts index 4cd28090420a7e..8f3765b7b5dcc5 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/extract_time_fields.test.ts +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/extract_time_fields.test.ts @@ -37,7 +37,7 @@ describe('extractTimeFields', () => { expect(extractTimeFields(fields)).toEqual([ { display: '@timestamp', fieldName: '@timestamp' }, { isDisabled: true, display: '───', fieldName: '' }, - { display: `I don't want to use the Time Filter`, fieldName: undefined }, + { display: `I don't want to use the time filter`, fieldName: undefined }, ]); }); }); diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/extract_time_fields.ts b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/extract_time_fields.ts index b7056ad17343af..efac21245c2578 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/extract_time_fields.ts +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/extract_time_fields.ts @@ -45,7 +45,7 @@ export function extractTimeFields(fields: IFieldType[]) { const noTimeFieldLabel = i18n.translate( 'indexPatternManagement.createIndexPattern.stepTime.noTimeFieldOptionLabel', { - defaultMessage: "I don't want to use the Time Filter", + defaultMessage: "I don't want to use the time filter", } ); const noTimeFieldOption = { From 143b0c09da11a39cdf67ea8ed59f61b14c841de8 Mon Sep 17 00:00:00 2001 From: cchaos Date: Wed, 10 Jun 2020 16:25:36 -0400 Subject: [PATCH 07/76] Last bits of cleanup in a few views --- .../ensure_default_index_pattern.tsx | 2 +- .../edit_index_pattern/edit_index_pattern.tsx | 105 ++++++++---------- .../index_header/index_header.tsx | 19 +--- .../edit_index_pattern/tabs/tabs.tsx | 1 + 4 files changed, 56 insertions(+), 71 deletions(-) diff --git a/src/plugins/data/public/index_patterns/index_patterns/ensure_default_index_pattern.tsx b/src/plugins/data/public/index_patterns/index_patterns/ensure_default_index_pattern.tsx index 2088bd8c925df9..eb9a4ffabe5ba4 100644 --- a/src/plugins/data/public/index_patterns/index_patterns/ensure_default_index_pattern.tsx +++ b/src/plugins/data/public/index_patterns/index_patterns/ensure_default_index_pattern.tsx @@ -71,7 +71,7 @@ export const createEnsureDefaultIndexPattern = (core: CoreStart) => { 'data.indexPatterns.ensureDefaultIndexPattern.bannerLabel', { defaultMessage: - "In order to visualize and explore data in Kibana, you'll need to create an index pattern to retrieve data from Elasticsearch.", + 'To visualize and explore data in Kibana, you must create an index pattern to retrieve data from Elasticsearch.', } ); diff --git a/src/plugins/index_pattern_management/public/components/edit_index_pattern/edit_index_pattern.tsx b/src/plugins/index_pattern_management/public/components/edit_index_pattern/edit_index_pattern.tsx index eab8b2c231c9ca..425873fa872d94 100644 --- a/src/plugins/index_pattern_management/public/components/edit_index_pattern/edit_index_pattern.tsx +++ b/src/plugins/index_pattern_management/public/components/edit_index_pattern/edit_index_pattern.tsx @@ -154,7 +154,7 @@ export const EditIndexPattern = withRouter( const timeFilterHeader = i18n.translate( 'indexPatternManagement.editIndexPattern.timeFilterHeader', { - defaultMessage: "Time Filter field name: '{timeFieldName}'", + defaultMessage: "Time field: '{timeFieldName}'", values: { timeFieldName: indexPattern.timeFieldName }, } ); @@ -179,62 +179,55 @@ export const EditIndexPattern = withRouter( return (
- - - - - {showTagsSection && ( - - {Boolean(indexPattern.timeFieldName) && ( - - {timeFilterHeader} - - )} - {tags.map((tag: any) => ( - - {tag.name} - - ))} - + + + {showTagsSection && ( + + {Boolean(indexPattern.timeFieldName) && ( + + {timeFilterHeader} + )} - - -

- {indexPattern.title} }} - />{' '} - - {mappingAPILink} - - -

-
- {conflictedFields.length > 0 && ( - -

{mappingConflictLabel}

-
- )} -
- - - -
+ {tags.map((tag: any) => ( + + {tag.name} + + ))} + + )} + + +

+ {indexPattern.title} }} + />{' '} + + {mappingAPILink} + +

+
+ {conflictedFields.length > 0 && ( + <> + + +

{mappingConflictLabel}

+
+ + )} + +
); diff --git a/src/plugins/index_pattern_management/public/components/edit_index_pattern/index_header/index_header.tsx b/src/plugins/index_pattern_management/public/components/edit_index_pattern/index_header/index_header.tsx index 4cf43d63d58397..7790d41e1ce4a4 100644 --- a/src/plugins/index_pattern_management/public/components/edit_index_pattern/index_header/index_header.tsx +++ b/src/plugins/index_pattern_management/public/components/edit_index_pattern/index_header/index_header.tsx @@ -77,22 +77,13 @@ export function IndexHeader({ return ( - - {defaultIndex === indexPattern.id && ( - - - - )} - - -

{indexPattern.title}

-
-
-
+ +

{indexPattern.title}

+
- - {setDefault && ( + + {defaultIndex !== indexPattern.id && setDefault && ( setFieldFilter(e.target.value)} From 67c73c89932cbc57d42db69c7b2f7d4ca5411ed1 Mon Sep 17 00:00:00 2001 From: cchaos Date: Wed, 10 Jun 2020 16:56:33 -0400 Subject: [PATCH 08/76] Fix illustration in dark mode and (most) snaps --- .../create_index_pattern_wizard.test.tsx.snap | 566 ++++++++++++++++-- .../header/__snapshots__/header.test.tsx.snap | 196 +++--- .../__snapshots__/indices_list.test.tsx.snap | 25 +- .../loading_indices.test.tsx.snap | 46 +- .../status_message.test.tsx.snap | 85 +-- .../step_time_field.test.tsx.snap | 81 ++- .../advanced_options.test.tsx.snap | 6 +- .../header/__snapshots__/header.test.tsx.snap | 6 +- .../__snapshots__/time_field.test.tsx.snap | 212 +++---- .../assets/index_pattern_illustration.js | 9 +- .../assets/index_pattern_illustration.scss | 6 +- .../empty_index_pattern_prompt.scss | 2 + .../empty_index_pattern_prompt.test.tsx | 7 +- .../scripting_help/test_script.scss | 2 +- 14 files changed, 809 insertions(+), 440 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.tsx.snap index 5c955bbd3283ec..4aba95d447de47 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.tsx.snap @@ -1,34 +1,116 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`CreateIndexPatternWizard defaults to the loading state 1`] = ` - -
-
- -
+ + -
+ `; exports[`CreateIndexPatternWizard renders index pattern step when there are indices 1`] = ` - -
+ +
+ -
+ -
+ `; exports[`CreateIndexPatternWizard renders the empty state when there are no indices 1`] = ` - -
-
- -
+ + -
+ `; exports[`CreateIndexPatternWizard renders time field step when step is set to 2 1`] = ` - -
+ +
+ -
+ -
+ `; exports[`CreateIndexPatternWizard renders when there are no indices but there are remote clusters 1`] = ` - -
+ +
+ -
+ -
+ `; exports[`CreateIndexPatternWizard shows system indices even if there are no other indices if the include system indices is toggled 1`] = ` - -
+ +
+ -
+ -
+ `; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/__snapshots__/header.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/__snapshots__/header.test.tsx.snap index 3021292953ff5c..851e5cc4c2a762 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/__snapshots__/header.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/__snapshots__/header.test.tsx.snap @@ -7,7 +7,7 @@ exports[`Header should mark the input as invalid 1`] = ` >

@@ -16,13 +16,8 @@ exports[`Header should mark the input as invalid 1`] = ` - - + + @@ -34,43 +29,40 @@ exports[`Header should mark the input as invalid 1`] = ` "Input is invalid", ] } - fullWidth={false} + fullWidth={true} hasChildLabel={true} hasEmptyLabelSpace={false} helpText={ -
-

- - * - , - } + + + * + , } - /> -

-

- - % - , - } + } + /> + + + % + , } - /> -

-
+ } + /> + } isInvalid={true} label={ @@ -79,6 +71,7 @@ exports[`Header should mark the input as invalid 1`] = ` > - - - + + + +
@@ -115,7 +119,7 @@ exports[`Header should render normally 1`] = ` >

@@ -124,13 +128,8 @@ exports[`Header should render normally 1`] = ` - - + + @@ -138,43 +137,40 @@ exports[`Header should render normally 1`] = ` describedByIds={Array []} display="row" error={Array []} - fullWidth={false} + fullWidth={true} hasChildLabel={true} hasEmptyLabelSpace={false} helpText={ -
-

- - * - , - } + + + * + , } - /> -

-

- - % - , - } + } + /> + + + % + , } - /> -

-
+ } + /> + } isInvalid={false} label={ @@ -183,6 +179,7 @@ exports[`Header should render normally 1`] = ` > - - - + + + +
diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/__snapshots__/indices_list.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/__snapshots__/indices_list.test.tsx.snap index 598de4d90e8932..6631a9bbd1d02b 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/__snapshots__/indices_list.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/__snapshots__/indices_list.test.tsx.snap @@ -2,7 +2,10 @@ exports[`IndicesList should change pages 1`] = `
- + - + - + - + - + - - - - - - - - - - - - +

+ +
+ +
`; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__snapshots__/status_message.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__snapshots__/status_message.test.tsx.snap index 4a063f1430d1c0..925aaf341a7a3b 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__snapshots__/status_message.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__snapshots__/status_message.test.tsx.snap @@ -1,20 +1,16 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`StatusMessage should render with exact matches 1`] = ` - - - + title={   , - "strongSuccess": - - , } } /> - - + } +/> `; exports[`StatusMessage should render with no partial matches 1`] = ` - - + title={ - - + } +/> `; exports[`StatusMessage should render with partial matches 1`] = ` - - + title={ - - + } +/> `; exports[`StatusMessage should render without a query 1`] = ` - - + title={ - - + } +/> `; exports[`StatusMessage should show that no indices exist 1`] = ` - - + title={ - - + } +/> `; exports[`StatusMessage should show that system indices exist 1`] = ` - - + title={ - - + } +/> `; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/__snapshots__/step_time_field.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/__snapshots__/step_time_field.test.tsx.snap index f865a1ddfd2233..e1e439dfd65d35 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/__snapshots__/step_time_field.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/__snapshots__/step_time_field.test.tsx.snap @@ -17,9 +17,7 @@ exports[`StepTimeField should enable the action button if the user decides to no `; exports[`StepTimeField should render "Custom index pattern ID already exists" when error is "Conflict" 1`] = ` - +
- + `; exports[`StepTimeField should render a loading state when creating the index pattern 1`] = ` - - + - - - - - +

- - - - +

+ +
+ + + +
`; exports[`StepTimeField should render a selected timeField 1`] = ` - +
- + `; exports[`StepTimeField should render advanced options 1`] = ` - +
- + `; exports[`StepTimeField should render advanced options with an index pattern id 1`] = ` - +
- + `; exports[`StepTimeField should render any error message 1`] = ` - +
- + `; exports[`StepTimeField should render normally 1`] = ` - +
- + `; exports[`StepTimeField should render timeFields 1`] = ` - +
- + `; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/advanced_options/__snapshots__/advanced_options.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/advanced_options/__snapshots__/advanced_options.test.tsx.snap index d1b10fb532020a..a844d95d85a230 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/advanced_options/__snapshots__/advanced_options.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/advanced_options/__snapshots__/advanced_options.test.tsx.snap @@ -2,12 +2,13 @@ exports[`AdvancedOptions should hide if not showing 1`] = `
+ @@ -20,12 +21,13 @@ exports[`AdvancedOptions should hide if not showing 1`] = ` exports[`AdvancedOptions should render normally 1`] = `
+ diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/header/__snapshots__/header.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/header/__snapshots__/header.test.tsx.snap index 63008ec5b52e79..9efda4fdac7f91 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/header/__snapshots__/header.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/header/__snapshots__/header.test.tsx.snap @@ -16,11 +16,9 @@ exports[`Header should render normally 1`] = ` - + + +

+ +

+
+ -

- -

-

- -

-
- } label={ - - - - - - - - - - + + } + labelAppend={ + } labelType="label" > @@ -73,62 +51,43 @@ exports[`TimeField should render a loading state 1`] = ` exports[`TimeField should render a selected time field 1`] = ` + +

+ +

+
+ -

- -

-

- -

-
- } label={ - + } + labelAppend={ + - - - - - - - - - - - + + + } labelType="label" > @@ -154,62 +113,43 @@ exports[`TimeField should render a selected time field 1`] = ` exports[`TimeField should render normally 1`] = ` + +

+ +

+
+ -

- -

-

- -

- - } label={ - + } + labelAppend={ + - - - - - - - - - - - + + + } labelType="label" > diff --git a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/assets/index_pattern_illustration.js b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/assets/index_pattern_illustration.js index a77419aaccce89..2461c0f5df9194 100644 --- a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/assets/index_pattern_illustration.js +++ b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/assets/index_pattern_illustration.js @@ -393,11 +393,6 @@ const IndexPatternIllustration = () => ( - @@ -407,11 +402,11 @@ const IndexPatternIllustration = () => ( d="M144.467 20.225c13-15 39.55-15.93 53.23-1.19 6.52 7 10.22 17 10.53 26.51.19 4.85-.61 9.688-2.35 14.22-2.3 5.83-6.34 9.82-10.37 14.43a.759.759 0 00.92 1.19c9.84-5.32 14.4-18 14.33-28.61-.07-10.61-4.12-21.65-11.4-29.41-14.57-15.53-42.56-14.37-55.4 2.46-.23.3.27.68.51.4z" /> - + - + diff --git a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/assets/index_pattern_illustration.scss b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/assets/index_pattern_illustration.scss index ad81bd67421121..cd0477aba7adf2 100644 --- a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/assets/index_pattern_illustration.scss +++ b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/assets/index_pattern_illustration.scss @@ -1,11 +1,9 @@ -$lightShadow: #ECF0F6; - .indexPatternIllustration { &__verticalStripes { - fill: lightOrDarkTheme($euiColorEmptyShade, $euiColorFullShade); + fill: $euiColorFullShade; } &__dots { - fill: lightOrDarkTheme($lightShadow, $euiShadowColor); + fill: $euiColorLightShade; } } diff --git a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.scss b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.scss index d8c3f7327ef950..f6db2fc89f353a 100644 --- a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.scss +++ b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.scss @@ -8,6 +8,8 @@ .inpEmptyIndexPatternPrompt__footer { @extend %inp-empty-state-footer; + // override EUI specificity + align-items: baseline !important; // sass-lint:disable-line no-important } .inpEmptyIndexPatternPrompt__title { diff --git a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx index db0edaa628cf71..af8dd860db2a8f 100644 --- a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx +++ b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx @@ -22,10 +22,9 @@ import { EmptyIndexPatternPrompt } from '../empty_index_pattern_prompt'; import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; describe('EmptyIndexPatternPrompt', () => { - it('should render normally', () => { - const component = shallowWithI18nProvider( - - ); + /** HELP */ + it.skip('should render normally', () => { + const component = shallowWithI18nProvider(); expect(component).toMatchSnapshot(); }); diff --git a/src/plugins/index_pattern_management/public/components/field_editor/components/scripting_help/test_script.scss b/src/plugins/index_pattern_management/public/components/field_editor/components/scripting_help/test_script.scss index 34e8a60d070745..ca230711827dc7 100644 --- a/src/plugins/index_pattern_management/public/components/field_editor/components/scripting_help/test_script.scss +++ b/src/plugins/index_pattern_management/public/components/field_editor/components/scripting_help/test_script.scss @@ -1,5 +1,5 @@ .testScript__searchBar { - .globalQueryBar { + .globalQueryBar { padding: $euiSize 0 0; } } From 46aad269a4eebbaa54406790243a36743952069e Mon Sep 17 00:00:00 2001 From: cchaos Date: Wed, 10 Jun 2020 17:06:37 -0400 Subject: [PATCH 09/76] Update API docs --- .../public/kibana-plugin-core-public.doclinkssetup.links.md | 1 + .../core/public/kibana-plugin-core-public.doclinkssetup.md | 2 +- src/core/public/public.api.md | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/development/core/public/kibana-plugin-core-public.doclinkssetup.links.md b/docs/development/core/public/kibana-plugin-core-public.doclinkssetup.links.md index fd05ae139ba215..a6bb32e2022f87 100644 --- a/docs/development/core/public/kibana-plugin-core-public.doclinkssetup.links.md +++ b/docs/development/core/public/kibana-plugin-core-public.doclinkssetup.links.md @@ -78,6 +78,7 @@ readonly links: { readonly loadingData: string; readonly introduction: string; }; + readonly addData: string; readonly kibana: string; readonly siem: { readonly guide: string; diff --git a/docs/development/core/public/kibana-plugin-core-public.doclinkssetup.md b/docs/development/core/public/kibana-plugin-core-public.doclinkssetup.md index 1114e05589c4b7..8960a5dceec58c 100644 --- a/docs/development/core/public/kibana-plugin-core-public.doclinkssetup.md +++ b/docs/development/core/public/kibana-plugin-core-public.doclinkssetup.md @@ -17,5 +17,5 @@ export interface DocLinksSetup | --- | --- | --- | | [DOC\_LINK\_VERSION](./kibana-plugin-core-public.doclinkssetup.doc_link_version.md) | string | | | [ELASTIC\_WEBSITE\_URL](./kibana-plugin-core-public.doclinkssetup.elastic_website_url.md) | string | | -| [links](./kibana-plugin-core-public.doclinkssetup.links.md) | {
readonly filebeat: {
readonly base: string;
readonly installation: string;
readonly configuration: string;
readonly elasticsearchOutput: string;
readonly startup: string;
readonly exportedFields: string;
};
readonly auditbeat: {
readonly base: string;
};
readonly metricbeat: {
readonly base: string;
};
readonly heartbeat: {
readonly base: string;
};
readonly logstash: {
readonly base: string;
};
readonly functionbeat: {
readonly base: string;
};
readonly winlogbeat: {
readonly base: string;
};
readonly aggs: {
readonly date_histogram: string;
readonly date_range: string;
readonly filter: string;
readonly filters: string;
readonly geohash_grid: string;
readonly histogram: string;
readonly ip_range: string;
readonly range: string;
readonly significant_terms: string;
readonly terms: string;
readonly avg: string;
readonly avg_bucket: string;
readonly max_bucket: string;
readonly min_bucket: string;
readonly sum_bucket: string;
readonly cardinality: string;
readonly count: string;
readonly cumulative_sum: string;
readonly derivative: string;
readonly geo_bounds: string;
readonly geo_centroid: string;
readonly max: string;
readonly median: string;
readonly min: string;
readonly moving_avg: string;
readonly percentile_ranks: string;
readonly serial_diff: string;
readonly std_dev: string;
readonly sum: string;
readonly top_hits: string;
};
readonly scriptedFields: {
readonly scriptFields: string;
readonly scriptAggs: string;
readonly painless: string;
readonly painlessApi: string;
readonly painlessSyntax: string;
readonly luceneExpressions: string;
};
readonly indexPatterns: {
readonly loadingData: string;
readonly introduction: string;
};
readonly kibana: string;
readonly siem: {
readonly guide: string;
readonly gettingStarted: string;
};
readonly query: {
readonly luceneQuerySyntax: string;
readonly queryDsl: string;
readonly kueryQuerySyntax: string;
};
readonly date: {
readonly dateMath: string;
};
readonly management: Record<string, string>;
} | | +| [links](./kibana-plugin-core-public.doclinkssetup.links.md) | {
readonly filebeat: {
readonly base: string;
readonly installation: string;
readonly configuration: string;
readonly elasticsearchOutput: string;
readonly startup: string;
readonly exportedFields: string;
};
readonly auditbeat: {
readonly base: string;
};
readonly metricbeat: {
readonly base: string;
};
readonly heartbeat: {
readonly base: string;
};
readonly logstash: {
readonly base: string;
};
readonly functionbeat: {
readonly base: string;
};
readonly winlogbeat: {
readonly base: string;
};
readonly aggs: {
readonly date_histogram: string;
readonly date_range: string;
readonly filter: string;
readonly filters: string;
readonly geohash_grid: string;
readonly histogram: string;
readonly ip_range: string;
readonly range: string;
readonly significant_terms: string;
readonly terms: string;
readonly avg: string;
readonly avg_bucket: string;
readonly max_bucket: string;
readonly min_bucket: string;
readonly sum_bucket: string;
readonly cardinality: string;
readonly count: string;
readonly cumulative_sum: string;
readonly derivative: string;
readonly geo_bounds: string;
readonly geo_centroid: string;
readonly max: string;
readonly median: string;
readonly min: string;
readonly moving_avg: string;
readonly percentile_ranks: string;
readonly serial_diff: string;
readonly std_dev: string;
readonly sum: string;
readonly top_hits: string;
};
readonly scriptedFields: {
readonly scriptFields: string;
readonly scriptAggs: string;
readonly painless: string;
readonly painlessApi: string;
readonly painlessSyntax: string;
readonly luceneExpressions: string;
};
readonly indexPatterns: {
readonly loadingData: string;
readonly introduction: string;
};
readonly addData: string;
readonly kibana: string;
readonly siem: {
readonly guide: string;
readonly gettingStarted: string;
};
readonly query: {
readonly luceneQuerySyntax: string;
readonly queryDsl: string;
readonly kueryQuerySyntax: string;
};
readonly date: {
readonly dateMath: string;
};
readonly management: Record<string, string>;
} | | diff --git a/src/core/public/public.api.md b/src/core/public/public.api.md index 74c41d010ca8db..05a39b8162e7e0 100644 --- a/src/core/public/public.api.md +++ b/src/core/public/public.api.md @@ -556,6 +556,7 @@ export interface DocLinksSetup { readonly loadingData: string; readonly introduction: string; }; + readonly addData: string; readonly kibana: string; readonly siem: { readonly guide: string; From 4b336df0d3a1ef9a3e8fceec5853013621ce3006 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Mon, 29 Jun 2020 17:11:16 -0500 Subject: [PATCH 10/76] use new endpoint --- .../index_pattern_management/kibana.json | 2 +- .../step_index_pattern/step_index_pattern.tsx | 16 +--- .../create_index_pattern_wizard.tsx | 9 +-- .../lib/get_indices.ts | 76 +++++++++---------- .../create_index_pattern_wizard/types.ts | 32 ++++++++ .../index_pattern_management/server/index.ts | 26 +++++++ .../index_pattern_management/server/plugin.ts | 51 +++++++++++++ 7 files changed, 149 insertions(+), 63 deletions(-) create mode 100644 src/plugins/index_pattern_management/server/index.ts create mode 100644 src/plugins/index_pattern_management/server/plugin.ts diff --git a/src/plugins/index_pattern_management/kibana.json b/src/plugins/index_pattern_management/kibana.json index 364edbb030dc99..23adef2626a72b 100644 --- a/src/plugins/index_pattern_management/kibana.json +++ b/src/plugins/index_pattern_management/kibana.json @@ -1,7 +1,7 @@ { "id": "indexPatternManagement", "version": "kibana", - "server": false, + "server": true, "ui": true, "requiredPlugins": ["management", "data", "kibanaLegacy"] } diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx index b6205a8731dfa9..ccfb18e668077b 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx @@ -128,12 +128,7 @@ export class StepIndexPattern extends Component diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.ts b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.ts index 9f75dc39a654c2..ca081df1dd4218 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.ts +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.ts @@ -18,12 +18,18 @@ */ import { get, sortBy } from 'lodash'; +import { HttpStart } from 'kibana/public'; +import { i18n } from '@kbn/i18n'; import { IndexPatternCreationConfig } from '../../../../../index_pattern_management/public'; -import { DataPublicPluginStart } from '../../../../../data/public'; -import { MatchedIndex } from '../types'; +import { MatchedIndex, ResolveIndexResponse } from '../types'; + +const aliasLabel = i18n.translate('indexPatternManagement.aliasLabel', { defaultMessage: 'Alias' }); +const dataStreamLabel = i18n.translate('indexPatternManagement.aliasLabel', { + defaultMessage: 'Data stream', +}); export async function getIndices( - es: DataPublicPluginStart['search']['__LEGACY']['esClient'], + http: HttpStart, indexPatternCreationType: IndexPatternCreationConfig, rawPattern: string, limit: number @@ -48,47 +54,14 @@ export async function getIndices( return []; } - // We need to always provide a limit and not rely on the default - if (!limit) { - throw new Error('`getIndices()` was called without the required `limit` parameter.'); - } - - const params = { - ignoreUnavailable: true, - index: pattern, - ignore: [404], - body: { - size: 0, // no hits - aggs: { - indices: { - terms: { - field: '_index', - size: limit, - }, - }, - }, - }, - }; - try { - const response = await es.search(params); - if (!response || response.error || !response.aggregations) { - return []; - } - - return sortBy( - response.aggregations.indices.buckets - .map((bucket: { key: string; doc_count: number }) => { - return bucket.key; - }) - .map((indexName: string) => { - return { - name: indexName, - tags: indexPatternCreationType.getIndexTags(indexName), - }; - }), - 'name' + const response = await http.get( + `/api/index-pattern-management/resolve_index/*`, + { + // prependBasePath: false, + } ); + return responseToItemArray(response, indexPatternCreationType); } catch (err) { const type = get(err, 'body.error.caused_by.type'); if (type === 'index_not_found_exception') { @@ -99,3 +72,22 @@ export async function getIndices( throw err; } } + +const responseToItemArray = ( + response: ResolveIndexResponse, + indexPatternCreationType: IndexPatternCreationConfig +): MatchedIndex[] => { + const source: MatchedIndex[] = []; + + response.indices.forEach((index) => { + source.push({ name: index.name, tags: indexPatternCreationType.getIndexTags(index.name) }); + }); + response.aliases.forEach((alias) => { + source.push({ name: alias.name, tags: [{ key: 'alias', name: aliasLabel }] }); + }); + response.data_streams.forEach((dataStream) => { + source.push({ name: dataStream.name, tags: [{ key: 'data_stream', name: dataStreamLabel }] }); + }); + + return sortBy(source, 'name'); +}; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/types.ts b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/types.ts index 634bbd856ea862..d595052d8f67f8 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/types.ts +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/types.ts @@ -22,6 +22,38 @@ export interface MatchedIndex { tags: Tag[]; } +export interface ResolveIndexResponse { + indices: ResolveIndexResponseItemIndex[]; + aliases: ResolveIndexResponseItemAlias[]; + data_streams: ResolveIndexResponseItemDataStream[]; +} + +export interface ResolveIndexResponseItem { + name: string; +} + +export interface ResolveIndexResponseItemDataStream extends ResolveIndexResponseItem { + backing_indices: string[]; + timestamp_field: string; +} + +export interface ResolveIndexResponseItemAlias extends ResolveIndexResponseItem { + indices: string[]; +} + +export interface ResolveIndexResponseItemIndex extends ResolveIndexResponseItem { + aliases?: string[]; + attributes?: ResolveIndexResponseItemIndexAttrs[]; + data_stream?: string; +} + +enum ResolveIndexResponseItemIndexAttrs { + OPEN = 'open', + CLOSED = 'closed', + HIDDEN = 'hidden', + FROZEN = 'frozen', +} + export interface Tag { name: string; key: string; diff --git a/src/plugins/index_pattern_management/server/index.ts b/src/plugins/index_pattern_management/server/index.ts new file mode 100644 index 00000000000000..a7c2bf18e5ada5 --- /dev/null +++ b/src/plugins/index_pattern_management/server/index.ts @@ -0,0 +1,26 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { PluginInitializerContext } from 'src/core/server'; +import { IndexPatternManagementPlugin } from './plugin'; +// export { IndexPatternManagementSetup, IndexPatternManagementStart } from './plugin'; + +export function plugin(initializerContext: PluginInitializerContext) { + return new IndexPatternManagementPlugin(initializerContext); +} diff --git a/src/plugins/index_pattern_management/server/plugin.ts b/src/plugins/index_pattern_management/server/plugin.ts new file mode 100644 index 00000000000000..a197246dfcc838 --- /dev/null +++ b/src/plugins/index_pattern_management/server/plugin.ts @@ -0,0 +1,51 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { PluginInitializerContext, CoreSetup, Plugin } from 'src/core/server'; +import { schema } from '@kbn/config-schema'; + +export class IndexPatternManagementPlugin implements Plugin { + constructor(initializerContext: PluginInitializerContext) {} + + public setup(core: CoreSetup) { + const router = core.http.createRouter(); + + router.get( + { + path: `/api/index-pattern-management/resolve_index/{query}`, + validate: { + params: schema.object({ + query: schema.string(), + }), + }, + }, + async (context, req, res) => { + const result = await context.core.elasticsearch.legacy.client.callAsCurrentUser( + 'transport.request', + { method: 'GET', path: `/_resolve/index/${req.params.query}` } + ); + return res.ok({ body: result }); + } + ); + } + + public start() {} + + public stop() {} +} From fd159e319bf5ef15495ac35e40fcfd1c413c006e Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Wed, 1 Jul 2020 13:23:26 -0500 Subject: [PATCH 11/76] appears to work, needs design tweaks --- .../indices_list/indices_list.test.tsx | 5 +- .../components/indices_list/indices_list.tsx | 4 +- .../status_message/status_message.test.tsx | 11 +- .../status_message/status_message.tsx | 8 +- .../step_index_pattern/step_index_pattern.tsx | 73 +++++++++--- .../step_time_field/step_time_field.tsx | 4 +- .../create_index_pattern_wizard.tsx | 31 +++-- .../lib/get_indices.test.ts | 111 ++++++++++++------ .../lib/get_indices.ts | 31 +++-- .../lib/get_matched_indices.test.ts | 8 +- .../lib/get_matched_indices.ts | 10 +- .../create_index_pattern_wizard/types.ts | 6 +- .../public/service/creation/config.ts | 4 +- .../index_pattern_management/server/plugin.ts | 17 ++- 14 files changed, 218 insertions(+), 105 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.test.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.test.tsx index d8a1d1a0ab72ff..fbd60cbe3d131a 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.test.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.test.tsx @@ -20,11 +20,12 @@ import React from 'react'; import { IndicesList } from '../indices_list'; import { shallow } from 'enzyme'; +import { MatchedItem } from '../../../../types'; -const indices = [ +const indices = ([ { name: 'kibana', tags: [] }, { name: 'es', tags: [] }, -]; +] as unknown) as MatchedItem[]; describe('IndicesList', () => { it('should render normally', () => { diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.tsx index c590d2a7ddfe2d..ea8eb975e9381c 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.tsx @@ -39,10 +39,10 @@ import { Pager } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { PER_PAGE_INCREMENTS } from '../../../../constants'; -import { MatchedIndex, Tag } from '../../../../types'; +import { MatchedItem, Tag } from '../../../../types'; interface IndicesListProps { - indices: MatchedIndex[]; + indices: MatchedItem[]; query: string; } diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.test.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.test.tsx index 899c21d59c5bc3..f97c9ffe8a364f 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.test.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.test.tsx @@ -20,18 +20,19 @@ import React from 'react'; import { StatusMessage } from '../status_message'; import { shallow } from 'enzyme'; +import { MatchedItem } from '../../../../types'; const tagsPartial = { tags: [], }; const matchedIndices = { - allIndices: [ + allIndices: ([ { name: 'kibana', ...tagsPartial }, { name: 'es', ...tagsPartial }, - ], - exactMatchedIndices: [], - partialMatchedIndices: [{ name: 'kibana', ...tagsPartial }], + ] as unknown) as MatchedItem[], + exactMatchedIndices: [] as MatchedItem[], + partialMatchedIndices: ([{ name: 'kibana', ...tagsPartial }] as unknown) as MatchedItem[], }; describe('StatusMessage', () => { @@ -51,7 +52,7 @@ describe('StatusMessage', () => { it('should render with exact matches', () => { const localMatchedIndices = { ...matchedIndices, - exactMatchedIndices: [{ name: 'kibana', ...tagsPartial }], + exactMatchedIndices: ([{ name: 'kibana', ...tagsPartial }] as unknown) as MatchedItem[], }; const component = shallow( diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx index ccdd1833ea9bfb..112c1fe0aa1d07 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx @@ -22,13 +22,13 @@ import React from 'react'; import { EuiText, EuiTextColor, EuiIcon } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -import { MatchedIndex } from '../../../../types'; +import { MatchedItem } from '../../../../types'; interface StatusMessageProps { matchedIndices: { - allIndices: MatchedIndex[]; - exactMatchedIndices: MatchedIndex[]; - partialMatchedIndices: MatchedIndex[]; + allIndices: MatchedItem[]; + exactMatchedIndices: MatchedItem[]; + partialMatchedIndices: MatchedItem[]; }; isIncludingSystemIndices: boolean; query: string; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx index ccfb18e668077b..05a91fdd326a18 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx @@ -26,7 +26,6 @@ import { IndexPatternAttributes, UI_SETTINGS, } from '../../../../../../../plugins/data/public'; -import { MAX_SEARCH_SIZE } from '../../constants'; import { getIndices, containsIllegalCharacters, @@ -40,20 +39,20 @@ import { IndicesList } from './components/indices_list'; import { Header } from './components/header'; import { context as contextType } from '../../../../../../kibana_react/public'; import { IndexPatternCreationConfig } from '../../../../../../../plugins/index_pattern_management/public'; -import { MatchedIndex } from '../../types'; +import { MatchedItem, ResolveIndexResponseItemDataStream } from '../../types'; import { IndexPatternManagmentContextValue } from '../../../../types'; interface StepIndexPatternProps { - allIndices: MatchedIndex[]; + allIndices: MatchedItem[]; isIncludingSystemIndices: boolean; indexPatternCreationType: IndexPatternCreationConfig; - goToNextStep: (query: string) => void; + goToNextStep: (query: string, timestampField?: string) => void; initialQuery?: string; } interface StepIndexPatternState { - partialMatchedIndices: MatchedIndex[]; - exactMatchedIndices: MatchedIndex[]; + partialMatchedIndices: MatchedItem[]; + exactMatchedIndices: MatchedItem[]; isLoadingIndices: boolean; existingIndexPatterns: string[]; indexPatternExists: boolean; @@ -128,7 +127,12 @@ export class StepIndexPattern extends Component 0; const isNextStepDisabled = containsErrors || indices.length === 0 || indexPatternExists; + // todo define next step OR create index pattern. + // look at matched indices + // if all are data streams with same time field then create index pattern + const { + allMatchingDataStreams: uniformDataStreams, + timeFieldName: matchingTimestamp, + } = indices.reduce( + ( + { + allMatchingDataStreams, + timeFieldName, + }: { allMatchingDataStreams: boolean; timeFieldName?: string }, + matchedItem + ) => { + const dataStreamItem = matchedItem.item as ResolveIndexResponseItemDataStream; + const dataStreamTimestampField = dataStreamItem.timestamp_field; + const isDataStream = !!dataStreamItem.timestamp_field; + const timestampFieldMatches = + timeFieldName === undefined || timeFieldName === dataStreamTimestampField; + + return { + allMatchingDataStreams: allMatchingDataStreams && isDataStream && timestampFieldMatches, + timeFieldName: dataStreamTimestampField || timeFieldName, + }; + }, + { + allMatchingDataStreams: true, + timeFieldName: undefined, + } + ); + return (
goToNextStep(query, uniformDataStreams ? matchingTimestamp : undefined)} + // goToNextStep={nextStepOrCreate} isNextStepDisabled={isNextStepDisabled} /> ); diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx index 98ce22cd14227c..febb95d56c1a7f 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx @@ -43,6 +43,7 @@ interface StepTimeFieldProps { goToPreviousStep: () => void; createIndexPattern: (selectedTimeField: string | undefined, indexPatternId: string) => void; indexPatternCreationType: IndexPatternCreationConfig; + selectedTimeField?: string; } interface StepTimeFieldState { @@ -69,7 +70,7 @@ export class StepTimeField extends Component, + asyncFn: Promise, errorValue: [] | string[], errorMsg: ReactElement ) => { @@ -129,22 +130,27 @@ export class CreateIndexPatternWizard extends Component< this.context.services.http, this.state.indexPatternCreationType, `*`, - MAX_SEARCH_SIZE + this.state.isIncludingSystemIndices ), [], indicesFailMsg ) - ).then((allIndices: MatchedIndex[]) => + ).then((allIndices: MatchedItem[]) => this.setState({ allIndices, isInitiallyLoadingIndices: false }) ); this.catchAndWarn( // if we get an error from remote cluster query, supply fallback value that allows user entry. // ['a'] is fallback value - getIndices(this.context.services.http, this.state.indexPatternCreationType, `*:*`, 1), + getIndices( + this.context.services.http, + this.state.indexPatternCreationType, + `*:*`, + this.state.isIncludingSystemIndices + ), ['a'], clustersFailMsg - ).then((remoteIndices: string[] | MatchedIndex[]) => + ).then((remoteIndices: string[] | MatchedItem[]) => this.setState({ remoteClustersExist: !!remoteIndices.length }) ); }; @@ -184,7 +190,7 @@ export class CreateIndexPatternWizard extends Component< if (isConfirmed) { return history.push(`/patterns/${indexPatternId}`); } else { - return false; + return; } } @@ -196,8 +202,8 @@ export class CreateIndexPatternWizard extends Component< history.push(`/patterns/${createdId}`); }; - goToTimeFieldStep = (indexPattern: string) => { - this.setState({ step: 2, indexPattern }); + goToTimeFieldStep = (indexPattern: string, selectedTimeField?: string) => { + this.setState({ step: 2, indexPattern, selectedTimeField }); }; goToIndexPatternStep = () => { @@ -239,7 +245,7 @@ export class CreateIndexPatternWizard extends Component< return ; } - const hasDataIndices = allIndices.some(({ name }: MatchedIndex) => !name.startsWith('.')); + const hasDataIndices = allIndices.some(({ name }: MatchedItem) => !name.startsWith('.')); if (!hasDataIndices && !isIncludingSystemIndices && !remoteClustersExist) { return ( ); } diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.test.ts b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.test.ts index b1faca8a04964b..3684a4ecde1687 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.test.ts +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.test.ts @@ -19,33 +19,50 @@ import { getIndices } from './get_indices'; import { IndexPatternCreationConfig } from '../../../../../index_pattern_management/public'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { LegacyApiCaller } from '../../../../../data/public/search/legacy'; +// import { LegacyApiCaller } from '../../../../../data/public/search/legacy'; +import { httpServiceMock } from '../../../../../../core/public/mocks'; export const successfulResponse = { - hits: { - total: 1, - max_score: 0.0, - hits: [], - }, - aggregations: { - indices: { - doc_count_error_upper_bound: 0, - sum_other_doc_count: 0, - buckets: [ - { - key: '1', - doc_count: 1, - }, - { - key: '2', - doc_count: 1, - }, - ], + indices: [ + { + name: 'remoteCluster1:bar-01', + attributes: ['open'], }, - }, + /* + { + name: 'foo-000001', + attributes: ['open', 'hidden'], + data_stream: 'foo', + }, + + { + name: 'foo_closed', + attributes: ['closed'], + }, + + { + name: 'freeze-index', + aliases: ['f-alias'], + attributes: ['open', 'frozen'], + }, + */ + ], + aliases: [ + { + name: 'f-alias', + indices: ['freeze-index', 'my-index'], + }, + ], + data_streams: [ + { + name: 'foo', + backing_indices: ['foo-000001'], + timestamp_field: '@timestamp', + }, + ], }; +/* export const exceptionResponse = { body: { error: { @@ -78,7 +95,7 @@ export const errorResponse = { statusCode: 400, error: 'Bad Request', }; - +*/ const mockIndexPatternCreationType = new IndexPatternCreationConfig({ type: 'default', name: 'name', @@ -87,6 +104,7 @@ const mockIndexPatternCreationType = new IndexPatternCreationConfig({ isBeta: false, }); +/* function esClientFactory(search: (params: any) => any): LegacyApiCaller { return { search, @@ -96,72 +114,89 @@ function esClientFactory(search: (params: any) => any): LegacyApiCaller { }), }; } +*/ + +// const es = esClientFactory(() => successfulResponse); -const es = esClientFactory(() => successfulResponse); +const http = httpServiceMock.createStartContract(); +http.get.mockResolvedValue(successfulResponse); describe('getIndices', () => { it('should work in a basic case', async () => { - const result = await getIndices(es, mockIndexPatternCreationType, 'kibana', 1); - expect(result.length).toBe(2); - expect(result[0].name).toBe('1'); - expect(result[1].name).toBe('2'); + const result = await getIndices(http, mockIndexPatternCreationType, 'kibana', false); + expect(result.length).toBe(3); + expect(result[0].name).toBe('f-alias'); + expect(result[1].name).toBe('foo'); }); it('should ignore ccs query-all', async () => { - expect((await getIndices(es, mockIndexPatternCreationType, '*:', 10)).length).toBe(0); + expect((await getIndices(http, mockIndexPatternCreationType, '*:', false)).length).toBe(0); }); it('should ignore a single comma', async () => { - expect((await getIndices(es, mockIndexPatternCreationType, ',', 10)).length).toBe(0); - expect((await getIndices(es, mockIndexPatternCreationType, ',*', 10)).length).toBe(0); - expect((await getIndices(es, mockIndexPatternCreationType, ',foobar', 10)).length).toBe(0); + expect((await getIndices(http, mockIndexPatternCreationType, ',', false)).length).toBe(0); + expect((await getIndices(http, mockIndexPatternCreationType, ',*', false)).length).toBe(0); + expect((await getIndices(http, mockIndexPatternCreationType, ',foobar', false)).length).toBe(0); }); it('should trim the input', async () => { let index; + // http.get.mockImplementation + http.get.mockResolvedValue((params: { index: string }) => { + index = params.index; + }); + /* + const esClient = esClientFactory( jest.fn().mockImplementation((params) => { index = params.index; }) ); + */ - await getIndices(esClient, mockIndexPatternCreationType, 'kibana ', 1); + await getIndices(http, mockIndexPatternCreationType, 'kibana ', false); expect(index).toBe('kibana'); }); it('should use the limit', async () => { let limit; + /* const esClient = esClientFactory( jest.fn().mockImplementation((params) => { limit = params.body.aggs.indices.terms.size; }) ); - await getIndices(esClient, mockIndexPatternCreationType, 'kibana', 10); + */ + await getIndices(http, mockIndexPatternCreationType, 'kibana', false); expect(limit).toBe(10); }); describe('errors', () => { it('should handle errors gracefully', async () => { - const esClient = esClientFactory(() => errorResponse); - const result = await getIndices(esClient, mockIndexPatternCreationType, 'kibana', 1); + // const esClient = esClientFactory(() => errorResponse); + const result = await getIndices(http, mockIndexPatternCreationType, 'kibana', false); expect(result.length).toBe(0); }); it('should throw exceptions', async () => { + /* const esClient = esClientFactory(() => { throw new Error('Fail'); }); + */ await expect( - getIndices(esClient, mockIndexPatternCreationType, 'kibana', 1) + getIndices(http, mockIndexPatternCreationType, 'kibana', false) ).rejects.toThrow(); }); it('should handle index_not_found_exception errors gracefully', async () => { + /* const esClient = esClientFactory( () => new Promise((resolve, reject) => reject(exceptionResponse)) ); - const result = await getIndices(esClient, mockIndexPatternCreationType, 'kibana', 1); + */ + const result = await getIndices(http, mockIndexPatternCreationType, 'kibana', false); expect(result.length).toBe(0); }); }); diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.ts b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.ts index ca081df1dd4218..1c770e23cc521d 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.ts +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.ts @@ -21,7 +21,7 @@ import { get, sortBy } from 'lodash'; import { HttpStart } from 'kibana/public'; import { i18n } from '@kbn/i18n'; import { IndexPatternCreationConfig } from '../../../../../index_pattern_management/public'; -import { MatchedIndex, ResolveIndexResponse } from '../types'; +import { MatchedItem, ResolveIndexResponse } from '../types'; const aliasLabel = i18n.translate('indexPatternManagement.aliasLabel', { defaultMessage: 'Alias' }); const dataStreamLabel = i18n.translate('indexPatternManagement.aliasLabel', { @@ -32,8 +32,8 @@ export async function getIndices( http: HttpStart, indexPatternCreationType: IndexPatternCreationConfig, rawPattern: string, - limit: number -): Promise { + showAllIndices: boolean +): Promise { const pattern = rawPattern.trim(); // Searching for `*:` fails for CCS environments. The search request @@ -55,11 +55,10 @@ export async function getIndices( } try { + const query = showAllIndices ? { expand_wildcards: 'all' } : undefined; const response = await http.get( - `/api/index-pattern-management/resolve_index/*`, - { - // prependBasePath: false, - } + `/api/index-pattern-management/resolve_index/${pattern}`, + { query } ); return responseToItemArray(response, indexPatternCreationType); } catch (err) { @@ -76,17 +75,25 @@ export async function getIndices( const responseToItemArray = ( response: ResolveIndexResponse, indexPatternCreationType: IndexPatternCreationConfig -): MatchedIndex[] => { - const source: MatchedIndex[] = []; +): MatchedItem[] => { + const source: MatchedItem[] = []; response.indices.forEach((index) => { - source.push({ name: index.name, tags: indexPatternCreationType.getIndexTags(index.name) }); + source.push({ + name: index.name, + tags: indexPatternCreationType.getIndexTags(index.name), + item: index, + }); }); response.aliases.forEach((alias) => { - source.push({ name: alias.name, tags: [{ key: 'alias', name: aliasLabel }] }); + source.push({ name: alias.name, tags: [{ key: 'alias', name: aliasLabel }], item: alias }); }); response.data_streams.forEach((dataStream) => { - source.push({ name: dataStream.name, tags: [{ key: 'data_stream', name: dataStreamLabel }] }); + source.push({ + name: dataStream.name, + tags: [{ key: 'data_stream', name: dataStreamLabel }], + item: dataStream, + }); }); return sortBy(source, 'name'); diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_matched_indices.test.ts b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_matched_indices.test.ts index 65840aa64046d1..c27eaa5ebc99ee 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_matched_indices.test.ts +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_matched_indices.test.ts @@ -18,7 +18,7 @@ */ import { getMatchedIndices } from './get_matched_indices'; -import { Tag } from '../types'; +import { Tag, MatchedItem } from '../types'; jest.mock('./../constants', () => ({ MAX_NUMBER_OF_MATCHING_INDICES: 6, @@ -32,18 +32,18 @@ const indices = [ { name: 'packetbeat', tags }, { name: 'metricbeat', tags }, { name: '.kibana', tags }, -]; +] as MatchedItem[]; const partialIndices = [ { name: 'kibana', tags }, { name: 'es', tags }, { name: '.kibana', tags }, -]; +] as MatchedItem[]; const exactIndices = [ { name: 'kibana', tags }, { name: '.kibana', tags }, -]; +] as MatchedItem[]; describe('getMatchedIndices', () => { it('should return all indices', () => { diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_matched_indices.ts b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_matched_indices.ts index 7e2eeb17ab3877..dbb166597152e1 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_matched_indices.ts +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_matched_indices.ts @@ -33,7 +33,7 @@ function isSystemIndex(index: string): boolean { return false; } -function filterSystemIndices(indices: MatchedIndex[], isIncludingSystemIndices: boolean) { +function filterSystemIndices(indices: MatchedItem[], isIncludingSystemIndices: boolean) { if (!indices) { return indices; } @@ -65,12 +65,12 @@ function filterSystemIndices(indices: MatchedIndex[], isIncludingSystemIndices: We call this `exact` matches because ES is telling us exactly what it matches */ -import { MatchedIndex } from '../types'; +import { MatchedItem } from '../types'; export function getMatchedIndices( - unfilteredAllIndices: MatchedIndex[], - unfilteredPartialMatchedIndices: MatchedIndex[], - unfilteredExactMatchedIndices: MatchedIndex[], + unfilteredAllIndices: MatchedItem[], + unfilteredPartialMatchedIndices: MatchedItem[], + unfilteredExactMatchedIndices: MatchedItem[], isIncludingSystemIndices: boolean = false ) { const allIndices = filterSystemIndices(unfilteredAllIndices, isIncludingSystemIndices); diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/types.ts b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/types.ts index d595052d8f67f8..541d86dcedfd59 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/types.ts +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/types.ts @@ -17,9 +17,13 @@ * under the License. */ -export interface MatchedIndex { +export interface MatchedItem { name: string; tags: Tag[]; + item: + | ResolveIndexResponseItemIndex + | ResolveIndexResponseItemAlias + | ResolveIndexResponseItemDataStream; } export interface ResolveIndexResponse { diff --git a/src/plugins/index_pattern_management/public/service/creation/config.ts b/src/plugins/index_pattern_management/public/service/creation/config.ts index 95a91fd7594caf..04510b1d64e1e2 100644 --- a/src/plugins/index_pattern_management/public/service/creation/config.ts +++ b/src/plugins/index_pattern_management/public/service/creation/config.ts @@ -18,7 +18,7 @@ */ import { i18n } from '@kbn/i18n'; -import { MatchedIndex } from '../../components/create_index_pattern_wizard/types'; +import { MatchedItem } from '../../components/create_index_pattern_wizard/types'; const indexPatternTypeName = i18n.translate( 'indexPatternManagement.editIndexPattern.createIndex.defaultTypeName', @@ -105,7 +105,7 @@ export class IndexPatternCreationConfig { return []; } - public checkIndicesForErrors(indices: MatchedIndex[]) { + public checkIndicesForErrors(indices: MatchedItem[]) { return undefined; } diff --git a/src/plugins/index_pattern_management/server/plugin.ts b/src/plugins/index_pattern_management/server/plugin.ts index a197246dfcc838..769f8cb6d1635e 100644 --- a/src/plugins/index_pattern_management/server/plugin.ts +++ b/src/plugins/index_pattern_management/server/plugin.ts @@ -33,12 +33,27 @@ export class IndexPatternManagementPlugin implements Plugin { params: schema.object({ query: schema.string(), }), + query: schema.object({ + expand_wildcards: schema.maybe( + schema.oneOf([ + schema.literal('all'), + schema.literal('open'), + schema.literal('closed'), + schema.literal('hidden'), + schema.literal('none'), + ]) + ), + }), }, }, async (context, req, res) => { + const query = req.query.expand_wildcards + ? { expand_wildcards: req.query.expand_wildcards } + : null; const result = await context.core.elasticsearch.legacy.client.callAsCurrentUser( 'transport.request', - { method: 'GET', path: `/_resolve/index/${req.params.query}` } + // todo make sense of paraams vs query string + { method: 'GET', path: `/_resolve/index/${encodeURIComponent(req.params.query)}`, query } ); return res.ok({ body: result }); } From 4e47b4054c47676a0207d5409f1aeec48be2e376 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Wed, 1 Jul 2020 15:34:50 -0500 Subject: [PATCH 12/76] i18n fix --- .../components/create_index_pattern_wizard/lib/get_indices.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.ts b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.ts index 1c770e23cc521d..f651af1e302d2f 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.ts +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.ts @@ -24,7 +24,7 @@ import { IndexPatternCreationConfig } from '../../../../../index_pattern_managem import { MatchedItem, ResolveIndexResponse } from '../types'; const aliasLabel = i18n.translate('indexPatternManagement.aliasLabel', { defaultMessage: 'Alias' }); -const dataStreamLabel = i18n.translate('indexPatternManagement.aliasLabel', { +const dataStreamLabel = i18n.translate('indexPatternManagement.dataStreamLabel', { defaultMessage: 'Data stream', }); From 5833e7c58ebed2135480c2a8da0c2114ed7fdf56 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Wed, 1 Jul 2020 17:58:23 -0500 Subject: [PATCH 13/76] show hidden indices --- .../components/header/header.tsx | 7 ++++--- .../step_index_pattern/step_index_pattern.tsx | 3 --- .../create_index_pattern_wizard.tsx | 14 ++++++++------ .../index_pattern_management/server/plugin.ts | 10 +++++++--- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx index 35c6e67d0ea0e7..f7422bad17f504 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx @@ -28,6 +28,7 @@ import { EuiText, EuiTextColor, EuiSwitch, + EuiSwitchEvent, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; @@ -47,7 +48,7 @@ export const Header = ({ indexPatternName: string; showSystemIndices?: boolean; isIncludingSystemIndices: boolean; - onChangeIncludingSystemIndices: () => void; + onChangeIncludingSystemIndices: (event: EuiSwitchEvent) => void; isBeta?: boolean; }) => { const changeTitle = useKibana().services.chrome.docTitle.change; @@ -96,8 +97,8 @@ export const Header = ({ } id="checkboxShowSystemIndices" diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx index 05a91fdd326a18..a95265a7610830 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx @@ -307,8 +307,6 @@ export class StepIndexPattern extends Component 0; const isNextStepDisabled = containsErrors || indices.length === 0 || indexPatternExists; - // todo define next step OR create index pattern. - // look at matched indices // if all are data streams with same time field then create index pattern const { allMatchingDataStreams: uniformDataStreams, @@ -347,7 +345,6 @@ export class StepIndexPattern extends Component goToNextStep(query, uniformDataStreams ? matchingTimestamp : undefined)} - // goToNextStep={nextStepOrCreate} isNextStepDisabled={isNextStepDisabled} /> ); diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx index d271581fa6021d..9ad6f942c5637f 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx @@ -19,7 +19,12 @@ import React, { ReactElement, Component } from 'react'; -import { EuiGlobalToastList, EuiGlobalToastListToast, EuiPanel } from '@elastic/eui'; +import { + EuiGlobalToastList, + EuiGlobalToastListToast, + EuiPanel, + EuiSwitchEvent, +} from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; import { withRouter, RouteComponentProps } from 'react-router-dom'; @@ -30,7 +35,6 @@ import { LoadingState } from './components/loading_state'; import { EmptyState } from './components/empty_state'; import { context as contextType } from '../../../../kibana_react/public'; - import { getCreateBreadcrumbs } from '../breadcrumbs'; import { ensureMinimumTime, getIndices } from './lib'; import { IndexPatternCreationConfig } from '../..'; @@ -210,10 +214,8 @@ export class CreateIndexPatternWizard extends Component< this.setState({ step: 1 }); }; - onChangeIncludingSystemIndices = () => { - this.setState((prevState) => ({ - isIncludingSystemIndices: !prevState.isIncludingSystemIndices, - })); + onChangeIncludingSystemIndices = (event: EuiSwitchEvent) => { + this.setState({ isIncludingSystemIndices: event.target.checked }, () => this.fetchData()); }; renderHeader() { diff --git a/src/plugins/index_pattern_management/server/plugin.ts b/src/plugins/index_pattern_management/server/plugin.ts index 769f8cb6d1635e..eb3a5ec44a3b9e 100644 --- a/src/plugins/index_pattern_management/server/plugin.ts +++ b/src/plugins/index_pattern_management/server/plugin.ts @@ -47,13 +47,17 @@ export class IndexPatternManagementPlugin implements Plugin { }, }, async (context, req, res) => { - const query = req.query.expand_wildcards + const queryString = req.query.expand_wildcards ? { expand_wildcards: req.query.expand_wildcards } : null; const result = await context.core.elasticsearch.legacy.client.callAsCurrentUser( 'transport.request', - // todo make sense of paraams vs query string - { method: 'GET', path: `/_resolve/index/${encodeURIComponent(req.params.query)}`, query } + { + method: 'GET', + path: `/_resolve/index/${encodeURIComponent(req.params.query)}${ + queryString ? '?' + new URLSearchParams(queryString).toString() : '' + }`, + } ); return res.ok({ body: result }); } From 289fc43f83c61212a09b01614888a61d157763a6 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Wed, 1 Jul 2020 22:11:20 -0500 Subject: [PATCH 14/76] rendeing improvements --- .../header/__snapshots__/header.test.tsx.snap | 186 +++++++++--------- .../components/header/header.tsx | 41 ++-- .../step_index_pattern.test.tsx.snap | 2 + .../step_index_pattern.test.tsx | 8 +- .../step_index_pattern/step_index_pattern.tsx | 4 +- .../step_time_field/step_time_field.tsx | 36 ++-- 6 files changed, 149 insertions(+), 128 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/__snapshots__/header.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/__snapshots__/header.test.tsx.snap index 81ca3e644d3ce3..1ef99f498718ce 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/__snapshots__/header.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/__snapshots__/header.test.tsx.snap @@ -31,12 +31,9 @@ exports[`Header should render a different name, prompt, and beta tag if provided

- +
-

- - - - - Kibana uses index patterns to retrieve data from Elasticsearch indices for things like visualizations. - - - - -

+ Read documentation", + } + } + > + Read documentation", + } + } + /> + + +
+
@@ -85,13 +89,11 @@ exports[`Header should render a different name, prompt, and beta tag if provided
Test prompt
- -
+
- +
`; @@ -110,12 +112,9 @@ exports[`Header should render normally 1`] = ` Create test index pattern - +
-

- - - - - Kibana uses index patterns to retrieve data from Elasticsearch indices for things like visualizations. - - - - -

+ Read documentation", + } + } + > + Read documentation", + } + } + /> + + +
+
- -
+
- +
`; @@ -179,12 +183,9 @@ exports[`Header should render without including system indices 1`] = ` Create test index pattern - +
-

- - - - - Kibana uses index patterns to retrieve data from Elasticsearch indices for things like visualizations. - - - - -

+ Read documentation", + } + } + > + Read documentation", + } + } + /> + + +
+
- -
+
- +
`; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx index f7422bad17f504..48e599613f9534 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx @@ -29,6 +29,8 @@ import { EuiTextColor, EuiSwitch, EuiSwitchEvent, + EuiIcon, + EuiHorizontalRule, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; @@ -60,6 +62,19 @@ export const Header = ({ } ); + const createIndexPatternLabel = i18n.translate('indexPatternManagement.createIndexPatternLabel', { + defaultMessage: + 'An index pattern can match a single source, for example, filebeat-4-3-22, or multiple data sources, filebeat-*. {docsLink}', + values: { + docsLink: + '' + + i18n.translate('indexPatternManagement.indexPatternDocLink', { + defaultMessage: 'Read documentation', + }) + + '', + }, + }); + changeTitle(createIndexPatternHeader); return ( @@ -79,20 +94,19 @@ export const Header = ({ ) : null} - + -

- - - -

+ +
- {showSystemIndices ? ( +
+ {showSystemIndices ? ( + - ) : null} - +
+ ) : null} + {prompt ? ( {prompt} ) : null} - + ); }; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/__snapshots__/step_index_pattern.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/__snapshots__/step_index_pattern.test.tsx.snap index b68ba4720b9352..9f243bc745c66f 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/__snapshots__/step_index_pattern.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/__snapshots__/step_index_pattern.test.tsx.snap @@ -25,6 +25,7 @@ exports[`StepIndexPattern renders indices which match the initial query 1`] = ` indices={ Array [ Object { + "item": Object {}, "name": "kibana", }, ] @@ -39,6 +40,7 @@ exports[`StepIndexPattern renders matching indices when input is valid 1`] = ` indices={ Array [ Object { + "item": Object {}, "name": "kibana", }, ] diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.test.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.test.tsx index 053940270c2b6d..332acfc99b61ac 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.test.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.test.tsx @@ -38,16 +38,16 @@ const mockIndexPatternCreationType = new IndexPatternCreationConfig({ jest.mock('../../lib/get_indices', () => ({ getIndices: ({}, {}, query: string) => { if (query.startsWith('e')) { - return [{ name: 'es' }]; + return [{ name: 'es', item: {} }]; } - return [{ name: 'kibana' }]; + return [{ name: 'kibana', item: {} }]; }, })); const allIndices = [ - { name: 'kibana', tags: [] }, - { name: 'es', tags: [] }, + { name: 'kibana', tags: [], item: {} }, + { name: 'es', tags: [], item: {} }, ]; const goToNextStep = () => {}; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx index a95265a7610830..586703666f85fb 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx @@ -362,7 +362,7 @@ export class StepIndexPattern extends Component + <> {this.renderHeader(matchedIndices)} {this.renderLoadingState()} @@ -370,7 +370,7 @@ export class StepIndexPattern extends Component {this.renderList(matchedIndices)} - + ); } } diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx index febb95d56c1a7f..4b720d3ed16c7e 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx @@ -22,10 +22,10 @@ import { EuiCallOut, EuiFlexGroup, EuiFlexItem, - EuiPanel, EuiText, EuiSpacer, EuiLoadingSpinner, + EuiHorizontalRule, } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { ensureMinimumTime, extractTimeFields } from '../../lib'; @@ -185,21 +185,19 @@ export class StepTimeField extends Component - - - - - - - - - - - + + + + + + + + + + ); } @@ -238,7 +236,7 @@ export class StepTimeField extends Component + <>
- + - + ); } } From 7e0698f429fa2a622bcc3bece2d64d0fb3d6895a Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Wed, 1 Jul 2020 22:41:48 -0500 Subject: [PATCH 15/76] rendering improvements --- .../header/__snapshots__/header.test.tsx.snap | 50 +-- .../components/header/header.tsx | 24 +- .../status_message.test.tsx.snap | 309 +++++++++--------- .../status_message/status_message.tsx | 33 +- 4 files changed, 207 insertions(+), 209 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/__snapshots__/header.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/__snapshots__/header.test.tsx.snap index 3021292953ff5c..6c370a45f3172e 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/__snapshots__/header.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/__snapshots__/header.test.tsx.snap @@ -17,12 +17,10 @@ exports[`Header should mark the input as invalid 1`] = ` size="m" /> - + @@ -34,30 +32,20 @@ exports[`Header should mark the input as invalid 1`] = ` "Input is invalid", ] } - fullWidth={false} + fullWidth={true} hasChildLabel={true} hasEmptyLabelSpace={false} helpText={

* , - } - } - /> -

-

- % , @@ -70,7 +58,7 @@ exports[`Header should mark the input as invalid 1`] = ` isInvalid={true} label={ @@ -79,6 +67,7 @@ exports[`Header should mark the input as invalid 1`] = ` > - + @@ -138,30 +125,20 @@ exports[`Header should render normally 1`] = ` describedByIds={Array []} display="row" error={Array []} - fullWidth={false} + fullWidth={true} hasChildLabel={true} hasEmptyLabelSpace={false} helpText={

* , - } - } - /> -

-

- % , @@ -174,7 +151,7 @@ exports[`Header should render normally 1`] = ` isInvalid={false} label={ @@ -183,6 +160,7 @@ exports[`Header should render normally 1`] = ` > = ({ - - + + } isInvalid={isInputInvalid} @@ -79,16 +80,12 @@ export const Header: React.FC = ({

* }} - /> -

-

- {characterList} }} + id="indexPatternManagement.createIndexPattern.step.indexPattern.allowDisallowLabel" + defaultMessage="You can use a {asterisk} as a wildcard in your index pattern. You can't use spaces or the characters {characterList}." + values={{ + asterisk: *, + characterList: {characterList}, + }} />

@@ -106,6 +103,7 @@ export const Header: React.FC = ({ isInvalid={isInputInvalid} onChange={onQueryChanged} data-test-subj="createIndexPatternNameInput" + fullWidth /> diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__snapshots__/status_message.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__snapshots__/status_message.test.tsx.snap index 4a063f1430d1c0..d526a5851d3cfb 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__snapshots__/status_message.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__snapshots__/status_message.test.tsx.snap @@ -1,177 +1,194 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`StatusMessage should render with exact matches 1`] = ` - - + + - - -   - - + + +   + + - , - "strongSuccess": - - , + /> + , + "strongSuccess": + + , + } } - } - /> - - - + /> + + + + `; exports[`StatusMessage should render with no partial matches 1`] = ` - - + + - - - + + + - , + /> + , + } } - } - /> - - - + /> + + + + `; exports[`StatusMessage should render with partial matches 1`] = ` - - + + - - - + + + - , + /> + , + } } - } - /> - - - + /> + + + + `; exports[`StatusMessage should render without a query 1`] = ` - - + + - - - 2 - indices - , - } - } - /> - - - + + +

+ +

+
+
+ + `; exports[`StatusMessage should show that no indices exist 1`] = ` - - + + - - - - - + + + + + + + `; exports[`StatusMessage should show that system indices exist 1`] = ` - - + + - - - - - + + + + + + + `; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx index 112c1fe0aa1d07..eb3a5706978bfe 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx @@ -19,7 +19,7 @@ import React from 'react'; -import { EuiText, EuiTextColor, EuiIcon } from '@elastic/eui'; +import { EuiText, EuiTextColor, EuiIcon, EuiSpacer } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { MatchedItem } from '../../../../types'; @@ -53,13 +53,15 @@ export const StatusMessage: React.FC = ({ if (allIndicesLength > 1) { statusMessage = ( - - {allIndicesLength} indices }} - /> - + +

+ +

+
); } else if (!isIncludingSystemIndices && showSystemIndices) { statusMessage = ( @@ -163,11 +165,14 @@ export const StatusMessage: React.FC = ({ } return ( - - - {statusIcon ? : null} - {statusMessage} - - + <> + + + + {statusIcon ? : null} + {statusMessage} + + + ); }; From 1dd96360aeaa5aa9bba55813867a8c513bd15b4f Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Wed, 1 Jul 2020 22:44:29 -0500 Subject: [PATCH 16/76] rendering improvements --- .../components/step_index_pattern/step_index_pattern.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx index 586703666f85fb..08a45ff023e017 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx @@ -18,7 +18,7 @@ */ import React, { Component } from 'react'; -import { EuiPanel, EuiSpacer, EuiCallOut } from '@elastic/eui'; +import { EuiSpacer, EuiCallOut } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { From 6a4eb0888edf45c24f9ffa6700502bea2d78f09c Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Wed, 1 Jul 2020 23:14:14 -0500 Subject: [PATCH 17/76] typescript and test fixes --- .../components/empty_state/empty_state.test.tsx | 11 ++++++++--- .../components/empty_state/empty_state.tsx | 4 ++-- .../components/header/header.test.tsx | 6 ++++++ .../components/header/header.tsx | 4 ++-- .../edit_index_pattern/edit_index_pattern.tsx | 1 - .../index_header/index_header.tsx | 9 +-------- .../empty_index_pattern_prompt.test.tsx | 13 +++++++++++-- 7 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.test.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.test.tsx index 20608b66641315..292a8a8c8cbd9a 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.test.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.test.tsx @@ -21,13 +21,18 @@ import React from 'react'; import { EmptyState } from '../empty_state'; import { shallow } from 'enzyme'; import sinon from 'sinon'; -// @ts-ignore +// @ts-expect-error import { findTestSubject } from '@elastic/eui/lib/test'; import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { docLinksServiceMock } from '../../../../../../../core/public/mocks'; + +const docLinks = docLinksServiceMock.createStartContract(); describe('EmptyState', () => { it('should render normally', () => { - const component = shallow( {}} prependBasePath={(x) => x} />); + const component = shallow( + {}} prependBasePath={(x) => x} /> + ); expect(component).toMatchSnapshot(); }); @@ -38,7 +43,7 @@ describe('EmptyState', () => { const onRefreshHandler = sinon.stub(); const component = mountWithIntl( - x} /> + x} /> ); findTestSubject(component, 'refreshIndicesButton').simulate('click'); diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.tsx index 6d429b6e3feb79..b7a05a4bc0d93f 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.tsx @@ -22,7 +22,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; // import { getDocLink } from '../../../../../ legacy/ui/public/documentation_links'; -import { IBasePath, DocLinksSetup } from 'kibana/public'; +import { IBasePath, DocLinksStart } from 'kibana/public'; import { EuiPageContentHeader, @@ -47,7 +47,7 @@ export const EmptyState = ({ }: { onRefresh: () => void; prependBasePath: IBasePath['prepend']; - docLinks: DocLinksSetup; + docLinks: DocLinksStart; }) => ( <> diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.test.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.test.tsx index d12e0401380b9e..f1a0112de07894 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.test.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.test.tsx @@ -22,6 +22,9 @@ import { Header } from '../header'; import { mount } from 'enzyme'; import { KibanaContextProvider } from 'src/plugins/kibana_react/public'; import { mockManagementPlugin } from '../../../../mocks'; +import { docLinksServiceMock } from '../../../../../../../core/public/mocks'; + +const docLinks = docLinksServiceMock.createStartContract(); describe('Header', () => { const indexPatternName = 'test index pattern'; @@ -33,6 +36,7 @@ describe('Header', () => { indexPatternName={indexPatternName} isIncludingSystemIndices={true} onChangeIncludingSystemIndices={() => {}} + docLinks={docLinks} />, { wrappingComponent: KibanaContextProvider, @@ -51,6 +55,7 @@ describe('Header', () => { indexPatternName={indexPatternName} isIncludingSystemIndices={false} onChangeIncludingSystemIndices={() => {}} + docLinks={docLinks} />, { wrappingComponent: KibanaContextProvider, @@ -71,6 +76,7 @@ describe('Header', () => { prompt={
Test prompt
} indexPatternName={indexPatternName} isBeta={true} + docLinks={docLinks} />, { wrappingComponent: KibanaContextProvider, diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx index 10584f0f792f12..5c8da009c040a1 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx @@ -31,7 +31,7 @@ import { import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import { DocLinksSetup } from 'kibana/public'; +import { DocLinksStart } from 'kibana/public'; import { useKibana } from '../../../../../../../plugins/kibana_react/public'; import { IndexPatternManagmentContext } from '../../../../types'; @@ -50,7 +50,7 @@ export const Header = ({ isIncludingSystemIndices: boolean; onChangeIncludingSystemIndices: () => void; isBeta?: boolean; - docLinks: DocLinksSetup; + docLinks: DocLinksStart; }) => { const changeTitle = useKibana().services.chrome.docTitle.change; const createIndexPatternHeader = i18n.translate( diff --git a/src/plugins/index_pattern_management/public/components/edit_index_pattern/edit_index_pattern.tsx b/src/plugins/index_pattern_management/public/components/edit_index_pattern/edit_index_pattern.tsx index 425873fa872d94..9047a55241e774 100644 --- a/src/plugins/index_pattern_management/public/components/edit_index_pattern/edit_index_pattern.tsx +++ b/src/plugins/index_pattern_management/public/components/edit_index_pattern/edit_index_pattern.tsx @@ -27,7 +27,6 @@ import { EuiBadge, EuiText, EuiLink, - EuiIcon, EuiCallOut, EuiPanel, } from '@elastic/eui'; diff --git a/src/plugins/index_pattern_management/public/components/edit_index_pattern/index_header/index_header.tsx b/src/plugins/index_pattern_management/public/components/edit_index_pattern/index_header/index_header.tsx index 7790d41e1ce4a4..8ca8c6453c7e96 100644 --- a/src/plugins/index_pattern_management/public/components/edit_index_pattern/index_header/index_header.tsx +++ b/src/plugins/index_pattern_management/public/components/edit_index_pattern/index_header/index_header.tsx @@ -19,14 +19,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; -import { - EuiFlexGroup, - EuiToolTip, - EuiFlexItem, - EuiIcon, - EuiTitle, - EuiButtonIcon, -} from '@elastic/eui'; +import { EuiFlexGroup, EuiToolTip, EuiFlexItem, EuiTitle, EuiButtonIcon } from '@elastic/eui'; import { IIndexPattern } from 'src/plugins/data/public'; interface IndexHeaderProps { diff --git a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx index af8dd860db2a8f..41c561e2e972bf 100644 --- a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx +++ b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx @@ -21,10 +21,19 @@ import React from 'react'; import { EmptyIndexPatternPrompt } from '../empty_index_pattern_prompt'; import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; +const routeComponentPropsMock = { + history: { + push: jest.fn(), + } as any, + location: {} as any, + match: {} as any, +}; + describe('EmptyIndexPatternPrompt', () => { - /** HELP */ it.skip('should render normally', () => { - const component = shallowWithI18nProvider(); + const component = shallowWithI18nProvider( + + ); expect(component).toMatchSnapshot(); }); From 86859a7706143915d134b1fc218af7e8a9b346ac Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Thu, 2 Jul 2020 06:36:47 -0500 Subject: [PATCH 18/76] i18n fix --- .../empty_index_pattern_prompt.tsx | 10 +++++----- .../index_pattern_table/index_pattern_table.tsx | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx index e31901579088b6..6da80525732f12 100644 --- a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx +++ b/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx @@ -69,18 +69,18 @@ export const EmptyIndexPatternPrompt = ({ canSave, history }: Props) => {


{ diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx index e539839e46baeb..4be046448ba3b7 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx @@ -163,7 +163,7 @@ export const IndexPatternTable = ({ canSave, history }: Props) => {

From c05f60425b45cd3bf5bd719bc89d1272e24a867d Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Thu, 2 Jul 2020 10:47:47 -0500 Subject: [PATCH 19/76] jest test fixes --- .../create_index_pattern_wizard.test.tsx.snap | 15 + .../__snapshots__/empty_state.test.tsx.snap | 234 ++++++++--- .../header/__snapshots__/header.test.tsx.snap | 388 ++++++++++++------ .../components/header/header.test.tsx | 6 +- 4 files changed, 457 insertions(+), 186 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.tsx.snap index 4aba95d447de47..f60f840d9f0c23 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.tsx.snap @@ -56,6 +56,9 @@ exports[`CreateIndexPatternWizard renders index pattern step when there are indi "auditbeat": Object { "base": "https://www.elastic.co/guide/en/beats/auditbeat/mocked-test-branch", }, + "dashboard": Object { + "drilldowns": "https://www.elastic.co/guide/en/kibana/mocked-test-branch/drilldowns.html", + }, "date": Object { "dateMath": "https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/common-options.html#date-math", }, @@ -193,6 +196,9 @@ exports[`CreateIndexPatternWizard renders the empty state when there are no indi "auditbeat": Object { "base": "https://www.elastic.co/guide/en/beats/auditbeat/mocked-test-branch", }, + "dashboard": Object { + "drilldowns": "https://www.elastic.co/guide/en/kibana/mocked-test-branch/drilldowns.html", + }, "date": Object { "dateMath": "https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/common-options.html#date-math", }, @@ -304,6 +310,9 @@ exports[`CreateIndexPatternWizard renders time field step when step is set to 2 "auditbeat": Object { "base": "https://www.elastic.co/guide/en/beats/auditbeat/mocked-test-branch", }, + "dashboard": Object { + "drilldowns": "https://www.elastic.co/guide/en/kibana/mocked-test-branch/drilldowns.html", + }, "date": Object { "dateMath": "https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/common-options.html#date-math", }, @@ -436,6 +445,9 @@ exports[`CreateIndexPatternWizard renders when there are no indices but there ar "auditbeat": Object { "base": "https://www.elastic.co/guide/en/beats/auditbeat/mocked-test-branch", }, + "dashboard": Object { + "drilldowns": "https://www.elastic.co/guide/en/kibana/mocked-test-branch/drilldowns.html", + }, "date": Object { "dateMath": "https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/common-options.html#date-math", }, @@ -568,6 +580,9 @@ exports[`CreateIndexPatternWizard shows system indices even if there are no othe "auditbeat": Object { "base": "https://www.elastic.co/guide/en/beats/auditbeat/mocked-test-branch", }, + "dashboard": Object { + "drilldowns": "https://www.elastic.co/guide/en/kibana/mocked-test-branch/drilldowns.html", + }, "date": Object { "dateMath": "https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/common-options.html#date-math", }, diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/__snapshots__/empty_state.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/__snapshots__/empty_state.test.tsx.snap index bb94a7aa0b4de5..ed70b99a4b03b6 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/__snapshots__/empty_state.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/__snapshots__/empty_state.test.tsx.snap @@ -1,66 +1,200 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`EmptyState should render normally 1`] = ` -
- - } + + -

- + + + +

+ +

+ + + + + + + + - , - "learnHowLink": + } + href="/app/home#/tutorial_directory" + icon={ + + } + title={ - , - "needToIndex": + } + /> + + + - , - } - } + } + icon={ + + } + isDisabled={true} + title={ + + } + /> + + + + } + href="/app/home#/tutorial_directory/sampleData" + icon={ + + } + title={ + + } + /> + + + +
+ + + + Read documentation + , + "title": , + }, + ] + } + /> + + + + + + + , + "title": , + }, + ] + } + /> + + +
+
+
+ + +

+ Some indices may be hidden. Try to + + create an index pattern + + anyway.

- - - -
-
+
+ `; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/__snapshots__/header.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/__snapshots__/header.test.tsx.snap index 81ca3e644d3ce3..9e00c6d657966f 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/__snapshots__/header.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/__snapshots__/header.test.tsx.snap @@ -2,6 +2,13 @@ exports[`Header should render a different name, prompt, and beta tag if provided 1`] = `
-
+ + +
- -
+ + multiple + , + "single": + filebeat-4-3-22 + , + "star": + filebeat-* + , + } + } + > + + An index pattern can match a single index, for example, + + + + + filebeat-4-3-22 + + + + + , or + + multiple + + indices, + + + + + filebeat-* + + + + + . + + +
+ - -
-

- - - - - Kibana uses index patterns to retrieve data from Elasticsearch indices for things like visualizations. - - - - -

-
-
-
-
+ + Read documentation + + + + +

- +
Test prompt
- -
-
`; exports[`Header should render normally 1`] = `
-
+ + +
- -
+ + multiple + , + "single": + filebeat-4-3-22 + , + "star": + filebeat-* + , + } + } > - + An index pattern can match a single index, for example, + + + + + filebeat-4-3-22 + + + + + , or + + multiple + + indices, + + + + + filebeat-* + + + + + . + + +
+ +
-
+ + Read documentation + + + + +

- - -
- +
`; exports[`Header should render without including system indices 1`] = `
-
+ + +
- -
+ + multiple + , + "single": + filebeat-4-3-22 + , + "star": + filebeat-* + , + } + } + > + + An index pattern can match a single index, for example, + + + + + filebeat-4-3-22 + + + + + , or + + multiple + + indices, + + + + + filebeat-* + + + + + . + + +
+ - -
-

- - - - - Kibana uses index patterns to retrieve data from Elasticsearch indices for things like visualizations. - - - - -

-
-
-
-
+ + Read documentation + + + + +

- - -
- +
`; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.test.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.test.tsx index f1a0112de07894..90334f5822a520 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.test.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.test.tsx @@ -22,9 +22,11 @@ import { Header } from '../header'; import { mount } from 'enzyme'; import { KibanaContextProvider } from 'src/plugins/kibana_react/public'; import { mockManagementPlugin } from '../../../../mocks'; -import { docLinksServiceMock } from '../../../../../../../core/public/mocks'; +import { DocLinksStart } from 'kibana/public'; +// import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; -const docLinks = docLinksServiceMock.createStartContract(); +// links.indexPatterns +const docLinks = { links: { indexPatterns: {} } } as DocLinksStart; describe('Header', () => { const indexPatternName = 'test index pattern'; From f4e1b3648072fc40db1ed15dba34be8aaa60d972 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Thu, 2 Jul 2020 15:53:36 -0500 Subject: [PATCH 20/76] fix and add tests for get_indices --- .../__snapshots__/get_indices.test.ts.snap | 40 +++++ .../lib/get_indices.test.ts | 146 ++++-------------- .../lib/get_indices.ts | 25 ++- .../create_index_pattern_wizard/types.ts | 6 +- 4 files changed, 81 insertions(+), 136 deletions(-) create mode 100644 src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/__snapshots__/get_indices.test.ts.snap diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/__snapshots__/get_indices.test.ts.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/__snapshots__/get_indices.test.ts.snap new file mode 100644 index 00000000000000..1cff66615b6159 --- /dev/null +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/__snapshots__/get_indices.test.ts.snap @@ -0,0 +1,40 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`getIndices response object to item array 1`] = ` +Array [ + Object { + "item": Object { + "indices": Array [], + "name": "test_alias", + }, + "name": "test_alias", + "tags": Array [ + Object { + "key": "alias", + "name": "Alias", + }, + ], + }, + Object { + "item": Object { + "backing_indices": Array [], + "name": "test_data_stream", + "timestamp_field": "test_timestamp_field", + }, + "name": "test_data_stream", + "tags": Array [ + Object { + "key": "data_stream", + "name": "Data stream", + }, + ], + }, + Object { + "item": Object { + "name": "test_index", + }, + "name": "test_index", + "tags": Array [], + }, +] +`; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.test.ts b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.test.ts index 3684a4ecde1687..ab395c21ff84c1 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.test.ts +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.test.ts @@ -17,9 +17,8 @@ * under the License. */ -import { getIndices } from './get_indices'; +import { getIndices, responseToItemArray } from './get_indices'; import { IndexPatternCreationConfig } from '../../../../../index_pattern_management/public'; -// import { LegacyApiCaller } from '../../../../../data/public/search/legacy'; import { httpServiceMock } from '../../../../../../core/public/mocks'; export const successfulResponse = { @@ -28,24 +27,6 @@ export const successfulResponse = { name: 'remoteCluster1:bar-01', attributes: ['open'], }, - /* - { - name: 'foo-000001', - attributes: ['open', 'hidden'], - data_stream: 'foo', - }, - - { - name: 'foo_closed', - attributes: ['closed'], - }, - - { - name: 'freeze-index', - aliases: ['f-alias'], - attributes: ['open', 'frozen'], - }, - */ ], aliases: [ { @@ -62,40 +43,6 @@ export const successfulResponse = { ], }; -/* -export const exceptionResponse = { - body: { - error: { - root_cause: [ - { - type: 'index_not_found_exception', - reason: 'no such index', - index_uuid: '_na_', - 'resource.type': 'index_or_alias', - 'resource.id': 't', - index: 't', - }, - ], - type: 'transport_exception', - reason: 'unable to communicate with remote cluster [cluster_one]', - caused_by: { - type: 'index_not_found_exception', - reason: 'no such index', - index_uuid: '_na_', - 'resource.type': 'index_or_alias', - 'resource.id': 't', - index: 't', - }, - }, - }, - status: 500, -}; - -export const errorResponse = { - statusCode: 400, - error: 'Bad Request', -}; -*/ const mockIndexPatternCreationType = new IndexPatternCreationConfig({ type: 'default', name: 'name', @@ -104,20 +51,6 @@ const mockIndexPatternCreationType = new IndexPatternCreationConfig({ isBeta: false, }); -/* -function esClientFactory(search: (params: any) => any): LegacyApiCaller { - return { - search, - msearch: () => ({ - abort: () => {}, - ...new Promise((resolve) => resolve({})), - }), - }; -} -*/ - -// const es = esClientFactory(() => successfulResponse); - const http = httpServiceMock.createStartContract(); http.get.mockResolvedValue(successfulResponse); @@ -139,63 +72,36 @@ describe('getIndices', () => { expect((await getIndices(http, mockIndexPatternCreationType, ',foobar', false)).length).toBe(0); }); - it('should trim the input', async () => { - let index; - // http.get.mockImplementation - http.get.mockResolvedValue((params: { index: string }) => { - index = params.index; - }); - /* - - const esClient = esClientFactory( - jest.fn().mockImplementation((params) => { - index = params.index; - }) - ); - */ - - await getIndices(http, mockIndexPatternCreationType, 'kibana ', false); - expect(index).toBe('kibana'); - }); - - it('should use the limit', async () => { - let limit; - /* - const esClient = esClientFactory( - jest.fn().mockImplementation((params) => { - limit = params.body.aggs.indices.terms.size; - }) - ); - */ - await getIndices(http, mockIndexPatternCreationType, 'kibana', false); - expect(limit).toBe(10); + it('response object to item array', () => { + const result = { + indices: [ + { + name: 'test_index', + }, + ], + aliases: [ + { + name: 'test_alias', + indices: [], + }, + ], + data_streams: [ + { + name: 'test_data_stream', + backing_indices: [], + timestamp_field: 'test_timestamp_field', + }, + ], + }; + expect(responseToItemArray(result, mockIndexPatternCreationType)).toMatchSnapshot(); + expect(responseToItemArray({}, mockIndexPatternCreationType)).toEqual([]); }); describe('errors', () => { it('should handle errors gracefully', async () => { - // const esClient = esClientFactory(() => errorResponse); - const result = await getIndices(http, mockIndexPatternCreationType, 'kibana', false); - expect(result.length).toBe(0); - }); - - it('should throw exceptions', async () => { - /* - const esClient = esClientFactory(() => { - throw new Error('Fail'); + http.get.mockImplementationOnce(() => { + throw new Error('Test error'); }); - */ - - await expect( - getIndices(http, mockIndexPatternCreationType, 'kibana', false) - ).rejects.toThrow(); - }); - - it('should handle index_not_found_exception errors gracefully', async () => { - /* - const esClient = esClientFactory( - () => new Promise((resolve, reject) => reject(exceptionResponse)) - ); - */ const result = await getIndices(http, mockIndexPatternCreationType, 'kibana', false); expect(result.length).toBe(0); }); diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.ts b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.ts index f651af1e302d2f..2f33cbbbc2f6a7 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.ts +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.ts @@ -17,7 +17,7 @@ * under the License. */ -import { get, sortBy } from 'lodash'; +import { sortBy } from 'lodash'; import { HttpStart } from 'kibana/public'; import { i18n } from '@kbn/i18n'; import { IndexPatternCreationConfig } from '../../../../../index_pattern_management/public'; @@ -54,41 +54,40 @@ export async function getIndices( return []; } + const query = showAllIndices ? { expand_wildcards: 'all' } : undefined; + try { - const query = showAllIndices ? { expand_wildcards: 'all' } : undefined; const response = await http.get( `/api/index-pattern-management/resolve_index/${pattern}`, { query } ); - return responseToItemArray(response, indexPatternCreationType); - } catch (err) { - const type = get(err, 'body.error.caused_by.type'); - if (type === 'index_not_found_exception') { - // This happens in a CSS environment when the controlling node returns a 500 even though the data - // nodes returned a 404. Remove this when/if this is handled: https://github.com/elastic/elasticsearch/issues/27461 + if (!response) { return []; } - throw err; + + return responseToItemArray(response, indexPatternCreationType); + } catch { + return []; } } -const responseToItemArray = ( +export const responseToItemArray = ( response: ResolveIndexResponse, indexPatternCreationType: IndexPatternCreationConfig ): MatchedItem[] => { const source: MatchedItem[] = []; - response.indices.forEach((index) => { + (response.indices || []).forEach((index) => { source.push({ name: index.name, tags: indexPatternCreationType.getIndexTags(index.name), item: index, }); }); - response.aliases.forEach((alias) => { + (response.aliases || []).forEach((alias) => { source.push({ name: alias.name, tags: [{ key: 'alias', name: aliasLabel }], item: alias }); }); - response.data_streams.forEach((dataStream) => { + (response.data_streams || []).forEach((dataStream) => { source.push({ name: dataStream.name, tags: [{ key: 'data_stream', name: dataStreamLabel }], diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/types.ts b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/types.ts index 541d86dcedfd59..654945e7594a8a 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/types.ts +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/types.ts @@ -27,9 +27,9 @@ export interface MatchedItem { } export interface ResolveIndexResponse { - indices: ResolveIndexResponseItemIndex[]; - aliases: ResolveIndexResponseItemAlias[]; - data_streams: ResolveIndexResponseItemDataStream[]; + indices?: ResolveIndexResponseItemIndex[]; + aliases?: ResolveIndexResponseItemAlias[]; + data_streams?: ResolveIndexResponseItemDataStream[]; } export interface ResolveIndexResponseItem { From 299091c82f3714b670a8c8fad5aa332671c1fceb Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Thu, 2 Jul 2020 17:33:43 -0500 Subject: [PATCH 21/76] test field preselect and update snapshots --- .../step_index_pattern.test.tsx | 57 ++++++++- .../step_index_pattern/step_index_pattern.tsx | 53 ++++----- .../step_time_field.test.tsx.snap | 110 +++++++----------- .../index_pattern_management/server/index.ts | 1 - 4 files changed, 121 insertions(+), 100 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.test.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.test.tsx index 332acfc99b61ac..de4a01c843a3cf 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.test.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.test.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { SavedObjectsFindResponsePublic } from 'kibana/public'; -import { StepIndexPattern } from '../step_index_pattern'; +import { StepIndexPattern, canPreselectTimeField } from './step_index_pattern'; import { Header } from './components/header'; import { IndexPatternCreationConfig } from '../../../../../../../plugins/index_pattern_management/public'; import { mockManagementPlugin } from '../../../../mocks'; @@ -205,4 +205,59 @@ describe('StepIndexPattern', () => { await new Promise((resolve) => process.nextTick(resolve)); expect(component.state('exactMatchedIndices')).toEqual([]); }); + + it('it can preselect time field', async () => { + const dataStream1 = { + name: 'data stream 1', + tags: [], + item: { name: 'data stream 1', backing_indices: [], timestamp_field: 'timestamp_field' }, + }; + + const dataStream2 = { + name: 'data stream 2', + tags: [], + item: { name: 'data stream 2', backing_indices: [], timestamp_field: 'timestamp_field' }, + }; + + const differentDataStream = { + name: 'different data stream', + tags: [], + item: { name: 'different data stream 2', backing_indices: [], timestamp_field: 'x' }, + }; + + const index = { + name: 'index', + tags: [], + item: { + name: 'index', + }, + }; + + const alias = { + name: 'alias', + tags: [], + item: { + name: 'alias', + indices: [], + }, + }; + + expect(canPreselectTimeField([index]).canPreselect).toEqual(false); + expect(canPreselectTimeField([alias]).canPreselect).toEqual(false); + expect(canPreselectTimeField([index, alias, dataStream1]).canPreselect).toEqual(false); + + expect(canPreselectTimeField([dataStream1])).toEqual({ + canPreselect: true, + timeFieldName: 'timestamp_field', + }); + + expect(canPreselectTimeField([dataStream1, dataStream2])).toEqual({ + canPreselect: true, + timeFieldName: 'timestamp_field', + }); + + expect( + canPreselectTimeField([dataStream1, dataStream2, differentDataStream]).canPreselect + ).toEqual(false); + }); }); diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx index 08a45ff023e017..c6d9ec9de227b1 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx @@ -62,6 +62,29 @@ interface StepIndexPatternState { indexPatternName: string; } +export const canPreselectTimeField = (indices: MatchedItem[]) => + indices.reduce( + ( + { canPreselect, timeFieldName }: { canPreselect: boolean; timeFieldName?: string }, + matchedItem + ) => { + const dataStreamItem = matchedItem.item as ResolveIndexResponseItemDataStream; + const dataStreamTimestampField = dataStreamItem.timestamp_field; + const isDataStream = !!dataStreamItem.timestamp_field; + const timestampFieldMatches = + timeFieldName === undefined || timeFieldName === dataStreamTimestampField; + + return { + canPreselect: canPreselect && isDataStream && timestampFieldMatches, + timeFieldName: dataStreamTimestampField || timeFieldName, + }; + }, + { + canPreselect: true, + timeFieldName: undefined, + } + ); + export class StepIndexPattern extends Component { static contextType = contextType; @@ -308,33 +331,7 @@ export class StepIndexPattern extends Component { - const dataStreamItem = matchedItem.item as ResolveIndexResponseItemDataStream; - const dataStreamTimestampField = dataStreamItem.timestamp_field; - const isDataStream = !!dataStreamItem.timestamp_field; - const timestampFieldMatches = - timeFieldName === undefined || timeFieldName === dataStreamTimestampField; - - return { - allMatchingDataStreams: allMatchingDataStreams && isDataStream && timestampFieldMatches, - timeFieldName: dataStreamTimestampField || timeFieldName, - }; - }, - { - allMatchingDataStreams: true, - timeFieldName: undefined, - } - ); + const { canPreselect, timeFieldName: matchingTimestamp } = canPreselectTimeField(indices); return (
goToNextStep(query, uniformDataStreams ? matchingTimestamp : undefined)} + goToNextStep={() => goToNextStep(query, canPreselect ? matchingTimestamp : undefined)} isNextStepDisabled={isNextStepDisabled} /> ); diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/__snapshots__/step_time_field.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/__snapshots__/step_time_field.test.tsx.snap index f865a1ddfd2233..ff293aa2dd9c2c 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/__snapshots__/step_time_field.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/__snapshots__/step_time_field.test.tsx.snap @@ -17,9 +17,7 @@ exports[`StepTimeField should enable the action button if the user decides to no `; exports[`StepTimeField should render "Custom index pattern ID already exists" when error is "Conflict" 1`] = ` - +
- + - + `; exports[`StepTimeField should render a loading state when creating the index pattern 1`] = ` - - + - - - - - - - - - - + + + + + + + + `; exports[`StepTimeField should render a selected timeField 1`] = ` - +
- + - + `; exports[`StepTimeField should render advanced options 1`] = ` - +
- + - + `; exports[`StepTimeField should render advanced options with an index pattern id 1`] = ` - +
- + - + `; exports[`StepTimeField should render any error message 1`] = ` - +
- + - + `; exports[`StepTimeField should render normally 1`] = ` - +
- + - + `; exports[`StepTimeField should render timeFields 1`] = ` - +
- + - + `; diff --git a/src/plugins/index_pattern_management/server/index.ts b/src/plugins/index_pattern_management/server/index.ts index a7c2bf18e5ada5..02a46315898323 100644 --- a/src/plugins/index_pattern_management/server/index.ts +++ b/src/plugins/index_pattern_management/server/index.ts @@ -19,7 +19,6 @@ import { PluginInitializerContext } from 'src/core/server'; import { IndexPatternManagementPlugin } from './plugin'; -// export { IndexPatternManagementSetup, IndexPatternManagementStart } from './plugin'; export function plugin(initializerContext: PluginInitializerContext) { return new IndexPatternManagementPlugin(initializerContext); From ddbe5a4d1658286cdb517de245f22530e0cc3254 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Thu, 2 Jul 2020 20:30:53 -0500 Subject: [PATCH 22/76] remove comments --- .../components/header/header.test.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.test.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.test.tsx index 90334f5822a520..0d14d2f579d3b5 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.test.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.test.tsx @@ -23,9 +23,7 @@ import { mount } from 'enzyme'; import { KibanaContextProvider } from 'src/plugins/kibana_react/public'; import { mockManagementPlugin } from '../../../../mocks'; import { DocLinksStart } from 'kibana/public'; -// import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; -// links.indexPatterns const docLinks = { links: { indexPatterns: {} } } as DocLinksStart; describe('Header', () => { From 6adea1ada6a97cee0f3ff038553bccd3a785b83b Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Thu, 2 Jul 2020 22:44:12 -0500 Subject: [PATCH 23/76] ui rendering updates --- .../create_index_pattern_wizard.test.tsx.snap | 480 +++++++++++++++--- .../header/__snapshots__/header.test.tsx.snap | 400 +++++++++------ .../components/header/header.test.tsx | 9 + .../components/header/header.tsx | 95 ++-- .../header/__snapshots__/header.test.tsx.snap | 158 +++--- .../components/header/header.tsx | 52 +- .../status_message.test.tsx.snap | 300 +++++------ .../status_message/status_message.tsx | 68 +-- .../step_time_field.test.tsx.snap | 27 +- .../header/__snapshots__/header.test.tsx.snap | 6 +- .../components/header/header.tsx | 4 +- .../__snapshots__/time_field.test.tsx.snap | 212 +++----- .../components/time_field/time_field.tsx | 126 +++-- .../step_time_field/step_time_field.tsx | 21 +- .../create_index_pattern_wizard.tsx | 58 ++- 15 files changed, 1218 insertions(+), 798 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.tsx.snap index 5c955bbd3283ec..0e8a780e614981 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.tsx.snap @@ -1,34 +1,118 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`CreateIndexPatternWizard defaults to the loading state 1`] = ` - -
-
- -
+ + -
+ `; exports[`CreateIndexPatternWizard renders index pattern step when there are indices 1`] = ` - -
+ +
+ -
+ -
+ `; exports[`CreateIndexPatternWizard renders the empty state when there are no indices 1`] = ` - -
-
- -
+ + -
+ `; exports[`CreateIndexPatternWizard renders time field step when step is set to 2 1`] = ` - -
+ +
+ -
+ -
+ `; exports[`CreateIndexPatternWizard renders when there are no indices but there are remote clusters 1`] = ` - -
+ +
+ -
+ -
+ `; exports[`CreateIndexPatternWizard shows system indices even if there are no other indices if the include system indices is toggled 1`] = ` - -
+ +
+ -
+ -
+ `; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/__snapshots__/header.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/__snapshots__/header.test.tsx.snap index 1ef99f498718ce..9e00c6d657966f 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/__snapshots__/header.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/__snapshots__/header.test.tsx.snap @@ -2,6 +2,13 @@ exports[`Header should render a different name, prompt, and beta tag if provided 1`] = `
- + +
+ +
- -
+ + multiple + , + "single": + filebeat-4-3-22 + , + "star": + filebeat-* + , + } + } > - -
- Read documentation", - } - } + + An index pattern can match a single index, for example, + + - Read documentation", - } - } - /> - - + + filebeat-4-3-22 + + + + + , or + + multiple + + indices, + + -
- -
- -
- + + + filebeat-* + + + + + . + +
+
+ + + +

- +
Test prompt
- -
-
`; exports[`Header should render normally 1`] = `
- +
+ + +
- -
+ + multiple + , + "single": + filebeat-4-3-22 + , + "star": + filebeat-* + , + } + } > - -
- Read documentation", - } - } + + An index pattern can match a single index, for example, + + - Read documentation", - } - } - /> - - + + filebeat-4-3-22 + + + + + , or + + multiple + + indices, + + -
- -
- -
- + + + filebeat-* + + + + + . + +
+
+ + + +

- - -
-
+
`; exports[`Header should render without including system indices 1`] = `
- +
+ + +
- -
+ + multiple + , + "single": + filebeat-4-3-22 + , + "star": + filebeat-* + , + } + } > - -
- Read documentation", - } - } + + An index pattern can match a single index, for example, + + - Read documentation", - } - } - /> - - + + filebeat-4-3-22 + + + + + , or + + multiple + + indices, + + -
- -
- -
- + + + filebeat-* + + + + + . + +
+
+ + + +

- - -
-
+
`; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.test.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.test.tsx index d12e0401380b9e..acad0351668a5e 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.test.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.test.tsx @@ -22,10 +22,16 @@ import { Header } from '../header'; import { mount } from 'enzyme'; import { KibanaContextProvider } from 'src/plugins/kibana_react/public'; import { mockManagementPlugin } from '../../../../mocks'; +import { DocLinksStart } from 'kibana/public'; describe('Header', () => { const indexPatternName = 'test index pattern'; const mockedContext = mockManagementPlugin.createIndexPatternManagmentContext(); + const mockedDocLinks = { + links: { + indexPatterns: {}, + }, + } as DocLinksStart; it('should render normally', () => { const component = mount( @@ -33,6 +39,7 @@ describe('Header', () => { indexPatternName={indexPatternName} isIncludingSystemIndices={true} onChangeIncludingSystemIndices={() => {}} + docLinks={mockedDocLinks} />, { wrappingComponent: KibanaContextProvider, @@ -51,6 +58,7 @@ describe('Header', () => { indexPatternName={indexPatternName} isIncludingSystemIndices={false} onChangeIncludingSystemIndices={() => {}} + docLinks={mockedDocLinks} />, { wrappingComponent: KibanaContextProvider, @@ -71,6 +79,7 @@ describe('Header', () => { prompt={
Test prompt
} indexPatternName={indexPatternName} isBeta={true} + docLinks={mockedDocLinks} />, { wrappingComponent: KibanaContextProvider, diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx index 48e599613f9534..f6965f5d1c5147 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx @@ -17,24 +17,22 @@ * under the License. */ -import React, { Fragment } from 'react'; +import React from 'react'; import { EuiBetaBadge, EuiSpacer, EuiTitle, - EuiFlexGroup, - EuiFlexItem, EuiText, - EuiTextColor, EuiSwitch, EuiSwitchEvent, - EuiIcon, - EuiHorizontalRule, + EuiCode, + EuiLink, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; +import { DocLinksStart } from 'kibana/public'; import { useKibana } from '../../../../../../../plugins/kibana_react/public'; import { IndexPatternManagmentContext } from '../../../../types'; @@ -45,6 +43,7 @@ export const Header = ({ isIncludingSystemIndices, onChangeIncludingSystemIndices, isBeta = false, + docLinks, }: { prompt?: React.ReactNode; indexPatternName: string; @@ -52,6 +51,7 @@ export const Header = ({ isIncludingSystemIndices: boolean; onChangeIncludingSystemIndices: (event: EuiSwitchEvent) => void; isBeta?: boolean; + docLinks: DocLinksStart; }) => { const changeTitle = useKibana().services.chrome.docTitle.change; const createIndexPatternHeader = i18n.translate( @@ -62,19 +62,6 @@ export const Header = ({ } ); - const createIndexPatternLabel = i18n.translate('indexPatternManagement.createIndexPatternLabel', { - defaultMessage: - 'An index pattern can match a single source, for example, filebeat-4-3-22, or multiple data sources, filebeat-*. {docsLink}', - values: { - docsLink: - '' + - i18n.translate('indexPatternManagement.indexPatternDocLink', { - defaultMessage: 'Read documentation', - }) + - '', - }, - }); - changeTitle(createIndexPatternHeader); return ( @@ -83,53 +70,61 @@ export const Header = ({

{createIndexPatternHeader} {isBeta ? ( - + <> {' '} - + ) : null}

- - - - + +

+ multiple, + single: filebeat-4-3-22, + star: filebeat-*, + }} + /> +
+ + - - - - + +

+
{showSystemIndices ? ( - - - - } - id="checkboxShowSystemIndices" - checked={isIncludingSystemIndices} - onChange={onChangeIncludingSystemIndices} - /> - - + <> + + + } + id="checkboxShowSystemIndices" + checked={isIncludingSystemIndices} + onChange={onChangeIncludingSystemIndices} + /> + ) : null} {prompt ? ( - - + <> + {prompt} - + ) : null} -
); }; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/__snapshots__/header.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/__snapshots__/header.test.tsx.snap index 6c370a45f3172e..c4f735558b1f21 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/__snapshots__/header.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/__snapshots__/header.test.tsx.snap @@ -16,10 +16,7 @@ exports[`Header should mark the input as invalid 1`] = ` - + -

- - * - , - "characterList": - % - , - } + + + * + , + } + } + /> + + + % + , } - /> -

-
+ } + /> + } isInvalid={true} label={ @@ -80,18 +84,29 @@ exports[`Header should mark the input as invalid 1`] = ` - - - + + + +
@@ -113,10 +128,7 @@ exports[`Header should render normally 1`] = ` - + -

- - * - , - "characterList": - % - , - } + + + * + , + } + } + /> + + + % + , } - /> -

- + } + /> + } isInvalid={false} label={ @@ -173,18 +192,29 @@ exports[`Header should render normally 1`] = ` - - - + + + +
diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx index f4b34f046d806e..cb27d1c3d6fbd6 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx @@ -63,7 +63,7 @@ export const Header: React.FC = ({ - + = ({ isInvalid={isInputInvalid} error={errors} helpText={ -
-

- *, - characterList: {characterList}, - }} - /> -

-
+ <> + * }} + />{' '} + {characterList} }} + /> + } > = ({
- goToNextStep(query)} - isDisabled={isNextStepDisabled} - data-test-subj="createIndexPatternGoToStep2Button" - > - - + + goToNextStep(query)} + isDisabled={isNextStepDisabled} + data-test-subj="createIndexPatternGoToStep2Button" + > + + +
diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__snapshots__/status_message.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__snapshots__/status_message.test.tsx.snap index d526a5851d3cfb..925aaf341a7a3b 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__snapshots__/status_message.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__snapshots__/status_message.test.tsx.snap @@ -1,194 +1,156 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`StatusMessage should render with exact matches 1`] = ` - - - - - - -   - - +   + + - , - "strongSuccess": - - , - } + } + /> + , } - /> - - - - + } + /> + + } +/> `; exports[`StatusMessage should render with no partial matches 1`] = ` - - - - - - - + + - , - } + } + /> + , } - /> - - - - + } + /> + + } +/> `; exports[`StatusMessage should render with partial matches 1`] = ` - - - - - - - + + - , - } + } + /> + , } - /> - - - - + } + /> + + } +/> `; exports[`StatusMessage should render without a query 1`] = ` - - - - - -

- -

-
-
-
-
+ + + 2 + indices + , + } + } + /> + + } +/> `; exports[`StatusMessage should show that no indices exist 1`] = ` - - - - - - - - - - + + + + } +/> `; exports[`StatusMessage should show that system indices exist 1`] = ` - - - - - - - - - - + + + + } +/> `; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx index eb3a5706978bfe..e979e7ed7df4f1 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx @@ -19,7 +19,8 @@ import React from 'react'; -import { EuiText, EuiTextColor, EuiIcon, EuiSpacer } from '@elastic/eui'; +import { EuiCallOut } from '@elastic/eui'; +import { EuiIconType } from '@elastic/eui/src/components/icon/icon'; import { FormattedMessage } from '@kbn/i18n/react'; import { MatchedItem } from '../../../../types'; @@ -41,35 +42,32 @@ export const StatusMessage: React.FC = ({ query, showSystemIndices, }) => { - let statusIcon; + let statusIcon: EuiIconType | undefined; let statusMessage; - let statusColor: 'default' | 'secondary' | undefined; + let statusColor: 'primary' | 'success' | undefined; const allIndicesLength = allIndices.length; if (query.length === 0) { - statusIcon = null; - statusColor = 'default'; + statusIcon = undefined; + statusColor = 'primary'; - if (allIndicesLength > 1) { + if (allIndicesLength >= 1) { statusMessage = ( - -

- -

-
+ + {allIndicesLength} indices }} + /> + ); } else if (!isIncludingSystemIndices && showSystemIndices) { statusMessage = ( ); @@ -85,22 +83,14 @@ export const StatusMessage: React.FC = ({ } } else if (exactMatchedIndices.length) { statusIcon = 'check'; - statusColor = 'secondary'; + statusColor = 'success'; statusMessage = (   - - - ), strongIndices: ( = ({ ); } else if (partialMatchedIndices.length) { - statusIcon = null; - statusColor = 'default'; + statusIcon = undefined; + statusColor = 'primary'; statusMessage = ( = ({ ); } else if (allIndicesLength) { - statusIcon = null; - statusColor = 'default'; + statusIcon = undefined; + statusColor = 'primary'; statusMessage = ( = ({ } return ( - <> - - - - {statusIcon ? : null} - {statusMessage} - - - + ); }; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/__snapshots__/step_time_field.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/__snapshots__/step_time_field.test.tsx.snap index ff293aa2dd9c2c..6cc92d20cfdcc1 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/__snapshots__/step_time_field.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/__snapshots__/step_time_field.test.tsx.snap @@ -75,22 +75,33 @@ exports[`StepTimeField should render "Custom index pattern ID already exists" wh exports[`StepTimeField should render a loading state when creating the index pattern 1`] = ` - + +

+ +

+
- - - +
`; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/header/__snapshots__/header.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/header/__snapshots__/header.test.tsx.snap index 63008ec5b52e79..9efda4fdac7f91 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/header/__snapshots__/header.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/header/__snapshots__/header.test.tsx.snap @@ -16,11 +16,9 @@ exports[`Header should render normally 1`] = ` - + = ({ indexPattern, indexPatternName } - + {indexPattern}
, indexPatternName, diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/time_field/__snapshots__/time_field.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/time_field/__snapshots__/time_field.test.tsx.snap index 886a4ccad39ccf..73277b1963626b 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/time_field/__snapshots__/time_field.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/time_field/__snapshots__/time_field.test.tsx.snap @@ -2,55 +2,33 @@ exports[`TimeField should render a loading state 1`] = ` + +

+ +

+
+ -

- -

-

- -

- - } label={ - - - - - - - - - - + + } + labelAppend={ + } labelType="label" > @@ -73,62 +51,43 @@ exports[`TimeField should render a loading state 1`] = ` exports[`TimeField should render a selected time field 1`] = ` + +

+ +

+
+ -

- -

-

- -

- - } label={ - + } + labelAppend={ + - - - - - - - - - - - + + + } labelType="label" > @@ -154,62 +113,43 @@ exports[`TimeField should render a selected time field 1`] = ` exports[`TimeField should render normally 1`] = ` + +

+ +

+
+ -

- -

-

- -

- - } label={ - + } + labelAppend={ + - - - - - - - - - - - + + + } labelType="label" > diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.tsx index b4ed37118966ba..7a3d72551f4641 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.tsx @@ -24,8 +24,7 @@ import React from 'react'; import { EuiForm, EuiFormRow, - EuiFlexGroup, - EuiFlexItem, + EuiSpacer, EuiLink, EuiSelect, EuiText, @@ -54,77 +53,68 @@ export const TimeField: React.FC = ({ }) => ( {isVisible ? ( - - - - - - - - {isLoading ? ( - - ) : ( - + <> + +

+ +

+
+ + + } + labelAppend={ + isLoading ? ( + + ) : ( + + - )} -
-
- } - helpText={ -
-

- -

-

- -

-
- } - > - {isLoading ? ( - - ) : ( - - )} - + + ) + } + > + {isLoading ? ( + + ) : ( + + )} + + ) : (

diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx index 4b720d3ed16c7e..0e333844b39134 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx @@ -22,7 +22,7 @@ import { EuiCallOut, EuiFlexGroup, EuiFlexItem, - EuiText, + EuiTitle, EuiSpacer, EuiLoadingSpinner, EuiHorizontalRule, @@ -185,17 +185,20 @@ export class StepTimeField extends Component + - + +

+ +

+ + - - - +
); diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx index 9ad6f942c5637f..b47985ae9e47df 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx @@ -22,12 +22,14 @@ import React, { ReactElement, Component } from 'react'; import { EuiGlobalToastList, EuiGlobalToastListToast, - EuiPanel, + EuiPageContent, EuiSwitchEvent, + EuiHorizontalRule, } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; import { withRouter, RouteComponentProps } from 'react-router-dom'; +import { DocLinksStart } from 'src/core/public'; import { StepIndexPattern } from './components/step_index_pattern'; import { StepTimeField } from './components/step_time_field'; import { Header } from './components/header'; @@ -51,6 +53,7 @@ interface CreateIndexPatternWizardState { toasts: EuiGlobalToastListToast[]; indexPatternCreationType: IndexPatternCreationConfig; selectedTimeField?: string; + docLinks: DocLinksStart; } export class CreateIndexPatternWizard extends Component< @@ -77,6 +80,7 @@ export class CreateIndexPatternWizard extends Component< isIncludingSystemIndices: false, toasts: [], indexPatternCreationType: context.services.indexPatternManagementStart.creation.getType(type), + docLinks: context.services.docLinks, }; } @@ -224,11 +228,14 @@ export class CreateIndexPatternWizard extends Component< return (
); } @@ -257,30 +264,39 @@ export class CreateIndexPatternWizard extends Component< ); } + const header = this.renderHeader(); + if (step === 1) { const { location } = this.props; const initialQuery = new URLSearchParams(location.search).get('id') || undefined; return ( - + + {header} + + + ); } if (step === 2) { return ( - + + {header} + + + ); } @@ -294,15 +310,11 @@ export class CreateIndexPatternWizard extends Component< }; render() { - const header = this.renderHeader(); const content = this.renderContent(); return ( - -
- {header} - {content} -
+ <> + {content} { @@ -310,7 +322,7 @@ export class CreateIndexPatternWizard extends Component< }} toastLifeTimeMs={6000} /> -
+ ); } } From 7dda4a0d024cbe94c2dcdd54bc38cf6a6a06d745 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Thu, 2 Jul 2020 23:14:00 -0500 Subject: [PATCH 24/76] simplify timestamp preset code --- .../step_index_pattern.test.tsx | 22 +++++++------------ .../step_index_pattern/step_index_pattern.tsx | 12 +++++----- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.test.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.test.tsx index de4a01c843a3cf..c88918041ca810 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.test.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.test.tsx @@ -242,22 +242,16 @@ describe('StepIndexPattern', () => { }, }; - expect(canPreselectTimeField([index]).canPreselect).toEqual(false); - expect(canPreselectTimeField([alias]).canPreselect).toEqual(false); - expect(canPreselectTimeField([index, alias, dataStream1]).canPreselect).toEqual(false); + expect(canPreselectTimeField([index])).toEqual(undefined); + expect(canPreselectTimeField([alias])).toEqual(undefined); + expect(canPreselectTimeField([index, alias, dataStream1])).toEqual(undefined); - expect(canPreselectTimeField([dataStream1])).toEqual({ - canPreselect: true, - timeFieldName: 'timestamp_field', - }); + expect(canPreselectTimeField([dataStream1])).toEqual('timestamp_field'); - expect(canPreselectTimeField([dataStream1, dataStream2])).toEqual({ - canPreselect: true, - timeFieldName: 'timestamp_field', - }); + expect(canPreselectTimeField([dataStream1, dataStream2])).toEqual('timestamp_field'); - expect( - canPreselectTimeField([dataStream1, dataStream2, differentDataStream]).canPreselect - ).toEqual(false); + expect(canPreselectTimeField([dataStream1, dataStream2, differentDataStream])).toEqual( + undefined + ); }); }); diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx index c6d9ec9de227b1..55a568a10c8c77 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx @@ -62,8 +62,8 @@ interface StepIndexPatternState { indexPatternName: string; } -export const canPreselectTimeField = (indices: MatchedItem[]) => - indices.reduce( +export const canPreselectTimeField = (indices: MatchedItem[]) => { + const preselectStatus = indices.reduce( ( { canPreselect, timeFieldName }: { canPreselect: boolean; timeFieldName?: string }, matchedItem @@ -85,6 +85,9 @@ export const canPreselectTimeField = (indices: MatchedItem[]) => } ); + return preselectStatus.canPreselect ? preselectStatus.timeFieldName : undefined; +}; + export class StepIndexPattern extends Component { static contextType = contextType; @@ -330,9 +333,6 @@ export class StepIndexPattern extends Component 0; const isNextStepDisabled = containsErrors || indices.length === 0 || indexPatternExists; - // if all are data streams with same time field then create index pattern - const { canPreselect, timeFieldName: matchingTimestamp } = canPreselectTimeField(indices); - return (
goToNextStep(query, canPreselect ? matchingTimestamp : undefined)} + goToNextStep={() => goToNextStep(query, canPreselectTimeField(indices))} isNextStepDisabled={isNextStepDisabled} /> ); From 4fc352768df12e7e9bef6d8a3755d93d3b2abb88 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Fri, 3 Jul 2020 00:05:29 -0500 Subject: [PATCH 25/76] add functional test, update text --- .../header/__snapshots__/header.test.tsx.snap | 18 +++--- .../components/header/header.tsx | 2 +- .../status_message.test.tsx.snap | 21 ++----- .../status_message/status_message.tsx | 16 ++---- .../create_index_pattern_wizard.tsx | 1 + .../_create_index_pattern_wizard.js | 55 +++++++++++++++++++ 6 files changed, 74 insertions(+), 39 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/__snapshots__/header.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/__snapshots__/header.test.tsx.snap index 9e00c6d657966f..124b57f7241eef 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/__snapshots__/header.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/__snapshots__/header.test.tsx.snap @@ -51,7 +51,7 @@ exports[`Header should render a different name, prompt, and beta tag if provided >

- An index pattern can match a single index, for example, + An index pattern can match a single source, for example, multiple - indices, + data souces,

- An index pattern can match a single index, for example, + An index pattern can match a single source, for example, multiple - indices, + data souces,

- An index pattern can match a single index, for example, + An index pattern can match a single source, for example, multiple - indices, + data souces, multiple, single: filebeat-4-3-22, diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__snapshots__/status_message.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__snapshots__/status_message.test.tsx.snap index 925aaf341a7a3b..94da6bcca0f6aa 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__snapshots__/status_message.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__snapshots__/status_message.test.tsx.snap @@ -10,21 +10,11 @@ exports[`StatusMessage should render with exact matches 1`] = `   - - , + "sourceCount": 1, } } /> @@ -105,14 +95,11 @@ exports[`StatusMessage should render without a query 1`] = ` title={ - 2 - indices - , + "sourceCount": 2, } } /> diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx index e979e7ed7df4f1..102adcf5b1426c 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx @@ -57,8 +57,8 @@ export const StatusMessage: React.FC = ({ {allIndicesLength} indices }} + defaultMessage="Your index pattern can match any of your {sourceCount} sources below." + values={{ sourceCount: allIndicesLength }} /> ); @@ -89,17 +89,9 @@ export const StatusMessage: React.FC = ({   - - - ), + sourceCount: exactMatchedIndices.length, }} /> diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx index b47985ae9e47df..695a84367ad02d 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx @@ -295,6 +295,7 @@ export class CreateIndexPatternWizard extends Component< goToPreviousStep={this.goToIndexPatternStep} createIndexPattern={this.createIndexPattern} indexPatternCreationType={this.state.indexPatternCreationType} + selectedTimeField={this.state.selectedTimeField} /> ); diff --git a/test/functional/apps/management/_create_index_pattern_wizard.js b/test/functional/apps/management/_create_index_pattern_wizard.js index 8209f3e1ac9d6d..292fbec5d31d2b 100644 --- a/test/functional/apps/management/_create_index_pattern_wizard.js +++ b/test/functional/apps/management/_create_index_pattern_wizard.js @@ -22,6 +22,8 @@ import expect from '@kbn/expect'; export default function ({ getService, getPageObjects }) { const kibanaServer = getService('kibanaServer'); const testSubjects = getService('testSubjects'); + const es = getService('legacyEs'); + const browser = getService('browser'); const PageObjects = getPageObjects(['settings', 'common']); describe('"Create Index Pattern" wizard', function () { @@ -48,5 +50,58 @@ export default function ({ getService, getPageObjects }) { expect(isEnabled).to.be.ok(); }); }); + + describe('can create data stream index patttern', async () => { + es.transport.request({ + path: '/_index_template/generic-logs', + method: 'PUT', + body: ```{ + "index_patterns": ["logs-*", "test_data_stream"], + "template": { + "mappings" : { + "properties": { + "@timestamp": { + "type": "date" + } + } + } + }, + "data_stream": { + "timestamp_field": "@timestamp" + } + }```, + }); + + es.transport.request({ + path: '/_data_stream/test_data_stream', + method: 'PUT', + }); + + await PageObjects.settings.setIndexPatternField('test_data_stream'); + await PageObjects.common.sleep(1000); + await (await PageObjects.settings.getCreateIndexPatternGoToStep2Button).click(); + await (await this.getCreateIndexPatternButton()).click(); + expect((await browser.getCurrentUrl()).match(/indexPatterns\/.+\?/)).equal(true); + }); + + describe('can create alias index patttern', async () => { + es.transport.request({ + path: '/blogs/_doc', + method: 'POST', + body: '{ "user" : "matt", "message" : 20 }', + }); + + es.transport.request({ + path: '/_aliases', + method: 'POST', + body: '{ "actions" : [{ "add" : { "index" : "blogs", "alias" : "alias1" } }]}', + }); + + await PageObjects.settings.setIndexPatternField('alias1'); + await PageObjects.common.sleep(1000); + await (await PageObjects.settings.getCreateIndexPatternGoToStep2Button).click(); + await (await this.getCreateIndexPatternButton()).click(); + expect((await browser.getCurrentUrl()).match(/indexPatterns\/.+\?/)).equal(true); + }); }); } From e40db395b279d575ae1a27b78dd6bfece8e2f1a1 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Fri, 3 Jul 2020 00:42:58 -0500 Subject: [PATCH 26/76] fix functional test --- .../_create_index_pattern_wizard.js | 68 ++++++++++--------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/test/functional/apps/management/_create_index_pattern_wizard.js b/test/functional/apps/management/_create_index_pattern_wizard.js index 292fbec5d31d2b..74d2ddcce05ed4 100644 --- a/test/functional/apps/management/_create_index_pattern_wizard.js +++ b/test/functional/apps/management/_create_index_pattern_wizard.js @@ -51,11 +51,13 @@ export default function ({ getService, getPageObjects }) { }); }); - describe('can create data stream index patttern', async () => { - es.transport.request({ - path: '/_index_template/generic-logs', - method: 'PUT', - body: ```{ + describe('data streams', () => { + it('can be an index pattern', async () => { + await es.init(); + await es.transport.request({ + path: '/_index_template/generic-logs', + method: 'PUT', + body: ```{ "index_patterns": ["logs-*", "test_data_stream"], "template": { "mappings" : { @@ -70,38 +72,42 @@ export default function ({ getService, getPageObjects }) { "timestamp_field": "@timestamp" } }```, - }); + }); - es.transport.request({ - path: '/_data_stream/test_data_stream', - method: 'PUT', - }); + await es.transport.request({ + path: '/_data_stream/test_data_stream', + method: 'PUT', + }); - await PageObjects.settings.setIndexPatternField('test_data_stream'); - await PageObjects.common.sleep(1000); - await (await PageObjects.settings.getCreateIndexPatternGoToStep2Button).click(); - await (await this.getCreateIndexPatternButton()).click(); - expect((await browser.getCurrentUrl()).match(/indexPatterns\/.+\?/)).equal(true); + await PageObjects.settings.setIndexPatternField('test_data_stream'); + await PageObjects.common.sleep(1000); + await (await PageObjects.settings.getCreateIndexPatternGoToStep2Button).click(); + await (await this.getCreateIndexPatternButton()).click(); + expect((await browser.getCurrentUrl()).match(/indexPatterns\/.+\?/)).equal(true); + }); }); - describe('can create alias index patttern', async () => { - es.transport.request({ - path: '/blogs/_doc', - method: 'POST', - body: '{ "user" : "matt", "message" : 20 }', - }); + describe('index alias', () => { + it('can be an index pattern', async () => { + await es.init(); + await es.transport.request({ + path: '/blogs/_doc', + method: 'POST', + body: '{ "user" : "matt", "message" : 20 }', + }); - es.transport.request({ - path: '/_aliases', - method: 'POST', - body: '{ "actions" : [{ "add" : { "index" : "blogs", "alias" : "alias1" } }]}', - }); + await es.transport.request({ + path: '/_aliases', + method: 'POST', + body: '{ "actions" : [{ "add" : { "index" : "blogs", "alias" : "alias1" } }]}', + }); - await PageObjects.settings.setIndexPatternField('alias1'); - await PageObjects.common.sleep(1000); - await (await PageObjects.settings.getCreateIndexPatternGoToStep2Button).click(); - await (await this.getCreateIndexPatternButton()).click(); - expect((await browser.getCurrentUrl()).match(/indexPatterns\/.+\?/)).equal(true); + await PageObjects.settings.setIndexPatternField('alias1'); + await PageObjects.common.sleep(1000); + await (await PageObjects.settings.getCreateIndexPatternGoToStep2Button).click(); + await (await this.getCreateIndexPatternButton()).click(); + expect((await browser.getCurrentUrl()).match(/indexPatterns\/.+\?/)).equal(true); + }); }); }); } From 7f8802e3b5794222211f4c63141d847801619dc5 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Fri, 3 Jul 2020 16:42:22 -0500 Subject: [PATCH 27/76] fix functional tests --- .../step_time_field/step_time_field.tsx | 3 ++ .../_create_index_pattern_wizard.js | 52 ++++++++----------- 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx index 0e333844b39134..5d33a08557fed5 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx @@ -88,6 +88,9 @@ export class StepTimeField extends Component { it('can be an index pattern', async () => { - await es.init(); await es.transport.request({ path: '/_index_template/generic-logs', method: 'PUT', - body: ```{ - "index_patterns": ["logs-*", "test_data_stream"], - "template": { - "mappings" : { - "properties": { - "@timestamp": { - "type": "date" - } - } - } + body: { + index_patterns: ['logs-*', 'test_data_stream'], + template: { + mappings: { + properties: { + '@timestamp': { + type: 'date', + }, + }, + }, + }, + data_stream: { + timestamp_field: '@timestamp', + }, }, - "data_stream": { - "timestamp_field": "@timestamp" - } - }```, }); await es.transport.request({ @@ -79,34 +77,30 @@ export default function ({ getService, getPageObjects }) { method: 'PUT', }); - await PageObjects.settings.setIndexPatternField('test_data_stream'); - await PageObjects.common.sleep(1000); - await (await PageObjects.settings.getCreateIndexPatternGoToStep2Button).click(); - await (await this.getCreateIndexPatternButton()).click(); - expect((await browser.getCurrentUrl()).match(/indexPatterns\/.+\?/)).equal(true); + await PageObjects.settings.createIndexPattern('test_data_stream', false); + + await es.transport.request({ + path: '/_data_stream/test_data_stream', + method: 'DELETE', + }); }); }); describe('index alias', () => { it('can be an index pattern', async () => { - await es.init(); await es.transport.request({ path: '/blogs/_doc', method: 'POST', - body: '{ "user" : "matt", "message" : 20 }', + body: { user: 'matt', message: 20 }, }); await es.transport.request({ path: '/_aliases', method: 'POST', - body: '{ "actions" : [{ "add" : { "index" : "blogs", "alias" : "alias1" } }]}', + body: { actions: [{ add: { index: 'blogs', alias: 'alias1' } }] }, }); - await PageObjects.settings.setIndexPatternField('alias1'); - await PageObjects.common.sleep(1000); - await (await PageObjects.settings.getCreateIndexPatternGoToStep2Button).click(); - await (await this.getCreateIndexPatternButton()).click(); - expect((await browser.getCurrentUrl()).match(/indexPatterns\/.+\?/)).equal(true); + await PageObjects.settings.createIndexPattern('alias1', false); }); }); }); From cb28e99e343cfb83f0e8006f9ec01c1c75af5120 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Sat, 4 Jul 2020 13:35:16 -0500 Subject: [PATCH 28/76] source instead of index --- .../create_index_pattern_wizard/components/header/header.tsx | 2 +- .../components/status_message/status_message.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx index 5c8da009c040a1..225697d7d2c127 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx @@ -85,7 +85,7 @@ export const Header = ({

multiple, single: filebeat-4-3-22, diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx index e444e12ce19c61..9b05927f2649f0 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx @@ -57,8 +57,8 @@ export const StatusMessage: React.FC = ({ {allIndicesLength} indices }} + defaultMessage="Your index pattern can match any of your {indicesCount} sources below." + values={{ indicesCount: allIndicesLength }} /> ); From 1a4db4b3581fb0f0c10d689fa0cfe723ad4496e6 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Sat, 4 Jul 2020 21:57:41 -0500 Subject: [PATCH 29/76] fix routing and state issues --- .../index_pattern_management/kibana.json | 2 +- .../create_index_pattern_wizard.test.tsx.snap | 224 ++++++++++-------- .../header/__snapshots__/header.test.tsx.snap | 18 +- .../status_message.test.tsx.snap | 7 +- .../create_index_pattern_wizard.test.tsx | 1 - .../create_index_pattern_wizard.tsx | 8 +- .../public/components/index.ts | 4 - .../empty_index_pattern_prompt.test.tsx.snap | 0 .../assets/index_pattern_illustration.js | 0 .../assets/index_pattern_illustration.scss | 0 .../empty_index_pattern_prompt.scss | 4 +- .../empty_index_pattern_prompt.test.tsx | 10 +- .../empty_index_pattern_prompt.tsx | 36 +-- .../empty_index_pattern_prompt/index.tsx | 5 +- .../__snapshots__/empty_state.test.tsx.snap | 15 +- .../empty_state/empty_state.scss | 4 +- .../empty_state/empty_state.test.tsx | 16 +- .../empty_state/empty_state.tsx | 19 +- .../empty_state/index.ts | 0 .../index_pattern_table.tsx | 35 +++ .../mount_management_section.tsx | 4 - 21 files changed, 226 insertions(+), 186 deletions(-) rename src/plugins/index_pattern_management/public/components/{ => index_pattern_table}/empty_index_pattern_prompt/__snapshots__/empty_index_pattern_prompt.test.tsx.snap (100%) rename src/plugins/index_pattern_management/public/components/{ => index_pattern_table}/empty_index_pattern_prompt/assets/index_pattern_illustration.js (100%) rename src/plugins/index_pattern_management/public/components/{ => index_pattern_table}/empty_index_pattern_prompt/assets/index_pattern_illustration.scss (100%) rename src/plugins/index_pattern_management/public/components/{ => index_pattern_table}/empty_index_pattern_prompt/empty_index_pattern_prompt.scss (92%) rename src/plugins/index_pattern_management/public/components/{ => index_pattern_table}/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx (85%) rename src/plugins/index_pattern_management/public/components/{ => index_pattern_table}/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx (77%) rename src/plugins/index_pattern_management/public/components/{ => index_pattern_table}/empty_index_pattern_prompt/index.tsx (87%) rename src/plugins/index_pattern_management/public/components/{create_index_pattern_wizard/components => index_pattern_table}/empty_state/__snapshots__/empty_state.test.tsx.snap (96%) rename src/plugins/index_pattern_management/public/components/{create_index_pattern_wizard/components => index_pattern_table}/empty_state/empty_state.scss (86%) rename src/plugins/index_pattern_management/public/components/{create_index_pattern_wizard/components => index_pattern_table}/empty_state/empty_state.test.tsx (79%) rename src/plugins/index_pattern_management/public/components/{create_index_pattern_wizard/components => index_pattern_table}/empty_state/empty_state.tsx (90%) rename src/plugins/index_pattern_management/public/components/{create_index_pattern_wizard/components => index_pattern_table}/empty_state/index.ts (100%) diff --git a/src/plugins/index_pattern_management/kibana.json b/src/plugins/index_pattern_management/kibana.json index 364edbb030dc99..88a2e7101cc314 100644 --- a/src/plugins/index_pattern_management/kibana.json +++ b/src/plugins/index_pattern_management/kibana.json @@ -3,5 +3,5 @@ "version": "kibana", "server": false, "ui": true, - "requiredPlugins": ["management", "data", "kibanaLegacy"] + "requiredPlugins": ["management", "data", "kibanaLegacy","home"] } diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.tsx.snap index f60f840d9f0c23..fd9d176b2bba76 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.tsx.snap @@ -154,109 +154,131 @@ exports[`CreateIndexPatternWizard renders index pattern step when there are indi exports[`CreateIndexPatternWizard renders the empty state when there are no indices 1`] = ` - +

+ indexPatternName="name" + isBeta={false} + isIncludingSystemIndices={false} + onChangeIncludingSystemIndices={[Function]} + prompt={null} + showSystemIndices={true} + /> + + +

- An index pattern can match a single index, for example, + An index pattern can match a single source, for example, multiple - indices, + data sources,

- An index pattern can match a single index, for example, + An index pattern can match a single source, for example, multiple - indices, + data sources,

- An index pattern can match a single index, for example, + An index pattern can match a single source, for example, multiple - indices, + data sources, - 2 - indices - , + "indicesCount": 2, } } /> diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.test.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.test.tsx index b14cd526d7e276..af5618424bbc08 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.test.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.test.tsx @@ -27,7 +27,6 @@ jest.mock('./components/step_index_pattern', () => ({ StepIndexPattern: 'StepInd 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/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx index f0a5fab4ef82f2..d55d90da484f92 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx @@ -33,7 +33,7 @@ import { StepIndexPattern } from './components/step_index_pattern'; import { StepTimeField } from './components/step_time_field'; import { Header } from './components/header'; import { LoadingState } from './components/loading_state'; -import { EmptyState } from './components/empty_state'; +// import { EmptyState } from './components/empty_state'; import { context as contextType } from '../../../../kibana_react/public'; import { getCreateBreadcrumbs } from '../breadcrumbs'; @@ -246,14 +246,15 @@ export class CreateIndexPatternWizard extends Component< isIncludingSystemIndices, step, indexPattern, - remoteClustersExist, - docLinks, + // remoteClustersExist, + // docLinks, } = this.state; if (isInitiallyLoadingIndices) { return ; } + /* const hasDataIndices = allIndices.some(({ name }: MatchedIndex) => !name.startsWith('.')); if (!hasDataIndices && !isIncludingSystemIndices && !remoteClustersExist) { return ( @@ -264,6 +265,7 @@ export class CreateIndexPatternWizard extends Component< /> ); } + */ const header = this.renderHeader(); diff --git a/src/plugins/index_pattern_management/public/components/index.ts b/src/plugins/index_pattern_management/public/components/index.ts index fede54dcfc5096..e0acb9d05bc848 100644 --- a/src/plugins/index_pattern_management/public/components/index.ts +++ b/src/plugins/index_pattern_management/public/components/index.ts @@ -25,7 +25,3 @@ export { CreateEditFieldContainer, } from './edit_index_pattern'; export { CreateIndexPatternWizardWithRouter } from './create_index_pattern_wizard'; -export { - EmptyIndexPatternPrompt, - EmptyIndexPatternPromptWithRouter, -} from './empty_index_pattern_prompt'; diff --git a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/__snapshots__/empty_index_pattern_prompt.test.tsx.snap b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/__snapshots__/empty_index_pattern_prompt.test.tsx.snap similarity index 100% rename from src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/__snapshots__/empty_index_pattern_prompt.test.tsx.snap rename to src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/__snapshots__/empty_index_pattern_prompt.test.tsx.snap diff --git a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/assets/index_pattern_illustration.js b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/assets/index_pattern_illustration.js similarity index 100% rename from src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/assets/index_pattern_illustration.js rename to src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/assets/index_pattern_illustration.js diff --git a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/assets/index_pattern_illustration.scss b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/assets/index_pattern_illustration.scss similarity index 100% rename from src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/assets/index_pattern_illustration.scss rename to src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/assets/index_pattern_illustration.scss diff --git a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.scss b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.scss similarity index 92% rename from src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.scss rename to src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.scss index f6db2fc89f353a..11ac55b098a57c 100644 --- a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.scss +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.scss @@ -1,5 +1,5 @@ -@import '../../variables'; -@import '../../templates'; +@import '../../../variables'; +@import '../../../templates'; .inpEmptyIndexPatternPrompt { // override EUI specificity diff --git a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx similarity index 85% rename from src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx rename to src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx index 41c561e2e972bf..fcd68c697a8281 100644 --- a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx @@ -21,18 +21,10 @@ import React from 'react'; import { EmptyIndexPatternPrompt } from '../empty_index_pattern_prompt'; import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; -const routeComponentPropsMock = { - history: { - push: jest.fn(), - } as any, - location: {} as any, - match: {} as any, -}; - describe('EmptyIndexPatternPrompt', () => { it.skip('should render normally', () => { const component = shallowWithI18nProvider( - + {} }]} /> ); expect(component).toMatchSnapshot(); diff --git a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx similarity index 77% rename from src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx rename to src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx index 6da80525732f12..4a2db96e699db0 100644 --- a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx @@ -18,42 +18,30 @@ */ import './empty_index_pattern_prompt.scss'; -import React, { useState, useEffect } from 'react'; +import React from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; -import { withRouter, RouteComponentProps } from 'react-router-dom'; import { EuiPageContent, EuiSpacer, EuiText, EuiFlexItem, EuiFlexGroup } from '@elastic/eui'; import { EuiDescriptionListTitle } from '@elastic/eui'; import { EuiDescriptionListDescription, EuiDescriptionList } from '@elastic/eui'; import { EuiLink } from '@elastic/eui'; -import { getListBreadcrumbs } from '../breadcrumbs'; -import { IndexPatternManagmentContext } from '../../types'; -import { useKibana } from '../../../../../plugins/kibana_react/public'; -import { IndexPatternCreationOption } from '../types'; -import { CreateButton } from '../create_button'; -// @ts-ignore +import { getListBreadcrumbs } from '../../breadcrumbs'; +import { IndexPatternManagmentContext } from '../../../types'; +import { useKibana } from '../../../../../../plugins/kibana_react/public'; +import { IndexPatternCreationOption } from '../../types'; +import { CreateButton } from '../../create_button'; +// @ts-expect-error import { Illustration } from './assets/index_pattern_illustration'; -interface Props extends RouteComponentProps { +interface Props { canSave: boolean; + creationOptions: IndexPatternCreationOption[]; } -export const EmptyIndexPatternPrompt = ({ canSave, history }: Props) => { - const { indexPatternManagementStart, setBreadcrumbs, docLinks } = useKibana< - IndexPatternManagmentContext - >().services; - const [creationOptions, setCreationOptions] = useState([]); +export const EmptyIndexPatternPrompt = ({ canSave, creationOptions }: Props) => { + const { setBreadcrumbs, docLinks } = useKibana().services; setBreadcrumbs(getListBreadcrumbs()); - useEffect(() => { - (async function () { - const options = await indexPatternManagementStart.creation.getIndexPatternCreationOptions( - history.push - ); - setCreationOptions(options); - })(); - }, [history.push, indexPatternManagementStart]); - return ( { ); }; - -export const EmptyIndexPatternPromptWithRouter = withRouter(EmptyIndexPatternPrompt); diff --git a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/index.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/index.tsx similarity index 87% rename from src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/index.tsx rename to src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/index.tsx index ddf1c83725ca01..239bb272b23abc 100644 --- a/src/plugins/index_pattern_management/public/components/empty_index_pattern_prompt/index.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/index.tsx @@ -17,7 +17,4 @@ * under the License. */ -export { - EmptyIndexPatternPrompt, - EmptyIndexPatternPromptWithRouter, -} from './empty_index_pattern_prompt'; +export { EmptyIndexPatternPrompt } from './empty_index_pattern_prompt'; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/__snapshots__/empty_state.test.tsx.snap b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap similarity index 96% rename from src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/__snapshots__/empty_state.test.tsx.snap rename to src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap index ed70b99a4b03b6..6f629c36834544 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/__snapshots__/empty_state.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap @@ -39,7 +39,6 @@ exports[`EmptyState should render normally 1`] = ` values={Object {}} /> } - href="/app/home#/tutorial_directory" icon={ } + onClick={[Function]} title={ } isDisabled={true} + onClick={[Function]} title={ } - href="/app/home#/tutorial_directory/sampleData" icon={ } + onClick={[Function]} title={

- Some indices may be hidden. Try to - + Some indices may be hidden. Try to + + create an index pattern - anyway. + + anyway.

diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.scss b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.scss similarity index 86% rename from src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.scss rename to src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.scss index 269d6ae99ff3b6..5b9eaa77a0088f 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.scss +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.scss @@ -1,5 +1,5 @@ -@import '../../../../variables'; -@import '../../../../templates'; +@import '../../../variables'; +@import '../../../templates'; .inpEmptyState { // override EUI specificity diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.test.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.test.tsx similarity index 79% rename from src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.test.tsx rename to src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.test.tsx index 292a8a8c8cbd9a..5d445fb7a0cba0 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.test.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.test.tsx @@ -24,14 +24,20 @@ import sinon from 'sinon'; // @ts-expect-error import { findTestSubject } from '@elastic/eui/lib/test'; import { mountWithIntl } from 'test_utils/enzyme_helpers'; -import { docLinksServiceMock } from '../../../../../../../core/public/mocks'; +import { docLinksServiceMock } from '../../../../../../core/public/mocks'; const docLinks = docLinksServiceMock.createStartContract(); +jest.mock('react-router-dom', () => ({ + useHistory: () => ({ + createHref: jest.fn(), + }), +})); + describe('EmptyState', () => { it('should render normally', () => { const component = shallow( - {}} prependBasePath={(x) => x} /> + {}} navigateToApp={async () => {}} /> ); expect(component).toMatchSnapshot(); @@ -43,7 +49,11 @@ describe('EmptyState', () => { const onRefreshHandler = sinon.stub(); const component = mountWithIntl( - x} /> + {}} + /> ); findTestSubject(component, 'refreshIndicesButton').simulate('click'); diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx similarity index 90% rename from src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.tsx rename to src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx index b7a05a4bc0d93f..0ba3591d29f4bf 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/empty_state.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx @@ -21,9 +21,7 @@ import './empty_state.scss'; import React from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -// import { getDocLink } from '../../../../../ legacy/ui/public/documentation_links'; -import { IBasePath, DocLinksStart } from 'kibana/public'; - +import { DocLinksStart, ApplicationStart } from 'kibana/public'; import { EuiPageContentHeader, EuiPageContentHeaderSection, @@ -39,14 +37,16 @@ import { EuiLink, EuiText, } from '@elastic/eui'; +import { useHistory } from 'react-router-dom'; +import { reactRouterNavigate } from '../../../../../../plugins/kibana_react/public'; export const EmptyState = ({ onRefresh, - prependBasePath, + navigateToApp, docLinks, }: { onRefresh: () => void; - prependBasePath: IBasePath['prepend']; + navigateToApp: ApplicationStart['navigateToApp']; docLinks: DocLinksStart; }) => ( <> @@ -69,7 +69,7 @@ export const EmptyState = ({ navigateToApp('home', { path: '#/tutorial_directory' })} icon={} title={ navigateToApp('ml', { path: '#/filedatavisualizer' })} className="inpEmptyState__card" betaBadgeLabel={i18n.translate( 'indexPatternManagement.createIndexPattern.emptyState.basicLicenseLabel', @@ -119,7 +120,7 @@ export const EmptyState = ({ navigateToApp('home', { path: '#/tutorial_directory/sampleData' })} icon={} title={ {/* TODO: Hook up link below */}

- Some indices may be hidden. Try to create an index pattern anyway. + Some indices may be hidden. Try to{' '} + create an index pattern{' '} + anyway.

diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/index.ts b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/index.ts similarity index 100% rename from src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/empty_state/index.ts rename to src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/index.ts diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx index 4be046448ba3b7..71eb1489d2e8b7 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx @@ -39,6 +39,9 @@ import { CreateButton } from '../create_button'; import { IndexPatternTableItem, IndexPatternCreationOption } from '../types'; import { getIndexPatterns } from '../utils'; import { getListBreadcrumbs } from '../breadcrumbs'; +import { EmptyState } from './empty_state'; +import { MatchedIndex } from '../create_index_pattern_wizard/types'; +import { EmptyIndexPatternPrompt } from './empty_index_pattern_prompt'; const pagination = { initialPageSize: 10, @@ -80,9 +83,13 @@ export const IndexPatternTable = ({ canSave, history }: Props) => { uiSettings, indexPatternManagementStart, chrome, + docLinks, + application, } = useKibana().services; const [indexPatterns, setIndexPatterns] = useState([]); const [creationOptions, setCreationOptions] = useState([]); + const [sources, setSources] = useState([]); + const [remoteClustersExist, setRemoteClustersExist] = useState(false); setBreadcrumbs(getListBreadcrumbs()); @@ -107,6 +114,16 @@ export const IndexPatternTable = ({ canSave, history }: Props) => { savedObjects.client, ]); + const loadSources = () => { + setSources([]); + setRemoteClustersExist(false); + }; + + useEffect(() => { + setSources([]); + setRemoteClustersExist(false); + }, []); + chrome.docTitle.change(title); const columns = [ @@ -152,6 +169,24 @@ export const IndexPatternTable = ({ canSave, history }: Props) => { <> ); + // this needs + // - a way to load indices + // - use getIndices + const hasDataIndices = sources.some(({ name }: MatchedIndex) => !name.startsWith('.')); + if (!indexPatterns.length && !hasDataIndices && !remoteClustersExist) { + if (!hasDataIndices && !remoteClustersExist) { + return ( + + ); + } else { + return ; + } + } + return ( diff --git a/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx b/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx index 6ae11a3bd15b57..bcabd55c879750 100644 --- a/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx +++ b/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx @@ -32,7 +32,6 @@ import { EditIndexPatternContainer, CreateEditFieldContainer, CreateIndexPatternWizardWithRouter, - EmptyIndexPatternPromptWithRouter, } from '../components'; import { IndexPatternManagementStartDependencies, IndexPatternManagementStart } from '../plugin'; import { IndexPatternManagmentContext } from '../types'; @@ -90,9 +89,6 @@ export async function mountManagementSection( - - - From 1ba8ea9c71ac03cc38028d474220aa636f22be12 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Sat, 4 Jul 2020 22:09:37 -0500 Subject: [PATCH 30/76] left over from merge --- .../components/step_index_pattern/components/header/header.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx index e4af89e4644e92..9a41806875195c 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx @@ -74,7 +74,6 @@ export const Header: React.FC = ({ defaultMessage="Index pattern name" /> } - fullWidth isInvalid={isInputInvalid} error={errors} helpText={ @@ -105,7 +104,6 @@ export const Header: React.FC = ({ isInvalid={isInputInvalid} onChange={onQueryChanged} data-test-subj="createIndexPatternNameInput" - fullWidth /> From 9f1b7bf6aaa0e48ad66ca5b0bdb7d99d5893f571 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Sat, 4 Jul 2020 23:55:13 -0500 Subject: [PATCH 31/76] load data sources --- .../step_index_pattern/step_index_pattern.tsx | 6 +-- .../step_time_field.test.tsx.snap | 7 --- .../step_time_field/step_time_field.tsx | 2 - .../create_index_pattern_wizard.tsx | 4 +- .../lib/get_indices.test.ts | 25 ++++------- .../lib/get_indices.ts | 8 ++-- .../index_pattern_table.tsx | 44 +++++++++++++------ 7 files changed, 49 insertions(+), 47 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx index 75d4c69389afda..42f8ea7d1951b5 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx @@ -155,7 +155,7 @@ export class StepIndexPattern extends Component indexPatternCreationType.getIndexTags(indexName), query, this.props.isIncludingSystemIndices ) @@ -171,13 +171,13 @@ export class StepIndexPattern extends Component indexPatternCreationType.getIndexTags(indexName), `${query}*`, this.props.isIncludingSystemIndices ), getIndices( this.context.services.http, - indexPatternCreationType, + (indexName: string) => indexPatternCreationType.getIndexTags(indexName), query, this.props.isIncludingSystemIndices ), diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/__snapshots__/step_time_field.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/__snapshots__/step_time_field.test.tsx.snap index 6cc92d20cfdcc1..a07c5dd4eece1f 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/__snapshots__/step_time_field.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/__snapshots__/step_time_field.test.tsx.snap @@ -32,7 +32,6 @@ exports[`StepTimeField should render "Custom index pattern ID already exists" wh onTimeFieldChanged={[Function]} timeFieldOptions={Array []} /> - - - - - - - - this.state.indexPatternCreationType.getIndexTags(indexName), `*`, this.state.isIncludingSystemIndices ), @@ -152,7 +152,7 @@ export class CreateIndexPatternWizard extends Component< // ['a'] is fallback value getIndices( this.context.services.http, - this.state.indexPatternCreationType, + (indexName: string) => this.state.indexPatternCreationType.getIndexTags(indexName), `*:*`, this.state.isIncludingSystemIndices ), diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.test.ts b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.test.ts index ab395c21ff84c1..fd23d59cbcb408 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.test.ts +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.test.ts @@ -18,7 +18,6 @@ */ import { getIndices, responseToItemArray } from './get_indices'; -import { IndexPatternCreationConfig } from '../../../../../index_pattern_management/public'; import { httpServiceMock } from '../../../../../../core/public/mocks'; export const successfulResponse = { @@ -43,33 +42,27 @@ export const successfulResponse = { ], }; -const mockIndexPatternCreationType = new IndexPatternCreationConfig({ - type: 'default', - name: 'name', - showSystemIndices: false, - httpClient: {}, - isBeta: false, -}); +const mockGetTags = () => []; const http = httpServiceMock.createStartContract(); http.get.mockResolvedValue(successfulResponse); describe('getIndices', () => { it('should work in a basic case', async () => { - const result = await getIndices(http, mockIndexPatternCreationType, 'kibana', false); + const result = await getIndices(http, mockGetTags, 'kibana', false); expect(result.length).toBe(3); expect(result[0].name).toBe('f-alias'); expect(result[1].name).toBe('foo'); }); it('should ignore ccs query-all', async () => { - expect((await getIndices(http, mockIndexPatternCreationType, '*:', false)).length).toBe(0); + expect((await getIndices(http, mockGetTags, '*:', false)).length).toBe(0); }); it('should ignore a single comma', async () => { - expect((await getIndices(http, mockIndexPatternCreationType, ',', false)).length).toBe(0); - expect((await getIndices(http, mockIndexPatternCreationType, ',*', false)).length).toBe(0); - expect((await getIndices(http, mockIndexPatternCreationType, ',foobar', false)).length).toBe(0); + expect((await getIndices(http, mockGetTags, ',', false)).length).toBe(0); + expect((await getIndices(http, mockGetTags, ',*', false)).length).toBe(0); + expect((await getIndices(http, mockGetTags, ',foobar', false)).length).toBe(0); }); it('response object to item array', () => { @@ -93,8 +86,8 @@ describe('getIndices', () => { }, ], }; - expect(responseToItemArray(result, mockIndexPatternCreationType)).toMatchSnapshot(); - expect(responseToItemArray({}, mockIndexPatternCreationType)).toEqual([]); + expect(responseToItemArray(result, mockGetTags)).toMatchSnapshot(); + expect(responseToItemArray({}, mockGetTags)).toEqual([]); }); describe('errors', () => { @@ -102,7 +95,7 @@ describe('getIndices', () => { http.get.mockImplementationOnce(() => { throw new Error('Test error'); }); - const result = await getIndices(http, mockIndexPatternCreationType, 'kibana', false); + const result = await getIndices(http, mockGetTags, 'kibana', false); expect(result.length).toBe(0); }); }); diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.ts b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.ts index 2f33cbbbc2f6a7..3c2f90bad31da7 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.ts +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.ts @@ -30,7 +30,7 @@ const dataStreamLabel = i18n.translate('indexPatternManagement.dataStreamLabel', export async function getIndices( http: HttpStart, - indexPatternCreationType: IndexPatternCreationConfig, + getIndexTags: IndexPatternCreationConfig['getIndexTags'], rawPattern: string, showAllIndices: boolean ): Promise { @@ -65,7 +65,7 @@ export async function getIndices( return []; } - return responseToItemArray(response, indexPatternCreationType); + return responseToItemArray(response, getIndexTags); } catch { return []; } @@ -73,14 +73,14 @@ export async function getIndices( export const responseToItemArray = ( response: ResolveIndexResponse, - indexPatternCreationType: IndexPatternCreationConfig + getIndexTags: IndexPatternCreationConfig['getIndexTags'] ): MatchedItem[] => { const source: MatchedItem[] = []; (response.indices || []).forEach((index) => { source.push({ name: index.name, - tags: indexPatternCreationType.getIndexTags(index.name), + tags: getIndexTags(index.name), item: index, }); }); diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx index 71eb1489d2e8b7..ae9b096cbcbb7d 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx @@ -40,8 +40,9 @@ import { IndexPatternTableItem, IndexPatternCreationOption } from '../types'; import { getIndexPatterns } from '../utils'; import { getListBreadcrumbs } from '../breadcrumbs'; import { EmptyState } from './empty_state'; -import { MatchedIndex } from '../create_index_pattern_wizard/types'; +import { MatchedItem, ResolveIndexResponseItemAlias } from '../create_index_pattern_wizard/types'; import { EmptyIndexPatternPrompt } from './empty_index_pattern_prompt'; +import { getIndices } from '../create_index_pattern_wizard/lib'; const pagination = { initialPageSize: 10, @@ -85,14 +86,16 @@ export const IndexPatternTable = ({ canSave, history }: Props) => { chrome, docLinks, application, + http, } = useKibana().services; const [indexPatterns, setIndexPatterns] = useState([]); const [creationOptions, setCreationOptions] = useState([]); - const [sources, setSources] = useState([]); + const [sources, setSources] = useState([]); const [remoteClustersExist, setRemoteClustersExist] = useState(false); + const [isLoadingSources, setIsLoadingSources] = useState(true); + const [isLoadingIndexPatterns, setIsLoadingIndexPatterns] = useState(true); setBreadcrumbs(getListBreadcrumbs()); - useEffect(() => { (async function () { const options = await indexPatternManagementStart.creation.getIndexPatternCreationOptions( @@ -103,6 +106,7 @@ export const IndexPatternTable = ({ canSave, history }: Props) => { uiSettings.get('defaultIndex'), indexPatternManagementStart ); + setIsLoadingIndexPatterns(false); setCreationOptions(options); setIndexPatterns(gettedIndexPatterns); })(); @@ -114,15 +118,27 @@ export const IndexPatternTable = ({ canSave, history }: Props) => { savedObjects.client, ]); + const removeAliases = (item: MatchedItem) => + !((item as unknown) as ResolveIndexResponseItemAlias).indices; + const loadSources = () => { - setSources([]); - setRemoteClustersExist(false); + getIndices(http, () => [], '*', false).then((dataSources) => + setSources(dataSources.filter(removeAliases)) + ); + getIndices(http, () => [], '*:*', false).then((dataSources) => + setRemoteClustersExist(!!dataSources.filter(removeAliases).length) + ); }; useEffect(() => { - setSources([]); - setRemoteClustersExist(false); - }, []); + getIndices(http, () => [], '*', false).then((dataSources) => { + setSources(dataSources.filter(removeAliases)); + setIsLoadingSources(false); + }); + getIndices(http, () => [], '*:*', false).then((dataSources) => + setRemoteClustersExist(!!dataSources.filter(removeAliases).length) + ); + }, [http, creationOptions]); chrome.docTitle.change(title); @@ -169,11 +185,13 @@ export const IndexPatternTable = ({ canSave, history }: Props) => { <> ); - // this needs - // - a way to load indices - // - use getIndices - const hasDataIndices = sources.some(({ name }: MatchedIndex) => !name.startsWith('.')); - if (!indexPatterns.length && !hasDataIndices && !remoteClustersExist) { + if (isLoadingSources || isLoadingIndexPatterns) { + return <>; + } + + const hasDataIndices = sources.some(({ name }: MatchedItem) => !name.startsWith('.')); + + if (!indexPatterns.length) { if (!hasDataIndices && !remoteClustersExist) { return ( Date: Sun, 5 Jul 2020 21:23:43 -0500 Subject: [PATCH 32/76] fix functional test --- .../index_pattern_table/empty_state/empty_state.tsx | 7 ++++++- .../feature_controls/index_patterns_security.ts | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx index 0ba3591d29f4bf..423733a4d13a43 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx @@ -50,7 +50,12 @@ export const EmptyState = ({ docLinks: DocLinksStart; }) => ( <> - + diff --git a/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts b/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts index fd8a46d2996898..e9b45f7b629d55 100644 --- a/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts +++ b/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts @@ -76,7 +76,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { it(`index pattern listing shows create button`, async () => { await PageObjects.settings.clickKibanaIndexPatterns(); - await testSubjects.existOrFail('createIndexPatternButton'); + await testSubjects.existOrFail('emptyState'); }); it(`doesn't show read-only badge`, async () => { From 8d503c74bfae331a5cd0dfbeef4f6873989d6faf Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Sun, 5 Jul 2020 22:38:49 -0500 Subject: [PATCH 33/76] update snapshot --- .../empty_state/__snapshots__/empty_state.test.tsx.snap | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap index 6f629c36834544..ab36054d0462cc 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap @@ -4,6 +4,7 @@ exports[`EmptyState should render normally 1`] = ` From c7c74c570085f497cad064ee3ff32fa17bec795d Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Wed, 8 Jul 2020 22:53:47 -0500 Subject: [PATCH 34/76] from merge --- .../components/step_index_pattern/components/header/header.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx index 40445a46853071..92b4bf595bddd7 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx @@ -112,7 +112,6 @@ export const Header: React.FC = ({ isInvalid={isInputInvalid} onChange={onQueryChanged} data-test-subj="createIndexPatternNameInput" - fullWidth /> From 20b9685f1c4f3fa90fd00c8f8b11a3a311bd4c4e Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Tue, 14 Jul 2020 17:18:01 -0500 Subject: [PATCH 35/76] add comment to kibana.json --- src/plugins/index_pattern_management/kibana.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/index_pattern_management/kibana.json b/src/plugins/index_pattern_management/kibana.json index cf9212778615d5..50a59ccac704ad 100644 --- a/src/plugins/index_pattern_management/kibana.json +++ b/src/plugins/index_pattern_management/kibana.json @@ -3,6 +3,6 @@ "version": "kibana", "server": true, "ui": true, - "requiredPlugins": ["management", "data", "kibanaLegacy","home"] + "requiredPlugins": ["management", "data", "kibanaLegacy","home"], "requiredBundles": ["kibanaReact", "kibanaUtils"] } From e37572c125e7c91c62b32d51cf4f37ee22e19cfa Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Thu, 16 Jul 2020 19:59:31 -0500 Subject: [PATCH 36/76] fix security functional test --- .../components/advanced_options/advanced_options.tsx | 1 - .../index_pattern_table/empty_state/empty_state.tsx | 5 +++-- .../feature_controls/index_patterns_security.ts | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.tsx index ea1fd4cce5fc71..0b1ed14eda3da6 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.tsx @@ -45,7 +45,6 @@ export const AdvancedOptions: React.FC = ({ onChangeIndexPatternId, }) => (
- - {/* TODO: Hook up link below */}

Some indices may be hidden. Try to{' '} - create an index pattern{' '} + + create an index pattern + {' '} anyway.

diff --git a/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts b/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts index e05c88087705a9..9788c4c5243ff5 100644 --- a/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts +++ b/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts @@ -76,7 +76,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { it(`index pattern listing shows create button`, async () => { await PageObjects.settings.clickKibanaIndexPatterns(); - await testSubjects.existOrFail('emptyState'); + await testSubjects.click('createAnyway'); + await testSubjects.existOrFail('createIndexPatternButton'); }); it(`doesn't show read-only badge`, async () => { @@ -130,6 +131,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { it(`index pattern listing doesn't show create button`, async () => { await PageObjects.settings.clickKibanaIndexPatterns(); + await testSubjects.click('createAnyway'); await testSubjects.existOrFail('indexPatternTable'); await testSubjects.missingOrFail('createIndexPatternButton'); }); From 9e40caf209e12d23ebf7dc133dbc9ca2ada1fda6 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Thu, 16 Jul 2020 20:45:55 -0500 Subject: [PATCH 37/76] remove unneeded comments, i18n text content --- .../components/header/header.tsx | 21 --------- .../components/header/header.tsx | 2 +- .../status_message/status_message.tsx | 2 +- .../advanced_options/advanced_options.tsx | 9 +--- .../create_index_pattern_wizard.tsx | 47 ++----------------- .../empty_state/empty_state.tsx | 26 ++++++---- 6 files changed, 26 insertions(+), 81 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx index 30494bea9f3e3d..cb4186e639de2f 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.tsx @@ -96,24 +96,3 @@ export const Header = ({
); }; - -/* - -{showSystemIndices ? ( - <> - - - } - id="checkboxShowSystemIndices" - checked={isIncludingSystemIndices} - onChange={onChangeIncludingSystemIndices} - /> - - ) : null} - - */ diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx index 92b4bf595bddd7..1061ad0bf9226a 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx @@ -107,11 +107,11 @@ export const Header: React.FC = ({ defaultMessage: 'index-name-*', } )} - fullWidth value={query} isInvalid={isInputInvalid} onChange={onQueryChanged} data-test-subj="createIndexPatternNameInput" + fullWidth /> diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx index 22b75071b93bb9..c2c4c84b516836 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.tsx @@ -132,7 +132,7 @@ export const StatusMessage: React.FC = ({ /> ); - } else if (allIndicesLength) { + } else { statusIcon = undefined; statusColor = 'warning'; statusMessage = ( diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.tsx index 0b1ed14eda3da6..752fcbcd42b5c4 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.tsx @@ -19,14 +19,7 @@ import React from 'react'; -import { - EuiForm, - EuiFormRow, - EuiFieldText, - EuiButtonEmpty, - EuiSpacer, - EuiHorizontalRule, -} from '@elastic/eui'; +import { EuiForm, EuiFormRow, EuiFieldText, EuiButtonEmpty, EuiSpacer } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx index 48badf31b67fff..a789ebbfadbcee 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/create_index_pattern_wizard.tsx @@ -33,7 +33,6 @@ import { StepIndexPattern } from './components/step_index_pattern'; import { StepTimeField } from './components/step_time_field'; import { Header } from './components/header'; import { LoadingState } from './components/loading_state'; -// import { EmptyState } from './components/empty_state'; import { context as contextType } from '../../../../kibana_react/public'; import { getCreateBreadcrumbs } from '../breadcrumbs'; @@ -211,56 +210,20 @@ export class CreateIndexPatternWizard extends Component< this.setState({ step: 1 }); }; - /* - onChangeIncludingSystemIndices = (event: EuiSwitchEvent) => { - this.setState({ isIncludingSystemIndices: event.target.checked }, () => this.fetchData()); - }; - */ - renderHeader() { - const { docLinks } = this.state; - // const { isIncludingSystemIndices, docLinks } = this.state; - + const { docLinks, indexPatternCreationType } = this.state; return (
); } - /* - ======= - renderHeader() { - return ( -
>>>>>> master -*/ - renderContent() { - const { - allIndices, - isInitiallyLoadingIndices, - step, - indexPattern, - // remoteClustersExist, - // docLinks, - } = this.state; + const { allIndices, isInitiallyLoadingIndices, step, indexPattern } = this.state; if (isInitiallyLoadingIndices) { return ; diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx index e7d9c15bc76dd7..de5171f90bcfd1 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx @@ -157,7 +157,10 @@ export const EmptyState = ({ ), description: ( - Read documentation + ), }, @@ -193,13 +196,20 @@ export const EmptyState = ({ -

- Some indices may be hidden. Try to{' '} - - create an index pattern - {' '} - anyway. -

+ + + + ), + }} + />
); From 6332e413447d13165b1392c0d9a6a9e25272f143 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Fri, 17 Jul 2020 16:38:11 -0500 Subject: [PATCH 38/76] add api to know if ml is available --- .../advanced_options.test.tsx.snap | 2 - .../__snapshots__/empty_state.test.tsx.snap | 37 ++++++++----- .../empty_state/empty_state.test.tsx | 8 ++- .../empty_state/empty_state.tsx | 4 +- .../index_pattern_table.tsx | 2 + .../mount_management_section.tsx | 4 +- .../index_pattern_management/public/mocks.ts | 3 ++ .../index_pattern_management/public/plugin.ts | 6 ++- .../service/environment/environment.mock.ts | 45 ++++++++++++++++ .../service/environment/environment.test.ts | 46 ++++++++++++++++ .../public/service/environment/environment.ts | 53 +++++++++++++++++++ .../public/service/environment/index.ts | 20 +++++++ .../index_pattern_management_service.ts | 4 ++ .../index_pattern_management/public/types.ts | 1 + .../apps/management/_index_pattern_empty.js | 23 ++++++++ test/functional/apps/management/index.js | 1 + x-pack/plugins/ml/kibana.json | 3 +- x-pack/plugins/ml/public/application/app.tsx | 3 +- x-pack/plugins/ml/public/plugin.ts | 5 ++ 19 files changed, 249 insertions(+), 21 deletions(-) create mode 100644 src/plugins/index_pattern_management/public/service/environment/environment.mock.ts create mode 100644 src/plugins/index_pattern_management/public/service/environment/environment.test.ts create mode 100644 src/plugins/index_pattern_management/public/service/environment/environment.ts create mode 100644 src/plugins/index_pattern_management/public/service/environment/index.ts create mode 100644 test/functional/apps/management/_index_pattern_empty.js diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/advanced_options/__snapshots__/advanced_options.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/advanced_options/__snapshots__/advanced_options.test.tsx.snap index a844d95d85a230..a2d2023ea06016 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/advanced_options/__snapshots__/advanced_options.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/advanced_options/__snapshots__/advanced_options.test.tsx.snap @@ -2,7 +2,6 @@ exports[`AdvancedOptions should hide if not showing 1`] = `
- - } - isDisabled={true} + isDisabled={false} onClick={[Function]} title={ - Read documentation + , "title": -

- Some indices may be hidden. Try to - - - create an index pattern - - - anyway. -

+ + + , + } + } + /> `; diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.test.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.test.tsx index 5d445fb7a0cba0..f5efd8e75b781e 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.test.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.test.tsx @@ -37,7 +37,12 @@ jest.mock('react-router-dom', () => ({ describe('EmptyState', () => { it('should render normally', () => { const component = shallow( - {}} navigateToApp={async () => {}} /> + {}} + navigateToApp={async () => {}} + isMlAvailable={() => true} + /> ); expect(component).toMatchSnapshot(); @@ -53,6 +58,7 @@ describe('EmptyState', () => { docLinks={docLinks} onRefresh={onRefreshHandler} navigateToApp={async () => {}} + isMlAvailable={() => true} /> ); diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx index de5171f90bcfd1..525c6d677ce5bc 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx @@ -44,10 +44,12 @@ export const EmptyState = ({ onRefresh, navigateToApp, docLinks, + isMlAvailable, }: { onRefresh: () => void; navigateToApp: ApplicationStart['navigateToApp']; docLinks: DocLinksStart; + isMlAvailable: () => boolean; }) => ( <> } title={ { docLinks, application, http, + isMlAvailable, } = useKibana().services; const [indexPatterns, setIndexPatterns] = useState([]); const [creationOptions, setCreationOptions] = useState([]); @@ -198,6 +199,7 @@ export const IndexPatternTable = ({ canSave, history }: Props) => { onRefresh={loadSources} docLinks={docLinks} navigateToApp={application.navigateToApp} + isMlAvailable={isMlAvailable} /> ); } else { diff --git a/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx b/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx index bcabd55c879750..2d8abeccb70fcb 100644 --- a/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx +++ b/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx @@ -48,7 +48,8 @@ const readOnlyBadge = { export async function mountManagementSection( getStartServices: StartServicesAccessor, - params: ManagementAppMountParams + params: ManagementAppMountParams, + isMlAvailable: () => boolean ) { const [ { chrome, application, savedObjects, uiSettings, notifications, overlays, http, docLinks }, @@ -73,6 +74,7 @@ export async function mountManagementSection( data, indexPatternManagementStart: indexPatternManagementStart as IndexPatternManagementStart, setBreadcrumbs: params.setBreadcrumbs, + isMlAvailable, }; ReactDOM.render( diff --git a/src/plugins/index_pattern_management/public/mocks.ts b/src/plugins/index_pattern_management/public/mocks.ts index ec8100db420851..6a9ef23e3732e6 100644 --- a/src/plugins/index_pattern_management/public/mocks.ts +++ b/src/plugins/index_pattern_management/public/mocks.ts @@ -39,6 +39,9 @@ const createSetupContract = (): IndexPatternManagementSetup => ({ getAll: jest.fn(), getById: jest.fn(), } as any, + environment: { + update: jest.fn(), + }, }); const createStartContract = (): IndexPatternManagementStart => ({ diff --git a/src/plugins/index_pattern_management/public/plugin.ts b/src/plugins/index_pattern_management/public/plugin.ts index fe680eff8657e2..2a7f761ef31b95 100644 --- a/src/plugins/index_pattern_management/public/plugin.ts +++ b/src/plugins/index_pattern_management/public/plugin.ts @@ -86,7 +86,11 @@ export class IndexPatternManagementPlugin mount: async (params) => { const { mountManagementSection } = await import('./management_app'); - return mountManagementSection(core.getStartServices, params); + return mountManagementSection( + core.getStartServices, + params, + () => this.indexPatternManagementService.environmentService.getEnvironment().ml + ); }, }); diff --git a/src/plugins/index_pattern_management/public/service/environment/environment.mock.ts b/src/plugins/index_pattern_management/public/service/environment/environment.mock.ts new file mode 100644 index 00000000000000..d8be02bf6552cb --- /dev/null +++ b/src/plugins/index_pattern_management/public/service/environment/environment.mock.ts @@ -0,0 +1,45 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { EnvironmentService, EnvironmentServiceSetup } from './environment'; + +const createSetupMock = (): jest.Mocked => { + const setup = { + update: jest.fn(), + }; + return setup; +}; + +const createMock = (): jest.Mocked> => { + const service = { + setup: jest.fn(), + getEnvironment: jest.fn(() => ({ + cloud: false, + apmUi: false, + ml: false, + })), + }; + service.setup.mockImplementation(createSetupMock); + return service; +}; + +export const environmentServiceMock = { + createSetup: createSetupMock, + create: createMock, +}; diff --git a/src/plugins/index_pattern_management/public/service/environment/environment.test.ts b/src/plugins/index_pattern_management/public/service/environment/environment.test.ts new file mode 100644 index 00000000000000..f416afad33c074 --- /dev/null +++ b/src/plugins/index_pattern_management/public/service/environment/environment.test.ts @@ -0,0 +1,46 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { EnvironmentService } from './environment'; + +describe('EnvironmentService', () => { + describe('setup', () => { + test('allows multiple update calls', () => { + const setup = new EnvironmentService().setup(); + expect(() => { + setup.update({ ml: true }); + }).not.toThrow(); + }); + }); + + describe('getEnvironment', () => { + test('returns default values', () => { + const service = new EnvironmentService(); + expect(service.getEnvironment()).toEqual({ ml: false }); + }); + + test('returns last state of update calls', () => { + const service = new EnvironmentService(); + const setup = service.setup(); + setup.update({ ml: true }); + setup.update({ ml: false }); + expect(service.getEnvironment()).toEqual({ ml: false }); + }); + }); +}); diff --git a/src/plugins/index_pattern_management/public/service/environment/environment.ts b/src/plugins/index_pattern_management/public/service/environment/environment.ts new file mode 100644 index 00000000000000..af8af630299d70 --- /dev/null +++ b/src/plugins/index_pattern_management/public/service/environment/environment.ts @@ -0,0 +1,53 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** @public */ +export interface Environment { + /** + * Flag whether the home app should advertise ml features + */ + readonly ml: boolean; +} + +export class EnvironmentService { + private environment = { + ml: false, + }; + + public setup() { + return { + /** + * Update the environment to influence how the home app is presenting available features. + * This API should not be extended for new features and will be removed in future versions + * in favor of display specific extension apis. + * @deprecated + * @param update + */ + update: (update: Partial) => { + this.environment = Object.assign({}, this.environment, update); + }, + }; + } + + public getEnvironment() { + return this.environment; + } +} + +export type EnvironmentServiceSetup = ReturnType; diff --git a/src/plugins/index_pattern_management/public/service/environment/index.ts b/src/plugins/index_pattern_management/public/service/environment/index.ts new file mode 100644 index 00000000000000..91d14c358e7db8 --- /dev/null +++ b/src/plugins/index_pattern_management/public/service/environment/index.ts @@ -0,0 +1,20 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { EnvironmentService, Environment, EnvironmentServiceSetup } from './environment'; diff --git a/src/plugins/index_pattern_management/public/service/index_pattern_management_service.ts b/src/plugins/index_pattern_management/public/service/index_pattern_management_service.ts index d4cc9c95e76a7e..06b9b83b1b6016 100644 --- a/src/plugins/index_pattern_management/public/service/index_pattern_management_service.ts +++ b/src/plugins/index_pattern_management/public/service/index_pattern_management_service.ts @@ -21,6 +21,7 @@ import { HttpSetup } from '../../../../core/public'; import { IndexPatternCreationManager, IndexPatternCreationConfig } from './creation'; import { IndexPatternListManager, IndexPatternListConfig } from './list'; import { FieldFormatEditors } from './field_format_editors'; +import { EnvironmentService } from './environment'; import { BytesFormatEditor, @@ -49,11 +50,13 @@ export class IndexPatternManagementService { indexPatternCreationManager: IndexPatternCreationManager; indexPatternListConfig: IndexPatternListManager; fieldFormatEditors: FieldFormatEditors; + environmentService: EnvironmentService; constructor() { this.indexPatternCreationManager = new IndexPatternCreationManager(); this.indexPatternListConfig = new IndexPatternListManager(); this.fieldFormatEditors = new FieldFormatEditors(); + this.environmentService = new EnvironmentService(); } public setup({ httpClient }: SetupDependencies) { @@ -83,6 +86,7 @@ export class IndexPatternManagementService { creation: creationManagerSetup, list: indexPatternListConfigSetup, fieldFormatEditors: fieldFormatEditorsSetup, + environment: this.environmentService.setup(), }; } diff --git a/src/plugins/index_pattern_management/public/types.ts b/src/plugins/index_pattern_management/public/types.ts index 97941687e652de..b7aa4262452ab2 100644 --- a/src/plugins/index_pattern_management/public/types.ts +++ b/src/plugins/index_pattern_management/public/types.ts @@ -44,6 +44,7 @@ export interface IndexPatternManagmentContext { data: DataPublicPluginStart; indexPatternManagementStart: IndexPatternManagementStart; setBreadcrumbs: ManagementAppMountParams['setBreadcrumbs']; + isMlAvailable: () => boolean; } export type IndexPatternManagmentContextValue = KibanaReactContextValue< diff --git a/test/functional/apps/management/_index_pattern_empty.js b/test/functional/apps/management/_index_pattern_empty.js new file mode 100644 index 00000000000000..2dc81ed1df4264 --- /dev/null +++ b/test/functional/apps/management/_index_pattern_empty.js @@ -0,0 +1,23 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +// test empty page +// test empty page links +// test empty page refresh +// test first index pattern diff --git a/test/functional/apps/management/index.js b/test/functional/apps/management/index.js index 97e7314f9678e7..2e823db489fe66 100644 --- a/test/functional/apps/management/index.js +++ b/test/functional/apps/management/index.js @@ -43,6 +43,7 @@ export default function ({ getService, loadTestFile }) { loadTestFile(require.resolve('./_scripted_fields')); loadTestFile(require.resolve('./_scripted_fields_preview')); loadTestFile(require.resolve('./_mgmt_import_saved_objects')); + loadTestFile(require.resolve('./_index_pattern_empty')); }); describe('', function () { diff --git a/x-pack/plugins/ml/kibana.json b/x-pack/plugins/ml/kibana.json index c61db9fb1ad8da..7b4ea5458f4a61 100644 --- a/x-pack/plugins/ml/kibana.json +++ b/x-pack/plugins/ml/kibana.json @@ -16,7 +16,8 @@ "share", "embeddable", "uiActions", - "kibanaLegacy" + "kibanaLegacy", + "indexPatternManagement" ], "optionalPlugins": [ "security", diff --git a/x-pack/plugins/ml/public/application/app.tsx b/x-pack/plugins/ml/public/application/app.tsx index cf645404860f5a..1ad82a10151702 100644 --- a/x-pack/plugins/ml/public/application/app.tsx +++ b/x-pack/plugins/ml/public/application/app.tsx @@ -20,7 +20,8 @@ import { MlRouter } from './routing'; import { mlApiServicesProvider } from './services/ml_api_service'; import { HttpService } from './services/http_service'; -export type MlDependencies = Omit & MlStartDependencies; +export type MlDependencies = Omit & + MlStartDependencies; interface AppProps { coreStart: CoreStart; diff --git a/x-pack/plugins/ml/public/plugin.ts b/x-pack/plugins/ml/public/plugin.ts index 449d8baa2a1847..0d9b1c79686393 100644 --- a/x-pack/plugins/ml/public/plugin.ts +++ b/x-pack/plugins/ml/public/plugin.ts @@ -18,6 +18,7 @@ import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; import { DataPublicPluginStart } from 'src/plugins/data/public'; import { HomePublicPluginSetup } from 'src/plugins/home/public'; +import { IndexPatternManagementSetup } from 'src/plugins/index_pattern_management/public'; import { EmbeddableSetup } from 'src/plugins/embeddable/public'; import { SecurityPluginSetup } from '../../security/public'; import { LicensingPluginSetup } from '../../licensing/public'; @@ -50,6 +51,7 @@ export interface MlSetupDependencies { uiActions: UiActionsSetup; kibanaVersion: string; share: SharePluginSetup; + indexPatternManagement: IndexPatternManagementSetup; } declare module '../../../../src/plugins/share/public' { @@ -113,6 +115,9 @@ export class MlPlugin implements Plugin { }); registerFeature(pluginsSetup.home); + // register ML for the index pattern management no data screen. + // so the file data visualizer appears to allow people to import data + pluginsSetup.indexPatternManagement.environment.update({ ml: true }); initManagementSection(pluginsSetup, core); registerEmbeddables(pluginsSetup.embeddable, core); From 9ce05409aa9a0e0c38f7fe6eab8016665d3e7c6c Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Fri, 17 Jul 2020 23:36:03 -0500 Subject: [PATCH 39/76] fix security tests --- .../components/header/header.tsx | 1 + .../empty_state/empty_state.tsx | 306 +++++++++--------- .../index_pattern_table.tsx | 1 + .../apps/management/_index_pattern_empty.js | 23 -- test/functional/apps/management/index.js | 1 - .../index_patterns_security.ts | 24 +- 6 files changed, 178 insertions(+), 178 deletions(-) delete mode 100644 test/functional/apps/management/_index_pattern_empty.js diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx index 1061ad0bf9226a..8efa44decf3c60 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.tsx @@ -127,6 +127,7 @@ export const Header: React.FC = ({ id="checkboxShowSystemIndices" checked={isIncludingSystemIndices} onChange={onChangeIncludingSystemIndices} + data-test-subj="showSystemAndHiddenIndices" /> ) : null} diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx index 525c6d677ce5bc..4eaff63cb4b6b4 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx @@ -45,158 +45,15 @@ export const EmptyState = ({ navigateToApp, docLinks, isMlAvailable, + canSave, }: { onRefresh: () => void; navigateToApp: ApplicationStart['navigateToApp']; docLinks: DocLinksStart; isMlAvailable: () => boolean; -}) => ( - <> - - - - -

- -

-
-
-
- - - - - navigateToApp('home', { path: '#/tutorial_directory' })} - icon={} - title={ - - } - description={ - - } - /> - - - navigateToApp('ml', { path: '#/filedatavisualizer' })} - className="inpEmptyState__card" - betaBadgeLabel={i18n.translate( - 'indexPatternManagement.createIndexPattern.emptyState.basicLicenseLabel', - { - defaultMessage: 'Basic', - } - )} - betaBadgeTooltipContent={i18n.translate( - 'indexPatternManagement.createIndexPattern.emptyState.basicLicenseDescription', - { - defaultMessage: 'This feature requires a Basic license.', - } - )} - isDisabled={!isMlAvailable()} - icon={} - title={ - - } - description={ - - } - /> - - - navigateToApp('home', { path: '#/tutorial_directory/sampleData' })} - icon={} - title={ - - } - description={ - - } - /> - - - -
- - - - ), - description: ( - - - - ), - }, - ]} - /> - - - - ), - description: ( - - {' '} - - - ), - }, - ]} - /> - - -
-
-
- + canSave: boolean; +}) => { + const createAnyway = ( - -); + ); + + return ( + <> + + + + +

+ +

+
+
+
+ + + + + navigateToApp('home', { path: '#/tutorial_directory' })} + icon={} + title={ + + } + description={ + + } + /> + + + navigateToApp('ml', { path: '#/filedatavisualizer' })} + className="inpEmptyState__card" + betaBadgeLabel={i18n.translate( + 'indexPatternManagement.createIndexPattern.emptyState.basicLicenseLabel', + { + defaultMessage: 'Basic', + } + )} + betaBadgeTooltipContent={i18n.translate( + 'indexPatternManagement.createIndexPattern.emptyState.basicLicenseDescription', + { + defaultMessage: 'This feature requires a Basic license.', + } + )} + isDisabled={!isMlAvailable()} + icon={} + title={ + + } + description={ + + } + /> + + + navigateToApp('home', { path: '#/tutorial_directory/sampleData' })} + icon={} + title={ + + } + description={ + + } + /> + + + +
+ + + + ), + description: ( + + + + ), + }, + ]} + /> + + + + ), + description: ( + + {' '} + + + ), + }, + ]} + /> + + +
+
+
+ + {canSave && createAnyway} + + ); +}; diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx index 062b0335c68e8d..bf7dde8a686e80 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx @@ -200,6 +200,7 @@ export const IndexPatternTable = ({ canSave, history }: Props) => { docLinks={docLinks} navigateToApp={application.navigateToApp} isMlAvailable={isMlAvailable} + canSave={canSave} /> ); } else { diff --git a/test/functional/apps/management/_index_pattern_empty.js b/test/functional/apps/management/_index_pattern_empty.js deleted file mode 100644 index 2dc81ed1df4264..00000000000000 --- a/test/functional/apps/management/_index_pattern_empty.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -// test empty page -// test empty page links -// test empty page refresh -// test first index pattern diff --git a/test/functional/apps/management/index.js b/test/functional/apps/management/index.js index 2e823db489fe66..97e7314f9678e7 100644 --- a/test/functional/apps/management/index.js +++ b/test/functional/apps/management/index.js @@ -43,7 +43,6 @@ export default function ({ getService, loadTestFile }) { loadTestFile(require.resolve('./_scripted_fields')); loadTestFile(require.resolve('./_scripted_fields_preview')); loadTestFile(require.resolve('./_mgmt_import_saved_objects')); - loadTestFile(require.resolve('./_index_pattern_empty')); }); describe('', function () { diff --git a/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts b/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts index 9788c4c5243ff5..958f0704a3c837 100644 --- a/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts +++ b/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts @@ -15,6 +15,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const appsMenu = getService('appsMenu'); const testSubjects = getService('testSubjects'); const globalNav = getService('globalNav'); + const es = getService('legacyEs'); describe('security', () => { before(async () => { @@ -74,10 +75,17 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { expect(navLinks).to.eql(['Stack Management']); }); - it(`index pattern listing shows create button`, async () => { + it(`index pattern empty shows create anyway link`, async () => { await PageObjects.settings.clickKibanaIndexPatterns(); - await testSubjects.click('createAnyway'); + await testSubjects.existOrFail('createAnyway'); + await es.transport.request({ + path: '/blogs/_doc', + method: 'POST', + body: { user: 'matt', message: 20 }, + }); + await testSubjects.click('refreshIndicesButton'); await testSubjects.existOrFail('createIndexPatternButton'); + // test when there's an existing pattern }); it(`doesn't show read-only badge`, async () => { @@ -129,11 +137,17 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { expect(navLinks).to.eql(['Stack Management']); }); - it(`index pattern listing doesn't show create button`, async () => { + it(`index pattern empty page show create anyway link`, async () => { await PageObjects.settings.clickKibanaIndexPatterns(); - await testSubjects.click('createAnyway'); - await testSubjects.existOrFail('indexPatternTable'); + await testSubjects.missingOrFail('createAnyway'); + await es.transport.request({ + path: '/blogs/_doc', + method: 'POST', + body: { user: 'matt', message: 20 }, + }); + await testSubjects.click('refreshIndicesButton'); await testSubjects.missingOrFail('createIndexPatternButton'); + // test when there's an existing pattern }); it(`shows read-only badge`, async () => { From e39c39fa9810f0723cb11a1789e87b21c7d86d71 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Fri, 17 Jul 2020 23:43:55 -0500 Subject: [PATCH 40/76] update snapshot --- .../__snapshots__/empty_state.test.tsx.snap | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap index 62d1ba065b9a37..475e572b8fe55d 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap @@ -189,29 +189,5 @@ exports[`EmptyState should render normally 1`] = `
- - - - , - } - } - /> - `; From 094de5c2f35cc2a9e676006e93cfaff02b82aebf Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Sat, 18 Jul 2020 09:46:54 -0500 Subject: [PATCH 41/76] typescript fixes --- .../index_pattern_table/empty_state/empty_state.test.tsx | 2 ++ .../index_patterns/feature_controls/index_patterns_security.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.test.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.test.tsx index f5efd8e75b781e..25dafd0763eaa1 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.test.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.test.tsx @@ -42,6 +42,7 @@ describe('EmptyState', () => { onRefresh={() => {}} navigateToApp={async () => {}} isMlAvailable={() => true} + canSave={true} /> ); @@ -59,6 +60,7 @@ describe('EmptyState', () => { onRefresh={onRefreshHandler} navigateToApp={async () => {}} isMlAvailable={() => true} + canSave={true} /> ); diff --git a/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts b/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts index 958f0704a3c837..67eac0920c9352 100644 --- a/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts +++ b/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts @@ -78,6 +78,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { it(`index pattern empty shows create anyway link`, async () => { await PageObjects.settings.clickKibanaIndexPatterns(); await testSubjects.existOrFail('createAnyway'); + // @ts-expect-error await es.transport.request({ path: '/blogs/_doc', method: 'POST', @@ -140,6 +141,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { it(`index pattern empty page show create anyway link`, async () => { await PageObjects.settings.clickKibanaIndexPatterns(); await testSubjects.missingOrFail('createAnyway'); + // @ts-expect-error await es.transport.request({ path: '/blogs/_doc', method: 'POST', From f728360b7803e7c973369ef08f12f87233ea0893 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Sat, 18 Jul 2020 11:12:04 -0500 Subject: [PATCH 42/76] try adding timeout --- .../feature_controls/index_patterns_security.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts b/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts index 67eac0920c9352..5a85e0ca6c7665 100644 --- a/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts +++ b/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts @@ -85,7 +85,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { body: { user: 'matt', message: 20 }, }); await testSubjects.click('refreshIndicesButton'); - await testSubjects.existOrFail('createIndexPatternButton'); + await testSubjects.existOrFail('createIndexPatternButton', { timeout: 5000 }); // test when there's an existing pattern }); @@ -148,7 +148,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { body: { user: 'matt', message: 20 }, }); await testSubjects.click('refreshIndicesButton'); - await testSubjects.missingOrFail('createIndexPatternButton'); + await testSubjects.missingOrFail('createIndexPatternButton', { timeout: 5000 }); // test when there's an existing pattern }); From 4de2cdd976f0b15b96ecd2d1076b395fbb40cb59 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Sun, 19 Jul 2020 21:19:30 -0500 Subject: [PATCH 43/76] fix tests --- .../__snapshots__/empty_state.test.tsx.snap | 24 +++++++++++++++++++ .../index_patterns_security.ts | 1 + 2 files changed, 25 insertions(+) diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap index 475e572b8fe55d..62d1ba065b9a37 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap @@ -189,5 +189,29 @@ exports[`EmptyState should render normally 1`] = ` + + + + , + } + } + /> + `; diff --git a/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts b/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts index 5a85e0ca6c7665..fe99bb3fd77a28 100644 --- a/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts +++ b/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts @@ -84,6 +84,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { method: 'POST', body: { user: 'matt', message: 20 }, }); + // await new Promise((r) => setTimeout(r, 300000)); await testSubjects.click('refreshIndicesButton'); await testSubjects.existOrFail('createIndexPatternButton', { timeout: 5000 }); // test when there's an existing pattern From 847e0e8691a2182ac17aa2c0aaffb7f96b29af48 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Sun, 19 Jul 2020 22:35:36 -0500 Subject: [PATCH 44/76] functional test - create logstash-a index --- .../feature_controls/index_patterns_security.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts b/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts index fe99bb3fd77a28..ed8c4ea1f8d672 100644 --- a/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts +++ b/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts @@ -80,7 +80,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await testSubjects.existOrFail('createAnyway'); // @ts-expect-error await es.transport.request({ - path: '/blogs/_doc', + path: '/logstash-a/_doc', method: 'POST', body: { user: 'matt', message: 20 }, }); @@ -144,7 +144,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await testSubjects.missingOrFail('createAnyway'); // @ts-expect-error await es.transport.request({ - path: '/blogs/_doc', + path: '/logstash-a/_doc', method: 'POST', body: { user: 'matt', message: 20 }, }); From 2c42d74f265f125f8e455de3b6af4242c63e2d7d Mon Sep 17 00:00:00 2001 From: cchaos Date: Mon, 20 Jul 2020 16:06:44 -0400 Subject: [PATCH 45/76] Design quick updates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Only show the card beta badge if it’s disabled - Some text tweaks --- .../components/header/header.tsx | 9 ++++++++- .../empty_state/empty_state.scss | 1 - .../empty_state/empty_state.tsx | 20 ++++++++++++------- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/header/header.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/header/header.tsx index c17b356e159f6a..530d0688b61ca6 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/header/header.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/header/header.tsx @@ -40,7 +40,14 @@ export const Header: React.FC = ({ indexPattern, indexPatternName } - {indexPattern} + {indexPattern}, + indexPatternName, + }} + />
); diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.scss b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.scss index 5b9eaa77a0088f..37889b9d7c4834 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.scss +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.scss @@ -11,7 +11,6 @@ } .inpEmptyState__card { - min-height: $euiSizeXL * 6; min-width: $euiSizeXL * 6; } diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx index 4eaff63cb4b6b4..53d207a0dd4e0c 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx @@ -53,6 +53,8 @@ export const EmptyState = ({ isMlAvailable: () => boolean; canSave: boolean; }) => { + const mlIsAvailable = isMlAvailable(); + const createAnyway = ( navigateToApp('ml', { path: '#/filedatavisualizer' })} className="inpEmptyState__card" - betaBadgeLabel={i18n.translate( - 'indexPatternManagement.createIndexPattern.emptyState.basicLicenseLabel', - { - defaultMessage: 'Basic', - } - )} + betaBadgeLabel={ + mlIsAvailable + ? undefined + : i18n.translate( + 'indexPatternManagement.createIndexPattern.emptyState.basicLicenseLabel', + { + defaultMessage: 'Basic', + } + ) + } betaBadgeTooltipContent={i18n.translate( 'indexPatternManagement.createIndexPattern.emptyState.basicLicenseDescription', { defaultMessage: 'This feature requires a Basic license.', } )} - isDisabled={!isMlAvailable()} + isDisabled={!mlIsAvailable} icon={} title={ Date: Mon, 20 Jul 2020 17:16:18 -0500 Subject: [PATCH 46/76] update snapshots --- .../header/__snapshots__/header.test.tsx.snap | 15 ++++++++++++--- .../__snapshots__/empty_state.test.tsx.snap | 1 - 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/header/__snapshots__/header.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/header/__snapshots__/header.test.tsx.snap index 2ac243780b31db..9efda4fdac7f91 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/header/__snapshots__/header.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/header/__snapshots__/header.test.tsx.snap @@ -17,9 +17,18 @@ exports[`Header should render normally 1`] = ` size="m" /> - - ki* - + + ki* + , + "indexPatternName": "ki*", + } + } + /> `; diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap index 62d1ba065b9a37..3a4d61e3b51d0f 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap @@ -59,7 +59,6 @@ exports[`EmptyState should render normally 1`] = ` Date: Mon, 20 Jul 2020 21:31:01 -0500 Subject: [PATCH 47/76] ingest manager is basic license too --- .../__snapshots__/empty_state.test.tsx.snap | 2 ++ .../empty_state/empty_state.test.tsx | 2 ++ .../empty_state/empty_state.tsx | 20 +++++++++++++++++++ .../index_pattern_table.tsx | 2 ++ .../mount_management_section.tsx | 4 +++- .../index_pattern_management/public/plugin.ts | 3 ++- .../service/environment/environment.mock.ts | 3 +-- .../public/service/environment/environment.ts | 4 +++- .../index_pattern_management/public/types.ts | 1 + x-pack/plugins/ingest_manager/kibana.json | 2 +- .../plugins/ingest_manager/public/plugin.ts | 4 ++++ 11 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap index 3a4d61e3b51d0f..5c60182f117ebd 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap @@ -32,6 +32,7 @@ exports[`EmptyState should render normally 1`] = ` > } + isDisabled={false} onClick={[Function]} title={ { onRefresh={() => {}} navigateToApp={async () => {}} isMlAvailable={() => true} + isIngestManagerAvailable={() => true} canSave={true} /> ); @@ -60,6 +61,7 @@ describe('EmptyState', () => { onRefresh={onRefreshHandler} navigateToApp={async () => {}} isMlAvailable={() => true} + isIngestManagerAvailable={() => true} canSave={true} /> ); diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx index 53d207a0dd4e0c..ece0d18f838163 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx @@ -45,15 +45,18 @@ export const EmptyState = ({ navigateToApp, docLinks, isMlAvailable, + isIngestManagerAvailable, canSave, }: { onRefresh: () => void; navigateToApp: ApplicationStart['navigateToApp']; docLinks: DocLinksStart; isMlAvailable: () => boolean; + isIngestManagerAvailable: () => boolean; canSave: boolean; }) => { const mlIsAvailable = isMlAvailable(); + const imIsAvailable = isIngestManagerAvailable(); const createAnyway = ( @@ -100,7 +103,24 @@ export const EmptyState = ({ navigateToApp('home', { path: '#/tutorial_directory' })} + isDisabled={!imIsAvailable} icon={} title={ { application, http, isMlAvailable, + isIngestManagerAvailable, } = useKibana().services; const [indexPatterns, setIndexPatterns] = useState([]); const [creationOptions, setCreationOptions] = useState([]); @@ -200,6 +201,7 @@ export const IndexPatternTable = ({ canSave, history }: Props) => { docLinks={docLinks} navigateToApp={application.navigateToApp} isMlAvailable={isMlAvailable} + isIngestManagerAvailable={isIngestManagerAvailable} canSave={canSave} /> ); diff --git a/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx b/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx index 2d8abeccb70fcb..625b4a91c52527 100644 --- a/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx +++ b/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx @@ -49,7 +49,8 @@ const readOnlyBadge = { export async function mountManagementSection( getStartServices: StartServicesAccessor, params: ManagementAppMountParams, - isMlAvailable: () => boolean + isMlAvailable: () => boolean, + isIngestManagerAvailable: () => boolean ) { const [ { chrome, application, savedObjects, uiSettings, notifications, overlays, http, docLinks }, @@ -75,6 +76,7 @@ export async function mountManagementSection( indexPatternManagementStart: indexPatternManagementStart as IndexPatternManagementStart, setBreadcrumbs: params.setBreadcrumbs, isMlAvailable, + isIngestManagerAvailable, }; ReactDOM.render( diff --git a/src/plugins/index_pattern_management/public/plugin.ts b/src/plugins/index_pattern_management/public/plugin.ts index 2a7f761ef31b95..25ebbc0f52584f 100644 --- a/src/plugins/index_pattern_management/public/plugin.ts +++ b/src/plugins/index_pattern_management/public/plugin.ts @@ -89,7 +89,8 @@ export class IndexPatternManagementPlugin return mountManagementSection( core.getStartServices, params, - () => this.indexPatternManagementService.environmentService.getEnvironment().ml + () => this.indexPatternManagementService.environmentService.getEnvironment().ml, + () => this.indexPatternManagementService.environmentService.getEnvironment().ingestManager ); }, }); diff --git a/src/plugins/index_pattern_management/public/service/environment/environment.mock.ts b/src/plugins/index_pattern_management/public/service/environment/environment.mock.ts index d8be02bf6552cb..0e90b12c8d7acd 100644 --- a/src/plugins/index_pattern_management/public/service/environment/environment.mock.ts +++ b/src/plugins/index_pattern_management/public/service/environment/environment.mock.ts @@ -30,9 +30,8 @@ const createMock = (): jest.Mocked> => { const service = { setup: jest.fn(), getEnvironment: jest.fn(() => ({ - cloud: false, - apmUi: false, ml: false, + ingestManager: false, })), }; service.setup.mockImplementation(createSetupMock); diff --git a/src/plugins/index_pattern_management/public/service/environment/environment.ts b/src/plugins/index_pattern_management/public/service/environment/environment.ts index af8af630299d70..d93f2b1ce45477 100644 --- a/src/plugins/index_pattern_management/public/service/environment/environment.ts +++ b/src/plugins/index_pattern_management/public/service/environment/environment.ts @@ -23,17 +23,19 @@ export interface Environment { * Flag whether the home app should advertise ml features */ readonly ml: boolean; + readonly ingestManager: boolean; } export class EnvironmentService { private environment = { ml: false, + ingestManager: false, }; public setup() { return { /** - * Update the environment to influence how the home app is presenting available features. + * Update the environment to influence how index pattern management is presenting available features. * This API should not be extended for new features and will be removed in future versions * in favor of display specific extension apis. * @deprecated diff --git a/src/plugins/index_pattern_management/public/types.ts b/src/plugins/index_pattern_management/public/types.ts index b7aa4262452ab2..188257f020d58c 100644 --- a/src/plugins/index_pattern_management/public/types.ts +++ b/src/plugins/index_pattern_management/public/types.ts @@ -45,6 +45,7 @@ export interface IndexPatternManagmentContext { indexPatternManagementStart: IndexPatternManagementStart; setBreadcrumbs: ManagementAppMountParams['setBreadcrumbs']; isMlAvailable: () => boolean; + isIngestManagerAvailable: () => boolean; } export type IndexPatternManagmentContextValue = KibanaReactContextValue< diff --git a/x-pack/plugins/ingest_manager/kibana.json b/x-pack/plugins/ingest_manager/kibana.json index ab0a2ba24ba663..36f1037c48beec 100644 --- a/x-pack/plugins/ingest_manager/kibana.json +++ b/x-pack/plugins/ingest_manager/kibana.json @@ -4,7 +4,7 @@ "server": true, "ui": true, "configPath": ["xpack", "ingestManager"], - "requiredPlugins": ["licensing", "data", "encryptedSavedObjects"], + "requiredPlugins": ["licensing", "data", "encryptedSavedObjects", "indexPatternManagement"], "optionalPlugins": ["security", "features", "cloud", "usageCollection", "home"], "extraPublicDirs": ["common"], "requiredBundles": ["kibanaReact", "esUiShared"] diff --git a/x-pack/plugins/ingest_manager/public/plugin.ts b/x-pack/plugins/ingest_manager/public/plugin.ts index fde4e93f8e39ff..fb8913825fbe78 100644 --- a/x-pack/plugins/ingest_manager/public/plugin.ts +++ b/x-pack/plugins/ingest_manager/public/plugin.ts @@ -14,6 +14,7 @@ import { i18n } from '@kbn/i18n'; import { DEFAULT_APP_CATEGORIES } from '../../../../src/core/public'; import { DataPublicPluginSetup, DataPublicPluginStart } from '../../../../src/plugins/data/public'; import { HomePublicPluginSetup } from '../../../../src/plugins/home/public'; +import { IndexPatternManagementSetup } from '../../../../src/plugins/index_pattern_management/public'; import { LicensingPluginSetup } from '../../licensing/public'; import { PLUGIN_ID, CheckPermissionsResponse, PostIngestSetupResponse } from '../common'; @@ -45,6 +46,7 @@ export interface IngestManagerStart { export interface IngestManagerSetupDeps { licensing: LicensingPluginSetup; data: DataPublicPluginSetup; + indexPatternManagement: IndexPatternManagementSetup; home?: HomePublicPluginSetup; } @@ -97,6 +99,8 @@ export class IngestManagerPlugin deps.home.tutorials.registerModuleNotice(PLUGIN_ID, TutorialModuleNotice); } + // deps.indexPatternManagement.environment.update({ ingestManager: true }); + return {}; } From 12454719f23598fac8d58e3c515f75b9737fc5e9 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Tue, 21 Jul 2020 08:55:09 -0500 Subject: [PATCH 48/76] fix jest tests --- .../public/service/environment/environment.test.ts | 11 +++++++++-- x-pack/plugins/ingest_manager/public/plugin.ts | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/plugins/index_pattern_management/public/service/environment/environment.test.ts b/src/plugins/index_pattern_management/public/service/environment/environment.test.ts index f416afad33c074..0374b379fcc20c 100644 --- a/src/plugins/index_pattern_management/public/service/environment/environment.test.ts +++ b/src/plugins/index_pattern_management/public/service/environment/environment.test.ts @@ -32,7 +32,14 @@ describe('EnvironmentService', () => { describe('getEnvironment', () => { test('returns default values', () => { const service = new EnvironmentService(); - expect(service.getEnvironment()).toEqual({ ml: false }); + expect(service.getEnvironment()).toEqual({ ml: false, ingestManager: false }); + }); + + test('sets values', () => { + const service = new EnvironmentService(); + const setup = service.setup(); + setup.update({ ml: true, ingestManager: true }); + expect(service.getEnvironment()).toEqual({ ml: true, ingestManager: true }); }); test('returns last state of update calls', () => { @@ -40,7 +47,7 @@ describe('EnvironmentService', () => { const setup = service.setup(); setup.update({ ml: true }); setup.update({ ml: false }); - expect(service.getEnvironment()).toEqual({ ml: false }); + expect(service.getEnvironment()).toEqual({ ml: false, ingestManager: false }); }); }); }); diff --git a/x-pack/plugins/ingest_manager/public/plugin.ts b/x-pack/plugins/ingest_manager/public/plugin.ts index fb8913825fbe78..17b9df4d6f27d4 100644 --- a/x-pack/plugins/ingest_manager/public/plugin.ts +++ b/x-pack/plugins/ingest_manager/public/plugin.ts @@ -99,7 +99,7 @@ export class IngestManagerPlugin deps.home.tutorials.registerModuleNotice(PLUGIN_ID, TutorialModuleNotice); } - // deps.indexPatternManagement.environment.update({ ingestManager: true }); + deps.indexPatternManagement.environment.update({ ingestManager: true }); return {}; } From 69044c82c5b3e7de70b9e8148ca19be415c59d43 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Tue, 21 Jul 2020 10:43:51 -0500 Subject: [PATCH 49/76] Revert "fix jest tests" This reverts commit 12454719f23598fac8d58e3c515f75b9737fc5e9. --- .../public/service/environment/environment.test.ts | 11 ++--------- x-pack/plugins/ingest_manager/public/plugin.ts | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/plugins/index_pattern_management/public/service/environment/environment.test.ts b/src/plugins/index_pattern_management/public/service/environment/environment.test.ts index 0374b379fcc20c..f416afad33c074 100644 --- a/src/plugins/index_pattern_management/public/service/environment/environment.test.ts +++ b/src/plugins/index_pattern_management/public/service/environment/environment.test.ts @@ -32,14 +32,7 @@ describe('EnvironmentService', () => { describe('getEnvironment', () => { test('returns default values', () => { const service = new EnvironmentService(); - expect(service.getEnvironment()).toEqual({ ml: false, ingestManager: false }); - }); - - test('sets values', () => { - const service = new EnvironmentService(); - const setup = service.setup(); - setup.update({ ml: true, ingestManager: true }); - expect(service.getEnvironment()).toEqual({ ml: true, ingestManager: true }); + expect(service.getEnvironment()).toEqual({ ml: false }); }); test('returns last state of update calls', () => { @@ -47,7 +40,7 @@ describe('EnvironmentService', () => { const setup = service.setup(); setup.update({ ml: true }); setup.update({ ml: false }); - expect(service.getEnvironment()).toEqual({ ml: false, ingestManager: false }); + expect(service.getEnvironment()).toEqual({ ml: false }); }); }); }); diff --git a/x-pack/plugins/ingest_manager/public/plugin.ts b/x-pack/plugins/ingest_manager/public/plugin.ts index 17b9df4d6f27d4..fb8913825fbe78 100644 --- a/x-pack/plugins/ingest_manager/public/plugin.ts +++ b/x-pack/plugins/ingest_manager/public/plugin.ts @@ -99,7 +99,7 @@ export class IngestManagerPlugin deps.home.tutorials.registerModuleNotice(PLUGIN_ID, TutorialModuleNotice); } - deps.indexPatternManagement.environment.update({ ingestManager: true }); + // deps.indexPatternManagement.environment.update({ ingestManager: true }); return {}; } From 336c746707aa1aa8696a89f83ded24ad87c2ac8c Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Tue, 21 Jul 2020 10:44:14 -0500 Subject: [PATCH 50/76] Revert "ingest manager is basic license too" This reverts commit bdb1ee2d68873d4c0a7136d9373903c91cdf8016. --- .../__snapshots__/empty_state.test.tsx.snap | 2 -- .../empty_state/empty_state.test.tsx | 2 -- .../empty_state/empty_state.tsx | 20 ------------------- .../index_pattern_table.tsx | 2 -- .../mount_management_section.tsx | 4 +--- .../index_pattern_management/public/plugin.ts | 3 +-- .../service/environment/environment.mock.ts | 3 ++- .../public/service/environment/environment.ts | 4 +--- .../index_pattern_management/public/types.ts | 1 - x-pack/plugins/ingest_manager/kibana.json | 2 +- .../plugins/ingest_manager/public/plugin.ts | 4 ---- 11 files changed, 6 insertions(+), 41 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap index 5c60182f117ebd..3a4d61e3b51d0f 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap @@ -32,7 +32,6 @@ exports[`EmptyState should render normally 1`] = ` > } - isDisabled={false} onClick={[Function]} title={ { onRefresh={() => {}} navigateToApp={async () => {}} isMlAvailable={() => true} - isIngestManagerAvailable={() => true} canSave={true} /> ); @@ -61,7 +60,6 @@ describe('EmptyState', () => { onRefresh={onRefreshHandler} navigateToApp={async () => {}} isMlAvailable={() => true} - isIngestManagerAvailable={() => true} canSave={true} /> ); diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx index ece0d18f838163..53d207a0dd4e0c 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx @@ -45,18 +45,15 @@ export const EmptyState = ({ navigateToApp, docLinks, isMlAvailable, - isIngestManagerAvailable, canSave, }: { onRefresh: () => void; navigateToApp: ApplicationStart['navigateToApp']; docLinks: DocLinksStart; isMlAvailable: () => boolean; - isIngestManagerAvailable: () => boolean; canSave: boolean; }) => { const mlIsAvailable = isMlAvailable(); - const imIsAvailable = isIngestManagerAvailable(); const createAnyway = ( @@ -103,24 +100,7 @@ export const EmptyState = ({ navigateToApp('home', { path: '#/tutorial_directory' })} - isDisabled={!imIsAvailable} icon={} title={ { application, http, isMlAvailable, - isIngestManagerAvailable, } = useKibana().services; const [indexPatterns, setIndexPatterns] = useState([]); const [creationOptions, setCreationOptions] = useState([]); @@ -201,7 +200,6 @@ export const IndexPatternTable = ({ canSave, history }: Props) => { docLinks={docLinks} navigateToApp={application.navigateToApp} isMlAvailable={isMlAvailable} - isIngestManagerAvailable={isIngestManagerAvailable} canSave={canSave} /> ); diff --git a/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx b/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx index 625b4a91c52527..2d8abeccb70fcb 100644 --- a/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx +++ b/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx @@ -49,8 +49,7 @@ const readOnlyBadge = { export async function mountManagementSection( getStartServices: StartServicesAccessor, params: ManagementAppMountParams, - isMlAvailable: () => boolean, - isIngestManagerAvailable: () => boolean + isMlAvailable: () => boolean ) { const [ { chrome, application, savedObjects, uiSettings, notifications, overlays, http, docLinks }, @@ -76,7 +75,6 @@ export async function mountManagementSection( indexPatternManagementStart: indexPatternManagementStart as IndexPatternManagementStart, setBreadcrumbs: params.setBreadcrumbs, isMlAvailable, - isIngestManagerAvailable, }; ReactDOM.render( diff --git a/src/plugins/index_pattern_management/public/plugin.ts b/src/plugins/index_pattern_management/public/plugin.ts index 25ebbc0f52584f..2a7f761ef31b95 100644 --- a/src/plugins/index_pattern_management/public/plugin.ts +++ b/src/plugins/index_pattern_management/public/plugin.ts @@ -89,8 +89,7 @@ export class IndexPatternManagementPlugin return mountManagementSection( core.getStartServices, params, - () => this.indexPatternManagementService.environmentService.getEnvironment().ml, - () => this.indexPatternManagementService.environmentService.getEnvironment().ingestManager + () => this.indexPatternManagementService.environmentService.getEnvironment().ml ); }, }); diff --git a/src/plugins/index_pattern_management/public/service/environment/environment.mock.ts b/src/plugins/index_pattern_management/public/service/environment/environment.mock.ts index 0e90b12c8d7acd..d8be02bf6552cb 100644 --- a/src/plugins/index_pattern_management/public/service/environment/environment.mock.ts +++ b/src/plugins/index_pattern_management/public/service/environment/environment.mock.ts @@ -30,8 +30,9 @@ const createMock = (): jest.Mocked> => { const service = { setup: jest.fn(), getEnvironment: jest.fn(() => ({ + cloud: false, + apmUi: false, ml: false, - ingestManager: false, })), }; service.setup.mockImplementation(createSetupMock); diff --git a/src/plugins/index_pattern_management/public/service/environment/environment.ts b/src/plugins/index_pattern_management/public/service/environment/environment.ts index d93f2b1ce45477..af8af630299d70 100644 --- a/src/plugins/index_pattern_management/public/service/environment/environment.ts +++ b/src/plugins/index_pattern_management/public/service/environment/environment.ts @@ -23,19 +23,17 @@ export interface Environment { * Flag whether the home app should advertise ml features */ readonly ml: boolean; - readonly ingestManager: boolean; } export class EnvironmentService { private environment = { ml: false, - ingestManager: false, }; public setup() { return { /** - * Update the environment to influence how index pattern management is presenting available features. + * Update the environment to influence how the home app is presenting available features. * This API should not be extended for new features and will be removed in future versions * in favor of display specific extension apis. * @deprecated diff --git a/src/plugins/index_pattern_management/public/types.ts b/src/plugins/index_pattern_management/public/types.ts index 188257f020d58c..b7aa4262452ab2 100644 --- a/src/plugins/index_pattern_management/public/types.ts +++ b/src/plugins/index_pattern_management/public/types.ts @@ -45,7 +45,6 @@ export interface IndexPatternManagmentContext { indexPatternManagementStart: IndexPatternManagementStart; setBreadcrumbs: ManagementAppMountParams['setBreadcrumbs']; isMlAvailable: () => boolean; - isIngestManagerAvailable: () => boolean; } export type IndexPatternManagmentContextValue = KibanaReactContextValue< diff --git a/x-pack/plugins/ingest_manager/kibana.json b/x-pack/plugins/ingest_manager/kibana.json index 36f1037c48beec..ab0a2ba24ba663 100644 --- a/x-pack/plugins/ingest_manager/kibana.json +++ b/x-pack/plugins/ingest_manager/kibana.json @@ -4,7 +4,7 @@ "server": true, "ui": true, "configPath": ["xpack", "ingestManager"], - "requiredPlugins": ["licensing", "data", "encryptedSavedObjects", "indexPatternManagement"], + "requiredPlugins": ["licensing", "data", "encryptedSavedObjects"], "optionalPlugins": ["security", "features", "cloud", "usageCollection", "home"], "extraPublicDirs": ["common"], "requiredBundles": ["kibanaReact", "esUiShared"] diff --git a/x-pack/plugins/ingest_manager/public/plugin.ts b/x-pack/plugins/ingest_manager/public/plugin.ts index fb8913825fbe78..fde4e93f8e39ff 100644 --- a/x-pack/plugins/ingest_manager/public/plugin.ts +++ b/x-pack/plugins/ingest_manager/public/plugin.ts @@ -14,7 +14,6 @@ import { i18n } from '@kbn/i18n'; import { DEFAULT_APP_CATEGORIES } from '../../../../src/core/public'; import { DataPublicPluginSetup, DataPublicPluginStart } from '../../../../src/plugins/data/public'; import { HomePublicPluginSetup } from '../../../../src/plugins/home/public'; -import { IndexPatternManagementSetup } from '../../../../src/plugins/index_pattern_management/public'; import { LicensingPluginSetup } from '../../licensing/public'; import { PLUGIN_ID, CheckPermissionsResponse, PostIngestSetupResponse } from '../common'; @@ -46,7 +45,6 @@ export interface IngestManagerStart { export interface IngestManagerSetupDeps { licensing: LicensingPluginSetup; data: DataPublicPluginSetup; - indexPatternManagement: IndexPatternManagementSetup; home?: HomePublicPluginSetup; } @@ -99,8 +97,6 @@ export class IngestManagerPlugin deps.home.tutorials.registerModuleNotice(PLUGIN_ID, TutorialModuleNotice); } - // deps.indexPatternManagement.environment.update({ ingestManager: true }); - return {}; } From d5049a28d825b167b65c7bc0bb6e4b3ed22995a5 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Sun, 2 Aug 2020 23:49:48 -0500 Subject: [PATCH 51/76] functional test improvements --- test/functional/apps/management/index.js | 4 ++- .../index_patterns_security.ts | 29 ++++--------------- 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/test/functional/apps/management/index.js b/test/functional/apps/management/index.js index 97e7314f9678e7..790935640e4c8c 100644 --- a/test/functional/apps/management/index.js +++ b/test/functional/apps/management/index.js @@ -32,9 +32,11 @@ export default function ({ getService, loadTestFile }) { await esArchiver.unload('empty_kibana'); }); - describe('', function () { + describe('', async function () { this.tags('ciGroup7'); + loadTestFile(require.resolve('./_index_patterns_empty')); + await esArchiver.loadIfNeeded('makelogs'); loadTestFile(require.resolve('./_create_index_pattern_wizard')); loadTestFile(require.resolve('./_index_pattern_create_delete')); loadTestFile(require.resolve('./_index_pattern_results_sort')); diff --git a/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts b/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts index ed8c4ea1f8d672..bc36f70df3641d 100644 --- a/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts +++ b/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts @@ -15,7 +15,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const appsMenu = getService('appsMenu'); const testSubjects = getService('testSubjects'); const globalNav = getService('globalNav'); - const es = getService('legacyEs'); describe('security', () => { before(async () => { @@ -75,19 +74,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { expect(navLinks).to.eql(['Stack Management']); }); - it(`index pattern empty shows create anyway link`, async () => { + it(`index pattern listing shows create button`, async () => { await PageObjects.settings.clickKibanaIndexPatterns(); - await testSubjects.existOrFail('createAnyway'); - // @ts-expect-error - await es.transport.request({ - path: '/logstash-a/_doc', - method: 'POST', - body: { user: 'matt', message: 20 }, - }); - // await new Promise((r) => setTimeout(r, 300000)); - await testSubjects.click('refreshIndicesButton'); - await testSubjects.existOrFail('createIndexPatternButton', { timeout: 5000 }); - // test when there's an existing pattern + await testSubjects.existOrFail('createIndexPatternButton'); }); it(`doesn't show read-only badge`, async () => { @@ -139,18 +128,10 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { expect(navLinks).to.eql(['Stack Management']); }); - it(`index pattern empty page show create anyway link`, async () => { + it(`index pattern listing doesn't show create button`, async () => { await PageObjects.settings.clickKibanaIndexPatterns(); - await testSubjects.missingOrFail('createAnyway'); - // @ts-expect-error - await es.transport.request({ - path: '/logstash-a/_doc', - method: 'POST', - body: { user: 'matt', message: 20 }, - }); - await testSubjects.click('refreshIndicesButton'); - await testSubjects.missingOrFail('createIndexPatternButton', { timeout: 5000 }); - // test when there's an existing pattern + await testSubjects.existOrFail('indexPatternTable'); + await testSubjects.missingOrFail('createIndexPatternButton'); }); it(`shows read-only badge`, async () => { From fddd47dddfd002ca75766c35f48e13f188c29d32 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Sun, 2 Aug 2020 23:50:30 -0500 Subject: [PATCH 52/76] functional test improvements --- .../apps/management/_index_patterns_empty.ts | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 test/functional/apps/management/_index_patterns_empty.ts diff --git a/test/functional/apps/management/_index_patterns_empty.ts b/test/functional/apps/management/_index_patterns_empty.ts new file mode 100644 index 00000000000000..4eaaef9d047ab2 --- /dev/null +++ b/test/functional/apps/management/_index_patterns_empty.ts @@ -0,0 +1,68 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { FtrProviderContext } from '../../ftr_provider_context'; + +export default function ({ getPageObjects, getService }: FtrProviderContext) { + const esArchiver = getService('esArchiver'); + const kibanaServer = getService('kibanaServer'); + // const config = getService('config'); + const PageObjects = getPageObjects(['common', 'settings']); + // const appsMenu = getService('appsMenu'); + const testSubjects = getService('testSubjects'); + const globalNav = getService('globalNav'); + const es = getService('legacyEs'); + + describe('index pattern empty view', () => { + before(async () => { + await esArchiver.load('empty_kibana'); + await kibanaServer.uiSettings.replace({}); + await PageObjects.settings.navigateTo(); + }); + + after(async () => { + await esArchiver.unload('empty_kibana'); + }); + + // create index pattern and return to verify list + it(`shows empty views`, async () => { + // @ts-expect-error + await es.transport.request({ + path: '/_all', + method: 'DELETE', + }); + await PageObjects.settings.clickKibanaIndexPatterns(); + await testSubjects.existOrFail('createAnyway'); + // @ts-expect-error + await es.transport.request({ + path: '/logstash-a/_doc', + method: 'POST', + body: { user: 'matt', message: 20 }, + }); + // await new Promise((r) => setTimeout(r, 300000)); + await testSubjects.click('refreshIndicesButton'); + await testSubjects.existOrFail('createIndexPatternButton', { timeout: 5000 }); + // test when there's an existing pattern + }); + + it(`doesn't show read-only badge`, async () => { + await globalNav.badgeMissingOrFail(); + }); + }); +} From 631daedd0ca819993098e13bfc5d3739efde11ac Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Mon, 3 Aug 2020 00:17:40 -0500 Subject: [PATCH 53/76] functional test fix --- test/functional/apps/management/_index_patterns_empty.ts | 1 + test/functional/apps/management/index.js | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/apps/management/_index_patterns_empty.ts b/test/functional/apps/management/_index_patterns_empty.ts index 4eaaef9d047ab2..c77d8ad5ed1871 100644 --- a/test/functional/apps/management/_index_patterns_empty.ts +++ b/test/functional/apps/management/_index_patterns_empty.ts @@ -38,6 +38,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => { await esArchiver.unload('empty_kibana'); + await esArchiver.loadIfNeeded('makelogs'); }); // create index pattern and return to verify list diff --git a/test/functional/apps/management/index.js b/test/functional/apps/management/index.js index 790935640e4c8c..9a4a69b878b83c 100644 --- a/test/functional/apps/management/index.js +++ b/test/functional/apps/management/index.js @@ -36,7 +36,6 @@ export default function ({ getService, loadTestFile }) { this.tags('ciGroup7'); loadTestFile(require.resolve('./_index_patterns_empty')); - await esArchiver.loadIfNeeded('makelogs'); loadTestFile(require.resolve('./_create_index_pattern_wizard')); loadTestFile(require.resolve('./_index_pattern_create_delete')); loadTestFile(require.resolve('./_index_pattern_results_sort')); From 027b2c4deacab7fda95c828ed3e3af7547f0e841 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Mon, 3 Aug 2020 06:48:03 -0500 Subject: [PATCH 54/76] localization fix --- test/functional/apps/management/index.js | 2 +- .../plugins/translations/translations/ja-JP.json | 15 --------------- .../plugins/translations/translations/zh-CN.json | 15 --------------- 3 files changed, 1 insertion(+), 31 deletions(-) diff --git a/test/functional/apps/management/index.js b/test/functional/apps/management/index.js index 9a4a69b878b83c..38ea017dee00d4 100644 --- a/test/functional/apps/management/index.js +++ b/test/functional/apps/management/index.js @@ -32,7 +32,7 @@ export default function ({ getService, loadTestFile }) { await esArchiver.unload('empty_kibana'); }); - describe('', async function () { + describe('', function () { this.tags('ciGroup7'); loadTestFile(require.resolve('./_index_patterns_empty')); diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index e2f59f3fa910a3..520f5cf99617ed 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -2386,11 +2386,6 @@ "indexPatternManagement.createIndexPattern.description": "インデックスパターンは、{single}または{multiple}データソース、{star}と一致します。", "indexPatternManagement.createIndexPattern.documentation": "ドキュメンテーションを表示", "indexPatternManagement.createIndexPattern.emptyState.checkDataButton": "新規データを確認", - "indexPatternManagement.createIndexPattern.emptyStateHeader": "Elasticsearchデータが見つかりませんでした", - "indexPatternManagement.createIndexPattern.emptyStateLabel.emptyStateDetail": "{needToIndex} {learnHowLink}または{getStartedLink}", - "indexPatternManagement.createIndexPattern.emptyStateLabel.getStartedLink": "サンプルデータで始めましょう。", - "indexPatternManagement.createIndexPattern.emptyStateLabel.learnHowLink": "方法を学習", - "indexPatternManagement.createIndexPattern.emptyStateLabel.needToIndexLabel": "インデックスパターンを作成する前に、Elasticsearchへのデータのインデックスが必要です。", "indexPatternManagement.createIndexPattern.includeSystemIndicesToggleSwitchLabel": "システムと非表示のインデックスを含める", "indexPatternManagement.createIndexPattern.loadClustersFailMsg": "リモートクラスターの読み込みに失敗", "indexPatternManagement.createIndexPattern.loadIndicesFailMsg": "インデックスの読み込みに失敗", @@ -2401,7 +2396,6 @@ "indexPatternManagement.createIndexPattern.step.indexPatternPlaceholder": "index-name-*", "indexPatternManagement.createIndexPattern.step.invalidCharactersErrorMessage": "{indexPatternName}にはスペースや{characterList}は使えません。", "indexPatternManagement.createIndexPattern.step.loadingHeader": "一致するインデックスを検索中…", - "indexPatternManagement.createIndexPattern.step.loadingLabel": "お待ちください…", "indexPatternManagement.createIndexPattern.step.nextStepButton": "次のステップ", "indexPatternManagement.createIndexPattern.step.pagingLabel": "ページごとの行数: {perPage}", "indexPatternManagement.createIndexPattern.step.status.matchAnyLabel.matchAnyDetail": "インデックスパターンは、{sourceCount, plural, one {個のソース} other {個のソース} }と一致します。", @@ -2551,15 +2545,6 @@ "indexPatternManagement.indexPattern.sectionsHeader": "インデックスパターン", "indexPatternManagement.indexPattern.titleExistsLabel": "「{title}」というタイトルのインデックスパターンがすでに存在します。", "indexPatternManagement.indexPatternList.createButton.betaLabel": "ベータ", - "indexPatternManagement.indexPatternPrompt.exampleOne": "チャートを作成したりコンテンツを素早くクエリできるように log-west-001 という名前の単一のデータソースをインデックスします。", - "indexPatternManagement.indexPatternPrompt.exampleOneTitle": "単一のデータソース", - "indexPatternManagement.indexPatternPrompt.examplesTitle": "インデックスパターンの例", - "indexPatternManagement.indexPatternPrompt.exampleThree": "比較目的に履歴の動向を集約できるよう、これらのログのアーカイブされた月々のロールアップメトリックスを指定どおりに別々のインデックスパターンにグループ分けします。", - "indexPatternManagement.indexPatternPrompt.exampleThreeTitle": "カスタムグルーピング", - "indexPatternManagement.indexPatternPrompt.exampleTwo": "すべての西海岸のサーバーログに対してクエリを実行できるように、頭に「log-west」の付いたすべての受信データソースをグループ化します。", - "indexPatternManagement.indexPatternPrompt.exampleTwoTitle": "複数データソース", - "indexPatternManagement.indexPatternPrompt.subtitle": "インデックスパターンは、Kibanaで共有フィールドにクエリを実行できるよう、種類の異なるデータソースをバケットにまとめることができます。", - "indexPatternManagement.indexPatternPrompt.title": "インデックスパターンについて", "indexPatternManagement.indexPatterns.badge.readOnly.text": "読み取り専用", "indexPatternManagement.indexPatterns.badge.readOnly.tooltip": "インデックスパターンを保存できません", "indexPatternManagement.indexPatterns.createBreadcrumb": "インデックスパターンを作成", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 316d3247d19d5e..ff70784d178587 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -2387,11 +2387,6 @@ "indexPatternManagement.createIndexPattern.description": "索引模式可以匹配单个源,例如 {single} 或 {multiple} 个数据源、{star}。", "indexPatternManagement.createIndexPattern.documentation": "阅读文档", "indexPatternManagement.createIndexPattern.emptyState.checkDataButton": "检查新数据", - "indexPatternManagement.createIndexPattern.emptyStateHeader": "找不到任何 Elasticsearch 数据", - "indexPatternManagement.createIndexPattern.emptyStateLabel.emptyStateDetail": "{needToIndex}{learnHowLink}或{getStartedLink}", - "indexPatternManagement.createIndexPattern.emptyStateLabel.getStartedLink": "开始使用一些样例数据集。", - "indexPatternManagement.createIndexPattern.emptyStateLabel.learnHowLink": "了解操作方法", - "indexPatternManagement.createIndexPattern.emptyStateLabel.needToIndexLabel": "您需要在 Elasticsearch 中索引一些数据后,才能创建索引模式。", "indexPatternManagement.createIndexPattern.includeSystemIndicesToggleSwitchLabel": "包括系统和隐藏索引", "indexPatternManagement.createIndexPattern.loadClustersFailMsg": "无法加载远程集群", "indexPatternManagement.createIndexPattern.loadIndicesFailMsg": "无法加载索引", @@ -2402,7 +2397,6 @@ "indexPatternManagement.createIndexPattern.step.indexPatternPlaceholder": "index-name-*", "indexPatternManagement.createIndexPattern.step.invalidCharactersErrorMessage": "{indexPatternName} 不能包含空格或字符:{characterList}", "indexPatternManagement.createIndexPattern.step.loadingHeader": "正在寻找匹配的索引......", - "indexPatternManagement.createIndexPattern.step.loadingLabel": "请稍候......", "indexPatternManagement.createIndexPattern.step.nextStepButton": "下一步", "indexPatternManagement.createIndexPattern.step.pagingLabel": "每页行数:{perPage}", "indexPatternManagement.createIndexPattern.step.status.matchAnyLabel.matchAnyDetail": "您的索引模式可以匹配{sourceCount, plural, one {您的 # 个源} other {您的 # 个源中的任何一个} }。", @@ -2552,15 +2546,6 @@ "indexPatternManagement.indexPattern.sectionsHeader": "索引模式", "indexPatternManagement.indexPattern.titleExistsLabel": "具有标题“{title}”的索引模式已存在。", "indexPatternManagement.indexPatternList.createButton.betaLabel": "公测版", - "indexPatternManagement.indexPatternPrompt.exampleOne": "索引单个称作 log-west-001 的数据源,以便可以快速地构建图表或查询其内容。", - "indexPatternManagement.indexPatternPrompt.exampleOneTitle": "单数据源", - "indexPatternManagement.indexPatternPrompt.examplesTitle": "索引模式示例", - "indexPatternManagement.indexPatternPrompt.exampleThree": "具体而言,将这些日志每月存档的汇总/打包指标分组成不同的索引模式,从而可以聚合历史趋势以进行比较。", - "indexPatternManagement.indexPatternPrompt.exampleThreeTitle": "定制分组", - "indexPatternManagement.indexPatternPrompt.exampleTwo": "分组以 log-west* 开头的所有传入数据源,以便可以查询所有西海岸服务器日志。", - "indexPatternManagement.indexPatternPrompt.exampleTwoTitle": "多数据源", - "indexPatternManagement.indexPatternPrompt.subtitle": "索引模式允许您将异类的数据源一起装入存储桶,从而可以在 Kibana 中查询它们共享的字段。", - "indexPatternManagement.indexPatternPrompt.title": "关于索引模式", "indexPatternManagement.indexPatterns.badge.readOnly.text": "只读", "indexPatternManagement.indexPatterns.badge.readOnly.tooltip": "无法保存索引模式", "indexPatternManagement.indexPatterns.createBreadcrumb": "创建索引模式", From 8431e16f03c6a94b96681c578568706799a58827 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Mon, 3 Aug 2020 10:05:44 -0500 Subject: [PATCH 55/76] functional test fixes --- test/functional/apps/management/_index_pattern_results_sort.js | 2 +- .../index_patterns/feature_controls/index_patterns_security.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/functional/apps/management/_index_pattern_results_sort.js b/test/functional/apps/management/_index_pattern_results_sort.js index 562159a319e788..9ea02c651eefee 100644 --- a/test/functional/apps/management/_index_pattern_results_sort.js +++ b/test/functional/apps/management/_index_pattern_results_sort.js @@ -75,7 +75,7 @@ export default function ({ getService, getPageObjects }) { }); }); describe('field list pagination', function () { - const EXPECTED_FIELD_COUNT = 86; + const EXPECTED_FIELD_COUNT = 89; before(async function () { await PageObjects.settings.createIndexPattern(); diff --git a/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts b/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts index bc36f70df3641d..cedd96f147c2b2 100644 --- a/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts +++ b/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts @@ -130,7 +130,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { it(`index pattern listing doesn't show create button`, async () => { await PageObjects.settings.clickKibanaIndexPatterns(); - await testSubjects.existOrFail('indexPatternTable'); + await testSubjects.existOrFail('emptyIndexPatternPrompt'); await testSubjects.missingOrFail('createIndexPatternButton'); }); From 04a6f44c717c407f5f054498231eedbc978fc7a8 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Mon, 3 Aug 2020 12:14:34 -0500 Subject: [PATCH 56/76] functional test fix --- test/functional/page_objects/settings_page.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/functional/page_objects/settings_page.ts b/test/functional/page_objects/settings_page.ts index fb63d94f8d145d..76bd870c8c4740 100644 --- a/test/functional/page_objects/settings_page.ts +++ b/test/functional/page_objects/settings_page.ts @@ -302,9 +302,11 @@ export function SettingsPageProvider({ getService, getPageObjects }: FtrProvider } async isIndexPatternListEmpty() { - await testSubjects.existOrFail('indexPatternTable', { timeout: 5000 }); - const indexPatternList = await this.getIndexPatternList(); - return indexPatternList.length === 0; + if (await testSubjects.exists('indexPatternTable', { timeout: 5000 })) { + return true; + } else { + return false; + } } async removeLogstashIndexPatternIfExist() { From f238527a7a579da967e10d194e5445258a706c49 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Mon, 3 Aug 2020 12:48:23 -0500 Subject: [PATCH 57/76] functional test fix --- test/functional/page_objects/settings_page.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/functional/page_objects/settings_page.ts b/test/functional/page_objects/settings_page.ts index 76bd870c8c4740..c6db5508d8b9ec 100644 --- a/test/functional/page_objects/settings_page.ts +++ b/test/functional/page_objects/settings_page.ts @@ -303,9 +303,9 @@ export function SettingsPageProvider({ getService, getPageObjects }: FtrProvider async isIndexPatternListEmpty() { if (await testSubjects.exists('indexPatternTable', { timeout: 5000 })) { - return true; - } else { return false; + } else { + return true; } } From 97bf9c6795c1509ab07c568c7ab6a36d00e27b2b Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Mon, 3 Aug 2020 19:35:01 -0500 Subject: [PATCH 58/76] kibana settings functional test tweak --- test/functional/apps/management/_kibana_settings.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/functional/apps/management/_kibana_settings.js b/test/functional/apps/management/_kibana_settings.js index 2a488a94c68896..0c440309657506 100644 --- a/test/functional/apps/management/_kibana_settings.js +++ b/test/functional/apps/management/_kibana_settings.js @@ -26,6 +26,7 @@ export default function ({ getService, getPageObjects }) { describe('kibana settings', function describeIndexTests() { before(async function () { + await PageObjects.settings.navigateTo(); // delete .kibana index and then wait for Kibana to re-create it await kibanaServer.uiSettings.replace({}); await PageObjects.settings.createIndexPattern(); From 57def4451d3980f6a969b9a96e75e810e63b850a Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Mon, 3 Aug 2020 20:44:39 -0500 Subject: [PATCH 59/76] fix index patten creation for test --- test/functional/apps/management/_kibana_settings.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/functional/apps/management/_kibana_settings.js b/test/functional/apps/management/_kibana_settings.js index 0c440309657506..e2b20bacc0b397 100644 --- a/test/functional/apps/management/_kibana_settings.js +++ b/test/functional/apps/management/_kibana_settings.js @@ -26,10 +26,9 @@ export default function ({ getService, getPageObjects }) { describe('kibana settings', function describeIndexTests() { before(async function () { - await PageObjects.settings.navigateTo(); // delete .kibana index and then wait for Kibana to re-create it await kibanaServer.uiSettings.replace({}); - await PageObjects.settings.createIndexPattern(); + await PageObjects.settings.createIndexPattern('logstash-*'); await PageObjects.settings.navigateTo(); }); From 699c8ee6d51fe0b17ea9a9e665cce0e884c6666a Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Mon, 3 Aug 2020 22:00:07 -0500 Subject: [PATCH 60/76] fix kibana setting functional test --- test/functional/apps/management/_kibana_settings.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/functional/apps/management/_kibana_settings.js b/test/functional/apps/management/_kibana_settings.js index e2b20bacc0b397..bc37e6507a7751 100644 --- a/test/functional/apps/management/_kibana_settings.js +++ b/test/functional/apps/management/_kibana_settings.js @@ -67,6 +67,7 @@ export default function ({ getService, getPageObjects }) { }); it('when false, dashboard state is unhashed', async function () { + await PageObjects.settings.createIndexPattern('logstash-*'); await PageObjects.common.navigateToApp('dashboard'); await PageObjects.dashboard.clickNewDashboard(); await PageObjects.timePicker.setDefaultAbsoluteRange(); From 140e48c7f71f42271e1a82137f3441d726b08db4 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Mon, 3 Aug 2020 22:44:01 -0500 Subject: [PATCH 61/76] fix kibana setting functional test --- test/functional/apps/management/_kibana_settings.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/functional/apps/management/_kibana_settings.js b/test/functional/apps/management/_kibana_settings.js index bc37e6507a7751..80c45930dd8f43 100644 --- a/test/functional/apps/management/_kibana_settings.js +++ b/test/functional/apps/management/_kibana_settings.js @@ -26,6 +26,7 @@ export default function ({ getService, getPageObjects }) { describe('kibana settings', function describeIndexTests() { before(async function () { + await PageObjects.settings.navigateTo(); // delete .kibana index and then wait for Kibana to re-create it await kibanaServer.uiSettings.replace({}); await PageObjects.settings.createIndexPattern('logstash-*'); From 840389706340dd321828cf327eabc150b3068f00 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Mon, 3 Aug 2020 23:47:21 -0500 Subject: [PATCH 62/76] fix kibana setting functional test --- test/functional/apps/management/_kibana_settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/apps/management/_kibana_settings.js b/test/functional/apps/management/_kibana_settings.js index 80c45930dd8f43..ca4d49ba74b636 100644 --- a/test/functional/apps/management/_kibana_settings.js +++ b/test/functional/apps/management/_kibana_settings.js @@ -68,7 +68,7 @@ export default function ({ getService, getPageObjects }) { }); it('when false, dashboard state is unhashed', async function () { - await PageObjects.settings.createIndexPattern('logstash-*'); + // await PageObjects.settings.createIndexPattern('logstash-*'); await PageObjects.common.navigateToApp('dashboard'); await PageObjects.dashboard.clickNewDashboard(); await PageObjects.timePicker.setDefaultAbsoluteRange(); From 35f674c6a5f93f358a73c3afe273034656aaa9a2 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Tue, 4 Aug 2020 00:25:57 -0500 Subject: [PATCH 63/76] fix kibana setting functional test --- test/functional/apps/management/_kibana_settings.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/functional/apps/management/_kibana_settings.js b/test/functional/apps/management/_kibana_settings.js index ca4d49ba74b636..717384a6361dc2 100644 --- a/test/functional/apps/management/_kibana_settings.js +++ b/test/functional/apps/management/_kibana_settings.js @@ -68,7 +68,8 @@ export default function ({ getService, getPageObjects }) { }); it('when false, dashboard state is unhashed', async function () { - // await PageObjects.settings.createIndexPattern('logstash-*'); + await PageObjects.settings.removeLogstashIndexPatternIfExist(); + await PageObjects.settings.createIndexPattern('logstash-*'); await PageObjects.common.navigateToApp('dashboard'); await PageObjects.dashboard.clickNewDashboard(); await PageObjects.timePicker.setDefaultAbsoluteRange(); From 59fb3a4d459e43fcef12681b634ba9321e1462be Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Tue, 4 Aug 2020 08:54:26 -0500 Subject: [PATCH 64/76] fix kibana setting functional test --- .../apps/management/_index_pattern_results_sort.js | 2 +- test/functional/apps/management/_kibana_settings.js | 8 ++++---- test/functional/apps/management/index.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/functional/apps/management/_index_pattern_results_sort.js b/test/functional/apps/management/_index_pattern_results_sort.js index 9ea02c651eefee..562159a319e788 100644 --- a/test/functional/apps/management/_index_pattern_results_sort.js +++ b/test/functional/apps/management/_index_pattern_results_sort.js @@ -75,7 +75,7 @@ export default function ({ getService, getPageObjects }) { }); }); describe('field list pagination', function () { - const EXPECTED_FIELD_COUNT = 89; + const EXPECTED_FIELD_COUNT = 86; before(async function () { await PageObjects.settings.createIndexPattern(); diff --git a/test/functional/apps/management/_kibana_settings.js b/test/functional/apps/management/_kibana_settings.js index 717384a6361dc2..4738a86a480a56 100644 --- a/test/functional/apps/management/_kibana_settings.js +++ b/test/functional/apps/management/_kibana_settings.js @@ -26,10 +26,10 @@ export default function ({ getService, getPageObjects }) { describe('kibana settings', function describeIndexTests() { before(async function () { - await PageObjects.settings.navigateTo(); + // await PageObjects.settings.navigateTo(); // delete .kibana index and then wait for Kibana to re-create it await kibanaServer.uiSettings.replace({}); - await PageObjects.settings.createIndexPattern('logstash-*'); + // await PageObjects.settings.createIndexPattern('logstash-*'); await PageObjects.settings.navigateTo(); }); @@ -68,8 +68,8 @@ export default function ({ getService, getPageObjects }) { }); it('when false, dashboard state is unhashed', async function () { - await PageObjects.settings.removeLogstashIndexPatternIfExist(); - await PageObjects.settings.createIndexPattern('logstash-*'); + // await PageObjects.settings.removeLogstashIndexPatternIfExist(); + // await PageObjects.settings.createIndexPattern('logstash-*'); await PageObjects.common.navigateToApp('dashboard'); await PageObjects.dashboard.clickNewDashboard(); await PageObjects.timePicker.setDefaultAbsoluteRange(); diff --git a/test/functional/apps/management/index.js b/test/functional/apps/management/index.js index 38ea017dee00d4..d5f0c286af7a55 100644 --- a/test/functional/apps/management/index.js +++ b/test/functional/apps/management/index.js @@ -35,7 +35,6 @@ export default function ({ getService, loadTestFile }) { describe('', function () { this.tags('ciGroup7'); - loadTestFile(require.resolve('./_index_patterns_empty')); loadTestFile(require.resolve('./_create_index_pattern_wizard')); loadTestFile(require.resolve('./_index_pattern_create_delete')); loadTestFile(require.resolve('./_index_pattern_results_sort')); @@ -44,6 +43,7 @@ export default function ({ getService, loadTestFile }) { loadTestFile(require.resolve('./_scripted_fields')); loadTestFile(require.resolve('./_scripted_fields_preview')); loadTestFile(require.resolve('./_mgmt_import_saved_objects')); + loadTestFile(require.resolve('./_index_patterns_empty')); }); describe('', function () { From c4cf0fc87e56a80eecfe19d7a731a2d723d706f4 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Tue, 4 Aug 2020 09:48:33 -0500 Subject: [PATCH 65/76] fix kibana setting functional test --- test/functional/apps/management/_kibana_settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/apps/management/_kibana_settings.js b/test/functional/apps/management/_kibana_settings.js index 4738a86a480a56..4019ae10725b00 100644 --- a/test/functional/apps/management/_kibana_settings.js +++ b/test/functional/apps/management/_kibana_settings.js @@ -29,7 +29,7 @@ export default function ({ getService, getPageObjects }) { // await PageObjects.settings.navigateTo(); // delete .kibana index and then wait for Kibana to re-create it await kibanaServer.uiSettings.replace({}); - // await PageObjects.settings.createIndexPattern('logstash-*'); + await PageObjects.settings.createIndexPattern('logstash-*'); await PageObjects.settings.navigateTo(); }); From 2a643db816d953a14b0795fb6fb3118b626555a6 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Tue, 4 Aug 2020 13:02:42 -0500 Subject: [PATCH 66/76] fix kibana setting functional test --- test/functional/apps/management/_index_patterns_empty.ts | 5 +---- test/functional/apps/management/_kibana_settings.js | 2 -- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/test/functional/apps/management/_index_patterns_empty.ts b/test/functional/apps/management/_index_patterns_empty.ts index c77d8ad5ed1871..4e1e03f307b4c5 100644 --- a/test/functional/apps/management/_index_patterns_empty.ts +++ b/test/functional/apps/management/_index_patterns_empty.ts @@ -22,9 +22,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - // const config = getService('config'); const PageObjects = getPageObjects(['common', 'settings']); - // const appsMenu = getService('appsMenu'); const testSubjects = getService('testSubjects'); const globalNav = getService('globalNav'); const es = getService('legacyEs'); @@ -56,10 +54,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { method: 'POST', body: { user: 'matt', message: 20 }, }); - // await new Promise((r) => setTimeout(r, 300000)); await testSubjects.click('refreshIndicesButton'); await testSubjects.existOrFail('createIndexPatternButton', { timeout: 5000 }); - // test when there's an existing pattern + await PageObjects.settings.createIndexPattern('logstash-*'); }); it(`doesn't show read-only badge`, async () => { diff --git a/test/functional/apps/management/_kibana_settings.js b/test/functional/apps/management/_kibana_settings.js index 4019ae10725b00..39ea90c4a94a3f 100644 --- a/test/functional/apps/management/_kibana_settings.js +++ b/test/functional/apps/management/_kibana_settings.js @@ -68,8 +68,6 @@ export default function ({ getService, getPageObjects }) { }); it('when false, dashboard state is unhashed', async function () { - // await PageObjects.settings.removeLogstashIndexPatternIfExist(); - // await PageObjects.settings.createIndexPattern('logstash-*'); await PageObjects.common.navigateToApp('dashboard'); await PageObjects.dashboard.clickNewDashboard(); await PageObjects.timePicker.setDefaultAbsoluteRange(); From f46afbac5fb37dadb4cda48e5c307cc647c48949 Mon Sep 17 00:00:00 2001 From: Matthew Kime Date: Tue, 4 Aug 2020 16:11:30 -0500 Subject: [PATCH 67/76] Update _index_patterns_empty.ts --- test/functional/apps/management/_index_patterns_empty.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/apps/management/_index_patterns_empty.ts b/test/functional/apps/management/_index_patterns_empty.ts index 4e1e03f307b4c5..80da356cb1254e 100644 --- a/test/functional/apps/management/_index_patterns_empty.ts +++ b/test/functional/apps/management/_index_patterns_empty.ts @@ -56,7 +56,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); await testSubjects.click('refreshIndicesButton'); await testSubjects.existOrFail('createIndexPatternButton', { timeout: 5000 }); - await PageObjects.settings.createIndexPattern('logstash-*'); + await PageObjects.settings.createIndexPattern('logstash-*',''); }); it(`doesn't show read-only badge`, async () => { From 6a63f53775fb181de9bbe112a18dcd8e61ddbf45 Mon Sep 17 00:00:00 2001 From: Matthew Kime Date: Tue, 4 Aug 2020 17:27:57 -0500 Subject: [PATCH 68/76] Update _index_patterns_empty.ts --- test/functional/apps/management/_index_patterns_empty.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/apps/management/_index_patterns_empty.ts b/test/functional/apps/management/_index_patterns_empty.ts index 80da356cb1254e..4ae2e7836ac376 100644 --- a/test/functional/apps/management/_index_patterns_empty.ts +++ b/test/functional/apps/management/_index_patterns_empty.ts @@ -56,7 +56,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); await testSubjects.click('refreshIndicesButton'); await testSubjects.existOrFail('createIndexPatternButton', { timeout: 5000 }); - await PageObjects.settings.createIndexPattern('logstash-*',''); + await PageObjects.settings.createIndexPattern('logstash-*', ''); }); it(`doesn't show read-only badge`, async () => { From 882a30fbe764171bad94871748de1634b828ba87 Mon Sep 17 00:00:00 2001 From: Matthew Kime Date: Tue, 4 Aug 2020 17:29:13 -0500 Subject: [PATCH 69/76] Update _kibana_settings.js --- test/functional/apps/management/_kibana_settings.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/functional/apps/management/_kibana_settings.js b/test/functional/apps/management/_kibana_settings.js index 39ea90c4a94a3f..e2b20bacc0b397 100644 --- a/test/functional/apps/management/_kibana_settings.js +++ b/test/functional/apps/management/_kibana_settings.js @@ -26,7 +26,6 @@ export default function ({ getService, getPageObjects }) { describe('kibana settings', function describeIndexTests() { before(async function () { - // await PageObjects.settings.navigateTo(); // delete .kibana index and then wait for Kibana to re-create it await kibanaServer.uiSettings.replace({}); await PageObjects.settings.createIndexPattern('logstash-*'); From efeb099331947bf14e429fcc11c768a238ff0249 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Thu, 6 Aug 2020 15:54:34 -0500 Subject: [PATCH 70/76] hide card when user doesn't have privs --- .../empty_state/empty_state.test.tsx | 5 +- .../empty_state/empty_state.tsx | 81 ++++++++++--------- .../index_pattern_table.tsx | 4 +- .../index_pattern_management/public/index.ts | 2 + .../mount_management_section.tsx | 6 +- .../index_pattern_management/public/plugin.ts | 6 +- .../service/environment/environment.mock.ts | 5 +- .../service/environment/environment.test.ts | 13 +-- .../public/service/environment/environment.ts | 13 ++- .../index_pattern_management/public/types.ts | 8 +- x-pack/plugins/ml/public/plugin.ts | 18 ++++- x-pack/plugins/ml/public/register_feature.ts | 8 +- 12 files changed, 93 insertions(+), 76 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.test.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.test.tsx index 25dafd0763eaa1..7b2cc0f4c3c60e 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.test.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.test.tsx @@ -25,6 +25,7 @@ import sinon from 'sinon'; import { findTestSubject } from '@elastic/eui/lib/test'; import { mountWithIntl } from 'test_utils/enzyme_helpers'; import { docLinksServiceMock } from '../../../../../../core/public/mocks'; +import { MlCardState } from '../../../types'; const docLinks = docLinksServiceMock.createStartContract(); @@ -41,7 +42,7 @@ describe('EmptyState', () => { docLinks={docLinks} onRefresh={() => {}} navigateToApp={async () => {}} - isMlAvailable={() => true} + getMlCardState={() => MlCardState.ENABLED} canSave={true} /> ); @@ -59,7 +60,7 @@ describe('EmptyState', () => { docLinks={docLinks} onRefresh={onRefreshHandler} navigateToApp={async () => {}} - isMlAvailable={() => true} + getMlCardState={() => MlCardState.ENABLED} canSave={true} /> ); diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx index 53d207a0dd4e0c..e223a84d76093a 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx @@ -39,21 +39,59 @@ import { } from '@elastic/eui'; import { useHistory } from 'react-router-dom'; import { reactRouterNavigate } from '../../../../../../plugins/kibana_react/public'; +import { MlCardState } from '../../../types'; export const EmptyState = ({ onRefresh, navigateToApp, docLinks, - isMlAvailable, + getMlCardState, canSave, }: { onRefresh: () => void; navigateToApp: ApplicationStart['navigateToApp']; docLinks: DocLinksStart; - isMlAvailable: () => boolean; + getMlCardState: () => MlCardState; canSave: boolean; }) => { - const mlIsAvailable = isMlAvailable(); + const mlCard = ( + + navigateToApp('ml', { path: '#/filedatavisualizer' })} + className="inpEmptyState__card" + betaBadgeLabel={ + getMlCardState() === MlCardState.ENABLED + ? undefined + : i18n.translate( + 'indexPatternManagement.createIndexPattern.emptyState.basicLicenseLabel', + { + defaultMessage: 'Basic', + } + ) + } + betaBadgeTooltipContent={i18n.translate( + 'indexPatternManagement.createIndexPattern.emptyState.basicLicenseDescription', + { + defaultMessage: 'This feature requires a Basic license.', + } + )} + isDisabled={getMlCardState() === MlCardState.DISABLED} + icon={} + title={ + + } + description={ + + } + /> + + ); const createAnyway = ( @@ -116,42 +154,7 @@ export const EmptyState = ({ } /> - - navigateToApp('ml', { path: '#/filedatavisualizer' })} - className="inpEmptyState__card" - betaBadgeLabel={ - mlIsAvailable - ? undefined - : i18n.translate( - 'indexPatternManagement.createIndexPattern.emptyState.basicLicenseLabel', - { - defaultMessage: 'Basic', - } - ) - } - betaBadgeTooltipContent={i18n.translate( - 'indexPatternManagement.createIndexPattern.emptyState.basicLicenseDescription', - { - defaultMessage: 'This feature requires a Basic license.', - } - )} - isDisabled={!mlIsAvailable} - icon={} - title={ - - } - description={ - - } - /> - + {getMlCardState() !== MlCardState.HIDDEN ? mlCard : <>} { docLinks, application, http, - isMlAvailable, + getMlCardState, } = useKibana().services; const [indexPatterns, setIndexPatterns] = useState([]); const [creationOptions, setCreationOptions] = useState([]); @@ -199,7 +199,7 @@ export const IndexPatternTable = ({ canSave, history }: Props) => { onRefresh={loadSources} docLinks={docLinks} navigateToApp={application.navigateToApp} - isMlAvailable={isMlAvailable} + getMlCardState={getMlCardState} canSave={canSave} /> ); diff --git a/src/plugins/index_pattern_management/public/index.ts b/src/plugins/index_pattern_management/public/index.ts index 2d6db13757eea5..9a0fd39fb4fd91 100644 --- a/src/plugins/index_pattern_management/public/index.ts +++ b/src/plugins/index_pattern_management/public/index.ts @@ -41,3 +41,5 @@ export { IndexPatternCreationOption, IndexPatternListConfig, } from './service'; + +export { MlCardState } from './types'; diff --git a/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx b/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx index 2d8abeccb70fcb..add45a07e0c5fb 100644 --- a/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx +++ b/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx @@ -34,7 +34,7 @@ import { CreateIndexPatternWizardWithRouter, } from '../components'; import { IndexPatternManagementStartDependencies, IndexPatternManagementStart } from '../plugin'; -import { IndexPatternManagmentContext } from '../types'; +import { IndexPatternManagmentContext, MlCardState } from '../types'; const readOnlyBadge = { text: i18n.translate('indexPatternManagement.indexPatterns.badge.readOnly.text', { @@ -49,7 +49,7 @@ const readOnlyBadge = { export async function mountManagementSection( getStartServices: StartServicesAccessor, params: ManagementAppMountParams, - isMlAvailable: () => boolean + getMlCardState: () => MlCardState ) { const [ { chrome, application, savedObjects, uiSettings, notifications, overlays, http, docLinks }, @@ -74,7 +74,7 @@ export async function mountManagementSection( data, indexPatternManagementStart: indexPatternManagementStart as IndexPatternManagementStart, setBreadcrumbs: params.setBreadcrumbs, - isMlAvailable, + getMlCardState, }; ReactDOM.render( diff --git a/src/plugins/index_pattern_management/public/plugin.ts b/src/plugins/index_pattern_management/public/plugin.ts index 2a7f761ef31b95..ee1e00fcafd980 100644 --- a/src/plugins/index_pattern_management/public/plugin.ts +++ b/src/plugins/index_pattern_management/public/plugin.ts @@ -86,10 +86,8 @@ export class IndexPatternManagementPlugin mount: async (params) => { const { mountManagementSection } = await import('./management_app'); - return mountManagementSection( - core.getStartServices, - params, - () => this.indexPatternManagementService.environmentService.getEnvironment().ml + return mountManagementSection(core.getStartServices, params, () => + this.indexPatternManagementService.environmentService.getEnvironment().ml() ); }, }); diff --git a/src/plugins/index_pattern_management/public/service/environment/environment.mock.ts b/src/plugins/index_pattern_management/public/service/environment/environment.mock.ts index d8be02bf6552cb..2c2c68b8ead2d6 100644 --- a/src/plugins/index_pattern_management/public/service/environment/environment.mock.ts +++ b/src/plugins/index_pattern_management/public/service/environment/environment.mock.ts @@ -18,6 +18,7 @@ */ import { EnvironmentService, EnvironmentServiceSetup } from './environment'; +import { MlCardState } from '../../types'; const createSetupMock = (): jest.Mocked => { const setup = { @@ -30,9 +31,7 @@ const createMock = (): jest.Mocked> => { const service = { setup: jest.fn(), getEnvironment: jest.fn(() => ({ - cloud: false, - apmUi: false, - ml: false, + ml: () => MlCardState.ENABLED, })), }; service.setup.mockImplementation(createSetupMock); diff --git a/src/plugins/index_pattern_management/public/service/environment/environment.test.ts b/src/plugins/index_pattern_management/public/service/environment/environment.test.ts index f416afad33c074..1aa67ba751b811 100644 --- a/src/plugins/index_pattern_management/public/service/environment/environment.test.ts +++ b/src/plugins/index_pattern_management/public/service/environment/environment.test.ts @@ -18,13 +18,14 @@ */ import { EnvironmentService } from './environment'; +import { MlCardState } from '../../types'; describe('EnvironmentService', () => { describe('setup', () => { test('allows multiple update calls', () => { const setup = new EnvironmentService().setup(); expect(() => { - setup.update({ ml: true }); + setup.update({ ml: () => MlCardState.ENABLED }); }).not.toThrow(); }); }); @@ -32,15 +33,17 @@ describe('EnvironmentService', () => { describe('getEnvironment', () => { test('returns default values', () => { const service = new EnvironmentService(); - expect(service.getEnvironment()).toEqual({ ml: false }); + expect(service.getEnvironment().ml()).toEqual(MlCardState.DISABLED); }); test('returns last state of update calls', () => { + let cardState = MlCardState.DISABLED; const service = new EnvironmentService(); const setup = service.setup(); - setup.update({ ml: true }); - setup.update({ ml: false }); - expect(service.getEnvironment()).toEqual({ ml: false }); + setup.update({ ml: () => cardState }); + expect(service.getEnvironment().ml()).toEqual(MlCardState.DISABLED); + cardState = MlCardState.ENABLED; + expect(service.getEnvironment().ml()).toEqual(MlCardState.ENABLED); }); }); }); diff --git a/src/plugins/index_pattern_management/public/service/environment/environment.ts b/src/plugins/index_pattern_management/public/service/environment/environment.ts index af8af630299d70..f40ce3589fa76a 100644 --- a/src/plugins/index_pattern_management/public/service/environment/environment.ts +++ b/src/plugins/index_pattern_management/public/service/environment/environment.ts @@ -17,26 +17,25 @@ * under the License. */ +import { MlCardState } from '../../types'; + /** @public */ export interface Environment { /** - * Flag whether the home app should advertise ml features + * Flag whether ml features should be advertised */ - readonly ml: boolean; + readonly ml: () => MlCardState; } export class EnvironmentService { private environment = { - ml: false, + ml: () => MlCardState.DISABLED, }; public setup() { return { /** - * Update the environment to influence how the home app is presenting available features. - * This API should not be extended for new features and will be removed in future versions - * in favor of display specific extension apis. - * @deprecated + * Update the environment to influence how available features are presented. * @param update */ update: (update: Partial) => { diff --git a/src/plugins/index_pattern_management/public/types.ts b/src/plugins/index_pattern_management/public/types.ts index b7aa4262452ab2..2876bd62273507 100644 --- a/src/plugins/index_pattern_management/public/types.ts +++ b/src/plugins/index_pattern_management/public/types.ts @@ -44,9 +44,15 @@ export interface IndexPatternManagmentContext { data: DataPublicPluginStart; indexPatternManagementStart: IndexPatternManagementStart; setBreadcrumbs: ManagementAppMountParams['setBreadcrumbs']; - isMlAvailable: () => boolean; + getMlCardState: () => MlCardState; } export type IndexPatternManagmentContextValue = KibanaReactContextValue< IndexPatternManagmentContext >; + +export enum MlCardState { + HIDDEN, + DISABLED, + ENABLED, +} diff --git a/x-pack/plugins/ml/public/plugin.ts b/x-pack/plugins/ml/public/plugin.ts index f8c18bc05bfbf2..6296cd8ea67baa 100644 --- a/x-pack/plugins/ml/public/plugin.ts +++ b/x-pack/plugins/ml/public/plugin.ts @@ -20,7 +20,10 @@ import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; import { DataPublicPluginStart } from 'src/plugins/data/public'; import { HomePublicPluginSetup } from 'src/plugins/home/public'; -import { IndexPatternManagementSetup } from 'src/plugins/index_pattern_management/public'; +import { + IndexPatternManagementSetup, + MlCardState, +} from 'src/plugins/index_pattern_management/public'; import { EmbeddableSetup } from 'src/plugins/embeddable/public'; import { AppStatus, AppUpdater, DEFAULT_APP_CATEGORIES } from '../../../../src/core/public'; import { SecurityPluginSetup } from '../../security/public'; @@ -106,10 +109,19 @@ export class MlPlugin implements Plugin { }); const licensing = pluginsSetup.licensing.license$.pipe(take(1)); - licensing.subscribe((license) => { + licensing.subscribe(async (license) => { + const [coreStart] = await core.getStartServices(); if (isMlEnabled(license)) { // add ML to home page - registerFeature(pluginsSetup.home, pluginsSetup.indexPatternManagement); + registerFeature(pluginsSetup.home); + + // register ML for the index pattern management no data screen. + pluginsSetup.indexPatternManagement.environment.update({ + ml: () => + coreStart.application.capabilities.ml.canFindFileStructure + ? MlCardState.ENABLED + : MlCardState.HIDDEN, + }); // register various ML plugin features which require a full license if (isFullLicense(license)) { diff --git a/x-pack/plugins/ml/public/register_feature.ts b/x-pack/plugins/ml/public/register_feature.ts index 1cab1faf8fffc4..ca60de612c3d58 100644 --- a/x-pack/plugins/ml/public/register_feature.ts +++ b/x-pack/plugins/ml/public/register_feature.ts @@ -9,18 +9,12 @@ import { HomePublicPluginSetup, FeatureCatalogueCategory, } from '../../../../src/plugins/home/public'; -import { IndexPatternManagementSetup } from '../../../../src/plugins/index_pattern_management/public'; import { PLUGIN_ID } from '../common/constants/app'; -export const registerFeature = ( - home: HomePublicPluginSetup, - indexPatternManagement: IndexPatternManagementSetup -) => { +export const registerFeature = (home: HomePublicPluginSetup) => { // register ML for the kibana home screen. // so the file data visualizer appears to allow people to import data home.environment.update({ ml: true }); - // register ML for the index pattern management no data screen. - indexPatternManagement.environment.update({ ml: true }); // register ML so it appears on the Kibana home page home.featureCatalogue.register({ From 4b75dbbb6eb3a050df8c808abc14003f99ffc3b4 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Thu, 6 Aug 2020 16:19:07 -0500 Subject: [PATCH 71/76] add required bundle --- x-pack/plugins/ml/kibana.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/ml/kibana.json b/x-pack/plugins/ml/kibana.json index 7b4ea5458f4a61..6a94c81e36f6fa 100644 --- a/x-pack/plugins/ml/kibana.json +++ b/x-pack/plugins/ml/kibana.json @@ -32,6 +32,7 @@ "kibanaUtils", "kibanaReact", "dashboard", - "savedObjects" + "savedObjects", + "indexPatternManagement" ] } From 37bcd63da432eb3877f45dda53dcc437ca154236 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Thu, 6 Aug 2020 22:58:04 -0500 Subject: [PATCH 72/76] fix import path --- x-pack/plugins/ml/kibana.json | 3 +-- x-pack/plugins/ml/public/plugin.ts | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/ml/kibana.json b/x-pack/plugins/ml/kibana.json index 6a94c81e36f6fa..7b4ea5458f4a61 100644 --- a/x-pack/plugins/ml/kibana.json +++ b/x-pack/plugins/ml/kibana.json @@ -32,7 +32,6 @@ "kibanaUtils", "kibanaReact", "dashboard", - "savedObjects", - "indexPatternManagement" + "savedObjects" ] } diff --git a/x-pack/plugins/ml/public/plugin.ts b/x-pack/plugins/ml/public/plugin.ts index 6296cd8ea67baa..ff59d46de758d9 100644 --- a/x-pack/plugins/ml/public/plugin.ts +++ b/x-pack/plugins/ml/public/plugin.ts @@ -20,12 +20,10 @@ import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; import { DataPublicPluginStart } from 'src/plugins/data/public'; import { HomePublicPluginSetup } from 'src/plugins/home/public'; -import { - IndexPatternManagementSetup, - MlCardState, -} from 'src/plugins/index_pattern_management/public'; +import { IndexPatternManagementSetup } from 'src/plugins/index_pattern_management/public'; import { EmbeddableSetup } from 'src/plugins/embeddable/public'; import { AppStatus, AppUpdater, DEFAULT_APP_CATEGORIES } from '../../../../src/core/public'; +import { MlCardState } from '../../../../src/plugins/index_pattern_management/public'; import { SecurityPluginSetup } from '../../security/public'; import { LicensingPluginSetup } from '../../licensing/public'; import { registerManagementSection } from './application/management'; From a196e29af303786e5489c7a4c6e1533f0ec02789 Mon Sep 17 00:00:00 2001 From: Matthew Kime Date: Tue, 11 Aug 2020 21:34:28 -0500 Subject: [PATCH 73/76] Update test/functional/page_objects/settings_page.ts Co-authored-by: Luke Elmers --- test/functional/page_objects/settings_page.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test/functional/page_objects/settings_page.ts b/test/functional/page_objects/settings_page.ts index c6db5508d8b9ec..b2dbf7e4165361 100644 --- a/test/functional/page_objects/settings_page.ts +++ b/test/functional/page_objects/settings_page.ts @@ -302,11 +302,7 @@ export function SettingsPageProvider({ getService, getPageObjects }: FtrProvider } async isIndexPatternListEmpty() { - if (await testSubjects.exists('indexPatternTable', { timeout: 5000 })) { - return false; - } else { - return true; - } +return !(await testSubjects.exists('indexPatternTable', { timeout: 5000 })); } async removeLogstashIndexPatternIfExist() { From 029e2adf7ffad249d887e401e66350c4774b08d8 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Tue, 11 Aug 2020 23:06:11 -0500 Subject: [PATCH 74/76] minor fixes --- src/plugins/index_pattern_management/kibana.json | 2 +- ...x_pattern_illustration.js => index_pattern_illustration.tsx} | 0 .../empty_index_pattern_prompt.test.tsx | 2 +- .../components/index_pattern_table/empty_state/empty_state.tsx | 2 +- test/functional/page_objects/settings_page.ts | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) rename src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/assets/{index_pattern_illustration.js => index_pattern_illustration.tsx} (100%) diff --git a/src/plugins/index_pattern_management/kibana.json b/src/plugins/index_pattern_management/kibana.json index 50a59ccac704ad..d0ad6a96065c30 100644 --- a/src/plugins/index_pattern_management/kibana.json +++ b/src/plugins/index_pattern_management/kibana.json @@ -3,6 +3,6 @@ "version": "kibana", "server": true, "ui": true, - "requiredPlugins": ["management", "data", "kibanaLegacy","home"], + "requiredPlugins": ["management", "data", "kibanaLegacy"], "requiredBundles": ["kibanaReact", "kibanaUtils"] } diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/assets/index_pattern_illustration.js b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/assets/index_pattern_illustration.tsx similarity index 100% rename from src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/assets/index_pattern_illustration.js rename to src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/assets/index_pattern_illustration.tsx diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx index fcd68c697a8281..7959767438b1ce 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx @@ -22,7 +22,7 @@ import { EmptyIndexPatternPrompt } from '../empty_index_pattern_prompt'; import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; describe('EmptyIndexPatternPrompt', () => { - it.skip('should render normally', () => { + it('should render normally', () => { const component = shallowWithI18nProvider( {} }]} /> ); diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx index e223a84d76093a..e758184f0f14b7 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx @@ -118,7 +118,7 @@ export const EmptyState = ({ className="inpEmptyState" grow={false} horizontalPosition="center" - data-test-subj="emptyState" + data-test-subj="indexPatternEmptyState" > diff --git a/test/functional/page_objects/settings_page.ts b/test/functional/page_objects/settings_page.ts index b2dbf7e4165361..a4285a5f94d51e 100644 --- a/test/functional/page_objects/settings_page.ts +++ b/test/functional/page_objects/settings_page.ts @@ -302,7 +302,7 @@ export function SettingsPageProvider({ getService, getPageObjects }: FtrProvider } async isIndexPatternListEmpty() { -return !(await testSubjects.exists('indexPatternTable', { timeout: 5000 })); + return !(await testSubjects.exists('indexPatternTable', { timeout: 5000 })); } async removeLogstashIndexPatternIfExist() { From 62b5f42b1244dd1bca8f2f1e7fc9a9003b1ce6de Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Wed, 12 Aug 2020 10:42:43 -0500 Subject: [PATCH 75/76] illsutation to tsx and update snapshot --- .../empty_index_pattern_prompt/empty_index_pattern_prompt.tsx | 1 - .../empty_state/__snapshots__/empty_state.test.tsx.snap | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx index 4a2db96e699db0..00c18848c21303 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx @@ -30,7 +30,6 @@ import { IndexPatternManagmentContext } from '../../../types'; import { useKibana } from '../../../../../../plugins/kibana_react/public'; import { IndexPatternCreationOption } from '../../types'; import { CreateButton } from '../../create_button'; -// @ts-expect-error import { Illustration } from './assets/index_pattern_illustration'; interface Props { diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap index 3a4d61e3b51d0f..645694371f9059 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap @@ -4,7 +4,7 @@ exports[`EmptyState should render normally 1`] = ` From 1c39a74113350dd95b3e4ad2b602d2e4cd5ebbdd Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Wed, 12 Aug 2020 11:08:36 -0500 Subject: [PATCH 76/76] fix jest test --- .../empty_index_pattern_prompt.test.tsx.snap | 33 ++++++++++--------- .../empty_index_pattern_prompt.test.tsx | 7 +++- .../empty_index_pattern_prompt.tsx | 15 ++++++--- .../index_pattern_table.tsx | 9 ++++- 4 files changed, 42 insertions(+), 22 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/__snapshots__/empty_index_pattern_prompt.test.tsx.snap b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/__snapshots__/empty_index_pattern_prompt.test.tsx.snap index 6519b9d479bb4d..c5e6d1220d8bf8 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/__snapshots__/empty_index_pattern_prompt.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/__snapshots__/empty_index_pattern_prompt.test.tsx.snap @@ -29,32 +29,39 @@ exports[`EmptyIndexPatternPrompt should render normally 1`] = `


- - +
@@ -66,27 +73,23 @@ exports[`EmptyIndexPatternPrompt should render normally 1`] = ` type="responsiveColumn" > diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx index 7959767438b1ce..83eb803333afcf 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx @@ -24,7 +24,12 @@ import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; describe('EmptyIndexPatternPrompt', () => { it('should render normally', () => { const component = shallowWithI18nProvider( - {} }]} /> + {} }]} + docLinksIndexPatternIntro={'testUrl'} + setBreadcrumbs={() => {}} + /> ); expect(component).toMatchSnapshot(); diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx index 00c18848c21303..de389097fd4ba5 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.tsx @@ -26,19 +26,24 @@ import { EuiDescriptionListTitle } from '@elastic/eui'; import { EuiDescriptionListDescription, EuiDescriptionList } from '@elastic/eui'; import { EuiLink } from '@elastic/eui'; import { getListBreadcrumbs } from '../../breadcrumbs'; -import { IndexPatternManagmentContext } from '../../../types'; -import { useKibana } from '../../../../../../plugins/kibana_react/public'; import { IndexPatternCreationOption } from '../../types'; import { CreateButton } from '../../create_button'; import { Illustration } from './assets/index_pattern_illustration'; +import { ManagementAppMountParams } from '../../../../../management/public'; interface Props { canSave: boolean; creationOptions: IndexPatternCreationOption[]; + docLinksIndexPatternIntro: string; + setBreadcrumbs: ManagementAppMountParams['setBreadcrumbs']; } -export const EmptyIndexPatternPrompt = ({ canSave, creationOptions }: Props) => { - const { setBreadcrumbs, docLinks } = useKibana().services; +export const EmptyIndexPatternPrompt = ({ + canSave, + creationOptions, + docLinksIndexPatternIntro, + setBreadcrumbs, +}: Props) => { setBreadcrumbs(getListBreadcrumbs()); return ( @@ -93,7 +98,7 @@ export const EmptyIndexPatternPrompt = ({ canSave, creationOptions }: Props) => /> - + { /> ); } else { - return ; + return ( + + ); } }