Bug: Integer ingestion config field changes needed to be handled correctly (#11104)

* Bug: Integer ingestion config field changes were not handled correctly

* Change method name
This commit is contained in:
Nahuel 2023-04-18 16:43:06 +02:00 committed by GitHub
parent 07b74ce8e8
commit af2093f78b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -149,11 +149,10 @@ const ConfigureIngestion = ({
const toggleField = (field: keyof AddIngestionState) =>
onChange({ [field]: !data[field] });
const handleValueParseInt =
(property: keyof AddIngestionState) =>
(event: React.ChangeEvent<HTMLInputElement>) =>
const handleIntValue =
(property: keyof AddIngestionState) => (value: number | undefined | null) =>
onChange({
[property]: parseInt(event.target.value),
[property]: value ?? undefined,
});
const handleValueChange =
@ -163,24 +162,6 @@ const ConfigureIngestion = ({
[property]: event.target.value,
});
const handleProfileSample = (profileSample: number | undefined | null) =>
onChange({
profileSample: profileSample ?? undefined,
});
const handleConfidenceScore = (confidence: number | undefined | null) =>
onChange({
confidence: confidence ?? undefined,
});
const handleProfileSampleTypeChange = (value: ProfileSampleType) => {
onChange({
profileSampleType: value,
});
handleProfileSample(undefined);
};
const handleDashBoardServiceNames = (inputValue: string[]) => {
if (inputValue) {
onChange({
@ -220,18 +201,30 @@ const ConfigureIngestion = ({
const handleProcessPii = () => toggleField('processPii');
const handleQueryLogDuration = handleValueParseInt('queryLogDuration');
const handleQueryLogDuration = handleIntValue('queryLogDuration');
const handleResultLimit = handleValueParseInt('resultLimit');
const handleResultLimit = handleIntValue('resultLimit');
const handleStageFileLocation = handleValueChange('stageFileLocation');
const handleThreadCount = handleValueParseInt('threadCount');
const handleThreadCount = handleIntValue('threadCount');
const handleTimeoutSeconds = handleValueParseInt('timeoutSeconds');
const handleTimeoutSeconds = handleIntValue('timeoutSeconds');
const handleIngestionName = handleValueChange('ingestionName');
const handleProfileSample = handleIntValue('profileSample');
const handleConfidenceScore = handleIntValue('confidence');
const handleProfileSampleTypeChange = (value: ProfileSampleType) => {
onChange({
profileSampleType: value,
});
handleProfileSample(undefined);
};
const commonMetadataFields: FieldProp[] = [
{
name: 'name',
@ -890,6 +883,7 @@ const ConfigureIngestion = ({
'data-testid': 'threadCount',
placeholder: '5',
value: threadCount,
min: 1,
onChange: handleThreadCount,
},
},
@ -905,6 +899,7 @@ const ConfigureIngestion = ({
'data-testid': 'timeoutSeconds',
placeholder: '43200',
value: timeoutSeconds,
min: 1,
onChange: handleTimeoutSeconds,
},
},