From 3686b73ef23bb434f455f86032b3ed57b1168158 Mon Sep 17 00:00:00 2001 From: Quynh Nguyen Date: Wed, 12 Aug 2020 12:59:48 -0500 Subject: [PATCH] [ML] Fix type errors --- .../new_job/common/job_creator/job_creator.ts | 8 +++++-- .../categorization_per_partition.tsx | 23 +++++++------------ .../categorization_per_partition_switch.tsx | 4 ++-- .../categorization_stop_on_warn_switch.tsx | 4 ++-- .../application/routing/routes/explorer.tsx | 3 ++- 5 files changed, 20 insertions(+), 22 deletions(-) diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator.ts b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator.ts index 3318865d22078..65647c693dac9 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator.ts +++ b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator.ts @@ -658,13 +658,17 @@ export class JobCreator { const firstCategorizationDetector = this._detectors.find( (d) => d.by_field_name === 'mlcategory' ); - if (firstCategorizationDetector && 'partition_field_name' in firstCategorizationDetector) { + if ( + firstCategorizationDetector && + 'partition_field_name' in firstCategorizationDetector && + firstCategorizationDetector.partition_field_name !== undefined + ) { return firstCategorizationDetector.partition_field_name; } return null; } - public set categorizationPerPartitionField(fieldName: string | number | null) { + public set categorizationPerPartitionField(fieldName: string | null) { if (fieldName === null) { this._detectors.forEach((detector) => { delete detector.partition_field_name; diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/categorization_partition_field/categorization_per_partition.tsx b/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/categorization_partition_field/categorization_per_partition.tsx index 801c4da6326b1..e8432b3197e6d 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/categorization_partition_field/categorization_per_partition.tsx +++ b/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/categorization_partition_field/categorization_per_partition.tsx @@ -8,11 +8,7 @@ import React, { FC, useContext, useEffect, useState } from 'react'; import { EuiFormRow } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { JobCreatorContext } from '../../../job_creator_context'; -import { - AdvancedJobCreator, - CategorizationJobCreator, - isCategorizationJobCreator, -} from '../../../../../common/job_creator'; +import { AdvancedJobCreator, CategorizationJobCreator } from '../../../../../common/job_creator'; import { newJobCapsService } from '../../../../../../../services/new_job_capabilities_service'; import { Description } from './description'; @@ -52,16 +48,13 @@ export const CategorizationPerPartitionField: FC = () => { setEnablePerPartitionCategorization(jobCreator.perPartitionCategorization); }, [jobCreatorUpdated]); - const isCategorizationJob = isCategorizationJobCreator(jobCreator); return ( - + } > @@ -73,8 +66,8 @@ export const CategorizationPerPartitionField: FC = () => { } > @@ -83,8 +76,8 @@ export const CategorizationPerPartitionField: FC = () => { } > diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/categorization_partition_field/categorization_per_partition_switch.tsx b/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/categorization_partition_field/categorization_per_partition_switch.tsx index dc1a1b4246a62..07c9e82ee1f34 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/categorization_partition_field/categorization_per_partition_switch.tsx +++ b/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/categorization_partition_field/categorization_per_partition_switch.tsx @@ -41,8 +41,8 @@ export const CategorizationPerPartitionSwitch: FC = () => { data-test-subj="mlJobWizardSwitchCategorizationPerPartition" label={ } /> diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/categorization_partition_field/categorization_stop_on_warn_switch.tsx b/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/categorization_partition_field/categorization_stop_on_warn_switch.tsx index 07b0014a4b279..028b12d675490 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/categorization_partition_field/categorization_stop_on_warn_switch.tsx +++ b/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/categorization_partition_field/categorization_stop_on_warn_switch.tsx @@ -31,8 +31,8 @@ export const CategorizationPerPartitionStopOnWarnSwitch: FC = () => { data-test-subj="mlJobWizardSwitchCategorizationPerPartitionStopOnWarn" label={ } /> diff --git a/x-pack/plugins/ml/public/application/routing/routes/explorer.tsx b/x-pack/plugins/ml/public/application/routing/routes/explorer.tsx index 40f4a1cc6891e..4e79bd32a8cc5 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/explorer.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/explorer.tsx @@ -131,7 +131,8 @@ const ExplorerUrlStateManager: FC = ({ jobsWithTim // eslint-disable-next-line no-console console.error(error); } - }); + }, []); + useEffect(() => { if (jobIds.length > 0) { explorerService.updateJobSelection(jobIds);