Skip to content

Commit

Permalink
[Search] Fix web crawler enabled without enterprise search (elastic#1…
Browse files Browse the repository at this point in the history
…74453)

## Summary

This fixes the web crawler being accessible in Search without a running
Enterprise Search node.
  • Loading branch information
sphilipse authored Jan 8, 2024
1 parent c3801ce commit 0109320
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ 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 {
Expand All @@ -35,6 +36,8 @@ import {
import { EnterpriseSearchContentPageTemplate } from '../layout';
import { SelectConnector } from '../new_index/select_connector/select_connector';

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

import { ConnectorStats } from './connector_stats';
import { ConnectorsLogic } from './connectors_logic';
import { ConnectorsTable } from './connectors_table';
Expand All @@ -52,6 +55,7 @@ export interface ConnectorsProps {
export const Connectors: React.FC<ConnectorsProps> = ({ isCrawler }) => {
const { fetchConnectors, onPaginate, setIsFirstRequest } = useActions(ConnectorsLogic);
const { data, isLoading, searchParams, isEmpty, connectors } = useValues(ConnectorsLogic);
const { errorConnectingMessage } = useValues(HttpLogic);
const [searchQuery, setSearchValue] = useState('');

useEffect(() => {
Expand Down Expand Up @@ -122,6 +126,7 @@ export const Connectors: React.FC<ConnectorsProps> = ({ isCrawler }) => {
]
: [
<EuiButton
disabled={Boolean(errorConnectingMessage)}
key="newCrawler"
color="primary"
iconType="plusInCircle"
Expand All @@ -141,6 +146,12 @@ export const Connectors: React.FC<ConnectorsProps> = ({ isCrawler }) => {
],
}}
>
{Boolean(errorConnectingMessage) && (
<>
<CannotConnect />
<EuiSpacer />
</>
)}
<ConnectorStats isCrawler={isCrawler} />
<EuiSpacer />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
*/
import React from 'react';

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';

export const CrawlerEmptyState: React.FC = () => {
const { errorConnectingMessage } = useValues(HttpLogic);
return (
<EuiPanel hasBorder>
<EuiEmptyPrompt
Expand All @@ -39,6 +43,7 @@ export const CrawlerEmptyState: React.FC = () => {
actions={
<EuiButton
color="primary"
disabled={Boolean(errorConnectingMessage)}
fill
iconType="plusInCircle"
onClick={() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';

import { Status } from '../../../../../../common/types/api';
import { docLinks } from '../../../../shared/doc_links';
import { HttpLogic } from '../../../../shared/http';
import { KibanaLogic } from '../../../../shared/kibana';
import { LicensingLogic } from '../../../../shared/licensing';
import {
LicensingCallout,
LICENSING_FEATURE,
} from '../../../../shared/licensing_callout/licensing_callout';
import { CreateCrawlerIndexApiLogic } from '../../../api/crawler/create_crawler_index_api_logic';
import { CannotConnect } from '../../search_index/components/cannot_connect';
import { NewSearchIndexTemplate } from '../new_search_index_template';

import { MethodCrawlerLogic } from './method_crawler_logic';
Expand All @@ -29,6 +31,7 @@ export const MethodCrawler: React.FC = () => {
const { makeRequest } = useActions(CreateCrawlerIndexApiLogic);
const { isCloud } = useValues(KibanaLogic);
const { hasPlatinumLicense } = useValues(LicensingLogic);
const { errorConnectingMessage } = useValues(HttpLogic);

const isGated = !isCloud && !hasPlatinumLicense;

Expand All @@ -41,11 +44,16 @@ export const MethodCrawler: React.FC = () => {
<LicensingCallout feature={LICENSING_FEATURE.CRAWLER} />
</EuiFlexItem>
)}
{Boolean(errorConnectingMessage) && (
<EuiFlexItem>
<CannotConnect />
</EuiFlexItem>
)}
<EuiFlexItem>
<NewSearchIndexTemplate
type="crawler"
onSubmit={(indexName, language) => makeRequest({ indexName, language })}
disabled={isGated}
disabled={isGated || Boolean(errorConnectingMessage)}
buttonLoading={status === Status.LOADING}
docsUrl={docLinks.crawlerOverview}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ export const NewSearchIndexPage: React.FC = () => {
<EuiIcon type={getIngestionMethodIconType(type)} size="xxl" />
</EuiFlexItem>
<EuiFlexItem grow={false}>{getTitle(type, serviceType)}</EuiFlexItem>
<EuiFlexItem grow={false}>{getConnectorModeBadge(isNative)}</EuiFlexItem>
{type === INGESTION_METHOD_IDS.CONNECTOR && (
<EuiFlexItem grow={false}>{getConnectorModeBadge(isNative)}</EuiFlexItem>
)}
</EuiFlexGroup>
),
}}
Expand Down

0 comments on commit 0109320

Please sign in to comment.