diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/search_index.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/search_index.tsx
index 09e6b494f94e4..7c13a3f524ccf 100644
--- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/search_index.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/search_index.tsx
@@ -5,7 +5,7 @@
* 2.0.
*/
-import React, { useEffect } from 'react';
+import React, { useEffect, useMemo } from 'react';
import { useParams } from 'react-router-dom';
@@ -15,12 +15,15 @@ import { EuiTabbedContent, EuiTabbedContentTab } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
+import { ClientConfigType } from '../../../../../common/types';
+
import { generateEncodedPath } from '../../../shared/encode_path_params';
import { ErrorStatePrompt } from '../../../shared/error_state';
import { HttpLogic } from '../../../shared/http';
import { KibanaLogic } from '../../../shared/kibana';
import { SEARCH_INDEX_PATH, SEARCH_INDEX_TAB_PATH } from '../../routes';
+import { ElasticsearchViewIndex } from '../../types';
import { isConnectorIndex, isCrawlerIndex } from '../../utils/indices';
import { ConnectorConfiguration } from '../connector_detail/connector_configuration';
import { EnterpriseSearchContentPageTemplate } from '../layout/page_template';
@@ -223,20 +226,6 @@ export const SearchIndex: React.FC = () => {
...(hasDefaultIngestPipeline ? [PIPELINES_TAB] : []),
];
- const selectedTab = tabs.find((tab) => tab.id === tabId);
-
- const onTabClick = (tab: EuiTabbedContentTab) => {
- KibanaLogic.values.navigateToUrl(
- generateEncodedPath(
- tab.id === SearchIndexTabId.OVERVIEW ? SEARCH_INDEX_PATH : SEARCH_INDEX_TAB_PATH,
- {
- indexName,
- tabId: tab.id,
- }
- )
- );
- };
-
return (
{
rightSideItems: getHeaderActions(index),
}}
>
- {isCrawlerIndex(index) && !index.connector ? (
-
- ) : isCrawlerIndex(index) && (Boolean(errorConnectingMessage) || !config.host) ? (
-
- ) : (
- <>
- {indexName === index?.name && (
-
- )}
- {isCrawlerIndex(index) && }
- >
- )}
+
);
};
+
+interface ContentProps {
+ config?: ClientConfigType;
+ errorConnectingMessage: string;
+ index?: ElasticsearchViewIndex;
+ tabId?: string;
+ tabs: EuiTabbedContentTab[];
+}
+
+const Content: React.FC = ({
+ config,
+ errorConnectingMessage,
+ index,
+ tabs,
+ tabId,
+}) => {
+ const selectedTab = useMemo(() => tabs.find((tab) => tab.id === tabId), [tabId]);
+
+ const onTabClick = (tab: EuiTabbedContentTab) => {
+ KibanaLogic.values.navigateToUrl(
+ generateEncodedPath(
+ tab.id === SearchIndexTabId.OVERVIEW ? SEARCH_INDEX_PATH : SEARCH_INDEX_TAB_PATH,
+ {
+ indexName: index?.name || '',
+ tabId: tab.id,
+ }
+ )
+ );
+ };
+
+ if (isCrawlerIndex(index) && !index.connector) {
+ return ;
+ }
+ if (isCrawlerIndex(index) && (Boolean(errorConnectingMessage) || !config?.host)) {
+ return ;
+ }
+ return (
+ <>
+
+ {isCrawlerIndex(index) && }
+ >
+ );
+};