Skip to content

Commit

Permalink
[8.13] Fix breadcrumbs and sidebar navigation for connectors/crawler …
Browse files Browse the repository at this point in the history
…+ fix routes for connectors (elastic#178078) (elastic#178249)

# Backport

This will backport the following commits from `main` to `8.13`:
- [Fix breadcrumbs and sidebar navigation for connectors/crawler + fix
routes for connectors
(elastic#178078)](elastic#178078)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Artem
Shelkovnikov","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-03-07T17:02:46Z","message":"Fix
breadcrumbs and sidebar navigation for connectors/crawler + fix routes
for connectors (elastic#178078)\n\n## Summary\r\n\r\nAttempts to
address\r\nhttps://github.com/elastic/search-team/issues/6514.\r\n\r\nSeveral
fixes were made:\r\n\r\n- Routing for new index was broken down into 3
routes per type: new api\r\nindex, new connector, new crawler. It was
done so that the sidebar\r\nnavigation would be accurate\r\n-
Breadcrumbs were updated to match the page location +
sidebar\r\nnavigation.\r\n\r\n## Routing changes to update
navigation:\r\n\r\nSelect
connector:\r\n```\r\napp/enterprise_search/content/search_indices/new_index/select_connector\r\nchanged
to\r\napp/enterprise_search/content/connectors/select_connector\r\n```\r\n\r\nNew
connector:\r\n```\r\napp/enterprise_search/content/search_indices/new_index/connector?service_type=X&connector_type=Y\r\nchanged
to\r\napp/enterprise_search/content/connectors/new_connector?service_type=X&connector_type=Y\r\n```\r\n\r\nNew
web
crawler:\r\n```\r\napp/enterprise_search/content/search_indices/new_index/crawler\r\nchanged
to\r\napp/enterprise_search/content/crawlers/new_crawler\r\n```\r\n\r\n###
Index of Web Crawlers\r\n\r\nBreadcrumbs were changed to \"Web
crawlers\"\r\n\r\nBefore: \r\n<img width=\"455\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/12238374/edd20cf5-40d1-40e8-aa74-3382e0fd2d32\">\r\n\r\nAfter:\r\n<img
width=\"455\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/12238374/4c7941a7-a9b4-4b18-8920-0002a1bf8e78\">\r\n\r\n###
Create Web Crawler\r\n\r\nBreadcrumbs and sidebar navigation were
changed to \"Web crawlers\"\r\n\r\nBefore:\r\n<img width=\"931\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/12238374/4e4182ca-5e75-471a-b0fc-4cc43b2d4fd5\">\r\n\r\nAfter:\r\n<img
width=\"931\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/12238374/e06190ce-9819-419c-9885-2dee3a93794f\">\r\n\r\n###
Select Connector\r\n\r\nBreadcrumb was changed to
\"Connectors\"\r\n\r\nBefore:\r\n<img width=\"553\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/12238374/6472e28e-0123-4327-9afb-118f99e50662\">\r\n\r\nAfter:\r\n<img
width=\"553\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/12238374/7b5cdc89-2d35-4dd9-923f-66cba122c65d\">\r\n\r\n###
Create connector\r\n\r\nBreadcrumb was fixed + sidebar navigation during
actual creation is now\r\nfixed. Notice, than breadcrumb now mentions
connector name!\r\n\r\nBefore:\r\n\r\n<img width=\"931\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/12238374/2baeb13c-be55-4503-8b90-4b4e152e0e35\">\r\n\r\nAfter:\r\n\r\n<img
width=\"931\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/12238374/c005567b-5da7-4405-a484-4a54fa84be60\">\r\n\r\n\r\n###
Checklist\r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n\r\n### Release
Note\r\n\r\nFix breadcrumbs for several Elastic Search Content
pages.","sha":"a199e7847182f4746cf07768c50a2aad1df04121","branchLabelMapping":{"^v8.14.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:EnterpriseSearch","v8.13.0","v8.14.0"],"title":"Fix
breadcrumbs and sidebar navigation for connectors/crawler + fix routes
for
connectors","number":178078,"url":"https://github.com/elastic/kibana/pull/178078","mergeCommit":{"message":"Fix
breadcrumbs and sidebar navigation for connectors/crawler + fix routes
for connectors (elastic#178078)\n\n## Summary\r\n\r\nAttempts to
address\r\nhttps://github.com/elastic/search-team/issues/6514.\r\n\r\nSeveral
fixes were made:\r\n\r\n- Routing for new index was broken down into 3
routes per type: new api\r\nindex, new connector, new crawler. It was
done so that the sidebar\r\nnavigation would be accurate\r\n-
Breadcrumbs were updated to match the page location +
sidebar\r\nnavigation.\r\n\r\n## Routing changes to update
navigation:\r\n\r\nSelect
connector:\r\n```\r\napp/enterprise_search/content/search_indices/new_index/select_connector\r\nchanged
to\r\napp/enterprise_search/content/connectors/select_connector\r\n```\r\n\r\nNew
connector:\r\n```\r\napp/enterprise_search/content/search_indices/new_index/connector?service_type=X&connector_type=Y\r\nchanged
to\r\napp/enterprise_search/content/connectors/new_connector?service_type=X&connector_type=Y\r\n```\r\n\r\nNew
web
crawler:\r\n```\r\napp/enterprise_search/content/search_indices/new_index/crawler\r\nchanged
to\r\napp/enterprise_search/content/crawlers/new_crawler\r\n```\r\n\r\n###
Index of Web Crawlers\r\n\r\nBreadcrumbs were changed to \"Web
crawlers\"\r\n\r\nBefore: \r\n<img width=\"455\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/12238374/edd20cf5-40d1-40e8-aa74-3382e0fd2d32\">\r\n\r\nAfter:\r\n<img
width=\"455\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/12238374/4c7941a7-a9b4-4b18-8920-0002a1bf8e78\">\r\n\r\n###
Create Web Crawler\r\n\r\nBreadcrumbs and sidebar navigation were
changed to \"Web crawlers\"\r\n\r\nBefore:\r\n<img width=\"931\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/12238374/4e4182ca-5e75-471a-b0fc-4cc43b2d4fd5\">\r\n\r\nAfter:\r\n<img
width=\"931\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/12238374/e06190ce-9819-419c-9885-2dee3a93794f\">\r\n\r\n###
Select Connector\r\n\r\nBreadcrumb was changed to
\"Connectors\"\r\n\r\nBefore:\r\n<img width=\"553\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/12238374/6472e28e-0123-4327-9afb-118f99e50662\">\r\n\r\nAfter:\r\n<img
width=\"553\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/12238374/7b5cdc89-2d35-4dd9-923f-66cba122c65d\">\r\n\r\n###
Create connector\r\n\r\nBreadcrumb was fixed + sidebar navigation during
actual creation is now\r\nfixed. Notice, than breadcrumb now mentions
connector name!\r\n\r\nBefore:\r\n\r\n<img width=\"931\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/12238374/2baeb13c-be55-4503-8b90-4b4e152e0e35\">\r\n\r\nAfter:\r\n\r\n<img
width=\"931\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/12238374/c005567b-5da7-4405-a484-4a54fa84be60\">\r\n\r\n\r\n###
Checklist\r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n\r\n### Release
Note\r\n\r\nFix breadcrumbs for several Elastic Search Content
pages.","sha":"a199e7847182f4746cf07768c50a2aad1df04121"}},"sourceBranch":"main","suggestedTargetBranches":["8.13"],"targetPullRequestStates":[{"branch":"8.13","label":"v8.13.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.14.0","branchLabelMappingKey":"^v8.14.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/178078","number":178078,"mergeCommit":{"message":"Fix
breadcrumbs and sidebar navigation for connectors/crawler + fix routes
for connectors (elastic#178078)\n\n## Summary\r\n\r\nAttempts to
address\r\nhttps://github.com/elastic/search-team/issues/6514.\r\n\r\nSeveral
fixes were made:\r\n\r\n- Routing for new index was broken down into 3
routes per type: new api\r\nindex, new connector, new crawler. It was
done so that the sidebar\r\nnavigation would be accurate\r\n-
Breadcrumbs were updated to match the page location +
sidebar\r\nnavigation.\r\n\r\n## Routing changes to update
navigation:\r\n\r\nSelect
connector:\r\n```\r\napp/enterprise_search/content/search_indices/new_index/select_connector\r\nchanged
to\r\napp/enterprise_search/content/connectors/select_connector\r\n```\r\n\r\nNew
connector:\r\n```\r\napp/enterprise_search/content/search_indices/new_index/connector?service_type=X&connector_type=Y\r\nchanged
to\r\napp/enterprise_search/content/connectors/new_connector?service_type=X&connector_type=Y\r\n```\r\n\r\nNew
web
crawler:\r\n```\r\napp/enterprise_search/content/search_indices/new_index/crawler\r\nchanged
to\r\napp/enterprise_search/content/crawlers/new_crawler\r\n```\r\n\r\n###
Index of Web Crawlers\r\n\r\nBreadcrumbs were changed to \"Web
crawlers\"\r\n\r\nBefore: \r\n<img width=\"455\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/12238374/edd20cf5-40d1-40e8-aa74-3382e0fd2d32\">\r\n\r\nAfter:\r\n<img
width=\"455\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/12238374/4c7941a7-a9b4-4b18-8920-0002a1bf8e78\">\r\n\r\n###
Create Web Crawler\r\n\r\nBreadcrumbs and sidebar navigation were
changed to \"Web crawlers\"\r\n\r\nBefore:\r\n<img width=\"931\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/12238374/4e4182ca-5e75-471a-b0fc-4cc43b2d4fd5\">\r\n\r\nAfter:\r\n<img
width=\"931\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/12238374/e06190ce-9819-419c-9885-2dee3a93794f\">\r\n\r\n###
Select Connector\r\n\r\nBreadcrumb was changed to
\"Connectors\"\r\n\r\nBefore:\r\n<img width=\"553\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/12238374/6472e28e-0123-4327-9afb-118f99e50662\">\r\n\r\nAfter:\r\n<img
width=\"553\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/12238374/7b5cdc89-2d35-4dd9-923f-66cba122c65d\">\r\n\r\n###
Create connector\r\n\r\nBreadcrumb was fixed + sidebar navigation during
actual creation is now\r\nfixed. Notice, than breadcrumb now mentions
connector name!\r\n\r\nBefore:\r\n\r\n<img width=\"931\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/12238374/2baeb13c-be55-4503-8b90-4b4e152e0e35\">\r\n\r\nAfter:\r\n\r\n<img
width=\"931\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/12238374/c005567b-5da7-4405-a484-4a54fa84be60\">\r\n\r\n\r\n###
Checklist\r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n\r\n### Release
Note\r\n\r\nFix breadcrumbs for several Elastic Search Content
pages.","sha":"a199e7847182f4746cf07768c50a2aad1df04121"}}]}]
BACKPORT-->

Co-authored-by: Artem Shelkovnikov <[email protected]>
  • Loading branch information
kibanamachine and artem-shelkovnikov authored Mar 7, 2024
1 parent 8f94eb0 commit cc87839
Show file tree
Hide file tree
Showing 16 changed files with 145 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { i18n } from '@kbn/i18n';
import { generateEncodedPath } from '../../../shared/encode_path_params';
import { KibanaLogic } from '../../../shared/kibana';
import { CONNECTOR_DETAIL_TAB_PATH } from '../../routes';
import { baseBreadcrumbs } from '../connectors/connectors';
import { connectorsBreadcrumbs } from '../connectors/connectors';
import { EnterpriseSearchContentPageTemplate } from '../layout/page_template';

import { getHeaderActions } from '../search_index/components/header_actions/header_actions';
Expand Down Expand Up @@ -226,7 +226,7 @@ export const ConnectorDetail: React.FC = () => {

return (
<EnterpriseSearchContentPageTemplate
pageChrome={[...baseBreadcrumbs, connector?.name ?? '...']}
pageChrome={[...connectorsBreadcrumbs, connector?.name ?? '...']}
pageViewTelemetry={tabId}
isLoading={isLoading}
pageHeader={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,16 @@ import {
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';

import { INGESTION_METHOD_IDS } from '../../../../../common/constants';

import { generateEncodedPath } from '../../../shared/encode_path_params';
import { HttpLogic } from '../../../shared/http';
import { KibanaLogic } from '../../../shared/kibana';
import { handlePageChange } from '../../../shared/table_pagination';
import {
NEW_INDEX_METHOD_PATH,
NEW_CRAWLER_PATH,
NEW_INDEX_SELECT_CONNECTOR_CLIENTS_PATH,
NEW_INDEX_SELECT_CONNECTOR_NATIVE_PATH,
NEW_INDEX_SELECT_CONNECTOR_PATH,
} from '../../routes';
import { EnterpriseSearchContentPageTemplate } from '../layout';
import { SelectConnector } from '../new_index/select_connector/select_connector';

import { CannotConnect } from '../search_index/components/cannot_connect';

Expand All @@ -49,13 +45,20 @@ import { ConnectorsLogic } from './connectors_logic';
import { ConnectorsTable } from './connectors_table';
import { CrawlerEmptyState } from './crawler_empty_state';
import { DeleteConnectorModal } from './delete_connector_modal';
import { SelectConnector } from './select_connector/select_connector';

export const baseBreadcrumbs = [
export const connectorsBreadcrumbs = [
i18n.translate('xpack.enterpriseSearch.content.connectors.breadcrumb', {
defaultMessage: 'Connectors',
}),
];

export const crawlersBreadcrumbs = [
i18n.translate('xpack.enterpriseSearch.content.crawlers.breadcrumb', {
defaultMessage: 'Web crawlers',
}),
];

export interface ConnectorsProps {
isCrawler: boolean;
}
Expand Down Expand Up @@ -83,7 +86,7 @@ export const Connectors: React.FC<ConnectorsProps> = ({ isCrawler }) => {
<>
<DeleteConnectorModal isCrawler={isCrawler} />
<EnterpriseSearchContentPageTemplate
pageChrome={baseBreadcrumbs}
pageChrome={!isCrawler ? connectorsBreadcrumbs : crawlersBreadcrumbs}
pageViewTelemetry={!isCrawler ? 'Connectors' : 'Web Crawlers'}
isLoading={isLoading}
pageHeader={{
Expand Down Expand Up @@ -202,11 +205,7 @@ export const Connectors: React.FC<ConnectorsProps> = ({ isCrawler }) => {
iconType="plusInCircle"
fill
onClick={() => {
KibanaLogic.values.navigateToUrl(
generateEncodedPath(NEW_INDEX_METHOD_PATH, {
type: INGESTION_METHOD_IDS.CRAWLER,
})
);
KibanaLogic.values.navigateToUrl(NEW_CRAWLER_PATH);
}}
>
{i18n.translate('xpack.enterpriseSearch.connectors.newCrawlerButtonLabel', {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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 { Routes, Route } from '@kbn/shared-ux-router';

import { CONNECTORS_PATH, NEW_INDEX_SELECT_CONNECTOR_PATH, NEW_CONNECTOR_PATH } from '../../routes';
import { NewSearchIndexPage } from '../new_index/new_search_index_page';

import { Connectors } from './connectors';
import { SelectConnector } from './select_connector/select_connector';

export const ConnectorsRouter: React.FC = () => {
return (
<Routes>
<Route path={NEW_INDEX_SELECT_CONNECTOR_PATH}>
<SelectConnector />
</Route>
<Route path={NEW_CONNECTOR_PATH}>
<NewSearchIndexPage type="connector" />
</Route>
<Route path={CONNECTORS_PATH}>
<Connectors isCrawler={false} />
</Route>
</Routes>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ import { useValues } from 'kea';
import { EuiButton, EuiEmptyPrompt, EuiPanel } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

import { generateEncodedPath } from '../../../shared/encode_path_params';
import { HttpLogic } from '../../../shared/http';
import { KibanaLogic } from '../../../shared/kibana';
import { NEW_INDEX_METHOD_PATH } from '../../routes';
import { NEW_CRAWLER_PATH } from '../../routes';

export const CrawlerEmptyState: React.FC = () => {
const { errorConnectingMessage } = useValues(HttpLogic);
Expand Down Expand Up @@ -46,11 +45,7 @@ export const CrawlerEmptyState: React.FC = () => {
disabled={Boolean(errorConnectingMessage)}
fill
iconType="plusInCircle"
onClick={() =>
KibanaLogic.values.navigateToUrl(
generateEncodedPath(NEW_INDEX_METHOD_PATH, { type: 'crawler' })
)
}
onClick={() => KibanaLogic.values.navigateToUrl(NEW_CRAWLER_PATH)}
>
{i18n.translate('xpack.enterpriseSearch.crawlerEmptyState.newWebCrawlerButtonLabel', {
defaultMessage: 'New web crawler',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* 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 { Routes, Route } from '@kbn/shared-ux-router';

import { CRAWLERS_PATH, NEW_CRAWLER_PATH } from '../../routes';
import { NewSearchIndexPage } from '../new_index/new_search_index_page';

import { Connectors } from './connectors';

export const CrawlersRouter: React.FC = () => {
return (
<Routes>
<Route path={NEW_CRAWLER_PATH}>
<NewSearchIndexPage type="crawler" />
</Route>
<Route path={CRAWLERS_PATH}>
<Connectors isCrawler />
</Route>
</Routes>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,21 @@ import {
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';

import {
CONNECTOR_CLIENTS_TYPE,
CONNECTOR_NATIVE_TYPE,
INGESTION_METHOD_IDS,
} from '../../../../../../common/constants';
import { CONNECTOR_CLIENTS_TYPE, CONNECTOR_NATIVE_TYPE } from '../../../../../../common/constants';

import connectorLogo from '../../../../../assets/source_icons/network_drive.svg';
import { BACK_BUTTON_LABEL } from '../../../../shared/constants';
import { generateEncodedPath } from '../../../../shared/encode_path_params';

import { KibanaLogic } from '../../../../shared/kibana';
import { LicensingLogic } from '../../../../shared/licensing';
import { parseQueryParams } from '../../../../shared/query_params';

import { NEW_INDEX_METHOD_PATH, NEW_INDEX_PATH } from '../../../routes';
import { NEW_CONNECTOR_PATH, NEW_INDEX_PATH } from '../../../routes';
import { EnterpriseSearchContentPageTemplate } from '../../layout';

import { CONNECTORS } from '../../search_index/connector/constants';

import { baseBreadcrumbs } from '../../search_indices';
import { connectorsBreadcrumbs } from '../connectors';

import { ConnectorCheckable } from './connector_checkable';
import { ConnectorDescriptionBadge } from './connector_description_badge_popout';
Expand Down Expand Up @@ -115,7 +110,7 @@ export const SelectConnector: React.FC = () => {
return (
<EnterpriseSearchContentPageTemplate
pageChrome={[
...baseBreadcrumbs,
...connectorsBreadcrumbs,
i18n.translate('xpack.enterpriseSearch.content.indices.selectConnector.breadcrumb', {
defaultMessage: 'Select connector',
}),
Expand Down Expand Up @@ -345,9 +340,7 @@ export const SelectConnector: React.FC = () => {
);
}
KibanaLogic.values.navigateToUrl(
`${generateEncodedPath(NEW_INDEX_METHOD_PATH, {
type: INGESTION_METHOD_IDS.CONNECTOR,
})}?${queryParam.toString()}`
`${NEW_CONNECTOR_PATH}?${queryParam.toString()}`
);
}}
documentationUrl={connector.docsUrl}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ import { INGESTION_METHOD_IDS } from '../../../../../common/constants';

import { ProductFeatures } from '../../../../../common/types';

import { generateEncodedPath } from '../../../shared/encode_path_params';
import { HttpLogic } from '../../../shared/http';
import { KibanaLogic } from '../../../shared/kibana/kibana_logic';

import { NEW_INDEX_METHOD_PATH, NEW_INDEX_SELECT_CONNECTOR_PATH } from '../../routes';
import { NEW_API_PATH, NEW_CRAWLER_PATH, NEW_INDEX_SELECT_CONNECTOR_PATH } from '../../routes';
import { EnterpriseSearchContentPageTemplate } from '../layout/page_template';
import { CannotConnect } from '../search_index/components/cannot_connect';
import { baseBreadcrumbs } from '../search_indices';
Expand Down Expand Up @@ -76,10 +75,10 @@ export const NewIndex: React.FC = () => {
onSelect={() => {
if (type === INGESTION_METHOD_IDS.CONNECTOR) {
KibanaLogic.values.navigateToUrl(NEW_INDEX_SELECT_CONNECTOR_PATH);
} else if (type === INGESTION_METHOD_IDS.CRAWLER) {
KibanaLogic.values.navigateToUrl(NEW_CRAWLER_PATH);
} else {
KibanaLogic.values.navigateToUrl(
generateEncodedPath(NEW_INDEX_METHOD_PATH, { type })
);
KibanaLogic.values.navigateToUrl(NEW_API_PATH);
}
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,19 @@ import React from 'react';

import { Routes, Route } from '@kbn/shared-ux-router';

import {
NEW_INDEX_PATH,
NEW_INDEX_SELECT_CONNECTOR_PATH,
NEW_INDEX_METHOD_PATH,
} from '../../routes';
import { NEW_INDEX_PATH, NEW_API_PATH } from '../../routes';

import { NewIndex } from './new_index';
import { NewSearchIndexPage } from './new_search_index_page';
import { SelectConnector } from './select_connector/select_connector';

export const NewIndexRouter: React.FC = () => {
return (
<Routes>
<Route path={NEW_INDEX_PATH} exact>
<NewIndex />
</Route>
<Route path={NEW_INDEX_SELECT_CONNECTOR_PATH} exact>
<SelectConnector />
</Route>
<Route path={NEW_INDEX_METHOD_PATH} exact>
<NewSearchIndexPage />
<Route path={NEW_API_PATH} exact>
<NewSearchIndexPage type="api" />
</Route>
</Routes>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import React from 'react';

import { useLocation, useParams } from 'react-router-dom';
import { useLocation } from 'react-router-dom';

import { EuiBadge, EuiFlexGroup, EuiFlexItem, EuiIcon } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
Expand All @@ -20,6 +20,7 @@ import {
} from '../../../../../common/constants';
import { parseQueryParams } from '../../../shared/query_params';

import { connectorsBreadcrumbs, crawlersBreadcrumbs } from '../connectors/connectors';
import { EnterpriseSearchContentPageTemplate } from '../layout/page_template';
import { CONNECTORS } from '../search_index/connector/constants';
import { baseBreadcrumbs } from '../search_indices';
Expand Down Expand Up @@ -95,6 +96,44 @@ const parseIsNativeParam = (queryString: string | string[] | null): boolean | un
return undefined;
};

const getBreadcrumb = (method: string, serviceType: string): string[] => {
switch (method) {
case INGESTION_METHOD_IDS.CONNECTOR:
const connector =
Boolean(serviceType) && CONNECTORS.find((item) => item.serviceType === serviceType);

const thisConnectorBreadcrumb = connector
? i18n.translate(
'xpack.enterpriseSearch.content.new_connector_with_service_type.breadcrumbs',
{
defaultMessage: `New {name} connector`,
values: {
name: connector.name,
},
}
)
: i18n.translate('xpack.enterpriseSearch.content.new_connector.breadcrumbs', {
defaultMessage: `New connector`,
});

return [...connectorsBreadcrumbs, thisConnectorBreadcrumb];
case INGESTION_METHOD_IDS.CRAWLER:
return [
...crawlersBreadcrumbs,
i18n.translate('xpack.enterpriseSearch.content.new_web_crawler.breadcrumbs', {
defaultMessage: 'New web crawler',
}),
];
default:
return [
...baseBreadcrumbs,
i18n.translate('xpack.enterpriseSearch.content.new_index.breadcrumbs', {
defaultMessage: 'New search index',
}),
];
}
};

const getConnectorModeBadge = (isNative?: boolean) => {
if (isNative) {
return (
Expand All @@ -117,9 +156,10 @@ const getConnectorModeBadge = (isNative?: boolean) => {
}
return undefined;
};

export const NewSearchIndexPage: React.FC = () => {
const type = decodeURIComponent(useParams<{ type: string }>().type);
export interface NewSearchIndexPageProps {
type: string;
}
export const NewSearchIndexPage: React.FC<NewSearchIndexPageProps> = ({ type }) => {
const { search } = useLocation();
const { service_type: inputServiceType, connector_type: inputConnectorType } =
parseQueryParams(search);
Expand All @@ -131,12 +171,7 @@ export const NewSearchIndexPage: React.FC = () => {

return (
<EnterpriseSearchContentPageTemplate
pageChrome={[
...baseBreadcrumbs,
i18n.translate('xpack.enterpriseSearch.content.new_index.breadcrumbs', {
defaultMessage: 'New search index',
}),
]}
pageChrome={getBreadcrumb(type, serviceType)}
pageViewTelemetry="New Index"
isLoading={false}
pageHeader={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import { KibanaLogic } from '../shared/kibana';
import { VersionMismatchPage } from '../shared/version_mismatch';

import { ConnectorDetailRouter } from './components/connector_detail/connector_detail_router';
import { Connectors } from './components/connectors/connectors';
import { ConnectorsRouter } from './components/connectors/connectors_router';
import { CrawlersRouter } from './components/connectors/crawlers_router';
import { NotFound } from './components/not_found';
import { SearchIndicesRouter } from './components/search_indices';
import {
Expand Down Expand Up @@ -77,14 +78,14 @@ export const EnterpriseSearchContentConfigured: React.FC<Required<InitialAppData
<Route path={SEARCH_INDICES_PATH}>
<SearchIndicesRouter />
</Route>
<Route path={CONNECTORS_PATH}>
<ConnectorsRouter />
</Route>
<Route path={CONNECTOR_DETAIL_PATH}>
<ConnectorDetailRouter />
</Route>
<Route path={CONNECTORS_PATH}>
<Connectors isCrawler={false} />
</Route>
<Route path={CRAWLERS_PATH}>
<Connectors isCrawler />
<CrawlersRouter />
</Route>
<Route>
<NotFound />
Expand Down
Loading

0 comments on commit cc87839

Please sign in to comment.