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.
[App Search] Final Document Creation API, Logic, & Summary/Error views (
elastic#86822) * [Setup] Server API route * [Cleanup] Remove unnecessary DocumentCreationSteps - errors can/should be shown in the EuiFlyoutBody banner (better UX since the JSON/file is right there for reference) vs its own page - No need to distinguish between ShowErrorSummary and ShowSuccessSummary + placeholder Summary view for now * Add DocumentCreationLogic file upload logic * Update creation form components to show error/warning feedback * Add final post-upload summary view - split up into subcomponents for easier reading/testing * [lint] oops, double licenses * [PR feedback] map -> forEach * [PR feedback] Reset form state on flyout close Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
Showing
27 changed files
with
1,687 additions
and
57 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
50 changes: 50 additions & 0 deletions
50
...ions/app_search/components/document_creation/creation_response_components/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,50 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { setMockValues } from '../../../../__mocks__/kea.mock'; | ||
|
||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { EuiCallOut } from '@elastic/eui'; | ||
|
||
import { Errors } from './'; | ||
|
||
describe('Errors', () => { | ||
it('does not render if no errors or warnings to render', () => { | ||
setMockValues({ errors: [], warnings: [] }); | ||
const wrapper = shallow(<Errors />); | ||
|
||
expect(wrapper.find(EuiCallOut)).toHaveLength(0); | ||
}); | ||
|
||
it('renders errors', () => { | ||
setMockValues({ errors: ['error 1', 'error 2'], warnings: [] }); | ||
const wrapper = shallow(<Errors />); | ||
|
||
expect(wrapper.find(EuiCallOut)).toHaveLength(1); | ||
expect(wrapper.find(EuiCallOut).prop('title')).toEqual( | ||
'Something went wrong. Please address the errors and try again.' | ||
); | ||
expect(wrapper.find('p').first().text()).toEqual('error 1'); | ||
expect(wrapper.find('p').last().text()).toEqual('error 2'); | ||
}); | ||
|
||
it('renders warnings', () => { | ||
setMockValues({ errors: [], warnings: ['document size warning'] }); | ||
const wrapper = shallow(<Errors />); | ||
|
||
expect(wrapper.find(EuiCallOut)).toHaveLength(1); | ||
expect(wrapper.find(EuiCallOut).prop('title')).toEqual('Warning!'); | ||
expect(wrapper.find('p').text()).toEqual('document size warning'); | ||
}); | ||
|
||
it('renders both errors and warnings', () => { | ||
setMockValues({ errors: ['some error'], warnings: ['some warning'] }); | ||
const wrapper = shallow(<Errors />); | ||
|
||
expect(wrapper.find(EuiCallOut)).toHaveLength(2); | ||
}); | ||
}); |
36 changes: 36 additions & 0 deletions
36
...lications/app_search/components/document_creation/creation_response_components/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,36 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { useValues } from 'kea'; | ||
|
||
import { EuiCallOut } from '@elastic/eui'; | ||
|
||
import { DOCUMENT_CREATION_ERRORS, DOCUMENT_CREATION_WARNINGS } from '../constants'; | ||
import { DocumentCreationLogic } from '../'; | ||
|
||
export const Errors: React.FC = () => { | ||
const { errors, warnings } = useValues(DocumentCreationLogic); | ||
|
||
return ( | ||
<> | ||
{errors.length > 0 && ( | ||
<EuiCallOut color="danger" iconType="alert" title={DOCUMENT_CREATION_ERRORS.TITLE}> | ||
{errors.map((message, index) => ( | ||
<p key={index}>{message}</p> | ||
))} | ||
</EuiCallOut> | ||
)} | ||
{warnings.length > 0 && ( | ||
<EuiCallOut color="warning" iconType="alert" title={DOCUMENT_CREATION_WARNINGS.TITLE}> | ||
{warnings.map((message, index) => ( | ||
<p key={index}>{message}</p> | ||
))} | ||
</EuiCallOut> | ||
)} | ||
</> | ||
); | ||
}; |
Oops, something went wrong.