Skip to content

Commit

Permalink
Show process crawls together with crawl requests (elastic#111398) (el…
Browse files Browse the repository at this point in the history
…astic#112069)

Co-authored-by: Orhan Toy <[email protected]>
  • Loading branch information
kibanamachine and orhantoy authored Sep 14, 2021
1 parent 376b92c commit 60c30c4
Show file tree
Hide file tree
Showing 15 changed files with 298 additions and 231 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ describe('AddDomainLogic', () => {
http.post.mockReturnValueOnce(
Promise.resolve({
domains: [],
events: [],
most_recent_crawl_request: null,
})
);

Expand All @@ -312,6 +314,8 @@ describe('AddDomainLogic', () => {

expect(CrawlerLogic.actions.onReceiveCrawlerData).toHaveBeenCalledWith({
domains: [],
events: [],
mostRecentCrawlRequest: null,
});
});

Expand All @@ -328,6 +332,8 @@ describe('AddDomainLogic', () => {
name: 'https://swiftype.co/site-search',
},
],
events: [],
most_recent_crawl_request: null,
})
);
jest.spyOn(AddDomainLogic.actions, 'onSubmitNewDomainSuccess');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ import { EuiBasicTable, EuiEmptyPrompt } from '@elastic/eui';

import { mountWithIntl } from '../../../../test_helpers';

import { CrawlerStatus, CrawlRequest } from '../types';
import { CrawlEvent, CrawlerStatus } from '../types';

import { CrawlRequestsTable } from './crawl_requests_table';

const values: { crawlRequests: CrawlRequest[] } = {
const values: { events: CrawlEvent[] } = {
// CrawlerLogic
crawlRequests: [
events: [
{
id: '618d0e66abe97bc688328900',
status: CrawlerStatus.Pending,
stage: 'crawl',
createdAt: 'Mon, 31 Aug 2020 17:00:00 +0000',
beganAt: null,
completedAt: null,
Expand Down Expand Up @@ -69,7 +70,7 @@ describe('CrawlRequestsTable', () => {
it('displays an empty prompt when there are no crawl requests', () => {
setMockValues({
...values,
crawlRequests: [],
events: [],
});

wrapper = shallow(<CrawlRequestsTable />);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,21 @@ import React from 'react';

import { useValues } from 'kea';

import { EuiBasicTable, EuiEmptyPrompt, EuiTableFieldDataColumnType } from '@elastic/eui';
import {
EuiBasicTable,
EuiEmptyPrompt,
EuiIconTip,
EuiTableFieldDataColumnType,
} from '@elastic/eui';

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

import { CrawlerLogic } from '../crawler_logic';
import { CrawlRequest, readableCrawlerStatuses } from '../types';
import { CrawlEvent, readableCrawlerStatuses } from '../types';

import { CustomFormattedTimestamp } from './custom_formatted_timestamp';

const columns: Array<EuiTableFieldDataColumnType<CrawlRequest>> = [
const columns: Array<EuiTableFieldDataColumnType<CrawlEvent>> = [
{
field: 'id',
name: i18n.translate(
Expand All @@ -36,7 +41,7 @@ const columns: Array<EuiTableFieldDataColumnType<CrawlRequest>> = [
defaultMessage: 'Created',
}
),
render: (createdAt: CrawlRequest['createdAt']) => (
render: (createdAt: CrawlEvent['createdAt']) => (
<CustomFormattedTimestamp timestamp={createdAt} />
),
},
Expand All @@ -48,17 +53,32 @@ const columns: Array<EuiTableFieldDataColumnType<CrawlRequest>> = [
defaultMessage: 'Status',
}
),
render: (status: CrawlRequest['status']) => readableCrawlerStatuses[status],
align: 'right',
render: (status: CrawlEvent['status'], event: CrawlEvent) => (
<>
{event.stage === 'process' && (
<EuiIconTip
aria-label="Process crawl"
size="m"
type="iInCircle"
color="primary"
position="top"
content="Re-applied crawl rules"
/>
)}
{readableCrawlerStatuses[status]}
</>
),
},
];

export const CrawlRequestsTable: React.FC = () => {
const { crawlRequests } = useValues(CrawlerLogic);
const { events } = useValues(CrawlerLogic);

return (
<EuiBasicTable
columns={columns}
items={crawlRequests}
items={events}
noItemsMessage={
<EuiEmptyPrompt
iconType="tableDensityExpanded"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { i18n } from '@kbn/i18n';
import { flashAPIErrors, flashSuccessToast } from '../../../../../shared/flash_messages';
import { HttpLogic } from '../../../../../shared/http';
import { EngineLogic } from '../../../engine';
import { CrawlerLogic } from '../../crawler_logic';
import { CrawlerDomain } from '../../types';

export interface ManageCrawlsPopoverLogicValues {
Expand Down Expand Up @@ -65,6 +66,8 @@ export const ManageCrawlsPopoverLogic = kea<
}
)
);

CrawlerLogic.actions.fetchCrawlerData();
} catch (e) {
flashAPIErrors(e);
} finally {
Expand Down
Loading

0 comments on commit 60c30c4

Please sign in to comment.