From c44c8c44c82ed80d1ae3dd990291dcc85b7a27dc Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 12 Apr 2022 05:29:19 -0500 Subject: [PATCH] [SecuritySolution] update sourcer messages (#129329) (#129984) * update wording for temporary sourcerer * update sourcer messages * add message utils * fix FormattedMessage * remove unused i18n keys Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit 6366f3738dbc8adf0aef6c93b9a1449189297c5e) Co-authored-by: Angela Chuang <6295984+angorayc@users.noreply.github.com> --- .../components/sourcerer/index.test.tsx | 40 ++++ .../common/components/sourcerer/temporary.tsx | 63 ++---- .../common/components/sourcerer/utils.tsx | 201 ++++++++++++++++++ .../translations/translations/ja-JP.json | 5 - .../translations/translations/zh-CN.json | 5 - 5 files changed, 258 insertions(+), 56 deletions(-) create mode 100644 x-pack/plugins/security_solution/public/common/components/sourcerer/utils.tsx diff --git a/x-pack/plugins/security_solution/public/common/components/sourcerer/index.test.tsx b/x-pack/plugins/security_solution/public/common/components/sourcerer/index.test.tsx index 05b24600ff9af..f7a4bd9b9e621 100644 --- a/x-pack/plugins/security_solution/public/common/components/sourcerer/index.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/sourcerer/index.test.tsx @@ -1000,6 +1000,14 @@ describe('Update available', () => { expect(wrapper.find(`[data-test-subj="sourcerer-deprecated-callout"]`).first().text()).toEqual( 'This timeline uses a legacy data view selector' ); + + expect( + wrapper.find(`[data-test-subj="sourcerer-current-patterns-message"]`).first().text() + ).toEqual('The active index patterns in this timeline are: myFakebeat-*'); + + expect(wrapper.find(`[data-test-subj="sourcerer-deprecated-message"]`).first().text()).toEqual( + "We have preserved your timeline by creating a temporary data view. If you'd like to modify your data, we can recreate your temporary data view with the new data view selector. You can also manually select a data view here." + ); }); test('Show Add index pattern in UpdateDefaultDataViewModal', () => { @@ -1103,6 +1111,10 @@ describe('Update available for timeline template', () => { expect(wrapper.find(`[data-test-subj="sourcerer-deprecated-callout"]`).first().text()).toEqual( 'This timeline template uses a legacy data view selector' ); + + expect(wrapper.find(`[data-test-subj="sourcerer-deprecated-message"]`).first().text()).toEqual( + "We have preserved your timeline template by creating a temporary data view. If you'd like to modify your data, we can recreate your temporary data view with the new data view selector. You can also manually select a data view here." + ); }); }); @@ -1179,6 +1191,20 @@ describe('Missing index patterns', () => { expect(wrapper.find(`[data-test-subj="sourcerer-deprecated-callout"]`).first().text()).toEqual( 'This timeline is out of date with the Security Data View' ); + + expect( + wrapper.find(`[data-test-subj="sourcerer-current-patterns-message"]`).first().text() + ).toEqual('The active index patterns in this timeline are: myFakebeat-*'); + + expect( + wrapper.find(`[data-test-subj="sourcerer-missing-patterns-callout"]`).first().text() + ).toEqual('Security Data View is missing the following index patterns: myFakebeat-*'); + + expect( + wrapper.find(`[data-test-subj="sourcerer-missing-patterns-message"]`).first().text() + ).toEqual( + "We have preserved your timeline by creating a temporary data view. If you'd like to modify your data, we can add the missing index patterns to the Security Data View. You can also manually select a data view here." + ); }); test('Show UpdateDefaultDataViewModal CallOut for timeline template', () => { @@ -1201,5 +1227,19 @@ describe('Missing index patterns', () => { expect(wrapper.find(`[data-test-subj="sourcerer-deprecated-callout"]`).first().text()).toEqual( 'This timeline template is out of date with the Security Data View' ); + + expect( + wrapper.find(`[data-test-subj="sourcerer-current-patterns-message"]`).first().text() + ).toEqual('The active index patterns in this timeline template are: myFakebeat-*'); + + expect( + wrapper.find(`[data-test-subj="sourcerer-missing-patterns-callout"]`).first().text() + ).toEqual('Security Data View is missing the following index patterns: myFakebeat-*'); + + expect( + wrapper.find(`[data-test-subj="sourcerer-missing-patterns-message"]`).first().text() + ).toEqual( + "We have preserved your timeline template by creating a temporary data view. If you'd like to modify your data, we can add the missing index patterns to the Security Data View. You can also manually select a data view here." + ); }); }); diff --git a/x-pack/plugins/security_solution/public/common/components/sourcerer/temporary.tsx b/x-pack/plugins/security_solution/public/common/components/sourcerer/temporary.tsx index 156d08df79d06..e4cfaea78b48d 100644 --- a/x-pack/plugins/security_solution/public/common/components/sourcerer/temporary.tsx +++ b/x-pack/plugins/security_solution/public/common/components/sourcerer/temporary.tsx @@ -8,7 +8,6 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { EuiCallOut, - EuiLink, EuiText, EuiTextColor, EuiSpacer, @@ -16,7 +15,6 @@ import { EuiFlexItem, EuiButton, EuiToolTip, - EuiIcon, } from '@elastic/eui'; import React, { useMemo } from 'react'; import * as i18n from './translations'; @@ -26,6 +24,12 @@ import { TimelineId, TimelineType } from '../../../../common/types'; import { timelineSelectors } from '../../../timelines/store/timeline'; import { useDeepEqualSelector } from '../../hooks/use_selector'; import { timelineDefaults } from '../../../timelines/store/timeline/defaults'; +import { + BadCurrentPatternsMessage, + CurrentPatternsMessage, + DeprecatedMessage, + MissingPatternsMessage, +} from './utils'; interface Props { activePatterns?: string[]; @@ -116,66 +120,33 @@ export const TemporarySourcererComp = React.memo(

{activePatterns && activePatterns.length > 0 ? ( - 0 ? ( - !activePatterns.includes(p)) - .join(', '), - }} - /> - } - > - - - ) : null, - callout:

