Skip to content

Commit

Permalink
[Enterprise Search] Fix support for cron scheduling for Elastic Crawl…
Browse files Browse the repository at this point in the history
…er Indices (#146357)
  • Loading branch information
byronhulcher authored Nov 28, 2022
1 parent 5f34263 commit 5b79dbe
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 287 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {

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

import { CrawlerIndex } from '../../../../../../../common/types/indices';
import {
HOURS_UNIT_LABEL,
DAYS_UNIT_LABEL,
Expand All @@ -36,23 +35,21 @@ import {
} from '../../../../../shared/constants';
import { EnterpriseSearchCronEditor } from '../../../../../shared/cron_editor/enterprise_search_cron_editor';
import { docLinks } from '../../../../../shared/doc_links/doc_links';
import { UpdateConnectorSchedulingApiLogic } from '../../../../api/connector/update_connector_scheduling_api_logic';
import { CrawlUnits } from '../../../../api/crawler/types';
import { isCrawlerIndex } from '../../../../utils/indices';
import { IndexViewLogic } from '../../index_view_logic';

import { AutomaticCrawlSchedulerLogic } from './automatic_crawl_scheduler_logic';

export const AutomaticCrawlScheduler: React.FC = () => {
const { index } = useValues(IndexViewLogic);
const { makeRequest } = useActions(UpdateConnectorSchedulingApiLogic);
const {
setCrawlAutomatically,
setCrawlFrequency,
setCrawlUnit,
setUseConnectorSchedule,
submitConnectorSchedule,
} = useActions(AutomaticCrawlSchedulerLogic);

const scheduling = (index as CrawlerIndex)?.connector?.scheduling;

const { setCrawlFrequency, setCrawlUnit, setUseConnectorSchedule, toggleCrawlAutomatically } =
useActions(AutomaticCrawlSchedulerLogic);

const { crawlAutomatically, crawlFrequency, crawlUnit, useConnectorSchedule } = useValues(
const { index, crawlAutomatically, crawlFrequency, crawlUnit, useConnectorSchedule } = useValues(
AutomaticCrawlSchedulerLogic
);

Expand Down Expand Up @@ -84,7 +81,7 @@ export const AutomaticCrawlScheduler: React.FC = () => {
defaultMessage: 'Enable recurring crawls with the following schedule',
}
)}
onChange={toggleCrawlAutomatically}
onChange={(e) => setCrawlAutomatically(e.target.checked)}
compressed
/>
</EuiFormRow>
Expand Down Expand Up @@ -124,11 +121,11 @@ export const AutomaticCrawlScheduler: React.FC = () => {
>
<EnterpriseSearchCronEditor
disabled={!crawlAutomatically || !useConnectorSchedule}
scheduling={scheduling}
scheduling={index.connector.scheduling}
onChange={(newScheduling) =>
makeRequest({
connectorId: index.connector.id,
scheduling: { ...newScheduling },
submitConnectorSchedule({
...newScheduling,
enabled: true,
})
}
/>
Expand Down

This file was deleted.

Loading

0 comments on commit 5b79dbe

Please sign in to comment.