diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/analysis_setup_indices_form.tsx b/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/analysis_setup_indices_form.tsx index 3334e565f70f7..89f8d77bd5f63 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/analysis_setup_indices_form.tsx +++ b/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/analysis_setup_indices_form.tsx @@ -13,11 +13,12 @@ import { LoadingOverlayWrapper } from '../../../loading_overlay_wrapper'; import { ValidatedIndex, ValidationIndicesUIError } from './validation'; export const AnalysisSetupIndicesForm: React.FunctionComponent<{ + disabled?: boolean; indices: ValidatedIndex[]; isValidating: boolean; onChangeSelectedIndices: (selectedIndices: ValidatedIndex[]) => void; valid: boolean; -}> = ({ indices, isValidating, onChangeSelectedIndices, valid }) => { +}> = ({ disabled = false, indices, isValidating, onChangeSelectedIndices, valid }) => { const handleCheckboxChange = useCallback( (event: React.ChangeEvent) => { onChangeSelectedIndices( @@ -40,7 +41,7 @@ export const AnalysisSetupIndicesForm: React.FunctionComponent<{ label={{index.name}} onChange={handleCheckboxChange} checked={index.validity === 'valid' && index.isSelected} - disabled={index.validity === 'invalid'} + disabled={disabled || index.validity === 'invalid'} /> ); @@ -52,7 +53,7 @@ export const AnalysisSetupIndicesForm: React.FunctionComponent<{ ); }), - [handleCheckboxChange, indices] + [disabled, handleCheckboxChange, indices] ); return ( diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/analysis_setup_timerange_form.tsx b/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/analysis_setup_timerange_form.tsx index f45d274169497..4319f844b1dcc 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/analysis_setup_timerange_form.tsx +++ b/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/analysis_setup_timerange_form.tsx @@ -46,11 +46,12 @@ function selectedDateToParam(selectedDate: Moment | null) { } export const AnalysisSetupTimerangeForm: React.FunctionComponent<{ + disabled?: boolean; setStartTime: (startTime: number | undefined) => void; setEndTime: (endTime: number | undefined) => void; startTime: number | undefined; endTime: number | undefined; -}> = ({ setStartTime, setEndTime, startTime, endTime }) => { +}> = ({ disabled = false, setStartTime, setEndTime, startTime, endTime }) => { const now = useMemo(() => moment(), []); const selectedEndTimeIsToday = !endTime || moment(endTime).isSame(now, 'day'); const startTimeValue = useMemo(() => { @@ -86,9 +87,11 @@ export const AnalysisSetupTimerangeForm: React.FunctionComponent<{ > setStartTime(undefined) } : undefined} + clear={startTime && !disabled ? { onClick: () => setStartTime(undefined) } : undefined} + isDisabled={disabled} > setStartTime(selectedDateToParam(date))} @@ -107,9 +110,11 @@ export const AnalysisSetupTimerangeForm: React.FunctionComponent<{ > setEndTime(undefined) } : undefined} + clear={endTime && !disabled ? { onClick: () => setEndTime(undefined) } : undefined} + isDisabled={disabled} > setEndTime(selectedDateToParam(date))} diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/initial_configuration_step.tsx b/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/initial_configuration_step.tsx index 2494b802cdb5b..de20dd12c17bd 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/initial_configuration_step.tsx +++ b/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/initial_configuration_step.tsx @@ -8,8 +8,9 @@ import { EuiSpacer, EuiForm, EuiCallOut } from '@elastic/eui'; import { EuiContainedStepProps } from '@elastic/eui/src/components/steps/steps'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import React from 'react'; +import React, { useMemo } from 'react'; +import { SetupStatus } from '../../../../../common/log_analysis'; import { AnalysisSetupIndicesForm } from './analysis_setup_indices_form'; import { AnalysisSetupTimerangeForm } from './analysis_setup_timerange_form'; import { ValidatedIndex, ValidationIndicesUIError } from './validation'; @@ -21,6 +22,7 @@ interface InitialConfigurationStepProps { endTime: number | undefined; isValidating: boolean; validatedIndices: ValidatedIndex[]; + setupStatus: SetupStatus; setValidatedIndices: (selectedIndices: ValidatedIndex[]) => void; validationErrors?: ValidationIndicesUIError[]; } @@ -39,20 +41,25 @@ export const InitialConfigurationStep: React.FunctionComponent { + const disabled = useMemo(() => !editableFormStatus.includes(setupStatus), [setupStatus]); + return ( <> { endTime, isValidating, validatedIndices, + setupStatus, setValidatedIndices, validationErrors, }), diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/page_setup_content.tsx b/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/page_setup_content.tsx index 7e90cf29072e1..6b3b5fe0b18fa 100644 --- a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/page_setup_content.tsx +++ b/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/page_setup_content.tsx @@ -47,6 +47,7 @@ export const LogEntryRateSetupContent: React.FunctionComponent = () => { endTime, isValidating, validatedIndices, + setupStatus, setValidatedIndices, validationErrors, }),