Skip to content

Commit

Permalink
[App Search] Migrate Source Engines & Crawler pages to new page templ…
Browse files Browse the repository at this point in the history
…ate (#102848) (#103030)

* Convert meta engines Source Engines view to new page template

* Convert CrawlerLanding to new page template

* Convert CrawlerOverview to new page template

* Update routers

* Misc Source Engines UI polish

- move away from color=secondary, EUI is eventually deprecating it
- add (+) icon to match other views

* Fix bad merge conflict
# Conflicts:
#	x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_overview.test.tsx
#	x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_overview.tsx
#	x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_router.test.tsx
#	x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_router.tsx
  • Loading branch information
Constance committed Jun 23, 2021
1 parent 9a5efd8 commit a2f1ecc
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,25 @@

import React from 'react';

import {
EuiButton,
EuiLink,
EuiPageHeader,
EuiPanel,
EuiSpacer,
EuiText,
EuiTitle,
} from '@elastic/eui';
import { EuiButton, EuiLink, EuiPanel, EuiSpacer, EuiText, EuiTitle } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

import { getAppSearchUrl } from '../../../shared/enterprise_search_url';
import { DOCS_PREFIX, ENGINE_CRAWLER_PATH } from '../../routes';
import { generateEnginePath } from '../engine';
import { generateEnginePath, getEngineBreadcrumbs } from '../engine';
import { AppSearchPageTemplate } from '../layout';

import './crawler_landing.scss';
import { CRAWLER_TITLE } from '.';

export const CrawlerLanding: React.FC = () => (
<div data-test-subj="CrawlerLanding" className="crawlerLanding">
<EuiPageHeader pageTitle={CRAWLER_TITLE} />
<EuiSpacer />
<EuiPanel grow paddingSize="l" className="crawlerLanding__panel">
<AppSearchPageTemplate
pageChrome={getEngineBreadcrumbs([CRAWLER_TITLE])}
pageHeader={{ pageTitle: CRAWLER_TITLE }}
className="crawlerLanding"
data-test-subj="CrawlerLanding"
>
<EuiPanel hasBorder paddingSize="l" className="crawlerLanding__panel">
<div className="crawlerLanding__wrapper">
<EuiTitle size="s">
<h2>
Expand Down Expand Up @@ -81,5 +77,5 @@ export const CrawlerLanding: React.FC = () => (
<EuiSpacer size="xl" />
</div>
</EuiPanel>
</div>
</AppSearchPageTemplate>
);
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
* 2.0.
*/

import { setMockValues } from '../../../__mocks__/kea_logic';
import { mockEngineValues } from '../../__mocks__';

import React from 'react';
import { Switch } from 'react-router-dom';

Expand All @@ -18,10 +15,6 @@ import { CrawlerRouter } from './crawler_router';

describe('CrawlerRouter', () => {
beforeEach(() => {
setMockValues({ ...mockEngineValues });
});

afterEach(() => {
jest.clearAllMocks();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,12 @@
import React from 'react';
import { Route, Switch } from 'react-router-dom';

import { SetAppSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome';

import { getEngineBreadcrumbs } from '../engine';

import { CRAWLER_TITLE } from './constants';
import { CrawlerLanding } from './crawler_landing';

export const CrawlerRouter: React.FC = () => {
return (
<Switch>
<Route>
<SetPageChrome trail={getEngineBreadcrumbs([CRAWLER_TITLE])} />
<CrawlerLanding />
</Route>
</Switch>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ export const EngineRouter: React.FC = () => {
<SchemaRouter />
</Route>
)}
{canViewMetaEngineSourceEngines && (
<Route path={META_ENGINE_SOURCE_ENGINES_PATH}>
<SourceEngines />
</Route>
)}
{canViewEngineCrawler && (
<Route path={ENGINE_CRAWLER_PATH}>
<CrawlerRouter />
</Route>
)}
{canManageEngineRelevanceTuning && (
<Route path={ENGINE_RELEVANCE_TUNING_PATH}>
<RelevanceTuning />
Expand Down Expand Up @@ -146,16 +156,6 @@ export const EngineRouter: React.FC = () => {
<Synonyms />
</Route>
)}
{canViewMetaEngineSourceEngines && (
<Route path={META_ENGINE_SOURCE_ENGINES_PATH}>
<SourceEngines />
</Route>
)}
{canViewEngineCrawler && (
<Route path={ENGINE_CRAWLER_PATH}>
<CrawlerRouter />
</Route>
)}
</Layout>
</Switch>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const AddSourceEnginesButton: React.FC = () => {
const { openModal } = useActions(SourceEnginesLogic);

return (
<EuiButton color="secondary" fill onClick={openModal}>
<EuiButton fill iconType="plusInCircle" onClick={openModal}>
{ADD_SOURCE_ENGINES_BUTTON_LABEL}
</EuiButton>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ import '../../__mocks__/engine_logic.mock';

import React from 'react';

import { shallow, ShallowWrapper } from 'enzyme';
import { shallow } from 'enzyme';

import { EuiPageHeader } from '@elastic/eui';

import { Loading } from '../../../shared/loading';
import { getPageHeaderActions } from '../../../test_helpers';

import { AddSourceEnginesButton, AddSourceEnginesModal, SourceEnginesTable } from './components';

Expand Down Expand Up @@ -61,20 +59,10 @@ describe('SourceEngines', () => {
expect(wrapper.find(AddSourceEnginesModal)).toHaveLength(1);
});

it('renders a loading component before data has loaded', () => {
setMockValues({ ...MOCK_VALUES, dataLoading: true });
const wrapper = shallow(<SourceEngines />);

expect(wrapper.find(Loading)).toHaveLength(1);
});

describe('page actions', () => {
const getPageHeader = (wrapper: ShallowWrapper) =>
wrapper.find(EuiPageHeader).dive().children().dive();

it('contains a button to add source engines', () => {
const wrapper = shallow(<SourceEngines />);
expect(getPageHeader(wrapper).find(AddSourceEnginesButton)).toHaveLength(1);
expect(getPageHeaderActions(wrapper).find(AddSourceEnginesButton)).toHaveLength(1);
});

it('hides the add source engines button if the user does not have permissions', () => {
Expand All @@ -86,7 +74,7 @@ describe('SourceEngines', () => {
});
const wrapper = shallow(<SourceEngines />);

expect(getPageHeader(wrapper).find(AddSourceEnginesButton)).toHaveLength(0);
expect(getPageHeaderActions(wrapper).find(AddSourceEnginesButton)).toHaveLength(0);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ import React, { useEffect } from 'react';

import { useActions, useValues } from 'kea';

import { EuiPageHeader, EuiPageContent } from '@elastic/eui';
import { EuiPanel } from '@elastic/eui';

import { FlashMessages } from '../../../shared/flash_messages';
import { SetAppSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome';
import { Loading } from '../../../shared/loading';
import { AppLogic } from '../../app_logic';
import { getEngineBreadcrumbs } from '../engine';
import { AppSearchPageTemplate } from '../layout';

import { AddSourceEnginesButton, AddSourceEnginesModal, SourceEnginesTable } from './components';
import { SOURCE_ENGINES_TITLE } from './i18n';
Expand All @@ -33,20 +31,19 @@ export const SourceEngines: React.FC = () => {
fetchSourceEngines();
}, []);

if (dataLoading) return <Loading />;

return (
<>
<SetPageChrome trail={getEngineBreadcrumbs([SOURCE_ENGINES_TITLE])} />
<EuiPageHeader
pageTitle={SOURCE_ENGINES_TITLE}
rightSideItems={canManageMetaEngineSourceEngines ? [<AddSourceEnginesButton />] : []}
/>
<FlashMessages />
<EuiPageContent hasBorder>
<AppSearchPageTemplate
pageChrome={getEngineBreadcrumbs([SOURCE_ENGINES_TITLE])}
pageHeader={{
pageTitle: SOURCE_ENGINES_TITLE,
rightSideItems: canManageMetaEngineSourceEngines ? [<AddSourceEnginesButton />] : [],
}}
isLoading={dataLoading}
>
<EuiPanel hasBorder>
<SourceEnginesTable />
{isModalOpen && <AddSourceEnginesModal />}
</EuiPageContent>
</>
</EuiPanel>
</AppSearchPageTemplate>
);
};

0 comments on commit a2f1ecc

Please sign in to comment.