From 1e86bfe2970647dceb64e3826a564754211056f9 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 28 Sep 2020 15:37:35 +0200 Subject: [PATCH 1/5] Improve error message --- src/plugins/data/common/search/aggs/param_types/field.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/data/common/search/aggs/param_types/field.ts b/src/plugins/data/common/search/aggs/param_types/field.ts index 492294bdf4e5f..93e1baaebb308 100644 --- a/src/plugins/data/common/search/aggs/param_types/field.ts +++ b/src/plugins/data/common/search/aggs/param_types/field.ts @@ -84,7 +84,7 @@ export class FieldParamType extends BaseParamType { } const validField = this.getAvailableFields(aggConfig).find((f: any) => f.name === fieldName); - if (!validField) { + if (!validField || 1 === 1) { throw new Error( i18n.translate( 'data.search.aggs.paramTypes.field.invalidSavedFieldParameterErrorMessage', @@ -92,7 +92,7 @@ export class FieldParamType extends BaseParamType { defaultMessage: 'Saved {fieldParameter} parameter is now invalid. Please select a new field.', values: { - fieldParameter: '"field"', + fieldParameter: `"${fieldName}"`, }, } ) From d6914dcf13e820cd0b1a7c7918db88681bd96ba4 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 28 Sep 2020 15:43:21 +0200 Subject: [PATCH 2/5] Remove debug code --- src/plugins/data/common/search/aggs/param_types/field.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/data/common/search/aggs/param_types/field.ts b/src/plugins/data/common/search/aggs/param_types/field.ts index 93e1baaebb308..35e363994430f 100644 --- a/src/plugins/data/common/search/aggs/param_types/field.ts +++ b/src/plugins/data/common/search/aggs/param_types/field.ts @@ -84,7 +84,7 @@ export class FieldParamType extends BaseParamType { } const validField = this.getAvailableFields(aggConfig).find((f: any) => f.name === fieldName); - if (!validField || 1 === 1) { + if (!validField) { throw new Error( i18n.translate( 'data.search.aggs.paramTypes.field.invalidSavedFieldParameterErrorMessage', From 3e8212bb71faf5624f5b075acfd25d46660bcb4c Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 29 Sep 2020 15:56:46 +0200 Subject: [PATCH 3/5] Improve error message --- src/plugins/data/common/search/aggs/param_types/field.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/data/common/search/aggs/param_types/field.ts b/src/plugins/data/common/search/aggs/param_types/field.ts index 35e363994430f..a306649abf6b0 100644 --- a/src/plugins/data/common/search/aggs/param_types/field.ts +++ b/src/plugins/data/common/search/aggs/param_types/field.ts @@ -90,9 +90,10 @@ export class FieldParamType extends BaseParamType { 'data.search.aggs.paramTypes.field.invalidSavedFieldParameterErrorMessage', { defaultMessage: - 'Saved {fieldParameter} parameter is now invalid. Please select a new field.', + 'Saved field "{fieldParameter}" is invalid for use with the "{aggType}" aggregation. Please select a new field.', values: { - fieldParameter: `"${fieldName}"`, + fieldParameter: fieldName, + aggType: aggConfig?.type?.name, }, } ) From a542b977c4db0b20c7640080782ae029d9b24a06 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 29 Sep 2020 17:54:12 +0200 Subject: [PATCH 4/5] Fix i18n --- x-pack/plugins/translations/translations/ja-JP.json | 1 - x-pack/plugins/translations/translations/zh-CN.json | 1 - 2 files changed, 2 deletions(-) diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index fd743400133a7..61b92fd7abab4 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -1200,7 +1200,6 @@ "data.search.aggs.metrics.uniqueCountTitle": "ユニークカウント", "data.search.aggs.otherBucket.labelForMissingValuesLabel": "欠測値のラベル", "data.search.aggs.otherBucket.labelForOtherBucketLabel": "他のバケットのラベル", - "data.search.aggs.paramTypes.field.invalidSavedFieldParameterErrorMessage": "保存した {fieldParameter} パラメーターが無効になりました。新しいフィールドを選択してください。", "data.search.aggs.paramTypes.field.requiredFieldParameterErrorMessage": "{fieldParameter} は必須パラメーターです", "data.search.aggs.percentageOfLabel": "{label} の割合", "data.search.aggs.string.customLabel": "カスタムラベル", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 104fc70f5dd71..2d84a3c3af2b6 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -1201,7 +1201,6 @@ "data.search.aggs.metrics.uniqueCountTitle": "唯一计数", "data.search.aggs.otherBucket.labelForMissingValuesLabel": "缺失值的标签", "data.search.aggs.otherBucket.labelForOtherBucketLabel": "其他存储桶的标签", - "data.search.aggs.paramTypes.field.invalidSavedFieldParameterErrorMessage": "保存的 {fieldParameter} 参数现在无效。请选择新字段。", "data.search.aggs.paramTypes.field.requiredFieldParameterErrorMessage": "{fieldParameter} 是必需字段", "data.search.aggs.percentageOfLabel": "{label} 的百分比", "data.search.aggs.string.customLabel": "定制标签", From d82c35e956df563517666d8a2aafaa377551329e Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 29 Sep 2020 22:07:36 +0200 Subject: [PATCH 5/5] use aggConfig.type.title --- src/plugins/data/common/search/aggs/param_types/field.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/data/common/search/aggs/param_types/field.ts b/src/plugins/data/common/search/aggs/param_types/field.ts index a306649abf6b0..a0bc71ac8e156 100644 --- a/src/plugins/data/common/search/aggs/param_types/field.ts +++ b/src/plugins/data/common/search/aggs/param_types/field.ts @@ -93,7 +93,7 @@ export class FieldParamType extends BaseParamType { 'Saved field "{fieldParameter}" is invalid for use with the "{aggType}" aggregation. Please select a new field.', values: { fieldParameter: fieldName, - aggType: aggConfig?.type?.name, + aggType: aggConfig?.type?.title, }, } )