From b1dda2b5a8edce2701b780cbf06a01b8d4163fed Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Tue, 18 Aug 2020 08:06:34 -0700 Subject: [PATCH] Allow Watcher index actions to be configured without specifying an index name. (#74684) (#75242) --- .../plugins/translations/translations/ja-JP.json | 2 -- .../plugins/translations/translations/zh-CN.json | 2 -- .../watch_create_threshold.test.tsx | 14 +++----------- .../watcher/common/models/action/index_action.js | 15 --------------- .../application/models/action/index_action.js | 7 ------- 5 files changed, 3 insertions(+), 37 deletions(-) diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 6593665351bf3..3d4800b4ff49a 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -19310,7 +19310,6 @@ "xpack.watcher.models.jiraAction.typeName": "Jira", "xpack.watcher.models.jsonWatch.selectMessageText": "生 JSON のカスタムウォッチをセットアップします。", "xpack.watcher.models.jsonWatch.typeName": "高度なウォッチ", - "xpack.watcher.models.loggingAction.actionJsonIndexNamePropertyMissingBadRequestMessage": "json引数には{actionJsonIndexName}プロパティが含まれている必要があります", "xpack.watcher.models.loggingAction.actionJsonLoggingPropertyMissingBadRequestMessage": "json 引数には {actionJsonLogging} プロパティが含まれている必要があります", "xpack.watcher.models.loggingAction.actionJsonLoggingTextPropertyMissingBadRequestMessage": "json 引数には {actionJsonLoggingText} プロパティが含まれている必要があります", "xpack.watcher.models.loggingAction.actionJsonWebhookHostPropertyMissingBadRequestMessage": "json引数には{actionJsonWebhookHost}プロパティが含まれている必要があります", @@ -19576,7 +19575,6 @@ "xpack.watcher.timeUnits.minuteLabel": "{timeValue, plural, one {分} other {分}}", "xpack.watcher.timeUnits.secondLabel": "{timeValue, plural, one {秒} other {秒}}", "xpack.watcher.watchActions.email.emailRecipientIsRequiredValidationMessage": "送信先メールアドレスが必要です。", - "xpack.watcher.watchActions.index.indexIsRequiredValidationMessage": "インデックス名が必要です。", "xpack.watcher.watchActions.jira.issueTypeNameIsRequiredValidationMessage": "Jira問題タイプが必要です。", "xpack.watcher.watchActions.jira.projectKeyIsRequiredValidationMessage": "Jiraプロジェクトキーが必要です。", "xpack.watcher.watchActions.jira.summaryIsRequiredValidationMessage": "Jira概要が必要です。", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 6799c379d7765..f48bbcaca1196 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -19318,7 +19318,6 @@ "xpack.watcher.models.jiraAction.typeName": "Jira", "xpack.watcher.models.jsonWatch.selectMessageText": "以原始 JSON 格式设置定制监视。", "xpack.watcher.models.jsonWatch.typeName": "高级监视", - "xpack.watcher.models.loggingAction.actionJsonIndexNamePropertyMissingBadRequestMessage": "JSON 参数必须包含 {actionJsonIndexName} 属性", "xpack.watcher.models.loggingAction.actionJsonLoggingPropertyMissingBadRequestMessage": "json 参数必须包含 {actionJsonLogging} 属性", "xpack.watcher.models.loggingAction.actionJsonLoggingTextPropertyMissingBadRequestMessage": "json 参数必须包含 {actionJsonLoggingText} 属性", "xpack.watcher.models.loggingAction.actionJsonWebhookHostPropertyMissingBadRequestMessage": "JSON 参数必须包含 {actionJsonWebhookHost} 属性", @@ -19584,7 +19583,6 @@ "xpack.watcher.timeUnits.minuteLabel": "{timeValue, plural, one {分钟} other {分钟}}", "xpack.watcher.timeUnits.secondLabel": "{timeValue, plural, one {秒} other {秒}}", "xpack.watcher.watchActions.email.emailRecipientIsRequiredValidationMessage": "“收件人”电子邮件地址必填。", - "xpack.watcher.watchActions.index.indexIsRequiredValidationMessage": "索引名称必填。", "xpack.watcher.watchActions.jira.issueTypeNameIsRequiredValidationMessage": "Jira 问题类型必填。", "xpack.watcher.watchActions.jira.projectKeyIsRequiredValidationMessage": "Jira 项目键必填。", "xpack.watcher.watchActions.jira.summaryIsRequiredValidationMessage": "Jira 摘要必填。", diff --git a/x-pack/plugins/watcher/__jest__/client_integration/watch_create_threshold.test.tsx b/x-pack/plugins/watcher/__jest__/client_integration/watch_create_threshold.test.tsx index 3513606dbfe30..5c6cf22065d95 100644 --- a/x-pack/plugins/watcher/__jest__/client_integration/watch_create_threshold.test.tsx +++ b/x-pack/plugins/watcher/__jest__/client_integration/watch_create_threshold.test.tsx @@ -290,24 +290,16 @@ describe(' create route', () => { }); test('should simulate an index action', async () => { - const { form, find, actions, exists } = testBed; - - const INDEX = 'my_index'; + const { form, actions, exists } = testBed; actions.clickAddActionButton(); actions.clickActionLink('index'); expect(exists('watchActionAccordion')).toBe(true); - // First, provide invalid field and verify + // Verify an empty index is allowed form.setInputValue('indexInput', ''); - expect(form.getErrorsMessages()).toContain('Index name is required.'); - expect(find('simulateActionButton').props().disabled).toEqual(true); - - // Next, provide valid field and verify - form.setInputValue('indexInput', INDEX); - await act(async () => { actions.clickSimulateButton(); await nextTick(); @@ -327,7 +319,7 @@ describe(' create route', () => { id: 'index_1', type: 'index', index: { - index: INDEX, + index: '', }, }, ], diff --git a/x-pack/plugins/watcher/common/models/action/index_action.js b/x-pack/plugins/watcher/common/models/action/index_action.js index 3db4e4f9b0dab..e21505ea98c8c 100644 --- a/x-pack/plugins/watcher/common/models/action/index_action.js +++ b/x-pack/plugins/watcher/common/models/action/index_action.js @@ -80,21 +80,6 @@ export class IndexAction extends BaseAction { }); } - if (json.index && !json.index.index) { - errors.push({ - code: ERROR_CODES.ERR_PROP_MISSING, - message: i18n.translate( - 'xpack.watcher.models.loggingAction.actionJsonIndexNamePropertyMissingBadRequestMessage', - { - defaultMessage: 'JSON argument must contain an {actionJsonIndexName} property', - values: { - actionJsonIndexName: 'actionJson.index.index', - }, - } - ), - }); - } - return { errors: errors.length ? errors : null }; } } diff --git a/x-pack/plugins/watcher/public/application/models/action/index_action.js b/x-pack/plugins/watcher/public/application/models/action/index_action.js index 537a13fd855ca..6f9823e981e5b 100644 --- a/x-pack/plugins/watcher/public/application/models/action/index_action.js +++ b/x-pack/plugins/watcher/public/application/models/action/index_action.js @@ -19,13 +19,6 @@ export class IndexAction extends BaseAction { const errors = { index: [], }; - if (!this.index) { - errors.index.push( - i18n.translate('xpack.watcher.watchActions.index.indexIsRequiredValidationMessage', { - defaultMessage: 'Index name is required.', - }) - ); - } return errors; }