Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLInputElement>) => {
onChangeSelectedIndices(
Expand All @@ -40,7 +41,7 @@ export const AnalysisSetupIndicesForm: React.FunctionComponent<{
label={<EuiCode>{index.name}</EuiCode>}
onChange={handleCheckboxChange}
checked={index.validity === 'valid' && index.isSelected}
disabled={index.validity === 'invalid'}
disabled={disabled || index.validity === 'invalid'}
/>
);

Expand All @@ -52,7 +53,7 @@ export const AnalysisSetupIndicesForm: React.FunctionComponent<{
</div>
);
}),
[handleCheckboxChange, indices]
[disabled, handleCheckboxChange, indices]
);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down Expand Up @@ -86,9 +87,11 @@ export const AnalysisSetupTimerangeForm: React.FunctionComponent<{
>
<EuiFlexGroup gutterSize="s">
<EuiFormControlLayout
clear={startTime ? { onClick: () => setStartTime(undefined) } : undefined}
clear={startTime && !disabled ? { onClick: () => setStartTime(undefined) } : undefined}
isDisabled={disabled}
>
<FixedDatePicker
disabled={disabled}
showTimeSelect
selected={startTimeValue}
onChange={date => setStartTime(selectedDateToParam(date))}
Expand All @@ -107,9 +110,11 @@ export const AnalysisSetupTimerangeForm: React.FunctionComponent<{
>
<EuiFlexGroup gutterSize="s">
<EuiFormControlLayout
clear={endTime ? { onClick: () => setEndTime(undefined) } : undefined}
clear={endTime && !disabled ? { onClick: () => setEndTime(undefined) } : undefined}
isDisabled={disabled}
>
<FixedDatePicker
disabled={disabled}
showTimeSelect
selected={endTimeValue}
onChange={date => setEndTime(selectedDateToParam(date))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -21,6 +22,7 @@ interface InitialConfigurationStepProps {
endTime: number | undefined;
isValidating: boolean;
validatedIndices: ValidatedIndex[];
setupStatus: SetupStatus;
setValidatedIndices: (selectedIndices: ValidatedIndex[]) => void;
validationErrors?: ValidationIndicesUIError[];
}
Expand All @@ -39,20 +41,25 @@ export const InitialConfigurationStep: React.FunctionComponent<InitialConfigurat
endTime,
isValidating,
validatedIndices,
setupStatus,
setValidatedIndices,
validationErrors = [],
}: InitialConfigurationStepProps) => {
const disabled = useMemo(() => !editableFormStatus.includes(setupStatus), [setupStatus]);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's changing this setupStatus value and where?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's being passed in as a property to the component. It originates from the job management hook that uses a combination of the ML API responses and the setup flow state to determine the overall setup state.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok so this value was already being set, gotcha. Looks good then!


return (
<>
<EuiSpacer size="m" />
<EuiForm>
<AnalysisSetupTimerangeForm
disabled={disabled}
setStartTime={setStartTime}
setEndTime={setEndTime}
startTime={startTime}
endTime={endTime}
/>
<AnalysisSetupIndicesForm
disabled={disabled}
indices={validatedIndices}
isValidating={isValidating}
onChangeSelectedIndices={setValidatedIndices}
Expand All @@ -65,6 +72,13 @@ export const InitialConfigurationStep: React.FunctionComponent<InitialConfigurat
);
};

const editableFormStatus = [
'required',
'requiredForReconfiguration',
'requiredForUpdate',
'failed',
];

const errorCalloutTitle = i18n.translate(
'xpack.infra.analysisSetup.steps.initialConfigurationStep.errorCalloutTitle',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const LogEntryCategoriesSetupContent: React.FunctionComponent = () => {
endTime,
isValidating,
validatedIndices,
setupStatus,
setValidatedIndices,
validationErrors,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const LogEntryRateSetupContent: React.FunctionComponent = () => {
endTime,
isValidating,
validatedIndices,
setupStatus,
setValidatedIndices,
validationErrors,
}),
Expand Down