Skip to content

Commit

Permalink
Allow Watcher index actions to be configured without specifying an in…
Browse files Browse the repository at this point in the history
…dex name. (#74684) (#75243)
  • Loading branch information
cjcenizal authored Aug 18, 2020
1 parent c74c842 commit 52481f3
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 37 deletions.
2 changes: 0 additions & 2 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -19393,7 +19393,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}プロパティが含まれている必要があります",
Expand Down Expand Up @@ -19659,7 +19658,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概要が必要です。",
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -19401,7 +19401,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} 属性",
Expand Down Expand Up @@ -19667,7 +19666,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 摘要必填。",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,24 +290,16 @@ describe('<ThresholdWatchEdit /> 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();
Expand All @@ -327,7 +319,7 @@ describe('<ThresholdWatchEdit /> create route', () => {
id: 'index_1',
type: 'index',
index: {
index: INDEX,
index: '',
},
},
],
Expand Down
15 changes: 0 additions & 15 deletions x-pack/plugins/watcher/common/models/action/index_action.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 52481f3

Please sign in to comment.