diff --git a/x-pack/plugins/ml/common/constants/job_actions.ts b/x-pack/plugins/ml/common/constants/job_actions.ts index 0cd16a10783e3..692875c73b105 100644 --- a/x-pack/plugins/ml/common/constants/job_actions.ts +++ b/x-pack/plugins/ml/common/constants/job_actions.ts @@ -5,8 +5,6 @@ * 2.0. */ -import { i18n } from '@kbn/i18n'; - export const JOB_ACTION = { DELETE: 'delete', RESET: 'reset', @@ -15,22 +13,16 @@ export const JOB_ACTION = { export type JobAction = typeof JOB_ACTION[keyof typeof JOB_ACTION]; -export function getJobActionString(action: JobAction) { +export type JobActionState = 'deleting' | 'resetting' | 'reverting'; + +export function getJobActionString(action: JobAction): JobActionState { switch (action) { case JOB_ACTION.DELETE: - return i18n.translate('xpack.ml.models.jobService.deletingJob', { - defaultMessage: 'deleting', - }); + return 'deleting'; case JOB_ACTION.RESET: - return i18n.translate('xpack.ml.models.jobService.resettingJob', { - defaultMessage: 'resetting', - }); + return 'resetting'; case JOB_ACTION.REVERT: - return i18n.translate('xpack.ml.models.jobService.revertingJob', { - defaultMessage: 'reverting', - }); - default: - return ''; + return 'reverting'; } } diff --git a/x-pack/plugins/ml/common/index.ts b/x-pack/plugins/ml/common/index.ts index de5989d92d208..cfed678a804a1 100644 --- a/x-pack/plugins/ml/common/index.ts +++ b/x-pack/plugins/ml/common/index.ts @@ -21,3 +21,4 @@ export { extractErrorMessage } from './util/errors'; export type { RuntimeMappings } from './types/fields'; export { getDefaultCapabilities as getDefaultMlCapabilities } from './types/capabilities'; export { DATAFEED_STATE, JOB_STATE } from './constants/states'; +export type { MlSummaryJob, SummaryJobState } from './types/anomaly_detection_jobs'; diff --git a/x-pack/plugins/ml/common/types/anomaly_detection_jobs/summary_job.ts b/x-pack/plugins/ml/common/types/anomaly_detection_jobs/summary_job.ts index fed0cc85c20b0..504fdb8cf1dcd 100644 --- a/x-pack/plugins/ml/common/types/anomaly_detection_jobs/summary_job.ts +++ b/x-pack/plugins/ml/common/types/anomaly_detection_jobs/summary_job.ts @@ -5,15 +5,19 @@ * 2.0. */ +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Moment } from 'moment'; import { MlCustomSettings } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { CombinedJob, CombinedJobWithStats } from './combined_job'; import type { MlAnomalyDetectionAlertRule } from '../alerts'; import type { MlJobBlocked } from './job'; +import type { JobActionState } from '../../constants/job_actions'; export type { Datafeed } from './datafeed'; export type { DatafeedStats } from './datafeed_stats'; +export type SummaryJobState = estypes.MlJobState | JobActionState; + /** * A summary of an anomaly detection job. */ @@ -47,7 +51,7 @@ export interface MlSummaryJob { /** * The status of the job. */ - jobState: string; + jobState: SummaryJobState; /** * An array of index names used by the datafeed. Wildcards are supported. diff --git a/x-pack/plugins/ml/server/index.ts b/x-pack/plugins/ml/server/index.ts index 786920ef5e46e..8a1cfb9590402 100644 --- a/x-pack/plugins/ml/server/index.ts +++ b/x-pack/plugins/ml/server/index.ts @@ -14,6 +14,8 @@ export type { AnomalyResultType as MlAnomalyResultType, DatafeedStats as MlDatafeedStats, Job as MlJob, + MlSummaryJob, + SummaryJobState as MlSummaryJobState, } from './shared'; export { UnknownMLCapabilitiesError, diff --git a/x-pack/plugins/security_solution/public/common/components/ml_popover/api.mock.ts b/x-pack/plugins/security_solution/public/common/components/ml_popover/api.mock.ts index 12bf4b1e824e3..172722b6fe99f 100644 --- a/x-pack/plugins/security_solution/public/common/components/ml_popover/api.mock.ts +++ b/x-pack/plugins/security_solution/public/common/components/ml_popover/api.mock.ts @@ -548,7 +548,7 @@ export const mockSecurityJobs: SecurityJob[] = [ datafeedState: '', hasDatafeed: false, isSingleMetricViewerJob: false, - jobState: '', + jobState: 'closed', memory_status: '', processed_record_count: 0, id: 'rare_process_by_host_windows_ecs', diff --git a/x-pack/plugins/security_solution/public/common/components/ml_popover/hooks/use_security_jobs_helpers.test.tsx b/x-pack/plugins/security_solution/public/common/components/ml_popover/hooks/use_security_jobs_helpers.test.tsx index 04d8dbb0931c0..f8f730c67248c 100644 --- a/x-pack/plugins/security_solution/public/common/components/ml_popover/hooks/use_security_jobs_helpers.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/ml_popover/hooks/use_security_jobs_helpers.test.tsx @@ -44,7 +44,7 @@ describe('useSecurityJobsHelpers', () => { isElasticJob: true, isInstalled: false, isSingleMetricViewerJob: false, - jobState: '', + jobState: 'closed', jobTags: {}, memory_status: '', moduleId: 'siem_auditbeat', diff --git a/x-pack/plugins/security_solution/public/common/components/ml_popover/hooks/use_security_jobs_helpers.tsx b/x-pack/plugins/security_solution/public/common/components/ml_popover/hooks/use_security_jobs_helpers.tsx index d2d7e198d47f3..3150c8aedd292 100644 --- a/x-pack/plugins/security_solution/public/common/components/ml_popover/hooks/use_security_jobs_helpers.tsx +++ b/x-pack/plugins/security_solution/public/common/components/ml_popover/hooks/use_security_jobs_helpers.tsx @@ -32,7 +32,7 @@ export const moduleToSecurityJob = ( datafeedState: '', hasDatafeed: false, isSingleMetricViewerJob: false, - jobState: '', + jobState: 'closed', memory_status: '', processed_record_count: 0, id: moduleJob.id, diff --git a/x-pack/plugins/security_solution/public/common/components/ml_popover/jobs_table/__snapshots__/jobs_table.test.tsx.snap b/x-pack/plugins/security_solution/public/common/components/ml_popover/jobs_table/__snapshots__/jobs_table.test.tsx.snap index 1950ef2228a1a..962f6f1a8dc42 100644 --- a/x-pack/plugins/security_solution/public/common/components/ml_popover/jobs_table/__snapshots__/jobs_table.test.tsx.snap +++ b/x-pack/plugins/security_solution/public/common/components/ml_popover/jobs_table/__snapshots__/jobs_table.test.tsx.snap @@ -100,7 +100,7 @@ exports[`JobsTableComponent renders correctly against snapshot 1`] = ` "isElasticJob": true, "isInstalled": false, "isSingleMetricViewerJob": false, - "jobState": "", + "jobState": "closed", "jobTags": Object {}, "memory_status": "", "moduleId": "siem_winlogbeat", diff --git a/x-pack/plugins/security_solution/public/common/components/ml_popover/jobs_table/filters/__snapshots__/jobs_table_filters.test.tsx.snap b/x-pack/plugins/security_solution/public/common/components/ml_popover/jobs_table/filters/__snapshots__/jobs_table_filters.test.tsx.snap index bd2c5611056f1..ed142a8132cfb 100644 --- a/x-pack/plugins/security_solution/public/common/components/ml_popover/jobs_table/filters/__snapshots__/jobs_table_filters.test.tsx.snap +++ b/x-pack/plugins/security_solution/public/common/components/ml_popover/jobs_table/filters/__snapshots__/jobs_table_filters.test.tsx.snap @@ -103,7 +103,7 @@ exports[`JobsTableFilters renders correctly against snapshot 1`] = ` "isElasticJob": true, "isInstalled": false, "isSingleMetricViewerJob": false, - "jobState": "", + "jobState": "closed", "jobTags": Object {}, "memory_status": "", "moduleId": "siem_winlogbeat", diff --git a/x-pack/plugins/translations/translations/fr-FR.json b/x-pack/plugins/translations/translations/fr-FR.json index 8a30c8bb80de3..f9e918322731d 100644 --- a/x-pack/plugins/translations/translations/fr-FR.json +++ b/x-pack/plugins/translations/translations/fr-FR.json @@ -18803,11 +18803,8 @@ "xpack.ml.models.jobService.categorization.messages.validTokenLength": "Plus de {tokenCount} tokens par exemple ont été trouvés dans plus de {percentage} % des exemples chargés.", "xpack.ml.models.jobService.categorization.messages.validTooManyTokens": "Moins de 10 000 tokens ont été trouvés en tout dans les exemples chargés.", "xpack.ml.models.jobService.categorization.messages.validUserPrivileges": "L'utilisateur dispose de privilèges suffisants pour effectuer les vérifications.", - "xpack.ml.models.jobService.deletingJob": "suppression", "xpack.ml.models.jobService.jobHasNoDatafeedErrorMessage": "La tâche ne comporte aucun flux de données", "xpack.ml.models.jobService.requestToActionTimedOutErrorMessage": "La requête pour {action} \"{id}\" a expiré.{extra}", - "xpack.ml.models.jobService.resettingJob": "réinitialisation", - "xpack.ml.models.jobService.revertingJob": "restauration", "xpack.ml.models.jobService.revertModelSnapshot.autoCreatedCalendar.description": "Créé automatiquement", "xpack.ml.models.jobValidation.messages.bucketSpanEmptyMessage": "Le champ d’étendue du compartiment doit être spécifié.", "xpack.ml.models.jobValidation.messages.bucketSpanEstimationMismatchHeading": "Étendue du compartiment", diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index fb1ca2dcd650a..e43675936d6cf 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -18950,11 +18950,8 @@ "xpack.ml.models.jobService.categorization.messages.validTokenLength": "読み込んだサンプルの {percentage}% 以上でサンプルあたり {tokenCount} 個を超えるトークンが見つかりました。", "xpack.ml.models.jobService.categorization.messages.validTooManyTokens": "読み込んだサンプル内に合計で 10000 個未満のトークンがありました。", "xpack.ml.models.jobService.categorization.messages.validUserPrivileges": "ユーザーには、確認を実行する十分な権限があります。", - "xpack.ml.models.jobService.deletingJob": "削除中", "xpack.ml.models.jobService.jobHasNoDatafeedErrorMessage": "ジョブにデータフィードがありません", "xpack.ml.models.jobService.requestToActionTimedOutErrorMessage": "「{id}」を{action}するリクエストがタイムアウトしました。{extra}", - "xpack.ml.models.jobService.resettingJob": "セットしています", - "xpack.ml.models.jobService.revertingJob": "元に戻しています", "xpack.ml.models.jobService.revertModelSnapshot.autoCreatedCalendar.description": "自動作成されました", "xpack.ml.models.jobValidation.messages.bucketSpanEmptyMessage": "バケットスパンフィールドを指定する必要があります。", "xpack.ml.models.jobValidation.messages.bucketSpanEstimationMismatchHeading": "バケットスパン", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 3b96df93ad35d..4aba1fae5d42b 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -18979,11 +18979,8 @@ "xpack.ml.models.jobService.categorization.messages.validTokenLength": "在 {percentage}% 以上的已加载示例中为每个示例找到 {tokenCount} 个以上分词。", "xpack.ml.models.jobService.categorization.messages.validTooManyTokens": "在已加载示例中总共找到的分词不超过 10000 个。", "xpack.ml.models.jobService.categorization.messages.validUserPrivileges": "用户有足够的权限执行检查。", - "xpack.ml.models.jobService.deletingJob": "正在删除", "xpack.ml.models.jobService.jobHasNoDatafeedErrorMessage": "作业没有数据馈送", "xpack.ml.models.jobService.requestToActionTimedOutErrorMessage": "对 {action} “{id}” 的请求超时。{extra}", - "xpack.ml.models.jobService.resettingJob": "正在重置", - "xpack.ml.models.jobService.revertingJob": "正在恢复", "xpack.ml.models.jobService.revertModelSnapshot.autoCreatedCalendar.description": "自动创建", "xpack.ml.models.jobValidation.messages.bucketSpanEmptyMessage": "必须指定存储桶跨度字段。", "xpack.ml.models.jobValidation.messages.bucketSpanEstimationMismatchHeading": "存储桶跨度",