Skip to content

Commit

Permalink
adding blocked to job summary
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdyelastic committed Aug 11, 2021
1 parent 268098f commit 797c274
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
10 changes: 6 additions & 4 deletions x-pack/plugins/ml/common/types/anomaly_detection_jobs/job.ts
Expand Up @@ -12,12 +12,14 @@ export type BucketSpan = string;

// temporary Job override, waiting for es client to have correct types
export type Job = estypes.MlJob & {
blocked: {
reason: 'delete' | 'revert' | 'reset';
task_id?: string;
};
blocked: MlJobBlocked;
};

export interface MlJobBlocked {
reason: 'delete' | 'revert' | 'reset';
task_id?: string;
}

export type AnalysisConfig = estypes.MlAnalysisConfig;

export type Detector = estypes.MlDetector;
Expand Down
Expand Up @@ -7,10 +7,11 @@

import { Moment } from 'moment';

import { CombinedJob, CombinedJobWithStats } from './combined_job';
import { MlAnomalyDetectionAlertRule } from '../alerts';
export { Datafeed } from './datafeed';
export { DatafeedStats } from './datafeed_stats';
import type { CombinedJob, CombinedJobWithStats } from './combined_job';
import type { MlAnomalyDetectionAlertRule } from '../alerts';
import type { MlJobBlocked } from './job';
export type { Datafeed } from './datafeed';
export type { DatafeedStats } from './datafeed_stats';

export interface MlSummaryJob {
id: string;
Expand All @@ -32,6 +33,7 @@ export interface MlSummaryJob {
isSingleMetricViewerJob: boolean;
isNotSingleMetricViewerJobMessage?: string;
deleting?: boolean;
blocked?: MlJobBlocked;
latestTimestampSortValue?: number;
earliestStartTimestampMs?: number;
awaitingNodeAssignment: boolean;
Expand Down
Expand Up @@ -16,7 +16,7 @@ import {
isStartable,
isStoppable,
isClosable,
isResetable,
isResettable,
} from '../utils';
import { getToastNotifications } from '../../../../util/dependency_cache';
import { i18n } from '@kbn/i18n';
Expand Down Expand Up @@ -112,7 +112,7 @@ export function actionsMenuContent(
}),
icon: 'refresh',
enabled: (item) => isJobBlocked(item) === false && canResetJob,
available: (item) => isResetable([item]),
available: (item) => isResettable([item]),
onClick: (item) => {
showResetJobModal([item]);
closeMenu(true);
Expand Down
Expand Up @@ -18,7 +18,7 @@ import {
isStartable,
isStoppable,
isClosable,
isResetable,
isResettable,
} from '../utils';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
Expand Down Expand Up @@ -111,7 +111,7 @@ class MultiJobActionsMenuUI extends Component {
);
}

if (isResetable(this.props.jobs)) {
if (isResettable(this.props.jobs)) {
items.push(
<EuiContextMenuItem
key="reset job"
Expand Down
Expand Up @@ -77,7 +77,7 @@ export function isClosable(jobs) {
);
}

export function isResetable(jobs) {
export function isResettable(jobs) {
return jobs.some((j) => j.jobState === JOB_STATE.CLOSED);
}

Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/ml/server/models/job_service/jobs.ts
Expand Up @@ -239,6 +239,7 @@ export function jobsProvider(
isNotSingleMetricViewerJobMessage: errorMessage,
nodeName: job.node ? job.node.name : undefined,
deleting: job.deleting || undefined,
blocked: job.blocked ?? undefined,
awaitingNodeAssignment: isJobAwaitingNodeAssignment(job),
alertingRules: job.alerting_rules,
jobTags: job.custom_settings?.job_tags ?? {},
Expand Down

0 comments on commit 797c274

Please sign in to comment.