Skip to content

Commit

Permalink
[Discover] Update mapping conflict popover with types list (elastic#1…
Browse files Browse the repository at this point in the history
…69855)

- Related to elastic#168874

## Summary

This PR updates the popover to include conflicting types list.

<img width="487" alt="Screenshot 2023-10-25 at 18 46 42"
src="https://github.com/elastic/kibana/assets/1415710/a68e5364-a784-4320-a68c-e7ba0c19d2f3">


### Checklist

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
  • Loading branch information
jughosta authored Oct 27, 2023
1 parent cb2a6e5 commit f78e062
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 15 deletions.
1 change: 1 addition & 0 deletions packages/kbn-field-utils/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface FieldBase {
timeSeriesMetric?: DataViewField['timeSeriesMetric'];
esTypes?: DataViewField['esTypes'];
scripted?: DataViewField['scripted'];
conflictDescriptions?: Record<string, string[]>;
}

export type GetCustomFieldType<T extends FieldBase> = (field: T) => FieldTypeKnown;

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 @@ -175,7 +175,10 @@ export function FieldItemButton<T extends FieldListItem = DataViewField>({
</EuiToolTip>
);

const conflictInfoIcon = field.type === 'conflict' ? <FieldConflictInfoIcon /> : null;
const conflictInfoIcon =
field.type === 'conflict' ? (
<FieldConflictInfoIcon conflictDescriptions={field.conflictDescriptions} />
) : null;

return (
<FieldButton
Expand Down Expand Up @@ -211,24 +214,35 @@ export function FieldItemButton<T extends FieldListItem = DataViewField>({
);
}

function FieldConflictInfoIcon() {
function FieldConflictInfoIcon({
conflictDescriptions,
}: {
conflictDescriptions?: Record<string, string[]>;
}) {
const types = conflictDescriptions ? Object.keys(conflictDescriptions) : [];
return (
<EuiToolTip
position="bottom"
content={i18n.translate('unifiedFieldList.fieldItemButton.mappingConflictDescription', {
defaultMessage:
'This field is defined as several types (string, integer, etc) across the indices that match this pattern.' +
'You may still be able to use this conflicting field, but it will be unavailable for functions that require Kibana to know their type. Correcting this issue will require reindexing your data.',
title={i18n.translate('unifiedFieldList.fieldItemButton.mappingConflictTitle', {
defaultMessage: 'Mapping Conflict',
})}
content={
types.length
? i18n.translate('unifiedFieldList.fieldItemButton.mappingConflictWithTypesDescription', {
defaultMessage:
'This field is defined as several types ({types}) across the indices that match this pattern. You may still be able to use this conflicting field, but it will be unavailable for functions that require Kibana to know their type. Correcting this issue will require reindexing your data.',
values: {
types: types.join(', '),
},
})
: i18n.translate('unifiedFieldList.fieldItemButton.mappingConflictDescription', {
defaultMessage:
'This field is defined as several types (string, integer, etc) across the indices that match this pattern.' +
'You may still be able to use this conflicting field, but it will be unavailable for functions that require Kibana to know their type. Correcting this issue will require reindexing your data.',
})
}
>
<EuiIcon
tabIndex={0}
type="warning"
title={i18n.translate('unifiedFieldList.fieldItemButton.mappingConflictTitle', {
defaultMessage: 'Mapping Conflict',
})}
size="s"
/>
<EuiIcon tabIndex={0} type="warning" size="s" />
</EuiToolTip>
);
}

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

1 change: 1 addition & 0 deletions src/plugins/data_views/common/field.stub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ export const stubLogstashFieldSpecMap: Record<string, FieldSpec> = {
name: 'custom_user_field',
type: 'conflict',
esTypes: ['conflict'],
conflictDescriptions: { keyword: ['index_a'], long: ['index_b'] },
aggregatable: true,
searchable: true,
count: 0,
Expand Down

0 comments on commit f78e062

Please sign in to comment.