diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/assets/bg_crawler_landing.png b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/assets/bg_crawler_landing.png new file mode 100644 index 00000000000000..e1f14ac26f353b Binary files /dev/null and b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/assets/bg_crawler_landing.png differ diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/constants.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/constants.ts index 0c1bf051747b58..7e95bf8fb8e45a 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/constants.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/constants.ts @@ -9,5 +9,5 @@ import { i18n } from '@kbn/i18n'; export const CRAWLER_TITLE = i18n.translate( 'xpack.enterpriseSearch.appSearch.engine.crawler.title', - { defaultMessage: 'Crawler' } + { defaultMessage: 'Web Crawler' } ); diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_landing.scss b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_landing.scss new file mode 100644 index 00000000000000..3ace4064008b6d --- /dev/null +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_landing.scss @@ -0,0 +1,13 @@ +.crawlerLanding { + &__panel { + overflow: hidden; + background-image: url('./assets/bg_crawler_landing.png'); + background-size: 45%; + background-repeat: no-repeat; + background-position: right -2rem; + } + + &__wrapper { + max-width: 50rem; + } +} diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_landing.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_landing.test.tsx new file mode 100644 index 00000000000000..9591b82773b9fe --- /dev/null +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_landing.test.tsx @@ -0,0 +1,43 @@ +/* + * 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__'; +import { mockEngineValues } from '../../__mocks__'; + +import React from 'react'; + +import { shallow, ShallowWrapper } from 'enzyme'; + +import { docLinks } from '../../../shared/doc_links'; + +import { CrawlerLanding } from './crawler_landing'; + +describe('CrawlerLanding', () => { + let wrapper: ShallowWrapper; + + beforeEach(() => { + setMockValues({ ...mockEngineValues }); + wrapper = shallow(); + }); + + afterEach(() => { + jest.clearAllMocks(); + }); + + it('contains an external documentation link', () => { + const externalDocumentationLink = wrapper.find('[data-test-subj="CrawlerDocumentationLink"]'); + + expect(externalDocumentationLink.prop('href')).toBe( + `${docLinks.appSearchBase}/web-crawler.html` + ); + }); + + it('contains a link to standalone App Search', () => { + const externalDocumentationLink = wrapper.find('[data-test-subj="CrawlerStandaloneLink"]'); + + expect(externalDocumentationLink.prop('href')).toBe('/as/engines/some-engine/crawler'); + }); +}); diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_landing.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_landing.tsx new file mode 100644 index 00000000000000..a2993b4d86d5a1 --- /dev/null +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_landing.tsx @@ -0,0 +1,85 @@ +/* + * 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 { + EuiButton, + EuiLink, + EuiPageHeader, + 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 './crawler_landing.scss'; +import { CRAWLER_TITLE } from '.'; + +export const CrawlerLanding: React.FC = () => ( +
+ + + +
+ +

+ {i18n.translate('xpack.enterpriseSearch.appSearch.engine.crawler.landingPage.title', { + defaultMessage: 'Setup the Web Crawler', + })} +

+
+ + +

+ {i18n.translate( + 'xpack.enterpriseSearch.appSearch.engine.crawler.landingPage.description', + { + defaultMessage: + "Easily index your website's content. To get started, enter your domain name, provide optional entry points and crawl rules, and we will handle the rest.", + } + )}{' '} + + {i18n.translate( + 'xpack.enterpriseSearch.appSearch.engine.crawler.landingPage.documentationLinkLabel', + { + defaultMessage: 'Learn more about the web crawler.', + } + )} + +

+
+ + + {i18n.translate( + 'xpack.enterpriseSearch.appSearch.engine.crawler.landingPage.standaloneLinkLabel', + { + defaultMessage: 'Configure the web crawler', + } + )} + + +
+
+
+); diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_router.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_router.test.tsx new file mode 100644 index 00000000000000..6aa9ca8c4feb1d --- /dev/null +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_router.test.tsx @@ -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__'; + +import { mockEngineValues } from '../../__mocks__'; + +import React from 'react'; +import { Switch } from 'react-router-dom'; + +import { shallow } from 'enzyme'; + +import { CrawlerLanding } from './crawler_landing'; +import { CrawlerRouter } from './crawler_router'; + +describe('CrawlerRouter', () => { + beforeEach(() => { + setMockValues({ ...mockEngineValues }); + }); + + afterEach(() => { + jest.clearAllMocks(); + }); + + it('renders a landing page', () => { + const wrapper = shallow(); + + expect(wrapper.find(Switch)).toHaveLength(1); + expect(wrapper.find(CrawlerLanding)).toHaveLength(1); + }); +}); diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_router.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_router.tsx new file mode 100644 index 00000000000000..fcc949de7d8b4b --- /dev/null +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_router.tsx @@ -0,0 +1,27 @@ +/* + * 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 { 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 ( + + + + + + + ); +}; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/index.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/index.ts index edb7e43aee35e6..58fb0a7cebb1a7 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/index.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/index.ts @@ -6,3 +6,4 @@ */ export { CRAWLER_TITLE } from './constants'; +export { CrawlerRouter } from './crawler_router'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_nav.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_nav.tsx index 4738209cee4a23..0edf01bada9381 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_nav.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_nav.tsx @@ -12,7 +12,6 @@ import { useValues } from 'kea'; import { EuiText, EuiBadge, EuiIcon, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { getAppSearchUrl } from '../../../shared/enterprise_search_url'; import { SideNavLink, SideNavItem } from '../../../shared/layout'; import { AppLogic } from '../../app_logic'; import { @@ -170,8 +169,7 @@ export const EngineNav: React.FC = () => { )} {canViewEngineCrawler && !isMetaEngine && ( {CRAWLER_TITLE} diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.test.tsx index 39055e772bcf93..3eab209d706fad 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.test.tsx @@ -18,6 +18,7 @@ import { shallow } from 'enzyme'; import { Loading } from '../../../shared/loading'; import { AnalyticsRouter } from '../analytics'; import { ApiLogs } from '../api_logs'; +import { CrawlerRouter } from '../crawler'; import { CurationsRouter } from '../curations'; import { Documents, DocumentDetail } from '../documents'; import { EngineOverview } from '../engine_overview'; @@ -168,4 +169,11 @@ describe('EngineRouter', () => { expect(wrapper.find(SourceEngines)).toHaveLength(1); }); + + it('renders a crawler view', () => { + setMockValues({ ...values, myRole: { canViewEngineCrawler: true } }); + const wrapper = shallow(); + + expect(wrapper.find(CrawlerRouter)).toHaveLength(1); + }); }); diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.tsx index 387f8cf1b9837f..40cc2ef0368c05 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.tsx @@ -23,7 +23,7 @@ import { ENGINE_DOCUMENTS_PATH, ENGINE_DOCUMENT_DETAIL_PATH, ENGINE_SCHEMA_PATH, - // ENGINE_CRAWLER_PATH, + ENGINE_CRAWLER_PATH, META_ENGINE_SOURCE_ENGINES_PATH, ENGINE_RELEVANCE_TUNING_PATH, ENGINE_SYNONYMS_PATH, @@ -34,6 +34,7 @@ import { } from '../../routes'; import { AnalyticsRouter } from '../analytics'; import { ApiLogs } from '../api_logs'; +import { CrawlerRouter } from '../crawler'; import { CurationsRouter } from '../curations'; import { DocumentDetail, Documents } from '../documents'; import { EngineOverview } from '../engine_overview'; @@ -52,7 +53,7 @@ export const EngineRouter: React.FC = () => { canViewEngineAnalytics, canViewEngineDocuments, canViewEngineSchema, - // canViewEngineCrawler, + canViewEngineCrawler, canViewMetaEngineSourceEngines, canManageEngineRelevanceTuning, canManageEngineSynonyms, @@ -143,6 +144,11 @@ export const EngineRouter: React.FC = () => { )} + {canViewEngineCrawler && ( + + + + )}