forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Enterprise Search] Show error panel on API call errors (elastic#156273)
## Summary This PR adds generic error handling for API calls that manage the ELSER model: creation (download), fetching and starting the deployment. If an error occurs, the ELSER panel is replaced with the error panel. The user can navigate to the ML Notifications page with a link, which might contain diagnostic information about the error. ![ELSER_error_handling](https://user-images.githubusercontent.com/14224983/235535266-93e8e822-0603-4a10-8aab-ec77cd167bf6.gif) ### Checklist - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [x] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
291cdb6
commit 5263339
Showing
11 changed files
with
220 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...rch_content/components/search_index/pipelines/ml_inference/text_expansion_errors.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { setMockValues } from '../../../../../__mocks__/kea_logic'; | ||
|
||
import React from 'react'; | ||
|
||
import { shallow } from 'enzyme'; | ||
|
||
import { EuiCallOut } from '@elastic/eui'; | ||
|
||
import { TextExpansionErrors } from './text_expansion_errors'; | ||
|
||
describe('TextExpansionErrors', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
setMockValues({}); | ||
}); | ||
const error = { | ||
title: 'some-error-title', | ||
message: 'some-error-message', | ||
}; | ||
it('extracts error panel with the given title and message', () => { | ||
const wrapper = shallow(<TextExpansionErrors error={error} />); | ||
expect(wrapper.find(EuiCallOut).length).toBe(1); | ||
expect(wrapper.find(EuiCallOut).prop('title')).toEqual(error.title); | ||
expect(wrapper.find(EuiCallOut).find('p').length).toBe(1); | ||
expect(wrapper.find(EuiCallOut).find('p').text()).toEqual(error.message); | ||
}); | ||
}); |
38 changes: 38 additions & 0 deletions
38
...e_search_content/components/search_index/pipelines/ml_inference/text_expansion_errors.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { useValues } from 'kea'; | ||
|
||
import { EuiCallOut, EuiLink } from '@elastic/eui'; | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
|
||
import { HttpLogic } from '../../../../../shared/http'; | ||
|
||
import { ML_NOTIFICATIONS_PATH } from '../../../../routes'; | ||
|
||
export const TextExpansionErrors = ({ error }: { error: { title: string; message: string } }) => { | ||
const { http } = useValues(HttpLogic); | ||
|
||
return ( | ||
<> | ||
<EuiCallOut color="danger" iconType="error" title={error.title}> | ||
<p>{error.message}</p> | ||
<EuiLink href={http.basePath.prepend(ML_NOTIFICATIONS_PATH)} target="_blank"> | ||
{i18n.translate( | ||
'xpack.enterpriseSearch.content.indices.pipelines.textExpansionCreateError.mlNotificationsLink', | ||
{ | ||
defaultMessage: 'Machine Learning notifications', | ||
} | ||
)} | ||
</EuiLink> | ||
</EuiCallOut> | ||
</> | ||
); | ||
}; |
Oops, something went wrong.