[Search] Disable crawler on overview without ent-search (#164227)

## Summary

This disables the crawler if Enterprise Search is not available on the
new overview page.
This commit is contained in:
Sander Philipse 2023-08-21 10:37:59 +02:00 committed by GitHub
parent f1402d682c
commit 8532b996c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,6 +9,8 @@ import React from 'react';
import { generatePath } from 'react-router-dom'; import { generatePath } from 'react-router-dom';
import { useValues } from 'kea';
import { EuiButton, EuiCard, EuiFlexGroup, EuiFlexItem, EuiIcon } from '@elastic/eui'; import { EuiButton, EuiCard, EuiFlexGroup, EuiFlexItem, EuiIcon } from '@elastic/eui';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
@ -27,13 +29,18 @@ import {
NEW_INDEX_METHOD_PATH, NEW_INDEX_METHOD_PATH,
NEW_INDEX_SELECT_CONNECTOR_PATH, NEW_INDEX_SELECT_CONNECTOR_PATH,
} from '../../../enterprise_search_content/routes'; } from '../../../enterprise_search_content/routes';
import { EuiLinkTo } from '../../../shared/react_router_helpers'; import { HttpLogic } from '../../../shared/http/http_logic';
import { KibanaLogic } from '../../../shared/kibana';
import { EuiButtonTo, EuiLinkTo } from '../../../shared/react_router_helpers';
const START_LABEL = i18n.translate('xpack.enterpriseSearch.ingestSelector.startButton', { const START_LABEL = i18n.translate('xpack.enterpriseSearch.ingestSelector.startButton', {
defaultMessage: 'Start', defaultMessage: 'Start',
}); });
export const IngestionSelector: React.FC = () => { export const IngestionSelector: React.FC = () => {
const { config, productFeatures } = useValues(KibanaLogic);
const { errorConnectingMessage } = useValues(HttpLogic);
const crawlerDisabled = Boolean(errorConnectingMessage || !config.host);
return ( return (
<EuiFlexGroup> <EuiFlexGroup>
<EuiFlexItem> <EuiFlexItem>
@ -61,60 +68,67 @@ export const IngestionSelector: React.FC = () => {
} }
/> />
</EuiFlexItem> </EuiFlexItem>
<EuiFlexItem> {productFeatures.hasConnectors && (
<EuiCard <EuiFlexItem>
hasBorder <EuiCard
icon={<EuiIcon type={connectorLogo} size="xxl" />} hasBorder
textAlign="left" icon={<EuiIcon type={connectorLogo} size="xxl" />}
title={i18n.translate('xpack.enterpriseSearch.ingestSelector.method.connectors', { textAlign="left"
defaultMessage: 'Connectors', title={i18n.translate('xpack.enterpriseSearch.ingestSelector.method.connectors', {
})} defaultMessage: 'Connectors',
description={i18n.translate( })}
'xpack.enterpriseSearch.ingestSelector.method.connectors.description', description={i18n.translate(
{ 'xpack.enterpriseSearch.ingestSelector.method.connectors.description',
defaultMessage: {
'Extract, transform, index and sync data from a third-party data source.', defaultMessage:
'Extract, transform, index and sync data from a third-party data source.',
}
)}
footer={
<EuiLinkTo
to={generatePath(
ENTERPRISE_SEARCH_CONTENT_PLUGIN.URL + NEW_INDEX_SELECT_CONNECTOR_PATH
)}
shouldNotCreateHref
>
<EuiButton fullWidth>{START_LABEL}</EuiButton>
</EuiLinkTo>
} }
)} />
footer={ </EuiFlexItem>
<EuiLinkTo )}
to={generatePath( {productFeatures.hasWebCrawler && (
ENTERPRISE_SEARCH_CONTENT_PLUGIN.URL + NEW_INDEX_SELECT_CONNECTOR_PATH <EuiFlexItem>
)} <EuiCard
shouldNotCreateHref hasBorder
> isDisabled={crawlerDisabled}
<EuiButton fullWidth>{START_LABEL}</EuiButton> icon={<EuiIcon type={crawlerLogo} size="xxl" />}
</EuiLinkTo> textAlign="left"
} title={i18n.translate('xpack.enterpriseSearch.ingestSelector.method.crawler', {
/> defaultMessage: 'Web Crawler',
</EuiFlexItem> })}
<EuiFlexItem> description={i18n.translate(
<EuiCard 'xpack.enterpriseSearch.ingestSelector.method.crawler.description',
hasBorder {
icon={<EuiIcon type={crawlerLogo} size="xxl" />} defaultMessage:
textAlign="left" 'Discover, extract, and index searchable content from websites and knowledge bases.',
title={i18n.translate('xpack.enterpriseSearch.ingestSelector.method.crawler', { }
defaultMessage: 'Web Crawler', )}
})} footer={
description={i18n.translate( <EuiButtonTo
'xpack.enterpriseSearch.ingestSelector.method.crawler.description', fullWidth
{ isDisabled={crawlerDisabled}
defaultMessage: to={generatePath(ENTERPRISE_SEARCH_CONTENT_PLUGIN.URL + NEW_INDEX_METHOD_PATH, {
'Discover, extract, and index searchable content from websites and knowledge bases.', type: INGESTION_METHOD_IDS.CRAWLER,
})}
shouldNotCreateHref
>
{START_LABEL}
</EuiButtonTo>
} }
)} />
footer={ </EuiFlexItem>
<EuiLinkTo )}
to={generatePath(ENTERPRISE_SEARCH_CONTENT_PLUGIN.URL + NEW_INDEX_METHOD_PATH, {
type: INGESTION_METHOD_IDS.CRAWLER,
})}
shouldNotCreateHref
>
<EuiButton fullWidth>{START_LABEL}</EuiButton>
</EuiLinkTo>
}
/>
</EuiFlexItem>
</EuiFlexGroup> </EuiFlexGroup>
); );
}; };