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

Add label and icon to nested fields in the doc table #54199

Merged
merged 9 commits into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions src/legacy/ui/public/directives/field_name/field_type_name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ export function getFieldTypeName(type: string) {
return i18n.translate('common.ui.directives.fieldNameIcons.stringFieldAriaLabel', {
defaultMessage: 'String field',
});
case 'nested':
return i18n.translate('common.ui.directives.fieldNameIcons.nestedFieldAriaLabel', {
defaultMessage: 'Nested field',
});
default:
return i18n.translate('common.ui.directives.fieldNameIcons.unknownFieldAriaLabel', {
defaultMessage: 'Unknown field',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('index_patterns/field_capabilities/field_caps_response', () => {
describe('conflicts', () => {
it('returns a field for each in response, no filtering', () => {
const fields = readFieldCapsResponse(esResponse);
expect(fields).toHaveLength(24);
expect(fields).toHaveLength(25);
});

it(
Expand Down Expand Up @@ -68,8 +68,8 @@ describe('index_patterns/field_capabilities/field_caps_response', () => {
sandbox.spy(shouldReadFieldFromDocValuesNS, 'shouldReadFieldFromDocValues');
const fields = readFieldCapsResponse(esResponse);
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
sinon.assert.callCount(shouldReadFieldFromDocValues, fields.length - conflictCount + 2);
// +1 is for the object field which is filtered out of the final return value from readFieldCapsResponse
sinon.assert.callCount(shouldReadFieldFromDocValues, fields.length - conflictCount + 1);
});

it('converts es types to kibana types', () => {
Expand Down Expand Up @@ -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 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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,6 @@ export function readFieldCapsResponse(fieldCapsResponse: FieldCapsResponse): Fie
});

return kibanaFormattedCaps.filter(field => {
return !['object', 'nested'].includes(field.type);
return !['object'].includes(field.type);
});
}
2 changes: 2 additions & 0 deletions src/plugins/kibana_react/public/field_icon/field_icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ interface FieldIconProps {
| 'number'
| '_source'
| 'string'
| 'nested'
| string;
label?: string;
size?: IconSize;
Expand All @@ -61,6 +62,7 @@ export const typeToEuiIconMap: Partial<Record<string, IconMapEntry>> = {
number: { icon: 'number', color: colors[0] },
_source: { icon: 'editorCodeBlock', color: colors[3] },
string: { icon: 'string', color: colors[4] },
nested: { icon: 'nested', color: colors[2] },
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ export default function({ getService }) {
name: 'foo',
readFromDocValues: true,
},
{
aggregatable: false,
esTypes: ['nested'],
name: 'nestedField',
readFromDocValues: false,
searchable: false,
type: 'nested',
},
{
aggregatable: false,
esTypes: ['keyword'],
Expand Down Expand Up @@ -153,6 +161,14 @@ export default function({ getService }) {
name: 'foo',
readFromDocValues: true,
},
{
aggregatable: false,
esTypes: ['nested'],
name: 'nestedField',
readFromDocValues: false,
searchable: false,
type: 'nested',
},
{
aggregatable: false,
esTypes: ['keyword'],
Expand Down