Skip to content

Commit

Permalink
[Enterprise Search] Fix scheduling callout and restrict width (#137255)
Browse files Browse the repository at this point in the history
  • Loading branch information
sphilipse authored Jul 27, 2022
1 parent c1f21d4 commit 37d5dd6
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ export const EnterpriseSearchContentPageTemplate: React.FC<PageTemplateProps> =
<EnterpriseSearchPageTemplateWrapper
{...pageTemplateProps}
solutionNav={{
name: ENTERPRISE_SEARCH_CONTENT_PLUGIN.NAME,
items: useEnterpriseSearchNav(),
name: ENTERPRISE_SEARCH_CONTENT_PLUGIN.NAME,
}}
restrictWidth
setPageChrome={pageChrome && <SetEnterpriseSearchChrome trail={pageChrome} />}
>
{pageViewTelemetry && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import React, { useState } from 'react';

import { generatePath } from 'react-router-dom';

import { useActions, useValues } from 'kea';

import {
Expand All @@ -27,14 +29,18 @@ import { i18n } from '@kbn/i18n';
import { Status } from '../../../../../../common/types/api';
import { ConnectorStatus } from '../../../../../../common/types/connectors';
import { ConnectorIndex } from '../../../../../../common/types/indices';
import { EuiButtonTo } from '../../../../shared/react_router_helpers';
import { UnsavedChangesPrompt } from '../../../../shared/unsaved_changes_prompt';
import { UpdateConnectorSchedulingApiLogic } from '../../../api/connector_package/update_connector_scheduling_api_logic';

import { SEARCH_INDEX_TAB_PATH } from '../../../routes';
import { IngestionStatus } from '../../../types';
import { isConnectorIndex } from '../../../utils/indices';

import { IndexViewLogic } from '../index_view_logic';

import { SearchIndexTabId } from '../search_index';

import { ConnectorSchedulingLogic } from './connector_scheduling_logic';

export const ConnectorSchedulingComponent: React.FC = () => {
Expand All @@ -60,41 +66,52 @@ export const ConnectorSchedulingComponent: React.FC = () => {
return <></>;
}

if (index.connector.status === ConnectorStatus.CREATED) {
if (
index.connector.status === ConnectorStatus.CREATED ||
index.connector.status === ConnectorStatus.NEEDS_CONFIGURATION
) {
return (
<EuiText size="s">
{i18n.translate(
'xpack.enterpriseSearch.content.indices.connectorScheduling.notConnected.title',
{
defaultMessage:
'Configure and deploy your connector, then return here to set your sync schedule. This schedule will dictate the interval that the connector will sync with your data source for updated documents.',
}
)}
</EuiText>
<>
<EuiSpacer />
<EuiCallOut
iconType="iInCircle"
title={i18n.translate(
'xpack.enterpriseSearch.content.indices.connectorScheduling.notConnected.title',
{
defaultMessage: 'Configure your connector to schedule a sync',
}
)}
>
<EuiText size="s">
{i18n.translate(
'xpack.enterpriseSearch.content.indices.connectorScheduling.notConnected.description',
{
defaultMessage:
'Configure and deploy your connector, then return here to set your sync schedule. This schedule will dictate the interval that the connector will sync with your data source for updated documents.',
}
)}
</EuiText>
<EuiSpacer size="s" />
<EuiButtonTo
to={generatePath(SEARCH_INDEX_TAB_PATH, {
indexName: index.connector.name,
tabId: SearchIndexTabId.CONFIGURATION,
})}
fill
size="s"
>
{i18n.translate(
'xpack.enterpriseSearch.content.indices.connectorScheduling.notConnected.button.label',
{
defaultMessage: 'Configure',
}
)}
</EuiButtonTo>
</EuiCallOut>
</>
);
}

const editor = (
<CronEditor
fieldToPreferredValueMap={fieldToPreferredValueMap}
cronExpression={simpleCron.expression}
frequency={simpleCron.frequency}
onChange={({
cronExpression: expression,
frequency,
fieldToPreferredValueMap: newFieldToPreferredValueMap,
}) => {
setSimpleCron({
expression,
frequency,
});
setFieldToPreferredValueMap(newFieldToPreferredValueMap);
setScheduling({ ...scheduling, interval: expression });
setHasChanges(true);
}}
/>
);

return (
<>
<UnsavedChangesPrompt
Expand All @@ -105,7 +122,7 @@ export const ConnectorSchedulingComponent: React.FC = () => {
)}
/>
<EuiSpacer />
<EuiPanel hasShadow={false} hasBorder>
<EuiPanel hasShadow={false} hasBorder className="schedulingPanel">
<EuiFlexGroup direction="column">
{ingestionStatus === IngestionStatus.ERROR ? (
<EuiCallOut
Expand Down Expand Up @@ -143,7 +160,26 @@ export const ConnectorSchedulingComponent: React.FC = () => {
)}
</EuiText>
</EuiFlexItem>
<EuiFlexItem>{editor}</EuiFlexItem>
<EuiFlexItem>
<CronEditor
fieldToPreferredValueMap={fieldToPreferredValueMap}
cronExpression={simpleCron.expression}
frequency={simpleCron.frequency}
onChange={({
cronExpression: expression,
frequency,
fieldToPreferredValueMap: newFieldToPreferredValueMap,
}) => {
setSimpleCron({
expression,
frequency,
});
setFieldToPreferredValueMap(newFieldToPreferredValueMap);
setScheduling({ ...scheduling, interval: expression });
setHasChanges(true);
}}
/>
</EuiFlexItem>
<EuiFlexItem>
<EuiFlexGroup>
<EuiFlexItem grow={false}>
Expand Down

0 comments on commit 37d5dd6

Please sign in to comment.