Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Alerting][Connectors] Removing ability to set refresh=true from ES Index Connector UI #158102

Merged
merged 5 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions docs/management/connectors/action-types/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ image::management/connectors/images/index-connector.png[Index connector]
[[index-connector-configuration]]
==== Connector configuration

Index connectors must have a name and an {es} index. You can optionally set the
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lcawl I removed references to refresh in the docs but did not touch the API as we are not changing the API (no breaking changes), just removing the ability to set the value in the UI.

{ref}/docs-refresh.html[refresh] policy and the time field, which contains the
Index connectors must have a name and an {es} index. You can optionally set the time field, which contains the
details about when each alert condition was detected.

[float]
Expand All @@ -46,10 +45,8 @@ xpack.actions.preconfigured:
actionTypeId: .index
config:
index: .kibana
refresh: true <1>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lcawl I also remove this from the preconfigured connector config because we want to discourage people from setting the value to true. When not set, it will default to false

executionTimeField: my-field
--
<1> By default, the {ref}/docs-refresh.html[refresh] policy is `false`.

For more information, go to <<pre-configured-connectors>>.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ describe('IndexActionConnectorFields', () => {
const wrapper = await setup(connector);

expect(wrapper.find('[data-test-subj="connectorIndexesComboBox"]').exists()).toBeTruthy();
expect(wrapper.find('[data-test-subj="indexRefreshCheckbox"]').exists()).toBeTruthy();

// time field switch shouldn't show up initially
expect(wrapper.find('[data-test-subj="hasTimeFieldCheckbox"]').exists()).toBeFalsy();
Expand Down Expand Up @@ -177,7 +176,6 @@ describe('IndexActionConnectorFields', () => {
const wrapper = await setup(props);

expect(wrapper.find('[data-test-subj="connectorIndexesComboBox"]').exists()).toBeTruthy();
expect(wrapper.find('[data-test-subj="indexRefreshCheckbox"]').exists()).toBeTruthy();

// time related fields shouldn't show up
expect(wrapper.find('[data-test-subj="hasTimeFieldCheckbox"]').exists()).toBeFalsy();
Expand All @@ -187,9 +185,6 @@ describe('IndexActionConnectorFields', () => {
.find(EuiComboBox)
.filter('[data-test-subj="connectorIndexesComboBox"]');
expect(indexComboBox.prop('selectedOptions')).toEqual([{ label: indexName, value: indexName }]);

const refreshSwitch = wrapper.find(EuiSwitch).filter('[data-test-subj="indexRefreshCheckbox"]');
expect(refreshSwitch.prop('checked')).toEqual(false);
});

test('renders correctly when editing connector - refresh set to true', async () => {
Expand All @@ -208,17 +203,13 @@ describe('IndexActionConnectorFields', () => {
const wrapper = await setup(props);

expect(wrapper.find('[data-test-subj="connectorIndexesComboBox"]').exists()).toBeTruthy();
expect(wrapper.find('[data-test-subj="indexRefreshCheckbox"]').exists()).toBeTruthy();
expect(wrapper.find('[data-test-subj="hasTimeFieldCheckbox"]').exists()).toBeFalsy();
expect(wrapper.find('[data-test-subj="executionTimeFieldSelect"]').exists()).toBeFalsy();

const indexComboBox = wrapper
.find(EuiComboBox)
.filter('[data-test-subj="connectorIndexesComboBox"]');
expect(indexComboBox.prop('selectedOptions')).toEqual([{ label: indexName, value: indexName }]);

const refreshSwitch = wrapper.find(EuiSwitch).filter('[data-test-subj="indexRefreshCheckbox"]');
expect(refreshSwitch.prop('checked')).toEqual(true);
});

test('renders correctly when editing connector - with date type field mapping but no time field selected', async () => {
Expand All @@ -238,7 +229,6 @@ describe('IndexActionConnectorFields', () => {

await waitFor(() => {
expect(wrapper.find('[data-test-subj="connectorIndexesComboBox"]').exists()).toBeTruthy();
expect(wrapper.find('[data-test-subj="indexRefreshCheckbox"]').exists()).toBeTruthy();
expect(wrapper.find('[data-test-subj="hasTimeFieldCheckbox"]').exists()).toBeTruthy();
expect(wrapper.find('[data-test-subj="executionTimeFieldSelect"]').exists()).toBeFalsy();
});
Expand All @@ -248,9 +238,6 @@ describe('IndexActionConnectorFields', () => {
.filter('[data-test-subj="connectorIndexesComboBox"]');
expect(indexComboBox.prop('selectedOptions')).toEqual([{ label: indexName, value: indexName }]);

const refreshSwitch = wrapper.find(EuiSwitch).filter('[data-test-subj="indexRefreshCheckbox"]');
expect(refreshSwitch.prop('checked')).toEqual(false);

const timeFieldSwitch = wrapper
.find(EuiSwitch)
.filter('[data-test-subj="hasTimeFieldCheckbox"]');
Expand All @@ -275,7 +262,6 @@ describe('IndexActionConnectorFields', () => {
await waitFor(() => {
wrapper.update();
expect(wrapper.find('[data-test-subj="connectorIndexesComboBox"]').exists()).toBeTruthy();
expect(wrapper.find('[data-test-subj="indexRefreshCheckbox"]').exists()).toBeTruthy();
expect(wrapper.find('[data-test-subj="hasTimeFieldCheckbox"]').exists()).toBeTruthy();
expect(wrapper.find('[data-test-subj="executionTimeFieldSelect"]').exists()).toBeTruthy();
});
Expand All @@ -285,9 +271,6 @@ describe('IndexActionConnectorFields', () => {
.filter('[data-test-subj="connectorIndexesComboBox"]');
expect(indexComboBox.prop('selectedOptions')).toEqual([{ label: indexName, value: indexName }]);

const refreshSwitch = wrapper.find(EuiSwitch).filter('[data-test-subj="indexRefreshCheckbox"]');
expect(refreshSwitch.prop('checked')).toEqual(false);

const timeFieldSwitch = wrapper
.find(EuiSwitch)
.filter('[data-test-subj="hasTimeFieldCheckbox"]');
Expand Down Expand Up @@ -380,8 +363,8 @@ describe('IndexActionConnectorFields', () => {
actionTypeId: '.index',
config: {
index: 'test_es_index',
refresh: false,
executionTimeField: '1',
refresh: false,
},
id: 'test',
isDeprecated: false,
Expand Down Expand Up @@ -425,7 +408,6 @@ describe('IndexActionConnectorFields', () => {
actionTypeId: '.index',
config: {
index: 'test_es_index',
refresh: false,
},
id: 'test',
isDeprecated: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ import { ToggleField, SelectField } from '@kbn/es-ui-shared-plugin/static/forms/
import { DocLinksStart } from '@kbn/core/public';
import { FormattedMessage } from '@kbn/i18n-react';
import { i18n } from '@kbn/i18n';
import type { ActionConnectorFieldsProps } from '@kbn/triggers-actions-ui-plugin/public';
import {
type ActionConnectorFieldsProps,
HiddenField,
} from '@kbn/triggers-actions-ui-plugin/public';
import {
firstFieldOption,
getFields,
Expand Down Expand Up @@ -131,6 +134,7 @@ const IndexActionConnectorFields: React.FunctionComponent<ActionConnectorFieldsP
/>
</h5>
</EuiTitle>
<HiddenField path={'config.refresh'} />
<EuiSpacer size="m" />
<UseField path="config.index" config={getIndexConfig(docLinks)}>
{(field) => {
Expand Down Expand Up @@ -214,33 +218,6 @@ const IndexActionConnectorFields: React.FunctionComponent<ActionConnectorFieldsP
}}
</UseField>
<EuiSpacer size="m" />
<UseField
path="config.refresh"
component={ToggleField}
config={{
defaultValue: false,
}}
componentProps={{
euiFieldProps: {
label: (
<>
<FormattedMessage
id="xpack.stackConnectors.components.index.refreshLabel"
defaultMessage="Refresh index"
/>{' '}
<EuiIconTip
position="right"
type="questionInCircle"
content={translations.REFRESH_FIELD_TOGGLE_TOOLTIP}
/>
</>
),
disabled: readOnly,
'data-test-subj': 'indexRefreshCheckbox',
},
}}
/>
<EuiSpacer size="m" />
{showTimeFieldCheckbox ? (
<UseField
path="__internal__.hasTimeFieldCheckbox"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@ export const SHOW_TIME_FIELD_TOGGLE_TOOLTIP = i18n.translate(
}
);

export const REFRESH_FIELD_TOGGLE_TOOLTIP = i18n.translate(
'xpack.stackConnectors.components.index.refreshTooltip',
{
defaultMessage: 'Refresh the affected shards to make this operation visible to search.',
}
);

export const INDEX_LABEL = i18n.translate(
'xpack.stackConnectors.components.index.indicesToQueryLabel',
{
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/translations/translations/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -33366,8 +33366,6 @@
"xpack.stackConnectors.components.index.jsonDocAriaLabel": "Éditeur de code",
"xpack.stackConnectors.components.index.preconfiguredIndex": "Index Elasticsearch",
"xpack.stackConnectors.components.index.preconfiguredIndexDocLink": "Affichez les documents.",
"xpack.stackConnectors.components.index.refreshLabel": "Actualiser l'index",
"xpack.stackConnectors.components.index.refreshTooltip": "Actualisez les partitions affectées pour rendre cette opération visible pour la recherche.",
"xpack.stackConnectors.components.index.resetDefaultIndexLabel": "Réinitialiser l'index par défaut",
"xpack.stackConnectors.components.index.selectMessageText": "Indexez les données dans Elasticsearch.",
"xpack.stackConnectors.components.jira.apiTokenTextFieldLabel": "Token d'API",
Expand Down
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 @@ -33345,8 +33345,6 @@
"xpack.stackConnectors.components.index.jsonDocAriaLabel": "コードエディター",
"xpack.stackConnectors.components.index.preconfiguredIndex": "Elasticsearchインデックス",
"xpack.stackConnectors.components.index.preconfiguredIndexDocLink": "ドキュメントを表示します。",
"xpack.stackConnectors.components.index.refreshLabel": "更新インデックス",
"xpack.stackConnectors.components.index.refreshTooltip": "影響を受けるシャードを更新し、この処理を検索できるようにします。",
"xpack.stackConnectors.components.index.resetDefaultIndexLabel": "デフォルトのインデックスをリセット",
"xpack.stackConnectors.components.index.selectMessageText": "データを Elasticsearch にインデックスしてください。",
"xpack.stackConnectors.components.jira.apiTokenTextFieldLabel": "APIトークン",
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 @@ -33363,8 +33363,6 @@
"xpack.stackConnectors.components.index.jsonDocAriaLabel": "代码编辑器",
"xpack.stackConnectors.components.index.preconfiguredIndex": "Elasticsearch 索引",
"xpack.stackConnectors.components.index.preconfiguredIndexDocLink": "查看文档。",
"xpack.stackConnectors.components.index.refreshLabel": "刷新索引",
"xpack.stackConnectors.components.index.refreshTooltip": "刷新影响的分片以使此操作对搜索可见。",
"xpack.stackConnectors.components.index.resetDefaultIndexLabel": "重置默认索引",
"xpack.stackConnectors.components.index.selectMessageText": "将数据索引到 Elasticsearch 中。",
"xpack.stackConnectors.components.jira.apiTokenTextFieldLabel": "API 令牌",
Expand Down