diff --git a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_index_pattern.html b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_index_pattern.html index 2df9f88abd760..8afc1837e6c7c 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_index_pattern.html +++ b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_index_pattern.html @@ -23,10 +23,7 @@
- This page lists every field in the {{::indexPattern.title}}
- index and the field's associated core type as recorded by Elasticsearch.
- While this list allows you to view the core type of each field, changing
- field types must be done using Elasticsearch's
+ This page lists every field in the {{::indexPattern.title}} index and the field's associated core type as recorded by Elasticsearch. To change a field type, use the Elasticsearch
Mapping API
@@ -145,10 +142,7 @@
class="fields indexed-fields"
>
-
+ The following deprecated languages are in use:
+ php
+ . Support for these languages will be removed in the next major version of Kibana and Elasticsearch. Convert you scripted fields to
+
+ The following deprecated languages are in use: {deprecatedLangsInUse.join(', ')}.
+ Support for these languages will be removed in the next major version of Kibana
+ and Elasticsearch. Convert you scripted fields to
+ You can use scripted fields in visualizations and display them in your documents. However, you cannot search scripted fields.
+
+ You can use scripted fields in visualizations and display them in your documents.
+ However, you cannot search scripted fields.
+
- These scripted fields are computed on the fly from your data. They can be used in visualizations and displayed in your documents, however they can not be searched. You can manage them here and add new ones as you see fit, but be careful, scripts can be tricky!
-
+
+
+
+
+ Scripted fields
+
+ Scripted fields
+ {}}
+ deleteField={() => {}}
+ onDataCriteriaChange={() => {}}
+ />
+ );
+
+ expect(component).toMatchSnapshot();
+ });
+
+ it('should render the format', async () => {
+ const component = shallow(
+
{}}
+ deleteField={() => {}}
+ onDataCriteriaChange={() => {}}
+ />
+ );
+
+ const formatTableCell = shallow(component.prop('config').columns[3].render('Elastic'));
+ expect(formatTableCell).toMatchSnapshot();
+ });
+
+ it('should allow edits', () => {
+ const editField = jest.fn();
+
+ const component = shallow(
+
{}}
+ onDataCriteriaChange={() => {}}
+ />
+ );
+
+ // Click the delete button
+ component.prop('config').columns[4].actions[0].onClick();
+ expect(editField).toBeCalled();
+ });
+
+ it('should allow deletes', () => {
+ const deleteField = jest.fn();
+
+ const component = shallow(
+
{}}
+ deleteField={deleteField}
+ onDataCriteriaChange={() => {}}
+ />
+ );
+
+ // Click the delete button
+ component.prop('config').columns[4].actions[1].onClick();
+ expect(deleteField).toBeCalled();
+ });
+
+});
diff --git a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/scripted_fields_table/components/table/index.js b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/scripted_fields_table/components/table/index.js
new file mode 100644
index 0000000000000..48232283cba67
--- /dev/null
+++ b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/scripted_fields_table/components/table/index.js
@@ -0,0 +1 @@
+export { Table } from './table';
diff --git a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/scripted_fields_table/components/table/table.js b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/scripted_fields_table/components/table/table.js
new file mode 100644
index 0000000000000..9f75c6e7874a5
--- /dev/null
+++ b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/scripted_fields_table/components/table/table.js
@@ -0,0 +1,119 @@
+import React, { PureComponent } from 'react';
+import PropTypes from 'prop-types';
+
+import {
+ EuiTableOfRecords
+} from '@elastic/eui';
+
+export class Table extends PureComponent {
+ static propTypes = {
+ indexPattern: PropTypes.object.isRequired,
+ model: PropTypes.shape({
+ data: PropTypes.shape({
+ records: PropTypes.array.isRequired,
+ totalRecordCount: PropTypes.number.isRequired,
+ }).isRequired,
+ criteria: PropTypes.shape({
+ page: PropTypes.shape({
+ index: PropTypes.number.isRequired,
+ size: PropTypes.number.isRequired,
+ }).isRequired,
+ sort: PropTypes.shape({
+ field: PropTypes.string.isRequired,
+ direction: PropTypes.string.isRequired,
+ }).isRequired,
+ }).isRequired,
+ }),
+ editField: PropTypes.func.isRequired,
+ deleteField: PropTypes.func.isRequired,
+ onDataCriteriaChange: PropTypes.func.isRequired,
+ }
+
+ renderFormatCell = (value) => {
+ const { indexPattern } = this.props;
+
+ const title = indexPattern.fieldFormatMap[value] && indexPattern.fieldFormatMap[value].type
+ ? indexPattern.fieldFormatMap[value].type.title
+ : '';
+
+ return (
+ {title}
+ );
+ }
+
+ getTableConfig() {
+ const { editField, deleteField, onDataCriteriaChange } = this.props;
+
+ return {
+ recordId: 'id',
+ columns: [
+ {
+ field: 'name',
+ name: 'Name',
+ description: `Name of the field`,
+ dataType: 'string',
+ sortable: true,
+ },
+ {
+ field: 'lang',
+ name: 'Lang',
+ description: `Language used for the field`,
+ dataType: 'string',
+ sortable: true,
+ render: value => {
+ return (
+
+ {value}
+
+ );
+ }
+ },
+ {
+ field: 'script',
+ name: 'Script',
+ description: `Script for the field`,
+ dataType: 'string',
+ sortable: true,
+ },
+ {
+ field: 'name',
+ name: 'Format',
+ description: `Format used for the field`,
+ render: this.renderFormatCell,
+ sortable: false,
+ },
+ {
+ name: '',
+ actions: [
+ {
+ name: 'Edit',
+ description: 'Edit this field',
+ icon: 'pencil',
+ onClick: editField,
+ },
+ {
+ name: 'Delete',
+ description: 'Delete this field',
+ icon: 'trash',
+ color: 'danger',
+ onClick: deleteField,
+ },
+ ]
+ }
+ ],
+ pagination: {
+ pageSizeOptions: [5, 10, 25, 50]
+ },
+ selection: undefined,
+ onDataCriteriaChange,
+ };
+ }
+
+ render() {
+ const { model } = this.props;
+
+ return (
+
- Scripted fields
-
-
- this.props.helpers.redirectToRoute(field, 'edit')}
+ deleteField={this.startDeleteField}
+ onDataCriteriaChange={this.onDataCriteriaChange}
+ />
+ : null
+ }
+ {this.renderDeleteConfirmationModal()}
+
+ );
+ }
+}