From aeaec0c64aee4f4efb68c021a37c1ba14641944b Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 20 Apr 2021 10:48:25 -0400 Subject: [PATCH] Add scripted field deprecation message (#97574) (#97625) * add scripted field deprecation msg Co-authored-by: Matthew Kime --- .../create_index_pattern_wizard.test.tsx.snap | 5 + .../header/__snapshots__/header.test.tsx.snap | 234 +++++++++++++--- .../components/header/header.test.tsx | 15 +- .../components/header/header.tsx | 81 +++--- .../header/__snapshots__/header.test.tsx.snap | 11 +- .../components/header/header.tsx | 12 +- .../warning_call_out.test.tsx.snap | 251 ++++++++++-------- .../scripting_call_outs/warning_call_out.tsx | 65 +++-- .../index_pattern_management/public/mocks.ts | 1 + .../translations/translations/ja-JP.json | 4 - .../translations/translations/zh-CN.json | 4 - 11 files changed, 442 insertions(+), 241 deletions(-) diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.tsx.snap b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.tsx.snap index 70b638d5d0b8d4..21248ac9d1dc0b 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.tsx.snap @@ -22,6 +22,7 @@ exports[`CreateIndexPatternWizard renders index pattern step when there are indi "ELASTIC_WEBSITE_URL": "htts://jestTest.elastic.co", "links": Object { "indexPatterns": Object {}, + "runtimeFields": Object {}, "scriptedFields": Object {}, }, } @@ -72,6 +73,7 @@ exports[`CreateIndexPatternWizard renders the empty state when there are no indi "ELASTIC_WEBSITE_URL": "htts://jestTest.elastic.co", "links": Object { "indexPatterns": Object {}, + "runtimeFields": Object {}, "scriptedFields": Object {}, }, } @@ -116,6 +118,7 @@ exports[`CreateIndexPatternWizard renders time field step when step is set to 2 "ELASTIC_WEBSITE_URL": "htts://jestTest.elastic.co", "links": Object { "indexPatterns": Object {}, + "runtimeFields": Object {}, "scriptedFields": Object {}, }, } @@ -160,6 +163,7 @@ exports[`CreateIndexPatternWizard renders when there are no indices but there ar "ELASTIC_WEBSITE_URL": "htts://jestTest.elastic.co", "links": Object { "indexPatterns": Object {}, + "runtimeFields": Object {}, "scriptedFields": Object {}, }, } @@ -204,6 +208,7 @@ exports[`CreateIndexPatternWizard shows system indices even if there are no othe "ELASTIC_WEBSITE_URL": "htts://jestTest.elastic.co", "links": Object { "indexPatterns": Object {}, + "runtimeFields": Object {}, "scriptedFields": Object {}, }, } diff --git a/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/components/header/__snapshots__/header.test.tsx.snap b/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/components/header/__snapshots__/header.test.tsx.snap index 5218ebd1b4ad44..e9bf6cf9002a92 100644 --- a/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/components/header/__snapshots__/header.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/components/header/__snapshots__/header.test.tsx.snap @@ -1,49 +1,205 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Header should render normally 1`] = ` -
-
-

- - Scripted fields - -

-

- - You can use scripted fields in visualizations and display them in your documents. However, you cannot search scripted fields. - -

-
-
-
- + + . + + +

+
+ +
+ + - - - Add scripted field - - - - - - + + + + + + + + + + `; diff --git a/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/components/header/header.test.tsx b/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/components/header/header.test.tsx index 3e2da10cb14735..609769690dbaea 100644 --- a/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/components/header/header.test.tsx +++ b/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/components/header/header.test.tsx @@ -7,22 +7,31 @@ */ import React from 'react'; -import { render } from 'enzyme'; +import { mount } from 'enzyme'; import { RouteComponentProps } from 'react-router-dom'; import { ScopedHistory } from 'kibana/public'; import { scopedHistoryMock } from '../../../../../../../../core/public/mocks'; +import { KibanaContextProvider } from 'src/plugins/kibana_react/public'; +import { mockManagementPlugin } from '../../../../../mocks'; import { Header } from './header'; describe('Header', () => { + const mockedContext = mockManagementPlugin.createIndexPatternManagmentContext(); test('should render normally', () => { - const component = render( + const component = mount( + />, + { + wrappingComponent: KibanaContextProvider, + wrappingComponentProps: { + services: mockedContext, + }, + } ); expect(component).toMatchSnapshot(); diff --git a/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/components/header/header.tsx b/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/components/header/header.tsx index 607f9ff804e7d2..96445b985e34c3 100644 --- a/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/components/header/header.tsx +++ b/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/components/header/header.tsx @@ -8,50 +8,61 @@ import React from 'react'; import { withRouter, RouteComponentProps } from 'react-router-dom'; -import { EuiButton, EuiFlexGroup, EuiFlexItem, EuiText, EuiTitle } from '@elastic/eui'; +import { EuiButton, EuiFlexGroup, EuiFlexItem, EuiText, EuiLink, EuiIcon } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { ScopedHistory } from 'kibana/public'; -import { reactRouterNavigate } from '../../../../../../../kibana_react/public'; +import { reactRouterNavigate, useKibana } from '../../../../../../../kibana_react/public'; +import { IndexPatternManagmentContext } from '../../../../../types'; interface HeaderProps extends RouteComponentProps { indexPatternId: string; history: ScopedHistory; } -export const Header = withRouter(({ indexPatternId, history }: HeaderProps) => ( - - - -

- -

-
- -

+export const Header = withRouter(({ indexPatternId, history }: HeaderProps) => { + const docLinks = useKibana().services.docLinks?.links; + return ( + + + +

+ +
+ + + + + ), + }} + /> +

+
+
+ + + -

- -
- - - - - - -
-)); + + + + ); +}); diff --git a/src/plugins/index_pattern_management/public/components/edit_index_pattern/source_filters_table/components/header/__snapshots__/header.test.tsx.snap b/src/plugins/index_pattern_management/public/components/edit_index_pattern/source_filters_table/components/header/__snapshots__/header.test.tsx.snap index daa8e4a1c70638..1f56e3caeaf6b6 100644 --- a/src/plugins/index_pattern_management/public/components/edit_index_pattern/source_filters_table/components/header/__snapshots__/header.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/edit_index_pattern/source_filters_table/components/header/__snapshots__/header.test.tsx.snap @@ -2,18 +2,9 @@ exports[`Header should render normally 1`] = ` - -

- -

-
-

( <> - -

- -

- - +

+ +

+

+ + + , + "scriptsInAggregation": + + , + } + } + > + + Please familiarize yourself with + + + + and + + + + before using this feature. Scripted fields can be used to display and aggregate calculated values. As such, they can be very slow and, if done incorrectly, can cause Kibana to become unusable. + + +

+
+
+ +
+ } @@ -38,12 +126,13 @@ exports[`ScriptingWarningCallOut should render normally 1`] = ` className="euiCallOutHeader__title" > - Proceed with caution + Scripted fields are deprecated. @@ -54,113 +143,57 @@ exports[`ScriptingWarningCallOut should render normally 1`] = `
-

- - -   - - , - "scriptsInAggregation": - -   - - , - } - } + +

- - Please familiarize yourself with - + + + , + } + } > - - - and with - - - - before using scripted fields. - - -

-

- - - Scripted fields can be used to display and aggregate calculated values. As such, they can be very slow, and if done incorrectly, can cause Kibana to be unusable. There's no safety net here. If you make a typo, unexpected exceptions will be thrown all over the place! - - -

+ + + . + + +

+
+
diff --git a/src/plugins/index_pattern_management/public/components/field_editor/components/scripting_call_outs/warning_call_out.tsx b/src/plugins/index_pattern_management/public/components/field_editor/components/scripting_call_outs/warning_call_out.tsx index e52136476dd03a..dc4409d35b3780 100644 --- a/src/plugins/index_pattern_management/public/components/field_editor/components/scripting_call_outs/warning_call_out.tsx +++ b/src/plugins/index_pattern_management/public/components/field_editor/components/scripting_call_outs/warning_call_out.tsx @@ -8,7 +8,7 @@ import React, { Fragment } from 'react'; -import { EuiCallOut, EuiIcon, EuiLink, EuiSpacer } from '@elastic/eui'; +import { EuiCallOut, EuiLink, EuiSpacer, EuiText } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; @@ -20,56 +20,67 @@ export interface ScriptingWarningCallOutProps { } export const ScriptingWarningCallOut = ({ isVisible = false }: ScriptingWarningCallOutProps) => { - const docLinksScriptedFields = useKibana().services.docLinks?.links - .scriptedFields; + const docLinks = useKibana().services.docLinks?.links; return isVisible ? ( - - } - color="warning" - iconType="alert" - > +

+ -   - ), scriptsInAggregation: ( - + -   - ), }} />

-

+ + + -

+ } + > + +

+ + + + ), + }} + /> +

+
diff --git a/src/plugins/index_pattern_management/public/mocks.ts b/src/plugins/index_pattern_management/public/mocks.ts index 606f9edafbca97..3462131e50463b 100644 --- a/src/plugins/index_pattern_management/public/mocks.ts +++ b/src/plugins/index_pattern_management/public/mocks.ts @@ -69,6 +69,7 @@ const docLinks = { links: { indexPatterns: {}, scriptedFields: {}, + runtimeFields: {}, } as any, }; diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 2dce2160e3ab6f..26a4958c8cb034 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -2814,7 +2814,6 @@ "indexPatternManagement.editIndexPattern.scripted.table.nameHeader": "名前", "indexPatternManagement.editIndexPattern.scripted.table.scriptDescription": "フィールドのスクリプトです", "indexPatternManagement.editIndexPattern.scripted.table.scriptHeader": "スクリプト", - "indexPatternManagement.editIndexPattern.scriptedHeader": "スクリプトフィールド", "indexPatternManagement.editIndexPattern.scriptedLabel": "ビジュアライゼーションにスクリプトフィールドを使用し、ドキュメントに表示させることができます。ただし、スクリプトフィールドは検索できません。", "indexPatternManagement.editIndexPattern.setDefaultAria": "デフォルトのインデックスに設定します。", "indexPatternManagement.editIndexPattern.setDefaultTooltip": "デフォルトのインデックスに設定します。", @@ -2832,7 +2831,6 @@ "indexPatternManagement.editIndexPattern.source.table.matchesHeader": "一致", "indexPatternManagement.editIndexPattern.source.table.notMatchedLabel": "ソースフィルターが既知のフィールドと一致しません。", "indexPatternManagement.editIndexPattern.source.table.saveAria": "保存", - "indexPatternManagement.editIndexPattern.sourceHeader": "フィールドフィルター", "indexPatternManagement.editIndexPattern.sourceLabel": "フィールドフィルターは、ドキュメントの取得時に 1 つまたは複数のフィールドを除外するのに使用される場合もあります。これは Discover アプリでのドキュメントの表示中、またはダッシュボードアプリの保存された検索の結果を表示する表で起こります。ドキュメントに大きなフィールドや重要ではないフィールドが含まれている場合、この程度の低いレベルでフィルターにより除外すると良いかもしれません。", "indexPatternManagement.editIndexPattern.sourcePlaceholder": "フィールドフィルター、ワイルドカード使用可 (例:「user*」と入力して「user」で始まるフィールドをフィルタリング) ", "indexPatternManagement.editIndexPattern.tabs.fieldsHeader": "フィールド", @@ -2910,8 +2908,6 @@ "indexPatternManagement.testScript.resultsTitle": "結果を表示", "indexPatternManagement.testScript.submitButtonLabel": "スクリプトを実行", "indexPatternManagement.typeLabel": "型", - "indexPatternManagement.warningCallOut.descriptionLabel": "計算値の表示と集約にスクリプトフィールドが使用できます。そのため非常に遅い場合があり、適切に行わないとKibanaが使用できなくなる可能性もあります。この場合安全策はありません。入力ミスがあると、あちこちに予期せぬ例外が起こります!", - "indexPatternManagement.warningCallOutHeader": "十分ご注意ください", "indexPatternManagement.warningCallOutLabel.callOutDetail": "スクリプトフィールドを使う前に、{scripFields}と{scriptsInAggregation}についてよく理解するようにしてください。", "indexPatternManagement.warningCallOutLabel.scripFieldsLink": "スクリプトフィールド", "indexPatternManagement.warningCallOutLabel.scriptsInAggregationLink": "集約におけるスクリプト", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index b8b410b4f93f93..775f84e16f78c9 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -2834,7 +2834,6 @@ "indexPatternManagement.editIndexPattern.scripted.table.nameHeader": "名称", "indexPatternManagement.editIndexPattern.scripted.table.scriptDescription": "字段的脚本", "indexPatternManagement.editIndexPattern.scripted.table.scriptHeader": "脚本", - "indexPatternManagement.editIndexPattern.scriptedHeader": "脚本字段", "indexPatternManagement.editIndexPattern.scriptedLabel": "可以在可视化中使用脚本字段,并在您的文档中显示它们。但是,您不能搜索脚本字段。", "indexPatternManagement.editIndexPattern.setDefaultAria": "设置为默认索引。", "indexPatternManagement.editIndexPattern.setDefaultTooltip": "设置为默认索引。", @@ -2852,7 +2851,6 @@ "indexPatternManagement.editIndexPattern.source.table.matchesHeader": "匹配", "indexPatternManagement.editIndexPattern.source.table.notMatchedLabel": "源筛选不匹配任何已知字段。", "indexPatternManagement.editIndexPattern.source.table.saveAria": "保存", - "indexPatternManagement.editIndexPattern.sourceHeader": "字段筛选", "indexPatternManagement.editIndexPattern.sourceLabel": "字段筛选可用于在提取文档时排除一个或多个字段。在 Discover 应用中查看文档时会使用字段筛选,表在 Dashboard 应用中显示已保存搜索的结果时也会使用字段筛选。如果您的文档含有较大或不重要的字段,则通过在此较低层级筛除这些字段可能会更好。", "indexPatternManagement.editIndexPattern.sourcePlaceholder": "字段筛选,接受通配符 (例如“user*”用于筛选以“user”开头的字段) ", "indexPatternManagement.editIndexPattern.tabs.fieldsHeader": "字段", @@ -2930,8 +2928,6 @@ "indexPatternManagement.testScript.resultsTitle": "预览结果", "indexPatternManagement.testScript.submitButtonLabel": "运行脚本", "indexPatternManagement.typeLabel": "类型", - "indexPatternManagement.warningCallOut.descriptionLabel": "脚本字段可用于显示并聚合计算值。因此,它们会很慢,如果操作不当,会导致 Kibana 不可用。此处没有安全网。如果拼写错误,则在任何地方都会引发异常!", - "indexPatternManagement.warningCallOutHeader": "谨慎操作", "indexPatternManagement.warningCallOutLabel.callOutDetail": "请先熟悉{scripFields}以及{scriptsInAggregation},然后再使用脚本字段。", "indexPatternManagement.warningCallOutLabel.scripFieldsLink": "脚本字段", "indexPatternManagement.warningCallOutLabel.scriptsInAggregationLink": "聚合中的脚本",