Skip to content

Commit

Permalink
Fixed due to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
YulNaumenko committed Mar 17, 2020
1 parent 8ab5781 commit eba4f70
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ async function executor(
body: bulkBody,
};

if (config.refresh != null) {
bulkParams.refresh = config.refresh;
}
bulkParams.refresh = config.refresh;

let result;
try {
Expand All @@ -86,7 +84,7 @@ async function executor(
const message = i18n.translate('xpack.actions.builtin.esIndex.errorIndexingErrorMessage', {
defaultMessage: 'error indexing documents',
});
logger.warn(`error indexing documents: ${err.message}`);
logger.error(`error indexing documents: ${err.message}`);
return {
status: 'error',
actionId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
EuiComboBoxOptionOption,
EuiSelect,
EuiTitle,
EuiIconTip,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
Expand Down Expand Up @@ -51,7 +52,7 @@ export function getActionType(): ActionTypeModel {
if (!action.config.index) {
errors.index.push(
i18n.translate(
'xpack.triggersActionsUI.components.builtinActionTypes.indexAction.error.requiredIndexlText',
'xpack.triggersActionsUI.components.builtinActionTypes.indexAction.error.requiredIndexText',
{
defaultMessage: 'Index is required.',
}
Expand Down Expand Up @@ -96,7 +97,6 @@ const IndexActionConnectorFields: React.FunctionComponent<ActionConnectorFieldsP

return (
<>
<EuiHorizontalRule />
<EuiTitle size="s">
<h5>
<FormattedMessage
Expand Down Expand Up @@ -177,10 +177,22 @@ const IndexActionConnectorFields: React.FunctionComponent<ActionConnectorFieldsP
editActionConfig('refresh', e.target.checked);
}}
label={
<FormattedMessage
id="xpack.triggersActionsUI.components.builtinActionTypes.indexAction.refreshLabel"
defaultMessage="Refresh"
/>
<>
<FormattedMessage
id="xpack.triggersActionsUI.components.builtinActionTypes.indexAction.refreshLabel"
defaultMessage="Refresh"
/>{' '}
<EuiIconTip
position="right"
type="questionInCircle"
content={i18n.translate(
'xpack.triggersActionsUI.components.builtinActionTypes.indexAction.refreshTooltip',
{
defaultMessage: 'This checkbox set refresh index value.',
}
)}
/>
</>
}
/>
<EuiSpacer size="m" />
Expand All @@ -191,22 +203,35 @@ const IndexActionConnectorFields: React.FunctionComponent<ActionConnectorFieldsP
setTimeFieldCheckboxState(!hasTimeFieldCheckbox);
}}
label={
<FormattedMessage
id="xpack.triggersActionsUI.components.builtinActionTypes.indexAction.defineTimeFieldLabel"
defaultMessage="Define time field"
/>
<>
<FormattedMessage
id="xpack.triggersActionsUI.components.builtinActionTypes.indexAction.defineTimeFieldLabel"
defaultMessage="Define time field"
/>
<EuiIconTip
position="right"
type="questionInCircle"
content={i18n.translate(
'xpack.triggersActionsUI.components.builtinActionTypes.indexAction.definedateFieldTooltip',
{
defaultMessage:
'This is checkbox allows to define execution time field for index.',
}
)}
/>
</>
}
/>
<EuiSpacer size="m" />
{hasTimeFieldCheckbox ? (
<>
<EuiFormRow
id="thresholdTimeField"
id="executionTimeField"
fullWidth
label={
<FormattedMessage
id="xpack.triggersActionsUI.components.builtinActionTypes.indexAction.timeFieldLabel"
defaultMessage="Timefield"
id="xpack.triggersActionsUI.components.builtinActionTypes.indexAction.executionTimeFieldLabel"
defaultMessage="Time field"
/>
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default function indexTest({ getService }: FtrProviderContext) {
actionTypeId: '.index',
config: {
index: ES_TEST_INDEX_NAME,
refresh: false,
},
});
createdActionID = createdAction.id;
Expand All @@ -57,7 +58,7 @@ export default function indexTest({ getService }: FtrProviderContext) {
id: fetchedAction.id,
name: 'An index action',
actionTypeId: '.index',
config: { index: ES_TEST_INDEX_NAME },
config: { index: ES_TEST_INDEX_NAME, refresh: false },
});

// create action with all config props
Expand Down Expand Up @@ -119,7 +120,7 @@ export default function indexTest({ getService }: FtrProviderContext) {
statusCode: 400,
error: 'Bad Request',
message:
'error validating action type config: [index]: types that failed validation:\n- [index.0]: expected value of type [string] but got [number]\n- [index.1]: expected value to equal [null]',
'error validating action type config: [index]: expected value of type [string] but got [number]',
});
});
});
Expand All @@ -129,6 +130,10 @@ export default function indexTest({ getService }: FtrProviderContext) {
.post(`/api/action/${createdActionID}/_execute`)
.set('kbn-xsrf', 'foo')
.send({
config: {
index: ES_TEST_INDEX_NAME,
refresh: false,
},
params: {
documents: [{ testing: [1, 2, 3] }],
},
Expand All @@ -146,6 +151,9 @@ export default function indexTest({ getService }: FtrProviderContext) {
.post(`/api/action/${createdActionID}/_execute`)
.set('kbn-xsrf', 'foo')
.send({
config: {
index: ES_TEST_INDEX_NAME,
},
params: {
documents: [{ testing: [1, 2, 3] }, { Testing: [4, 5, 6] }],
},
Expand Down Expand Up @@ -177,6 +185,9 @@ export default function indexTest({ getService }: FtrProviderContext) {
.post(`/api/action/${createdActionID}/_execute`)
.set('kbn-xsrf', 'foo')
.send({
config: {
index: ES_TEST_INDEX_NAME,
},
params: {
documents: [{ refresh: 'not set' }],
},
Expand All @@ -192,6 +203,10 @@ export default function indexTest({ getService }: FtrProviderContext) {
.post(`/api/action/${createdActionID}/_execute`)
.set('kbn-xsrf', 'foo')
.send({
config: {
index: ES_TEST_INDEX_NAME,
refresh: true,
},
params: {
documents: [{ refresh: 'true' }],
},
Expand All @@ -211,6 +226,9 @@ export default function indexTest({ getService }: FtrProviderContext) {
.post(`/api/action/${createdActionID}/_execute`)
.set('kbn-xsrf', 'foo')
.send({
config: {
index: ES_TEST_INDEX_NAME,
},
params: {
documents: [{ testing: [1, 2, 3] }],
},
Expand All @@ -219,13 +237,16 @@ export default function indexTest({ getService }: FtrProviderContext) {
result = response.body;
expect(result.status).to.equal('error');
expect(result.message).to.eql(
'error validating action params: [indeX]: definition for this key is missing'
'error validating action params: [index]: definition for this key is missing'
);

response = await supertest
.post(`/api/action/${createdActionID}/_execute`)
.set('kbn-xsrf', 'foo')
.send({
config: {
index: ES_TEST_INDEX_NAME,
},
params: {
documents: [{ testing: [1, 2, 3] }],
},
Expand Down

0 comments on commit eba4f70

Please sign in to comment.