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)

* add error toast for create index pattern with data source

Signed-off-by: Su <szhongna@amazon.com>

* update change log

Signed-off-by: Su <szhongna@amazon.com>

Signed-off-by: Su <szhongna@amazon.com>
  • Loading branch information
zhongnansu authored Oct 6, 2022
1 parent 21a173b commit 0e742b9
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 0e742b9

Please sign in to comment.