From 058c5dd196b78806255898d42c3b06638a0e323b Mon Sep 17 00:00:00 2001 From: Quynh Nguyen Date: Mon, 12 Apr 2021 10:54:37 -0500 Subject: [PATCH] [ML] Update message --- x-pack/plugins/ml/common/util/job_utils.ts | 12 ++++++------ .../jobs/jobs_list/components/job_actions/results.js | 12 +----------- x-pack/plugins/translations/translations/ja-JP.json | 3 +-- x-pack/plugins/translations/translations/zh-CN.json | 3 +-- 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/x-pack/plugins/ml/common/util/job_utils.ts b/x-pack/plugins/ml/common/util/job_utils.ts index 7e1fb61f4a7f2..da340d4413849 100644 --- a/x-pack/plugins/ml/common/util/job_utils.ts +++ b/x-pack/plugins/ml/common/util/job_utils.ts @@ -140,10 +140,10 @@ export function isSourceDataChartableForDetector(job: CombinedJob, detectorIndex // We cannot plot the source data for some specific aggregation configurations const aggs = getDatafeedAggregations(job.datafeed_config); - if (aggs !== undefined) { + if (isPopulatedObject(aggs)) { const aggBucketsName = getFirstKeyInObject(aggs); if (aggBucketsName !== undefined) { - // if fieldName is a aggregated field under nested terms using bucket_script + // if fieldName is an aggregated field under nested terms using bucket_script const aggregations = getAggregations(aggs[aggBucketsName]) ?? {}; const foundField = findAggField(aggregations, dtr.field_name, false); @@ -198,16 +198,16 @@ export function isModelPlotChartableForDetector(job: Job, detectorIndex: number) export function getSingleMetricViewerJobErrorMessage(job: CombinedJob): string | undefined { // if job has at least one composite source that is not terms or date_histogram const aggs = getDatafeedAggregations(job.datafeed_config); - if (aggs !== undefined) { + if (isPopulatedObject(aggs)) { const aggBucketsName = getFirstKeyInObject(aggs); if (aggBucketsName !== undefined && aggs[aggBucketsName] !== undefined) { - // if fieldName is a aggregated field under nested terms using bucket_script + // if fieldName is an aggregated field under nested terms using bucket_script if (!hasValidComposite(aggs[aggBucketsName])) { return i18n.translate( 'xpack.ml.timeSeriesJob.jobWithUnsupportedCompositeAggregationMessage', { - defaultMessage: 'the datafeed contains unsupported composite sources', + defaultMessage: 'Disabled because the datafeed contains unsupported composite sources.', } ); } @@ -223,7 +223,7 @@ export function getSingleMetricViewerJobErrorMessage(job: CombinedJob): string | if (isChartableTimeSeriesViewJob === false) { return i18n.translate('xpack.ml.timeSeriesJob.notViewableTimeSeriesJobMessage', { - defaultMessage: 'not a viewable time series job', + defaultMessage: 'Disabled because not a viewable time series job.', }); } } diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_actions/results.js b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_actions/results.js index 251b1b24087fa..f8195f5747f7e 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_actions/results.js +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_actions/results.js @@ -39,16 +39,6 @@ export function ResultLinks({ jobs }) { const singleMetricDisabledMessage = jobs.length === 1 && jobs[0].isNotSingleMetricViewerJobMessage; - const singleMetricDisabledMessageText = - singleMetricDisabledMessage !== undefined - ? i18n.translate('xpack.ml.jobsList.resultActions.singleMetricDisabledMessageText', { - defaultMessage: 'Disabled because {reason}.', - values: { - reason: singleMetricDisabledMessage, - }, - }) - : undefined; - const jobActionsDisabled = jobs.length === 1 && jobs[0].deleting === true; const { createLinkWithUserDefaults } = useCreateADLinks(); const timeSeriesExplorerLink = useMemo( @@ -62,7 +52,7 @@ export function ResultLinks({ jobs }) { {singleMetricVisible && (