Skip to content

Commit

Permalink
[MD] Display error toast for create index pattern with data source (#…
Browse files Browse the repository at this point in the history
…2506) (#2526)

* add error toast for create index pattern with data source
* update change log

Signed-off-by: Su <[email protected]>
(cherry picked from commit 0e742b9)
  • Loading branch information
opensearch-trigger-bot[bot] authored Oct 11, 2022
1 parent bebd4bc commit 8b81f4b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

* [MD] Support legacy client for data source ([#2204](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2204))
* [Plugin Helpers] Facilitate version changes ([#2398](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2398))
* [MD] Display error toast for create index pattern with data source ([#2506](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2506))

### 🐛 Bug Fixes
* [Vis Builder] Fixes auto bounds for timeseries bar chart visualization ([2401](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2401))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export class CreateIndexPatternWizard extends Component<
id: errorMsg.props.id,
color: 'warning',
iconType: 'alert',
text: errors.body.message,
},
]),
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('getIndices', () => {
expect(result[1].name).toBe('foo');
});

it('should make two calls in cross cluser case', async () => {
it('should make two calls in cross cluster case', async () => {
http.get.mockResolvedValue(successfulResolveResponse);
const result = await getIndices({
http,
Expand Down Expand Up @@ -201,9 +201,23 @@ describe('getIndices', () => {
getIndexTags,
pattern: 'opensearch-dashboards',
searchClient,
dataSourceId,
});
expect(result.length).toBe(0);
});

it('should throw error with data source use case', async () => {
http.get.mockImplementationOnce(() => {
throw new Error('Test error');
});
expect(
getIndices({
http,
getIndexTags,
pattern: 'opensearch-dashboards',
searchClient,
dataSourceId,
})
).rejects.toThrowError();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,14 @@ export async function getIndices({
pattern,
showAllIndices,
dataSourceId,
}).catch(() => []);
}).catch((error) => {
// swallow the errors to be backwards compatible with non-data-source use case
if (dataSourceId) {
throw error;
} else {
return [];
}
});
requests.push(promiseResolve);

if (isCCS) {
Expand Down

0 comments on commit 8b81f4b

Please sign in to comment.