Skip to content

Commit 732ee56

Browse files
committed
Add CurationCreation view
1 parent f6dc151 commit 732ee56

4 files changed

Lines changed: 112 additions & 4 deletions

File tree

x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curations_router.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import {
1919
ENGINE_CURATION_ADD_RESULT_PATH,
2020
} from '../../routes';
2121

22-
import { CURATIONS_TITLE } from './constants';
23-
import { Curations } from './views';
22+
import { CURATIONS_TITLE, CREATE_NEW_CURATION_TITLE } from './constants';
23+
import { Curations, CurationCreation } from './views';
2424

2525
interface Props {
2626
engineBreadcrumb: BreadcrumbTrail;
@@ -35,8 +35,8 @@ export const CurationsRouter: React.FC<Props> = ({ engineBreadcrumb }) => {
3535
<Curations />
3636
</Route>
3737
<Route exact path={ENGINE_CURATIONS_NEW_PATH}>
38-
<SetPageChrome trail={[...CURATIONS_BREADCRUMB, 'Create a curation']} />
39-
TODO: Curation creation view
38+
<SetPageChrome trail={[...CURATIONS_BREADCRUMB, CREATE_NEW_CURATION_TITLE]} />
39+
<CurationCreation />
4040
</Route>
4141
<Route exact path={ENGINE_CURATION_PATH}>
4242
<SetPageChrome trail={[...CURATIONS_BREADCRUMB, 'curation queries']} />
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import { setMockActions } from '../../../../__mocks__';
9+
10+
import React from 'react';
11+
12+
import { shallow } from 'enzyme';
13+
14+
import { CurationQueries } from '../components';
15+
16+
import { CurationCreation } from './curation_creation';
17+
18+
describe('CurationCreation', () => {
19+
const actions = {
20+
createCuration: jest.fn(),
21+
};
22+
23+
beforeEach(() => {
24+
jest.clearAllMocks();
25+
setMockActions(actions);
26+
});
27+
28+
it('renders', () => {
29+
const wrapper = shallow(<CurationCreation />);
30+
31+
expect(wrapper.find('h1').text()).toEqual('Create new curation');
32+
expect(wrapper.find(CurationQueries)).toHaveLength(1);
33+
});
34+
35+
it('calls createCuration on CurationQueries submit', () => {
36+
const wrapper = shallow(<CurationCreation />);
37+
wrapper.find(CurationQueries).simulate('submit', ['some query']);
38+
39+
expect(actions.createCuration).toHaveBeenCalledWith(['some query']);
40+
});
41+
});
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import React from 'react';
9+
10+
import { useActions } from 'kea';
11+
12+
import {
13+
EuiPageHeader,
14+
EuiPageHeaderSection,
15+
EuiPageContent,
16+
EuiTitle,
17+
EuiText,
18+
EuiSpacer,
19+
} from '@elastic/eui';
20+
import { i18n } from '@kbn/i18n';
21+
22+
import { FlashMessages } from '../../../../shared/flash_messages';
23+
24+
import { CurationQueries } from '../components';
25+
import { CREATE_NEW_CURATION_TITLE } from '../constants';
26+
import { CurationsLogic } from '../index';
27+
28+
export const CurationCreation: React.FC = () => {
29+
const { createCuration } = useActions(CurationsLogic);
30+
31+
return (
32+
<>
33+
<EuiPageHeader>
34+
<EuiPageHeaderSection>
35+
<EuiTitle size="l">
36+
<h1>{CREATE_NEW_CURATION_TITLE}</h1>
37+
</EuiTitle>
38+
</EuiPageHeaderSection>
39+
</EuiPageHeader>
40+
<FlashMessages />
41+
<EuiPageContent>
42+
<EuiTitle>
43+
<h2>
44+
{i18n.translate(
45+
'xpack.enterpriseSearch.appSearch.engine.curations.create.curationQueriesTitle',
46+
{ defaultMessage: 'Curation queries' }
47+
)}
48+
</h2>
49+
</EuiTitle>
50+
<EuiText color="subdued">
51+
<p>
52+
{i18n.translate(
53+
'xpack.enterpriseSearch.appSearch.engine.curations.create.curationQueriesDescription',
54+
{
55+
defaultMessage:
56+
'Add one or multiple queries to curate. You will be able add or remove more queries later.',
57+
}
58+
)}
59+
</p>
60+
</EuiText>
61+
<EuiSpacer />
62+
<CurationQueries queries={['']} onSubmit={(queries) => createCuration(queries)} />
63+
</EuiPageContent>
64+
</>
65+
);
66+
};

x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
*/
77

88
export { Curations } from './curations';
9+
export { CurationCreation } from './curation_creation';

0 commit comments

Comments
 (0)