diff --git a/CHANGELOG.md b/CHANGELOG.md index a961d187d6ad..3a440f643548 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) * [Multi DataSource] Skip data source view in index pattern step when pick default ([#2574](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2574)) * [Multi DataSource] Address UX comments on Edit Data source page ([#2629](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2629)) * [Multi DataSource] Address UX comments on index pattern management stack ([#2611](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2611)) +* [Multi DataSource] Apply get indices error handling in step index pattern ([#2652](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2652)) ### 🚞 Infrastructure 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 1546eda9b552..c27e4d7c1487 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 @@ -39,6 +39,7 @@ exports[`CreateIndexPatternWizard renders index pattern step when there are indi }, ] } + catchAndWarn={[Function]} goToNextStep={[Function]} goToPreviousStep={[Function]} indexPatternCreationType={ @@ -90,6 +91,7 @@ exports[`CreateIndexPatternWizard renders the empty state when there are no indi {}; +const catchAndWarn = jest.fn(async (asyncFn) => await asyncFn); const mockContext = mockManagementPlugin.createIndexPatternManagmentContext(); @@ -94,6 +95,7 @@ describe('StepIndexPattern', () => { goToNextStep, indexPatternCreationType: mockIndexPatternCreationType, initialQuery: 'opensearch-dashboards', + catchAndWarn, }, mockContext ); @@ -116,6 +118,7 @@ describe('StepIndexPattern', () => { isIncludingSystemIndices: false, goToNextStep, indexPatternCreationType: mockIndexPatternCreationType, + catchAndWarn, }, mockContext ); @@ -139,6 +142,7 @@ describe('StepIndexPattern', () => { isIncludingSystemIndices: false, goToNextStep, indexPatternCreationType: mockIndexPatternCreationType, + catchAndWarn, }, mockContext ); @@ -163,6 +167,7 @@ describe('StepIndexPattern', () => { isIncludingSystemIndices: false, goToNextStep, indexPatternCreationType: mockIndexPatternCreationType, + catchAndWarn, }, mockContext ); @@ -179,6 +184,7 @@ describe('StepIndexPattern', () => { isIncludingSystemIndices: false, goToNextStep, indexPatternCreationType: mockIndexPatternCreationType, + catchAndWarn, }, mockContext ); @@ -194,6 +200,7 @@ describe('StepIndexPattern', () => { isIncludingSystemIndices: false, goToNextStep, indexPatternCreationType: mockIndexPatternCreationType, + catchAndWarn, }, mockContext ); 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 e42fc3218dd2..76e47b0875e5 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 @@ -28,7 +28,7 @@ * under the License. */ -import React, { Component } from 'react'; +import React, { Component, ReactElement } from 'react'; import { EuiSpacer, EuiCallOut, @@ -65,6 +65,11 @@ interface StepIndexPatternProps { showSystemIndices: boolean; dataSourceRef?: DataSourceRef; stepInfo: StepInfo; + catchAndWarn: ( + asyncFn: Promise, + errorValue: [] | string[], + errorMsg: ReactElement + ) => Promise; } interface StepIndexPatternState { @@ -165,7 +170,7 @@ export class StepIndexPattern extends Component { - const { indexPatternCreationType, dataSourceRef } = this.props; + const { indexPatternCreationType, dataSourceRef, catchAndWarn } = this.props; const dataSourceId = dataSourceRef?.id; const { existingIndexPatterns } = this.state; const { http } = this.context.services; @@ -180,16 +185,27 @@ export class StepIndexPattern extends Component + ); + if (query.endsWith('*')) { const exactMatchedIndices = await ensureMinimumTime( - getIndices({ - http, - getIndexTags, - pattern: query, - showAllIndices, - searchClient, - dataSourceId, - }) + catchAndWarn( + getIndices({ + http, + getIndexTags, + pattern: query, + showAllIndices, + searchClient, + dataSourceId, + }), + [], + indicesFailMsg + ) ); // If the search changed, discard this state if (query !== this.lastQuery) { @@ -200,22 +216,30 @@ export class StepIndexPattern extends Component );