mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Add label and icon to nested fields in the doc table (#54199)
* Apply label and icon to nested fields in the doc table * Include nested fields in the index pattern so we can identify them in the Discover UI * use color recommended by design * Fix unit tests * Update api integration test * Fix test comment Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Tim Roes <mail@timroes.de>
This commit is contained in:
parent
b9a0f958bc
commit
f77b36206a
5 changed files with 30 additions and 6 deletions
|
@ -61,6 +61,10 @@ export function getFieldTypeName(type: string) {
|
||||||
return i18n.translate('common.ui.directives.fieldNameIcons.stringFieldAriaLabel', {
|
return i18n.translate('common.ui.directives.fieldNameIcons.stringFieldAriaLabel', {
|
||||||
defaultMessage: 'String field',
|
defaultMessage: 'String field',
|
||||||
});
|
});
|
||||||
|
case 'nested':
|
||||||
|
return i18n.translate('common.ui.directives.fieldNameIcons.nestedFieldAriaLabel', {
|
||||||
|
defaultMessage: 'Nested field',
|
||||||
|
});
|
||||||
default:
|
default:
|
||||||
return i18n.translate('common.ui.directives.fieldNameIcons.unknownFieldAriaLabel', {
|
return i18n.translate('common.ui.directives.fieldNameIcons.unknownFieldAriaLabel', {
|
||||||
defaultMessage: 'Unknown field',
|
defaultMessage: 'Unknown field',
|
||||||
|
|
|
@ -37,7 +37,7 @@ describe('index_patterns/field_capabilities/field_caps_response', () => {
|
||||||
describe('conflicts', () => {
|
describe('conflicts', () => {
|
||||||
it('returns a field for each in response, no filtering', () => {
|
it('returns a field for each in response, no filtering', () => {
|
||||||
const fields = readFieldCapsResponse(esResponse);
|
const fields = readFieldCapsResponse(esResponse);
|
||||||
expect(fields).toHaveLength(24);
|
expect(fields).toHaveLength(25);
|
||||||
});
|
});
|
||||||
|
|
||||||
it(
|
it(
|
||||||
|
@ -68,8 +68,8 @@ describe('index_patterns/field_capabilities/field_caps_response', () => {
|
||||||
sandbox.spy(shouldReadFieldFromDocValuesNS, 'shouldReadFieldFromDocValues');
|
sandbox.spy(shouldReadFieldFromDocValuesNS, 'shouldReadFieldFromDocValues');
|
||||||
const fields = readFieldCapsResponse(esResponse);
|
const fields = readFieldCapsResponse(esResponse);
|
||||||
const conflictCount = fields.filter(f => f.type === 'conflict').length;
|
const conflictCount = fields.filter(f => f.type === 'conflict').length;
|
||||||
// +2 is for the object and nested fields which get filtered out of the final return value from readFieldCapsResponse
|
// +1 is for the object field which is filtered out of the final return value from readFieldCapsResponse
|
||||||
sinon.assert.callCount(shouldReadFieldFromDocValues, fields.length - conflictCount + 2);
|
sinon.assert.callCount(shouldReadFieldFromDocValues, fields.length - conflictCount + 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('converts es types to kibana types', () => {
|
it('converts es types to kibana types', () => {
|
||||||
|
@ -159,10 +159,12 @@ describe('index_patterns/field_capabilities/field_caps_response', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not include the field actually mapped as nested itself', () => {
|
it('returns the nested parent as not searchable or aggregatable', () => {
|
||||||
const fields = readFieldCapsResponse(esResponse);
|
const fields = readFieldCapsResponse(esResponse);
|
||||||
const child = fields.find(f => f.name === 'nested_object_parent');
|
const child = fields.find(f => f.name === 'nested_object_parent');
|
||||||
expect(child).toBeUndefined();
|
expect(child.type).toBe('nested');
|
||||||
|
expect(child.aggregatable).toBe(false);
|
||||||
|
expect(child.searchable).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not confuse object children for multi or nested field children', () => {
|
it('should not confuse object children for multi or nested field children', () => {
|
||||||
|
|
|
@ -195,6 +195,6 @@ export function readFieldCapsResponse(fieldCapsResponse: FieldCapsResponse): Fie
|
||||||
});
|
});
|
||||||
|
|
||||||
return kibanaFormattedCaps.filter(field => {
|
return kibanaFormattedCaps.filter(field => {
|
||||||
return !['object', 'nested'].includes(field.type);
|
return !['object'].includes(field.type);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ interface FieldIconProps {
|
||||||
| 'number'
|
| 'number'
|
||||||
| '_source'
|
| '_source'
|
||||||
| 'string'
|
| 'string'
|
||||||
|
| 'nested'
|
||||||
| string;
|
| string;
|
||||||
label?: string;
|
label?: string;
|
||||||
size?: IconSize;
|
size?: IconSize;
|
||||||
|
@ -61,6 +62,7 @@ export const typeToEuiIconMap: Partial<Record<string, IconMapEntry>> = {
|
||||||
number: { icon: 'number', color: colors[0] },
|
number: { icon: 'number', color: colors[0] },
|
||||||
_source: { icon: 'editorCodeBlock', color: colors[3] },
|
_source: { icon: 'editorCodeBlock', color: colors[3] },
|
||||||
string: { icon: 'string', color: colors[4] },
|
string: { icon: 'string', color: colors[4] },
|
||||||
|
nested: { icon: 'nested', color: colors[2] },
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -71,6 +71,14 @@ export default function({ getService }) {
|
||||||
name: 'foo',
|
name: 'foo',
|
||||||
readFromDocValues: true,
|
readFromDocValues: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
aggregatable: false,
|
||||||
|
esTypes: ['nested'],
|
||||||
|
name: 'nestedField',
|
||||||
|
readFromDocValues: false,
|
||||||
|
searchable: false,
|
||||||
|
type: 'nested',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
aggregatable: false,
|
aggregatable: false,
|
||||||
esTypes: ['keyword'],
|
esTypes: ['keyword'],
|
||||||
|
@ -153,6 +161,14 @@ export default function({ getService }) {
|
||||||
name: 'foo',
|
name: 'foo',
|
||||||
readFromDocValues: true,
|
readFromDocValues: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
aggregatable: false,
|
||||||
|
esTypes: ['nested'],
|
||||||
|
name: 'nestedField',
|
||||||
|
readFromDocValues: false,
|
||||||
|
searchable: false,
|
||||||
|
type: 'nested',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
aggregatable: false,
|
aggregatable: false,
|
||||||
esTypes: ['keyword'],
|
esTypes: ['keyword'],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue