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

[Data Views] Disable scripted field creation in the Data Views management page #202250

Merged
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1af7942
disable scripted field creation
mattkime Aug 15, 2024
5bb4dce
Merge branch 'main' into disable_scripted_field_creation
mattkime Sep 17, 2024
bb2ac7d
remove button, add callout, update functional tests
mattkime Sep 18, 2024
c396745
remove unused localization
mattkime Sep 18, 2024
3f3dfe8
test fixes
mattkime Sep 18, 2024
9b56eff
test fixes
mattkime Sep 18, 2024
4de4413
fix functional tests and Ãsnapshöts
mattkime Sep 18, 2024
aa5130e
add i18n
mattkime Sep 18, 2024
b5dac4d
better fallback when scripted field tab isn't available - for functio…
mattkime Sep 18, 2024
65ac465
more functional test fixes
mattkime Sep 18, 2024
4647a32
fix functional test
mattkime Sep 18, 2024
b308106
remove period from title
mattkime Sep 20, 2024
909d9c3
update snapshot
mattkime Sep 20, 2024
c3bdd04
Merge branch 'main' into disable_scripted_field_creation
mattkime Sep 28, 2024
d3ad3cf
Merge branch 'main' into davis_disable_scripted_field_creation
davismcphee Nov 29, 2024
6ee7c25
Update docs and UA copy
davismcphee Nov 29, 2024
33d3d19
Copy fixes
davismcphee Nov 29, 2024
5037ad5
Remove modified translations
davismcphee Nov 29, 2024
6b44a98
Add markdown support to ugprade assistant and updated scripted fields…
davismcphee Dec 1, 2024
662f41b
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine Dec 1, 2024
0c06115
Adjust copy
davismcphee Dec 2, 2024
b66b159
Merge branch 'main' into davis_disable_scripted_field_creation
davismcphee Dec 3, 2024
c937a94
Update docs
davismcphee Dec 3, 2024
9030958
Fix broken test
davismcphee Dec 3, 2024
7b0984c
Add upgrade notes
davismcphee Dec 3, 2024
c0b7021
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine Dec 3, 2024
9e258da
Cleanup
davismcphee Dec 3, 2024
367119a
Merge branch 'main' into davis_disable_scripted_field_creation
davismcphee Dec 3, 2024
0ab2795
Show data view name when available in UA
davismcphee Dec 4, 2024
1c10e2f
Merge branch 'main' into davis_disable_scripted_field_creation
davismcphee Dec 5, 2024
8334e46
Apply docs PR feedback
davismcphee Dec 5, 2024
cf2ff64
Merge branch 'main' into davis_disable_scripted_field_creation
davismcphee Dec 5, 2024
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
22 changes: 4 additions & 18 deletions docs/management/manage-data-views.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -192,34 +192,20 @@ doc['field_name'].value
For more information on scripted fields and additional examples, refer to
https://www.elastic.co/blog/using-painless-kibana-scripted-fields[Using Painless in {kib} scripted fields]

[float]
[[create-scripted-field]]
==== Create scripted fields

Create and add scripted fields to your data views.

. Go to the *Data Views* management page using the navigation menu or the <<kibana-navigation-search,global search field>>.

. Select the data view you want to add a scripted field to.

. Select the *Scripted fields* tab, then click *Add scripted field*.

. Enter a *Name* for the scripted field, then enter the *Script* you want to use to compute a value on the fly from your index data.

. Click *Create field*.

For more information about scripted fields in {es}, refer to {ref}/modules-scripting.html[Scripting].

[float]
[[update-scripted-field]]
==== Manage scripted fields

WARNING: The ability to create new scripted fields has been removed from the *Data Views* management page in 9.0. Existing scripted fields can still be edited or deleted, and the creation UI can be accessed by navigating directly to the `/app/management/kibana/dataViews/dataView/{dataViewId}/create-field` path, but it is recommended to migrate to runtime fields or the Elasticsearch Query Language (ES|QL) to prepare for removal.

. Go to the *Data Views* management page using the navigation menu or the <<kibana-navigation-search,global search field>>.

. Select the data view that contains the scripted field you want to manage.

. Select the *Scripted fields* tab, then open the scripted field edit options or delete the scripted field.

For more information about scripted fields in {es}, refer to {ref}/modules-scripting.html[Scripting].

WARNING: Built-in validation is unsupported for scripted fields. When your scripts contain errors, you receive
exceptions when you view the dynamically generated data.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

export type {
DeprecationDetailsMessage,
BaseDeprecationDetails,
ConfigDeprecationDetails,
FeatureDeprecationDetails,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

export interface DeprecationDetailsMessage {
type: 'markdown' | 'text';
content: string;
}

/**
* Base properties shared by all types of deprecations
*
Expand All @@ -22,7 +27,7 @@ export interface BaseDeprecationDetails {
* The description message to be displayed for the deprecation.
* Check the README for writing deprecations in `src/core/server/deprecations/README.mdx`
*/
message: string | string[];
message: string | DeprecationDetailsMessage | Array<string | DeprecationDetailsMessage>;
/**
* levels:
* - warning: will not break deployment upon upgrade
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-doc-links/src/get_doc_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ export const getDocLinks = ({ kibanaBranch, buildFlavor }: GetDocLinkOptions): D
urlDrilldownTemplateSyntax: `${KIBANA_DOCS}drilldowns.html#url-templating-language`,
urlDrilldownVariables: `${KIBANA_DOCS}drilldowns.html#url-template-variable`,
},
dataViews: {
manage: `${KIBANA_DOCS}managing-data-views.html`,
},
discover: {
guide: `${KIBANA_DOCS}discover.html`,
fieldStatistics: `${KIBANA_DOCS}show-field-statistics.html`,
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-doc-links/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ export interface DocLinks {
readonly urlDrilldownTemplateSyntax: string;
readonly urlDrilldownVariables: string;
};
readonly dataViews: {
readonly manage: string;
};
readonly discover: Record<string, string>;
readonly filebeat: {
readonly base: string;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@

import React from 'react';
import { mountWithI18nProvider } from '@kbn/test-jest-helpers';
import { RouteComponentProps } from 'react-router-dom';
import { ScopedHistory } from '@kbn/core/public';
import { scopedHistoryMock } from '@kbn/core/public/mocks';
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
import { mockManagementPlugin } from '../../../../../mocks';

Expand All @@ -20,20 +17,12 @@ import { Header } from './header';
describe('Header', () => {
const mockedContext = mockManagementPlugin.createIndexPatternManagmentContext();
test('should render normally', () => {
const component = mountWithI18nProvider(
<Header.WrappedComponent
indexPatternId="test"
history={scopedHistoryMock.create() as unknown as ScopedHistory}
location={{} as unknown as RouteComponentProps['location']}
match={{} as unknown as RouteComponentProps['match']}
/>,
{
wrappingComponent: KibanaContextProvider,
wrappingComponentProps: {
services: mockedContext,
},
}
);
const component = mountWithI18nProvider(<Header />, {
wrappingComponent: KibanaContextProvider,
wrappingComponentProps: {
services: mockedContext,
},
});

expect(component.render()).toMatchSnapshot();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,68 +8,54 @@
*/

import React from 'react';
import { withRouter, RouteComponentProps } from 'react-router-dom';
import { EuiButton, EuiFlexGroup, EuiFlexItem, EuiText, EuiLink, EuiIcon } from '@elastic/eui';
import { EuiCallOut, EuiFlexGroup, EuiFlexItem, EuiText, EuiLink } from '@elastic/eui';

import { FormattedMessage } from '@kbn/i18n-react';
import { ScopedHistory } from '@kbn/core/public';
import { i18n } from '@kbn/i18n';

import { reactRouterNavigate, useKibana } from '@kbn/kibana-react-plugin/public';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { IndexPatternManagmentContext } from '../../../../../types';

interface HeaderProps extends RouteComponentProps {
indexPatternId: string;
history: ScopedHistory;
}

export const Header = withRouter(({ indexPatternId, history }: HeaderProps) => {
const { dataViews, docLinks } = useKibana<IndexPatternManagmentContext>().services;
export const Header = () => {
const { docLinks } = useKibana<IndexPatternManagmentContext>().services;
const links = docLinks?.links;
const userEditPermission = dataViews.getCanSaveSync();
return (
<EuiFlexGroup alignItems="center">
<EuiFlexItem>
<EuiCallOut
title={i18n.translate('indexPatternManagement.editIndexPattern.deprecation.title', {
defaultMessage: 'Scripted fields are deprecated',
})}
color="warning"
iconType="warning"
>
<FormattedMessage
id="indexPatternManagement.editIndexPattern.deprecation.message"
tagName="span"
defaultMessage="Use {runtimeDocs} instead."
values={{
runtimeDocs: (
<EuiLink target="_blank" href={links.indexPatterns.runtimeFields}>
<FormattedMessage
id="indexPatternManagement.header.runtimeLink"
defaultMessage="runtime fields"
/>
</EuiLink>
),
}}
/>
</EuiCallOut>
<br />
<EuiText size="s">
<p>
<FormattedMessage
tagName="span"
id="indexPatternManagement.editIndexPattern.scriptedLabel"
defaultMessage="Scripted fields can be used in visualizations and displayed in documents. However, they cannot be searched."
/>
<br />
<EuiIcon type="warning" color="warning" style={{ marginRight: '4px' }} />
<FormattedMessage
id="indexPatternManagement.editIndexPattern.deprecation"
tagName="span"
defaultMessage="Scripted fields are deprecated. Use {runtimeDocs} instead."
values={{
runtimeDocs: (
<EuiLink target="_blank" href={links.runtimeFields.overview}>
<FormattedMessage
id="indexPatternManagement.header.runtimeLink"
defaultMessage="runtime fields"
/>
</EuiLink>
),
}}
/>
</p>
</EuiText>
</EuiFlexItem>

{userEditPermission && (
<EuiFlexItem grow={false}>
<EuiButton
data-test-subj="addScriptedFieldLink"
{...reactRouterNavigate(history, `patterns/${indexPatternId}/create-field/`)}
>
<FormattedMessage
id="indexPatternManagement.editIndexPattern.scripted.addFieldButton"
defaultMessage="Add scripted field"
/>
</EuiButton>
</EuiFlexItem>
)}
</EuiFlexGroup>
);
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class ScriptedFieldsTable extends Component<

return (
<>
<Header indexPatternId={indexPattern.id || ''} />
<Header />

<CallOuts deprecatedLangsInUse={deprecatedLangsInUse} painlessDocLink={painlessDocLink} />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ export function getTabs(
'data-test-subj': 'tab-indexedFields',
});

if (!isRollup(indexPattern.type) && scriptedFieldsEnabled) {
if (
!isRollup(indexPattern.type) &&
scriptedFieldsEnabled &&
indexPattern.getScriptedFields().length > 0
) {
tabs.push({
name: getTitle('scripted', filteredCount, totalCount),
id: TAB_SCRIPTED_FIELDS,
Expand Down
Loading