{activePatterns.join(', ')}
, - }} + ) : ( - {selectedPatterns.join(', ')}, - }} + )} {isModified === 'deprecated' && ( - {i18n.TOGGLE_TO_NEW_SOURCERER}, - }} - /> + )} {isModified === 'missingPatterns' && ( <> {missingPatterns.join(', ')}, }} /> - {i18n.TOGGLE_TO_NEW_SOURCERER}, - }} - /> + )}

diff --git a/x-pack/plugins/security_solution/public/common/components/sourcerer/utils.tsx b/x-pack/plugins/security_solution/public/common/components/sourcerer/utils.tsx new file mode 100644 index 0000000000000..18fba2648c25e --- /dev/null +++ b/x-pack/plugins/security_solution/public/common/components/sourcerer/utils.tsx @@ -0,0 +1,201 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { EuiIcon, EuiLink, EuiToolTip } from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n-react'; +import React, { useMemo } from 'react'; +import { TimelineType } from '../../../../common/types'; +import { Blockquote } from './helpers'; +import * as i18n from './translations'; + +export const CurrentPatternsMessage = ({ + activePatterns, + deadPatterns, + selectedPatterns, + timelineType, +}: { + activePatterns: string[]; + deadPatterns: string[]; + selectedPatterns: string[]; + timelineType: TimelineType; +}) => { + const tooltip = useMemo( + () => + deadPatterns.length > 0 ? ( + + } + > + + + ) : null, + [activePatterns, deadPatterns.length, selectedPatterns, timelineType] + ); + + if (timelineType === TimelineType.template) { + return ( + {activePatterns.join(', ')}, + }} + /> + ); + } + + return ( + {activePatterns.join(', ')}, + }} + /> + ); +}; + +export const NoMatchDataMessage = ({ + activePatterns, + selectedPatterns, + timelineType, +}: { + activePatterns: string[]; + selectedPatterns: string[]; + timelineType: TimelineType; +}) => { + const aliases = useMemo( + () => selectedPatterns.filter((p) => !activePatterns.includes(p)).join(', '), + [activePatterns, selectedPatterns] + ); + if (timelineType === TimelineType.template) { + return ( + + ); + } + + return ( + + ); +}; + +export const BadCurrentPatternsMessage = ({ + timelineType, + selectedPatterns, +}: { + timelineType: TimelineType; + selectedPatterns: string[]; +}) => { + const callout = useMemo( + () =>
{selectedPatterns.join(', ')}
, + [selectedPatterns] + ); + + if (timelineType === TimelineType.template) { + return ( + + ); + } + return ( + + ); +}; + +export const DeprecatedMessage = ({ + onReset, + timelineType, +}: { + onReset: () => void; + timelineType: TimelineType; +}) => { + if (timelineType === TimelineType.template) { + return ( + {i18n.TOGGLE_TO_NEW_SOURCERER}, + }} + /> + ); + } + return ( + {i18n.TOGGLE_TO_NEW_SOURCERER}, + }} + /> + ); +}; + +export const MissingPatternsMessage = ({ + onReset, + timelineType, +}: { + timelineType: TimelineType; + onReset: () => void; +}) => { + if (timelineType === TimelineType.template) { + return ( + {i18n.TOGGLE_TO_NEW_SOURCERER}, + }} + /> + ); + } + return ( + {i18n.TOGGLE_TO_NEW_SOURCERER}, + }} + /> + ); +}; diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 6b963a4696a1a..914bce25e4c4a 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -25187,8 +25187,6 @@ "xpack.securitySolution.indexPatterns.chooseDataViewLabel": "データビューを選択", "xpack.securitySolution.indexPatterns.closeButton": "閉じる", "xpack.securitySolution.indexPatterns.continue": "追加せずに続行", - "xpack.securitySolution.indexPatterns.currentPatterns": "このタイムラインのアクティブなインデックスパターンは{tooltip}です:{callout}", - "xpack.securitySolution.indexPatterns.currentPatternsBad": "このタイムラインの現在のインデックスパターン:{callout}", "xpack.securitySolution.indexPatterns.dataViewLabel": "データビュー", "xpack.securitySolution.indexPatterns.descriptionsLabel": "これらは現在選択されているインデックスパターンです。データビューからインデックスパターンを除外すると、全体的なパフォーマンスを改善できます。", "xpack.securitySolution.indexPatterns.disabled": "このページでは無効なインデックスパターンが推奨されますが、最初にKibanaインデックスパターン設定で構成する必要があります。", @@ -25198,10 +25196,8 @@ "xpack.securitySolution.indexPatterns.indexPatternsLabel": "インデックスパターン", "xpack.securitySolution.indexPatterns.missingPatterns": "以前のタイムラインのデータビューを再作成するには、セキュリティデータビューに次のインデックスパターンがありません:{callout}", "xpack.securitySolution.indexPatterns.missingPatterns.callout": "セキュリティデータビューには次のインデックスパターンがありません:{callout}", - "xpack.securitySolution.indexPatterns.missingPatterns.description": "一時データビューを作成することで、タイムラインを保持しています。データを修正する場合は、見つからないインデックスパターンをセキュリティデータビューに追加できます。手動でデータビュー{link}を選択することもできます。", "xpack.securitySolution.indexPatterns.modifiedBadgeTitle": "変更済み", "xpack.securitySolution.indexPatterns.noData": "このタイムラインのインデックスパターンはデータストリーム、インデックス、またはインデックスエイリアスと一致しません。", - "xpack.securitySolution.indexPatterns.noMatchData": "次のインデックスパターンはこのタイムラインに保存されますが、データストリーム、インデックス、またはインデックスエイリアスと一致しません:{aliases}", "xpack.securitySolution.indexPatterns.onlyDetectionAlertsLabel": "検出アラートのみを表示", "xpack.securitySolution.indexPatterns.pickIndexPatternsCombo": "インデックスパターンを選択", "xpack.securitySolution.indexPatterns.reloadPageTitle": "ページを再読み込み", @@ -25211,7 +25207,6 @@ "xpack.securitySolution.indexPatterns.securityDefaultDataViewLabel": "セキュリティデフォルトデータビュー", "xpack.securitySolution.indexPatterns.selectDataView": "データビュー選択", "xpack.securitySolution.indexPatterns.successToastTitle": "設定を有効にするためにページの再読み込みが必要です", - "xpack.securitySolution.indexPatterns.toggleToNewSourcerer": "一時データビューを作成することで、タイムラインを保持しています。データを修正する場合は、新しいデータビューセレクターを使用して、一時データビューを再作成できます。手動でデータビュー{link}を選択することもできます。", "xpack.securitySolution.indexPatterns.toggleToNewSourcerer.link": "こちら", "xpack.securitySolution.indexPatterns.update": "データビューを更新して再作成", "xpack.securitySolution.indexPatterns.updateAvailableBadgeTitle": "更新が利用可能です", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index a8fda777b07af..7cfe04a7d91db 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -25218,8 +25218,6 @@ "xpack.securitySolution.indexPatterns.chooseDataViewLabel": "选择数据视图", "xpack.securitySolution.indexPatterns.closeButton": "关闭", "xpack.securitySolution.indexPatterns.continue": "继续,而不添加", - "xpack.securitySolution.indexPatterns.currentPatterns": "此时间线中的活动索引模式为 {tooltip}:{callout}", - "xpack.securitySolution.indexPatterns.currentPatternsBad": "此时间线中的当前索引模式为:{callout}", "xpack.securitySolution.indexPatterns.dataViewLabel": "数据视图", "xpack.securitySolution.indexPatterns.descriptionsLabel": "这些是当前选择的索引模式。从您的数据视图中筛除索引模式可帮助提高整体性能。", "xpack.securitySolution.indexPatterns.disabled": "在此页面上建议使用已禁用的索引模式,但是首先需要在 Kibana 索引模式设置中配置这些模式", @@ -25229,10 +25227,8 @@ "xpack.securitySolution.indexPatterns.indexPatternsLabel": "索引模式", "xpack.securitySolution.indexPatterns.missingPatterns": "要重新创建上一时间线的数据视图,安全数据视图缺少以下索引模式:{callout}", "xpack.securitySolution.indexPatterns.missingPatterns.callout": "安全数据视图缺少以下索引模式:{callout}", - "xpack.securitySolution.indexPatterns.missingPatterns.description": "我们已通过创建临时数据视图来保留您的时间线。如果您要修改数据,我们可以将缺失的索引模式添加到安全数据视图。您还可以手动选择数据视图 {link}。", "xpack.securitySolution.indexPatterns.modifiedBadgeTitle": "已修改", "xpack.securitySolution.indexPatterns.noData": "此时间线上的索引模式不匹配任何数据流、索引或索引别名。", - "xpack.securitySolution.indexPatterns.noMatchData": "以下索引模式已保存到此时间线,但不匹配任何数据流、索引或索引别名:{aliases}", "xpack.securitySolution.indexPatterns.onlyDetectionAlertsLabel": "仅显示检测告警", "xpack.securitySolution.indexPatterns.pickIndexPatternsCombo": "选取索引模式", "xpack.securitySolution.indexPatterns.reloadPageTitle": "重新加载页面", @@ -25242,7 +25238,6 @@ "xpack.securitySolution.indexPatterns.securityDefaultDataViewLabel": "安全默认数据视图", "xpack.securitySolution.indexPatterns.selectDataView": "数据视图选择", "xpack.securitySolution.indexPatterns.successToastTitle": "一个或多个设置需要您重新加载页面才能生效", - "xpack.securitySolution.indexPatterns.toggleToNewSourcerer": "我们已通过创建临时数据视图来保留您的时间线。如果您要修改数据,我们可以使用新的数据视图选择器重新创建临时数据视图。您还可以手动选择数据视图 {link}。", "xpack.securitySolution.indexPatterns.toggleToNewSourcerer.link": "此处", "xpack.securitySolution.indexPatterns.update": "更新并重新创建数据视图", "xpack.securitySolution.indexPatterns.updateAvailableBadgeTitle": "有可用更新",