Skip to content

Commit

Permalink
[ML] Fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
qn895 committed Aug 12, 2020
1 parent 0a813e1 commit 3686b73
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -52,16 +48,13 @@ export const CategorizationPerPartitionField: FC = () => {
setEnablePerPartitionCategorization(jobCreator.perPartitionCategorization);
}, [jobCreatorUpdated]);

const isCategorizationJob = isCategorizationJobCreator(jobCreator);
return (
<Description isOptional={isCategorizationJob === false}>
<Description>
<EuiFormRow
label={
<FormattedMessage
id={
'xpack.ml.newJob.wizard.extraStep.categorizationJob.perPartitionCategorizationLabel'
}
defaultMessage={'Enable per-partition categorization'}
id="xpack.ml.newJob.wizard.extraStep.categorizationJob.perPartitionCategorizationLabel"
defaultMessage="Enable per-partition categorization"
/>
}
>
Expand All @@ -73,8 +66,8 @@ export const CategorizationPerPartitionField: FC = () => {
<EuiFormRow
label={
<FormattedMessage
id={'xpack.ml.newJob.wizard.extraStep.categorizationJob.stopOnWarnLabel'}
defaultMessage={'Stop on warn'}
id="xpack.ml.newJob.wizard.extraStep.categorizationJob.stopOnWarnLabel"
defaultMessage="Stop on warn"
/>
}
>
Expand All @@ -83,8 +76,8 @@ export const CategorizationPerPartitionField: FC = () => {
<EuiFormRow
label={
<FormattedMessage
id={'xpack.ml.newJob.wizard.extraStep.categorizationJob.partitionFieldLabel'}
defaultMessage={'Partition field'}
id="xpack.ml.newJob.wizard.extraStep.categorizationJob.partitionFieldLabel"
defaultMessage="Partition field"
/>
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export const CategorizationPerPartitionSwitch: FC = () => {
data-test-subj="mlJobWizardSwitchCategorizationPerPartition"
label={
<FormattedMessage
id={'xpack.ml.newJob.wizard.perPartitionCategorizationSwitchLabel'}
defaultMessage={'Enable per-partition categorization'}
id="xpack.ml.newJob.wizard.perPartitionCategorizationSwitchLabel"
defaultMessage="Enable per-partition categorization"
/>
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export const CategorizationPerPartitionStopOnWarnSwitch: FC = () => {
data-test-subj="mlJobWizardSwitchCategorizationPerPartitionStopOnWarn"
label={
<FormattedMessage
id={'xpack.ml.newJob.wizard.perPartitionCategorizationtopOnWarnSwitchLabel'}
defaultMessage={'Stop on warn'}
id="xpack.ml.newJob.wizard.perPartitionCategorizationtopOnWarnSwitchLabel"
defaultMessage="Stop on warn"
/>
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ const ExplorerUrlStateManager: FC<ExplorerUrlStateManagerProps> = ({ jobsWithTim
// eslint-disable-next-line no-console
console.error(error);
}
});
}, []);

useEffect(() => {
if (jobIds.length > 0) {
explorerService.updateJobSelection(jobIds);
Expand Down

0 comments on commit 3686b73

Please sign in to comment.