-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
112 additions
and
4 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
41 changes: 41 additions & 0 deletions
41
...arch/public/applications/app_search/components/curations/views/curation_creation.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,41 @@ | ||
/* | ||
* 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 { setMockActions } from '../../../../__mocks__'; | ||
|
||
import React from 'react'; | ||
|
||
import { shallow } from 'enzyme'; | ||
|
||
import { CurationQueries } from '../components'; | ||
|
||
import { CurationCreation } from './curation_creation'; | ||
|
||
describe('CurationCreation', () => { | ||
const actions = { | ||
createCuration: jest.fn(), | ||
}; | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
setMockActions(actions); | ||
}); | ||
|
||
it('renders', () => { | ||
const wrapper = shallow(<CurationCreation />); | ||
|
||
expect(wrapper.find('h1').text()).toEqual('Create new curation'); | ||
expect(wrapper.find(CurationQueries)).toHaveLength(1); | ||
}); | ||
|
||
it('calls createCuration on CurationQueries submit', () => { | ||
const wrapper = shallow(<CurationCreation />); | ||
wrapper.find(CurationQueries).simulate('submit', ['some query']); | ||
|
||
expect(actions.createCuration).toHaveBeenCalledWith(['some query']); | ||
}); | ||
}); |
66 changes: 66 additions & 0 deletions
66
...se_search/public/applications/app_search/components/curations/views/curation_creation.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,66 @@ | ||
/* | ||
* 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 { useActions } from 'kea'; | ||
|
||
import { | ||
EuiPageHeader, | ||
EuiPageHeaderSection, | ||
EuiPageContent, | ||
EuiTitle, | ||
EuiText, | ||
EuiSpacer, | ||
} from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
import { FlashMessages } from '../../../../shared/flash_messages'; | ||
|
||
import { CurationQueries } from '../components'; | ||
import { CREATE_NEW_CURATION_TITLE } from '../constants'; | ||
import { CurationsLogic } from '../index'; | ||
|
||
export const CurationCreation: React.FC = () => { | ||
const { createCuration } = useActions(CurationsLogic); | ||
|
||
return ( | ||
<> | ||
<EuiPageHeader> | ||
<EuiPageHeaderSection> | ||
<EuiTitle size="l"> | ||
<h1>{CREATE_NEW_CURATION_TITLE}</h1> | ||
</EuiTitle> | ||
</EuiPageHeaderSection> | ||
</EuiPageHeader> | ||
<FlashMessages /> | ||
<EuiPageContent> | ||
<EuiTitle> | ||
<h2> | ||
{i18n.translate( | ||
'xpack.enterpriseSearch.appSearch.engine.curations.create.curationQueriesTitle', | ||
{ defaultMessage: 'Curation queries' } | ||
)} | ||
</h2> | ||
</EuiTitle> | ||
<EuiText color="subdued"> | ||
<p> | ||
{i18n.translate( | ||
'xpack.enterpriseSearch.appSearch.engine.curations.create.curationQueriesDescription', | ||
{ | ||
defaultMessage: | ||
'Add one or multiple queries to curate. You will be able add or remove more queries later.', | ||
} | ||
)} | ||
</p> | ||
</EuiText> | ||
<EuiSpacer /> | ||
<CurationQueries queries={['']} onSubmit={(queries) => createCuration(queries)} /> | ||
</EuiPageContent> | ||
</> | ||
); | ||
}; |
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 |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
*/ | ||
|
||
export { Curations } from './curations'; | ||
export { CurationCreation } from './curation_creation'; |