Skip to content

Commit

Permalink
[Enterprise Search] Dedicated crawlers page (#172479)
Browse files Browse the repository at this point in the history
## Summary

Create a new Dedicated Crawlers page route.
<img width="2560" alt="Screenshot 2023-12-04 at 16 00 18"
src="https://github.com/elastic/kibana/assets/1410658/e31fd36d-f020-4c00-a154-7e4fc7f80b2b">


### Checklist

Delete any items that are not applicable to this PR.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)


### Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to
identify risks that should be tested prior to the change/feature
release.

When forming the risk matrix, consider some of the following examples
and how they may potentially impact the change:

| Risk | Probability | Severity | Mitigation/Notes |

|---------------------------|-------------|----------|-------------------------|
| Multiple Spaces&mdash;unexpected behavior in non-default Kibana Space.
| Low | High | Integration tests will verify that all features are still
supported in non-default Kibana Space and when user switches between
spaces. |
| Multiple nodes&mdash;Elasticsearch polling might have race conditions
when multiple Kibana nodes are polling for the same tasks. | High | Low
| Tasks are idempotent, so executing them multiple times will not result
in logical error, but will degrade performance. To test for this case we
add plenty of unit tests around this logic and document manual testing
procedure. |
| Code should gracefully handle cases when feature X or plugin Y are
disabled. | Medium | High | Unit tests will verify that any feature flag
or plugin combination still results in our service operational. |
| [See more potential risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <[email protected]>
  • Loading branch information
efegurkan and kibanamachine authored Dec 5, 2023
1 parent 426d8ac commit 703e990
Show file tree
Hide file tree
Showing 15 changed files with 912 additions and 319 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ import { HttpLogic } from '../../../shared/http';

export type FetchSyncJobsStatsResponse = SyncJobsStats;

export const fetchSyncJobsStats = async () => {
export interface FetchSyncJobsStatsApiLogicArgs {
isCrawler?: boolean;
}

export const fetchSyncJobsStats = async ({ isCrawler }: FetchSyncJobsStatsApiLogicArgs) => {
const route = '/internal/enterprise_search/stats/sync_jobs';
return await HttpLogic.values.http.get<FetchSyncJobsStatsResponse>(route);
const options = isCrawler !== undefined ? { query: { isCrawler } } : undefined;
return await HttpLogic.values.http.get<FetchSyncJobsStatsResponse>(route, options);
};

export const FetchSyncJobsStatsApiLogic = createApiLogic(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ import { i18n } from '@kbn/i18n';

import { FetchSyncJobsStatsApiLogic } from '../../api/stats/fetch_sync_jobs_stats_api_logic';

export const ConnectorStats: React.FC = () => {
export interface ConnectorStatsProps {
isCrawler: boolean;
}

export const ConnectorStats: React.FC<ConnectorStatsProps> = ({ isCrawler }) => {
const { makeRequest } = useActions(FetchSyncJobsStatsApiLogic);
const { data } = useValues(FetchSyncJobsStatsApiLogic);

useEffect(() => {
makeRequest({});
makeRequest({ isCrawler });
}, []);

return (
Expand All @@ -39,21 +43,33 @@ export const ConnectorStats: React.FC = () => {
<EuiFlexItem>
<EuiTitle size="xxxs">
<h4>
{i18n.translate(
'xpack.enterpriseSearch.connectorStats.h4.connectorSummaryLabel',
{ defaultMessage: 'Connector summary' }
)}
{!isCrawler
? i18n.translate(
'xpack.enterpriseSearch.connectorStats.h4.connectorSummaryLabel',
{ defaultMessage: 'Connector summary' }
)
: i18n.translate(
'xpack.enterpriseSearch.connectorStats.h4.crawlerSummaryLabel',
{ defaultMessage: 'Web crawler summary' }
)}
</h4>
</EuiTitle>
</EuiFlexItem>
<EuiFlexItem>
<EuiText>
{i18n.translate('xpack.enterpriseSearch.connectorStats.connectorsTextLabel', {
defaultMessage: '{count} connectors',
values: {
count: (data?.connected || 0) + (data?.incomplete || 0),
},
})}
{!isCrawler
? i18n.translate('xpack.enterpriseSearch.connectorStats.connectorsTextLabel', {
defaultMessage: '{count} connectors',
values: {
count: (data?.connected || 0) + (data?.incomplete || 0),
},
})
: i18n.translate('xpack.enterpriseSearch.connectorStats.crawlersTextLabel', {
defaultMessage: '{count} web crawlers',
values: {
count: (data?.connected || 0) + (data?.incomplete || 0),
},
})}
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import React from 'react';

import { EuiFlexGroup, EuiFlexItem, EuiIcon, EuiText } from '@elastic/eui';

import { i18n } from '@kbn/i18n';

import { CRAWLER_SERVICE_TYPE } from '@kbn/search-connectors';

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

export interface ConnectorTypeProps {
Expand All @@ -26,7 +30,13 @@ export const ConnectorType: React.FC<ConnectorTypeProps> = ({ serviceType }) =>
)}
<EuiFlexItem>
<EuiText size="s">
<p>{connector?.name ?? '-'}</p>
<p>
{serviceType === CRAWLER_SERVICE_TYPE
? i18n.translate('xpack.enterpriseSearch.content.connectors.connectorType.crawler', {
defaultMessage: 'Web crawler',
})
: connector?.name ?? '-'}
</p>
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ 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 { KibanaLogic } from '../../../shared/kibana';
import { handlePageChange } from '../../../shared/table_pagination';
import {
NEW_INDEX_METHOD_PATH,
NEW_INDEX_SELECT_CONNECTOR_CLIENTS_PATH,
NEW_INDEX_SELECT_CONNECTOR_NATIVE_PATH,
NEW_INDEX_SELECT_CONNECTOR_PATH,
Expand All @@ -34,105 +38,160 @@ import { SelectConnector } from '../new_index/select_connector/select_connector'
import { ConnectorStats } from './connector_stats';
import { ConnectorsLogic } from './connectors_logic';
import { ConnectorsTable } from './connectors_table';
import { CrawlerEmptyState } from './crawler_empty_state';

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

export interface ConnectorsProps {
isCrawler: boolean;
}
export const Connectors: React.FC<ConnectorsProps> = ({ isCrawler }) => {
const { fetchConnectors, onPaginate, setIsFirstRequest } = useActions(ConnectorsLogic);
const { data, isLoading, searchParams, isEmpty, connectors } = useValues(ConnectorsLogic);
const [searchQuery, setSearchValue] = useState('');

useEffect(() => {
setIsFirstRequest();
}, []);
}, [isCrawler]);

useEffect(() => {
fetchConnectors({ ...searchParams, searchQuery });
}, [searchParams.from, searchParams.size, searchQuery]);
fetchConnectors({ ...searchParams, searchQuery, fetchCrawlersOnly: isCrawler });
}, [searchParams.from, searchParams.size, searchQuery, isCrawler]);

return (
<>
{!isLoading && isEmpty ? (
<SelectConnector />
) : (
<EnterpriseSearchContentPageTemplate
pageChrome={baseBreadcrumbs}
pageViewTelemetry="Connectors"
isLoading={isLoading}
pageHeader={{
pageTitle: i18n.translate('xpack.enterpriseSearch.connectors.title', {
return !isLoading && isEmpty && !isCrawler ? (
<SelectConnector />
) : (
<EnterpriseSearchContentPageTemplate
pageChrome={baseBreadcrumbs}
pageViewTelemetry={!isCrawler ? 'Connectors' : 'Web Crawlers'}
isLoading={isLoading}
pageHeader={{
pageTitle: !isCrawler
? i18n.translate('xpack.enterpriseSearch.connectors.title', {
defaultMessage: 'Elasticsearch connectors',
})
: i18n.translate('xpack.enterpriseSearch.crawlers.title', {
defaultMessage: 'Elasticsearch web crawlers',
}),
rightSideGroupProps: {
gutterSize: 's',
},
rightSideItems: isLoading
? []
: [
<EuiButton
key="newConnector"
color="primary"
iconType="plusInCircle"
fill
onClick={() => {
KibanaLogic.values.navigateToUrl(NEW_INDEX_SELECT_CONNECTOR_PATH);
}}
>
<FormattedMessage
id="xpack.enterpriseSearch.connectors.newConnectorButtonLabel"
defaultMessage="New Connector"
/>
</EuiButton>,
<EuiButton
key="newConnectorNative"
onClick={() => {
KibanaLogic.values.navigateToUrl(NEW_INDEX_SELECT_CONNECTOR_NATIVE_PATH);
}}
>
{i18n.translate(
'xpack.enterpriseSearch.connectors.newNativeConnectorButtonLabel',
{ defaultMessage: 'New Native Connector' }
)}
</EuiButton>,
<EuiButton
key="newConnectorClient"
onClick={() => {
KibanaLogic.values.navigateToUrl(NEW_INDEX_SELECT_CONNECTOR_CLIENTS_PATH);
}}
>
{i18n.translate(
'xpack.enterpriseSearch.connectors.newConnectorsClientButtonLabel',
{ defaultMessage: 'New Connectors Client' }
)}
</EuiButton>,
],
}}
>
<ConnectorStats />
<EuiSpacer />
rightSideGroupProps: {
gutterSize: 's',
},
rightSideItems: isLoading
? []
: !isCrawler
? [
<EuiButton
key="newConnector"
color="primary"
iconType="plusInCircle"
fill
onClick={() => {
KibanaLogic.values.navigateToUrl(NEW_INDEX_SELECT_CONNECTOR_PATH);
}}
>
<FormattedMessage
id="xpack.enterpriseSearch.connectors.newConnectorButtonLabel"
defaultMessage="New Connector"
/>
</EuiButton>,
<EuiButton
key="newConnectorNative"
onClick={() => {
KibanaLogic.values.navigateToUrl(NEW_INDEX_SELECT_CONNECTOR_NATIVE_PATH);
}}
>
{i18n.translate('xpack.enterpriseSearch.connectors.newNativeConnectorButtonLabel', {
defaultMessage: 'New Native Connector',
})}
</EuiButton>,
<EuiButton
key="newConnectorClient"
onClick={() => {
KibanaLogic.values.navigateToUrl(NEW_INDEX_SELECT_CONNECTOR_CLIENTS_PATH);
}}
>
{i18n.translate(
'xpack.enterpriseSearch.connectors.newConnectorsClientButtonLabel',
{ defaultMessage: 'New Connectors Client' }
)}
</EuiButton>,
]
: [
<EuiButton
key="newCrawler"
color="primary"
iconType="plusInCircle"
fill
onClick={() => {
KibanaLogic.values.navigateToUrl(
generateEncodedPath(NEW_INDEX_METHOD_PATH, {
type: INGESTION_METHOD_IDS.CRAWLER,
})
);
}}
>
{i18n.translate('xpack.enterpriseSearch.connectors.newCrawlerButtonLabel', {
defaultMessage: 'New web crawler',
})}
</EuiButton>,
],
}}
>
<ConnectorStats isCrawler={isCrawler} />
<EuiSpacer />

<EuiFlexGroup direction="column">
<EuiFlexGroup direction="column">
{isEmpty && isCrawler ? (
<CrawlerEmptyState />
) : (
<>
<EuiFlexItem>
<EuiTitle>
<h2>
<FormattedMessage
id="xpack.enterpriseSearch.connectorsTable.h2.availableConnectorsLabel"
defaultMessage="Available Connectors"
/>
{!isCrawler ? (
<FormattedMessage
id="xpack.enterpriseSearch.connectorsTable.h2.availableConnectorsLabel"
defaultMessage="Available connectors"
/>
) : (
<FormattedMessage
id="xpack.enterpriseSearch.connectorsTable.h2.availableCrawlersLabel"
defaultMessage="Available web crawlers"
/>
)}
</h2>
</EuiTitle>
</EuiFlexItem>
<EuiFlexItem>
<EuiSearchBar
query={searchQuery}
box={{ incremental: true, placeholder: 'Filter Connectors' }}
aria-label={i18n.translate(
'xpack.enterpriseSearch.connectorsTable.euiSearchBar.filterConnectorsLabel',
{ defaultMessage: 'Filter Connectors' }
)}
box={{
incremental: true,
placeholder: !isCrawler
? i18n.translate(
'xpack.enterpriseSearch.connectorsTable.euiSearchBar.filterConnectorsPlaceholder',
{ defaultMessage: 'Filter connectors' }
)
: i18n.translate(
'xpack.enterpriseSearch.connectorsTable.euiSearchBar.filterCrawlersPlaceholder',
{ defaultMessage: 'Filter web crawlers' }
),
}}
aria-label={
!isCrawler
? i18n.translate(
'xpack.enterpriseSearch.connectorsTable.euiSearchBar.filterConnectorsLabel',
{ defaultMessage: 'Filter connectors' }
)
: i18n.translate(
'xpack.enterpriseSearch.connectorsTable.euiSearchBar.filterCrawlersLabel',
{ defaultMessage: 'Filter web crawlers' }
)
}
onChange={(event) => setSearchValue(event.queryText)}
/>
</EuiFlexItem>
Expand All @@ -141,9 +200,9 @@ export const Connectors: React.FC = () => {
meta={data?.meta}
onChange={handlePageChange(onPaginate)}
/>
</EuiFlexGroup>
</EnterpriseSearchContentPageTemplate>
)}
</>
</>
)}
</EuiFlexGroup>
</EnterpriseSearchContentPageTemplate>
);
};
Loading

0 comments on commit 703e990

Please sign in to comment.