[index patterns] Field custom name => custom label (#83717)

* custom name => custom label
This commit is contained in:
Matthew Kime 2020-11-19 16:03:05 -06:00 committed by GitHub
parent b3c334a1d9
commit 48ac9f706e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 117 additions and 117 deletions

View file

@ -1,11 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [IFieldType](./kibana-plugin-plugins-data-public.ifieldtype.md) &gt; [customName](./kibana-plugin-plugins-data-public.ifieldtype.customname.md)
[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [IFieldType](./kibana-plugin-plugins-data-public.ifieldtype.md) &gt; [customLabel](./kibana-plugin-plugins-data-public.ifieldtype.customlabel.md)
## IFieldType.customName property
## IFieldType.customLabel property
<b>Signature:</b>
```typescript
customName?: string;
customLabel?: string;
```

View file

@ -16,7 +16,7 @@ export interface IFieldType
| --- | --- | --- |
| [aggregatable](./kibana-plugin-plugins-data-public.ifieldtype.aggregatable.md) | <code>boolean</code> | |
| [count](./kibana-plugin-plugins-data-public.ifieldtype.count.md) | <code>number</code> | |
| [customName](./kibana-plugin-plugins-data-public.ifieldtype.customname.md) | <code>string</code> | |
| [customLabel](./kibana-plugin-plugins-data-public.ifieldtype.customlabel.md) | <code>string</code> | |
| [displayName](./kibana-plugin-plugins-data-public.ifieldtype.displayname.md) | <code>string</code> | |
| [esTypes](./kibana-plugin-plugins-data-public.ifieldtype.estypes.md) | <code>string[]</code> | |
| [filterable](./kibana-plugin-plugins-data-public.ifieldtype.filterable.md) | <code>boolean</code> | |

View file

@ -9,7 +9,7 @@
```typescript
getFieldAttrs: () => {
[x: string]: {
customName: string;
customLabel: string;
};
};
```

View file

@ -27,7 +27,7 @@ export declare class IndexPattern implements IIndexPattern
| [flattenHit](./kibana-plugin-plugins-data-public.indexpattern.flattenhit.md) | | <code>(hit: Record&lt;string, any&gt;, deep?: boolean) =&gt; Record&lt;string, any&gt;</code> | |
| [formatField](./kibana-plugin-plugins-data-public.indexpattern.formatfield.md) | | <code>FormatFieldFn</code> | |
| [formatHit](./kibana-plugin-plugins-data-public.indexpattern.formathit.md) | | <code>{</code><br/><code> (hit: Record&lt;string, any&gt;, type?: string): any;</code><br/><code> formatField: FormatFieldFn;</code><br/><code> }</code> | |
| [getFieldAttrs](./kibana-plugin-plugins-data-public.indexpattern.getfieldattrs.md) | | <code>() =&gt; {</code><br/><code> [x: string]: {</code><br/><code> customName: string;</code><br/><code> };</code><br/><code> }</code> | |
| [getFieldAttrs](./kibana-plugin-plugins-data-public.indexpattern.getfieldattrs.md) | | <code>() =&gt; {</code><br/><code> [x: string]: {</code><br/><code> customLabel: string;</code><br/><code> };</code><br/><code> }</code> | |
| [getOriginalSavedObjectBody](./kibana-plugin-plugins-data-public.indexpattern.getoriginalsavedobjectbody.md) | | <code>() =&gt; {</code><br/><code> fieldAttrs?: string &#124; undefined;</code><br/><code> title?: string &#124; undefined;</code><br/><code> timeFieldName?: string &#124; undefined;</code><br/><code> intervalName?: string &#124; undefined;</code><br/><code> fields?: string &#124; undefined;</code><br/><code> sourceFilters?: string &#124; undefined;</code><br/><code> fieldFormatMap?: string &#124; undefined;</code><br/><code> typeMeta?: string &#124; undefined;</code><br/><code> type?: string &#124; undefined;</code><br/><code> }</code> | Get last saved saved object fields |
| [id](./kibana-plugin-plugins-data-public.indexpattern.id.md) | | <code>string</code> | |
| [intervalName](./kibana-plugin-plugins-data-public.indexpattern.intervalname.md) | | <code>string &#124; undefined</code> | |

View file

@ -1,13 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [IndexPatternField](./kibana-plugin-plugins-data-public.indexpatternfield.md) &gt; [customName](./kibana-plugin-plugins-data-public.indexpatternfield.customname.md)
[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [IndexPatternField](./kibana-plugin-plugins-data-public.indexpatternfield.md) &gt; [customLabel](./kibana-plugin-plugins-data-public.indexpatternfield.customlabel.md)
## IndexPatternField.customName property
## IndexPatternField.customLabel property
<b>Signature:</b>
```typescript
get customName(): string | undefined;
get customLabel(): string | undefined;
set customName(label: string | undefined);
set customLabel(customLabel: string | undefined);
```

View file

@ -23,7 +23,7 @@ export declare class IndexPatternField implements IFieldType
| [aggregatable](./kibana-plugin-plugins-data-public.indexpatternfield.aggregatable.md) | | <code>boolean</code> | |
| [conflictDescriptions](./kibana-plugin-plugins-data-public.indexpatternfield.conflictdescriptions.md) | | <code>Record&lt;string, string[]&gt; &#124; undefined</code> | Description of field type conflicts across different indices in the same index pattern |
| [count](./kibana-plugin-plugins-data-public.indexpatternfield.count.md) | | <code>number</code> | Count is used for field popularity |
| [customName](./kibana-plugin-plugins-data-public.indexpatternfield.customname.md) | | <code>string &#124; undefined</code> | |
| [customLabel](./kibana-plugin-plugins-data-public.indexpatternfield.customlabel.md) | | <code>string &#124; undefined</code> | |
| [displayName](./kibana-plugin-plugins-data-public.indexpatternfield.displayname.md) | | <code>string</code> | |
| [esTypes](./kibana-plugin-plugins-data-public.indexpatternfield.estypes.md) | | <code>string[] &#124; undefined</code> | |
| [filterable](./kibana-plugin-plugins-data-public.indexpatternfield.filterable.md) | | <code>boolean</code> | |

View file

@ -20,7 +20,7 @@ toJSON(): {
aggregatable: boolean;
readFromDocValues: boolean;
subType: import("../types").IFieldSubType | undefined;
customName: string | undefined;
customLabel: string | undefined;
};
```
<b>Returns:</b>
@ -38,6 +38,6 @@ toJSON(): {
aggregatable: boolean;
readFromDocValues: boolean;
subType: import("../types").IFieldSubType | undefined;
customName: string | undefined;
customLabel: string | undefined;
}`

View file

@ -1,11 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IFieldType](./kibana-plugin-plugins-data-server.ifieldtype.md) &gt; [customName](./kibana-plugin-plugins-data-server.ifieldtype.customname.md)
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IFieldType](./kibana-plugin-plugins-data-server.ifieldtype.md) &gt; [customLabel](./kibana-plugin-plugins-data-server.ifieldtype.customlabel.md)
## IFieldType.customName property
## IFieldType.customLabel property
<b>Signature:</b>
```typescript
customName?: string;
customLabel?: string;
```

View file

@ -16,7 +16,7 @@ export interface IFieldType
| --- | --- | --- |
| [aggregatable](./kibana-plugin-plugins-data-server.ifieldtype.aggregatable.md) | <code>boolean</code> | |
| [count](./kibana-plugin-plugins-data-server.ifieldtype.count.md) | <code>number</code> | |
| [customName](./kibana-plugin-plugins-data-server.ifieldtype.customname.md) | <code>string</code> | |
| [customLabel](./kibana-plugin-plugins-data-server.ifieldtype.customlabel.md) | <code>string</code> | |
| [displayName](./kibana-plugin-plugins-data-server.ifieldtype.displayname.md) | <code>string</code> | |
| [esTypes](./kibana-plugin-plugins-data-server.ifieldtype.estypes.md) | <code>string[]</code> | |
| [filterable](./kibana-plugin-plugins-data-server.ifieldtype.filterable.md) | <code>boolean</code> | |

View file

@ -9,7 +9,7 @@
```typescript
getFieldAttrs: () => {
[x: string]: {
customName: string;
customLabel: string;
};
};
```

View file

@ -27,7 +27,7 @@ export declare class IndexPattern implements IIndexPattern
| [flattenHit](./kibana-plugin-plugins-data-server.indexpattern.flattenhit.md) | | <code>(hit: Record&lt;string, any&gt;, deep?: boolean) =&gt; Record&lt;string, any&gt;</code> | |
| [formatField](./kibana-plugin-plugins-data-server.indexpattern.formatfield.md) | | <code>FormatFieldFn</code> | |
| [formatHit](./kibana-plugin-plugins-data-server.indexpattern.formathit.md) | | <code>{</code><br/><code> (hit: Record&lt;string, any&gt;, type?: string): any;</code><br/><code> formatField: FormatFieldFn;</code><br/><code> }</code> | |
| [getFieldAttrs](./kibana-plugin-plugins-data-server.indexpattern.getfieldattrs.md) | | <code>() =&gt; {</code><br/><code> [x: string]: {</code><br/><code> customName: string;</code><br/><code> };</code><br/><code> }</code> | |
| [getFieldAttrs](./kibana-plugin-plugins-data-server.indexpattern.getfieldattrs.md) | | <code>() =&gt; {</code><br/><code> [x: string]: {</code><br/><code> customLabel: string;</code><br/><code> };</code><br/><code> }</code> | |
| [getOriginalSavedObjectBody](./kibana-plugin-plugins-data-server.indexpattern.getoriginalsavedobjectbody.md) | | <code>() =&gt; {</code><br/><code> fieldAttrs?: string &#124; undefined;</code><br/><code> title?: string &#124; undefined;</code><br/><code> timeFieldName?: string &#124; undefined;</code><br/><code> intervalName?: string &#124; undefined;</code><br/><code> fields?: string &#124; undefined;</code><br/><code> sourceFilters?: string &#124; undefined;</code><br/><code> fieldFormatMap?: string &#124; undefined;</code><br/><code> typeMeta?: string &#124; undefined;</code><br/><code> type?: string &#124; undefined;</code><br/><code> }</code> | Get last saved saved object fields |
| [id](./kibana-plugin-plugins-data-server.indexpattern.id.md) | | <code>string</code> | |
| [intervalName](./kibana-plugin-plugins-data-server.indexpattern.intervalname.md) | | <code>string &#124; undefined</code> | |

View file

@ -47,7 +47,7 @@ Object {
],
},
"count": 1,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"text",
],

View file

@ -68,12 +68,12 @@ export class IndexPatternField implements IFieldType {
this.spec.lang = lang;
}
public get customName() {
return this.spec.customName;
public get customLabel() {
return this.spec.customLabel;
}
public set customName(label) {
this.spec.customName = label;
public set customLabel(customLabel) {
this.spec.customLabel = customLabel;
}
/**
@ -93,8 +93,8 @@ export class IndexPatternField implements IFieldType {
}
public get displayName(): string {
return this.spec.customName
? this.spec.customName
return this.spec.customLabel
? this.spec.customLabel
: this.spec.shortDotsEnable
? shortenDottedString(this.spec.name)
: this.spec.name;
@ -163,7 +163,7 @@ export class IndexPatternField implements IFieldType {
aggregatable: this.aggregatable,
readFromDocValues: this.readFromDocValues,
subType: this.subType,
customName: this.customName,
customLabel: this.customLabel,
};
}
@ -186,7 +186,7 @@ export class IndexPatternField implements IFieldType {
readFromDocValues: this.readFromDocValues,
subType: this.subType,
format: getFormatterForField ? getFormatterForField(this).toJSON() : undefined,
customName: this.customName,
customLabel: this.customLabel,
shortDotsEnable: this.spec.shortDotsEnable,
};
}

View file

@ -37,7 +37,7 @@ export interface IFieldType {
scripted?: boolean;
subType?: IFieldSubType;
displayName?: string;
customName?: string;
customLabel?: string;
format?: any;
toSpec?: (options?: { getFormatterForField?: IndexPattern['getFormatterForField'] }) => FieldSpec;
}

View file

@ -9,7 +9,7 @@ Object {
"aggregatable": true,
"conflictDescriptions": undefined,
"count": 0,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"keyword",
],
@ -33,7 +33,7 @@ Object {
"aggregatable": true,
"conflictDescriptions": undefined,
"count": 30,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"date",
],
@ -57,7 +57,7 @@ Object {
"aggregatable": true,
"conflictDescriptions": undefined,
"count": 0,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"_id",
],
@ -81,7 +81,7 @@ Object {
"aggregatable": true,
"conflictDescriptions": undefined,
"count": 0,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"_source",
],
@ -105,7 +105,7 @@ Object {
"aggregatable": true,
"conflictDescriptions": undefined,
"count": 0,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"_type",
],
@ -129,7 +129,7 @@ Object {
"aggregatable": true,
"conflictDescriptions": undefined,
"count": 0,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"geo_shape",
],
@ -153,7 +153,7 @@ Object {
"aggregatable": true,
"conflictDescriptions": undefined,
"count": 10,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"long",
],
@ -177,7 +177,7 @@ Object {
"aggregatable": true,
"conflictDescriptions": undefined,
"count": 0,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"conflict",
],
@ -201,7 +201,7 @@ Object {
"aggregatable": true,
"conflictDescriptions": undefined,
"count": 0,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"text",
],
@ -225,7 +225,7 @@ Object {
"aggregatable": true,
"conflictDescriptions": undefined,
"count": 0,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"keyword",
],
@ -253,7 +253,7 @@ Object {
"aggregatable": true,
"conflictDescriptions": undefined,
"count": 0,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"geo_point",
],
@ -277,7 +277,7 @@ Object {
"aggregatable": true,
"conflictDescriptions": undefined,
"count": 0,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"keyword",
],
@ -301,7 +301,7 @@ Object {
"aggregatable": false,
"conflictDescriptions": undefined,
"count": 0,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"murmur3",
],
@ -325,7 +325,7 @@ Object {
"aggregatable": true,
"conflictDescriptions": undefined,
"count": 0,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"ip",
],
@ -349,7 +349,7 @@ Object {
"aggregatable": true,
"conflictDescriptions": undefined,
"count": 0,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"text",
],
@ -373,7 +373,7 @@ Object {
"aggregatable": true,
"conflictDescriptions": undefined,
"count": 0,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"keyword",
],
@ -401,7 +401,7 @@ Object {
"aggregatable": true,
"conflictDescriptions": undefined,
"count": 0,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"text",
],
@ -425,7 +425,7 @@ Object {
"aggregatable": false,
"conflictDescriptions": undefined,
"count": 0,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"text",
],
@ -449,7 +449,7 @@ Object {
"aggregatable": true,
"conflictDescriptions": undefined,
"count": 0,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"integer",
],
@ -473,7 +473,7 @@ Object {
"aggregatable": true,
"conflictDescriptions": undefined,
"count": 0,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"geo_point",
],
@ -497,7 +497,7 @@ Object {
"aggregatable": true,
"conflictDescriptions": undefined,
"count": 0,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"attachment",
],
@ -521,7 +521,7 @@ Object {
"aggregatable": true,
"conflictDescriptions": undefined,
"count": 0,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"date",
],
@ -545,7 +545,7 @@ Object {
"aggregatable": true,
"conflictDescriptions": undefined,
"count": 0,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"murmur3",
],
@ -569,7 +569,7 @@ Object {
"aggregatable": true,
"conflictDescriptions": undefined,
"count": 0,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"long",
],
@ -593,7 +593,7 @@ Object {
"aggregatable": true,
"conflictDescriptions": undefined,
"count": 0,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"text",
],
@ -617,7 +617,7 @@ Object {
"aggregatable": true,
"conflictDescriptions": undefined,
"count": 20,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"boolean",
],
@ -641,7 +641,7 @@ Object {
"aggregatable": true,
"conflictDescriptions": undefined,
"count": 30,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"date",
],
@ -665,7 +665,7 @@ Object {
"aggregatable": true,
"conflictDescriptions": undefined,
"count": 0,
"customName": undefined,
"customLabel": undefined,
"esTypes": Array [
"date",
],

View file

@ -135,8 +135,8 @@ export class IndexPattern implements IIndexPattern {
const newFieldAttrs = { ...this.fieldAttrs };
this.fields.forEach((field) => {
if (field.customName) {
newFieldAttrs[field.name] = { customName: field.customName };
if (field.customLabel) {
newFieldAttrs[field.name] = { customLabel: field.customLabel };
} else {
delete newFieldAttrs[field.name];
}

View file

@ -309,7 +309,7 @@ export class IndexPatternsService {
*/
fieldArrayToMap = (fields: FieldSpec[], fieldAttrs?: FieldAttrs) =>
fields.reduce<IndexPatternFieldMap>((collector, field) => {
collector[field.name] = { ...field, customName: fieldAttrs?.[field.name]?.customName };
collector[field.name] = { ...field, customLabel: fieldAttrs?.[field.name]?.customLabel };
return collector;
}, {});

View file

@ -52,7 +52,7 @@ export interface IndexPatternAttributes {
}
export interface FieldAttrs {
[key: string]: { customName: string };
[key: string]: { customLabel: string };
}
export type OnNotification = (toastInputFields: ToastInputFields) => void;
@ -169,7 +169,7 @@ export interface FieldSpec {
readFromDocValues?: boolean;
subType?: IFieldSubType;
indexed?: boolean;
customName?: string;
customLabel?: string;
// not persisted
shortDotsEnable?: boolean;
}

View file

@ -978,7 +978,7 @@ export interface IFieldType {
// (undocumented)
count?: number;
// (undocumented)
customName?: string;
customLabel?: string;
// (undocumented)
displayName?: string;
// (undocumented)
@ -1152,7 +1152,7 @@ export class IndexPattern implements IIndexPattern {
// (undocumented)
getFieldAttrs: () => {
[x: string]: {
customName: string;
customLabel: string;
};
};
// (undocumented)
@ -1259,8 +1259,8 @@ export class IndexPatternField implements IFieldType {
get count(): number;
set count(count: number);
// (undocumented)
get customName(): string | undefined;
set customName(label: string | undefined);
get customLabel(): string | undefined;
set customLabel(customLabel: string | undefined);
// (undocumented)
get displayName(): string;
// (undocumented)
@ -1299,7 +1299,7 @@ export class IndexPatternField implements IFieldType {
aggregatable: boolean;
readFromDocValues: boolean;
subType: import("../types").IFieldSubType | undefined;
customName: string | undefined;
customLabel: string | undefined;
};
// (undocumented)
toSpec({ getFormatterForField, }?: {

View file

@ -507,7 +507,7 @@ export interface IFieldType {
// (undocumented)
count?: number;
// (undocumented)
customName?: string;
customLabel?: string;
// (undocumented)
displayName?: string;
// (undocumented)
@ -612,7 +612,7 @@ export class IndexPattern implements IIndexPattern {
// (undocumented)
getFieldAttrs: () => {
[x: string]: {
customName: string;
customLabel: string;
};
};
// (undocumented)

View file

@ -151,9 +151,9 @@ const editDescription = i18n.translate(
{ defaultMessage: 'Edit' }
);
const customNameDescription = i18n.translate(
'indexPatternManagement.editIndexPattern.fields.table.customNameTooltip',
{ defaultMessage: 'A custom name for the field.' }
const labelDescription = i18n.translate(
'indexPatternManagement.editIndexPattern.fields.table.customLabelTooltip',
{ defaultMessage: 'A custom label for the field.' }
);
interface IndexedFieldProps {
@ -197,11 +197,11 @@ export class Table extends PureComponent<IndexedFieldProps> {
/>
</span>
) : null}
{field.customName && field.customName !== field.name ? (
{field.customLabel && field.customLabel !== field.name ? (
<div>
<EuiToolTip content={customNameDescription}>
<EuiToolTip content={labelDescription}>
<EuiBadge iconType="flag" iconSide="left">
{field.customName}
{field.customLabel}
</EuiBadge>
</EuiToolTip>
</div>

View file

@ -54,15 +54,15 @@ exports[`FieldEditor should render create new scripted field correctly 1`] = `
<eui-form-row
helpText={
<FormattedMessage
defaultMessage="Set a custom name to use when this field is displayed in Discover and Visualize. Queries and filters don't currently support a custom name and will use the original field name."
id="indexPatternManagement.customNameHelpText"
defaultMessage="Set a custom label to use when this field is displayed in Discover and Visualize. Queries and filters don't currently support a custom label and will use the original field name."
id="indexPatternManagement.labelHelpText"
values={Object {}}
/>
}
label="Custom name"
label="Custom label"
>
<eui-field-text
data-test-subj="editorFieldCustomName"
data-test-subj="editorFieldCustomLabel"
onChange={[Function]}
value=""
/>
@ -294,15 +294,15 @@ exports[`FieldEditor should render edit scripted field correctly 1`] = `
<eui-form-row
helpText={
<FormattedMessage
defaultMessage="Set a custom name to use when this field is displayed in Discover and Visualize. Queries and filters don't currently support a custom name and will use the original field name."
id="indexPatternManagement.customNameHelpText"
defaultMessage="Set a custom label to use when this field is displayed in Discover and Visualize. Queries and filters don't currently support a custom label and will use the original field name."
id="indexPatternManagement.labelHelpText"
values={Object {}}
/>
}
label="Custom name"
label="Custom label"
>
<eui-field-text
data-test-subj="editorFieldCustomName"
data-test-subj="editorFieldCustomLabel"
onChange={[Function]}
placeholder="test"
value=""
@ -586,15 +586,15 @@ exports[`FieldEditor should show conflict field warning 1`] = `
<eui-form-row
helpText={
<FormattedMessage
defaultMessage="Set a custom name to use when this field is displayed in Discover and Visualize. Queries and filters don't currently support a custom name and will use the original field name."
id="indexPatternManagement.customNameHelpText"
defaultMessage="Set a custom label to use when this field is displayed in Discover and Visualize. Queries and filters don't currently support a custom label and will use the original field name."
id="indexPatternManagement.labelHelpText"
values={Object {}}
/>
}
label="Custom name"
label="Custom label"
>
<eui-field-text
data-test-subj="editorFieldCustomName"
data-test-subj="editorFieldCustomLabel"
onChange={[Function]}
placeholder="foobar"
value=""
@ -827,15 +827,15 @@ exports[`FieldEditor should show deprecated lang warning 1`] = `
<eui-form-row
helpText={
<FormattedMessage
defaultMessage="Set a custom name to use when this field is displayed in Discover and Visualize. Queries and filters don't currently support a custom name and will use the original field name."
id="indexPatternManagement.customNameHelpText"
defaultMessage="Set a custom label to use when this field is displayed in Discover and Visualize. Queries and filters don't currently support a custom label and will use the original field name."
id="indexPatternManagement.labelHelpText"
values={Object {}}
/>
}
label="Custom name"
label="Custom label"
>
<eui-field-text
data-test-subj="editorFieldCustomName"
data-test-subj="editorFieldCustomLabel"
onChange={[Function]}
placeholder="test"
value=""
@ -1200,15 +1200,15 @@ exports[`FieldEditor should show multiple type field warning with a table contai
<eui-form-row
helpText={
<FormattedMessage
defaultMessage="Set a custom name to use when this field is displayed in Discover and Visualize. Queries and filters don't currently support a custom name and will use the original field name."
id="indexPatternManagement.customNameHelpText"
defaultMessage="Set a custom label to use when this field is displayed in Discover and Visualize. Queries and filters don't currently support a custom label and will use the original field name."
id="indexPatternManagement.labelHelpText"
values={Object {}}
/>
}
label="Custom name"
label="Custom label"
>
<eui-field-text
data-test-subj="editorFieldCustomName"
data-test-subj="editorFieldCustomLabel"
onChange={[Function]}
placeholder="foobar"
value=""

View file

@ -175,13 +175,13 @@ describe('FieldEditor', () => {
expect(component).toMatchSnapshot();
});
it('should display and update a customName correctly', async () => {
it('should display and update a custom label correctly', async () => {
let testField = ({
name: 'test',
format: new Format(),
lang: undefined,
type: 'string',
customName: 'Test',
customLabel: 'Test',
} as unknown) as IndexPatternField;
fieldList.push(testField);
indexPattern.fields.getByName = (name) => {
@ -219,14 +219,14 @@ describe('FieldEditor', () => {
await new Promise((resolve) => process.nextTick(resolve));
component.update();
const input = findTestSubject(component, 'editorFieldCustomName');
const input = findTestSubject(component, 'editorFieldCustomLabel');
expect(input.props().value).toBe('Test');
input.simulate('change', { target: { value: 'new Test' } });
const saveBtn = findTestSubject(component, 'fieldSaveButton');
await saveBtn.simulate('click');
await new Promise((resolve) => process.nextTick(resolve));
expect(testField.customName).toEqual('new Test');
expect(testField.customLabel).toEqual('new Test');
});
it('should show deprecated lang warning', async () => {

View file

@ -126,7 +126,7 @@ export interface FieldEditorState {
errors?: string[];
format: any;
spec: IndexPatternField['spec'];
customName: string;
customLabel: string;
}
export interface FieldEdiorProps {
@ -167,7 +167,7 @@ export class FieldEditor extends PureComponent<FieldEdiorProps, FieldEditorState
isSaving: false,
format: props.indexPattern.getFormatterForField(spec),
spec: { ...spec },
customName: '',
customLabel: '',
};
this.supportedLangs = getSupportedScriptingLanguages();
this.deprecatedLangs = getDeprecatedScriptingLanguages();
@ -211,7 +211,7 @@ export class FieldEditor extends PureComponent<FieldEdiorProps, FieldEditorState
data.fieldFormats
),
fieldFormatId: indexPattern.getFormatterForFieldNoDefault(spec.name)?.type?.id,
customName: spec.customName || '',
customLabel: spec.customLabel || '',
fieldFormatParams: format.params(),
});
}
@ -414,27 +414,27 @@ export class FieldEditor extends PureComponent<FieldEdiorProps, FieldEditorState
);
}
renderCustomName() {
const { customName, spec } = this.state;
renderCustomLabel() {
const { customLabel, spec } = this.state;
return (
<EuiFormRow
label={i18n.translate('indexPatternManagement.customNameLabel', {
defaultMessage: 'Custom name',
label={i18n.translate('indexPatternManagement.customLabel', {
defaultMessage: 'Custom label',
})}
helpText={
<FormattedMessage
id="indexPatternManagement.customNameHelpText"
defaultMessage="Set a custom name to use when this field is displayed in Discover and Visualize. Queries and filters don't currently support a custom name and will use the original field name."
id="indexPatternManagement.labelHelpText"
defaultMessage="Set a custom label to use when this field is displayed in Discover and Visualize. Queries and filters don't currently support a custom label and will use the original field name."
/>
}
>
<EuiFieldText
value={customName || ''}
value={customLabel || ''}
placeholder={spec.name}
data-test-subj="editorFieldCustomName"
data-test-subj="editorFieldCustomLabel"
onChange={(e) => {
this.setState({ customName: e.target.value });
this.setState({ customLabel: e.target.value });
}}
/>
</EuiFormRow>
@ -802,7 +802,7 @@ export class FieldEditor extends PureComponent<FieldEdiorProps, FieldEditorState
saveField = async () => {
const field = this.state.spec;
const { indexPattern } = this.props;
const { fieldFormatId, fieldFormatParams, customName } = this.state;
const { fieldFormatId, fieldFormatParams, customLabel } = this.state;
if (field.scripted) {
this.setState({
@ -843,8 +843,8 @@ export class FieldEditor extends PureComponent<FieldEdiorProps, FieldEditorState
indexPattern.deleteFieldFormat(field.name);
}
if (field.customName !== customName) {
field.customName = customName;
if (field.customLabel !== customLabel) {
field.customLabel = customLabel;
indexPattern.fields.update(field);
}
@ -908,7 +908,7 @@ export class FieldEditor extends PureComponent<FieldEdiorProps, FieldEditorState
<EuiForm>
{this.renderScriptingPanels()}
{this.renderName()}
{this.renderCustomName()}
{this.renderCustomLabel()}
{this.renderLanguage()}
{this.renderType()}
{this.renderTypeConflict()}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long